diff --git a/xwords4/franklin/.cvsignore b/xwords4/franklin/.cvsignore deleted file mode 100644 index 00859fdbe..000000000 --- a/xwords4/franklin/.cvsignore +++ /dev/null @@ -1,23 +0,0 @@ -xwords4.seb -xwords4_sa.coff -xwords4_sa.link -xwords4_sa.map -xwords4_sa.seg -xwords4_sa.sym -xwords4.chk -xwords4.coff -xwords4.fxe -xwords4.icn -xwords4.link -xwords4.map -bmps_includes.h -lib.snk32 -libraries.link -os.cmd -sGDB -GDB -xwords4.mp -xwords4.seg -xwords4.sym -xwords4_sa -xwords4 \ No newline at end of file diff --git a/xwords4/franklin/LocalizedStrIncludes.h b/xwords4/franklin/LocalizedStrIncludes.h deleted file mode 100644 index 3c4f412aa..000000000 --- a/xwords4/franklin/LocalizedStrIncludes.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 1997 - 2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -/* - * For faking out franklin compiler for now. - */ - -enum { - STRD_REMAINING_TILES_ADD, - STRD_UNUSED_TILES_SUB, - STR_COMMIT_CONFIRM, - STR_BONUS_ALL, - STRD_TURN_SCORE, - STR_NONLOCAL_NAME, - STR_LOCAL_NAME, - STRD_TIME_PENALTY_SUB, - - STRD_CUMULATIVE_SCORE, - STRS_TRAY_AT_START, - STRS_MOVE_DOWN, - STRS_MOVE_ACROSS, - STRS_NEW_TILES, - STRSS_TRADED_FOR, - STR_PASS, - STR_PHONY_REJECTED, - STRD_ROBOT_TRADED, - STR_ROBOT_MOVED, - STR_REMOTE_MOVED, - - STRD_TRADED, - STRSD_SUMMARYSCORED, - STR_PASSED, - STR_LOSTTURN, - - STRS_VALUES_HEADER, - - STR_LAST -}; diff --git a/xwords4/franklin/Makefile b/xwords4/franklin/Makefile deleted file mode 100644 index c91e2ad53..000000000 --- a/xwords4/franklin/Makefile +++ /dev/null @@ -1,166 +0,0 @@ -# -*- mode: Makefile; compile-command: "make -k ARCH=i686"; -*- -# ©2001 Franklin Electronic Publishers, Inc. Burlington, NJ. -# File: gui/test/Makefile -# -PLATFORM = franklin -COMMON = ../common - -ifndef ARCH -$(error "Franklin builds require the environment variable ARCH. ") -endif - -XW_DEFINES = -DPLATFORM_EBOOK -DPOINTER_SUPPORT -DKEY_SUPPORT -DSHOW_PROGRESS \ - -DXWFEATURE_STANDALONE_ONLY -DFEATURE_TRAY_EDIT -DXWFEATURE_SEARCHLIMIT \ - -DNODE_CAN_4 -DUSE_PATTERNS -D__LITTLE_ENDIAN -include ../common/config.mk - -APPNAME = xwords4 - -# Define the list of source files -SRCS_CPP = frankdraw.cpp \ - frankmain.cpp \ - franksavedgames.cpp \ - frankask.cpp \ - frankgamesdb.cpp \ - frankpasswd.cpp \ - frankshowtext.cpp \ - frankdict.cpp \ - frankletter.cpp \ - frankplayer.cpp \ - frankdlist.cpp - -SRCS_C = -SRCS_S = - -# Program parameters (ebo_locate needs 12K of stack) -#HEAPSPACE = 98304 -HEAPSPACE = 409600 # 0x64000 -MAINSTACKSPACE = 16384 -TIMERSTACKSPACE = 4096 - -# Environment: Use "yes" or "no" -GUI_LOCAL_COPY = no -OS_LOCAL_COPY = no -LANG_LOCAL_COPY = no -GUI_LANGUAGE = GUI_Amr.pkg -OS_BASEDIR = ../../../os -GUI_BASEDIR = ../source - -#To prevent warnings from stopping the compilation, change the following line -#to "ERROR=" or start the make using "make ERROR=". -ERROR = -Werror - -OBJS = ${COMMONOBJ} - -# Include the standard Makefile targets -ifeq (x$(EBSDK_LIBS)x,xx) -# Normal: binary release version - include ${EBOOKMAN_SDK}/ebsdk.uses - include ${ESDK_TARGET_INC}/Makefile.GUI -else -# Special: building the SDK - include ${EBSDK_LIBS}/ebookman_libs.uses - include ../source/Makefile.GUI -endif - - -# -# At this point in the Makefile, you can put overrides for variables that -# were set in "Makefile.GUI". -# - -#Create linkable version of VoiceAge file -#${OBJDIR}/objects.link: welcome.voiceage - -#welcome.voiceage: welcome.seb -# tail -c+4097 welcome.voiceage - -#CLEANLIST += welcome.voiceage - - -#Need this for an os1 link of a program that uses floating-point -#GCC_LIB = ${ESDK_LIBGCC_INSTALL_LIBFILE_FLOAT} - -INCFLAGS += -I$(COMMON) -I../relay -I./ -CFLAGS += ${XW_DEFINES} -DCPLUS -CFL_NOCPLUS = $(subst -DCPLUS,,${CFLAGS}) - -CLEANLIST += ${COMMONOBJ} - -# dependencies for image generation -BMPS = ./bmps -frankmain.cpp: bmps_includes.h - -$(BMPS)/%.cpp: $(BMPS)/%.pbitm - ./pbitm2frank.pl $< $* > $@ - -GENIMGS = $(BMPS)/flip.cpp \ - $(BMPS)/lightbulb.cpp \ - $(BMPS)/valuebutton.cpp \ - $(BMPS)/undo.cpp \ - -# listing the .cpp files here as dependencies should be all that's -# needed to get them generated. -bmps_includes.h: $(GENIMGS) - @echo "/* This file generated in Makefile; do not edit!!! */" > $@ - for f in $^; do echo "#include \"$$f\"" >> $@; done - - - -# -# Generic rules for invoking the compiler and assembler. Stolen from -# Makefile.GUI -# - -${COMMONOBJDIR}/%.s :: ${COMMON}/%.c - ${ESDK_GCC32_EXE} -b sneak32 -g $(CFL_NOCPLUS) -mclist -S -o $@ -c $< - -${COMMONOBJDIR}/%.i :: ${COMMON}/%.c - ${ESDK_GCC32_EXE} -b sneak32 -g $(CFL_NOCPLUS) -mclist -E -o $@ -c $< - -${COMMONOBJDIR}/%.i :: ${COMMON}/%.cpp - ${ESDK_GXX32_EXE} -b sneak32 -g $(CFLAGS) -mclist -E -o $@ -c $< - -${COMMONOBJDIR}/%.s :: ${COMMON}/%.cpp - ${ESDK_GXX32_EXE} -b sneak32 -g $(CFLAGS) -mclist -S -o $@ -c $< - -${COMMONOBJDIR}/%.o :: ${COMMON}/%.cpp - ${ESDK_GXX32_EXE} -b sneak32 -g $(CFLAGS) -o $@ -c $< - -${COMMONOBJDIR}/%.o :: ${COMMON}/%.c - ${ESDK_GCC32_EXE} -b sneak32 -g $(CFL_NOCPLUS) -o $@ -c $< - -${COMMONOBJDIR}/%.o :: ${COMMONOBJDIR}/%.s - ${ESDK_ASM32_EXE} -case ${INCFLAGS} -po ${COMMONOBJDIR} -o $< - -# Targets to allow build without copying lots of files in. First has -# hack to force directory creation -os.link os.def standalone.link: - mkdir -p ../common/franklin - ln -s $$(find $${EBOOKMAN_SDK} -follow -name $@ | grep gui) $@ - -# get rid of the welcome crap -libraries.link: - cat $$(find $${EBOOKMAN_SDK} -follow -name $@ | grep gui) | \ - grep -v Welcome > $@ - - - -# -# The following targets are usable only during SDK creation. They are for -# copying this directory to samples/gui/test. -# - -build: os sa - -configure: - -do_install_out: build - mkdir -p ${ELIB_GUI_INSTALL_SAMPLE_TESTDIR} - (tar cf - . | (cd ${ELIB_GUI_INSTALL_SAMPLE_TESTDIR} && tar xf -)) - -memdebug: - $(MAKE) "XW_DEFINES = ${XW_DEFINES} -DMEM_DEBUG -DDEBUG" - -test: - echo ${OBJS} diff --git a/xwords4/franklin/README.txt b/xwords4/franklin/README.txt deleted file mode 100644 index cdcafac37..000000000 --- a/xwords4/franklin/README.txt +++ /dev/null @@ -1,56 +0,0 @@ -This file describes how to build Crosswords for Franklin's eBookman. - -It should be possible to do eBookman development on either Windows -(with cygwin) or Linux, but I've only done it on Linux, so that's what -I'll describe. I expect it's not much different on Windows once -cygwin's installed. - -You can get the SDK, and instructions for installing it, here: -http://download.franklin.com/franklin/ebookman/developer/ - -There are two environment variables you'll need to build for eBookman. -Add these to your shell startup script. Here's mine (for bash): - -export ARCH=i686 -export EBOOKMAN_SDK=/home/ehouse/franklin/SDK - -You can build either for the simulator/debugger, or to run on a -device. For the simulator, type at a commandline in this directory: - -# make memdebug - -or - -# make - -Provided you have a copy of BasEnglish2to8.xwd in this directory, you -can then run Crosswords in the simulator by typing: - -# ./sGDB - -(To run with additional dictionaries, edit initial.mom.) - -The command ./GDB is also available. The difference is that the -former is much faster and launches you directly into Crosswords, while -the latter launches the device's App Picker screen, allowing you to -launch Crosswords the way an end-user would. sGDB is what I use 95% -of the time. - -(The simulator is a bit rough. Not all of the buttons work, etc. To -at least get started, wait for the two windows to come up. Go to the -one titled "Source Window", and choose "Continue" on the "Control" -menu. That'll get Crosswords running.) - -To build a .seb file you can install on a device, type - -# make xwords4.seb - -Install this on an eBookman together with at least one dictionary -(e.g. BasEnglish2to8.seb) and you're good to go. - -****************** - -On debugging: I've never had much luck with the source-level debugger -in the eBookman SDK. I use XP_DEBUGF statements a lot, and do common -code development on the Linux port where debugging's better. If you're -using cygwin on Windows you may have better luck. diff --git a/xwords4/franklin/bmps/.cvsignore b/xwords4/franklin/bmps/.cvsignore deleted file mode 100644 index d1a8a81f2..000000000 --- a/xwords4/franklin/bmps/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -flip.cpp -lightbulb.cpp -undo.cpp -valuebutton.cpp diff --git a/xwords4/franklin/bmps/flip.pbitm b/xwords4/franklin/bmps/flip.pbitm deleted file mode 100644 index 9118656f8..000000000 --- a/xwords4/franklin/bmps/flip.pbitm +++ /dev/null @@ -1,12 +0,0 @@ -############ -#-########## -#--######### -#---######## -#----####### -#-----###### -#------##### -#-------#### -#--------### -#---------## -#----------# -############ diff --git a/xwords4/franklin/bmps/lightbulb.pbitm b/xwords4/franklin/bmps/lightbulb.pbitm deleted file mode 100644 index fab145196..000000000 --- a/xwords4/franklin/bmps/lightbulb.pbitm +++ /dev/null @@ -1,11 +0,0 @@ -############ -#-###--###-# -####-##-#### -###-####-### -#-#-####-#-# -####-##-#### -####-##-#### -##-##--##-## -#-###--###-# -#####--##### -############ \ No newline at end of file diff --git a/xwords4/franklin/bmps/undo.pbitm b/xwords4/franklin/bmps/undo.pbitm deleted file mode 100644 index 9045477a8..000000000 --- a/xwords4/franklin/bmps/undo.pbitm +++ /dev/null @@ -1,11 +0,0 @@ -############ -#####-###### -####--###### -###---###### -##--------## -#---------## -##--------## -###---###### -####--###### -#####-###### -############ diff --git a/xwords4/franklin/bmps/valuebutton.pbitm b/xwords4/franklin/bmps/valuebutton.pbitm deleted file mode 100644 index 7767bc67a..000000000 --- a/xwords4/franklin/bmps/valuebutton.pbitm +++ /dev/null @@ -1,12 +0,0 @@ -############ -##--######-# -###-#####-## -###-####-### -###-###-#### -##---#-##### -#####-#---## -####-#-###-# -###-##-----# -##-###-###-# -#-####-###-# -############ diff --git a/xwords4/franklin/frankask.cpp b/xwords4/franklin/frankask.cpp deleted file mode 100644 index ca0f9bf1c..000000000 --- a/xwords4/franklin/frankask.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -#if 0 -#include -#include -#include -#include -#include -#include "sys.h" -#include "gui.h" -#include "OpenDatabases.h" -#include "ebm_object.h" - -extern "C" { -#include "xptypes.h" -#include "board.h" -#include "model.h" -} - -#include "frankids.h" -#include "frankask.h" - -#define FIRST_BUTTON_ID 2000 - -CAskDialog::CAskDialog( U16* resultP, char* question, U16 numButtons, ... ) - : CWindow( ASK_WINDOW_ID, 2, 50, 196, 80, "Question..." ) -{ - U16 i; - va_list ap; - - this->resultP = resultP; - this->question = question; - this->drawInProgress = FALSE; - - U16 horSpacing = 196 / (numButtons+1); - - va_start(ap, numButtons); - for ( i = 0; i < numButtons; ++i ) { - char* buttName = va_arg( ap, char*); - XP_DEBUGF( "button %d's title is %s\n", i, buttName ); - CButton* button = new CButton( i+FIRST_BUTTON_ID, 0, 0, buttName ); - - U16 width = button->GetWidth(); - U16 bx = horSpacing * (i+1); - this->AddChild( button, bx - (width/2), 40 ); - } - va_end(ap); - - - this->textY = 10; - this->textX = 5; -} // CAskDialog::CAskDialog - -void -CAskDialog::Draw() -{ - if ( !this->drawInProgress ) { - - this->drawInProgress = TRUE; - - CWindow::Draw(); // buttons, etc. - - this->DrawText( this->question, this->textX, this->textY ); - - this->drawInProgress = FALSE; - } -} // CAskDialog::Draw - -S32 -CAskDialog::MsgHandler( MSG_TYPE type, CViewable *object, S32 data ) -{ - S32 result = 0; - S16 id; - - switch (type) { - case MSG_BUTTON_SELECT: - id = object->GetID(); - *this->resultP = id - FIRST_BUTTON_ID; - this->Close(); - result = 1; - default: - break; - } - - if ( result == 0 ) { - result = CWindow::MsgHandler( type, object, data ); - } - return result; -} // CGamesBrowserWindow::MsgHandler - -#endif /* 0 */ diff --git a/xwords4/franklin/frankask.h b/xwords4/franklin/frankask.h deleted file mode 100644 index 9999ce98c..000000000 --- a/xwords4/franklin/frankask.h +++ /dev/null @@ -1,40 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ -#if 0 -#ifndef _FRANKASK_H_ -#define _FRANKASK_H_ - -class CAskDialog : public CWindow { - - private: - U16* resultP; - U16 textY; - U16 textX; - char* question; - BOOL drawInProgress; - - public: - CAskDialog( U16* resultP, char* question, U16 numButtons, ...); - void Draw(); - S32 MsgHandler( MSG_TYPE type, CViewable *object, S32 data ); -}; - - -#endif -#endif /* 0 */ diff --git a/xwords4/franklin/frankdict.cpp b/xwords4/franklin/frankdict.cpp deleted file mode 100644 index 4e9a32de3..000000000 --- a/xwords4/franklin/frankdict.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 1997-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 - -#include "dictnryp.h" -#include "frankdict.h" -#include "frankids.h" - -#ifdef CPLUS -extern "C" { -#endif - -typedef struct FrankDictionaryCtxt { - DictionaryCtxt super; - - void* base; - size_t dictSize; - BOOL isMMC; /* means the base must be free()d */ -} FrankDictionaryCtxt; - -static void frank_dictionary_destroy( DictionaryCtxt* dict ); -static void loadSpecialData( FrankDictionaryCtxt* ctxt, U8** ptr ); -static U16 countSpecials( FrankDictionaryCtxt* ctxt ); -static int tryLoadMMCFile( MPFORMAL XP_UCHAR* dictName, U8** ptrP, - size_t* size ); -static U32 ntohl_noalign(U8* n); -static U16 ntohs_noalign(U8** n); - -U16 -GetDictFlags( ebo_enumerator_t* eboe, FileLoc loc ) -{ - U16 flags = FRANK_DICT_FLAGS_ERROR; - U16 tmp; - - if ( loc == IN_RAM ) { - ebo_name_t* name = &eboe->name; - size_t size = EBO_BLK_SIZE; - U8* ptr = (U8*)OS_availaddr + FLAGS_CHECK_OFFSET; -#ifdef DEBUG - int result = -#endif - ebo_mapin( name, 0, (void*)ptr, &size, 0 ); - XP_ASSERT( result >= 0 ); - - tmp = *(U16*)ptr; - (void)ebo_unmap( ptr, size ); - - } else if ( loc == ON_MMC ) { -#ifdef DEBUG - long read = -#endif - ebo_iread( eboe->index, &tmp, 0, sizeof(tmp) ); - XP_ASSERT( read == sizeof(tmp) ); - } - - XP_DEBUGF( "raw value: 0x%x", tmp ); -#if BYTE_ORDER==LITTLE_ENDIAN - ((char*)&flags)[0] = ((char*)&tmp)[1]; - ((char*)&flags)[1] = ((char*)&tmp)[0]; -#else - flags = tmp; -#endif - - XP_DEBUGF( "GetDictFlags returning 0x%x", flags ); - return flags; -} /* GetDictFlags */ - -DictionaryCtxt* -frank_dictionary_make( MPFORMAL XP_UCHAR* dictName ) -{ - FrankDictionaryCtxt* ctxt = (FrankDictionaryCtxt*)NULL; - - ctxt = (FrankDictionaryCtxt*)XP_MALLOC(mpool, sizeof(*ctxt)); - XP_MEMSET( ctxt, 0, sizeof(*ctxt) ); - - dict_super_init( (DictionaryCtxt*)ctxt ); - - MPASSIGN( ctxt->super.mpool, mpool ); - - if ( !!dictName ) { - ebo_enumerator_t eboe; - - XP_MEMSET( &eboe.name, 0, sizeof(eboe.name) ); - - U8* ptr = (U8*)OS_availaddr + DICT_OFFSET; - size_t size = EBO_BLK_SIZE * 75; /* PENDING(ehouse) how to find size - of file */ - strcpy( (char*)eboe.name.name, (char*)dictName ); - strcpy( eboe.name.publisher, PUB_ERICHOUSE ); - strcpy( eboe.name.extension, EXT_XWORDSDICT ); - XP_DEBUGF( "makedict: looking for %s.%s\n", dictName, - &eboe.name.extension ); - int result = ebo_mapin( &eboe.name, 0, (void*)ptr, &size, 0 ); - XP_DEBUGF( "ebo_mapin returned %d; size=%d\n", result, size ); - - int flags; - if ( result >= 0 ) { - flags = GetDictFlags( &eboe, IN_RAM ); - if ( flags != 0x0001 && flags != 0x0002 && flags != 0x0003 ) { - result = -1; - } - } - - if ( result < 0 ) { - result = tryLoadMMCFile( MPPARM(mpool) dictName, &ptr, &size ); - if ( result >= 0 ) { - ctxt->isMMC = true; - } - } - - if ( result >= 0 ) { - XP_U16 numFaces; - XP_U16 facesSize; - XP_U16 charSize; - - /* save for later */ - ctxt->base = (void*)ptr; - ctxt->dictSize = size; - - ctxt->super.destructor = frank_dictionary_destroy; - - U16 flags = ntohs_noalign( &ptr ); - if ( flags == 0x0001 ) { - charSize = 1; - ctxt->super.nodeSize = 3; - } else if ( flags == 0x0002 ) { - charSize = 2; - ctxt->super.nodeSize = 3; - } else if ( flags == 0x0003 ) { - charSize = 2; - ctxt->super.nodeSize = 4; - } else { - XP_ASSERT( XP_FALSE ); - charSize = 0; /* shut up compiler */ - } - - ctxt->super.nFaces = numFaces = *ptr++; - XP_DEBUGF( "read %d faces from dict\n", numFaces ); - - facesSize = numFaces * sizeof(ctxt->super.faces16[0]); - ctxt->super.faces16 = (XP_U16*)XP_MALLOC( mpool, facesSize ); - XP_MEMSET( ctxt->super.faces16, 0, facesSize ); - - for ( XP_U16 i = 0; i < numFaces; ++i ) { - if ( charSize == 2 ) { - ++ptr; /* skip the extra byte; screw unicode for - now. :-) */ - } - ctxt->super.faces16[i] = *ptr++; - } - - ctxt->super.countsAndValues = - (XP_U8*)XP_MALLOC(mpool, numFaces*2); - - ptr += 2; /* skip xloc header */ - for ( U16 i = 0; i < numFaces*2; i += 2 ) { - ctxt->super.countsAndValues[i] = *ptr++; - ctxt->super.countsAndValues[i+1] = *ptr++; - } - - loadSpecialData( ctxt, &ptr ); - - U32 topOffset = ntohl_noalign( ptr ); - ptr += sizeof(topOffset); - XP_DEBUGF( "incremented ptr by startOffset: %ld", topOffset ); - - ctxt->super.topEdge = ptr + topOffset; - ctxt->super.base = ptr; - -#ifdef DEBUG - XP_U32 dictLength = size - (ptr - ((U8*)ctxt->base)); - /* Can't do this because size is a multiple of 0x1000 created - during the memory-mapping process. Need to figure out how to - get the actual size if it ever matter. */ -/* XP_ASSERT( (dictLength % 3) == 0 ); */ - ctxt->super.numEdges = dictLength / 3; -#endif - } - - setBlankTile( (DictionaryCtxt*)ctxt ); - - ctxt->super.name = frankCopyStr(MPPARM(mpool) dictName); - } - return (DictionaryCtxt*)ctxt; -} // frank_dictionary_make - -static int -tryLoadMMCFile( MPFORMAL XP_UCHAR* dictName, U8** ptrP, size_t* size ) -{ - int result; - ebo_enumerator_t eboe; - - for ( result = ebo_first_xobject( &eboe ); - result == EBO_OK; - result = ebo_next_xobject( &eboe ) ) { - U16 flags; - - if ( strcmp( eboe.name.publisher, PUB_ERICHOUSE ) == 0 - && strcmp( eboe.name.extension, EXT_XWORDSDICT ) == 0 - && strcmp( eboe.name.name, (char*)dictName ) == 0 - && ( ((flags = GetDictFlags(&eboe, ON_MMC)) == 0x0001) - || (flags == 0x0002) - || (flags == 0x0003) ) ) { - - XP_DEBUGF( "looking to allocate %ld bytes", eboe.size ); - - void* buf = (void*)XP_MALLOC( mpool, eboe.size ); - long read = ebo_iread (eboe.index, buf, 0, eboe.size ); - if ( read != (long)eboe.size ) { - XP_FREE( mpool, buf ); - result = -1; - } else { - *ptrP = (U8*)buf; - *size = eboe.size; - } - break; - } - } - return result; -} /* tryLoadMMCFile */ - -static U32 -ntohl_noalign( U8* np ) -{ - union { - U32 num; - unsigned char aschars[4]; - } u; - S16 i; - -#if BYTE_ORDER==LITTLE_ENDIAN - for ( i = 3; i >= 0; --i ) { - u.aschars[i] = *np++; - } -#else - for ( i = 0; i < 4; ++i ) { - u.aschars[i] = *np++; - } -#endif - XP_DEBUGF( "ntohl_noalign returning %ld", u.num ); - return u.num; -} /* ntohl_noalign */ - -static U16 -ntohs_noalign( U8** p ) -{ - U8* np = *p; - union { - U16 num; - unsigned char aschars[2]; - } u; - S16 i; - -#if BYTE_ORDER==LITTLE_ENDIAN - for ( i = 1; i >= 0; --i ) { - u.aschars[i] = *np++; - } -#else - for ( i = 0; i < 2; ++i ) { - u.aschars[i] = *np++; - } -#endif - XP_DEBUGF( "ntohl_noalign returning %ld", u.num ); - *p = np; - return u.num; -} /* */ - -static U16 -countSpecials( FrankDictionaryCtxt* ctxt ) -{ - U16 result = 0; - - for ( U16 i = 0; i < ctxt->super.nFaces; ++i ) { - if ( IS_SPECIAL(ctxt->super.faces16[i] ) ) { - ++result; - } - } - - return result; -} /* countSpecials */ - -static XP_Bitmap* -makeBitmap( FrankDictionaryCtxt* ctxt, U8** ptrp ) -{ - U8* ptr = *ptrp; - IMAGE* bitmap = (IMAGE*)NULL; - U8 nCols = *ptr++; - - if ( nCols > 0 ) { - U8 nRows = *ptr++; - U16 rowBytes = (nCols+7) / 8; - - bitmap = (IMAGE*)XP_MALLOC( ctxt->super.mpool, - sizeof(IMAGE) + (nRows * rowBytes) ); - bitmap->img_width = nCols; - bitmap->img_height = nRows; - bitmap->img_rowbytes = rowBytes; - bitmap->img_colmode = COLOR_MODE_MONO; - bitmap->img_palette = (COLOR*)NULL; - U8* dest = ((U8*)&bitmap->img_buffer) + sizeof(bitmap->img_buffer); - bitmap->img_buffer = dest; - - U8 srcByte = 0, destByte = 0; - U8 nBits = nRows*nCols; - for ( U16 i = 0; i < nBits; ++i ) { - U8 srcBitIndex = i % 8; - U8 destBitIndex = (i % nCols) % 8; - - if ( srcBitIndex == 0 ) { - srcByte = *ptr++; - } - - U8 srcMask = 1 << (7 - srcBitIndex); - U8 bit = (srcByte & srcMask) != 0; - destByte |= bit << (7 - destBitIndex); - - /* we need to put the byte if we've filled it or if we're done - with the row */ - if ( (destBitIndex==7) || ((i%nCols) == (nCols-1)) ) { - *dest++ = destByte; - destByte = 0; - } - } - } - - *ptrp = ptr; - return (XP_Bitmap*)bitmap; -} /* makeBitmap */ - -static void -loadSpecialData( FrankDictionaryCtxt* ctxt, U8** ptrp ) -{ - U16 nSpecials = countSpecials( ctxt ); - U8* ptr = *ptrp; - - XP_DEBUGF( "loadSpecialData: there are %d specials\n", nSpecials ); - - XP_UCHAR** texts = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool, - nSpecials * sizeof(*texts) ); - SpecialBitmaps* bitmaps = (SpecialBitmaps*) - XP_MALLOC( ctxt->super.mpool, nSpecials * sizeof(*bitmaps) ); - - for ( Tile i = 0; i < ctxt->super.nFaces; ++i ) { - - XP_UCHAR face = ctxt->super.faces16[(short)i]; - if ( IS_SPECIAL(face) ) { - - /* get the string */ - U8 txtlen = *ptr++; - XP_UCHAR* text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1); - XP_MEMCPY( text, ptr, txtlen ); - ptr += txtlen; - text[txtlen] = '\0'; - XP_ASSERT( face < nSpecials ); - texts[face] = text; - - XP_DEBUGF( "making bitmaps for %s", texts[face] ); - bitmaps[face].largeBM = makeBitmap( ctxt, &ptr ); - bitmaps[face].smallBM = makeBitmap( ctxt, &ptr ); - } - } - - ctxt->super.chars = texts; - ctxt->super.bitmaps = bitmaps; - - XP_DEBUGF( "loadSpecialData consumed %ld bytes", - ptr - *ptrp ); - - *ptrp = ptr; -} /* loadSpecialData */ - -#if 0 -char* -frank_dictionary_getName(DictionaryCtxt* dict ) -{ - FrankDictionaryCtxt* ctxt = (FrankDictionaryCtxt*)dict; - return ctxt->name; -} /* frank_dictionary_getName */ -#endif - -static void -frank_dictionary_destroy( DictionaryCtxt* dict ) -{ - FrankDictionaryCtxt* ctxt = (FrankDictionaryCtxt*)dict; - U16 nSpecials = countSpecials( ctxt ); - U16 i; - - if ( !!dict->chars ) { - for ( i = 0; i < nSpecials; ++i ) { - XP_UCHAR* text = dict->chars[i]; - if ( !!text ) { - XP_FREE( dict->mpool, text ); - } - } - XP_FREE( dict->mpool, dict->chars ); - } - - if ( !!dict->countsAndValues ) { - XP_FREE( dict->mpool, dict->countsAndValues ); - } - if ( !!ctxt->super.faces16 ) { - XP_FREE( dict->mpool, ctxt->super.faces16 ); - } - - if ( !!ctxt->super.bitmaps ) { - for ( i = 0; i < nSpecials; ++i ) { - XP_Bitmap bmp = ctxt->super.bitmaps[i].largeBM; - if ( !!bmp ) { - XP_FREE( ctxt->super.mpool, bmp ); - } - bmp = ctxt->super.bitmaps[i].smallBM; - if ( !!bmp ) { - XP_FREE( ctxt->super.mpool, bmp ); - } - } - XP_FREE( ctxt->super.mpool, ctxt->super.bitmaps ); - } - - if ( ctxt->isMMC ) { - XP_FREE( ctxt->super.mpool, ctxt->base ); - } else { - (void)ebo_unmap( ctxt->base, ctxt->dictSize ); - } - XP_FREE( ctxt->super.mpool, ctxt ); -} // frank_dictionary_destroy - -#ifdef CPLUS -} -#endif diff --git a/xwords4/franklin/frankdict.h b/xwords4/franklin/frankdict.h deleted file mode 100644 index ba89894f7..000000000 --- a/xwords4/franklin/frankdict.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 1999-2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKDICT_H_ -#define _FRANKDICT_H_ - -#include - -#ifdef CPLUS -extern "C" { -#endif - -typedef enum { - LOC_UNKNOWN, - IN_RAM, - ON_MMC -} FileLoc ; - -#define FRANK_DICT_FLAGS_ERROR 0xFFFF - -U16 GetDictFlags( ebo_enumerator_t* eboe, FileLoc loc ); - -DictionaryCtxt* frank_dictionary_make( MPFORMAL XP_UCHAR* name ); - -void debugf( char* format, ... ); - -#ifdef CPLUS -} -#endif - -#endif /* _FRANKDICT_H_ */ diff --git a/xwords4/franklin/frankdlist.cpp b/xwords4/franklin/frankdlist.cpp deleted file mode 100755 index 283581a7c..000000000 --- a/xwords4/franklin/frankdlist.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001-2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 "frankdlist.h" -#include "frankids.h" - -#include "strutils.h" - -FrankDictList::FrankDictList(MPFORMAL_NOCOMMA) -{ - MPASSIGN( this->mpool, mpool ); - fNDicts = 0; - - for ( XP_U16 i = 0; i < MAX_DICTS; ++i ) { - fDictNames[i] = (XP_UCHAR*)NULL; - } - - populateList(); -} // FrankDictList::FrankDictList - -FrankDictList::~FrankDictList() -{ - for ( XP_U16 i = 0; i < fNDicts; ++i ) { - XP_ASSERT( !!fDictNames[i] ); - XP_FREE( mpool, fDictNames[i] ); - } -} - -XP_S16 -FrankDictList::IndexForName( XP_UCHAR* name ) -{ - XP_ASSERT( !!name ); - for ( XP_S16 i = 0; i < fNDicts; ++i ) { - if ( 0 == XP_STRCMP( name, fDictNames[i] ) ) { - return i; - } - } - - XP_ASSERT(0); - return -1; -} // FrankDictList::IndexForName - -XP_S16 -FrankDictList::dictListInsert( ebo_enumerator_t* eboep, FileLoc loc ) -{ - U16 flags; - if ( strcmp( eboep->name.publisher, PUB_ERICHOUSE ) == 0 - && strcmp( eboep->name.extension, EXT_XWORDSDICT ) == 0 - && ( ((flags = GetDictFlags( eboep, loc )) == 0x0001 ) - || (flags == 0x0002) || (flags == 0x0003) ) ) { - - XP_UCHAR* newName = (XP_UCHAR*)eboep->name.name; - XP_U16 nDicts = fNDicts; - XP_S16 pred; // predecessor - - // it's a keeper. Insert in alphabetical order - for ( pred = nDicts - 1; pred >= 0; --pred ) { - XP_S16 cmps = XP_STRCMP( newName, fDictNames[pred] ); - - // 0 means a duplicate, e.g one on MMC and another in - // RAM. Drop the dup in favor of the RAM copy. - if ( cmps == 0 ) { - return -1; - } - - if ( cmps > 0 ) { - break; // found it - } - } - - /* Now move any above the new location up */ - XP_S16 newLoc = pred + 1; - for ( XP_U16 j = nDicts; j > newLoc; --j ) { - fDictNames[j] = fDictNames[j-1]; - } - - XP_ASSERT( newLoc >= 0 ); - fDictNames[newLoc] = copyString( MPPARM(mpool) newName ); - fDictLocs[newLoc] = loc; - ++fNDicts; - - return newLoc; - - } else { - return -1; - } -} - -void -FrankDictList::populateList() -{ - int result; - ebo_enumerator_t eboe; - - for ( result = ebo_first_object( &eboe ); - result == EBO_OK; - result = ebo_next_object( &eboe ) ) { - dictListInsert( &eboe, IN_RAM ); - } - - for ( result = ebo_first_xobject( &eboe ); - result == EBO_OK; - result = ebo_next_xobject( &eboe ) ) { - dictListInsert( &eboe, ON_MMC ); - } -} // FrankDictList::populateList diff --git a/xwords4/franklin/frankdlist.h b/xwords4/franklin/frankdlist.h deleted file mode 100755 index 6affbd04f..000000000 --- a/xwords4/franklin/frankdlist.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001-2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKDLIST_H_ -#define _FRANKDLIST_H_ - -#include - -extern "C" { -#include "comtypes.h" -} - -#include "mempool.h" -#include "frankdict.h" - -#define MAX_DICTS 16 - -class FrankDictList { - - public: - - FrankDictList( MPFORMAL_NOCOMMA ); - ~FrankDictList(); - - XP_U16 GetDictCount() { return fNDicts; } - - XP_UCHAR* GetNthName( XP_U16 n ) { - XP_ASSERT( n < fNDicts ); - return fDictNames[n]; - } - - FileLoc GetNthLoc( XP_U16 n ) { - XP_ASSERT( n < fNDicts ); - return fDictLocs[n]; - } - - XP_S16 IndexForName( XP_UCHAR* name ); - - private: - void populateList(); - XP_S16 dictListInsert( ebo_enumerator_t* eboep, FileLoc loc ); - - XP_U16 fNDicts; - XP_UCHAR* fDictNames[MAX_DICTS]; - FileLoc fDictLocs[MAX_DICTS]; - - MPSLOT -}; -#endif diff --git a/xwords4/franklin/frankdraw.cpp b/xwords4/franklin/frankdraw.cpp deleted file mode 100644 index c0c633fcd..000000000 --- a/xwords4/franklin/frankdraw.cpp +++ /dev/null @@ -1,638 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 1997-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 - -extern "C" { -#include "xptypes.h" -#include "board.h" -#include "draw.h" -#include "mempool.h" -} /* extern "C" */ - -#include "frankmain.h" - -static void -insetRect( RECT* r, short i ) -{ - r->x += i; - r->y += i; - - i *= 2; - r->width -= i; - r->height -= i; -} /* insetRect */ - -static void -eraseRect(FrankDrawCtx* dctx, RECT* rect ) -{ - dctx->window->DrawRectFilled( rect, COLOR_WHITE ); -} /* eraseRect */ - -static XP_Bool -frank_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* dict, - const XP_Rect* rect, XP_Bool hasfocus ) -{ - return XP_TRUE; -} /* draw_finish */ - -static void -frank_draw_boardFinished( DrawCtx* p_dctx ) -{ - // GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; -} /* draw_finished */ - -static void -XP_RectToRECT( RECT* d, const XP_Rect* s ) -{ - d->x = s->left; - d->y = s->top; - d->width = s->width; - d->height = s->height; -} /* XP_RectToRECT */ - -/* Called by methods that draw cells, i.e. drawCell and drawCursor, to do - * common prep of the area. - */ -static void -cellDrawPrep( FrankDrawCtx* dctx, const XP_Rect* xprect, RECT* insetRect ) -{ - XP_RectToRECT( insetRect, xprect ); - - ++insetRect->height; - ++insetRect->width; - - eraseRect( dctx, insetRect ); -} /* cellDrawPrep */ - -static XP_Bool -frank_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* xprect, - const XP_UCHAR* letters, const XP_Bitmap* bitmap, - Tile tile, XP_S16 owner, XWBonusType bonus, - HintAtts hintAtts, - XP_Bool isBlank, XP_Bool isPending, XP_Bool isStar ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT rectInset; - XP_Bool showGrid = XP_TRUE; - - cellDrawPrep( dctx, xprect, &rectInset ); - - if ( !!letters ) { - if ( *letters == LETTER_NONE ) { - if ( bonus != BONUS_NONE ) { - XP_ASSERT( bonus <= 4 ); -#ifdef USE_PATTERNS - dctx->window->DrawTiledImage( xprect->left, xprect->top, - xprect->width, - xprect->height, - &dctx->bonusImages[bonus-1] ); -#else - RECT filledR = rectInset; - COLOR color; - insetRect( &filledR, 1 ); - - switch( bonus ) { - case BONUS_DOUBLE_LETTER: - color = COLOR_GRAY53; - break; - case BONUS_TRIPLE_LETTER: - color = COLOR_GRAY40; - break; - case BONUS_DOUBLE_WORD: - color = COLOR_GRAY27; - break; - case BONUS_TRIPLE_WORD: - color = COLOR_GRAY13; - break; - default: - color = COLOR_WHITE; /* make compiler happy */ - XP_ASSERT(0); - } - - dctx->window->DrawRectFilled( &filledR, color ); -#endif - } - - if ( isStar ) { - dctx->window->DrawImage( xprect->left+2, xprect->top+2, - &dctx->startMark ); - } - - } else { - dctx->window->DrawText( (const char*)letters, rectInset.x+2, - rectInset.y+1 ); - } - } else if ( !!bitmap ) { - dctx->window->DrawImage( xprect->left+2, xprect->top+2, - (IMAGE*)bitmap ); - } - - if ( showGrid ) { - COLOR color = isBlank? COLOR_GRAY53:COLOR_BLACK; - dctx->window->DrawRect( &rectInset, color ); - } - if ( isPending ) { - insetRect( &rectInset, 1 ); - dctx->window->InvertRect( &rectInset ); - } - - return XP_TRUE; -} /* frank_draw_drawCell */ - -static void -frank_draw_invertCell( DrawCtx* p_dctx, const XP_Rect* rect ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT r; - - XP_RectToRECT( &r, rect ); - r.x += 3; - r.y += 3; - r.width -= 5; - r.height -= 5; - -/* insetRect( &r, 2 ); */ - dctx->window->InvertRect( &r ); - GUI_UpdateNow(); -} /* frank_draw_invertCell */ - -static XP_Bool -frank_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, XP_U16 owner, - XP_Bool hasfocus ) -{ -/* FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; */ -/* clip? */ -/* eraseRect( dctx, rect ); */ - return XP_TRUE; -} /* frank_draw_trayBegin */ - -static void -frank_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* xprect, - const XP_UCHAR* letter, - XP_Bitmap* bitmap, XP_S16 val, XP_Bool highlighted ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - char numbuf[3]; - U32 width; - XP_Rect insetR = *xprect; - RECT rect; - - XP_RectToRECT( &rect, xprect ); - - eraseRect( dctx, &rect ); - - /* frame the tile */ - - dctx->window->DrawRect( &rect, COLOR_BLACK ); - - if ( !!letter ) { - if ( *letter != LETTER_NONE ) { /* blank */ - dctx->window->DrawText( (char*)letter, rect.x+1, rect.y+1, - dctx->trayFont ); - } - } else if ( !!bitmap ) { - dctx->window->DrawImage( rect.x+2, rect.y+3, (IMAGE*)bitmap ); - } - - if ( val >= 0 ) { - sprintf( (char*)numbuf, (const char*)"%d", val ); - width = GUI_TextWidth( dctx->valFont, numbuf, strlen(numbuf)); - U16 height = GUI_FontHeight( dctx->valFont ); - dctx->window->DrawText( (char*)numbuf, rect.x+rect.width - width - 1, - rect.y + rect.height - height - 1, - dctx->valFont ); - } - - if ( highlighted ) { - insetRect( &rect, 1 ); - dctx->window->DrawRect( &rect, COLOR_BLACK ); - } -} /* frank_draw_drawTile */ - -static void -frank_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* xprect ) -{ -/* FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; */ - - frank_draw_drawTile( p_dctx, xprect, (XP_UCHAR*)"?", - (XP_Bitmap*)NULL, -1, XP_FALSE ); -} /* frank_draw_drawTileBack */ - -static void -frank_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect, - XP_Bool selected ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT winRect; - XP_RectToRECT( &winRect, rect ); - - eraseRect( dctx, &winRect ); - - ++winRect.x; - winRect.width -= 2; - - COLOR color; - if ( selected ) { - color = COLOR_GRAY27; - } else { - color = COLOR_BLACK; - } - - dctx->window->DrawRectFilled( &winRect, color ); -} /* frank_draw_drawTrayDivider */ - -static void -frank_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT rect; - - XP_RectToRECT( &rect, rectP ); - - eraseRect( dctx, &rect ); - -} /* frank_draw_clearRect */ - -static void -frank_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* xprect, - XWBonusType cursorBonus, XP_Bool vertical, - HintAtts hintAtts ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT rect; - - cellDrawPrep( dctx, xprect, &rect ); - - dctx->window->DrawImage( rect.x+3, rect.y+2, - vertical?&dctx->downcursor:&dctx->rightcursor ); - /* frame the cell */ - dctx->window->DrawRect( &rect, COLOR_BLACK ); -} /* frank_draw_drawBoardArrow */ - -static void -frank_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 numPlayers, XP_Bool hasfocus ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT r; - - XP_RectToRECT( &r, rect ); - eraseRect( dctx, &r ); -} /* frank_draw_scoreBegin */ - -static void -frank_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* r, - XP_S16 nTilesLeft, - XP_U16* width, XP_U16* height ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - - *height = SCORE_HEIGHT; - - char buf[15]; - sprintf( (char*)buf, "rem:%d", nTilesLeft ); - *width = GUI_TextWidth( dctx->scoreFnt, (char*)buf, - strlen(buf) ); -} /* frank_draw_measureRemText */ - -static void -frank_draw_drawRemText( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, XP_S16 nTilesLeft ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - char buf[15]; - sprintf( (char*)buf, "rem:%d", nTilesLeft ); - dctx->window->DrawText( (char*)buf, rInner->left, rInner->top, - dctx->scoreFnt ); -} /* frank_draw_drawRemText */ - -static XP_U16 -scoreWidthAndText( char* buf, const FONT* font, const DrawScoreInfo* dsi ) -{ - char* borders = ""; - if ( dsi->isTurn ) { - borders = "*"; - } - - sprintf( buf, "%s%.3d", borders, dsi->score ); - if ( dsi->nTilesLeft >= 0 ) { - char nbuf[10]; - sprintf( nbuf, ":%d", dsi->nTilesLeft ); - strcat( buf, nbuf ); - } - strcat( buf, borders ); - - S32 width = GUI_TextWidth( font, buf, strlen(buf) ); - return width; -} /* scoreWidthAndText */ - -static void -frank_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* r, - const DrawScoreInfo* dsi, - XP_U16* width, XP_U16* height ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - char buf[20]; - const FONT* font = dsi->selected? dctx->scoreFntBold:dctx->scoreFnt; - - *height = SCORE_HEIGHT; - *width = scoreWidthAndText( buf, font, dsi ); -} /* frank_draw_measureScoreText */ - -static void -frank_draw_score_drawPlayer( DrawCtx* p_dctx, - const XP_Rect* rInner, const XP_Rect* rOuter, - const DrawScoreInfo* dsi ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - char buf[20]; - XP_U16 x; - const FONT* font = dsi->selected? dctx->scoreFntBold:dctx->scoreFnt; - - S32 width = scoreWidthAndText( buf, font, dsi ); - - x = rInner->left + ((rInner->width - width) /2); - - dctx->window->DrawText( buf, x, rInner->top, font ); -} /* frank_draw_score_drawPlayer */ - -static void -frank_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect, - XP_S16 score, XP_U16 playerNum ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - char buf[5]; - XP_U16 left; - - if ( score >= 0 ) { - sprintf( buf, "%.3d", score ); - } else { - strcpy( buf, "???" ); - } - - RECT r; - XP_RectToRECT( &r, rect ); - eraseRect( dctx, &r ); - - left = r.x+1; - dctx->window->DrawText( "Pts:", left, r.y, dctx->valFont ); - dctx->window->DrawText( buf, left, r.y+(r.height/2), - dctx->scoreFnt ); -} /* frank_draw_score_pendingScore */ - -static void -frank_draw_scoreFinished( DrawCtx* p_dctx ) -{ - -} /* frank_draw_scoreFinished */ - -static U16 -frankFormatTimerText( char* buf, XP_S16 secondsLeft ) -{ - XP_U16 minutes, seconds; - XP_U16 nChars = 0; - - if ( secondsLeft < 0 ) { - *buf++ = '-'; - secondsLeft *= -1; - ++nChars; - } - - minutes = secondsLeft / 60; - seconds = secondsLeft % 60; - - char secBuf[6]; - sprintf( secBuf, "0%d", seconds ); - - nChars += sprintf( buf, "%d:%s", minutes, - secBuf[2] == '\0'? secBuf:&secBuf[1] ); - return nChars; -} /* frankFormatTimerText */ - -static void -frank_draw_drawTimer( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, XP_U16 player, - XP_S16 secondsLeft ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - char buf[12]; - - (void)frankFormatTimerText( buf, secondsLeft ); - - XP_DEBUGF( "drawing timer text: %s at %d,%d", buf, rInner->left, - rInner->top ); - RECT r; - XP_RectToRECT( &r, rInner ); - eraseRect( dctx, &r ); - dctx->window->DrawText( buf, rInner->left, rInner->top, dctx->scoreFnt ); -} /* frank_draw_drawTimer */ - -static XP_UCHAR* -frank_draw_getMiniWText( DrawCtx* p_dctx, XWMiniTextType whichText ) -{ - char* str = (char*)NULL; - - switch( whichText ) { - case BONUS_DOUBLE_LETTER: - str = "Double letter"; break; - case BONUS_DOUBLE_WORD: - str = "Double word"; break; - case BONUS_TRIPLE_LETTER: - str = "Triple letter"; break; - case BONUS_TRIPLE_WORD: - str = "Triple word"; break; - case INTRADE_MW_TEXT: - str = "Click D when done"; break; - default: - XP_ASSERT( XP_FALSE ); - } - return (XP_UCHAR*)str; -} /* frank_draw_getMiniWText */ - -static void -frank_draw_measureMiniWText( DrawCtx* p_dctx, const XP_UCHAR* str, - XP_U16* widthP, XP_U16* heightP ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - *widthP = 6 + GUI_TextWidth( dctx->scoreFnt, (const char*)str, - strlen((const char*)str) ); - *heightP = 6 + GUI_FontHeight( dctx->scoreFnt ); -} /* frank_draw_measureMiniWText */ - -static void -frank_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text, - const XP_Rect* rect, void** closureP ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; - RECT r; - - XP_RectToRECT( &r, rect ); - - eraseRect( dctx, &r ); - - --r.width; - --r.height; - ++r.x; - ++r.y; - dctx->window->DrawRect( &r, COLOR_BLACK ); - --r.x; - --r.y; - eraseRect( dctx, &r ); - dctx->window->DrawRect( &r, COLOR_BLACK ); - - dctx->window->DrawText( (const char*)text, r.x+2, r.y+2, dctx->scoreFnt ); -} /* frank_draw_drawMiniWindow */ - -static void -frank_draw_eraseMiniWindow( DrawCtx* p_dctx, const XP_Rect* rect, - XP_Bool lastTime, - void** closure, XP_Bool* invalUnder ) -{ -/* FrankDrawCtx* dctx = (FrankDrawCtx*)p_dctx; */ - *invalUnder = XP_TRUE; -} /* frank_draw_eraseMiniWindow */ - -#define SET_GDK_COLOR( c, r, g, b ) { \ - c.red = (r); \ - c.green = (g); \ - c.blue = (b); \ -} -static void -draw_doNothing( DrawCtx* dctx, ... ) -{ -} /* draw_doNothing */ - - -const unsigned char downcursor_bits[] = { - 0x00, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0xfe, 0x00, - 0x7c, 0x00, - 0x38, 0x00, - 0x10, 0x00, - 0x00, 0x00, -}; - -const unsigned char rightcursor_bits[] = { - 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x1c, 0x00, 0xfe, 0x00, 0x1c, 0x00, - 0x18, 0x00, 0x10, 0x00, 0x00, 0x00 -}; -const unsigned char startMark_bits[] = { - 0xc1, 0x80, /* ##-- ---# # */ - 0xe3, 0x80, /* ###- --## # */ - 0x77, 0x00, /* -### -### - */ - 0x3e, 0x00, /* --## ###- - */ - 0x1c, 0x00, /* ---# ##-- - */ - 0x3e, 0x00, /* --## ###- - */ - 0x77, 0x00, /* -### -### - */ - 0xe3, 0x80, /* ###- --## # */ - 0xc1, 0x80, /* ##-- ---# # */ -}; - -#ifdef USE_PATTERNS -const unsigned char bonus_bits[][4] = { - { 0x88, 0x44, 0x22, 0x11 }, - { 0xaa, 0x55, 0xaa, 0x55 }, - { 0xCC, 0x66, 0x33, 0x99 }, - { 0xCC, 0xCC, 0x33, 0x33 } -}; -#endif - -DrawCtx* -frank_drawctxt_make( MPFORMAL CWindow* window ) -{ - FrankDrawCtx* dctx = (FrankDrawCtx*)XP_MALLOC( mpool, - sizeof(FrankDrawCtx) ); - U16 i; - - dctx->vtable = (DrawCtxVTable*) - XP_MALLOC( mpool, sizeof(*(((FrankDrawCtx*)dctx)->vtable)) ); - - for ( i = 0; i < sizeof(*dctx->vtable)/4; ++i ) { - ((void**)(dctx->vtable))[i] = draw_doNothing; - } - -/* SET_VTABLE_ENTRY( dctx, draw_destroyCtxt, frank_ ); */ - SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_invertCell, frank ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_boardFinished, frank ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTile, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTileBack, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTrayDivider, frank ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, frank ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreBegin, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_measureRemText, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawRemText, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_measureScoreText, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreFinished, frank ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, frank ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, frank ); - SET_VTABLE_ENTRY( dctx->vtable, draw_eraseMiniWindow, frank ); - - dctx->window = window; - - dctx->valFont = GUI_GetFont( 9, CTRL_NORMAL ); - dctx->scoreFnt = GUI_GetFont( 12, CTRL_NORMAL ); - dctx->scoreFntBold = GUI_GetFont( 12, CTRL_BOLD ); - dctx->trayFont = GUI_GetFont( 16, CTRL_NORMAL ); - - IMAGE downcursor = { 9, 9, 2, - COLOR_MODE_MONO, 0, (const COLOR *) 0, - (U8*)downcursor_bits }; - XP_MEMCPY( (IMAGE*)&dctx->downcursor, &downcursor, - sizeof(dctx->downcursor) ); - - IMAGE rightcursor = { 9, 9, 2, - COLOR_MODE_MONO, 0, (const COLOR *) 0, - (U8*)rightcursor_bits }; - XP_MEMCPY( (IMAGE*)&dctx->rightcursor, &rightcursor, - sizeof(dctx->rightcursor) ); - - IMAGE startMark = { 9, 9, 2, - COLOR_MODE_MONO, 0, (const COLOR *) 0, - (U8*)startMark_bits }; - XP_MEMCPY( (IMAGE*)&dctx->startMark, &startMark, - sizeof(dctx->startMark) ); - -#ifdef USE_PATTERNS - for ( i = 0; i < BONUS_LAST; ++i ) { - IMAGE bonus = { 8, 4, 1, - COLOR_MODE_MONO, 0, (const COLOR *) 0, - (U8*)bonus_bits[i] }; - XP_MEMCPY( (IMAGE*)&dctx->bonusImages[i], &bonus, - sizeof(dctx->bonusImages[i]) ); - } -#endif - return (DrawCtx*)dctx; -} /* frank_drawctxt_make */ diff --git a/xwords4/franklin/frankdraw.h b/xwords4/franklin/frankdraw.h deleted file mode 100644 index 19b26a177..000000000 --- a/xwords4/franklin/frankdraw.h +++ /dev/null @@ -1,31 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 - -extern "C" { - -#include "frankmain.h" -#include "draw.h" -#include "board.h" - -} /* extern "C" */ - -DrawCtx* frank_drawctxt_make( MPFORMAL CWindow* win ); - diff --git a/xwords4/franklin/frankgamesdb.cpp b/xwords4/franklin/frankgamesdb.cpp deleted file mode 100644 index b76f90cb5..000000000 --- a/xwords4/franklin/frankgamesdb.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include "frankgamesdb.h" -#include "frankids.h" - -extern "C" { -# include "xptypes.h" -} - -CGamesDB::CGamesDB(MPFORMAL const XP_UCHAR* fileName) -{ - this->nRecordsUsed = 0; - this->nRecordsAllocated = 0; - this->lockedIndex = -1; - MPASSIGN( this->mpool, mpool ); - - fRecords = (DBRecord*)NULL; - - // create or load file - memset( &this->xwfile, 0, sizeof(xwfile) ); - strcpy( (char*)this->xwfile.name, (char*)fileName ); - strcpy( this->xwfile.publisher, PUB_ERICHOUSE ); - strcpy( this->xwfile.extension, EXT_XWORDSGAMES ); - - size_t size = EBO_BLK_SIZE; - int result = ebo_new( &this->xwfile, size, FALSE ); - BOOL exists = result < 0; - - XP_DEBUGF( "exists=%d", exists ); - - if ( exists ) { - readFromFile( &xwfile ); - } -} // CGamesDBn - -CGamesDB::~CGamesDB() -{ - this->writeToFile(); - - U16 nRecords = this->nRecordsUsed; - for ( U16 i = 0; i < nRecords; ++i ) { - DBRecord* record = &fRecords[i]; - XP_FREE( mpool, record->datum ); - if ( !!record->name ) { - XP_FREE( mpool, record->name ); - } - } - - XP_FREE( mpool, fRecords ); -} // ~CGamesDB - -void* -CGamesDB::getNthRecord( U16 index, U16* recordLen ) -{ - XP_ASSERT( index < this->nRecordsUsed ); - XP_ASSERT( this->lockedIndex < 0 ); - this->lockedIndex = index; - *recordLen = fRecords[index].length; - - XP_DEBUGF( "getNthRecord(%d) returning len=%d", index, *recordLen ); - - return fRecords[index].datum; -} // getNthRecord - -XP_UCHAR* -CGamesDB::getNthName( U16 index ) -{ - XP_ASSERT( index < this->nRecordsUsed ); - XP_DEBUGF( "returning %dth name: %s", index, fRecords[index].name ); - return fRecords[index].name; -} /* getNthName */ - -void -CGamesDB::recordRelease( U16 index ) -{ - XP_ASSERT( this->lockedIndex == index ); - this->lockedIndex = -1; -} // recordRelease - -void -CGamesDB::putNthRecord( U16 index, void* ptr, U16 len ) -{ - XP_DEBUGF( "putNthRecord(%d,ptr,%d)", index, len ); - XP_ASSERT( index <= nRecordsUsed ); - - if ( index == nRecordsAllocated ) { /* need a new one */ - ensureSpace( nRecordsUsed+1 ); - } else if ( !!fRecords[index].datum ) { - XP_FREE(mpool, fRecords[index].datum ); - } - - void* datap = XP_MALLOC( mpool, len ); - XP_MEMCPY( datap, ptr, len ); - fRecords[index].datum = datap; - fRecords[index].length = len; - - if ( index == this->nRecordsUsed ) { - ++this->nRecordsUsed; - } -} // putNthRecord - -void -CGamesDB::putNthName( U16 index, XP_UCHAR* name ) -{ - XP_ASSERT( index <= this->nRecordsUsed ); - - if ( index == nRecordsAllocated ) { /* need a new one */ - ensureSpace( nRecordsUsed+1 ); - } else if ( !!fRecords[index].name ) { - XP_FREE( mpool, fRecords[index].name ); - } - - fRecords[index].name = frankCopyStr( MPPARM(mpool) name); - if ( index == this->nRecordsUsed ) { - ++this->nRecordsUsed; - } -} /* putNthName */ - -void -CGamesDB::removeNthRecord( U16 index ) -{ - XP_ASSERT( index < this->nRecordsUsed ); - - if ( !!fRecords[index].datum ) { - XP_FREE( mpool, fRecords[index].datum ); - if ( !!fRecords[index].name ) { - XP_FREE( mpool, fRecords[index].name ); - } - } - - U16 nRecords = --this->nRecordsUsed; - for ( U16 i = index; i < nRecords; ++i ) { - fRecords[i] = fRecords[i+1]; - } - fRecords[nRecords].datum = NULL; - fRecords[nRecords].length = 0; -} // removeNthRecord - -U16 -CGamesDB::duplicateNthRecord( U16 index ) -{ - XP_ASSERT( index < this->nRecordsUsed ); - - ensureSpace( nRecordsUsed + 1 ); - - U16 newIndex = index + 1; - for ( U16 i = this->nRecordsUsed; i > newIndex; --i ) { - fRecords[i] = fRecords[i-1]; - } - ++this->nRecordsUsed; - - U16 len = fRecords[newIndex].length = fRecords[index].length; - void* data = XP_MALLOC( mpool, len ); - XP_MEMCPY( data, fRecords[index].datum, len ); - fRecords[newIndex].datum = data; - fRecords[newIndex].name = - frankCopyStr( MPPARM(mpool) fRecords[index].name ); - - XP_DEBUGF( "done with duplicateNthRecord; returning %d", newIndex ); - - return newIndex; -} /* duplicateNthRecord */ - -U16 -CGamesDB::countRecords() -{ - return this->nRecordsUsed; -} // countRecords - -void -CGamesDB::readFromFile( const ebo_name_t* xwfile ) -{ - size_t size = EBO_BLK_SIZE; - void* vmbase = (void*)ebo_roundup(OS_availaddr+GAMES_DB_OFFSET); -#ifdef DEBUG - int result = ebo_mapin( xwfile, 0, vmbase, &size, 1 ); - XP_ASSERT( result >= 0 ); -#else - (void)ebo_mapin( xwfile, 0, vmbase, &size, 1 ); -#endif - XP_ASSERT( ((unsigned long)vmbase & 0x01) == 0 ); - - U16 nRecords; - unsigned char* ptr = (unsigned char*)vmbase; - nRecords = *((U16*)ptr)++; - XP_DEBUGF( "nRecords = %d", nRecords ); - this->nRecordsUsed = this->nRecordsAllocated = nRecords; - - fRecords = (DBRecord*)XP_MALLOC( mpool, nRecords * sizeof(fRecords[0]) ); - - for ( U16 i = 0; i < nRecords; ++i ) { - DBRecord* record = &fRecords[i]; - U8 nameLen = *ptr++; - XP_UCHAR* name = (XP_UCHAR*)NULL; - - if ( nameLen > 0 ) { - name = (XP_UCHAR*)XP_MALLOC(mpool, nameLen+1); - XP_MEMCPY( name, ptr, nameLen ); - name[nameLen] = '\0'; - ptr += nameLen; - } - record->name = name; - - /* fix alignment */ - while ( ((unsigned long)ptr & 0x00000001) != 0 ) { - ++ptr; - } - - U16 len = record->length = *((U16*)ptr)++; - XP_DEBUGF( "read len %d from offset %ld", len, - (unsigned long)ptr - (unsigned long)vmbase - 2 ); - - record->datum = XP_MALLOC( mpool, len ); - XP_MEMCPY( record->datum, ptr, len ); - ptr += len; - - XP_DEBUGF( "Read %dth record", i ); - XP_ASSERT( ((unsigned char*)vmbase) + size >= ptr ); - } - - (void)ebo_unmap( vmbase, size ); - - XP_DEBUGF( "read %d records from file", nRecords ); -} // readFromFile - -void -CGamesDB::writeToFile() -{ - size_t size = EBO_BLK_SIZE; - void* vmbase = (void*)ebo_roundup(OS_availaddr+GAMES_DB_OFFSET); -#ifdef DEBUG - int result = ebo_mapin( &this->xwfile, 0, vmbase, &size, 1 ); - XP_ASSERT( result >= 0 ); -#else - (void)ebo_mapin( &this->xwfile, 0, vmbase, &size, 1 ); -#endif - XP_ASSERT( ((unsigned long)vmbase & 0x01) == 0 ); - - U16 nRecords = this->nRecordsUsed; - unsigned char* ptr = (unsigned char*)vmbase; - - *(U16*)ptr = nRecords; - ptr += sizeof(U16); - - for ( U16 i = 0; i < nRecords; ++i ) { - - XP_UCHAR* name = fRecords[i].name; - U16 slen = !!name? XP_STRLEN( name ): 0; - *ptr++ = slen; - if ( slen > 0 ) { - XP_ASSERT( slen < 0x00FF ); - XP_MEMCPY( ptr, name, slen ); - ptr += slen; - } - - /* fix alignment */ - while ( ((unsigned long)ptr & 0x00000001) != 0 ) { - ++ptr; - } - - U16 len = fRecords[i].length; - XP_DEBUGF( "writing len %d at offset %ld", len, - (unsigned long)ptr - (unsigned long)vmbase ); - *((U16*)ptr)++ = len; - - XP_MEMCPY( ptr, fRecords[i].datum, len ); - ptr += len; - } - - ebo_unmap( vmbase, size ); - - XP_WARNF( "finished writing %d recs to file", nRecords ); -} // writeToFile - -void -CGamesDB::ensureSpace( U16 nNeeded ) -{ - if ( this->nRecordsAllocated < nNeeded ) { - U16 newLen = nNeeded * sizeof(fRecords[0]); - if ( !!fRecords ) { - fRecords = (DBRecord*)XP_REALLOC( mpool, fRecords, newLen ); - } else { - fRecords = (DBRecord*)XP_MALLOC( mpool, newLen ); - - } - - U16 sizeAdded = (nNeeded - this->nRecordsAllocated) * sizeof(*fRecords); - XP_MEMSET( fRecords + this->nRecordsAllocated, 0x00, sizeAdded ); - - this->nRecordsAllocated = nNeeded; - XP_DEBUGF( "ensureSpace: increasing nRecordsAllocated to %d (len=%d)", - nRecordsAllocated, newLen ); - } -} /* ensureSpace */ diff --git a/xwords4/franklin/frankgamesdb.h b/xwords4/franklin/frankgamesdb.h deleted file mode 100644 index 81d178964..000000000 --- a/xwords4/franklin/frankgamesdb.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKGAMESDB_H_ -#define _FRANKGAMESDB_H_ - -#include -#include -#include "sys.h" -#include "gui.h" -#include "comtypes.h" -#include "mempool.h" - -/* #include "ebm_object.h" */ - -struct DBRecord { - U16 length; - void* datum; - XP_UCHAR* name; -}; - -class CGamesDB { - - private: - U16 nRecordsUsed; - U16 nRecordsAllocated; - DBRecord* fRecords; - S16 lockedIndex; - ebo_name_t xwfile; - - void readFromFile( const ebo_name_t* xwfile ); - void writeToFile(); - void ensureSpace( U16 nNeeded ); - - MPSLOT - - public: - /* create or open if already exists */ - CGamesDB(MPFORMAL const XP_UCHAR* fileName); - - /* commit optimized in-memory representation to a flat "file" */ - ~CGamesDB(); - - /* Return a ptr (read-only by convention!!) to the beginning of the - record's data. The ptr's valid until recordRelease is called. */ - void* getNthRecord( U16 index, U16* recordLen ); - void recordRelease( U16 index ); - XP_UCHAR* getNthName( U16 index ); - - /* put data into a record, adding a new one, replacing or appending to an - existing one */ - void putNthRecord( U16 index, void* ptr, U16 len ); - void appendNthRecord( U16 index, void* ptr, U16 len ); - void putNthName( U16 index, XP_UCHAR* name ); - - U16 duplicateNthRecord( U16 index ); - void removeNthRecord( U16 index ); - - /* how many records do I have. indices passed by getter methods that are - >= this number are illegal. setters can pass a number = to this, in - which case we create a new record. */ - U16 countRecords(); -}; - -#endif diff --git a/xwords4/franklin/frankids.h b/xwords4/franklin/frankids.h deleted file mode 100644 index 6f9cd972b..000000000 --- a/xwords4/franklin/frankids.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2000 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 "comtypes.h" -#include "mempool.h" - -#ifndef _FRANKIDS_H_ -#define _FRANKIDS_H_ - -#define MAIN_FLIP_BUTTON_ID 101 -#define MAIN_VALUE_BUTTON_ID 102 -#define MAIN_HINT_BUTTON_ID 103 -#define MAIN_UNDO_BUTTON_ID 104 -#define MAIN_COMMIT_BUTTON_ID 105 -#define MAIN_TRADE_BUTTON_ID 106 -#define MAIN_JUGGLE_BUTTON_ID 107 -#define MAIN_HIDE_BUTTON_ID 108 - - -#define MAIN_WINDOW_ID 1000 -#define ASK_WINDOW_ID 1001 -#define ASKLETTER_WINDOW_ID 1002 -#define PLAYERS_WINDOW_ID 1003 -#define PASSWORD_WINDOW_ID 1004 -#define SAVEDGAMES_WINDOW_ID 1005 - -#define FILEMENU_BUTTON_ID 1020 -#define FILEMENU_NEWGAME 1021 -#define FILEMENU_SAVEDGAMES 1022 -#define FILEMENU_PREFS 1023 -#define FILEMENU_ABOUT 1024 - -#define GAMEMENU_BUTTON_ID 1025 -#define GAMEMENU_TVALUES 1026 -#define GAMEMENU_FINALSCORES 1041 -#define GAMEMENU_GAMEINFO 1027 -#define GAMEMENU_HISTORY 1028 - -#define MOVEMENU_BUTTON_ID 1029 -#define MOVEMENU_HINT 1030 -#define MOVEMENU_NEXTHINT 1031 -#define MOVEMENU_REVERT 1032 -#define MOVEMENU_UNDO 1033 -#define MOVEMENU_DONE 1034 -#define MOVEMENU_JUGGLE 1035 -#define MOVEMENU_TRADE 1036 -#define MOVEMENU_HIDETRAY 1037 - -#ifdef MEM_DEBUG -# define DEBUGMENU_BUTTON_ID 1050 -# define DEBUGMENU_HEAPDUMP 1051 -#endif - -#define FILEMENU_WINDOW_ID 1038 -#define GAMEMENU_WINDOW_ID 1039 -#define MOVEMENU_WINDOW_ID 1040 -#define MENUBAR_WINDOW_ID 1041 - -const char* PUB_ERICHOUSE = "Eric_House"; - -const char* EXT_XWORDSDICT = "xwd"; -const char* EXT_XWORDSGAMES = "xwg"; - -#define DICT_OFFSET 0x00000000 -#define GAMES_DB_OFFSET 0x00800000 -#define FLAGS_CHECK_OFFSET 0x00900000 - -#define MAX_NAME_LENGTH 31 /* not including null byte */ - -extern "C" { - XP_UCHAR* frankCopyStr( MPFORMAL const XP_UCHAR* ); -} - -#endif - diff --git a/xwords4/franklin/frankletter.cpp b/xwords4/franklin/frankletter.cpp deleted file mode 100644 index dc8de6a7a..000000000 --- a/xwords4/franklin/frankletter.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2000 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include "sys.h" -#include "gui.h" -#include "ebm_object.h" - -extern "C" { -#include "xptypes.h" -} - -#include "frankletter.h" - -#include "frankids.h" -#include "frankask.h" - -#define LETTER_HEIGHT 12 -#define LETTERS_ROW_HEIGHT LETTER_HEIGHT -#define LETTERS_ROW_WIDTH 30 -#define LETTERS_NUM_VISROWS 16 - -class LettersList : public CList { -private: - const XP_UCHAR4* fTexts; - - public: - LettersList( const XP_UCHAR4* texts, U16 numRows ); - - U16 GetRowHeight( S32 row ) { return LETTER_HEIGHT; } - void DrawRow( RECT *rect, S32 row ); -}; - -LettersList::LettersList( const XP_UCHAR4* texts, U16 numRows ) - : CList( 1001, LETTERS_ROW_WIDTH, - LETTERS_ROW_HEIGHT * LETTERS_NUM_VISROWS, - numRows, LISTOPTION_ALWAYS_HIGHLIGHT ) -{ - fTexts = texts; - - this->SetCurrentRow(0); // Select the first item so there's a default -} - -void LettersList::DrawRow( RECT *rect, S32 row ) -{ - CWindow* window = this->GetWindow(); - window->DrawText( (char*)fTexts[row], rect->x, rect->y ); -} /* LettersList::DrawRow */ - -CAskLetterWindow::CAskLetterWindow( const PickInfo* pi, XP_U16 playerNum, - const XP_UCHAR4* texts, XP_U16 nTiles, - XP_S16* resultP ) - : CWindow( ASKLETTER_WINDOW_ID, 55, 15, 80, 220, "Blank", TRUE ) -{ - fTexts = texts; - fNTiles = nTiles; - fResultP = resultP; - - this->list = new LettersList( texts, nTiles ); - this->AddChild( this->list, 5, 5 ); - - CButton* okbutton = new CButton( 1000, 0, 0, "Ok" ); - this->AddChild( okbutton, 40, 70 ); -} // CAskWindow - -S32 -CAskLetterWindow::MsgHandler( MSG_TYPE type, CViewable *object, S32 data ) -{ - S32 result = 0; - - switch (type) { - case MSG_BUTTON_SELECT: // there's only one button.... - *fResultP = this->list->GetCurrentRow(); - - this->Close(); - result = 1; - break; - - case MSG_KEY: // allow keys to select the matching letter in the list - if ( isalpha( data ) ) { - XP_UCHAR ch = toupper(data); - for ( U16 i = 0; i < fNTiles; ++i ) { - if ( ch == fTexts[i][0] ) { - this->list->SetCurrentRow( i ); - result = 1; - break; - } - } - } - - default: - break; - } - - if ( result == 0 ) { - result = CWindow::MsgHandler( type, object, data ); - } - return result; -} // CAskLetterWindow::MsgHandler - - - diff --git a/xwords4/franklin/frankletter.h b/xwords4/franklin/frankletter.h deleted file mode 100644 index 3f1dd0479..000000000 --- a/xwords4/franklin/frankletter.h +++ /dev/null @@ -1,35 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -extern "C" { -#include "dictnry.h" -#include "util.h" -} - -class CAskLetterWindow : public CWindow { - private: - const XP_UCHAR4* fTexts; - XP_S16* fResultP; - XP_U16 fNTiles; - CList* list; /* my own subclass, of course */ - public: - CAskLetterWindow( const PickInfo* pi, XP_U16 playerNum, - const XP_UCHAR4* texts, XP_U16 nTiles, XP_S16* result ); - S32 MsgHandler( MSG_TYPE type, CViewable *object, S32 data ); -}; diff --git a/xwords4/franklin/frankmain.cpp b/xwords4/franklin/frankmain.cpp deleted file mode 100644 index 220eb0498..000000000 --- a/xwords4/franklin/frankmain.cpp +++ /dev/null @@ -1,1673 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 1999-2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -#define TEST_CPP 1 - -#include -#include -#include -#include -#include -#include -#include /* for time_get_onOS */ -#include - -#include "sys.h" -#include "gui.h" -#include "OpenDatabases.h" -#include "comms.h" /* for CHANNEL_NONE */ -#include "LocalizedStrIncludes.h" -// #include "FieldMgr.h" - -#include "ebm_object.h" - -extern "C" { -#include /* jonathan_yavner@franklin.com says put in extern "C" */ -#include "xptypes.h" -#include "game.h" -#include "vtabmgr.h" -#include "dictnry.h" -#include "util.h" -#include "memstream.h" -#include "strutils.h" -} - -#include "frankmain.h" -#include "frankdraw.h" -#include "frankdict.h" -#include "frankpasswd.h" -#include "frankdlist.h" -#include "frankshowtext.h" -/* #include "frankask.h" */ -#include "frankletter.h" -#include "frankplayer.h" -#include "frankgamesdb.h" -#include "franksavedgames.h" -#include "bmps_includes.h" -/* #include "browser.h" */ - -extern "C" { -#include "lcd.h" -#include "ereader_hostio.h" -} - -#include "frankids.h" -class CXWordsWindow; - -enum { HINT_REQUEST, SERVER_TIME_REQUEST, NEWGAME_REQUEST, - FINALSCORE_REQUEST }; - -CXWordsWindow *MainWindow; -/* CLabel *Repeat_Label; */ -CMenuBar MainMenuBar( MENUBAR_WINDOW_ID, 23 ); -/* CPushButton *Edit_Button; */ - -/* Addrtest variables */ -/* class CRecordWindow; */ -/* COpenDB DBase; */ -// CFMDatabase FMgr; -/* CRecordWindow *AddrWindow; */ - - -/* callbacks */ -static VTableMgr* frank_util_getVTManager( XW_UtilCtxt* uc ); -static DictionaryCtxt* frank_util_makeEmptyDict( XW_UtilCtxt* uc ); -static void frank_util_userError( XW_UtilCtxt* uc, UtilErrID id ); -static XP_Bool frank_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, - XWStreamCtxt* stream ); -static XP_S16 frank_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi, - XP_U16 playerNum, - const XP_UCHAR4* texts, XP_U16 nTiles ); -static XP_Bool frank_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name, - XP_UCHAR* buf, XP_U16* len ); -static void frank_util_trayHiddenChange( XW_UtilCtxt* uc, - XW_TrayVisState newState ); -static void frank_util_notifyGameOver( XW_UtilCtxt* uc ); -static XP_Bool frank_util_hiliteCell( XW_UtilCtxt* uc, - XP_U16 col, XP_U16 row ); -static XP_Bool frank_util_engineProgressCallback( XW_UtilCtxt* uc ); -static void frank_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, - XP_U16 when, - TimerProc proc, void* closure ); -static void frank_util_requestTime( XW_UtilCtxt* uc ); -static XP_U32 frank_util_getCurSeconds( XW_UtilCtxt* uc ); -static XWBonusType frank_util_getSquareBonus( XW_UtilCtxt* uc, - ModelCtxt* model, - XP_U16 col, XP_U16 row ); -static XP_UCHAR* frank_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode ); -static XP_Bool frank_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, - XP_U16 turn, XP_Bool turnLost ); -static void frank_util_engineStarting( XW_UtilCtxt* uc, XP_U16 nBlanks ); -static void frank_util_engineStopping( XW_UtilCtxt* uc ); - - -typedef struct FrankSavedState { - U32 magic; - U16 curGameIndex; - XP_Bool showProgress; -} FrankSavedState; - - -CXWordsWindow -class CXWordsWindow : public CWindow { - public: /* so util functions can access */ - XWGame fGame; - CurGameInfo fGameInfo; - VTableMgr* fVTableMgr; - - private: - FrankDrawCtx* draw; - DictionaryCtxt* dict; - XW_UtilCtxt util; - FrankDictList* fDictList; - - FrankSavedState fState; - - CGamesDB* gamesDB; - - CommonPrefs cp; - - RECT fProgressRect; - U16 fProgressCurLine; - - /* There's a wasted slot here, but it simplifies indexing */ - TimerProc fTimerProcs[NUM_TIMERS_PLUS_ONE]; - void* fTimerClosures[NUM_TIMERS_PLUS_ONE]; - - XP_U8 phoniesAction; - BOOL penDown; - BOOL drawInProgress; - BOOL userEventPending; - XP_Bool fRobotHalted; - XP_Bool fAskTrayLimits; - -public: - CXWordsWindow( MPFORMAL FrankDictList* dlist ); - ~CXWordsWindow(); -// void init(); - void Draw(); - S32 MsgHandler( MSG_TYPE type, CViewable *from, S32 data ); - - void setUserEventPending() { this->userEventPending = TRUE; } - void clearUserEventPending() { this->userEventPending = FALSE; } - BOOL getUserEventPending() { return this->userEventPending; } - void setTimerImpl( XWTimerReason why, - TimerProc proc, void* closure ); - void setTimerIfNeeded(); - void fireTimer( XWTimerReason why ); - XP_Bool robotIsHalted() { return fRobotHalted; } - void updateCtrlsForTray( XW_TrayVisState newState ); - void startProgressBar(); - void advanceProgressBar(); - void finishProgressBar(); - - private: - CButton* addButtonAt( short id, short x, short y, char* str ); - CButton* addButtonAtBitmap( short id, short x, short y, const char* c, - IMAGE* img ); - void initUtil(); - void initPrefs(); - void loadPrefs(); - void loadGameFromStream( XWStreamCtxt* inStream ); - void makeNewGame( U16 newIndex ); - void loadCurrentGame(); - void saveCurrentGame(); - void resetCurrentGame(); - void positionBoard(); - void disOrEnableFrank( U16 id, XP_Bool enable ); - - void writeGameToStream( XWStreamCtxt* stream, U16 index ); - XWStreamCtxt* makeMemStream(); - - public: - void doCommit(); - void doHint( XP_Bool reset ); - void doUndo(); - void doHideTray(); - void doHeapDump(); - - BOOL newGame( XP_Bool allowCancel ); - void gameInfo(); - void doNewGameMenu(); -#ifndef HASBRO_EBM - void doSavedGames(); -#endif - void doAbout(); - void doEndGame(); - void doTileValues(); - void doGameHistory(); - - void fni(); - void displayFinalScores(); - XP_U16 displayTextFromStream( XWStreamCtxt* stream, const char* title, - BOOL killStream = TRUE, - BOOL includeCancel = FALSE ); - void wrappedEventLoop( CWindow* window ); - - MPSLOT -}; /* class CXWordsWindow */ - -#ifdef MEM_DEBUG -#define MEMPOOL(t) (t)->mpool, -#define MEMPOOL_NOCOMMA(t) (t)->mpool -#else -#define MEMPOOL_NOCOMMA(t) -#define MEMPOOL(t) -#endif - -#define V_BUTTON_SPACING 17 -#define BUTTON_LEFT 183 - -CXWordsWindow::CXWordsWindow(MPFORMAL FrankDictList* dlist ) - : CWindow(MAIN_WINDOW_ID, 0, 0, 200, 240, - "Crosswords 4" -) -{ - short buttonTop = BOARD_TOP; - MPASSIGN( this->mpool, mpool ); - fDictList = dlist; - - fVTableMgr = make_vtablemgr(MPPARM_NOCOMMA(mpool)); - - this->gamesDB = new CGamesDB( MEMPOOL(this) (XP_UCHAR*)"xwords_games" ); - - this->penDown = FALSE; - this->drawInProgress = FALSE; - fRobotHalted = XP_FALSE; - - this->cp.showBoardArrow = XP_TRUE; - this->cp.showRobotScores = XP_FALSE; /* No ui to turn on/off yet!! */ - - CButton* button; - button = addButtonAtBitmap( MAIN_FLIP_BUTTON_ID, BUTTON_LEFT, buttonTop, - "F", (IMAGE*)&flip ); - buttonTop += button->GetHeight() + 2; - button = addButtonAtBitmap( MAIN_VALUE_BUTTON_ID, BUTTON_LEFT, buttonTop, - "V", (IMAGE*)&valuebutton ); - buttonTop += button->GetHeight() + 2; - button = addButtonAtBitmap( MAIN_HINT_BUTTON_ID, BUTTON_LEFT, - buttonTop, "?", (IMAGE*)&lightbulb ); - buttonTop += button->GetHeight() + 2; - (void)addButtonAtBitmap( MAIN_UNDO_BUTTON_ID, BUTTON_LEFT, buttonTop, - "U", (IMAGE*)&undo ); - - fProgressRect.y = buttonTop + V_BUTTON_SPACING + 2; - - /* now start drawing from the bottom */ - buttonTop = 205; - button = addButtonAt( MAIN_COMMIT_BUTTON_ID, - BUTTON_LEFT, buttonTop, "D" ); - (void)addButtonAt( MAIN_HIDE_BUTTON_ID, - BUTTON_LEFT - button->GetWidth(), buttonTop, "H" ); - buttonTop -= V_BUTTON_SPACING; - (void)addButtonAt( MAIN_TRADE_BUTTON_ID, BUTTON_LEFT, buttonTop, "T" ); - buttonTop -= V_BUTTON_SPACING; - (void)addButtonAt( MAIN_JUGGLE_BUTTON_ID, BUTTON_LEFT, buttonTop, "J" ); - - this->draw = (FrankDrawCtx*)frank_drawctxt_make( MEMPOOL(this) this ); - - fProgressRect.x = BUTTON_LEFT + 2; - fProgressRect.width = 10; - fProgressRect.height = buttonTop - fProgressRect.y - 2; - - this->initUtil(); - - fGame.model = (ModelCtxt*)NULL; - fGame.server = (ServerCtxt*)NULL; - fGame.board = (BoardCtxt*)NULL; - - fAskTrayLimits = XP_FALSE; - - gi_initPlayerInfo( MEMPOOL(this) &fGameInfo, (XP_UCHAR*)"Player %d" ); - - U16 nRecords = gamesDB->countRecords(); - if ( nRecords == 0 ) { /* 1 for prefs, 1 for first game */ - initPrefs(); - - fGameInfo.serverRole = SERVER_STANDALONE; - /* fGameInfo.timerEnabled = XP_TRUE; */ - makeNewGame( fState.curGameIndex ); - - GUI_EventMessage( MSG_USER, this, NEWGAME_REQUEST ); - } else { - XP_ASSERT( nRecords >= 2 ); - loadPrefs(); - - /* there needs to be a "game" for the saved one to be loaded into. */ - game_makeNewGame( MPPARM(mpool) &fGame, &fGameInfo, &this->util, - (DrawCtx*)this->draw, 0, &this->cp, - (TransportSend)NULL, NULL); - loadCurrentGame(); - - positionBoard(); - server_do( fGame.server ); /* in case there's a robot */ - board_invalAll( fGame.board ); - } -} /* CXWordsWindow::CXWordsWindow */ - -XWStreamCtxt* -CXWordsWindow::makeMemStream() -{ - XWStreamCtxt* stream = mem_stream_make( MEMPOOL(this) - fVTableMgr, - this, - CHANNEL_NONE, - (MemStreamCloseCallback)NULL ); - return stream; -} /* makeMemStream */ - -void -CXWordsWindow::saveCurrentGame() -{ - XWStreamCtxt* stream = makeMemStream(); - writeGameToStream( stream, fState.curGameIndex ); - - U16 len = stream_getSize( stream ); - void* ptr = XP_MALLOC( this->mpool, len ); - stream_getBytes( stream, ptr, len ); - this->gamesDB->putNthRecord( fState.curGameIndex, ptr, len ); - XP_FREE( this->mpool, ptr ); - - stream_destroy( stream ); -} /* saveCurrentGame */ - -void -CXWordsWindow::positionBoard() -{ - board_setPos( fGame.board, BOARD_LEFT, BOARD_TOP, - XP_FALSE ); - board_setScale( fGame.board, BOARD_SCALE, BOARD_SCALE ); - - board_setScoreboardLoc( fGame.board, SCORE_LEFT, SCORE_TOP, - this->GetWidth()-SCORE_LEFT-TIMER_WIDTH, - SCORE_HEIGHT, XP_TRUE ); - - U16 trayTop = BOARD_TOP + (BOARD_SCALE * 15) + 2; - board_setTrayLoc( fGame.board, TRAY_LEFT, trayTop, - MIN_TRAY_SCALE, MIN_TRAY_SCALE, - FRANK_DIVIDER_WIDTH ); - - board_setTimerLoc( fGame.board, - this->GetWidth() - TIMER_WIDTH, - SCORE_TOP, TIMER_WIDTH, TIMER_HEIGHT ); -} /* positionBoard */ - -void -CXWordsWindow::makeNewGame( U16 newIndex ) -{ - XP_U32 gameID = frank_util_getCurSeconds( &this->util ); - if ( !!fGame.model ) { - saveCurrentGame(); - game_reset( MEMPOOL(this) &fGame, &fGameInfo, &this->util, - gameID, &this->cp, (TransportSend)NULL, NULL ); - } else { - game_makeNewGame( MPPARM(mpool) &fGame, &fGameInfo, &this->util, - (DrawCtx*)this->draw, gameID, &this->cp, - (TransportSend)NULL, NULL); - positionBoard(); - } - this->gamesDB->putNthName( newIndex, (XP_UCHAR*)"untitled game" ); - fState.curGameIndex = newIndex; -} /* makeNewGame */ - -CButton* -CXWordsWindow::addButtonAt( short id, short x, short y, char* str ) -{ - CButton* button = new CButton( id, 0, 0, str ); - this->AddChild( button, x, y ); - return button; -} /* addButtonAt */ - -CButton* -CXWordsWindow::addButtonAtBitmap( short id, short x, short y, const char* c, - IMAGE* img ) -{ - CButton* button = new CButton( id, 0, 0, (const char*)NULL, - img, (IMAGE*)NULL, (IMAGE*)NULL ); - this->AddChild( button, x+1, y ); - - return button; -} /* addButtonAtBitmap */ - -void -CXWordsWindow::initUtil() -{ - UtilVtable* vtable = this->util.vtable = new UtilVtable; - this->util.closure = (void*)this; - this->util.gameInfo = &fGameInfo; - MPASSIGN( this->util.mpool, mpool ); - -/* vtable->m_util_makeStreamFromAddr = NULL; */ - vtable->m_util_getVTManager = frank_util_getVTManager; - vtable->m_util_makeEmptyDict = frank_util_makeEmptyDict; -/* vtable->m_util_yOffsetChange = NULL <--no scrolling */ - vtable->m_util_userError = frank_util_userError; - vtable->m_util_userQuery = frank_util_userQuery; - vtable->m_util_userPickTile = frank_util_userPickTile; - vtable->m_util_askPassword = frank_util_askPassword; - vtable->m_util_trayHiddenChange = frank_util_trayHiddenChange; - vtable->m_util_notifyGameOver = frank_util_notifyGameOver; - vtable->m_util_hiliteCell = frank_util_hiliteCell; - vtable->m_util_engineProgressCallback = frank_util_engineProgressCallback; - vtable->m_util_setTimer = frank_util_setTimer; - vtable->m_util_requestTime = frank_util_requestTime; - vtable->m_util_getCurSeconds = frank_util_getCurSeconds; - - vtable->m_util_getSquareBonus = frank_util_getSquareBonus; - vtable->m_util_getUserString = frank_util_getUserString; - vtable->m_util_warnIllegalWord = frank_util_warnIllegalWord; -#ifdef SHOW_PROGRESS - vtable->m_util_engineStarting = frank_util_engineStarting; - vtable->m_util_engineStopping = frank_util_engineStopping; -#endif -} /* initUtil */ - -CXWordsWindow::~CXWordsWindow() -{ - XP_WARNF( "~CXWordsWindow(this=%p) called", this ); - - if ( !!this->gamesDB ) { - this->gamesDB->putNthRecord( 0, &fState, sizeof(fState) ); - saveCurrentGame(); - - delete this->gamesDB; - this->gamesDB = (CGamesDB*)NULL; - } - delete fDictList; -} - -void CXWordsWindow::Draw() -{ - if ( !this->drawInProgress ) { - this->drawInProgress = TRUE; - // don't call CWindow::Draw(); It erases the entire board - board_draw( fGame.board ); - - this->DrawChildren(); - this->drawInProgress = FALSE; - } -} // CXWordsWindow::Draw - -S32 -CXWordsWindow::MsgHandler( MSG_TYPE type, CViewable *from, S32 data ) -{ - S32 result = 0; - XP_Key xpkey; - S16 drag_x; - S16 drag_y; - XP_Bool handled; - - drag_x = (S16) (data >> 16); - drag_y = (S16) data; - - GUI_DisableTimers(); - switch (type) { - - case MSG_USER: - switch ( data ) { - case HINT_REQUEST: - doHint( XP_FALSE ); /* will reset if fails */ - break; - case SERVER_TIME_REQUEST: - this->clearUserEventPending(); /* clear before calling server! */ - if ( server_do( fGame.server ) ) { - GUI_NeedUpdate(); - } - break; - case NEWGAME_REQUEST: - this->newGame( XP_FALSE ); - break; - case FINALSCORE_REQUEST: - this->displayFinalScores(); - break; - } - break; - - case MSG_PEN_DOWN: - this->penDown = TRUE; - if ( board_handlePenDown( fGame.board, drag_x, drag_y, &handled ) ) { - GUI_NeedUpdate(); - result = 1; - } - board_pushTimerSave( fGame.board ); - break; - - case MSG_PEN_TRACK: - if ( this->penDown ) { - if ( board_handlePenMove( fGame.board, drag_x, drag_y ) ) { - GUI_NeedUpdate(); - result = 1; - } - } - break; - - case MSG_PEN_UP: - if ( this->penDown ) { - board_popTimerSave( fGame.board ); - if ( board_handlePenUp( fGame.board, drag_x, drag_y, 0 ) ) { - GUI_NeedUpdate(); - result = 1; - } - this->penDown = FALSE; - } - break; - - case MSG_TIMER: - fireTimer( (XWTimerReason)data ); - setTimerIfNeeded(); - GUI_NeedUpdate(); /* Needed off-emulator? PENDING */ - break; - - case MSG_BUTTON_SELECT: - result = 1; - switch (from->GetID()) { - case MAIN_FLIP_BUTTON_ID: - if ( board_flip( fGame.board ) ) { - GUI_NeedUpdate(); - } - break; - - case MAIN_VALUE_BUTTON_ID: - if ( board_toggle_showValues( fGame.board ) ) { - GUI_NeedUpdate(); - } - break; - - case MAIN_HINT_BUTTON_ID: - this->doHint( XP_FALSE ); - break; - - case MAIN_UNDO_BUTTON_ID: - this->doUndo(); - break; - - case MAIN_COMMIT_BUTTON_ID: - this->doCommit(); - break; - - case MAIN_TRADE_BUTTON_ID: - if ( board_beginTrade( fGame.board ) ) { - GUI_NeedUpdate(); - } - break; - - case MAIN_JUGGLE_BUTTON_ID: - if ( board_juggleTray( fGame.board ) ) { - GUI_NeedUpdate(); - } - break; - case MAIN_HIDE_BUTTON_ID: - this->doHideTray(); - break; - default: - result = 0; - } - break; - - case MSG_KEY: - xpkey = XP_KEY_NONE; - switch( data ) { - - case K_JOG_ENTER: - xpkey = XP_RETURN_KEY; - break; - - case K_JOG_DOWN: - xpkey = XP_CURSOR_KEY_RIGHT; - break; - - case K_JOG_UP: - xpkey = XP_CURSOR_KEY_LEFT; - break; - - case K_DELETE: - case K_BACKSPACE: - xpkey = XP_CURSOR_KEY_DEL; - break; - - default: - if ( isalpha( data ) ) { - xpkey = (XP_Key)toupper(data); - } - break; - - } - - if ( xpkey != XP_KEY_NONE ) { - if ( board_handleKey( fGame.board, xpkey ) ) { - GUI_NeedUpdate(); - result = 1; - } - } - - break; /* MSG_KEY */ - - default: - break; - } - GUI_EnableTimers(); - - if ( result == 0 ) { - result = CWindow::MsgHandler( type, from, data ); - } - return result; -} // CXWordsWindow::MsgHandler - -void -CXWordsWindow::setTimerIfNeeded() -{ - U32 mSeconds; - XWTimerReason why; - - if ( fTimerProcs[TIMER_PENDOWN] != NULL ) { /* faster, so higher priority */ - mSeconds = (U32)450; - why = TIMER_PENDOWN; - } else if ( fTimerProcs[TIMER_TIMERTICK] != NULL ) { - mSeconds = (U32)1000; - why = TIMER_TIMERTICK; - } else { - return; - } - - SetTimer( mSeconds, XP_FALSE, why ); -} /* setTimerIfNeeded */ - -void -CXWordsWindow::fireTimer( XWTimerReason why ) -{ - TimerProc proc = fTimerProcs[why]; - fTimerProcs[why] = (TimerProc)NULL; /* clear now; board may set it again */ - - (*proc)( fTimerClosures[why], why ); -} - -void -CXWordsWindow::setTimerImpl( XWTimerReason why, TimerProc proc, void* closure ) -{ - XP_ASSERT( why == TIMER_PENDOWN || - why == TIMER_TIMERTICK ); - - fTimerProcs[why] = proc; - fTimerClosures[why] = closure; - setTimerIfNeeded(); -} - -void -CXWordsWindow::disOrEnableFrank( U16 id, XP_Bool enable ) -{ - CButton* button = (CButton*)GetChildID( id ); - if ( enable ) { - button->Enable(); - } else { - button->Disable(); - } -} /* disOrEnableFrank */ - -void -CXWordsWindow::updateCtrlsForTray( XW_TrayVisState newState ) -{ - XP_ASSERT( newState != TRAY_HIDDEN ); - XP_Bool isRevealed = newState == TRAY_REVEALED; - - disOrEnableFrank( MAIN_HINT_BUTTON_ID, isRevealed ); - disOrEnableFrank( MAIN_UNDO_BUTTON_ID, isRevealed ); - disOrEnableFrank( MAIN_COMMIT_BUTTON_ID, isRevealed ); - disOrEnableFrank( MAIN_TRADE_BUTTON_ID, isRevealed ); - disOrEnableFrank( MAIN_JUGGLE_BUTTON_ID, isRevealed ); - disOrEnableFrank( MAIN_HIDE_BUTTON_ID, isRevealed ); -} /* updateCtrlsForTray */ - -void -CXWordsWindow::startProgressBar() -{ - if ( fState.showProgress ) { - - DrawRectFilled( &fProgressRect, COLOR_WHITE ); - DrawRect( &fProgressRect, COLOR_BLACK ); - - fProgressCurLine = 0; - } -} /* startProgressBar */ - -void -CXWordsWindow::finishProgressBar() -{ - if ( fState.showProgress ) { - DrawRectFilled( &fProgressRect, COLOR_WHITE ); - } -} /* finishProgressBar */ - -void -CXWordsWindow::advanceProgressBar() -{ - if ( fState.showProgress ) { - U16 line; - U16 height = fProgressRect.height - 2; /* don't overwrite top and - bottom */ - XP_Bool draw; - COLOR color; - - fProgressCurLine %= height * 2; - draw = fProgressCurLine < height; - - line = fProgressCurLine % (height) + 1; - line = fProgressRect.y + height - line + 1; - if ( draw ) { - color = COLOR_BLACK; - } else { - color = COLOR_WHITE; - } - - DrawLine( fProgressRect.x+1, line, - fProgressRect.x + fProgressRect.width - 1, line, color ); - - ++fProgressCurLine; - } -} /* advanceProgressBar */ - -void -CXWordsWindow::wrappedEventLoop( CWindow* window ) -{ - XP_Bool robotHalted = fRobotHalted; - fRobotHalted = XP_TRUE; - board_pushTimerSave( fGame.board ); - - GUI_EventLoop( window ); - - board_popTimerSave( fGame.board ); - fRobotHalted = robotHalted; -} /* wrappedEventLoop */ - -void -CXWordsWindow::gameInfo() -{ - BOOL ignore; - wrappedEventLoop( new CPlayersWindow( MEMPOOL(this) &fGameInfo, fDictList, - FALSE, FALSE, &ignore ) ); -} /* gameInfo */ - -BOOL -CXWordsWindow::newGame( XP_Bool allowCancel ) -{ - BOOL cancelled; - wrappedEventLoop( new CPlayersWindow( MEMPOOL(this) &fGameInfo, fDictList, - TRUE, allowCancel, &cancelled ) ); - - XP_ASSERT( allowCancel || !cancelled ); /* can't clear cancelled if not - allowed to */ - if ( !cancelled ) { - XP_U32 gameID = frank_util_getCurSeconds( &this->util ); - game_reset( MPPARM(mpool) &fGame, &fGameInfo, &this->util, gameID, - &this->cp, (TransportSend)NULL, NULL ); - if ( !!fGameInfo.dictName ) { - DictionaryCtxt* dict = model_getDictionary( fGame.model ); - if ( !!dict && 0==strcmp( (char*)dict_getName(dict), - (char*)fGameInfo.dictName)){ - /* do nothing; this dict's fine */ - } else { - if ( !!dict ) { - dict_destroy( dict ); - } - dict = frank_dictionary_make( MPPARM(mpool) - fGameInfo.dictName); - model_setDictionary( fGame.model, dict ); - } - } - server_do( fGame.server ); - - GUI_NeedUpdate(); - } - - return !cancelled; -} /* newGame */ - -/* ======================================================================== */ -void -Init_Window( MPFORMAL FrankDictList* dlist ) -{ - MainWindow = new CXWordsWindow( MPPARM(mpool) dlist ); -} - -void -Init_Menu() -{ - short row; - CMenu* menu; - - menu = new CMenu( FILEMENU_WINDOW_ID ); - menu->SetNumRows( 4 ); /* 4 with preferences */ - row = 0; - menu->SetRow( row++, FILEMENU_NEWGAME, "New game", 'n' ); - menu->SetRow( row++, FILEMENU_SAVEDGAMES, "Saved games..." ); - menu->SetSeparatorRow( row++ ); -/* menu->SetRow( row++, FILEMENU_PREFS, "Preferences..." ); */ -#ifdef HASBRO_EBM - menu->SetRow( row++, FILEMENU_ABOUT, "About Franklin Scrabble(tm)..." ); -#else - menu->SetRow( row++, FILEMENU_ABOUT, "About Crosswords..." ); -#endif - MainMenuBar.AddButton( new CPushButton(FILEMENU_BUTTON_ID,0,0,"File"), - menu ); - - menu = new CMenu( GAMEMENU_WINDOW_ID ); - menu->SetNumRows( 4 ); - row = 0; - menu->SetRow( row++, GAMEMENU_TVALUES, "Tile values", 'v' ); - menu->SetRow( row++, GAMEMENU_GAMEINFO, "Current game info", 'i' ); - menu->SetRow( row++, GAMEMENU_HISTORY, "Game history", 's' ); - menu->SetRow( row++, GAMEMENU_FINALSCORES, "Final scores", 'f' ); - MainMenuBar.AddButton( new CPushButton(GAMEMENU_BUTTON_ID,0,0,"Game"), - menu ); - - menu = new CMenu( MOVEMENU_WINDOW_ID ); - menu->SetNumRows( 9 ); - row = 0; - menu->SetRow( row++, MOVEMENU_HINT, "Hint", 'h' ); - menu->SetRow( row++, MOVEMENU_NEXTHINT, "Next hint", 'n' ); - menu->SetRow( row++, MOVEMENU_REVERT, "Revert move", 'r' ); - menu->SetRow( row++, MOVEMENU_UNDO, "Undo prev. move", 'u' ); - menu->SetSeparatorRow( row++ ); - menu->SetRow( row++, MOVEMENU_DONE, "Done", 'd' ); - menu->SetRow( row++, MOVEMENU_JUGGLE, "Juggle", 'j' ); - menu->SetRow( row++, MOVEMENU_TRADE, "Trade", 't' ); - menu->SetRow( row++, MOVEMENU_HIDETRAY, "Hide tray", 'h' ); - - MainMenuBar.AddButton( new CPushButton(MOVEMENU_BUTTON_ID,0,0,"Move"), - menu ); - -#ifdef MEM_DEBUG - menu = new CMenu( MOVEMENU_WINDOW_ID ); - menu->SetNumRows( 1 ); - row = 0; - menu->SetRow( row++, DEBUGMENU_HEAPDUMP, "Heap dump" ); - - MainMenuBar.AddButton( new CPushButton(DEBUGMENU_BUTTON_ID,0,0,"Debug"), - menu ); -#endif - -} - -void -MyErrorHandler( const char *filename, int lineno, const char *failexpr ) -{ - if (lineno != -1 || strcmp( failexpr, "Out of memory" )) { - return; - } - - GUI_Alert( ALERT_WARNING, - "Operation cancelled - insufficient memory" ); - GUI_SetMallocReserve( 1536 ); - GUI_ClearStack(); -} - -S32 -GUI_main( MSG_TYPE type, CViewable *object, S32 data ) -{ - switch (type) { - case MSG_APP_START: { - FrankDictList* dlist; - if (OS_is_present && hostIO_am_I_the_current_task()) { - HOSTIO_INLINE_BREAKPOINT(); - } - - struct timeval tv; - gettimeofday( &tv, (struct timezone *)NULL ); - srand( tv.tv_sec /*20*/ /*TIMER_GetTickCountUSecs()*/ ); - -#ifdef MEM_DEBUG - MemPoolCtx* mpool = mpool_make(); -#endif - - dlist = new FrankDictList( MPPARM_NOCOMMA(mpool) ); - if ( dlist->GetDictCount() > 0 ) { - Init_Window( MPPARM(mpool) dlist ); - Init_Menu(); - GUI_SetErrorHandler( MyErrorHandler ); - } else { - delete dlist; -#ifdef MEM_DEBUG - mpool_destroy( mpool ); -#endif - GUI_Alert( ALERT_WARNING, - "Crosswords requires at least one dictionary." ); - GUI_Exit(); - } - return 1; - } - - case MSG_APP_STOP: - delete MainWindow; /* trigger save */ - return 1; - - case MSG_KEY: - if ( data == K_MENU ) { - MainMenuBar.Show(); - return 1; - } - break; - - case MSG_MENU_SELECT: - if (data == -1) { - /* We don't care about menu cancellations */ - return 1; - } - switch ((U16) data) { - - case FILEMENU_NEWGAME: - MainWindow->doNewGameMenu(); - return 1; - - case FILEMENU_SAVEDGAMES: -#ifdef HASBRO_EBM - GUI_Alert( ALERT_WARNING, "Feature not available in demo version." ); -#else - MainWindow->doSavedGames(); -#endif - return 1; - - /* case FILEMENU_PREFS: */ - case FILEMENU_ABOUT: - MainWindow->doAbout(); - return 1; - - case GAMEMENU_TVALUES: - MainWindow->doTileValues(); - return 1; - - case GAMEMENU_FINALSCORES: - MainWindow->doEndGame(); - return 1; - break; - - case GAMEMENU_GAMEINFO: - MainWindow->gameInfo(); - return 1; - - case GAMEMENU_HISTORY: - MainWindow->doGameHistory(); - return 1; - - case MOVEMENU_HINT: - case MOVEMENU_NEXTHINT: - MainWindow->doHint( (U16)data == MOVEMENU_HINT ); - break; - - case MOVEMENU_UNDO: - MainWindow->doUndo(); - break; - - case MOVEMENU_REVERT: - break; - case MOVEMENU_DONE: - MainWindow->doCommit(); - break; - case MOVEMENU_JUGGLE: - case MOVEMENU_TRADE: - break; - case MOVEMENU_HIDETRAY: - MainWindow->doHideTray(); - break; -#ifdef MEM_DEBUG - case DEBUGMENU_HEAPDUMP: - MainWindow->doHeapDump(); - break; -#endif - } - break; - default: - fallthru; - } - return 0; -} // GUI_main - -void -CXWordsWindow::doHint( XP_Bool reset ) -{ - XP_Bool workRemains = XP_FALSE; - XP_Bool done; - - if ( reset ) { - board_resetEngine( fGame.board ); - } - done = board_requestHint( fGame.board, - fAskTrayLimits, &workRemains ); - if ( done ) { - GUI_NeedUpdate(); - } - if ( workRemains ) { - GUI_EventMessage( MSG_USER, this, HINT_REQUEST ); - } -} /* handleHintMenu */ - -void -CXWordsWindow::doUndo() -{ - if ( server_handleUndo( fGame.server ) ) { - GUI_NeedUpdate(); - } -} /* doUndo */ - -void -CXWordsWindow::doHideTray() -{ - if ( board_hideTray( fGame.board ) ) { - GUI_NeedUpdate(); - } -} /* doHideTray */ - -#ifdef MEM_DEBUG -void -CXWordsWindow::doHeapDump() -{ - XWStreamCtxt* stream = makeMemStream(); - mpool_stats( mpool, stream ); - - XP_U16 size = stream_getSize( stream ); - char* buf = (char*)malloc(size+1); - stream_getBytes( stream, buf, size ); - buf[size] = '\0'; - perror(buf); /* XP_DEBUGF has 256 byte limit */ - free( buf ); -} /* CXWordsWindow::doHeapDump */ -#endif - -void -CXWordsWindow::doCommit() -{ - if ( board_commitTurn( fGame.board ) ) { - GUI_NeedUpdate(); - } -} /* doCommit */ - -/* If there's a game in progress (and there always is, I think), ask user if - * wants to save. If does, save that game and make a new one, with a new - * index, to call the gui on. Else reset the existing one and call the gui.*/ -void -CXWordsWindow::doNewGameMenu() -{ - XP_Bool doit = XP_TRUE; - /* OK returns 1 */ - if ( 0 == GUI_Alert( ALERT_OK, - "Click \"OK\" to replace the current game with a new " - "one, or \"Cancel\" to add without deleting the current " - "game." ) ) { - makeNewGame( this->gamesDB->countRecords() ); - } else if ( 0 == GUI_Alert( ALERT_OK, - "Are you sure you want to replace" - " the existing game?" ) ) { - doit = XP_FALSE; - } - - if ( doit && newGame( XP_FALSE ) ) { /* don't let user cancel; too late! */ - positionBoard(); - } - - board_invalAll( fGame.board ); - GUI_NeedUpdate(); -} /* doNewGameMenu */ - -#ifndef HASBRO_EBM -void -CXWordsWindow::doSavedGames() -{ - U16 openIndex; /* what index am I to open? */ - U16 curIndex = fState.curGameIndex; /* may change if lower-index - game deleted */ - saveCurrentGame(); /* so can be duped */ - wrappedEventLoop( new CSavedGamesWindow( this->gamesDB, &openIndex, - &curIndex) ); - - fState.curGameIndex = curIndex; - if ( curIndex != openIndex ) { - fState.curGameIndex = openIndex; - loadCurrentGame(); - positionBoard(); - server_do( fGame.server ); /* in case there's a robot */ - board_invalAll( fGame.board ); - GUI_NeedUpdate(); - } -} /* doSavedGames */ -#endif - -void -CXWordsWindow::doAbout() -{ - XP_U16 ignore; - XWStreamCtxt* stream; - - stream = makeMemStream(); - char* txt = "Crosswords " VERSION_STRING "\n" - "Copyright 2000-2004 by Eric House (xwords@eehouse.org).\n" - "All rights reserved.\n" - "For further information see www.peak.org/~fixin/xwords/ebm.html."; - stream_putString( stream, txt ); - stream_putU8( stream, '\0' ); - - wrappedEventLoop( new CShowTextWindow( MEMPOOL(this) stream, - "About Crosswords", - true, false, - &ignore ) ); -} /* doAbout */ - -void -CXWordsWindow::doEndGame() -{ - if ( server_getGameIsOver( fGame.server ) ) { - this->displayFinalScores(); - } else if ( GUI_Alert( ALERT_OK, - "Are you sure you want to end the game now?" ) - != 0 ) { - server_endGame( fGame.server ); - } - GUI_NeedUpdate(); -} /* doEndGame */ - -void -CXWordsWindow::doTileValues() -{ - XWStreamCtxt* stream; - - stream = makeMemStream(); - server_formatDictCounts( fGame.server, stream, 2 /* cols */ ); - - displayTextFromStream( stream, "Tile counts and values" ); -} /* doTileValues */ - -void -CXWordsWindow::doGameHistory() -{ - XP_Bool gameOver = server_getGameIsOver( fGame.server ); - XWStreamCtxt* stream = makeMemStream(); - model_writeGameHistory( fGame.model, stream, fGame.server, gameOver ); - - displayTextFromStream( stream, "Game history" ); -} /* doGameHistory */ - -void -CXWordsWindow::initPrefs() -{ - fState.magic = 0x12345678; - fState.curGameIndex = 1; /* 0 is prefs record */ - fState.showProgress = XP_TRUE; - - /* save 'em now so we can save 1st game at expected index. */ - this->gamesDB->putNthRecord( 0, &fState, sizeof(fState) ); -} /* initPrefs */ - -void -CXWordsWindow::loadPrefs() -{ - CGamesDB* gamesDB = this->gamesDB; - XP_ASSERT( gamesDB->countRecords() > 0 ); - - U16 len; - void* recordP = gamesDB->getNthRecord( 0, &len ); - - XP_ASSERT( len == sizeof(fState) ); - XP_ASSERT( !!recordP ); - XP_MEMCPY( &fState, recordP, len ); - gamesDB->recordRelease(0); - - XP_ASSERT( fState.magic == 0x12345678 ); -} /* loadPrefs */ - -void -CXWordsWindow::loadCurrentGame() -{ - U16 len; - void* recordP = gamesDB->getNthRecord( fState.curGameIndex, &len ); - - XWStreamCtxt* inStream = makeMemStream(); - stream_putBytes( inStream, recordP, len ); - gamesDB->recordRelease( fState.curGameIndex ); - - loadGameFromStream( inStream ); - stream_destroy( inStream ); -} /* loadCurrentGame */ - -void -CXWordsWindow::writeGameToStream( XWStreamCtxt* stream, U16 index ) -{ - /* the dictionary */ - DictionaryCtxt* dict = model_getDictionary( fGame.model ); - XP_UCHAR* dictName = dict_getName( dict ); - stream_putU8( stream, !!dictName ); - if ( !!dictName ) { - stringToStream( stream, dictName ); - } - - game_saveToStream( &fGame, &fGameInfo, stream ); -} /* writeGameToStream */ - -void -CXWordsWindow::loadGameFromStream( XWStreamCtxt* inStream ) -{ - /* the dictionary */ - XP_U8 hasDictName = stream_getU8( inStream ); - DictionaryCtxt* dict = (DictionaryCtxt*)NULL; - if ( hasDictName ) { - XP_UCHAR* name = stringFromStream(MEMPOOL(this) inStream); - dict = frank_dictionary_make( MPPARM(mpool) name ); - } - - game_makeFromStream( MPPARM(mpool) inStream, &fGame, &fGameInfo, - dict, &this->util, (DrawCtx*)this->draw, &this->cp, - (TransportSend)NULL, NULL ); -} /* loadGameFromStream */ - -void -CXWordsWindow::fni() -{ - GUI_Alert( ALERT_WARNING, "Feature pending" ); - board_invalAll( fGame.board ); - GUI_NeedUpdate(); -} /* fni */ - -void -CXWordsWindow::displayFinalScores() -{ - XWStreamCtxt* stream; - - stream = makeMemStream(); - server_writeFinalScores( fGame.server, stream ); - - displayTextFromStream( stream, "Final scores" ); -} /* displayFinalScores */ - -XP_U16 -CXWordsWindow::displayTextFromStream( XWStreamCtxt* stream, - const char* title, /* should be ID!!! */ - BOOL killStream, - BOOL includeCancel ) -{ - XP_U16 result = 0; - wrappedEventLoop( new CShowTextWindow( MEMPOOL(this) stream, title, - killStream, includeCancel, - &result ) ); - return result; -} /* displayTextFromStream */ - -extern "C" { - - int - frank_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... ) - { - va_list ap; - - va_start(ap, format); - - vsnprintf((char*)buf, len, (char*)format, ap); - - va_end(ap); - - return strlen((char*)buf); - } /* frank_snprintf */ - - void - frank_debugf( char* format, ... ) - { - char buf[256]; - va_list ap; - - va_start(ap, format); - - vsprintf(buf, format, ap); - - va_end(ap); - - perror(buf); - } // debugf - - XP_UCHAR* - frankCopyStr( MPFORMAL const XP_UCHAR* buf ) - { - XP_U16 len = XP_STRLEN(buf) + 1; - XP_UCHAR* result = (XP_UCHAR*)XP_MALLOC( mpool, len ); - XP_MEMCPY( result, buf, len ); - return result; - } /* frankCopyStr */ - - unsigned long - frank_flipLong( unsigned long l ) - { - unsigned long result = - ((l & 0x000000FF) << 24) | - ((l & 0x0000FF00) << 8) | - ((l & 0x00FF0000) >> 8) | - ((l & 0xFF000000) >> 24); - return result; - } /* frank_flipLong */ - - unsigned short - frank_flipShort(unsigned short s) - { - unsigned short result = - ((s & 0x00FF) << 8) | - ((s & 0xFF00) >> 8); - - return result; - } /* frank_flipShort */ - -} -/***************************************************************************** - * These are the callbacks intstalled in the util vtable - ****************************************************************************/ -static VTableMgr* -frank_util_getVTManager( XW_UtilCtxt* uc ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - return self->fVTableMgr; -} /* frank_util_getVTManager */ - -static DictionaryCtxt* -frank_util_makeEmptyDict( XW_UtilCtxt* uc ) -{ - return frank_dictionary_make( MPPARM(uc->mpool) (XP_UCHAR*)NULL ); -} /* frank_util_makeEmptyDict */ - -static void -frank_util_userError( XW_UtilCtxt* uc, UtilErrID id ) -{ - const char *message; -/* - BOOL GUI_Alert( ALERT type, const char *text ); - Puts up an alert window, which is a small window containing an icon, some text, and one or more buttons. - These types of alerts are offered: - ALERT_BUG: Insect icon and "Abort" button (click terminates application). Does not return. - ALERT_FATAL: Octagonal icon and "Stop" button (click terminates application). Does not return. - ALERT_ERROR: Exclamation-point icon and "Cancel" button (click returns 0). - ALERT_WARNING: Info icon and "OK" button (click returns 0). - ALERT_OK: Question-mark icon, buttons "OK" (click returns 1) and "Cancel" (click returns 0). - ALERT_RETRY: Exclamation-point icon and buttons "Try again" (returns 1) and "Exit" (returns 0). -*/ - switch( id ) { - case ERR_TILES_NOT_IN_LINE: - message = "All tiles played must be in a line."; - break; - case ERR_NO_EMPTIES_IN_TURN: - message = "Empty squares cannot separate tiles played."; - break; - - case ERR_TWO_TILES_FIRST_MOVE: - message = "Must play two or more pieces on the first move."; - break; - case ERR_TILES_MUST_CONTACT: - message = "New pieces must contact others already in place (or " - "the middle square on the first move)."; - break; - case ERR_NOT_YOUR_TURN: - message = "You can't do that; it's not your turn!"; - break; - case ERR_NO_PEEK_ROBOT_TILES: - message = "No peeking at the robot's tiles!"; - break; - case ERR_CANT_TRADE_MID_MOVE: - message = "Remove played tiles before trading."; - break; - case ERR_TOO_FEW_TILES_LEFT_TO_TRADE: - message = "Too few tiles left to trade."; - break; - default: - message = "unknown errorcode ID!!!"; - break; - } - - (void)GUI_Alert( ALERT_ERROR, message ); - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - board_invalAll( self->fGame.board ); - GUI_NeedUpdate(); -} /* frank_util_userError */ - -static XP_Bool -frank_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream ) -{ - char* question; - XP_U16 askResult; - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - - switch( id ) { - case QUERY_COMMIT_TURN: - askResult = self->displayTextFromStream( stream, "Query", - FALSE, TRUE ); - return askResult; - case QUERY_COMMIT_TRADE: - question = "Really trade the selected tiles?"; - break; - case QUERY_ROBOT_MOVE: - case QUERY_ROBOT_TRADE: - XP_LOGF( "handling robot info" ); - askResult = self->displayTextFromStream( stream, "Robot move", - FALSE, FALSE ); - return askResult; - break; - default: - question = "Unimplemented query code!!!"; - break; - } - - askResult = GUI_Alert( ALERT_OK, question ); - board_invalAll( self->fGame.board ); - GUI_NeedUpdate(); - return askResult != 0; -} /* frank_util_userQuery */ - -static XP_S16 -frank_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi, - XP_U16 playerNum, - const XP_UCHAR4* texts, XP_U16 nTiles ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - XP_S16 result; - self->wrappedEventLoop( new CAskLetterWindow( pi, playerNum, - texts, nTiles, &result ) ); - return result; - /* doesn't need to inval because CAskLetterWindow saves bits behind */ -} /* frank_util_askBlankFace */ - -static XP_Bool -frank_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name, XP_UCHAR* buf, - XP_U16* lenp ) -{ - XP_Bool ok; - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - self->wrappedEventLoop( new CAskPasswdWindow( name, buf, lenp, &ok ) ); - return ok; -} /* frank_util_askPassword */ - -static void -frank_util_trayHiddenChange( XW_UtilCtxt* uc, XW_TrayVisState newState ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - self->updateCtrlsForTray( newState ); -} /* frank_util_trayHiddenChange */ - -static void -frank_util_notifyGameOver( XW_UtilCtxt* uc ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - board_invalAll( self->fGame.board ); - GUI_NeedUpdate(); - GUI_EventMessage( MSG_USER, self, FINALSCORE_REQUEST ); -} /* frank_util_notifyGameOver */ - -static XP_Bool -frank_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - XP_Bool halted = self->robotIsHalted(); - if ( !halted ) { - board_hiliteCellAt( self->fGame.board, col, row ); - } - BOOL waiting = EVNT_IsWaiting(); - return !waiting && !halted; -} /* frank_util_hiliteCell */ - -/* Return false to get engine to abort search. - */ -static XP_Bool -frank_util_engineProgressCallback( XW_UtilCtxt* uc ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - - self->advanceProgressBar(); - - BOOL waiting = EVNT_IsWaiting(); - return !waiting && !self->robotIsHalted(); -} /* frank_util_engineProgressCallback */ - -static void -frank_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when, - TimerProc proc, void* closure ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - self->setTimerImpl( why, proc, closure ); -} /* frank_util_setTimer */ - -static void -frank_util_requestTime( XW_UtilCtxt* uc ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - if ( !self->getUserEventPending() ) { - GUI_EventMessage( MSG_USER, self, SERVER_TIME_REQUEST ); - self->setUserEventPending(); - } -} /* frank_util_requestTime */ - -static XP_U32 -frank_util_getCurSeconds( XW_UtilCtxt* uc ) -{ - struct timeval tv; - gettimeofday( &tv, (struct timezone *)NULL ); - return tv.tv_sec; -} /* frank_util_getCurSeconds */ - -#define EM BONUS_NONE -#define DL BONUS_DOUBLE_LETTER -#define DW BONUS_DOUBLE_WORD -#define TL BONUS_TRIPLE_LETTER -#define TW BONUS_TRIPLE_WORD - -static XWBonusType -frank_util_getSquareBonus( XW_UtilCtxt* uc, ModelCtxt* model, - XP_U16 col, XP_U16 row ) -{ - XP_U16 index; - - const char scrabbleBoard[8*8] = { - TW,EM,EM,DL,EM,EM,EM,TW, - EM,DW,EM,EM,EM,TL,EM,EM, - - EM,EM,DW,EM,EM,EM,DL,EM, - DL,EM,EM,DW,EM,EM,EM,DL, - - EM,EM,EM,EM,DW,EM,EM,EM, - EM,TL,EM,EM,EM,TL,EM,EM, - - EM,EM,DL,EM,EM,EM,DL,EM, - TW,EM,EM,DL,EM,EM,EM,DW, - }; /* scrabbleBoard */ - - if ( col > 7 ) col = 14 - col; - if ( row > 7 ) row = 14 - row; - index = (row*8) + col; - if ( index >= 8*8 ) { - return (XWBonusType)EM; - } else { - return (XWBonusType)scrabbleBoard[index]; - } -} /* frank_util_getSquareBonus */ - -static XP_UCHAR* -frank_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode ) -{ - switch( stringCode ) { - case STRD_REMAINING_TILES_ADD: - return (XP_UCHAR*)"+ %d [all remaining tiles]"; - case STRD_UNUSED_TILES_SUB: - return (XP_UCHAR*)"- %d [unused tiles]"; - case STR_BONUS_ALL: - return (XP_UCHAR*)"Bonus for using all tiles: 50\n"; - case STRD_TURN_SCORE: - return (XP_UCHAR*)"Score for turn: %d\n"; - case STR_COMMIT_CONFIRM: - return (XP_UCHAR*)"Commit the current move?\n"; - case STR_NONLOCAL_NAME: - return (XP_UCHAR*)"%s (remote)"; - case STR_LOCAL_NAME: - return (XP_UCHAR*)"%s"; - case STRD_TIME_PENALTY_SUB: - return (XP_UCHAR*)" - %d [time]"; - - case STRD_CUMULATIVE_SCORE: - return (XP_UCHAR*)"Cumulative score: %d\n"; - case STRS_MOVE_ACROSS: - return (XP_UCHAR*)"move (from %s across)\n"; - case STRS_MOVE_DOWN: - return (XP_UCHAR*)"move (from %s down)\n"; - case STRS_TRAY_AT_START: - return (XP_UCHAR*)"Tray at start: %s\n"; - - case STRS_NEW_TILES: - return (XP_UCHAR*)"New tiles: %s\n"; - case STRSS_TRADED_FOR: - return (XP_UCHAR*)"Traded %s for %s."; - case STR_PASS: - return (XP_UCHAR*)"pass\n"; - case STR_PHONY_REJECTED: - return (XP_UCHAR*)"Illegal word in move; turn lost!\n"; - case STRD_ROBOT_TRADED: - return (XP_UCHAR*)"Robot traded %d tiles this turn."; - case STR_ROBOT_MOVED: - return (XP_UCHAR*)"The robot made this move:\n"; - - case STR_PASSED: - return (XP_UCHAR*)"Passed"; - case STRSD_SUMMARYSCORED: - return (XP_UCHAR*)"%s:%d"; - case STRD_TRADED: - return (XP_UCHAR*)"Traded %d"; - case STR_LOSTTURN: - return (XP_UCHAR*)"Lost turn"; - - case STRS_VALUES_HEADER: - return (XP_UCHAR*)"%s counts/values:\n"; - - default: - return (XP_UCHAR*)"unknown code "; - } -} /* frank_util_getUserString */ - -static void -formatBadWords( BadWordInfo* bwi, char buf[] ) -{ - XP_U16 i; - - for ( i = 0, buf[0] = '\0'; ; ) { - char wordBuf[18]; - sprintf( wordBuf, "\"%s\"", bwi->words[i] ); - strcat( buf, wordBuf ); - if ( ++i == bwi->nWords ) { - break; - } - strcat( buf, ", " ); - } -} /* formatBadWords */ - -static XP_Bool -frank_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, - XP_U16 turn, XP_Bool turnLost ) -{ - char buf[200]; - char wordsBuf[150]; - XP_Bool result; - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - - formatBadWords( bwi, wordsBuf ); - - if ( turnLost ) { - XP_UCHAR* name = self->fGameInfo.players[turn].name; - XP_ASSERT( !!name ); - sprintf( buf, "Player %d (%s) played illegal word[s] " - "%s; loses turn", - turn+1, name, wordsBuf ); - (void)GUI_Alert( ALERT_ERROR, buf ); - result = XP_TRUE; - } else { - sprintf( buf, "Word %s not in the current dictionary. " - "Use it anyway?", wordsBuf ); - result = GUI_Alert( ALERT_OK, buf ); - } - return result; -} /* frank_util_warnIllegalWord */ - -#ifdef SHOW_PROGRESS -static void -frank_util_engineStarting( XW_UtilCtxt* uc, XP_U16 nBlanks ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - self->startProgressBar(); -} /* frank_util_engineStarting */ - -static void -frank_util_engineStopping( XW_UtilCtxt* uc ) -{ - CXWordsWindow* self = (CXWordsWindow*)uc->closure; - self->finishProgressBar(); -} /* frank_util_engineStopping */ -#endif /* SHOW_PROGRESS */ diff --git a/xwords4/franklin/frankmain.h b/xwords4/franklin/frankmain.h deleted file mode 100644 index 0b16f612d..000000000 --- a/xwords4/franklin/frankmain.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2000 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKMAIN_H_ -#define _FRANKMAIN_H_ - -#include -#include -#include -#include -#include "sys.h" -#include "gui.h" -#include "OpenDatabases.h" -/* #include "FieldMgr.h" */ - -#include "ebm_object.h" - -#define SCREEN_WIDTH 200 - -#define BOARD_LEFT 2 - -#define SCORE_LEFT BOARD_LEFT -#define SCORE_TOP 3 -#define SCORE_WIDTH SCREEN_WIDTH -#define SCORE_HEIGHT 13 - -#define TIMER_WIDTH 36 -#define TIMER_HEIGHT SCORE_HEIGHT - -#define BOARD_TOP SCORE_HEIGHT+SCORE_TOP -#define BOARD_SCALE 12 - -#define TRAY_LEFT BOARD_LEFT -#define MIN_TRAY_SCALE 23 -#define FRANK_DIVIDER_WIDTH 5 - -#define VERSION_STRING "4.0.7a1" - -extern "C" { - - typedef struct FrankDrawCtx { - DrawCtxVTable* vtable; - CWindow* window; - const FONT* scoreFnt; - const FONT* scoreFntBold; - const FONT* trayFont; - const FONT* valFont; - const IMAGE rightcursor; - const IMAGE downcursor; - const IMAGE startMark; -#ifdef USE_PATTERNS - const IMAGE bonusImages[BONUS_LAST]; -#endif - } FrankDrawCtx; - - void debugf( char* format, ... ); - -} /* extern "C" */ - -#endif diff --git a/xwords4/franklin/frankpasswd.cpp b/xwords4/franklin/frankpasswd.cpp deleted file mode 100644 index 677c9966a..000000000 --- a/xwords4/franklin/frankpasswd.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include "sys.h" -#include "gui.h" -#include "ebm_object.h" - -extern "C" { -#include "xptypes.h" -} - -#include "frankpasswd.h" - -#include "frankids.h" - -#define TEXT_ID 2000 -#define PASSWD_WIDTH 105 -#define PASSWD_HEIGHT 12 - -#define LABEL_X 10 -#define LABEL_Y 10 -#define PASSWD_X LABEL_X -#define PASSWD_Y (LABEL_Y+15) - -#define BUTTON_Y (PASSWD_Y+20) -#define OK_BUTTON_X 30 -#define CANCEL_BUTTON_X 100 -#define PASS_CANCEL_ID 2001 -#define PASS_OK_ID 2002 -#define LABEL_ID 2003 - -CAskPasswdWindow::CAskPasswdWindow( const XP_UCHAR* name, XP_UCHAR* buf, - XP_U16* len, XP_Bool* result ) - : CWindow( PASSWORD_WINDOW_ID, 10, 120, 180, 85, "Password", TRUE ) -{ - fName = name; - fBuf = buf; - this->lenp = len; - this->okP = result; - - snprintf( fLabelBuf, sizeof(fLabelBuf), "Password for %s:", name ); - CLabel* label = new CLabel( LABEL_ID, fLabelBuf ); - this->AddChild( label, LABEL_X, LABEL_Y ); - - this->entry = new CTextEdit( TEXT_ID, PASSWD_WIDTH, PASSWD_HEIGHT, - TEXTOPTION_PASSWORD - | TEXTOPTION_ONELINE - | TEXTOPTION_HAS_FOCUS); - this->AddChild( this->entry, PASSWD_X, PASSWD_Y ); - this->SetFocus( this->entry ); - - CButton* button = new CButton( PASS_CANCEL_ID, 0, 0, "Cancel" ); - this->AddChild( button, CANCEL_BUTTON_X, BUTTON_Y ); - button = new CButton( PASS_OK_ID, 0, 0, "Ok" ); - this->AddChild( button, OK_BUTTON_X, BUTTON_Y ); -} // CAskWindow - -S32 -CAskPasswdWindow::MsgHandler( MSG_TYPE type, CViewable *object, S32 data ) -{ - S32 result = 0; - char* text; - XP_U16 len; - - switch (type) { - case MSG_BUTTON_SELECT: // there's only one button.... - switch ( object->GetID() ) { - case PASS_OK_ID: - text = this->entry->GetText(); - len = this->entry->TextLength(); - strncpy( (char*)fBuf, text, XP_MIN(len,*this->lenp) ); - fBuf[len] = '\0'; - *this->lenp = len; - *this->okP = XP_TRUE; - break; - case PASS_CANCEL_ID: - *this->okP = XP_FALSE; - break; - default: - return 0; - } - result = 1; - this->Close(); - break; - - default: - break; - } - - return result; -} // CAskLetterWindow::MsgHandler - - - diff --git a/xwords4/franklin/frankpasswd.h b/xwords4/franklin/frankpasswd.h deleted file mode 100644 index 540c0a76d..000000000 --- a/xwords4/franklin/frankpasswd.h +++ /dev/null @@ -1,40 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKPASSWD_H_ -#define _FRANKPASSWD_H_ - -#include "comtypes.h" - -class CAskPasswdWindow : public CWindow { - private: - const XP_UCHAR* fName; - XP_UCHAR* fBuf; - XP_U16* lenp; - XP_Bool* okP; - CTextEdit* entry; - char fLabelBuf[64]; - public: - CAskPasswdWindow( const XP_UCHAR* name, XP_UCHAR* buf, XP_U16* len, - XP_Bool* result ); - S32 MsgHandler( MSG_TYPE type, CViewable *object, S32 data ); -}; - - -#endif /* _FRANKPASSWD_H_ */ diff --git a/xwords4/franklin/frankplayer.cpp b/xwords4/franklin/frankplayer.cpp deleted file mode 100644 index 444e54d1e..000000000 --- a/xwords4/franklin/frankplayer.cpp +++ /dev/null @@ -1,466 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include "sys.h" -#include "gui.h" -#include "ebm_object.h" - -extern "C" { -#include "xptypes.h" -#include "strutils.h" -#include "mempool.h" -} - -#include "frankids.h" -#include "frankplayer.h" -#include "frankdict.h" - - -#define PLAYERCOUNT_MENU_ID 2000 -#define NUMPLAYERS_POPUP_ID 2001 -#define NAME_LABEL_ID 2002 -#define ROBOT_LABEL_ID 2003 -#define PASSWORD_LABEL_ID 2004 -#define OK_BUTTON_ID 2005 -#define CANCEL_BUTTON_ID 2006 -#define REVERT_BUTTON_ID 2007 -#define COUNT_LABEL_ID 2008 -#define PLAYERDICT_MENU_ID 2009 -#define DICTNAMES_POPUP_ID 2010 -#define DICT_LABEL_ID 2011 -#define SIZE_LABEL_ID 2012 -#define BOARDSIZE_MENU_ID 2013 -#define BOARDSIZE_POPUP_ID 2014 -#define TIMER_CHECKBOX_ID 2015 -#define TIMER_FIELD_ID 2016 -#define PHONIES_MENU_ID 2017 -#define PHONIES_POPUP_ID 2018 - -#define OK_BUTTON_COL 35 -#define CANCEL_BUTTON_COL 95 -#define REVERT_BUTTON_COL 125 -/* These must be far enough apart that derivitaves will remain unique; make it - 10 for now. Also, there can't be any overlap between their ranges and - other ids!!!!*/ -#define NAME_BASE 2060 -#define ROBOT_BASE 2070 -#define PASSWORD_BASE 2080 - -#define COUNTER_ROW 5 -#define LABEL_ROW 20 -#define FIRST_ROW (LABEL_ROW+20) -#define ROW_OFFSET 18 -#define DICTMENU_ROW (FIRST_ROW + (ROW_OFFSET * MAX_NUM_PLAYERS) + 2) -#define SIZEMENU_ROW (DICTMENU_ROW + ROW_OFFSET + 1) -#define PHONIESMENU_ROW (SIZEMENU_ROW + ROW_OFFSET + 1) -#define TIMER_ROW (PHONIESMENU_ROW + ROW_OFFSET + 1) - -#define BUTTON_ROW (TIMER_ROW + ROW_OFFSET + 3) -#define NAME_COL 5 -#define NAME_WIDTH 105 -#define NAME_HEIGHT 12 -#define ROBOT_COL (NAME_COL + NAME_WIDTH + 10) -#define PASSWD_WIDTH 20 -#define TIME_WIDTH 20 -#define PASSWD_HEIGHT NAME_HEIGHT -#define PASSWORD_COL (ROBOT_COL + PASSWD_WIDTH + 10) -#define TIMER_FIELD_COL 120 - -/* Put up a window with a list for each player giving name and robotness, - * and allowing for setting/changing a password. - */ -CPlayersWindow::CPlayersWindow( MPFORMAL CurGameInfo* gi, FrankDictList* dlist, - BOOL isNew, BOOL allowCancel, BOOL* cancelledP ) - : CWindow( PLAYERS_WINDOW_ID, 2, 12, 196, 226, "Game setup", !isNew, - FALSE, FALSE ) -{ - fLocalGI = *gi; - fGIRef = gi; - fDList = dlist; - this->resultP = cancelledP; - fIsNew = isNew; - MPASSIGN( this->mpool, mpool ); - - /* numplayers counter */ - CLabel* label = new CLabel( COUNT_LABEL_ID, "Number of players:" ); - this->AddChild( label, NAME_COL, COUNTER_ROW ); - this->countMenu = new CMenu(PLAYERCOUNT_MENU_ID, 0, 0, 0, 0, 0 ); - this->countMenu->SetNumRows( MAX_NUM_PLAYERS ); - - char* base = (char*)fNumsBuf; - for ( U16 i = 0 ; i < MAX_NUM_PLAYERS; ++i ) { - snprintf( base, 2, "%d", i+1 ); - this->countMenu->SetRow( i, 2000+i, base ); - base += 2; - } - - CPopupTrigger *trigger = new CPopupTrigger( NUMPLAYERS_POPUP_ID, 0, 0, - this->countMenu, 0 ); - trigger->SetCurrentRow( fLocalGI.nPlayers-1 ); - this->AddChild( trigger, NAME_COL+130, COUNTER_ROW ); - if ( !isNew ) { - DisOrEnable( NUMPLAYERS_POPUP_ID, FALSE ); - } - - /* Column labels */ - label = new CLabel( NAME_LABEL_ID, "Name" ); - this->AddChild( label, NAME_COL, LABEL_ROW ); - label = new CLabel( ROBOT_LABEL_ID, "Rbt" ); - this->AddChild( label, ROBOT_COL, LABEL_ROW ); - label = new CLabel( PASSWORD_LABEL_ID, "Pwd" ); - this->AddChild( label, PASSWORD_COL, LABEL_ROW ); - - /* build a row of controls for each potential player. Disable those below - the point determined by the number of players we have. */ - for ( U16 i = 0; i < MAX_NUM_PLAYERS; ++i ) { - LocalPlayer* fp = &fLocalGI.players[i]; - - CTextEdit* name = new CTextEdit( NAME_BASE + i, NAME_WIDTH, - NAME_HEIGHT, TEXTOPTION_ONELINE ); - name->SetText( (char*)fp->name ); - this->AddChild( name, NAME_COL, FIRST_ROW + (ROW_OFFSET*i) ); - - CCheckbox *robot_check = new CCheckbox( ROBOT_BASE + i, 0, 0, "" ); - robot_check->SetDownStatus( fp->isRobot ); - this->AddChild( robot_check, ROBOT_COL, FIRST_ROW + (ROW_OFFSET*i) ); - - CTextEdit* passwd = new CTextEdit( PASSWORD_BASE + i, - PASSWD_WIDTH, PASSWD_HEIGHT, - TEXTOPTION_PASSWORD - | TEXTOPTION_ONELINE); - this->AddChild( passwd, PASSWORD_COL, FIRST_ROW + (ROW_OFFSET*i) ); - const char* password = (const char*)fp->password; - if ( !!password && !!password[0] ) { - passwd->SetText( password ); - } - } - - this->makeDictMenu(); - - this->makeSizeMenu(); - - this->makePhoniesMenu(); - - /* the timer checkbox */ - fTimerEnabled = new CCheckbox( TIMER_CHECKBOX_ID, 0, 0, - "Timer enabled" ); - fTimerEnabled->SetDownStatus( fLocalGI.timerEnabled ); - AddChild( fTimerEnabled, NAME_COL, TIMER_ROW ); - if ( !isNew ) { - fTimerEnabled->Disable(); - } - - /* the timer field (hidden if checkbox not checked) */ - fTimerField = new CTextEdit( TIMER_FIELD_ID, TIME_WIDTH, - PASSWD_HEIGHT, TEXTOPTION_ONELINE ); - char buf[10]; - sprintf( buf, "%d", fLocalGI.gameSeconds / 60 ); - fTimerField->SetText( buf ); - AddChild( fTimerField, TIMER_FIELD_COL, TIMER_ROW ); - if ( !fLocalGI.timerEnabled || !isNew ) { - fTimerField->Disable(); - } - - /* the buttons at the bottom */ - U16 okCol = OK_BUTTON_COL; - CButton* button = new CButton( OK_BUTTON_ID, 0, 0, "Ok" ); - if ( !(isNew && allowCancel) ) { - U16 buttonWidth = button->GetWidth(); - U16 windowWidth = this->GetWidth(); - okCol = (windowWidth - buttonWidth) / 2; - } - this->AddChild( button, okCol, BUTTON_ROW ); - - if ( isNew && allowCancel ) { - button = new CButton( CANCEL_BUTTON_ID, 0, 0, "Cancel" ); - this->AddChild( button, CANCEL_BUTTON_COL, BUTTON_ROW ); - } - - adjustVisibility(); - XP_DEBUGF( "CPlayersWindow done" ); -} // CPlayersWindow - -CPlayersWindow::~CPlayersWindow() -{ - delete( this->countMenu ); - delete( this->dictMenu ); - delete( this->sizeMenu ); -} /* ~CPlayersWindow */ - -void -CPlayersWindow::DisOrEnable( U16 id, BOOL enable ) -{ - CViewable* child = this->GetChildID( id ); - if ( enable ) { - XP_DEBUGF( "enabling child id=%d\n", id ); - child->Enable(); - } else { - XP_DEBUGF( "disabling child id=%d\n", id ); - child->Disable(); - } -} /* DisOrEnable */ - - -static BOOL -checkAllDigits( CTextEdit* te ) -{ - char* text = te->GetText(); - char ch; - while ( (ch=*text++) != '\0' ) { - if ( !isdigit(ch) ) { - return false; - } - } - return true; -} /* checkAllDigits */ - -S32 -CPlayersWindow::MsgHandler( MSG_TYPE type, CViewable *from, S32 data ) -{ - S32 result = 0; - S32 id; - U16 row; - - switch ( type ) { - case MSG_MENU_SELECT: /* the num-players trigger */ - XP_DEBUGF( "MSG_MENU_SELECT: data=%ld\n", data ); - switch ( from->GetID()) { - case NUMPLAYERS_POPUP_ID: - row = this->countMenu->GetCurrentRow(); - fLocalGI.nPlayers = row + 1; /* GetCurrentRow is 0-based */ - adjustVisibility(); - GUI_NeedUpdate(); - result = 1; - break; - /* case DICTNAMES_POPUP_ID: */ - /* row = this->dictMenu->GetCurrentRow(); */ - /* break; */ - } - break; - - case MSG_TEXT_CHANGED: - if ( (from->GetID() == TIMER_FIELD_ID) - && !checkAllDigits( (CTextEdit*)from ) ) { - result = TEXTEDIT_PLEASE_UNDO; - } - break; - - case MSG_BUTTON_SELECT: - result = 1; - id = from->GetID(); - switch ( id ) { - - case TIMER_CHECKBOX_ID: - DisOrEnable( TIMER_FIELD_ID, fTimerEnabled->GetDownStatus() ); - break; - - case OK_BUTTON_ID: - for ( U16 i = 0; i < fLocalGI.nPlayers; ++i ) { - copyIDString( NAME_BASE+i, &fLocalGI.players[i].name ); - copyIDString( PASSWORD_BASE+i, - &fLocalGI.players[i].password ); - } - if ( !!dictMenu ) { - fLocalGI.dictName = - copyString( MPPARM(mpool) - fDList->GetNthName(dictMenu->GetCurrentRow())); - } else { - fLocalGI.dictName = (XP_UCHAR*)NULL; - } - - if ( fIsNew ) { - fLocalGI.boardSize = 15 - this->sizeMenu->GetCurrentRow(); - fLocalGI.phoniesAction = fPhoniesMenu->GetCurrentRow(); - } - - fLocalGI.timerEnabled = fTimerEnabled->GetDownStatus(); - if ( fLocalGI.timerEnabled ) { - char* text = fTimerField->GetText(); - fLocalGI.gameSeconds = atoi(text) * 60; - } - - *fGIRef = fLocalGI; /* copy changes to caller */ - case CANCEL_BUTTON_ID: - *this->resultP = id == CANCEL_BUTTON_ID; - this->Close(); - result = 1; - break; - default: /* probably one of our synthetic IDs */ - if ( id >= ROBOT_BASE && id < ROBOT_BASE+MAX_NUM_PLAYERS ) { - U16 playerNum = id - ROBOT_BASE; - BOOL isRobot = ((CButton*)from)->GetDownStatus(); - fLocalGI.players[playerNum].isRobot = isRobot; - adjustVisibility(); - } else if (id >= NAME_BASE && id < NAME_BASE + MAX_NUM_PLAYERS ){ - } else { - result = 0; - } - } - default: - break; - } - - if ( result == 0 ) { - result = CWindow::MsgHandler( type, from, data ); - } - return result; -} // CPlayersWindow::MsgHandler - -/* This will create a dictionary of the dict listed first in the initial.mom - * file - */ -void -CPlayersWindow::makeDictMenu() -{ - XP_U16 nDicts = fDList->GetDictCount(); - - U16 startRow; - if ( !!fLocalGI.dictName ) { - startRow = fDList->IndexForName( fLocalGI.dictName); - } else { - startRow = 0; - } - - XP_ASSERT( nDicts > 0 ); - - CMenu* menu = new CMenu( PLAYERDICT_MENU_ID, 0, 0, 0, 0, 0 ); - menu->SetNumRows( nDicts ); - - for ( U16 i = 0; i < nDicts; ++i ) { - menu->SetRow( i, 3000+i, (char*)fDList->GetNthName(i) ); - } - - CPopupTrigger *trigger = new CPopupTrigger( DICTNAMES_POPUP_ID, 0, 0, - menu, 0 ); - trigger->SetCurrentRow(startRow); - menu->SetCurrentRow(startRow); - - CLabel* label = new CLabel( DICT_LABEL_ID, "Dictnry:" ); - this->AddChild( label, NAME_COL, DICTMENU_ROW ); - U16 labelWidth = label->GetWidth(); - this->AddChild( trigger, NAME_COL+labelWidth+10, DICTMENU_ROW ); - - if ( !fIsNew ) { - DisOrEnable( DICTNAMES_POPUP_ID, FALSE ); - } - - this->dictMenu = menu; -} /* CPlayersWindow::makeDictMenu */ - -void -CPlayersWindow::makeSizeMenu() -{ - CMenu* menu = new CMenu( BOARDSIZE_MENU_ID, 0, 0, 0, 0, 0 ); - menu->SetNumRows( NUM_SIZES ); - for ( U16 i = 0; i < NUM_SIZES; ++i ) { - U16 siz = 15-i; - snprintf( (char*)this->sizeNames[i], sizeof(this->sizeNames[i]), - "%dx%d", siz, siz ); - menu->SetRow( i, 4000+i, (char*)this->sizeNames[i] ); - } - CPopupTrigger* trigger = new CPopupTrigger( BOARDSIZE_POPUP_ID, 0, 0, - menu, 0 ); - U16 curSize = 15-fLocalGI.boardSize; - trigger->SetCurrentRow(curSize); - menu->SetCurrentRow(curSize); - - CLabel* label = new CLabel( SIZE_LABEL_ID, "Board size:" ); - this->AddChild( label, NAME_COL, SIZEMENU_ROW ); - U16 labelWidth = label->GetWidth(); - this->AddChild( trigger, NAME_COL+labelWidth+10, SIZEMENU_ROW ); - - if ( !fIsNew ) { - DisOrEnable( BOARDSIZE_POPUP_ID, FALSE ); - } - - this->sizeMenu = menu; -} /* CPlayersWindow::makeSizeMenu */ - -void -CPlayersWindow::adjustVisibility() -{ - /* disable everything greater than the number of players. Before that, - disable passwords if robot */ - - U16 nPlayers = fLocalGI.nPlayers; - for ( U16 i = 0; i < MAX_NUM_PLAYERS; ++i ) { - XP_Bool disableAll = i >= nPlayers; - BOOL enable; - - /* name */ - enable = !disableAll; - DisOrEnable( NAME_BASE + i, enable ); - - /* robot check */ - /* enable's the same as above */ - DisOrEnable( ROBOT_BASE + i, enable ); - - /* passwd */ - enable = !disableAll && !fLocalGI.players[i].isRobot; - DisOrEnable( PASSWORD_BASE + i, enable ); - } -} /* adjustVisibility */ - -void -CPlayersWindow::makePhoniesMenu() -{ - CMenu* menu = new CMenu( PHONIES_MENU_ID, 0, 0, 0, 0, 0 ); - menu->SetNumRows( 3 ); - menu->SetRow( 0, 5000, "Ignore" ); - menu->SetRow( 1, 5001, "Warn" ); - menu->SetRow( 2, 5002, "Disallow" ); - - CPopupTrigger* trigger = new CPopupTrigger( PHONIES_POPUP_ID, 0, 0, - menu, 0 ); - - XWPhoniesChoice phoniesAction = fLocalGI.phoniesAction; - trigger->SetCurrentRow(phoniesAction); - menu->SetCurrentRow(phoniesAction); - - CLabel* label = new CLabel( SIZE_LABEL_ID, "Phonies:" ); - this->AddChild( label, NAME_COL, PHONIESMENU_ROW ); - U16 labelWidth = label->GetWidth(); - this->AddChild( trigger, NAME_COL+labelWidth+10, PHONIESMENU_ROW ); - - fPhoniesMenu = menu; -} /* CPlayersWindow::makePhoniesMenu */ - -void -CPlayersWindow::copyIDString( U16 id, XP_UCHAR** where ) -{ - if ( *where ) { - XP_DEBUGF( "freeing string " ); - XP_DEBUGF( "%s\n", *where ); - XP_FREE( mpool, *where ); - XP_DEBUGF( "done freeing string\n" ); - } - - XP_UCHAR* str = (XP_UCHAR*)NULL; - CTextEdit* te = (CTextEdit*)this->GetChildID( id ); - XP_UCHAR* name = (XP_UCHAR*)te->GetText(); - U16 len = te->TextLength(); - if ( len > 0 ) { - str = (XP_UCHAR*)XP_MALLOC( mpool, len + 1 ); - memcpy( str, name, len ); - str[len] = '\0'; - } - *where = str; -} /* CPlayersWindow::copyIDString */ diff --git a/xwords4/franklin/frankplayer.h b/xwords4/franklin/frankplayer.h deleted file mode 100644 index 1bb977db9..000000000 --- a/xwords4/franklin/frankplayer.h +++ /dev/null @@ -1,66 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001-2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKPLAYER_H_ -#define _FRANKPLAYER_H_ - -extern "C" { -#include "comtypes.h" -#include "game.h" -} - -#include "frankdict.h" -#include "frankdlist.h" - -#define NUM_SIZES 6 - -class CPlayersWindow : public CWindow { - private: - CurGameInfo fLocalGI; /* local copy; discard if cancel */ - BOOL* resultP; /* where to write ok-or-cancel */ - CurGameInfo* fGIRef; /* copy local to here if not cancel */ - CMenu* countMenu; /* need to preserve in order to delete */ - CMenu* dictMenu; /* need to preserve in order to delete */ - CMenu* sizeMenu; - CMenu* fPhoniesMenu; - CCheckbox* fTimerEnabled; - CTextEdit* fTimerField; - XP_UCHAR sizeNames[10][NUM_SIZES]; - FrankDictList* fDList; - BOOL fIsNew; - XP_UCHAR fNumsBuf[10]; /* saves allocs and frees for menu strings */ - - public: - MPSLOT - - public: - CPlayersWindow( MPFORMAL CurGameInfo* pi, FrankDictList* dlist, BOOL isNew, - BOOL allowCancel, BOOL* cancelledP ); - ~CPlayersWindow(); - S32 MsgHandler( MSG_TYPE type, CViewable *object, S32 data ); - private: - void DisOrEnable( U16 id, BOOL enable ); - void makeDictMenu(); - void makeSizeMenu(); - void makePhoniesMenu(); - void copyIDString( U16 id, XP_UCHAR** where ); - void adjustVisibility(); -}; - -#endif diff --git a/xwords4/franklin/franksavedgames.cpp b/xwords4/franklin/franksavedgames.cpp deleted file mode 100644 index 0f0a2b860..000000000 --- a/xwords4/franklin/franksavedgames.cpp +++ /dev/null @@ -1,231 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 1999-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include "sys.h" -#include "gui.h" -#include "ebm_object.h" - -extern "C" { -#include "comtypes.h" -} - -#include "franksavedgames.h" -#include "frankids.h" - -#define RENAME_BUTTON_ID 1000 -#define DUP_BUTTON_ID 1001 -#define DELETE_BUTTON_ID 1002 -#define DONE_BUTTON_ID 1003 -#define OPEN_BUTTON_ID 1004 -#define NAME_FIELD_ID 1005 - -#define ROW_HEIGHT 12 -#define GAMES_NUM_VISROWS 6 -#define GAMES_ROW_WIDTH 150 -#define LIST_TOP 5 -#define LIST_HEIGHT (GAMES_NUM_VISROWS*ROW_HEIGHT) -#define FIELD_TOP (LIST_TOP+LIST_HEIGHT+8) -#define LIST_LEFT 5 -#define FIELD_HEIGHT 15 -#define FIELD_WIDTH 100 -#define BUTTON_TOP (FIELD_TOP+FIELD_HEIGHT+8) - -class GamesList : public CList { -private: - CGamesDB* gamesDB; - - public: - GamesList( CGamesDB* gamesDB, U16 numRows, U16 startRow ); - - U16 GetRowHeight( S32 row ) { return ROW_HEIGHT; } - void DrawRow( RECT *rect, S32 row ); -}; - -GamesList::GamesList( CGamesDB* gamesDB, U16 numRows, U16 startRow ) - : CList( 1001, GAMES_ROW_WIDTH, LIST_HEIGHT, - numRows, LISTOPTION_ALWAYS_HIGHLIGHT ) -{ - this->gamesDB = gamesDB; - - this->SetCurrentRow(startRow); -} - -void GamesList::DrawRow( RECT *rect, S32 row ) -{ - XP_UCHAR* name = this->gamesDB->getNthName( row+1 ); - if ( !name ) { - name = (XP_UCHAR*)"untitled"; - } - - CWindow* window = this->GetWindow(); - window->DrawText( (char*)name, rect->x, rect->y ); -} /* GamesList::DrawRow */ - -/***************************************************************************** - * The class itself - ****************************************************************************/ -CSavedGamesWindow::CSavedGamesWindow( CGamesDB* gamesDB, U16* toOpen, - U16* curIndex ) - : CWindow( SAVEDGAMES_WINDOW_ID, 2, 90, 196, 148, "Saved games", TRUE, - FALSE, FALSE /* no closebox */ ) -{ - this->gamesDB = gamesDB; - this->toOpenP = toOpen; /* what we'll say to open */ - this->curIndexP = curIndex; /* where we'll say current's moved to */ - this->curIndex = *curIndex; /* save current (move when delete/dup) */ - this->displayIndex = this->curIndex; /* start display at current */ - this->gamesList = (GamesList*)NULL; - - CTextEdit* field = new CTextEdit( NAME_FIELD_ID, FIELD_WIDTH, - FIELD_HEIGHT, TEXTOPTION_HAS_FOCUS - | TEXTOPTION_ONELINE ); - this->nameField = field; - field->SetText( (char*)gamesDB->getNthName( this->displayIndex ) ); - this->AddChild( field, LIST_LEFT, FIELD_TOP ); - - CButton* button = new CButton( RENAME_BUTTON_ID, 0, 0, "Rename" ); - U16 result = this->AddChild( button, 130, FIELD_TOP ); - - button = new CButton( DUP_BUTTON_ID, 0, 0, "Dup" ); - result = this->AddChild( button, 5, BUTTON_TOP ); - - button = new CButton( DELETE_BUTTON_ID, 0, 0, "Delete" ); - result = this->AddChild( button, 40, BUTTON_TOP ); - this->deleteButton = button; - checkDisableDelete(); - - button = new CButton( OPEN_BUTTON_ID, 0, 0, "Open" ); - result = this->AddChild( button, 90, BUTTON_TOP ); - - button = new CButton( DONE_BUTTON_ID, 0, 0, "Done" ); - result = this->AddChild( button, 130, BUTTON_TOP ); - - reBuildGamesList(); -} // CSavedGamesWindow - -void -CSavedGamesWindow::reBuildGamesList() -{ - if ( !!this->gamesList ) { - this->DeleteChild( this->gamesList ); - delete this->gamesList; - } - - U16 numRows = this->gamesDB->countRecords() - 1; /* skip prefs */ - GamesList* list = new GamesList( gamesDB, numRows, this->curIndex-1 ); - this->gamesList = list; - this->AddChild( list, LIST_LEFT, LIST_TOP ); - list->SetCurrentRow( this->displayIndex-1 ); -} /* reBuildGamesList */ - -void -CSavedGamesWindow::checkDisableDelete() -{ - BOOL disable = this->displayIndex == this->curIndex; - CButton* button = this->deleteButton; - if ( disable != button->IsDisabled() ) { - if ( disable ) { - button->Disable(); - } else { - button->Enable(); - } - } -} /* checkDisableDelete */ - -S32 -CSavedGamesWindow::MsgHandler( MSG_TYPE type, CViewable *object, S32 data ) -{ - S32 result = 0; - XP_UCHAR* name; - U16 newID; - - switch (type) { - case MSG_BUTTON_SELECT: // there's only one button.... - switch (object->GetID()) { - - case RENAME_BUTTON_ID: - name = (XP_UCHAR*)this->nameField->GetText(); - this->gamesDB->putNthName( this->displayIndex, name ); - this->gamesList->Draw(); - break; - - case DUP_BUTTON_ID: - newID = this->gamesDB->duplicateNthRecord( this->displayIndex ); - this->displayIndex = newID; - reBuildGamesList(); - this->gamesList->Draw(); - checkDisableDelete(); - break; - - case DELETE_BUTTON_ID: - /* disable button instead of checking here */ - XP_ASSERT( this->displayIndex != this->curIndex ); - if ( 1 == GUI_Alert( ALERT_OK, - "Are you sure you want to delete" - " the selected game?" ) ) { - this->gamesDB->removeNthRecord( this->displayIndex ); - - if ( this->displayIndex < this->curIndex ) { - --this->curIndex; - } - - if ( this->displayIndex == this->gamesDB->countRecords() ) { - --this->displayIndex; - } - - reBuildGamesList(); - this->gamesList->Draw(); - checkDisableDelete(); - } - break; - - case DONE_BUTTON_ID: - this->displayIndex = this->curIndex; /* restore to saved so next - line's does nothing */ - /* FALLTHRU */ - case OPEN_BUTTON_ID: - *this->curIndexP = this->curIndex; - *this->toOpenP = this->displayIndex; - this->Close(); - break; - } - result = 1; - break; - - case MSG_ROW_SELECT: - this->displayIndex = (U16)data + 1; - nameField->SetText( (char*)gamesDB->getNthName( this->displayIndex ) ); - checkDisableDelete(); - result = 1; - break; - - default: - break; - } - - if ( result == 0 ) { - result = CWindow::MsgHandler( type, object, data ); - } - return result; -} // MsgHandler - - - diff --git a/xwords4/franklin/franksavedgames.h b/xwords4/franklin/franksavedgames.h deleted file mode 100644 index 2f476c608..000000000 --- a/xwords4/franklin/franksavedgames.h +++ /dev/null @@ -1,47 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _FRANKSAVEDGAMES_H_ -#define _FRANKSAVEDGAMES_H_ - -#include "frankgamesdb.h" - -extern "C" { -} - -class CSavedGamesWindow : public CWindow { - private: - CGamesDB* gamesDB; - class GamesList* gamesList; - CTextEdit* nameField; - CButton* deleteButton; - U16* toOpenP; - U16* curIndexP; - U16 curIndex; - U16 displayIndex; - - void reBuildGamesList(); - void checkDisableDelete(); - - public: - CSavedGamesWindow( CGamesDB* gamesDB, U16* toOpen, U16* curIndex ); - S32 MsgHandler( MSG_TYPE type, CViewable *object, S32 data ); -}; - -#endif diff --git a/xwords4/franklin/frankshowtext.cpp b/xwords4/franklin/frankshowtext.cpp deleted file mode 100644 index faac30e39..000000000 --- a/xwords4/franklin/frankshowtext.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include "sys.h" -#include "gui.h" -#include "ebm_object.h" - -extern "C" { -#include "xptypes.h" -#include "xwstream.h" -} - -#include "frankshowtext.h" -#include "frankids.h" - -#define MAX_DLG_HT 200 -#define SHOWTEXT_WINDOW_ID 2000 -#define SHOW_TEXT_ID 2001 -#define TEXT_X 5 -#define TEXT_PADDING_ABOVE 5 -#define TEXT_PADDING_BELOW 5 -#define TEXT_Y TEXT_PADDING_ABOVE -#define TEXT_WIDTH 180 -#define TEXT_HEIGHT 40 - -#define TEXT_PADDING (TEXT_PADDING_ABOVE+TEXT_PADDING_BELOW) -#define TITLE_BAR_HT 15 - - -#define OK_BUTTON_ID 1000 -#define CANCEL_BUTTON_ID 1001 -#define OK_BUTTON_X 40 -#define CANCEL_BUTTON_X 100 -#define BUTTON_HEIGHT 12 -#define BUTTON_PADDING 3 /* below buttons */ - -CShowTextWindow::CShowTextWindow( MPFORMAL XWStreamCtxt* stream, - const char* title, - XP_Bool killStream, XP_Bool showCancel, - XP_U16* resultLoc ) - : CWindow( SHOWTEXT_WINDOW_ID, 5, 170, 190, - TEXT_HEIGHT + TEXT_PADDING + TITLE_BAR_HT, - title, TRUE, FALSE, !showCancel ) -{ - MPASSIGN( this->mpool, mpool ); - - CButton* okButton = (CButton*)NULL; - CButton* cancelButton = (CButton*)NULL; - - fResultLoc = resultLoc; - - CTextEdit* entry = new CTextEdit( SHOW_TEXT_ID, TEXT_WIDTH, TEXT_HEIGHT, - TEXTOPTION_NOEDIT | - TEXTOPTION_NOUNDERLINE); - - /* copy the stream's text into the texteditor */ - stream_putU8( stream, '\0' ); - XP_U16 len = stream_getSize( stream ); - char* textPtr = (char*)XP_MALLOC( mpool, len ); - stream_getBytes( stream, textPtr, len ); - XP_ASSERT( textPtr[len-1] == '\0' ); - entry->SetText(textPtr); - XP_FREE( mpool, textPtr ); - - if ( killStream ) { - stream_destroy( stream ); - } - - RECT rect; - GetUsableRect( &rect ); - U16 titleBarHt = rect.y - GetY(); - - U16 maxTextHeight = MAX_DLG_HT - TEXT_PADDING - titleBarHt; - U16 buttonHeight; - if ( showCancel ) { - okButton = new CButton( OK_BUTTON_ID, 0, 0, "Ok" ); - cancelButton = new CButton( CANCEL_BUTTON_ID, 0, 0, "Cancel" ); - buttonHeight = okButton->GetHeight() + BUTTON_PADDING; - maxTextHeight -= buttonHeight; - } else { - buttonHeight = 0; - } - - /* FIND out how big the text wants to be. Make the window as big as - necessary, growing it upward. */ - - U16 curTextHeight = entry->GetMaxHeight(); - if ( curTextHeight > maxTextHeight ) { - curTextHeight = maxTextHeight; - } - entry->SetHeight( curTextHeight ); - - U16 newDlgHeight = curTextHeight + buttonHeight + TEXT_PADDING - + titleBarHt; - S16 diff = newDlgHeight - GetHeight(); - SetY( GetY() - diff ); - SetHeight( newDlgHeight ); - - this->AddChild( entry, TEXT_X, TEXT_Y ); - - if ( showCancel ) { - U16 buttonY = TEXT_Y + curTextHeight + TEXT_PADDING_BELOW; - AddChild( okButton, OK_BUTTON_X, buttonY ); - AddChild( cancelButton, CANCEL_BUTTON_X, buttonY ); - } - -} /* CShowTextWindow */ - -S32 -CShowTextWindow::MsgHandler( MSG_TYPE type, CViewable *object, S32 data ) -{ - S32 result = 0; - - switch ( type ) { - case MSG_BUTTON_SELECT: /* there's only one button */ - result = 1; - switch ( object->GetID() ) { - case OK_BUTTON_ID: - *fResultLoc = 1; - break; - case CANCEL_BUTTON_ID: - *fResultLoc = 0; - break; - } - break; - - default: - break; - } - - if ( result == 1 ) { - this->Close(); - } - - return result; -} /* MsgHandler */ diff --git a/xwords4/franklin/frankshowtext.h b/xwords4/franklin/frankshowtext.h deleted file mode 100644 index 47454f979..000000000 --- a/xwords4/franklin/frankshowtext.h +++ /dev/null @@ -1,42 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SHOWTEXT_H_ -#define _SHOWTEXT_H_ - -extern "C" { -#include "comtypes.h" -#include "mempool.h" -} - -class CShowTextWindow : public CWindow { - private: - XP_U16* fResultLoc; - - public: - MPSLOT - - public: - CShowTextWindow( MPFORMAL XWStreamCtxt* stream, const char* title, - XP_Bool killStream, XP_Bool showCancel, - XP_U16* resultLoc ); - S32 MsgHandler( MSG_TYPE type, CViewable *object, S32 data ); -}; - -#endif /* _SHOWTEXT_H_ */ diff --git a/xwords4/franklin/initial.mom b/xwords4/franklin/initial.mom deleted file mode 100644 index aa222375e..000000000 --- a/xwords4/franklin/initial.mom +++ /dev/null @@ -1,10 +0,0 @@ -object Franklin _GUI pkg _GUI.pkg -object Franklin _Default fnt _Default.fnt -object Franklin _System fnt _System.fnt -object Franklin _jingles piezo _jingles.dat -sobject Franklin _alarms timer _alarms.dat -sobject Franklin _SysSet_ dat _settings.dat -object Eric_House xwords4 fxe xwords4.fxe - icon xwords4.icn Cross- words 4 - attribute _LFLAGS S -object Eric_House BasEnglish2to8 xwd BasEnglish2to8.xwd diff --git a/xwords4/franklin/pbitm2frank.pl b/xwords4/franklin/pbitm2frank.pl deleted file mode 100755 index 77289a81d..000000000 --- a/xwords4/franklin/pbitm2frank.pl +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/perl -# Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. -# -# 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. - -# write a pbitm out in franklin "format" -# -# usage: pbitm2frank.pl infile outName - -use strict; - -my $infile = $ARGV[0]; -my $outname = $ARGV[1]; - -my @lines; -my $width = -1; -my $height = 0; - -open (INFILE, $infile) or die "can't find file $infile\n"; - -print qq ( -/* This file generated from $infile; do not edit!!! */ - -); - -while ( ) { - ++$height; - - s/\s//; # get rid of whitespace - push( @lines, $_ ); - - my $len = length($_); - if ( $width == -1 ) { - $width = $len; - } elsif ( $len != $width ) { - die "line $height width differs"; - } -} - -my $rowbytes = ($width + 7) >> 3; -my $structName = "${outname}_struct" ; - -print qq( typedef struct $structName { - IMAGE img; - U8 data[$height * $rowbytes]; -} $structName; - -); - -printStruct(0); - -print "#ifdef USE_INVERTED\n"; -printStruct(1); -print "#endif /* USE_INVERTED */\n"; - - -sub printStruct() { - my ($invert) = @_; - - my $thisName = $outname; - - if ( $invert ) { - $thisName .= "_inverted"; - } - - print qq( -$structName $thisName = { - { $width, $height, $rowbytes, - COLOR_MODE_MONO, 0, (const COLOR *) 0, (U8*)NULL }, - { - ); - - foreach my $line (@lines) { - printLine( $width, $line, $invert ); - } - - print " }\n};\n"; -} # printStruct - -sub printLine() { - my ($len, $line, $invert) = @_; - - $line .= '-------'; # pad with 7 0s - - if ( $invert ) { - $line =~ s/#/h/g; - $line =~ s/\-/#/g; - $line =~ s/h/\-/g; - } - - for ( my $i = 0; $len > 0; ++$i ) { - my $byte = 0; - my $subline = substr($line, $i*8, 8 ); - - for ( my $j = 0; $j < 8; ++$j ) { - my $ch = substr( $subline, $j, 1 ); - if ( $ch eq '-' ) { - } elsif ( $ch eq '#' ) { - $byte |= 1 << (7-$j); - } else { - print STDERR ("unexpected char $ch at offset ", - ($i*8)+$j, " in line $height\n"); - die; - } - } - - printf( "\t0x%x, ", $byte ); - $len -= 8; - } - - print "\t/* ", substr($line, 0, -7), " */\n"; -} # printLine diff --git a/xwords4/franklin/xptypes.h b/xwords4/franklin/xptypes.h deleted file mode 100644 index 7dd59bab6..000000000 --- a/xwords4/franklin/xptypes.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 1999-2000 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _XPTYPES_H_ -#define _XPTYPES_H_ - -#include -#include -#include -#include -#include -#include - -#ifdef CPLUS -extern "C" { -#endif - -#define XP_TRUE ((XP_Bool)(1==1)) -#define XP_FALSE ((XP_Bool)(1==0)) - -typedef U8 XP_U8; -typedef S8 XP_S8; -typedef unsigned char XP_UCHAR; - -typedef U16 XP_U16; -typedef S16 XP_S16; - -typedef U32 XP_U32; -/* typedef S32 XP_A32; */ -typedef S32 XP_S32; - -typedef signed short XP_FontCode; /* not sure how I'm using this yet */ -typedef BOOL XP_Bool; -typedef U32 XP_Time; - -#define XP_CR "\n" - -void frank_insetRect( RECT* r, short byWhat ); -void frank_debugf(char*, ...); -void p_ignore(char*, ...); -int frank_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... ); -unsigned long frank_flipLong( unsigned long l ); -unsigned short frank_flipShort(unsigned short s); - -#define XP_RANDOM() rand() - -#ifdef MEM_DEBUG -# define XP_PLATMALLOC(nbytes) malloc(nbytes) -# define XP_PLATREALLOC(p,s) realloc((p), (s)) -# define XP_PLATFREE(p) free(p) -#else -# define XP_MALLOC(pool, nbytes) malloc(nbytes) -# define XP_REALLOC(pool, p, bytes) realloc((p), (bytes)) -# define XP_FREE(pool, p) free(p) -#endif - -#define XP_MEMSET(src, val, nbytes) memset( (src), (val), (nbytes) ) -#define XP_MEMCPY(d,s,l) memcpy((d),(s),(l)) -#define XP_MEMCMP( a1, a2, l ) memcmp((a1),(a2),(l)) -#define XP_STRLEN(s) strlen((char*)(s)) -#define XP_STRCMP(s1,s2) strcmp((char*)(s1),(char*)(s2)) -#define XP_STRNCMP(s1,s2,l) strncmp((char*)(s1),(char*)(s2),(l)) -#define XP_STRCAT(d,s) strcat((d),(s)) - -#define XP_SNPRINTF frank_snprintf - -#define XP_MIN(a,b) ((a)<(b)?(a):(b)) -#define XP_MAX(a,b) ((a)>(b)?(a):(b)) - -#ifdef DEBUG -#define XP_ASSERT(b) assert(b) -#else -#define XP_ASSERT(b) -#endif - -#define XP_STATUSF XP_DEBUGF -#define XP_WARNF XP_DEBUGF - -#ifdef DEBUG -#define XP_LOGF frank_debugf -#define XP_DEBUGF frank_debugf -#else -#define XP_LOGF if(0)p_ignore -#define XP_DEBUGF if(0)p_ignore -#endif - -#define XP_NTOHL(l) frank_flipLong(l) -#define XP_NTOHS(s) frank_flipShort(s) -#define XP_HTONL(l) frank_flipLong(l) -#define XP_HTONS(s) frank_flipShort(s) - -#ifdef CPLUS -} -#endif - -#endif diff --git a/xwords4/franklin/xwords4.atts b/xwords4/franklin/xwords4.atts deleted file mode 100644 index e07a9fc5c..000000000 --- a/xwords4/franklin/xwords4.atts +++ /dev/null @@ -1,36 +0,0 @@ -# -# This file contains attributes common to all things. -# -# Format is: NAME|permissions|VALUE - -# Set these attributes to your desired MOM object name -# -_PUB|global+read-only|"Eric_House" -_NAME|global+read-only|"xwords4" - -# If your object has an icon, this attribute sets the icon label text -# Restrictions: two rows of 9 characters, spaces break to the next line. -# This example "GUI Test App" will appear as two lines: "GUI Test" and "App" -_ITXT|global|"Cross- words 4" - -# Launcher flag characters: -# S = launch after sync -# B = launch on boot -# If this attribute is omitted, the app is never launched automatically. -#_LFLAGS|global+read-only|"SB" - - -# -# The attributes below should rarely have to change -# - -# Launcher category setting -_LCAT|nosign+global|"PROGRAMS" - -# file extension -_EXT|global+read-only|"fxe" - -# system permissions, apps are read-only, take off the "read-only" -# for read/write permission -_PERM|global+read-only|x"00000000" - diff --git a/xwords4/franklin/xwords4_icon.bmp b/xwords4/franklin/xwords4_icon.bmp deleted file mode 100644 index 6c72e5248..000000000 Binary files a/xwords4/franklin/xwords4_icon.bmp and /dev/null differ diff --git a/xwords4/palm/.cvsignore b/xwords4/palm/.cvsignore deleted file mode 100644 index 2191c21a5..000000000 --- a/xwords4/palm/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -*.out -*.bin -LocalizedStrIncludes.h -app.gdb -gdbload -palm -fnavgen -pace_gen.h -pace_gen.c -PNOC_bin.pre -PALM_PNO -_dirList diff --git a/xwords4/palm/Makefile b/xwords4/palm/Makefile deleted file mode 100644 index 7c5850b70..000000000 --- a/xwords4/palm/Makefile +++ /dev/null @@ -1,356 +0,0 @@ -# -*- mode: Makefile; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE"; -*- -# Copyright 2002-2006 by Eric House (xwords@eehouse.org). All rights -# reserved. -# -# 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. - -PLATFORM=obj_palm -SVNREV = $(shell svnversion -n .. | tr ':' '_') - -ifeq ($(MEMDEBUG),TRUE) -DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -PLATFORM := $(PLATFORM)_memdebug -CFLAGS += $(DEBUG) -g -O0 -CSFLAGS += -O0 -g -NAME = "CrossDbg" -ICONTEXT = "CrossDbg" -APPID ?= Xwdb -else -PLATFORM := $(PLATFORM)_rel -CFLAGS += -O2 -fomit-frame-pointer -# The -Os flag breaks multilink, at least as I'm using it -CSFLAGS += -OS -fomit-frame-pointer -NAME = "Crosswords" -ICONTEXT = "Crosswords" -APPID ?= Xwr4 -endif - -RELAY_NAME_DEFAULT="eehouse.org" - -LANG=en_US -ROOTNAME = $(NAME) -BITMAPS = ./bmps -TYPE = appl -MLPREFIX = /usr -DICT = $(shell echo $$BASENG_PATH) - -ARCH ?= ARM_ONLY - -ifeq ($(ARCH),ARM_ONLY) -PLATFORM := $(PLATFORM)_armonly -BUILD_AS_PNOLET = 1 -TARGET=$(PLATFORM)/xw4_ARM_$(SVNREV).prc -else -ifeq ($(ARCH),68K_ONLY) -PLATFORM := $(PLATFORM)_68konly -TARGET=$(PLATFORM)/xw4_68K_$(SVNREV).prc -else -ifeq ($(ARCH),SONY) -# No highres in sony build case -PLATFORM := $(PLATFORM)_sony -BUILD_AS_PNOLET = 1 -FEATURE_PNOAND68K = -DFEATURE_PNOAND68K -TARGET=$(PLATFORM)/xw4_SONY_$(SVNREV).prc -else -ifeq ($(ARCH),COMBINED) -PLATFORM := $(PLATFORM)_combined -BUILD_AS_PNOLET = 1 -FEATURE_PNOAND68K = -DFEATURE_PNOAND68K -TARGET=$(PLATFORM)/xw4_COMB_$(SVNREV).prc -endif -endif -endif -endif - -PLATFORM := $(PLATFORM)_$(shell echo $(LANG) | tr [A-Z] [a-z]) - -APPNAME = "$(NAME)" - -PALM_TOOLS_PREFIX = $(shell echo $$PALM_TOOLS_PREFIX) - -ifeq (x$(PALM_TOOLS_PREFIX)x, xx) - PALM_TOOLS_PREFIX = m68k-palmos- -endif -#PALM_TOOLS_PREFIX=m68k-palmos-coff- - -CC = $(PALM_TOOLS_PREFIX)gcc -AR = $(PALM_TOOLS_PREFIX)ar -MULTILINK = $(PALM_TOOLS_PREFIX)multilink -############################################################################### -# par is a utility for manipulating .prc and .pdb files. See -# http://djw.org/product/palm/par/index.html to download source. -############################################################################### -PAR = par -PILRC = pilrc -BUILD-PRC = build-prc -OBJ-RES = m68k-palmos-obj-res - -MULTILINK_OPTIONS = -basename $(ROOTNAME) -segmentsize 27k -g \ - -deadstrip -verbose -gdb-script app.gdb - -MYDEFS_COMMON = $(PASSTHRU) -DXW_FEATURE_UTILS -DPOINTER_SUPPORT \ - -DKEY_SUPPORT -DOVERRIDE_EDGE_FOR_INDEX -DCOLOR_SUPPORT \ - -DSHOW_PROGRESS $(HASHDEF) -DNO_REG_REQUIRED -DPERIMETER_FOCUS - -# turn on letting users pick tiles "face-up" -MYDEFS_COMMON += -DFEATURE_TRAY_EDIT - -# turn on limits to searches on board and in tray (number of tiles to -# use) -MYDEFS_COMMON += -DXWFEATURE_SEARCHLIMIT - -#MYDEFS_COMMON += -DXWFEATURE_HINT_CONFIG - -ifdef XWFEATURE_STANDALONE_ONLY -MYDEFS_COMMON += -DXWFEATURE_STANDALONE_ONLY -else -# Turn on network play over IP via cellular modem. Very much -# experimental at this point! -RELAY = -DXWFEATURE_RELAY -MYDEFS_COMMON += $(RELAY) - -# turn on bluetooth comms option for 68K and ARM -BLUETOOTH = -DXWFEATURE_BLUETOOTH -DBT_USE_L2CAP -# -DCOMMS_HEARTBEAT -#BLUETOOTH = -DXWFEATURE_BLUETOOTH -DBT_USE_RFCOMM -MYDEFS_COMMON += $(BLUETOOTH) - -MYDEFS_COMMON += -DXWFEATURE_IR - -endif # ifdef XWFEATURE_STANDALONE_ONLY - -# Add menu allowing to choose to run 68K or ARM -ifeq ($(ARCH),COMBINED) -MYDEFS_COMMON += -DFEATURE_DUALCHOOSE -endif - -# For Danish and perhaps other languages, custom-measure glyph height -# so that overtall letters have a chance of fitting. -MYDEFS_COMMON += -DTALL_FONTS - -# Turn on ability to handle 4-byte-node DAWG files. These are of type -# Xwr4, not Xwr3 like the old ones. Currently this option means the -# binary won't be able to read or even find the old dictionaries. -# Don't release with this on until there's a UI decision and code on -# how to help users transition. -MYDEFS_COMMON += -DNODE_CAN_4 - -MYDEFS_COMMON += -DSVN_REV=\"$(shell svnversion -n .)\" - -MYDEFS_ARM = -D__LITTLE_ENDIAN -DXW_TARGET_PNO $(MYDEFS_COMMON) -MYDEFS_68K = -DPLATFORM_PALM -D__BIG_ENDIAN $(MYDEFS_COMMON) \ - -DAPPNAME=\"$(APPNAME)\" \ - -DRELAY_NAME_DEFAULT=\"$(RELAY_NAME_DEFAULT)\" \ - $(BLUETOOTH) - - -BITMAP_RSRCS = \ - $(BITMAPS)/rightarrow.pbitm \ - $(BITMAPS)/downarrow.pbitm \ - $(BITMAPS)/flipbutton.pbitm \ - $(BITMAPS)/valuebutton.pbitm \ - $(BITMAPS)/lightbulb.pbitm \ - $(BITMAPS)/traybuttons.pbitm \ - $(BITMAPS)/showtray.pbitm \ - $(BITMAPS)/xwords4.pbitm -ifdef BLUETOOTH -BITMAP_RSRCS += \ - $(BITMAPS)/bts_conn.bmp \ - $(BITMAPS)/bts_listen.bmp \ - $(BITMAPS)/bts_off.bmp \ - $(BITMAPS)/bts_seek.bmp -endif -ifdef RELAY -BITMAP_RSRCS += \ - $(BITMAPS)/rls_allconn.bmp \ - $(BITMAPS)/rls_off.bmp \ - $(BITMAPS)/rls_pending.bmp -endif - -# INCLUDES += -I/usr/local/share/palmdev/sdk-5r3/Extensions/ExpansionMgr -ifdef BLUETOOTH -INCLUDES += -I/usr/local/share/palmdev/sdk-5r3/include/Extensions/Bluetooth -endif - -XWFEATURE_FIVEWAY = -DXWFEATURE_FIVEWAY -DKEYBOARD_NAV -XWFEATURE_FIVEWAY += -DDO_TUNGSTEN_FIVEWAY - -ifneq (x$(XWFEATURE_FIVEWAY)x, xx) - INCLUDES += -I/usr/local/share/palmdev/Handspring5 - INCLUDES += -I/usr/local/share/palmdev/Handspring5/68K -# INCLUDES += -I/usr/local/share/palmdev/duoIncs -# INCLUDES += -I/usr/local/share/palmdev/duoIncs/68K -# INCLUDES += -I/usr/local/share/palmdev/duoIncs/68K/System -# INCLUDES += -I/usr/local/share/palmdev/duoIncs/Common/System - - MYDEFS_68K += $(XWFEATURE_FIVEWAY) - MYDEFS_ARM += $(XWFEATURE_FIVEWAY) - -endif - -INCLUDES += -I/usr/local/share/palmdev/sdk-5r3/include/SonyIncs -INCLUDES += -I/usr/local/share/palmdev/sdk-5r3/include/SonyIncs/System -INCLUDES += -I/usr/local/share/palmdev/sdk-5r3/include/SonyIncs/Libraries -MYDEFS_68K += -DCPU_TYPE=CPU_68K - -include ../common/config.mk - -OBJS_68K = $(PLATFORM)/palmmain.o \ - $(PLATFORM)/palmsavg.o \ - $(PLATFORM)/gameutil.o \ - $(PLATFORM)/newgame.o \ - $(PLATFORM)/palmdict.o \ - $(PLATFORM)/palmdraw.o \ - $(PLATFORM)/palmutil.o \ - $(PLATFORM)/dictui.o \ - $(PLATFORM)/dictlist.o \ - $(PLATFORM)/palmir.o \ - $(PLATFORM)/palmip.o \ - $(PLATFORM)/palmbt.o \ - $(PLATFORM)/prefsdlg.o \ - $(PLATFORM)/connsdlg.o \ - $(PLATFORM)/palmblnk.o \ - $(PLATFORM)/palmdbg.o \ - $(COMMONOBJ) - -# if BUILD_AS_PNOLET is defined and FEATURE_PNOAND68K isn't, exclude -# all but enter68k.o from the 68K part of the binary (code resources). -ifdef BUILD_AS_PNOLET - OBJS = $(PLATFORM)/enter68k.o - PNOLET = pnolet -endif -ifndef BUILD_AS_PNOLET - OBJS += $(OBJS_68K) -else -ifdef FEATURE_PNOAND68K - OBJS += $(OBJS_68K) -endif -endif - -MYDEFS_68K += $(FEATURE_PNOAND68K) -MYDEFS_ARM += $(FEATURE_PNOAND68K) - -include ../common/rules.mk - -CSFLAGS += -S -Wall -DAPPID=\'$(APPID)\' $(MYDEFS_68K) $(INCLUDES) -CFLAGS += -Wall -DAPPID=\'$(APPID)\' $(MYDEFS_68K) $(INCLUDES) -# In the non-debug mode (for which DONT_OMIT is undefined) build without -# the frame pointer. - -$(TARGET): $(PLATFORM)/objs.prc $(PLATFORM)/res.prc - $(PAR) -c -a 'resource|backup' -v 4 $@ $(NAME) $(TYPE) $(APPID) $^ -ifdef XW_UPLOAD_SCRIPT - $(XW_UPLOAD_SCRIPT) $@ -endif - -solo: - $(MAKE) XWFEATURE_STANDALONE_ONLY=1 - -gremlins: - $(MAKE) PASSTHRU="-DDEBUG -DMEM_DEBUG -DFOR_GREMLINS" DONT_OMIT=true - -# -REL=405 -REL_PATH=public_html/xwords/4.0.5 -ship-all: - make clean; make; \ - make; (cd xwconfig && make); \ - for l in fr_FR en_US es_ES es_CT sv_SE de_DE ; do \ - make clean; \ - make LANG=$$l; \ - zip -j xw$(REL)_$$l.zip xwconfig/xwconfig.prc $(TARGET); \ - done - -.S.o: - $(CC) $(TARGETFLAGS) -c $< - -.c.s: - $(CC) $(CSFLAGS) $< - -$(BITMAPS)/%.pbitm: $(BITMAPS)/%.bmp - bmtoa $< > $@ - -$(PLATFORM)/objs.prc: $(PLATFORM)/LocalizedStrIncludes.h $(OBJS) gdbload - @rm -f *.grc *.bin -ifeq ($(ARCH),ARM_ONLY) - $(CC) $(OBJS) -o tmp.o - $(OBJ-RES) tmp.o - rm -f tmp.o -else - $(MULTILINK) $(MULTILINK_OPTIONS) $(OBJS) -endif - $(PAR) -c -a resource $(PLATFORM)/objs.prc Code rsrc rsrc *.grc - @rm -f *.grc *.bin - - -$(PLATFORM)/res.prc: xwords4.rcp $(HEADERS) StrL03e8.bin $(FNAVS) $(PNOLET) - $(PILRC) $< >/dev/null - $(PAR) -c -a 'resource' $@ Rsrc rsrc rsrc *.bin - rm -f $< *.bin - -xwords4.rcp: l10n/xwords4_$(LANG).rcp.pre xwords4defines.h $(BITMAP_RSRCS) - gcc -x c -E -P $(INCLUDES) $(MYDEFS_68K) $(DEBUG) \ - -DICONTEXT=\"$(ICONTEXT)\" $< > $@ - -# LocalizedStrIncludes.h: SVN_REV can change, but I don't have a way -# to express a dependency on it. If it does change, strings can wind -# up with offsets out of sync with the .h file. Not sure what to do -# about this.... Clean builds are probably a safe fallback. - -$(PLATFORM)/LocalizedStrIncludes.h StrL03e8.bin: \ - ./l10n/StrRes_$(LANG).pre ./l10n/mkstrsres.c - gcc $(CFLAGS) $(FORMATDEFINES) \ - -DLANGSTRFILE=\"$<\" ./l10n/mkstrsres.c \ - -o mkstrsres - mkdir -p $(PLATFORM) - ./mkstrsres StrL03e8.bin $(PLATFORM)/LocalizedStrIncludes.h - rm -f mkstrsres - -ifneq (x$(BUILD_AS_PNOLET)x, xx) -.PHONY : pnolet - -pnolet: $(PLATFORM)/LocalizedStrIncludes.h - $(MAKE) -f Makefile.PNO MEMDEBUG=$(MEMDEBUG) PLATFORM=$(PLATFORM) \ - MYDEFS="$(MYDEFS_ARM) -DAPPID=\'$(APPID)\' -DAPPNAME=\\\"$(APPNAME)\\\" -DRELAY_NAME_DEFAULT=\\\"$(RELAY_NAME_DEFAULT)\\\"" -endif - -# GDB seems confused by relative paths these days. So generate the -# file rather than trying to keep in in cvs. -gdbload: - echo "source app.gdb" > $@ - echo "load-segments" >> $@ - echo "dir $(shell pwd)" >> $@ - echo "dir $(shell pwd)/../common" >> $@ - -clean: - cd ../common && $(MAKE) PLATFORM=$(PLATFORM) $@ - rm -rf $(PLATFORM)/*.[oa] xwords4 *.bin *.stamp *.[pg]rc \ - xwords4.rcp *.btxt $(PLATFORM)/* $(PLATFORM)/LocalizedStrIncludes.h \ - gdbload -ifneq (x$(BUILD_AS_PNOLET)x, xx) - $(MAKE) -f Makefile.PNO PLATFORM=$(PLATFORM) clean -endif - -#cmod03E8.bin: palmdraw.c Makefile -# $(CC) -O2 -nostartfiles $(INCLUDES) $(MYDEFS) -o tmp $< -# $(OBJRES) tmp -# mv code0001.tmp.grc $@ ; rm *.tmp.grc - -help: - @echo "make [ARCH=(ARM_ONLY|68K_ONLY|SONY|COMBINED)] [MEMDEBUG=TRUE] [LANG=fr_FR|en_US|es_ES|es_CT|sv_SE|de_DE] [clean]" - @echo OR - @echo "make ship-all" - @echo OR - @echo "make gremlins" diff --git a/xwords4/palm/Makefile.PNO b/xwords4/palm/Makefile.PNO deleted file mode 100644 index 0252ce210..000000000 --- a/xwords4/palm/Makefile.PNO +++ /dev/null @@ -1,128 +0,0 @@ -# -*- mode: Makefile; compile-command: "make ARCH=ARM_ONLY"; -*- - -PALMDIR = /usr/local/share/palmdev/sdk-5r3/include - -# Which arm suite to use? Well, the suite in prc-tools-arm is broken -# on debian at the moment: builds code that doesn't work. But older -# versions, e.g. on current debian stable, are ok. For current debian -# the workaround is to build your own crosscompilation toolchain, -# which should put arm-elf-gcc in your path. We'll use that if we -# find it. Otherwise we fall back to the prc-tools-arm chain. -WHICH = $(shell if which arm-elf-gcc > /dev/null ; then echo elf; else echo palmos; fi) - -CC_ARM = arm-$(WHICH)-gcc -OC_ARM= arm-$(WHICH)-objcopy -OD_ARM = arm-$(WHICH)-objdump - -OPT = -Os -MINUS_G = -g - -ifeq ($(MEMDEBUG),TRUE) -DEBUG = -DMEM_DEBUG -DDEBUG -endif - -INCLUDES += \ - -I$(PALMDIR) \ - -I$(PALMDIR)/Libraries \ - -I$(PALMDIR)/Dynamic \ - -I$(PALMDIR)/Core \ - -I$(PALMDIR)/Extensions/ExpansionMgr \ - -I$(PALMDIR)/Core/UI \ - -I$(PALMDIR)/Core/System \ - -I$(PALMDIR)/Core/System/Unix \ - -I$(PALMDIR)/Core/Hardware \ - -I$(PALMDIR)/Extensions/Bluetooth \ - -ifneq (, $(findstring XWFEATURE_FIVEWAY,$(MYDEFS))) -INCLUDES += -I/usr/local/share/palmdev/Handspring5 -INCLUDES += -I/usr/local/share/palmdev/Handspring5/68K -GENDEFS += -DXWFEATURE_FIVEWAY -endif - -ifneq (, $(findstring XWFEATURE_BLUETOOTH,$(MYDEFS))) -GENDEFS += -DXWFEATURE_BLUETOOTH -endif - -# NOTE!!!! Added the -w flag to supress all warnings since arm-elf-gcc -# does so much bitching about the Palm headers. Need to fix that, or -# use the arm-palmos-gcc, or something. But for now, -w.... -CCFLAGS = $(OPT) $(MINUS_G) -Wall -Wunused-parameter -D__PALMOS__ -D__palmos__ -Asystem=palmos -ARMCCFS = $(CCFLAGS) -DNATIVE $(DEBUG) \ - -nostartfiles -mshort-load-bytes -nodefaultlibs -ffixed-r9 \ - -mpic-register=r10 -msingle-pic-base -fpic \ - -Wno-multichar \ - $(INCLUDES) - -ARMLDFS = -Xlinker --script=./ldscript.arm -lgcc - -# ARM-specific -ARM_DEFINES = $(MYDEFS) -DXW_TARGET_PNO -D__LITTLE_ENDIAN -include undef_hack.h - -# turn show progress off for now -# ARM_DEFINES += -USHOW_PROGRESS - -include ../common/config.mk - -OBJS = $(PLATFORM)/pnolet.o \ - $(PLATFORM)/palmmain.o \ - $(PLATFORM)/palmsavg.o \ - $(PLATFORM)/gameutil.o \ - $(PLATFORM)/newgame.o \ - $(PLATFORM)/palmdict.o \ - $(PLATFORM)/palmdraw.o \ - $(PLATFORM)/palmutil.o \ - $(PLATFORM)/palmblnk.o \ - $(PLATFORM)/dictui.o \ - $(PLATFORM)/dictlist.o \ - $(PLATFORM)/palmir.o \ - $(PLATFORM)/palmip.o \ - $(PLATFORM)/palmbt.o \ - $(PLATFORM)/prefsdlg.o \ - $(PLATFORM)/connsdlg.o \ - $(PLATFORM)/palmdbg.o \ - $(PLATFORM)/pace_gen.o \ - $(PLATFORM)/pace_man.o \ - $(COMMONOBJ) - -# The target of this makefile is the .bin files that comprise the -# pnolet. There will be more than just PNOC0000.bin, but the others -# get made as a matter of course and as long as they all get included -# in the .prc we're fine. - -all: Pnoc0000.bin Pnog0000.bin - -$(PLATFORM)/%.o : %.c $(MAKEFILE) - mkdir -p $(PLATFORM) - $(CC_ARM) -o $@ -c $(ARM_DEFINES) -DHERE $(ARMCCFS) $< - -$(COMMONOBJDIR)/%.o : $(COMMONDIR)/%.c $(MAKEFILE) - mkdir -p $(COMMONOBJDIR) - $(CC_ARM) -o $@ -c $(ARM_DEFINES) -DHERE $(ARMCCFS) $< - -Pnoc_bin.pre Pnog0000.bin: pace_gen.h $(OBJS) - $(CC_ARM) $(OBJS) $(ARMCCFS) $(ARMLDFS) -Wl,-Map,Pnoc_bin.map -o tmp.out -# @$(OD_ARM) --disassemble-all tmp.out - $(OC_ARM) -j .text -O binary tmp.out Pnoc_bin.pre - $(OC_ARM) -j .got -O binary tmp.out Pnog0000.bin -# @rm -f tmp.out - -# create not only Pnoc0000.bin but any others required to fit the -# pnolet into 50K chunks (for hotsyncing...) -Pnoc0000.bin: Pnoc_bin.pre - rm -f Pnoc????.bin - split -a 4 -b 50k -d $< Pnoc - for f in $$(ls Pnoc????); do mv $$f $$f.bin; done - -pace_gen.c pace_gen.h: ./gen_pace.pl funcfile.txt - rm -f $@ _dirList - ./gen_pace.pl -func funcfile.txt \ - -file $(PALMDIR)/Core/UI \ - -file $(PALMDIR)/Core/System \ - -file $(PALMDIR)/Extensions/ExpansionMgr \ - -file $(PALMDIR)/Extensions/Bluetooth \ - -file /usr/local/share/palmdev/Handspring5/68K/System \ - -oc pace_gen.c -oh pace_gen.h $(GENDEFS) - rm -f _dirList - -clean: - rm -rf $(OBJS) pace_gen.c pace_gen.h *.bin Pnoc_bin.pre diff --git a/xwords4/palm/bmps/bts_conn.bmp b/xwords4/palm/bmps/bts_conn.bmp deleted file mode 100644 index 306ec55fc..000000000 Binary files a/xwords4/palm/bmps/bts_conn.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/bts_conn.pbitm b/xwords4/palm/bmps/bts_conn.pbitm deleted file mode 100644 index 6dbb118b7..000000000 --- a/xwords4/palm/bmps/bts_conn.pbitm +++ /dev/null @@ -1,7 +0,0 @@ -###-#### -##--#### -#------# -######## -#------# -####--## -####-### diff --git a/xwords4/palm/bmps/bts_listen.bmp b/xwords4/palm/bmps/bts_listen.bmp deleted file mode 100644 index 64d5bf6fa..000000000 Binary files a/xwords4/palm/bmps/bts_listen.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/bts_listen.pbitm b/xwords4/palm/bmps/bts_listen.pbitm deleted file mode 100644 index fccd40fc6..000000000 --- a/xwords4/palm/bmps/bts_listen.pbitm +++ /dev/null @@ -1,7 +0,0 @@ -###-#### -##--#### -#------# -######## -######## -######## -######## diff --git a/xwords4/palm/bmps/bts_off.bmp b/xwords4/palm/bmps/bts_off.bmp deleted file mode 100644 index 279e8f5d8..000000000 Binary files a/xwords4/palm/bmps/bts_off.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/bts_off.pbitm b/xwords4/palm/bmps/bts_off.pbitm deleted file mode 100644 index c755cb0f6..000000000 --- a/xwords4/palm/bmps/bts_off.pbitm +++ /dev/null @@ -1,7 +0,0 @@ -######## -##-##-## -##-##-## -###--### -##-##-## -##-##-## -######## diff --git a/xwords4/palm/bmps/bts_seek.bmp b/xwords4/palm/bmps/bts_seek.bmp deleted file mode 100644 index 218a403f4..000000000 Binary files a/xwords4/palm/bmps/bts_seek.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/bts_seek.pbitm b/xwords4/palm/bmps/bts_seek.pbitm deleted file mode 100644 index f35875a39..000000000 --- a/xwords4/palm/bmps/bts_seek.pbitm +++ /dev/null @@ -1,7 +0,0 @@ -######## -######## -######## -######## -#------# -####--## -####-### diff --git a/xwords4/palm/bmps/downarrow.pbitm b/xwords4/palm/bmps/downarrow.pbitm deleted file mode 100644 index 5cce779c3..000000000 --- a/xwords4/palm/bmps/downarrow.pbitm +++ /dev/null @@ -1,9 +0,0 @@ ---------- -----#---- -----#---- -----#---- --#######- ---#####-- ----###--- -----#---- ---------- diff --git a/xwords4/palm/bmps/downarrowhd.pbitm b/xwords4/palm/bmps/downarrowhd.pbitm deleted file mode 100644 index 2b9e2c119..000000000 --- a/xwords4/palm/bmps/downarrowhd.pbitm +++ /dev/null @@ -1,18 +0,0 @@ ------------------- ------------------- ---------##-------- ---------##-------- ---------##-------- ---------##-------- ---------##-------- ---------##-------- --################- ---##############-- ----############--- -----##########---- ------########----- -------######------ --------####------- ---------##-------- ------------------- ------------------- diff --git a/xwords4/palm/bmps/flipbutton.pbitm b/xwords4/palm/bmps/flipbutton.pbitm deleted file mode 100644 index c5ce87b11..000000000 --- a/xwords4/palm/bmps/flipbutton.pbitm +++ /dev/null @@ -1,8 +0,0 @@ -######## -#-###### -#--##### -#---#### -#----### -#-----## -#------# -######## diff --git a/xwords4/palm/bmps/flipbuttonhd.pbitm b/xwords4/palm/bmps/flipbuttonhd.pbitm deleted file mode 100644 index f7ff2c467..000000000 --- a/xwords4/palm/bmps/flipbuttonhd.pbitm +++ /dev/null @@ -1,16 +0,0 @@ -################ -#-############## -#--############# -#---############ -#----########### -#-----########## -#------######### -#-------######## -#--------####### -#---------###### -#----------##### -#-----------#### -#------------### -#-------------## -#--------------# -################ diff --git a/xwords4/palm/bmps/lightbulb.pbitm b/xwords4/palm/bmps/lightbulb.pbitm deleted file mode 100644 index 37a5a132d..000000000 --- a/xwords4/palm/bmps/lightbulb.pbitm +++ /dev/null @@ -1,11 +0,0 @@ --######- -###--### -##-##-## -#-####-# -#-####-# -##-##-## -##-##-## -###--### -###--### -###--### --######- diff --git a/xwords4/palm/bmps/lightbulbhd.pbitm b/xwords4/palm/bmps/lightbulbhd.pbitm deleted file mode 100644 index f2e13d9a7..000000000 --- a/xwords4/palm/bmps/lightbulbhd.pbitm +++ /dev/null @@ -1,23 +0,0 @@ ---############-- --##############- -######----###### -#####--##--##### -####--####--#### -###--######--### -##--##-#####--## -##--###-####--## -##--##-#####--## -##--########--## -###--######--### -####--####--#### -####--####--#### -####--####--#### -#####------##### -######-#--###### -######--#-###### -######----###### -######-#--###### -######--#-###### --######--######- ---############-- - \ No newline at end of file diff --git a/xwords4/palm/bmps/rightarrow.pbitm b/xwords4/palm/bmps/rightarrow.pbitm deleted file mode 100644 index ee3b667b7..000000000 --- a/xwords4/palm/bmps/rightarrow.pbitm +++ /dev/null @@ -1,9 +0,0 @@ ---------- -----#---- -----##--- -----###-- --#######- -----###-- -----##--- -----#---- ---------- diff --git a/xwords4/palm/bmps/rightarrowhd.pbitm b/xwords4/palm/bmps/rightarrowhd.pbitm deleted file mode 100644 index 5505f89f1..000000000 --- a/xwords4/palm/bmps/rightarrowhd.pbitm +++ /dev/null @@ -1,18 +0,0 @@ ------------------- ---------#--------- ---------##-------- ---------###------- ---------####------ ---------#####----- ---------######---- ---------#######--- ---##############-- ---##############-- ---------#######--- ---------######---- ---------#####----- ---------####------ ---------###------- ---------##-------- ---------#--------- ------------------- diff --git a/xwords4/palm/bmps/rls_allconn.bmp b/xwords4/palm/bmps/rls_allconn.bmp deleted file mode 100644 index 76364576b..000000000 Binary files a/xwords4/palm/bmps/rls_allconn.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/rls_meconn.bmp b/xwords4/palm/bmps/rls_meconn.bmp deleted file mode 100644 index c6ed0c06c..000000000 Binary files a/xwords4/palm/bmps/rls_meconn.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/rls_off.bmp b/xwords4/palm/bmps/rls_off.bmp deleted file mode 100644 index ab623ec37..000000000 Binary files a/xwords4/palm/bmps/rls_off.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/rls_pending.bmp b/xwords4/palm/bmps/rls_pending.bmp deleted file mode 100644 index cbef99773..000000000 Binary files a/xwords4/palm/bmps/rls_pending.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/showtray.pbitm b/xwords4/palm/bmps/showtray.pbitm deleted file mode 100644 index 86dd04004..000000000 --- a/xwords4/palm/bmps/showtray.pbitm +++ /dev/null @@ -1,12 +0,0 @@ --######- -######## -#------# -#------# -###--### -###--### -###--### -###--### -###--### -###--### -######## --######- diff --git a/xwords4/palm/bmps/startmark.pbitm b/xwords4/palm/bmps/startmark.pbitm deleted file mode 100644 index 317fc7e8e..000000000 --- a/xwords4/palm/bmps/startmark.pbitm +++ /dev/null @@ -1,8 +0,0 @@ --------- --##---## --###-### ---#####- ----###-- ---#####- --###-### --##---## diff --git a/xwords4/palm/bmps/startmarkhd.pbitm b/xwords4/palm/bmps/startmarkhd.pbitm deleted file mode 100644 index f016b2775..000000000 --- a/xwords4/palm/bmps/startmarkhd.pbitm +++ /dev/null @@ -1,16 +0,0 @@ ----------------- ----------------- ---###--------### ---####------#### ---#####----##### ----#####--#####- -----##########-- ------########--- -------######---- -------######---- ------########--- -----##########-- ----#####--#####- ---#####----##### ---####------#### ---###--------### diff --git a/xwords4/palm/bmps/traybuttons.pbitm b/xwords4/palm/bmps/traybuttons.pbitm deleted file mode 100644 index 8e0448613..000000000 --- a/xwords4/palm/bmps/traybuttons.pbitm +++ /dev/null @@ -1,20 +0,0 @@ ------------------- ----#############-- --################# --##-###-#######-## --##-###-#######-## --##-###-#######-## --##-----#######-## --##-###-###-###-## --##-###-###-###-## --##-###-####---### --################# --##-----###----### --####-#####-###-## --####-#####-###-## --####-#####-###-## --####-#####-###-## --####-#####-###-## --####-#####----### --################# ----#############-- diff --git a/xwords4/palm/bmps/traybuttonshd.pbitm b/xwords4/palm/bmps/traybuttonshd.pbitm deleted file mode 100644 index c462a48b7..000000000 --- a/xwords4/palm/bmps/traybuttonshd.pbitm +++ /dev/null @@ -1,32 +0,0 @@ ----------------------------------- --################################- -################################## -####--######--##############--#### -####--######--##############--#### -####--######--##############--#### -####--######--##############--#### -####--######--##############--#### -####--######--##############--#### -####----------##############--#### -####--######--##############--#### -####--######--######--######--#### -####--######--######--######--#### -####--######--######--######--#### -####--######--#######--####--##### -####--######--########------###### -################################## -################################## -####----------######--------###### -########--##########--#####--##### -########--##########--######--#### -########--##########--######--#### -########--##########--######--#### -########--##########--######--#### -########--##########--######--#### -########--##########--######--#### -########--##########--######--#### -########--##########--######--#### -########--##########--#####--##### -########--##########--------###### -################################## --###############################- diff --git a/xwords4/palm/bmps/valuebutton.pbitm b/xwords4/palm/bmps/valuebutton.pbitm deleted file mode 100644 index 9741a829e..000000000 --- a/xwords4/palm/bmps/valuebutton.pbitm +++ /dev/null @@ -1,10 +0,0 @@ -######## -#--###-# -##-##-## -#---#-## -####-### -###-#-## -##-#-#-# -##-#---# -#-##-#-# -######## diff --git a/xwords4/palm/bmps/valuebuttonhd.pbitm b/xwords4/palm/bmps/valuebuttonhd.pbitm deleted file mode 100644 index b7446409d..000000000 --- a/xwords4/palm/bmps/valuebuttonhd.pbitm +++ /dev/null @@ -1,21 +0,0 @@ -################ -##############-# -####-#########-# -###--########-## -####-########-## -####-#######-### -####-######-#### -####-#####-##### -####-####-###### -###---##-####### -#######-##--#### -######-##-##-### -#####-##-####-## -####-###-####-## -###-####------## -##-#####-####-## -##-#####-####-## -#-######-####-## -#-############## -################ - \ No newline at end of file diff --git a/xwords4/palm/bmps/xwbandwicon.bmp b/xwords4/palm/bmps/xwbandwicon.bmp deleted file mode 100644 index fd8b6939d..000000000 Binary files a/xwords4/palm/bmps/xwbandwicon.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/xwbandwicon_sm.bmp b/xwords4/palm/bmps/xwbandwicon_sm.bmp deleted file mode 100644 index f2babf0c7..000000000 Binary files a/xwords4/palm/bmps/xwbandwicon_sm.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/xwcoloricon.bmp b/xwords4/palm/bmps/xwcoloricon.bmp deleted file mode 100644 index 01929f3c0..000000000 Binary files a/xwords4/palm/bmps/xwcoloricon.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/xwcoloricon_sm.bmp b/xwords4/palm/bmps/xwcoloricon_sm.bmp deleted file mode 100644 index a06b073c1..000000000 Binary files a/xwords4/palm/bmps/xwcoloricon_sm.bmp and /dev/null differ diff --git a/xwords4/palm/bmps/xwords4.pbitm b/xwords4/palm/bmps/xwords4.pbitm deleted file mode 100644 index 6dc969ef6..000000000 --- a/xwords4/palm/bmps/xwords4.pbitm +++ /dev/null @@ -1,22 +0,0 @@ --############--------- -#------------#-------- -#-#----#-----#-------- -#-#----#-----#-------- -#--#--#------#-------- -#--#--#------#-------- -#---##-------#-------- -#--#--#------#-------- -#--#--#--############- -#-#----##------------# -#-#----##-#-----#----# -#-------#-#-----#----# -#-------#-#-----#----# --########-#--#--#----# ---------#-#--#--#----# ---------#-#--#--#----# ---------#--#-#-#--#--# ---------#---#-#--##--# ---------#-------#-#--# ---------#-------####-# ---------#---------#--# ----------############- diff --git a/xwords4/palm/bmps/xwords4small.pbitm b/xwords4/palm/bmps/xwords4small.pbitm deleted file mode 100644 index 290050ac4..000000000 --- a/xwords4/palm/bmps/xwords4small.pbitm +++ /dev/null @@ -1,9 +0,0 @@ ----#########--- ----#-------#--- ----#--###--#--- ----#-#-----#--- ----#-#-----#--- ----#-#-----#--- ----#--###--#--- ----#-------#--- ----#########--- \ No newline at end of file diff --git a/xwords4/palm/callback.h b/xwords4/palm/callback.h deleted file mode 100644 index bec41f794..000000000 --- a/xwords4/palm/callback.h +++ /dev/null @@ -1,27 +0,0 @@ -/* copied from _Palm Programming_ p. 79*/ - -#ifndef __CALLBACK__ -#define __CALLBACK__ - -#if defined MW_COMPILER -/* these are no-ops for MW as I understand it */ -# define CALLBACK_PROLOGUE() -# define CALLBACK_EPILOGUE() - -#elif defined XW_TARGET_PNO || defined XW_TARGET_X86 - -#define CALLBACK_PROLOGUE() -#define CALLBACK_EPILOGUE() - -#else - -register void *reg_a4 asm("%a4"); - -#define CALLBACK_PROLOGUE() \ - { void* __save_a4 = reg_a4; asm("move.l %%a5,%%a4; sub.l #edata,%%a4" : :); - -#define CALLBACK_EPILOGUE() reg_a4 = __save_a4;} - -#endif /* MW_COMPILER */ - -#endif diff --git a/xwords4/palm/common.rcp.pre b/xwords4/palm/common.rcp.pre deleted file mode 100644 index ae266d8eb..000000000 --- a/xwords4/palm/common.rcp.pre +++ /dev/null @@ -1,270 +0,0 @@ -/* -*-mode: c; fill-column: 78; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE"; -*- */ - -/***************************************************************************** - * Copyright 1999 - 2001 by Eric House. All rights reserved. - * - * 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. - * - * These resources are shared among all localized verions of XW4; no - * localization required. - ****************************************************************************/ - -#ifdef COLOR_SUPPORT -/* colors */ -HEX "Clrs" ID 1000 - 0x00 0x00 0x00 /* black */ - 0xFF 0xFF 0xFF /* white */ - 0x00 0x00 0x00 /* player 1 */ - 0xFF 0x00 0x00 - 0x00 0x00 0xFF - 0x00 0xFF 0x00 - 0xAF 0xAF 0x00 /* bonus 1 */ - 0x00 0xAF 0xAF - 0xAF 0x00 0xAF - 0xAF 0xAF 0xAF - 0xFF 0xFF 0xFF /* empty cells */ - 0xFF 0xFF 0x99 /* tile background */ -#endif - -ICONFAMILY "./bmps/xwbandwicon.bmp" "" "" "./bmps/xwcoloricon.bmp" TRANSPARENT 255 255 255 -SMALLICONFAMILY "bmps/xwbandwicon_sm.bmp" "" "" "./bmps/xwcoloricon_sm.bmp" TRANSPARENT 255 255 255 - -BITMAP ID SHOWTRAY_BUTTON_BMP_RES_ID "bmps/showtray.pbitm" AUTOCOMPRESS - -BITMAP ID DOWN_ARROW_RESID AUTOCOMPRESS -BEGIN - BITMAP "bmps/downarrow.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/downarrowhd.pbitm" BPP 1 DENSITY 144 -END - -BITMAP ID RIGHT_ARROW_RESID AUTOCOMPRESS -BEGIN - BITMAP "bmps/rightarrow.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/rightarrowhd.pbitm" BPP 1 DENSITY 144 -END - -/* bitmap family for inclding highres version */ -BITMAP ID TRAY_BUTTONS_BMP_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/traybuttons.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/traybuttonshd.pbitm" BPP 1 DENSITY 144 -END - -BITMAP ID STAR_BMP_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/startmark.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/startmarkhd.pbitm" BPP 1 DENSITY 144 -END - -BITMAP ID FLIP_BUTTON_BMP_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/flipbutton.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/flipbuttonhd.pbitm" BPP 1 DENSITY 144 -END - -BITMAP ID HINT_BUTTON_BMP_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/lightbulb.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/lightbulbhd.pbitm" BPP 1 DENSITY 144 -END - -BITMAP ID VALUE_BUTTON_BMP_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/valuebutton.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/valuebuttonhd.pbitm" BPP 1 DENSITY 144 -END - -#ifdef XWFEATURE_BLUETOOTH -BITMAP ID BTSTATUS_NONE_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_off.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/bts_off.bmp" BPP 8 DENSITY 144 -END - -BITMAP ID BTSTATUS_LISTENING_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_listen.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/bts_listen.bmp" BPP 8 DENSITY 144 -END - -BITMAP ID BTSTATUS_SEEKING_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_seek.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/bts_seek.bmp" BPP 8 DENSITY 144 -END - -BITMAP ID BTSTATUS_CONNECTED_RES_ID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_conn.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/bts_conn.bmp" BPP 8 DENSITY 144 -END -#endif /* XWFEATURE_BLUETOOTH */ - -#ifdef XWFEATURE_RELAY -BITMAP ID RELAYSTATUS_NONE_RESID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_off.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/rls_off.bmp" BPP 8 DENSITY 144 -END - -BITMAP ID RELAYSTATUS_PENDING_RESID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_listen.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/rls_pending.bmp" BPP 8 DENSITY 144 -END - -BITMAP ID RELAYSTATUS_CONN_RESID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_seek.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/rls_meconn.bmp" BPP 8 DENSITY 144 -END - -BITMAP ID RELAYSTATUS_ALLCONN_RESID AUTOCOMPRESS -BEGIN - BITMAP "bmps/bts_conn.pbitm" BPP 1 DENSITY 72 - BITMAP "bmps/rls_allconn.bmp" BPP 8 DENSITY 144 -END -#endif - -#define TBH TRAY_BUTTON_HEIGHT_HR -#define TBY TRAY_BUTTONS_Y_HR - -FORM ID XW_MAIN_FORM AT (0 0 160 160) -USABLE -NOFRAME -MENUID XW_MAIN_MENU_ID -BEGIN -#ifdef XWFEATURE_FIVEWAY - GADGET ID XW_SCOREBOARD_GADGET_ID AT (0 0 1 1) USABLE - GADGET ID XW_BOARD_GADGET_ID AT (0 0 1 1) USABLE - GADGET ID XW_TRAY_GADGET_ID AT (0 0 1 1) USABLE -#endif - BUTTON "" XW_MAIN_FLIP_BUTTON_ID - AT (PALM_FLIP_LEFT PALM_BOARD_TOP FLIP_BUTTON_WIDTH - FLIP_BUTTON_HEIGHT) NOFRAME - BUTTON "" XW_MAIN_VALUE_BUTTON_ID - AT (PALM_FLIP_LEFT PREVBOTTOM+2 - FLIP_BUTTON_WIDTH FLIP_BUTTON_HEIGHT+2) NOFRAME - BUTTON "" XW_MAIN_HINT_BUTTON_ID - AT (PALM_FLIP_LEFT PREVBOTTOM+2 FLIP_BUTTON_WIDTH - FLIP_BUTTON_HEIGHT+3) NOFRAME - - SCROLLBAR ID XW_MAIN_SCROLLBAR_ID - AT ( PREVLEFT PREVBOTTOM+5 RECOMMENDED_SBAR_WIDTH - 160-TRAY_HEIGHT_HR-PREVBOTTOM-IR_STATUS_HEIGHT-5) - USABLE VALUE SBAR_START_VALUE MIN SBAR_MIN MAX SBAR_MIN - PAGESIZE SBAR_PAGESIZE - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - GADGET ID XW_NETSTATUS_GADGET_ID AT (PALM_FLIP_LEFT PREVBOTTOM+4 16 15) - NONUSABLE -#endif - - BUTTON "" XW_MAIN_SHOWTRAY_BUTTON_ID - AT (PALM_FLIP_LEFT SHOWTRAY_BUTTON_Y - FLIP_BUTTON_WIDTH FLIP_BUTTON_WIDTH+4) NOFRAME - -#ifndef EIGHT_TILES - BUTTON "" XW_MAIN_HIDE_BUTTON_ID - AT(PALM_TRAY_BUTTON_LEFT TBY TRAY_BUTTON_WIDTH TBH) NOFRAME - BUTTON "" XW_MAIN_JUGGLE_BUTTON_ID - AT(PREVRIGHT PREVTOP TRAY_BUTTON_WIDTH TBH) NOFRAME - BUTTON "" XW_MAIN_TRADE_BUTTON_ID - AT(PALM_TRAY_BUTTON_LEFT PREVBOTTOM TRAY_BUTTON_WIDTH - TBH) NOFRAME - BUTTON "" XW_MAIN_DONE_BUTTON_ID - AT(PREVRIGHT PREVTOP TRAY_BUTTON_WIDTH TBH) NOFRAME -#endif -#ifdef FOR_GREMLINS - GADGET GREMLIN_BOARD_GADGET_IDAUTOID AT ( 0 5 152 135 ) - GADGET GREMLIN_TRAY_GADGET_IDAUTOID AT ( 0 140 145 20 ) -#endif -END /* XW_MAIN_FORM */ - -#ifdef XWFEATURE_FIVEWAY -NAVIGATION ID XW_MAIN_FORM -INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState -/* INITIALOBJECTID: the OS arbitrarily sends a focusTake event for some button - * on opening the form if this isn't set, otherwise it sends for this. That's - * easier to test for and drop, so set it is. */ -INITIALOBJECTID XW_SCOREBOARD_GADGET_ID -NAVIGATIONMAP - ROW XW_SCOREBOARD_GADGET_ID - ROW XW_BOARD_GADGET_ID - XW_MAIN_FLIP_BUTTON_ID - XW_MAIN_VALUE_BUTTON_ID - XW_MAIN_HINT_BUTTON_ID - ROW XW_TRAY_GADGET_ID - XW_MAIN_SHOWTRAY_BUTTON_ID - XW_MAIN_HIDE_BUTTON_ID - XW_MAIN_JUGGLE_BUTTON_ID - XW_MAIN_TRADE_BUTTON_ID - XW_MAIN_DONE_BUTTON_ID -END - -NAVIGATION ID XW_PASSWORD_DIALOG_ID -INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState -INITIALOBJECTID XW_PASSWORD_PASS_FIELD -NAVIGATIONMAP - ROW XW_PASSWORD_PASS_FIELD - ROW XW_PASSWORD_OK_BUTTON XW_PASSWORD_CANCEL_BUTTON -END -#endif - -STRING ID 1000 "/palm/programs/Crosswords/" - -APPLICATIONICONNAME ID 1000 ICONTEXT - -/* force hotsync into games category */ -LAUNCHERCATEGORY ID 1000 "Games" - -HEX "Xbrd" ID 1000 -#if 1 /* the "scrabble" pattern */ - 0x40 0x01 0x00 0x04 - 0x02 0x00 0x03 0x00 - 0x00 0x20 0x00 0x10 - 0x10 0x02 0x00 0x01 - 0x00 0x00 0x20 0x00 - 0x03 0x00 0x03 0x00 - 0x00 0x10 0x00 0x10 - 0x40 0x01 0x00 0x02 -#else - 0x04 0x00 0x10 0x04 - 0x40 0x00 0x03 0x00 - 0x00 0x00 0x20 0x10 - 0x00 0x03 0x00 0x01 - 0x10 0x20 0x00 0x30 - 0x03 0x00 0x01 0x00 - 0x00 0x10 0x30 0x00 - 0x40 0x01 0x00 0x02 -#endif - -/* for 13x13 board */ -HEX "Xbrd" ID 1001 /* This is 7x7, so one line is two rows */ - 0x20 0x03 0x00 0x30 0x40 0x00 0x10 - 0x00 0x10 0x00 0x03 0x00 0x30 0x00 - 0x00 0x00 0x10 0x00 0x10 0x00 0x30 - 0x30 0x00 0x00 0x20 - -/* for 11x11 board */ -HEX "Xbrd" ID 1002 /* This is 6x6 */ - 0x04 0x00 0x03 - 0x40 0x03 0x00 - 0x00 0x10 0x01 - 0x03 0x01 0x00 - 0x00 0x00 0x30 - 0x30 0x10 0x02 - -VERSION ID 1000 XW_PALM_VERSION_STRING diff --git a/xwords4/palm/connsdlg.c b/xwords4/palm/connsdlg.c deleted file mode 100644 index f22d6c01a..000000000 --- a/xwords4/palm/connsdlg.c +++ /dev/null @@ -1,397 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=ARM_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 2003-2008 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - -#include - -#include "callback.h" - -#include "connsdlg.h" -#include "strutils.h" -#include "palmmain.h" -#include "palmutil.h" -#include "palmir.h" -#include "palmbt.h" -#include "LocalizedStrIncludes.h" - -/* When user pops up via Host gadget, we want to get the port to listen on. - * When pops up via the Guest gadget, we want to get the port and IP address - * of the host AS WELL AS the local port that we'll tell it we're listening - * on. We need local state for both, since user can switch between them and - * expect state to live as long as the parent dialog isn't exited. - */ - -typedef struct XportEntry { - XP_U16 resID; - CommsConnType conType; -} XportEntry; - -#define MAX_XPORTS 3 - -typedef struct ConnsDlgState { - ListPtr connTypesList; - ListData sLd; - XportEntry xports[MAX_XPORTS]; - XP_U16 nXports; - XP_U16 serverRole; - XP_Bool isNewGame; - CommsConnType conType; - CommsAddrRec* addr; - XP_BtAddr btAddr; /* since there's no field, save it here */ -#ifdef XWFEATURE_BLUETOOTH - char hostName[PALM_BT_NAME_LEN]; -#endif -} ConnsDlgState; - -static void -ctlsFromState( PalmAppGlobals* globals ) -{ - ConnsDlgState* state = globals->connState; - CommsAddrRec* addr = state->addr; - XP_Bool isNewGame = state->isNewGame; - state->conType = addr->conType; - - if ( 0 ) { -#ifdef XWFEATURE_RELAY - } else if ( addr->conType == COMMS_CONN_RELAY ) { - XP_UCHAR buf[16]; - setFieldStr( XW_CONNS_RELAY_FIELD_ID, addr->u.ip_relay.hostName ); - setFieldEditable( XW_CONNS_RELAY_FIELD_ID, isNewGame ); - - StrPrintF( buf, "%d", addr->u.ip_relay.port ); - setFieldStr( XW_CONNS_PORT_FIELD_ID, buf ); - setFieldEditable( XW_CONNS_PORT_FIELD_ID, isNewGame ); - - setFieldStr( XW_CONNS_INVITE_FIELD_ID, addr->u.ip_relay.invite ); - setFieldEditable( XW_CONNS_INVITE_FIELD_ID, isNewGame ); -#endif -#ifdef XWFEATURE_BLUETOOTH - } else if ( addr->conType == COMMS_CONN_BT - /* It's ok to load the controls even if we won't use them */ - /* && state->serverRole == SERVER_ISCLIENT */ ) { - ControlPtr ctrl = getActiveObjectPtr( XW_CONNS_BT_HOSTTRIGGER_ID ); - - XP_MEMCPY( &state->btAddr, &state->addr->u.bt.btAddr, - sizeof(state->btAddr) ); - XP_MEMCPY( &state->hostName, &state->addr->u.bt.hostName, - sizeof(state->hostName) ); - - if ( '\0' != addr->u.bt.hostName[0] ) { - CtlSetLabel( ctrl, state->hostName ); - } - CtlSetEnabled( ctrl, isNewGame ); - -#endif - } - -#ifdef XWFEATURE_BLUETOOTH - /* Set up any controls that are not based on union fields regardless of - conType, as user may change and we want the defaults to be right. - This is a case where using a union breaks down: it'd be better to have - access to all the defaults, but they may be corrupt if conType is - wrong. */ - XP_ASSERT( !!globals->prefsDlgState ); - setBooleanCtrl( XW_CONNS_BTCONFIRM_CHECKBOX_ID, - globals->prefsDlgState->confirmBTConnect ); -#endif - -} /* ctlsFromState */ - -static XP_Bool -stateFromCtls( PalmAppGlobals* globals, XP_Bool* prefsChanged ) -{ - ConnsDlgState* state = globals->connState; - CommsAddrRec addr; - XP_Bool addrOk; - - *prefsChanged = XP_FALSE; - - XP_MEMCPY( &addr, state->addr, sizeof(addr) ); - addr.conType = state->conType; - - if ( 0 ) { -#ifdef XWFEATURE_RELAY - } else if ( addr.conType == COMMS_CONN_RELAY ) { - XP_UCHAR buf[16]; - getFieldStr( XW_CONNS_RELAY_FIELD_ID, addr.u.ip_relay.hostName, - sizeof(addr.u.ip_relay.hostName) ); - - getFieldStr( XW_CONNS_PORT_FIELD_ID, buf, sizeof(buf) ); - addr.u.ip_relay.port = StrAToI( buf ); - - getFieldStr( XW_CONNS_INVITE_FIELD_ID, addr.u.ip_relay.invite, - sizeof(addr.u.ip_relay.invite) ); -#endif -#ifdef XWFEATURE_BLUETOOTH - } else if ( addr.conType == COMMS_CONN_BT - && state->serverRole == SERVER_ISCLIENT ) { - XP_Bool confirmBTConnect; - /* Not exactly from a control... */ - /* POSE is flagging this as reading from a bad address, but it - looks ok inside the debugger */ - XP_MEMCPY( addr.u.bt.hostName, state->hostName, - sizeof(addr.u.bt.hostName) ); - XP_MEMCPY( &addr.u.bt.btAddr, &state->btAddr, - sizeof(addr.u.bt.btAddr) ); - LOG_HEX( &addr.u.bt.btAddr, sizeof(addr.u.bt.btAddr), __func__ ); - - confirmBTConnect = getBooleanCtrl( XW_CONNS_BTCONFIRM_CHECKBOX_ID ); - XP_ASSERT( !!globals->prefsDlgState ); - if ( confirmBTConnect != globals->prefsDlgState->confirmBTConnect ) { - globals->prefsDlgState->confirmBTConnect = confirmBTConnect; - *prefsChanged = XP_TRUE; - } -#endif - } - - addrOk = comms_checkAddr( state->serverRole, &addr, &globals->util ); - if ( addrOk ) { - XP_MEMCPY( state->addr, &addr, sizeof( *state->addr) ); - } - - return addrOk; -} /* stateFromCtls */ - -static void -updateFormCtls( FormPtr form, ConnsDlgState* state ) -{ - const XP_U16 relayCtls[] = { -#ifdef XWFEATURE_RELAY - XW_CONNS_RELAY_LABEL_ID, - XW_CONNS_RELAY_FIELD_ID, - XW_CONNS_PORT_LABEL_ID, - XW_CONNS_PORT_FIELD_ID, - XW_CONNS_INVITE_LABEL_ID, - XW_CONNS_INVITE_FIELD_ID, -#endif - 0 - }; - const XP_U16 btGuestCtls[] = { -#ifdef XWFEATURE_BLUETOOTH - XW_CONNS_BT_HOSTNAME_LABEL_ID, - XW_CONNS_BT_HOSTTRIGGER_ID, - XW_CONNS_BTCONFIRM_CHECKBOX_ID, -#endif - 0 - }; - const XP_U16* allCtls[] = { - relayCtls, btGuestCtls - }; - const XP_U16* on; - XP_U16 i; - - if ( state->conType == COMMS_CONN_RELAY ) { - on = relayCtls; - } else if ( state->conType == COMMS_CONN_BT -#ifdef XWFEATURE_BLUETOOTH - && state->serverRole == SERVER_ISCLIENT -#endif - ) { - on = btGuestCtls; - } else { - on = NULL; - } - - for ( i = 0; i < VSIZE(allCtls); ++i ) { - const XP_U16* cur = allCtls[i]; - if ( cur != on ) { - disOrEnableSet( form, cur, XP_FALSE ); - } - } - if ( on != NULL ) { - disOrEnableSet( form, on, XP_TRUE ); - } - -} /* updateFormCtls */ - -static CommsConnType -selToConType( const ConnsDlgState* state, XP_U16 sel ) -{ - XP_ASSERT( sel < state->nXports ); - return state->xports[sel].conType; -} /* selToConType */ - -#ifdef XWFEATURE_BLUETOOTH -static void -browseForDeviceName( PalmAppGlobals* globals ) -{ - ConnsDlgState* state = globals->connState; - XP_BtAddr btAddr; - if ( palm_bt_browse_device( globals, &btAddr, - state->hostName, sizeof(state->hostName) ) ) { - CtlSetLabel( getActiveObjectPtr( XW_CONNS_BT_HOSTTRIGGER_ID ), - state->hostName ); - XP_MEMCPY( &state->btAddr, &btAddr, sizeof(state->btAddr) ); - LOG_HEX( &state->btAddr, sizeof(state->btAddr), __func__ ); - } -} /* browseForDeviceName */ -#endif - -static void -setupXportList( PalmAppGlobals* globals ) -{ - ConnsDlgState* state = globals->connState; - ListData* sLd = &state->sLd; - XP_U16 ii; - XP_S16 selSel = -1; - const XP_UCHAR* selName = NULL; - - XP_ASSERT( state->nXports >= 1 ); - state->connTypesList = getActiveObjectPtr( XW_CONNS_TYPE_LIST_ID ); - - initListData( MPPARM(globals->mpool) sLd, state->nXports ); - for ( ii = 0; ii < state->nXports; ++ii ) { - XportEntry* xports = &state->xports[ii]; - const XP_UCHAR* xname = getResString( globals, xports->resID ); - addListTextItem( MPPARM(globals->mpool) sLd, xname ); - if ( state->conType == xports->conType ) { - selName = xname; - selSel = ii; - } - } - - XP_ASSERT( !!selName ); - setListSelection( sLd, selName ); - setListChoices( sLd, state->connTypesList, NULL ); - - setSelectorFromList( XW_CONNS_TYPE_TRIGGER_ID, state->connTypesList, - selSel ); -} /* setupXportList */ - -static void -buildXportData( ConnsDlgState* state ) -{ - XportEntry* xports = state->xports; - XP_ASSERT( 0 == state->nXports ); - -#ifdef XWFEATURE_IR - xports->conType = COMMS_CONN_IR; - xports->resID = STR_IR_XPORTNAME; - ++xports; -#endif -#ifdef XWFEATURE_BLUETOOTH - xports->conType = COMMS_CONN_BT; - xports->resID = STR_BT_XPORTNAME; - ++xports; -#endif -#ifdef XWFEATURE_RELAY - xports->conType = COMMS_CONN_RELAY; - xports->resID = STR_RELAY_XPORTNAME; - ++xports; -#endif - state->nXports = xports - state->xports; -} /* buildXportData */ - -Boolean -ConnsFormHandleEvent( EventPtr event ) -{ - Boolean result; - PalmAppGlobals* globals; - ConnsDlgState* state; - FormPtr form; - XP_S16 chosen; - - CALLBACK_PROLOGUE(); - - globals = getFormRefcon(); - state = globals->connState; - if ( !state ) { - state = globals->connState = XP_MALLOC( globals->mpool, - sizeof(*state) ); - XP_MEMSET( state, 0, sizeof(*state) ); - } - - form = FrmGetActiveForm(); - - switch ( event->eType ) { - case frmOpenEvent: - state->serverRole = - (DeviceRole)globals->dlgParams[CONNS_PARAM_ROLE_INDEX]; - state->addr = - (CommsAddrRec*)globals->dlgParams[CONNS_PARAM_ADDR_INDEX]; - state->isNewGame = globals->isNewGame; - - ctlsFromState( globals ); - - /* setup connection popup */ - buildXportData( state ); - setupXportList( globals ); - - updateFormCtls( form, state ); - - case frmUpdateEvent: - FrmDrawForm( form ); - result = true; - break; - - case ctlSelectEvent: - result = true; - switch ( event->data.ctlSelect.controlID ) { - -#ifdef XWFEATURE_BLUETOOTH - case XW_CONNS_BT_HOSTTRIGGER_ID: - if ( state->isNewGame ) { - browseForDeviceName( globals ); - } - break; -#endif - - case XW_CONNS_TYPE_TRIGGER_ID: - if ( state->isNewGame ) { - chosen = LstPopupList( state->connTypesList ); - if ( chosen >= 0 ) { - setSelectorFromList( XW_CONNS_TYPE_TRIGGER_ID, - state->connTypesList, chosen ); - state->conType = selToConType( state, chosen ); - updateFormCtls( form, state ); - } - } - break; - - case XW_CONNS_OK_BUTTON_ID: - if ( !state->isNewGame ) { - /* do nothing; same as cancel */ - } else { - XP_Bool prefsChanged; - if ( !stateFromCtls( globals, &prefsChanged ) ) { - break; /* refuse to exit */ - } - if ( prefsChanged ) { - postEmptyEvent( prefsChangedEvent ); - } - } - /* FALLTHRU */ - case XW_CONNS_CANCEL_BUTTON_ID: - freeListData( MPPARM(globals->mpool) &globals->connState->sLd ); - XP_FREE( globals->mpool, globals->connState ); - globals->connState = NULL; - FrmReturnToForm( 0 ); - break; - } - break; - default: - result = false; - } - - CALLBACK_EPILOGUE(); - return result; -} /* ConnsFormHandleEvent */ - -#endif /* #if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY */ diff --git a/xwords4/palm/connsdlg.h b/xwords4/palm/connsdlg.h deleted file mode 100644 index 30b300c9d..000000000 --- a/xwords4/palm/connsdlg.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2003 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _CONNSDLG_H_ -#define _CONNSDLG_H_ - -#include - - -Boolean ConnsFormHandleEvent( EventPtr event ); - -#define CONNS_PARAM_ROLE_INDEX 0 -#define CONNS_PARAM_ADDR_INDEX 1 - -#define PopupConnsForm( g, h, addrP ) { \ - (g)->dlgParams[CONNS_PARAM_ROLE_INDEX] = (XP_U32)(h); \ - (g)->dlgParams[CONNS_PARAM_ADDR_INDEX] = (XP_U32)(addrP); \ - FrmPopupForm( XW_CONNS_FORM ); \ -} - -#endif diff --git a/xwords4/palm/dictlist.c b/xwords4/palm/dictlist.c deleted file mode 100644 index 6bd244373..000000000 --- a/xwords4/palm/dictlist.c +++ /dev/null @@ -1,600 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/**************************************************************************** - * - * Copyright 1999 - 2003 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include -#include - -#include "callback.h" -#include "dictlist.h" -#include "palmmain.h" -#include "palmutil.h" -#include "palmdict.h" -#include "strutils.h" -#include "xwords4defines.h" -#include "LocalizedStrIncludes.h" - -#define TYPE_DAWG 'DAWG' -#ifdef NODE_CAN_4 -# define TYPE_XWRDICT 'XwrD' -#else -# define TYPE_XWRDICT 'Xwr3' -#endif - -////////////////////////////////////////////////////////////////////////////// -// typedef and #defines -////////////////////////////////////////////////////////////////////////////// - -struct PalmDictList { - XP_U16 nDicts; - DictListEntry dictArray[1]; -}; - -////////////////////////////////////////////////////////////////////////////// -// Prototypes -////////////////////////////////////////////////////////////////////////////// -static PalmDictList* dictListMakePriv( MPFORMAL XP_U32 creatorSought, - XP_U16 versSought ); - - -XP_Bool -getNthDict( const PalmDictList* dl, short n, DictListEntry** dle ) -{ - XP_Bool exists = !!dl && (dl->nDicts > n); - if ( exists ) { - *dle = (DictListEntry*)&dl->dictArray[n]; - } - return exists; -} /* getNthDict */ - -XP_Bool -getDictWithName( const PalmDictList* dl, const XP_UCHAR* name, - DictListEntry** dlep ) -{ - XP_Bool result = XP_FALSE; - - if ( !!dl ) { - XP_U16 i; - XP_UCHAR* extName; - XP_UCHAR oldChName = '\0'; /* shut compiler up */ - DictListEntry* dle = (DictListEntry*)dl->dictArray; - - extName = (XP_UCHAR*)StrStr((const char*)name, - (const char*)".pdb" ); - - if ( !!extName ) { - oldChName = *extName; - *extName = '\0'; - } - - for ( i = 0; !result && i < dl->nDicts; ++i ) { - XP_UCHAR* extCand; - XP_UCHAR oldChCand = '\0'; - - extCand = (XP_UCHAR*)StrStr((const char*)dle->baseName, ".pdb" ); - if ( !!extCand ) { - oldChCand = *extCand; - *extCand = '\0'; - } - - if ( 0 == XP_STRCMP( (const char*)name, - (const char*)dle->baseName ) ) { - - *dlep = dle; - result = XP_TRUE; - } - - if ( !!extCand ) { - *extCand = oldChCand; - } - - ++dle; - } - - if ( !!extName ) { - *extName = oldChName; - } - - } - return result; -} /* getDictWithName */ - -void -cacheDictForName( PalmDictList* dl, const XP_UCHAR* dictName, - DictionaryCtxt* dict ) -{ - DictListEntry* dle; - (void)getDictWithName(dl, dictName, &dle ); - XP_ASSERT( getDictWithName(dl, dictName, &dle ) ); - XP_ASSERT( !dle->dict ); - - dle->dict = dict; -} /* cacheDictForName */ - -void -removeFromDictCache( PalmDictList* dl, XP_UCHAR* dictName ) -{ - DictListEntry* dle; - (void)getDictWithName( dl, dictName, &dle ); - XP_ASSERT( getDictWithName( dl, dictName, &dle ) ); - XP_ASSERT( !!dle->dict ); - - dle->dict = NULL; -} /* removeFromDictCache */ - -static XP_Bool -addEntry( MPFORMAL PalmDictList** dlp, DictListEntry* dle ) -{ - XP_Bool isNew; - PalmDictList* dl = *dlp; - DictListEntry* ignore; - - if ( !dl ) { - dl = (PalmDictList*)XP_MALLOC( mpool, sizeof(*dl) ); - XP_MEMSET( dl, 0, sizeof(*dl) ); - } - - isNew = !getDictWithName( dl, dle->baseName, &ignore ); - if ( isNew ) { - XP_U16 size = sizeof(*dl); - size += dl->nDicts * sizeof( dl->dictArray[0] ); - - dl = (PalmDictList*)XP_REALLOC( mpool, (XP_U8*)dl, size ); - - dle->dict = NULL; - XP_MEMCPY( &dl->dictArray[dl->nDicts++], dle, - sizeof( dl->dictArray[0] ) ); - } - - *dlp = dl; - return isNew; -} /* addEntry */ - -static void -searchDir( MPFORMAL PalmDictList** dlp, UInt16 volNum, - unsigned char XP_UNUSED(separator), - unsigned char* path, XP_U16 pathSize, XP_U32 creatorSought, - XP_U16 versSought ) -{ - Err err; - FileRef dirRef; - XP_U16 pathLen = XP_STRLEN( (const char*)path ); - - err = VFSFileOpen( volNum, (const char*)path, vfsModeRead, &dirRef ); - if ( err == errNone ) { - UInt32 dEnum = vfsIteratorStart; - FileInfoType fit; - - fit.nameP = (char*)path + pathLen; - - while ( dEnum != vfsIteratorStop ) { - XP_UCHAR* ext; - fit.nameBufLen = pathSize - pathLen; - err = VFSDirEntryEnumerate( dirRef, &dEnum, &fit ); - - if ( err != errNone ) { - break; - } - - if ( (fit.attributes & vfsFileAttrDirectory) != 0 ) { -#ifdef RECURSIVE_VFS_SEARCH - XP_U16 len = XP_STRLEN((const char*)path); - path[len] = separator; - path[len+1] = '\0'; - searchDir( MPPARM(mpool) dlp, volNum, separator, - path, pathSize, creatorSought, versSought ); -#endif - } else if ( (ext = (XP_UCHAR*)StrStr( (const char*)path, ".pdb" )) - != NULL ) { - - /* find out if it's a crosswords dict. */ - FileRef fileRef; - UInt32 type, creator; - - err = VFSFileOpen( volNum, (const char*)path, vfsModeRead, - &fileRef ); - if ( err == errNone ) { - XP_U16 vers; - err = VFSFileDBInfo( fileRef, NULL, /* name */ - NULL, /* attributes */ - &vers, /* versionP */ - NULL, /* crDateP */ - NULL, NULL, /*UInt32 *modDateP, UInt32 *bckUpDateP,*/ - NULL, NULL, /*UInt32 *modNumP, MemHandle *appInfoHP,*/ - NULL, /*MemHandle *sortInfoHP, */ - &type, &creator, - NULL ); /* nRecords */ - VFSFileClose( fileRef ); - - if ( (err == errNone) && (type == TYPE_DAWG) && - (creator == creatorSought) && (vers == versSought) ) { - DictListEntry dl; - - dl.path = copyString( mpool, path ); - dl.location = DL_VFS; - dl.u.vfsData.volNum = volNum; - dl.baseName = dl.path + pathLen; - - if ( !addEntry( MPPARM(mpool) dlp, &dl ) ) { - XP_FREE( mpool, dl.path ); - } - } - } - } - } - - path[pathLen] = '\0'; - VFSFileClose( dirRef ); - } - -} /* searchDir */ - -static void -tryVFSSearch( MPFORMAL PalmDictList** dlp, XP_U32 creatorSought, - XP_U16 versSought ) -{ - Err err; - UInt16 volNum; - UInt32 vEnum; - - vEnum = vfsIteratorStart; - while ( vEnum != vfsIteratorStop ) { - unsigned char pathStr[265]; - MemHandle h; - UInt16 bufLen; - - err = VFSVolumeEnumerate( &volNum, &vEnum ); - if ( err != errNone ) { - break; - } - - /* Search from the default (/palm/Launcher, normally) */ - bufLen = sizeof(pathStr); - err = VFSGetDefaultDirectory( volNum, ".pdb", (char*)pathStr, - &bufLen ); - if ( err == errNone ) { - searchDir( MPPARM(mpool) dlp, volNum, pathStr[0], - pathStr, sizeof(pathStr), creatorSought, versSought ); - } - - h = DmGetResource( 'tSTR', 1000 ); - if ( !!h ) { - pathStr[0] = '\0'; - XP_STRCAT( pathStr, MemHandleLock(h) ); - MemHandleUnlock( h ); - DmReleaseResource( h ); - searchDir( MPPARM(mpool) dlp, volNum, pathStr[0], - pathStr, sizeof(pathStr), creatorSought, versSought ); - } - } - -} /* tryVFSSearch */ - -/* if we've allocated extra space in the array as an optimization now's when - * we pull back */ -static void -cleanList( PalmDictList** XP_UNUSED(dl) ) -{ -} /* cleanList */ - -PalmDictList* -DictListMake( MPFORMAL_NOCOMMA ) -{ - return dictListMakePriv( MPPARM(mpool) TYPE_XWRDICT, 1 ); -} - -static PalmDictList* -dictListMakePriv( MPFORMAL XP_U32 creatorSought, XP_U16 versSought ) -{ - Err err; - DmSearchStateType stateType; - UInt32 vers; - PalmDictList* dl = NULL; - UInt16 cardNo; - LocalID dbID; - Boolean newSearch = true; - XP_Bool found = false; - - /* first the DM case */ - while ( !found ) { - err = DmGetNextDatabaseByTypeCreator( newSearch, &stateType, TYPE_DAWG, - creatorSought, - false,// onlyLatestVers, - &cardNo, &dbID ); - if ( err != errNone ) { - break; - } else { - XP_UCHAR nameBuf[33]; - XP_U16 nameLen; - DictListEntry dle; - XP_U16 vers; - - err = DmDatabaseInfo( cardNo, dbID, (char*)nameBuf, NULL, &vers, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL ); - if ( (err == errNone) && (vers == versSought) ) { - nameLen = XP_STRLEN( (const char*)nameBuf ) + 1; - - dle.location = DL_STORAGE; - dle.u.dmData.cardNo = cardNo; - dle.u.dmData.dbID = dbID; - dle.path = dle.baseName = XP_MALLOC( mpool, nameLen ); - XP_MEMCPY( dle.path, nameBuf, nameLen ); - - addEntry( MPPARM(mpool) &dl, &dle ); - } - } - - newSearch = false; - } - - /* then the VFS case */ - err = FtrGet( sysFileCVFSMgr, vfsFtrIDVersion, &vers ); - if ( err == errNone ) { - tryVFSSearch( MPPARM(mpool) &dl, creatorSought, versSought ); - } - - cleanList( &dl ); - - return dl; -} /* dictListMakePriv */ - -void -DictListFree( MPFORMAL PalmDictList* dl ) -{ - if ( !!dl ) { - DictListEntry* dle = dl->dictArray; - XP_U16 i; - - for ( i = 0; i < dl->nDicts; ++i, ++dle ) { - XP_FREE( mpool, dle->path ); - } - - XP_FREE( mpool, dl ); - } -} /* dictListFree */ - -XP_U16 -DictListCount( PalmDictList* dl ) -{ - XP_U16 result; - if ( !dl ) { - result = 0; - } else { - result = dl->nDicts; - } - return result; -} /* dictListCount */ - -#ifdef NODE_CAN_4 - -/***************************************************************************** - * Conversion from old Crosswords DAWG format to new. It should be possible - * for this to go away once the new format's been out for a while. - *****************************************************************************/ - -static XP_Bool -convertOneRecord( DmOpenRef ref, XP_U16 index ) -{ - XP_Bool success = XP_FALSE; - MemHandle h = DmGetRecord( ref, index ); - XP_U16 siz = MemHandleSize( h ); - XP_U8* recPtr; - XP_U16 i; - Err err; - - XP_U16 nRecs = siz / 3; - XP_U8* tmp = MemPtrNew( siz ); - - XP_ASSERT( !!tmp ); - XP_ASSERT( (siz % 3) == 0 ); - - recPtr = MemHandleLock(h); - XP_MEMCPY( tmp, recPtr, siz ); - - for ( i = 0; i < nRecs; ++i ) { - array_edge_old* edge = (array_edge_old*)&tmp[i * 3]; - XP_U8 oldBits = edge->bits; - XP_U8 newBits = 0; - - XP_ASSERT( LETTERMASK_OLD == LETTERMASK_NEW_3 ); - XP_ASSERT( LASTEDGEMASK_OLD == LASTEDGEMASK_NEW ); - newBits |= (oldBits & (LETTERMASK_OLD | LASTEDGEMASK_OLD) ); - - if ( (oldBits & ACCEPTINGMASK_OLD) != 0 ) { - newBits |= ACCEPTINGMASK_NEW; - } - - if ( (oldBits & EXTRABITMASK_OLD) != 0 ) { - newBits |= EXTRABITMASK_NEW; - } - - edge->bits = newBits; - } - - err = DmWrite( recPtr, 0, tmp, siz ); - XP_ASSERT( err == errNone ); - success = err == errNone; - - MemPtrFree( tmp ); - MemHandleUnlock( h ); - DmReleaseRecord( ref, index, true ); - return success; -} /* convertOneRecord */ - -static XP_Bool -convertOneDict( UInt16 cardNo, LocalID dbID ) -{ - Err err; - UInt32 creator; - DmOpenRef ref; - MemHandle h; - dawg_header* header; - dawg_header tmp; - XP_U16 siz; - unsigned char charTableRecNum, firstEdgeRecNum; - XP_U16 nChars; - - /* now modify the flags */ - ref = DmOpenDatabase( cardNo, dbID, dmModeReadWrite ); - XP_ASSERT( ref != 0 ); - h = DmGetRecord( ref, 0 ); - siz = MemHandleSize( h ); - if ( siz < sizeof(*header) ) { - MemHandleResize( h, sizeof(*header) ); - } - - tmp.flags = XP_HTONS(0x0002); - XP_ASSERT( sizeof(tmp.flags) == 2 ); - header = (dawg_header*)MemHandleLock(h); - charTableRecNum = header->charTableRecNum; - firstEdgeRecNum = header->firstEdgeRecNum; - DmWrite( header, OFFSET_OF(dawg_header,flags), &tmp.flags, - sizeof(tmp.flags) ); - MemHandleUnlock(h); - DmReleaseRecord( ref, 0, true ); - - /* Now convert to 16-bit psuedo-unicode */ - h = DmGetRecord( ref, charTableRecNum ); - XP_ASSERT( !!h ); - nChars = MemHandleSize( h ); - err = MemHandleResize( h, nChars * 2 ); - XP_ASSERT( err == errNone ); - - if ( err == errNone ) { - XP_U8 buf[(MAX_UNIQUE_TILES+1)*2]; - XP_S16 i; - XP_U8* ptr = (XP_U8*)MemHandleLock( h ); - - XP_MEMSET( buf, 0, sizeof(buf) ); - - for ( i = 0; i < nChars; ++i ) { - buf[(i*2)+1] = ptr[i]; - } - DmWrite( ptr, 0, buf, nChars * 2 ); - MemHandleUnlock(h); - } - err = DmReleaseRecord( ref, charTableRecNum, true ); - XP_ASSERT( err == errNone ); - - /* Now transpose the accepting and extra bits for every node. */ - if ( err == errNone ) { - XP_U32 nRecords = DmNumRecords(ref); - XP_U16 i; - - for ( i = firstEdgeRecNum; i < nRecords; ++i ) { - convertOneRecord( ref, i ); - } - } - - err = DmCloseDatabase( ref ); - XP_ASSERT( err == errNone ); - - if ( err == errNone ) { - XP_U16 newVers = 1; - creator = TYPE_XWRDICT; - err = DmSetDatabaseInfo( cardNo, dbID, NULL, - NULL, &newVers, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - &creator ); - XP_ASSERT( err == errNone ); - } - return err == errNone; -} /* convertOneDict */ - -static XP_Bool -confirmDictConvert( PalmAppGlobals* globals, const XP_UCHAR* name ) -{ - XP_UCHAR buf[128]; - const XP_UCHAR *fmt = getResString( globals, STRS_CONFIRM_ONEDICT ); - XP_ASSERT( !!fmt ); - XP_SNPRINTF( buf, sizeof(buf), fmt, name ); - return palmask( globals, buf, NULL, -1 ); -} /* confirmDictConvert */ - -void -offerConvertOldDicts( PalmAppGlobals* globals ) -{ - PalmDictList* dl = dictListMakePriv( MPPARM(globals->mpool) 'Xwr3', 0 ); - XP_U16 count = DictListCount(dl); - Err err; - - if ( count > 0 && palmaskFromStrId( globals, STR_CONFIRM_CONVERTDICT, - -1 ) ) { - - XP_U16 i; - for ( i = 0; i < count; ++i ) { - DictListEntry* dle; - if ( getNthDict( dl, i, &dle ) ) { - - if ( dle->location == DL_STORAGE ) { - - if ( confirmDictConvert( globals, dle->baseName ) ) { - convertOneDict( dle->u.dmData.cardNo, - dle->u.dmData.dbID ); - } - - } else { - - if ( confirmDictConvert( globals, dle->baseName ) ) { - - UInt16 cardNo; - LocalID dbID; - UInt16 volRefNum = dle->u.vfsData.volNum; - - XP_ASSERT( dle->location == DL_VFS ); - - XP_LOGF( "trying %s", dle->path ); - - /* copy from SD card to storage, convert, copy back */ - err = VFSImportDatabaseFromFile( volRefNum, - (const char*)dle->path, - &cardNo, &dbID ); - XP_LOGF( "VFSImportDatabaseFromFile => %d", err ); - if ( err == errNone && convertOneDict( cardNo, dbID ) ) { - - err = VFSFileDelete( volRefNum, dle->path ); - XP_LOGF( "VFSFileDelete=>%d", err ); - if ( err == errNone ) { - - err = VFSExportDatabaseToFile( volRefNum, - (const char*)dle->path, - cardNo, dbID ); - - XP_LOGF( "VFSExportDatabaseToFile => %d", err ); - - XP_ASSERT( err == errNone ); - err = DmDeleteDatabase( cardNo, dbID ); - XP_ASSERT( err == errNone ); - } - } - } - } - } - } - } - - DictListFree( MPPARM(globals->mpool) dl ); -} /* offerConvertOldDicts */ -#endif diff --git a/xwords4/palm/dictlist.h b/xwords4/palm/dictlist.h deleted file mode 100644 index f6aa1d27a..000000000 --- a/xwords4/palm/dictlist.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _DICTLIST_H_ -#define _DICTLIST_H_ - -#include "palmmain.h" -#include "palmdict.h" - -enum { DL_STORAGE, DL_VFS }; - -typedef struct DictListEntry { - XP_UCHAR* path; - XP_UCHAR* baseName; /* points into, or ==, path */ - DictionaryCtxt* dict; /* cache so can refcount */ - XP_UCHAR location; /* Storage RAM or VFS */ - union { - struct { - UInt16 cardNo; - LocalID dbID; - } dmData; - struct { - UInt16 volNum; - } vfsData; - } u; -} DictListEntry; - -PalmDictList* DictListMake( MPFORMAL_NOCOMMA ); -void DictListFree( MPFORMAL PalmDictList* dl ); -XP_U16 DictListCount( PalmDictList* dl ); - -XP_Bool getDictWithName( const PalmDictList* dl, const unsigned char* name, - DictListEntry** dle ); -void cacheDictForName( PalmDictList* dl, const XP_UCHAR* dictName, - DictionaryCtxt* ctxt ); -void removeFromDictCache( PalmDictList* dl, XP_UCHAR* dictName ); - -XP_Bool getNthDict( const PalmDictList* dl, short n, DictListEntry** dle ); - -#endif diff --git a/xwords4/palm/dictui.c b/xwords4/palm/dictui.c deleted file mode 100644 index f8b5080df..000000000 --- a/xwords4/palm/dictui.c +++ /dev/null @@ -1,286 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/**************************************************************************** - * - * Copyright 1999 - 2003 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include -#include - -#include "callback.h" -#include "dictui.h" -#include "palmmain.h" -#include "palmutil.h" -#include "palmdict.h" -#include "dictlist.h" -#include "strutils.h" -#include "xwords4defines.h" - -#define TYPE_DAWG 'DAWG' -#define TYPE_XWR3 'Xwr3' - -////////////////////////////////////////////////////////////////////////////// -// Prototypes -////////////////////////////////////////////////////////////////////////////// -static XP_U16 populateDictionaryList( MPFORMAL ListData* sLd, - const XP_UCHAR* curDictName, - ListPtr list, Int16 triggerID, - PalmDictList* dl ); -static Boolean beamDict( const PalmDictList* dl, XP_UCHAR* dictName ); - -/***************************************************************************** - * Handler for dictionary info form. - ****************************************************************************/ -#define USE_POPULATE 1 -Boolean -dictFormHandleEvent( EventPtr event ) -{ - FormPtr form; - Boolean result; - Int16 chosen; - DictionaryCtxt* dict; - PalmAppGlobals* globals; - XP_UCHAR* dictName; - - CALLBACK_PROLOGUE(); - - result = false; - globals = getFormRefcon(); - - switch ( event->eType ) { - case frmOpenEvent: { - const XP_UCHAR* curName; - XP_U16 width; - RectangleType rect; - - form = FrmGetActiveForm(); - - /* we're either a beam dlg or a dict picker; disable a button here. */ - disOrEnable( form, - globals->dictuiForBeaming ? - XW_DICTINFO_DONE_BUTTON_ID:XW_DICTINFO_BEAM_BUTTON_ID, - false ); - - /* dictionary list setup */ - globals->dictState.dictList = - getActiveObjectPtr( XW_DICTINFO_LIST_ID ); - - dict = !!globals->game.model? - model_getDictionary(globals->game.model) : NULL; - if ( dict ) { - curName = dict_getName( dict ); - } else { - curName = NULL; - } - width = populateDictionaryList( MPPARM(globals->mpool) - &globals->dictState.sLd, - curName, globals->dictState.dictList, - XW_DICTINFO_TRIGGER_ID, - globals->dictList ); - getObjectBounds( XW_DICTINFO_LIST_ID, &rect ); - rect.extent.x = width; - setObjectBounds( XW_DICTINFO_LIST_ID, &rect ); - - FrmDrawForm( form ); - break; - } - - case ctlSelectEvent: - switch ( event->data.ctlEnter.controlID ) { - - case XW_DICTINFO_TRIGGER_ID: - // don't let change dict except first time - if ( globals->dictuiForBeaming || globals->isNewGame ) { - chosen = LstPopupList( globals->dictState.dictList ); - if ( chosen >= 0 ) { - setSelectorFromList( XW_DICTINFO_TRIGGER_ID, - globals->dictState.dictList, - chosen ); - } - } - result = true; - break; -/* case XW_PHONIES_TRIGGER_ID: */ -/* chosen = LstPopupList( sPhoniesList ); */ -/* if ( chosen >= 0 ) { */ -/* setTriggerFromList( XW_PHONIES_TRIGGER_ID, sPhoniesList, */ -/* chosen ); */ -/* } */ -/* result = true; */ -/* break; */ - - case XW_DICTINFO_DONE_BUTTON_ID: - case XW_DICTINFO_BEAM_BUTTON_ID: - /* discard the const */ - dictName = (XP_UCHAR*)CtlGetLabel( - getActiveObjectPtr( XW_DICTINFO_TRIGGER_ID) ); - - if ( globals->dictuiForBeaming ) { - if ( !beamDict( globals->dictList, dictName ) ) { - break; /* don't cancel dialog yet */ - } - } else { - EventType eventToPost; - - XP_ASSERT( dictName != NULL ); - - eventToPost.eType = dictSelectedEvent; - ((DictSelectedData*)&eventToPost.data.generic)->dictName - = copyString( globals->mpool, dictName ); - EvtAddEventToQueue( &eventToPost ); - } - - case XW_DICTINFO_CANCEL_BUTTON_ID: - result = true; - freeListData( MPPARM(globals->mpool) &globals->dictState.sLd ); - FrmReturnToForm( 0 ); - break; - - } // switch ( event->data.ctlEnter.controlID ) - break; - - default: - break; - } // switch - - CALLBACK_EPILOGUE(); - return result; -} /* dictFormHandleEvent */ - -/***************************************************************************** - * - ****************************************************************************/ -static XP_U16 -populateDictionaryList( MPFORMAL ListData* sLd, const XP_UCHAR* curDictName, - ListPtr list, Int16 triggerID, PalmDictList* dl ) -{ - XP_U16 i; - XP_U16 maxWidth = 0; - XP_U16 nDicts; - - initListData( MPPARM(mpool) sLd, 16 ); /* PENDING: MAX_DICTS or count */ - nDicts = DictListCount( dl ); - - for ( i = 0; i < nDicts; ++i ) { - DictListEntry* dle; - XP_UCHAR* name; - XP_U16 width; - - getNthDict( dl, i, &dle ); - name = dle->baseName; - - addListTextItem( MPPARM(mpool) sLd, name ); - width = FntCharsWidth( (const char*)name, XP_STRLEN((const char*)name) ); - if ( width > maxWidth ) { - maxWidth = width; - } - } - - sortList( sLd ); - setListSelection( sLd, (char*)curDictName ); - setListChoices( sLd, list, NULL ); - - setSelectorFromList( triggerID, list, LstGetSelection(list) ); - - return maxWidth + 3; /* 3: for white space */ -} /* populateDictionaryList */ - -/*********************************************************************** - * The rest of this file mostly stolen from palmos.com. I've only modified - * beamDict - ************************************************************************/ -static Err -WriteDBData(const void* dataP, UInt32* sizeP, void* userDataP) -{ - Err err; - - /* Try to send as many bytes as were requested by the caller */ - *sizeP = ExgSend((ExgSocketPtr)userDataP, (void*)dataP, *sizeP, &err); - return err; -} /* WriteDBData */ - -Err -sendDatabase( UInt16 cardNo, LocalID dbID, XP_UCHAR* nameP, - XP_UCHAR* descriptionP ) -{ - ExgSocketType exgSocket; - Err err; - - /* Create exgSocket structure */ - XP_MEMSET( &exgSocket, 0, sizeof(exgSocket) ); - exgSocket.description = (char*)descriptionP; - exgSocket.name = (char*)nameP; - - /* Start an exchange put operation */ - err = ExgPut(&exgSocket); - if ( !err ) { - err = ExgDBWrite( WriteDBData, &exgSocket, NULL, dbID, cardNo ); - /* Disconnect Exg and pass error */ - err = ExgDisconnect(&exgSocket, err); - } - return err; -} /* sendDatabase */ - -static Boolean -beamDict( const PalmDictList* dl, XP_UCHAR* dictName ) -{ - Err err; - UInt16 cardNo; - LocalID dbID; - Boolean found; - XP_Bool shouldDispose = XP_FALSE; - DictListEntry* dle; - - found = getDictWithName( dl, dictName, &dle ); - - /* Find our app using its internal name */ - XP_ASSERT( found ); - - if ( found ) { - if ( dle->location == DL_VFS ) { - err = VFSImportDatabaseFromFile( dle->u.vfsData.volNum, - (const char*)dle->path, - &cardNo, &dbID ); - if ( err == dmErrAlreadyExists ) { - } else if ( err == errNone ) { - shouldDispose = XP_TRUE; - } else { - found = XP_FALSE; - } - } else { - cardNo = dle->u.dmData.cardNo; - dbID = dle->u.dmData.dbID; - } - } - - if ( found ) { /* send it giving external name and description */ - XP_UCHAR prcName[40]; - XP_SNPRINTF( prcName, sizeof(prcName), (XP_UCHAR*)"%s.pdb", dictName ); - err = sendDatabase( cardNo, dbID, prcName, dictName ); - found = err == 0; - - if ( shouldDispose ) { - DmDeleteDatabase( cardNo, dbID ); - } - } - - return found; -} /* beamDict */ - diff --git a/xwords4/palm/dictui.h b/xwords4/palm/dictui.h deleted file mode 100644 index 5f6ce3369..000000000 --- a/xwords4/palm/dictui.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _DICTUI_H_ -#define _DICTUI_H_ - -#include "palmmain.h" -#include "palmdict.h" - -typedef struct DictSelectedData { - MemPtr dictName; -} DictSelectedData; - -Boolean dictFormHandleEvent( EventPtr event ); - -/* export for beamBoard */ -Err sendDatabase( UInt16 cardNo, LocalID dbID, XP_UCHAR* nameP, - XP_UCHAR* descriptionP ); -#endif diff --git a/xwords4/palm/enter68k.c b/xwords4/palm/enter68k.c deleted file mode 100644 index 8505e234d..000000000 --- a/xwords4/palm/enter68k.c +++ /dev/null @@ -1,250 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2004 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include -#include -#include -#include -#include -#include "pnostate.h" -#include "palmmain.h" /* for Ftr enum */ - -static void -write_byte32( void* dest, UInt32 val ) -{ - MemMove( dest, &val, sizeof(val) ); -} - -static UInt32 -byte_swap32( UInt32 in ) -{ - UInt32 tmp = 0L; - tmp |= (in & 0x000000FF) << 24; - tmp |= (in & 0x0000FF00) << 8; - tmp |= (in & 0x00FF0000) >> 8; - tmp |= (in & 0xFF000000) >> 24; - return tmp; -} - -static void -alertUser( char* str ) -{ - (void)FrmCustomAlert( XW_ERROR_ALERT_ID, - str, " ", " " ); -} - -typedef struct PNOFtrHeader { - UInt32* gotTable; -} PNOFtrHeader; - -void -storageCallback( void/*PnoletUserData*/* _dataP ) -{ - PnoletUserData* dataP = (PnoletUserData*)_dataP; - UInt32 offset; - PNOFtrHeader* ftrBase; - - if ( dataP->recursive ) { - WinDrawChars( "ERROR: overwriting", 13, 5, 60 ); -#ifdef DEBUG - for ( ; ; ); /* make sure we see it. :-) */ -#endif - } - - ftrBase = (PNOFtrHeader*)dataP->pnoletEntry; - --ftrBase; /* back up over header */ - offset = (char*)dataP->stateDest - (char*)ftrBase; - DmWrite( ftrBase, offset, dataP->stateSrc, sizeof(PNOState) ); -} - -static void -countOrLoadPNOCs( UInt32* pnoSizeP, UInt8* base, UInt32 offset ) -{ - DmResID id; - - for ( id = 0; ; ++id ) { - UInt32 size; - MemHandle h = DmGetResource( 'Pnoc', id ); - - if ( !h ) { - break; - } - size = MemHandleSize( h ); - if ( !!base ) { - Err err = DmWrite( base, offset, MemHandleLock(h), size ); - if ( err != errNone ) { - alertUser( "error from DmWrite" ); - } - MemHandleUnlock(h); - } - DmReleaseResource(h); - offset += size; - } - - if ( !!pnoSizeP ) { - *pnoSizeP = offset; - } -} /* countOrLoadPNOCs */ - -/* Return true if we had to load the pnolet. If we didn't, then we're being - * called recursively (probably because of ExgMgr activity); in that case the - * caller better not unload! - */ -static Boolean -setupPnolet( UInt32** entryP, UInt32** gotTableP ) -{ - PNOFtrHeader* ftrBase; - Err err = FtrGet( APPID, PNOLET_STORE_FEATURE, (UInt32*)&ftrBase ); - XP_Bool mustLoad = err != errNone; - - if ( mustLoad ) { - UInt32* gotTable; - UInt32 pnoSize, gotSize, pad; - UInt32 ftrSize = sizeof( PNOFtrHeader ); - UInt32* pnoCode; - PNOFtrHeader header; - - // LOAD: GOT table - MemHandle h = DmGetResource( 'Pnog', 0 ); - if ( !h ) { - gotSize = 0; - gotTable = NULL; - } else { - gotSize = MemHandleSize( h ); - gotTable = (UInt32*)MemPtrNew( gotSize ); - MemMove( gotTable, MemHandleLock(h), gotSize ); - MemHandleUnlock( h ); - DmReleaseResource( h ); - } - ftrSize += gotSize; - - countOrLoadPNOCs( &pnoSize, NULL, 0 ); - ftrSize += pnoSize; - pad = (4 - (pnoSize & 3)) & 3; - ftrSize += pad; - - FtrPtrNew( APPID, PNOLET_STORE_FEATURE, ftrSize, (void**)&ftrBase ); - pnoCode = (UInt32*)&ftrBase[1]; - - countOrLoadPNOCs( NULL, (UInt8*)ftrBase, sizeof(PNOFtrHeader) ); - - if ( gotSize > 0 ) { - UInt32 cnt = gotSize >> 2; - UInt32 i; - for ( i = 0; i < cnt; ++i ) { - write_byte32(&gotTable[i], - byte_swap32(byte_swap32(gotTable[i]) - + (UInt32)pnoCode)); - } - - DmWrite( ftrBase, sizeof(PNOFtrHeader) + pnoSize + pad, - gotTable, gotSize ); - MemPtrFree( gotTable ); - - header.gotTable = (UInt32*)(((char*)pnoCode) + pnoSize + pad); - DmWrite( ftrBase, 0, &header, sizeof(header) ); - } - } - - *gotTableP = ftrBase->gotTable; - *entryP = (UInt32*)&ftrBase[1]; - - return mustLoad; -} /* setupPnolet */ - -static Boolean -shouldRunPnolet() -{ - UInt32 value; - Boolean runArm = false; - Err err = FtrGet( sysFtrCreator, sysFtrNumProcessorID, &value ); - - if ( ( err == errNone ) && sysFtrNumProcessorIsARM( value ) ) { - runArm = true; - } -#ifdef FEATURE_DUALCHOOSE - if ( runArm ) { - err = FtrGet( APPID, FEATURE_WANTS_68K, &value ); - if ( (err == errNone) && (value == WANTS_68K) ) { - runArm = false; - } - } -#endif - return runArm; -} /* shouldRunPnolet */ - -UInt32 -PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) -{ - UInt32 result = 0; - if ( ( cmd == sysAppLaunchCmdNormalLaunch ) -#ifdef XWFEATURE_IR - || ( cmd == sysAppLaunchCmdExgAskUser ) - || ( cmd == sysAppLaunchCmdSyncNotify ) - || ( cmd == sysAppLaunchCmdExgReceiveData ) -#endif - ) { - - /* This is the entry point for both an ARM-only app and one capable - of doing both. If the latter, and ARM's an option, we want to use - it unless the user's said not to. */ - - if ( shouldRunPnolet() ) { - UInt32* gotTable; - PnoletUserData* dataP; - UInt32* pnoCode; - UInt32 result; - Boolean loaded; - -#ifdef DEBUG - WinDrawChars( "Loading ARM code...", 19, 5, 25 ); -#endif - - loaded = setupPnolet( &pnoCode, &gotTable ); - dataP = (PnoletUserData*)MemPtrNew( sizeof(PnoletUserData) ); - dataP->recursive = !loaded; - - dataP->pnoletEntry = pnoCode; - dataP->gotTable = gotTable; - dataP->storageCallback = storageCallback; - - dataP->cmdPBP = cmdPBP; - dataP->cmd = cmd; - dataP->launchFlags = launchFlags; - - result = PceNativeCall((NativeFuncType*)pnoCode, (void*)dataP ); - MemPtrFree( dataP ); - - if ( loaded ) { - FtrPtrFree( APPID, PNOLET_STORE_FEATURE ); - } - } else { -#ifdef FEATURE_PNOAND68K - result = PM2(PilotMain)( cmd, cmdPBP, launchFlags); -#else - alertUser( "This copy of Crosswords runs only on ARM-based Palms. " - "Get the right version at xwords.sf.net." ); -#endif - } - } - - return result; -} /* PilotMain */ diff --git a/xwords4/palm/fnavgen.c b/xwords4/palm/fnavgen.c deleted file mode 100644 index 07f53ee9b..000000000 --- a/xwords4/palm/fnavgen.c +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- mode: c; -*- */ - -#include -#include - -#include "xwords4defines.h" - -typedef struct fnavElem { - unsigned short objectID; - unsigned short objectFlags; - unsigned short objectAbove; - unsigned short objectBelow; -} fnavElem; - -typedef struct fnavHeader { - unsigned short formID; /* not part of resource!!!! */ - - unsigned short version; /* always 1 */ - unsigned short objcount; - unsigned short headerSizeInBytes; /* always 20 */ - unsigned short listSizeInBytes; /* always 8 */ - unsigned short navflags; - unsigned short initialHint; - unsigned short jumpToHint; - unsigned short bottomLeftHint; -} fnavHeader; - - -fnavHeader gamesHeader = { - XW_NEWGAMES_FORM, - 0, /* fill this in */ - 0, /* fill this in */ - 0, /* fill this in */ - 0, /* fill this in */ - 0x0001, /* force obj focus mode */ - 0, - 0, - 0, -}; - -fnavElem gamesElems[] = { - { XW_ROBOT_1_CHECKBOX_ID, 0, 0, XW_ROBOT_2_CHECKBOX_ID }, - { XW_ROBOT_2_CHECKBOX_ID, 0, XW_ROBOT_1_CHECKBOX_ID, XW_ROBOT_3_CHECKBOX_ID }, - { XW_ROBOT_3_CHECKBOX_ID, 0, XW_ROBOT_2_CHECKBOX_ID, XW_ROBOT_4_CHECKBOX_ID }, - { XW_ROBOT_4_CHECKBOX_ID, 0, XW_ROBOT_3_CHECKBOX_ID, XW_SOLO_GADGET_ID }, - - { XW_SOLO_GADGET_ID, 0, XW_ROBOT_4_CHECKBOX_ID, XW_SERVER_GADGET_ID }, - { XW_SERVER_GADGET_ID, 0, XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID }, - { XW_CLIENT_GADGET_ID, 0, XW_SERVER_GADGET_ID, 0 } -}; - -unsigned short gamesElemsShort[] = { - -#ifndef XWFEATURE_STANDALONE_ONLY - XW_SOLO_GADGET_ID, - XW_SERVER_GADGET_ID, - XW_CLIENT_GADGET_ID, -#endif - - XW_NPLAYERS_SELECTOR_ID, - XW_PREFS_BUTTON_ID, - - XW_REMOTE_1_CHECKBOX_ID, - XW_PLAYERNAME_1_FIELD_ID, - XW_ROBOT_1_CHECKBOX_ID, - XW_PLAYERPASSWD_1_TRIGGER_ID, - - XW_REMOTE_2_CHECKBOX_ID, - XW_PLAYERNAME_2_FIELD_ID, - XW_ROBOT_2_CHECKBOX_ID, - XW_PLAYERPASSWD_2_TRIGGER_ID, - - XW_REMOTE_3_CHECKBOX_ID, - XW_PLAYERNAME_3_FIELD_ID, - XW_ROBOT_3_CHECKBOX_ID, - XW_PLAYERPASSWD_3_TRIGGER_ID, - - XW_REMOTE_4_CHECKBOX_ID, - XW_PLAYERNAME_4_FIELD_ID, - XW_ROBOT_4_CHECKBOX_ID, - XW_PLAYERPASSWD_4_TRIGGER_ID, - - XW_DICT_SELECTOR_ID, - XW_CANCEL_BUTTON_ID, - XW_OK_BUTTON_ID - -}; - -static void -usage( char* name ) -{ - fprintf( stderr, "usage: %s outfile\n", name ); - exit( 1 ); -} /* */ - -static void -write_network_short( FILE* fil, unsigned short s ) -{ - unsigned short tmp = htons( s ); - fwrite( &tmp, sizeof(tmp), 1, fil ); -} /* write_network_short */ - -write_fnav( fnavHeader* header, unsigned short* idArray, - fnavElem* elems, int count ) -{ - char nameBuf[32]; - FILE* fil; - int i; - - assert( !idArray || !elems ); - - sprintf( nameBuf, "fnav%.4x.bin", header->formID ); - fil = fopen( nameBuf, "w" ); - fprintf( stderr, "created file %s\n", nameBuf ); - - write_network_short( fil, 1 ); - write_network_short( fil, count ); - write_network_short( fil, 20 ); - write_network_short( fil, 8 ); - write_network_short( fil, header->navflags ); - write_network_short( fil, header->initialHint ); - write_network_short( fil, header->jumpToHint ); - write_network_short( fil, header->bottomLeftHint ); - - /* Two words of padding. Docs disagree, but Blazer's resources have - 'em */ - write_network_short( fil, 0 ); - write_network_short( fil, 0 ); - - if ( !!elems ) { - - for ( i = 0; i < count; ++i ) { - write_network_short( fil, elems->objectID ); - write_network_short( fil, elems->objectFlags ); - write_network_short( fil, elems->objectAbove ); - write_network_short( fil, elems->objectBelow ); - - ++elems; - } - - } else { - unsigned short prevID = 0; - unsigned short id = *idArray++; - - while ( count-- ) { - unsigned short nextID; - - if ( count == 0 ) { - nextID = 0; - } else { - nextID = *idArray++; - } - - write_network_short( fil, id ); - write_network_short( fil, 0 ); - write_network_short( fil, prevID ); - write_network_short( fil, nextID ); - - if ( !nextID ) { - break; - } - - prevID = id; - id = nextID; - } - } - - fclose(fil); -} /* write_fnav */ - -int -main( int argc, char** argv ) -{ - int i; - char* outFName; - - if ( argc != 1 ) { - usage( argv[0] ); - } - - write_fnav( &gamesHeader, gamesElemsShort, NULL, - VSIZE(gamesElemsShort) ); -/* sizeof(gamesElems)/sizeof(gamesElems[0]) ); */ - - -} /* main */ diff --git a/xwords4/palm/funcfile.txt b/xwords4/palm/funcfile.txt deleted file mode 100644 index a8ce437cb..000000000 --- a/xwords4/palm/funcfile.txt +++ /dev/null @@ -1,254 +0,0 @@ -# PalmOS functions listed here will have PACE-interface bodies -# generated for them. For most, that's enough. Some will require -# manual work beyond that. -# -# Just to have a record, list the ones that must be hand-coded here. -# StrVPrintF -# StrPrintF -# SysHandleEvent -# FrmSetEventHandler -# LstSetListChoices -# SysNotifyRegister -# LstSetDrawFunction -# ExgDBWrite -# -################################################################# -CtlEnabled -CtlGetLabel -CtlGetValue -CtlSetEnabled -CtlSetLabel -CtlSetValue -DateToAscii -DmCloseDatabase -DmCreateDatabase -DmDatabaseInfo -DmDeleteDatabase -DmFindDatabase -DmFindResource -DmFindResourceType -DmGetNextDatabaseByTypeCreator -DmGetRecord -DmGetResource -DmGetResourceIndex -DmNewRecord -DmNewResource -DmNumRecords -DmOpenDatabase -DmQueryRecord -DmReleaseRecord -DmReleaseResource -DmRemoveRecord -DmWrite -DmWriteCheck -EvtSysEventAvail -ExgAccept -ExgDisconnect -ExgPut -ExgReceive -ExgRegisterData -ExgSend -FldCalcFieldHeight -FldCopy -FldDrawField -FldGetAttributes -FldGetScrollValues -FldGetTextLength -FldGetTextPtr -FldInsert -FldRecalculateField -FldScrollField -FldScrollable -FldSetAttributes -FldSetSelection -FldSetTextPtr -FntCharsWidth -FntGetFont -FntLineHeight -FntSetFont -FrmCloseAllForms -FrmCustomAlert -FrmDeleteForm -FrmDoDialog -FrmDrawForm -FrmGetActiveForm -FrmGetActiveFormID -FrmGetFirstForm -FrmGetFocus -FrmGetFormBounds -FrmGetFormPtr -FrmGetGadgetData -FrmGetNumberOfObjects -FrmGetObjectBounds -FrmGetObjectId -FrmGetObjectIndex -FrmGetObjectPosition -FrmGetObjectPtr -FrmGetObjectType -FrmGetWindowHandle -FrmGotoForm -FrmHideObject -FrmInitForm -FrmPopupForm -FrmReturnToForm -FrmSetActiveForm -FrmSetFocus -FrmSetGadgetData -FrmSetObjectBounds -FrmSetObjectPosition -FrmSetTitle -FrmShowObject -FrmUpdateForm -FtrGet -FtrSet -FtrUnregister -GrfSetState -LstDrawList -LstEraseList -LstGetNumberOfItems -LstGetSelection -LstGetSelectionText -LstMakeItemVisible -LstPopupList -LstSetHeight -LstSetSelection -MemChunkFree -MemHandleLock -MemHandleLockCount -MemHandleResize -MemHandleSize -MemHandleUnlock -MemMove -MemPtrNew -MemPtrRecoverHandle -MemPtrSize -MemPtrUnlock -MemSet -MenuEraseStatus -PrefGetAppPreferences -PrefGetAppPreferencesV10 -PrefSetAppPreferences -RctGetIntersection -RctPtInRectangle -SclSetScrollBar -SndPlaySystemSound -StrAToI -StrCat -StrCompare -StrCopy -StrIToA -StrLen -StrNCompare -StrStr -SysLibFind -SysLibLoad -SysNotifyUnregister -SysRandom -SysTicksPerSecond -TimGetSeconds -TimGetTicks -TimeToAscii -VFSDirEntryEnumerate -VFSFileClose -VFSFileDBInfo -VFSFileOpen -VFSGetDefaultDirectory -VFSImportDatabaseFromFile -VFSVolumeEnumerate -WinDeleteWindow -WinDrawBitmap -WinDrawChars -WinDrawLine -WinDrawPixel -WinDrawRectangle -WinDrawRectangleFrame -WinEraseRectangle -WinEraseRectangleFrame -WinEraseWindow -WinFillRectangle -WinGetClip -WinGetDrawWindowBounds -WinInvertRectangle -WinPopDrawState -WinPushDrawState -WinRGBToIndex -WinRestoreBits -WinSaveBits -WinScreenMode -WinScrollRectangle -WinSetBackColor -WinSetBounds -WinSetClip -WinSetDrawWindow -WinSetForeColor -WinSetPattern -WinSetTextColor -WinEraseLine -SclDrawScrollBar -DmNumRecordsInCategory -DmSeekRecordInCategory -DmResizeRecord -VFSExportDatabaseToFile -VFSFileDelete -DmSetDatabaseInfo -DmGetLastErr -WinRestoreBits -WinSetCoordinateSystem -WinGetDisplayExtent -WinScreenGetAttribute -TimSecondsToDateTime -EvtGetEvent -FrmDispatchEvent -MenuHandleEvent -EvtAddEventToQueue -FtrPtrFree -SysUIAppSwitch -FntBaseLine -WinSetScalingMode -WinGetDrawWindow -############ These only needed if XWFEATURE_RELAY defined -NetLibOpen -NetLibSocketOpen -NetLibClose -NetLibSocketClose -NetLibSend -NetLibReceive -NetLibSelect -NetLibSocketConnect -NetLibSocketOptionSet -# -# These are currently needed only when TALL_FONTS is #defined -# -BmpCreate -BmpDelete -WinCreateBitmapWindow -WinSetDrawMode -WinGetPixel -# -# Needed for five-way navigation -# -UIColorGetTableEntryIndex -#HsNavDrawFocusRing -#ifdef XWFEATURE_BLUETOOTH -BtLibOpen -BtLibAddrBtdToA -BtLibSocketSend -BtLibSocketClose -BtLibLinkConnect -BtLibDiscoverSingleDevice -BtLibLinkDisconnect -BtLibSocketRespondToConnection -BtLibClose -BtLibSocketConnect -BtLibSocketListen -#BtLibRegisterManagementNotification -#BtLibUnregisterManagementNotification -#BtLibSocketCreate -BtLibGetRemoteDeviceName -BtLibSdpServiceRecordCreate -BtLibSdpServiceRecordStopAdvertising -BtLibSdpGetPsmByUuid -BtLibSdpServiceRecordSetAttributesForSocket -BtLibSdpServiceRecordStartAdvertising -BtLibSdpServiceRecordDestroy -#endif diff --git a/xwords4/palm/gameutil.c b/xwords4/palm/gameutil.c deleted file mode 100644 index b1bca3744..000000000 --- a/xwords4/palm/gameutil.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include - -#include "comtypes.h" -#include "comms.h" -#include "strutils.h" -#include "gameutil.h" -#include "xwords4defines.h" -#include "xwstream.h" -#include "palmmain.h" - -XP_U16 -countGameRecords( PalmAppGlobals* globals ) -{ - LocalID id; - DmOpenRef dbP; - UInt16 numRecs; - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeWrite ); - numRecs = DmNumRecords( dbP ); - DMCLOSEDATABASE( dbP ); - return numRecs; -} - -void -deleteGameRecord( PalmAppGlobals* globals, XP_S16 index ) -{ - LocalID id; - DmOpenRef dbP; - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeWrite ); - DmRemoveRecord( dbP, index ); - DMCLOSEDATABASE( dbP ); -} /* deleteGameRecord */ - -XP_S16 -duplicateGameRecord( PalmAppGlobals* globals, XP_S16 fromIndex ) -{ - LocalID id; - DmOpenRef dbP; - MemHandle newRecord, curRecord; - XP_U16 size; - XP_S16 newIndex = fromIndex + 1; - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeWrite ); - XP_ASSERT( fromIndex < countGameRecords(globals) ); - curRecord = DmQueryRecord( dbP, fromIndex ); - size = MemHandleSize( curRecord ); - newRecord = DmNewRecord( dbP, (XP_U16*)&newIndex, size ); - - DmWrite( MemHandleLock(newRecord), 0, MemHandleLock(curRecord), size ); - - MemHandleUnlock( curRecord ); - MemHandleUnlock( newRecord ); - - DmReleaseRecord( dbP, newIndex, true ); - - DMCLOSEDATABASE( dbP ); - - return newIndex; -} /* duplicateGameRecord */ - -void -streamToGameRecord( PalmAppGlobals* globals, XWStreamCtxt* stream, - XP_S16 index ) -{ - LocalID id; - DmOpenRef dbP; - MemHandle handle; - MemPtr tmpPtr, ptr; - Err err; - - XP_U32 size = stream_getSize( stream ); - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeWrite ); - XP_ASSERT( !!dbP ); - - if ( index == DmNumRecords(dbP) ) { - handle = DmNewRecord( dbP, (XP_U16*)&index, size ); - } else { - XP_ASSERT( index < countGameRecords(globals) ); - handle = DmGetRecord( dbP, index ); - MemHandleResize( handle, size ); - } - - tmpPtr = MemPtrNew(size); - stream_getBytes( stream, tmpPtr, size ); - ptr = MemHandleLock( handle ); - err = DmWrite( ptr, 0, tmpPtr, size ); - XP_ASSERT( err == 0 ); - MemPtrFree( tmpPtr ); - - MemHandleUnlock(handle); - err = DmReleaseRecord( dbP, index, true ); - XP_ASSERT( err == 0 ); - DMCLOSEDATABASE( dbP ); -} /* streamToGameRecord */ - -void -writeNameToGameRecord( PalmAppGlobals* globals, XP_S16 index, - char* newName, XP_U16 len ) -{ - LocalID id; - DmOpenRef dbP; - MemHandle handle; - char name[MAX_GAMENAME_LENGTH]; - - XP_ASSERT( len == XP_STRLEN(newName) ); - XP_ASSERT( len > 0 ); - XP_MEMSET( name, 0, sizeof(name) ); - if ( len >= MAX_GAMENAME_LENGTH ) { - len = MAX_GAMENAME_LENGTH - 1; - } - XP_MEMCPY( name, newName, len+1 ); - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeWrite ); - - if ( index == DmNumRecords(dbP) ) { - handle = DmNewRecord(dbP, (XP_U16*)&index, MAX_GAMENAME_LENGTH); - } else { - XP_ASSERT( index < DmNumRecords(dbP) ); - handle = DmGetRecord( dbP, index ); - } - XP_ASSERT( !!handle ); - DmWrite( MemHandleLock(handle), 0, name, MAX_GAMENAME_LENGTH ); - MemHandleUnlock( handle ); - (void)DmReleaseRecord( dbP, index, true ); - DMCLOSEDATABASE( dbP ); -} /* writeNameToGameRecord */ - -void -nameFromRecord( PalmAppGlobals* globals, XP_S16 index, char* buf ) -{ - LocalID id; - DmOpenRef dbP; - MemHandle handle; - - buf[0] = '\0'; /* init to empty string */ - - if ( index < countGameRecords(globals) ) { - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - if ( id != 0 ) { - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeWrite ); - if ( dbP != 0 ) { - handle = DmQueryRecord( dbP, index ); - - XP_MEMCPY( buf, MemHandleLock(handle), MAX_GAMENAME_LENGTH ); - buf[MAX_GAMENAME_LENGTH-1] = '\0'; - - MemHandleUnlock( handle ); - DMCLOSEDATABASE( dbP ); - } - } - } -} /* nameFromRecord */ - -/***************************************************************************** - * Later this will provide a default name based on a timestamp. - *****************************************************************************/ -#ifndef TIME_FORMAT -#define TIME_FORMAT tfColonAMPM -#endif -#ifndef DATE_FORMAT -#define DATE_FORMAT dfMDYLongWithComma -#endif -void -makeDefaultGameName( char* buf ) -{ - char timeBuf[timeStringLength+1]; /* add 1 to be safe */ - char dateBuf[longDateStrLength+1]; - DateTimeType timeType; - - TimSecondsToDateTime( TimGetSeconds(), &timeType ); - TimeToAscii( timeType.hour, timeType.minute, TIME_FORMAT, timeBuf ); - - DateToAscii( timeType.month, timeType.day, timeType.year, - DATE_FORMAT, dateBuf ); - - StrPrintF( buf, "%s, %s", dateBuf, timeBuf ); -} /* makeDefaultGameName */ - diff --git a/xwords4/palm/gameutil.h b/xwords4/palm/gameutil.h deleted file mode 100644 index 599df574f..000000000 --- a/xwords4/palm/gameutil.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _GAMEUTIL_H_ -#define _GAMEUTIL_H_ - -#include "comtypes.h" -#include "memstream.h" -#include "palmmain.h" - -XP_U16 countGameRecords( PalmAppGlobals* globals ); -void deleteGameRecord( PalmAppGlobals* globals, XP_S16 index ); -XP_S16 duplicateGameRecord( PalmAppGlobals* globals, XP_S16 fromIndex ); -void nameFromRecord( PalmAppGlobals* globals, XP_S16 index, char* buf ); -void streamToGameRecord( PalmAppGlobals* globals, XWStreamCtxt* stream, - XP_S16 index ); -void makeDefaultGameName( char* buf ); - -#endif diff --git a/xwords4/palm/gen_pace.pl b/xwords4/palm/gen_pace.pl deleted file mode 100755 index 0bbd17245..000000000 --- a/xwords4/palm/gen_pace.pl +++ /dev/null @@ -1,715 +0,0 @@ -#!/usr/bin/perl -# Copyright 2004-2007 by Eric House (xwords@eehouse.org). All rights reserved. -# -# 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. - -use strict; -use File::Basename; - -my %funcInfo; -my %fileNames; -my %contents; -my @ifdefs; -my @minusDs; - -sub usage() { - print STDERR "$0 \\\n" . - "\t[-oh out.h] \\\n" . - "\t[-oc out.c] \\\n" . - "\t[-os out.s] \\\n" . - "\t[-D ... -D] \\\n" . - "\t[-file palmheader.h|palm_header_dir] (can repeat) \\\n" . - "\t[-func func_name_or_list_file] (can repeat)\n"; - - exit 1; -} - -# Given the name of a palm function, or of a file containing a list of -# such, return a list of function names. In the first case it'll be a -# singleton. -sub makeFuncList($) { - my ( $nameOrPath ) = @_; - my @result; - - if ( open LIST, "< $nameOrPath" ) { - while ( ) { - chomp; - - # ifdef/endif pairs - if ( m/^\#\s*ifdef\s+(\w+)\s*$/ ) { - # print STDERR "looking for $1 in ", join( ",", @minusDs), "\n"; - if ( 0 == grep( {$1 eq $_} @minusDs ) ) { - # print STDERR "adding $1 to skippers\n"; - push( @ifdefs, $1 ); - } else { - # print STDERR "NOT adding $1 to skippers\n"; - } - next; - } elsif ( m/^\#\s*endif\s+(\w+)\s*$/ ) { - if ( 0 == grep( {$1 eq $_} @minusDs ) ) { - die "$1 not most recently defined" if $1 ne pop(@ifdefs); - } - next; - } - next if @ifdefs > 0; - - # comments? - s/\#.*$//; - # white space - s/^\s*//; - s/\s*$//; - - if ( m,^(\w+)\s+(-?\d+)\s+(0x\w+)$, ) { - push( @result, [ $1, $2, $3 ] ); - } elsif ( m,^(\w+)$, ) { - push( @result, [ $1 ] ); - } else { - next; - } - } - close LIST; - } else { - # must be a simple function name - push( @result, $nameOrPath ); - } - return @result; -} # makeFuncList - -sub makeFileList($) { - my ( $fileOrDir ) = @_; - my @result; - push @result, $fileOrDir; - return @result; -} # makeFileList - -my @funcList; -my @pathList; -my $dot_c; -my $dot_s; -my $dot_h; - -# A list of types seen in the header files. The idea is to use these -# to determine the size of a type and whether it's returned in d0 or -# a0. The user function should print out types it doesn't find here -# and they should be added manually; - -my %typeInfo = ( - "UInt32" => { "size" => 4, "a0" => 0 }, - "UInt16" => { "size" => 2, "a0" => 0 }, - "void*" => { "size" => 4, "a0" => 1 }, - "void**" => { "size" => 4, "a0" => 1, "autoSwap" => 4 }, - "void" => { "size" => 0, "a0" => 0 }, - "BitmapPtr" => { "size" => 4, "a0" => 1 }, - "Boolean" => { "size" => 1, "a0" => 0 }, - "Boolean*" => { "size" => 4, "a0" => 0, "autoSwap" => 1 }, - "Char const*" => { "size" => 4, "a0" => 1 }, - "Char*" => { "size" => 4, "a0" => 1 }, - "Char**" => { "size" => 4, "a0" => 1 }, - "ControlType*" => { "size" => 4, "a0" => 1 }, - "Coord" => { "size" => 2, "a0" => 0 }, # ??? - "Coord*" => { "size" => 4, "a0" => 0, "autoSwap" => 2 }, - "DateFormatType" => { "size" => 1, "a0" => 0 }, # enum - "DateTimeType*" => { "size" => 4, "a0" => 0, "autoSwap" => -1 }, - "DmOpenRef" => { "size" => 4, "a0" => 1 }, - "DmResID" => { "size" => 2, "a0" => 0 }, - "DmResType" => { "size" => 4, "a0" => 0 }, - "DmSearchStatePtr" => { "size" => 4, "a0" => 0 }, - "Err" => { "size" => 2, "a0" => 0 }, - "Err*" => { "size" => 4, "a0" => 1 }, - "EventPtr" => { "size" => 4, "a0" => 1 }, - "EventType*" => { "size" => 4, "a0" => 1, "autoSwap" => -1 }, - "ExgDBWriteProcPtr" => { "size" => 4, "a0" => 1 }, - "ExgSocketType*" => { "size" => 4, "a0" => 1, "autoSwap" => -1 }, - "FieldAttrPtr" => { "size" => 4, "a0" => 1 }, - "FieldType*" => { "size" => 4, "a0" => 1 }, - "FileInfoType*" => { "size" => 4, "a0" => 1, "autoSwap" => -1 }, - "FileRef" => { "size" => 4, "a0" => 0 }, # UInt32 - "FileRef*" => { "size" => 4, "a0" => 1, "autoSwap" => 4 }, - "FontID" => { "size" => 1, "a0" => 0 }, # enum - "FormEventHandlerType*" => { "size" => 4, "a0" => 1 }, - "FormType*" => { "size" => 4, "a0" => 1 }, - "FrameType" => { "size" => 2, "a0" => 0 }, - "IndexedColorType" => { "size" => 1, "a0" => 0 }, # UInt8 - "Int16" => { "size" => 2, "a0" => 0 }, - "Int32" => { "size" => 4, "a0" => 0 }, - "Int8" => { "size" => 1, "a0" => 0 }, - "ListDrawDataFuncPtr" => { "size" => 4, "a0" => 1 }, - "ListType*" => { "size" => 4, "a0" => 1 }, - "LocalID" => { "size" => 4, "a0" => 0 }, - "LocalID*" => { "size" => 4, "a0" => 1, "autoSwap" => 4 }, - "MemHandle" => { "size" => 4, "a0" => 1 }, - "MemHandle*" => { "size" => 4, "a0" => 1 }, - "MemPtr" => { "size" => 4, "a0" => 1 }, - "MenuBarType*" => { "size" => 4, "a0" => 1 }, - "RectangleType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "ScrollBarType*" => { "size" => 4, "a0" => 1 }, - "SndSysBeepType" => { "size" => 1, "a0" => 0 }, - "SysNotifyProcPtr" => { "size" => 4, "a0" => 1 }, - "TimeFormatType" => { "size" => 1, "a0" => 0 }, # enum - "UInt16*" => { "size" => 4, "a0" => 1, "autoSwap" => 2 }, - "UInt32*" => { "size" => 4, "a0" => 1, "autoSwap" => 4 }, - "UInt8" => { "size" => 1, "a0" => 0 }, - "UInt8*" => { "size" => 4, "a0" => 1 }, - "WinDirectionType" => { "size" => 1, "a0" => 0 }, # enum - "WinDrawOperation" => { "size" => 1, "a0" => 0 }, # enum - "WinHandle" => { "size" => 4, "a0" => 1 }, - "WinScreenModeOperation" => { "size" => 1, "a0" => 0 }, # enum - "WindowFormatType" => { "size" => 1, "a0" => 0 }, # enum - "char*" => { "size" => 4, "a0" => 1 }, - "const Char*" => { "size" => 4, "a0" => 1 }, - "const ControlType*" => { "size" => 4, "a0" => 1 }, - # CustomPatternType is UInt8[8]; no need to translate - "const CustomPatternType*" => { "size" => 4, "a0" => 1 }, - "const EventType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "const FieldAttrType*" => { "size" => 4, "a0" => 1 }, - "const FieldType*" => { "size" => 4, "a0" => 1 }, - "const FormType*" => { "size" => 4, "a0" => 1 }, - "const ListType*" => { "size" => 4, "a0" => 1 }, - "const RGBColorType*" => { "size" => 4, "a0" => 1 }, - "const RectangleType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "const char*" => { "size" => 4, "a0" => 1 }, - "const void*" => { "size" => 4, "a0" => 1 }, - "FormObjectKind" => { "size" => 1, "a0" => 0 }, # enum - # it's a char*, likely never returned - "_Palm_va_list" => { "size" => 4, "a0" => 1 }, - "WinScreenAttrType" => { "size" => 1, "a0" => 0 }, # enum - "NetSocketRef" => { "size" => 2, "a0" => 0 }, - "NetSocketAddrType*" => { "size" => 4, "a0" => 1 }, - "NetFDSetType*" => { "size" => 4, "a0" => 1, "autoSwap" => 4 }, - "NetSocketAddrEnum" => { "size" => 1, "a0" => 0 }, - "NetSocketTypeEnum" => { "size" => 1, "a0" => 0 }, - "BitmapType*" => { "size" => 4, "a0" => 1 }, - "ColorTableType*" => { "size" => 4, "a0" => 1 }, - "UIColorTableEntries" => { "size" => 1, "a0" => 0 }, # enum - - "BtLibClassOfDeviceType*" => { "size" => 4, "a0" => 1, - "autoSwap" => 4}, # uint32 - "BtLibDeviceAddressType*" => { "size" => 4, "a0" => 1 }, - "BtLibDeviceAddressTypePtr" => { "size" => 4, "a0" => 1 }, - "BtLibSocketRef" => { "size" => 2, "a0" => 0 }, - "BtLibSocketRef*" => { "size" => 4, "a0" => 1, - "autoSwap" => 2 }, - "BtLibProtocolEnum" => { "size" => 1, "a0" => 0 }, # enum - "BtLibSocketConnectInfoType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "BtLibSocketListenInfoType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "BtLibSdpRecordHandle" => { "size" => 4, "a0" => 1 }, - "BtLibSdpRecordHandle*"=> { "size" => 4, "a0" => 1, - "autoSwap" => 4 }, - "BtLibSdpUuidType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "BtLibFriendlyNameType*" => { "size" => 4, "a0" => 1, - "autoSwap" => -1 }, - "BtLibGetNameEnum" => { "size" => 1, "a0" => 0 }, # enum - - ); - -sub name_compact($) { - my ( $name ) = @_; - - $name =~ s/^\s*//; - $name =~ s/\s*$//; - return $name; -} - -sub type_compact($) { - my ( $type ) = @_; - #print STDERR "1. $type\n"; - $type = name_compact( $type ); - $type =~ s/\s*(\*+)$/$1/; # remove spaces before any trailing * - #print STDERR "2. $type\n"; - return $type; -} - -# Split a string like "( type foo, type* bar, type *bazz, const type -# buzz )" into a list of hashes each with "type" and "name" -sub params_parse($) { - my ( $params ) = @_; - my @plist; - - # strip leading and training ws and params - $params =~ s/^\s*\(//; - $params =~ s/\)\s*$//; - $params =~ s/^void$//; # if just (void), nuke it - - #split based on commas - my @params = split ",", $params; - - @params = map { - s/^\s*//; # leading ws - s/\s*$//; # trailing ws - m|^([\w\s]+[\s\*]+)(\w+)$|; # split on space-or-star - { "type" => type_compact($1), "name" => name_compact($2) }; - } @params; - - return \@params; -} - -sub clean_type($) { - my ( $type ) = @_; - # trip white space off the type - $type =~ s/\s*\*/\*/; - $type =~ s/^\s*//; - $type =~ s/\s*$//; - $type =~ s/^\s*(\S*)\s*$/$1/; - - my @out; - my @terms = split( '\s+', $type ); - foreach my $term (@terms) { - if ( defined( $typeInfo{$term} ) ) { - } elsif ( "const" eq $term ) { - } elsif ( "extern" eq $term ) { - } else { - next; - } - push( @out, $term ); - } - $type = join( " ", @out ); - # print STDERR "clean_type => $type\n"; - - return $type; -} - - -sub searchOneFile($$) { - my ( $file, $function ) = @_; -# print STDERR "searching $file for $function\n"; - - my $base = basename($file); - my $contents = $contents{$base}; - - if ( ! $contents ) { - - # read the file into a single long line, stripping - # (imperfectly) comments. - open FILE, "< $file"; - # print STDERR "looking at file $file\n"; - while( ) { - chomp; - # remove // to eol comments - s|//.*$||; - $contents .= "$_ "; - } - - close FILE; - # strip /*....*/ comments - $contents =~ s|/\*[^*]*\*+([^/*][^*]*\*+)*/||g; - $contents{$base} = $contents; - # print STDERR "$contents\n"; - } - - # a word-token, followed by at least ' ' or *, and another token. - - # This one strips 'const' in 'const type func(params)' - # $contents =~ m/(\w+)([\s\*]+)$function\s*(\([^)]*\))/; - - if ( $contents =~ m/([\w\s]+)([\s\*]+)$function\s*(\([^)]*\))[^V]*(VFSMGR_TRAP)\(([\w]+)\);/ - || $contents =~ m/([\w\s]+)([\s\*]+)$function\s*(\([^)]*\))[^S]*(SYS_TRAP)\s*\(([\w]+)\);/ - || $contents =~ m/([\w\s]+)([\s\*]+)$function\s*(\([^)]*\))[^B]*(BTLIB_TRAP)\s*\(([\w]+)\);/ - || $contents =~ m/([\w\s]+)([\s\*]+)$function\s*(\([^)]*\))[^S]*(SYS_SEL_TRAP)\s*\(([\w]+)\s*,\s*([\w]+)\);/ - || $contents =~ m/([\w\s]+)([\s\*]+)$function\s*(\([^)]*\))[^H]*(HIGH_DENSITY_TRAP)\(([\w]+)\);/ - || $contents =~ m/([\w\s]+)([\s\*]+)$function\s*(\([^)]*\))[^G]*(GRF_TRAP)\(([\w]+)\);/ ) { - - # print STDERR "found something\n"; - - my ( $type, $params, $trapType, $trapSel, $trapSubSel ) = ( "$1$2", $3, $4, $5, $6 ); - if ( $type && $params ) { - - $type = clean_type($type); - -# my $found = "type: $type\nfunction: $function\nparams: $params\n" -# . " trapSel: $trapSel\ntrapType: $trapType\ntrapSubSel: $trapSubSel\n"; -# print STDERR "$found"; - - $params = params_parse($params); - $funcInfo{$function} = { 'type' => $type, - 'params' => $params, - 'file' => $base, - 'sel' => $trapSel, - 'trapType' => $trapType, - }; - $fileNames{$base} = 1; - return 1; - } - } - return 0; -} # searchOneFile - -sub searchOneDir($$) { - my ( $dir, $function ) = @_; - my $found = 0; - - opendir(DIR, $dir) || die "can't opendir $dir: $!"; - my @files = readdir(DIR); - closedir DIR; - - foreach my $file (@files) { - if ( $file =~ m|^\.| ) { - # skip if starts with . - } elsif ( -d "$dir/$file" ) { - $found = searchOneDir( "$dir/$file", $function ); - last if $found; - } elsif ( $file =~ m|\.h$| ) { - $found = searchOneFile( "$dir/$file", $function ); - last if $found; - } - } - return $found; -} # searchOneDir - -sub print_params_list($$) { - my ( $params, $startLen ) = @_; - my $result = "("; - - foreach my $param ( @$params ) { - my $p = " " . $$param{"type"} . " " . $$param{'name'} . ","; - if ( length($p) + $startLen >= 80 ) { - $p = "\n $p"; - $startLen = length($p); - } - $result .= $p; - $startLen += length($p); - } - - $result =~ s/,$//; - $result .= " )"; - - return $result; -} - -sub nameToBytes($) { - my ( $nam ) = @_; - # Any way to insert a '\n' in this? - my $str = "\"'" . join( "','", split( //, $nam ) ) . "'\""; - return $str; -} - -sub makeSwapStuff($$$$$) { - my ( $params, $varDecls, $swapIns, $pushes, $swapOuts ) = @_; - my $sizeSum = 0; - my $vcount = 0; - - $$varDecls .= " /* var decls */\n"; - $$pushes .= " /* pushes */\n"; - $$swapOuts .= " /* swapOuts */\n"; - $$swapIns .= " /* swapIns */\n"; - - foreach my $param ( @$params ) { - # each param has "type" and "name" fields - my $type = $param->{"type"}; - my $info = $typeInfo{$type}; - my $size = $info->{'size'}; - my $name = $param->{'name'}; - my $pushName = $name; - - # If type requires swapping, just swap in and out. If it's - # RECT (or later, other things) declare a tmp var and swap in - # and out. If it's const, only swap in. - - my $swapInfo = $info->{"autoSwap"}; - if ( defined $swapInfo ) { - - if ( $swapInfo == -1 ) { - my $typeNoStar = $type; - $typeNoStar =~ s/\*$//; - # Does anything bad happen if there's no *? - # die "no star found" if $typeNoStar eq $type; - my $isConst = $typeNoStar =~ m|^const|; - $typeNoStar =~ s/^const\s+//; - my $vName = "${typeNoStar}_68K${vcount}"; - $pushName = "&$vName"; - $$varDecls .= " $typeNoStar $vName;\n"; - $typeNoStar = uc($typeNoStar); - $$swapIns .= " SWAP_${typeNoStar}_ARM_TO_68K( &$vName, $name );\n"; - if ( ! $isConst ) { - $$swapOuts .= " SWAP_${typeNoStar}_68K_TO_ARM( $name, &$vName );\n"; - } - - } else { - if ( $swapInfo >= 1 && $swapInfo <= 4 ) { - $$swapIns .= " SWAP${swapInfo}_NON_NULL_IN($name);\n"; - $$swapOuts .= " SWAP${swapInfo}_NON_NULL_OUT($name);\n"; - } else { - die "unknown swapInfo $swapInfo\n"; - } - } - } - - $$pushes .= " ADD_TO_STACK$size(stack, $pushName, $sizeSum);\n"; - - $sizeSum += $size; - if ( $size == 1 ) { - ++$sizeSum; - } - ++$vcount; - } - return $sizeSum; -} # makeSwapStuff - - -sub print_body($$$$$) { - my ( $name, $returnType, $params, $trapSel, $trapType ) = @_; - my $result; - my $offset = 0; - my $notVoid = $returnType !~ m|void$|; - - $result .= "{\n"; - if ( $notVoid ) { - $result .= " $returnType result;\n"; - } - $result .= " FUNC_HEADER($name);\n"; - - my ( $varDecls, $swapIns, $pushes, $swapOuts ); - $offset = makeSwapStuff( $params, \$varDecls, - \$swapIns, \$pushes, \$swapOuts ); - - $result .= $varDecls . $swapIns; - - $result .= " {\n"; - $result .= " PNOState* sp = GET_CALLBACK_STATE();\n"; - - $result .= " STACK_START(unsigned char, stack, $offset);\n" - . $pushes - . " STACK_END(stack);\n"; - - my $info = $typeInfo{$returnType}; - if ( $info->{'a0'} ) { - $offset = "kPceNativeWantA0 | $offset"; - } - - if ( $trapType eq "VFSMGR_TRAP" ) { - $result .= " SET_SEL_REG($trapSel, sp);\n"; - $trapSel = "sysTrapFileSystemDispatch"; - } elsif ( $trapType eq "HIGH_DENSITY_TRAP" ) { - $result .= " SET_SEL_REG($trapSel, sp);\n"; - $trapSel = "sysTrapHighDensityDispatch"; - } elsif( $trapType eq "GRF_TRAP" || $trapType eq "SYS_TRAP" - || $trapType eq "BTLIB_TRAP" ) { - # they're the same according to Graffiti.h - } elsif ( $trapType eq "SYS_SEL_TRAP" ) { - print( STDERR "name = $name\n" ); - print( STDERR "returnType = $returnType\n" ); - print( STDERR "params = $params\n" ); - print( STDERR "trapSel = $trapSel\n" ); - print( STDERR "trapType = $trapType\n" ); - die "can't emit for SYS_SEL_TRAP yet"; - } else { - die "unknown dispatch type: \"$trapType\""; - } - - $result .= " "; - if ( $notVoid ) { - $result .= "result = ($returnType)"; - } - - $result .= "(*sp->call68KFuncP)( sp->emulStateP, \n" - . " PceNativeTrapNo($trapSel),\n" - . " stack, $offset );\n"; - - $result .= $swapOuts; - - $result .= " }\n FUNC_TAIL($name);\n"; - $result .= " EMIT_NAME(\"$name\"," . nameToBytes($name) . ");\n"; - if ( $notVoid ) { - $result .= " return result;\n"; - } - $result .= "} /* $name */\n"; - - return $result; -} - -sub print_func_impl($$$$$$) { - my ( $returnType, $name, - $params, # ref-to-list created by params_parse above - $file, $trapSel, $trapType ) = @_; - my $result; - - $result .= "\n/* from file $file */\n"; - $result .= "$returnType\n"; - my $lenToName = length( $result ); - $result .= "$name"; - $result .= print_params_list($params, length($result)-$lenToName) . "\n"; - $result .= print_body( $name, $returnType, $params, $trapSel, $trapType ); - - return $result; -} # print_func_impl - -# create a signature for each function. We'll see how many match up. -sub funcId($$) { - my ( $retType, $parms ) = @_; - my $id = "${retType}_"; - - foreach my $param ( @$parms ) { - $id .= $$param{"type"}; - } - - return $id; -} # funcId - -sub genStub($$$) { - my( $func, $r9off, $off ) = @_; - my $result; - - if ( $func && $r9off && $off ) { - $result .= "\t\t.type $func, %function\n"; - $result .= "\t\t.globl $func\n"; - $result .= "$func:\n"; - $result .= "\tldr ip, [r9, #$r9off]\n"; - my $intoff = 4 * hex($off); - $result .= "\tldr pc, [ip, #$intoff]\n"; - } - return $result; -} - -########################################################################### -# Main -########################################################################### - -my @paths; -my @funcs; -while ( my $arg = shift(@ARGV) ) { - if ( $arg eq "-oh" ) { - $dot_h = shift(@ARGV); - } elsif ( $arg eq "-oc" ) { - $dot_c = shift(@ARGV); - } elsif ( $arg eq "-os" ) { - $dot_s = shift(@ARGV); - } elsif ( $arg eq "-file" ) { - push( @paths, shift(@ARGV)); - } elsif ( $arg eq "-func" ) { - push( @funcs, shift(@ARGV)); - } elsif ( $arg =~ m|^-D(\w+)$| ) { - push( @minusDs, $1 ); - } else { - usage(); - } -} - -map { push( @pathList, makeFileList($_) ); } @paths; -map { push( @funcList, makeFuncList($_) ); } @funcs; - -my $dot_s_out = "\t.text\n"; -foreach my $fref (@funcList) { - if ( $dot_s ) { - $dot_s_out .= genStub( $$fref[0], $$fref[1], $$fref[2] ); - } - if ( $dot_c ) { - my $func = $$fref[0]; - my $found = 0; - my $path; - foreach my $path (@pathList) { - if ( -d $path ) { - $found = searchOneDir( $path, $func ); - last if $found; - } elsif ( -e $path ) { - $found = searchOneFile( $path, $func ); - last if $found; - } - } - die "unable to find declaration of $func\n" if ! $found; - } -# close PATHS; -} - -my $outRef; - -if ( $dot_s ) { - if ( $dot_s eq "-" ) { - $outRef = *STDOUT{IO}; - } else { - open DOT, "> $dot_s"; - $outRef = *DOT{IO}; - } - print $outRef $dot_s_out; - if ( $dot_c ne "-" ) { - close DOT; - } -} - -if ( $dot_c ) { - if ( $dot_c eq "-" ) { - $outRef = *STDOUT{IO}; - } else { - open DOT, "> $dot_c"; - $outRef = *DOT{IO}; - } - print $outRef "/********** this file is autogenerated by $0 " - . "***************/\n\n"; - - print $outRef "\n"; - - print $outRef < $dot_h"; - print DOT "/********** this file is autogenerated by $0 " - . "***************/\n\n"; - - my $def = "_" . uc($dot_h) . "_"; - $def =~ s/\./_/; - - print DOT "#ifndef $def\n"; - print DOT "#define $def\n"; - - map { print DOT "#include <$_>\n"; } keys(%fileNames); - - foreach my $key (keys %funcInfo) { - my $ref = $funcInfo{$key}; - print DOT $${ref}{"type"}, " " - . $key . print_params_list($$ref{'params'}, 0) . ";\n"; - } - - print DOT "\n#include \"pace_man.h\"\n"; - print DOT "#endif /* $def */\n"; - close DOT; -} - - -exit 0; diff --git a/xwords4/palm/l10n/StrRes_en_US.pre b/xwords4/palm/l10n/StrRes_en_US.pre deleted file mode 100644 index 2d4a7536a..000000000 --- a/xwords4/palm/l10n/StrRes_en_US.pre +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- mode: c; compile-command: "cd .. && make ARCH=68K_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 1997 - 2009 by Eric House (xwords@eehouse.org) and others. All - * rights reserved. - * - * 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. - */ - -/* This table is where English user-visible strings come from (all - * strings meant to wind up in a str# resource, actually. Each entry - * is a pair of strings, first the constant name and then the string - * itself. The build system creats a str# resource with the latter - * and generates a .h file of #defines using the former. */ - -{ "STR_COMMIT_CONFIRM", "Commit the current move?\n" }, -{ "STR_NOT_YOUR_TURN", "You can't do that; it's not your turn!" }, -{ "STR_NO_PEEK_ROBOT_TILES", "No peeking at the robot's tiles!" }, -#ifndef XWFEATURE_STANDALONE_ONLY -{ "STR_NO_PEEK_REMOTE_TILES", "No peeking at remote player's tiles!" }, -{ "STR_SERVER_DICT_WINS", - "Conflict between Host and Guest dictionaries; Host wins." }, -{ "STR_REG_UNEXPECTED_USER", "Attempt to register unexpected user refused" }, -{ "STR_REG_NEED_REMOTE", "Please make one or more players Remote when " - "playing as Host." }, -{ "STR_REG_BT_NEED_HOST", "Please locate the device where Crosswords is " - "running as Host." }, -{ "STR_RESEND_STANDALONE", "This is a standalone game. There is nothing " - "to resend." }, -#endif -{ "STR_TOO_FEW_TILES", "Too few tiles left to trade." }, -{ "STR_CANT_UNDO_TILEASSIGN", "Nothing to undo. (Initial tile picking " - "cannot be undone.)" }, -{ "STR_CANT_HINT_WHILE_DISABLED", "The hint feature is disabled for this " - "game. Enable it for a new game using the " - "Preferences dialog." }, - -{ "STR_VALUES_TITLE", "Counts and Values" }, -{ "STR_REMAINS_TITLE","Remaining tiles" }, -{ "STRS_VALUES_HEADER", "%s counts/values:\n" }, - -{ "STR_DOUBLE_LETTER", "Double letter" }, -{ "STR_DOUBLE_WORD", "Double word" }, -{ "STR_TRIPLE_LETTER", "Triple letter" }, -{ "STR_TRIPLE_WORD", "Triple word" }, -{ "STR_REMTILES", "rem:%d" }, -{ "STR_CANT_TRADE_MIDTURN", "Remove played tiles before trading."}, -{ "STR_ASK_REPLACE_GAME", "Do you want to overwrite the current game?" }, -{ "STR_OK", "Ok" }, -{ "STR_ABOUT_TITLE", "About Crosswords" }, -{ "STR_DEFAULT_NAME", "Player %d" }, -{ "STR_CONFIRM_END_GAME", "Are you sure you want to end the game now?"}, -{ "STR_CONFIRM_TRADE", "Are you sure you want to use your " \ - "turn trading tiles?" }, -{ "STR_TRADING_REMINDER", "Click D when done." }, - -{ "STR_LOCAL_NAME", "%s" }, -{ "STR_NONLOCAL_NAME", "%s (remote)" }, -{ "STRSD_SUMMARYSCORED", "%s:%d" }, -{ "STRD_TRADED", "Traded %d" }, -{ "STR_PASSED", "Passed" }, -{ "STR_LOSTTURN", "Lost turn" }, - -{ "STR_HISTORY_TITLE", "Game history" }, -{ "STRD_REMAINING_TILES_ADD", "+ %d [all remaining tiles]" }, -{ "STRD_UNUSED_TILES_SUB", "- %d [unused tiles]" }, -{ "STR_BONUS_ALL", "Bonus for using all tiles: 50\n" }, -{ "STRD_TURN_SCORE", "Score for turn: %d\n" }, -{ "STR_ALL_IN_LINE_ERR", "All tiles played must be in a line." }, -{ "STR_NO_EMPTIES_ERR", "Empty squares cannot separate pieces played." }, -{ "STR_FIRST_MOVE_ERR", "Must play two or more pieces on " \ - "the first move." }, - /* phony comment to get diff back in sync */ -{ "STR_MUST_CONTACT_ERR", "New tiles must contact others already " \ - "in place (or the middle square on the " \ - "first move)." }, -{ "STR_PTS", "Pts:" }, -{ "STR_CONFIRM_DEL_GAME", "Really delete the selected game?" }, - -{ "STRD_TIME_PENALTY_SUB", " - %d [time]" }, - -{ "STR_NO_DICT_INSTALLED", "Crosswords 4 requires at least one dictionary." \ - "Download one or more from xwords.sf.net." }, -{ "STR_ILLEGAL_WORD", "Word[s] %s not found in dictionary. Allow anyway?" }, - -{ "STR_FINAL_SCORES_TITLE", "Final scores"}, - - /* another phony comment to get diff back in sync */ - -{ "STRD_CUMULATIVE_SCORE", "Cumulative score: %d\n" }, -{ "STRS_TRAY_AT_START", "Tray at start: %s\n" }, -{ "STRS_MOVE_ACROSS", "move (from %s across)\n" }, -{ "STRS_MOVE_DOWN", "move (from %s down)\n" }, -{ "STRS_NEW_TILES", "New tiles: %s\n" }, -{ "STRSS_TRADED_FOR", "Traded %s for %s." }, -{ "STR_PASS", "pass\n" }, -{ "STR_PHONY_REJECTED", "Turn lost: illegal word in move." }, - -{ "STR_ROBOT_MOVED", "The robot made this move:\n" }, -{ "STR_REMOTE_MOVED", "Remote player made this move:\n" }, -{ "STRD_ROBOT_TRADED", "%d tiles traded this turn." }, -{ "STR_ROBOT_TITLE", "Remote/robot score" }, - - /* The end of 4.0.5's strings */ - -{ "STR_PICK_BLANK", "Select the letter for your blank." }, -#ifdef FEATURE_TRAY_EDIT -{ "STRS_PICK_TILE", "Choose a new tile for %s." }, -{ "STR_PICK_TILE_CUR", "Cur" }, - -#endif - -#ifdef NODE_CAN_4 -{ "STR_CONFIRM_CONVERTDICT", "Do you want to convert any existing Crosswords " \ - "dictionaries to the new format? " \ - "The change is not reversible." }, -{ "STRS_CONFIRM_ONEDICT", "Convert dictionary %s?" }, -#endif -{ "STRS_CANNOT_FIND_DICT", "%s dictionary not found." }, -{ "STR_DICT_COPY_EXPL", "Copying dictionary from card..." }, - -{ "STR_LOCALPLAYERS", "Local players" }, -{ "STR_TOTALPLAYERS", "Total players" }, - -#ifdef XWFEATURE_RELAY -{ "STR_RELAY_XPORTNAME", "Internet" }, -{ "STR_RELAY_TIMEOUT", "Relay error: Other devices failed to " - "connect." }, -{ "STR_RELAY_LOST_OTHER", "Relay error: another device has lost its " - "connection." }, -{ "STR_RELAY_GENERIC", "Relay error: something's wrong." }, -#endif - -#ifdef XWFEATURE_IR -{ "STR_IR_XPORTNAME", "Beaming" }, -#endif - -#ifdef XWFEATURE_BLUETOOTH -{ "STR_BT_XPORTNAME", "Bluetooth" }, -{ "STR_BT_NOINIT", "Bluetooth appears to be off. Please turn it " - "on if you want Crosswords to use it." }, -{ "STRS_BT_CONFIRM", "Is Crosswords running on %s and " - "ready to accept a connection? (If you " - "choose \"No\" Crosswords will not try to " - "connect until you restart it " - "or choose the \"Resend\" menu item.)" }, - -#endif - -{ "STR_ABOUT_CONTENT", -/* #ifdef XWFEATURE_BLUETOOTH */ -/* "THANKS FOR DOWNLOADING this beta version of " */ -/* "Crosswords. Please see the notes and caveats at " */ -/* "xwords.sf.net/bt_palm.php. Please report bugs to " */ -/* "xwords@eehouse.org. Enjoy!\n\n" */ -/* #endif */ - "Crosswords " XW_PALM_VERSION_STRING " (rev. " SVN_REV ").\n" \ - "Copyright 1998-2009 by Eric House. "\ - "Released under the GNU Public License.\n\n"\ - - "See the manual at xwords.sf.net or " - "eehouse.org/xwords/.\n\n" \ - - "This program is postcardware. If you like it " \ - "please mail a postcard to:\n" \ - "The Houses\n" \ - "1610 NW 14th Place\n" \ - "Corvallis, OR 97330 USA\n\n" - - "Thanks to Debian GNU/Linux for the development "\ - "tools and to KT for the time." \ - }, diff --git a/xwords4/palm/l10n/StrRes_es_CT.pre b/xwords4/palm/l10n/StrRes_es_CT.pre deleted file mode 100644 index b9978a113..000000000 --- a/xwords4/palm/l10n/StrRes_es_CT.pre +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- mode: c; -*- */ -/* - * Copyright 1997 - 2002 by Eric House (xwords@eehouse.org) and others. All rights reserved. - * - * 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. - */ - -/* This table is where English user-visible strings come from (all - * strings meant to wind up in a str# resource, actually. Each entry - * is a pair of strings, first the constant name and then the string - * itself. The build system creats a str# resource with the latter - * and generates a .h file of #defines using the former. */ - -{ "STR_COMMIT_CONFIRM", "Acceptes la jugada?\n\n" }, -{ "STR_NOT_YOUR_TURN", "No ho pots fer; no és el teu torn!" }, -{ "STR_NO_PEEK_ROBOT_TILES", "No miris les fitxes de la màquina!" }, -#ifndef XWFEATURE_STANDALONE_ONLY -{ "STR_NO_PEEK_REMOTE_TILES", "No miris les fitxes dels altres!" }, -{ "STR_SERVER_DICT_WINS", - "Conflicte de diccionaris: mana el del servidor." }, -{ "STR_REG_UNEXPECTED_USER", "Jugador inesperat: no s'accepta" }, -{ "STR_RESEND_IR", "Error enviant el missatge; ¿reenviar?" }, -#endif -{ "STR_TOO_FEW_TILES", "No hi ha prou fitxes." }, -{ "STR_CANT_UNDO_TILEASSIGN", "El repartiment de fitxes no pot desfer-se." }, - -{ "STR_VALUES_TITLE", "Counts and Values" }, /* translate */ -{ "STR_REMAINS_TITLE","Remaining tiles" }, /* translate */ -{ "STRS_VALUES_HEADER", "%s counts/values:\n" }, /* translate */ - -{ "STR_DOUBLE_LETTER", "Doble de lletra" }, -{ "STR_DOUBLE_WORD", "Doble de paraula" }, -{ "STR_TRIPLE_LETTER", "Triple de lletra" }, -{ "STR_TRIPLE_WORD", "Triple de paraula" }, -{ "STR_REMTILES", "Hi ha:%d" }, -{ "STR_CANT_TRADE_MIDTURN", "Encara tens fitxes al tauler."}, -{ "STR_ASK_REPLACE_GAME", "Vols sobreescriure la partida?" }, -{ "STR_OK", "Ok" }, /* translate */ -{ "STR_ABOUT_TITLE", "Sobre Crosswords" }, -{ "STR_DEFAULT_NAME", "Jugador %d" }, -{ "STR_ABOUT_CONTENT", - "Crosswords " XW_PALM_VERSION_STRING " (rev. " SVN_REV ").\n" \ - "Copyright 1998-2004 by Eric House. "\ - "Tots els drets reservats.\n\n"\ - - "El manual és a xwords.sourceforge.net\n\n" \ - - "Aquest programa és postalware.\nSi el fas servir, " \ - "envia una postal a:\n" \ - "The Houses\n" \ - "1610 NW 14th Place\n" \ - "Corvallis, OR 97330 USA\n\n" - - "Escrit sobre Debian GNU/Linux usant les prc-tools.\n\n" \ - - "Versió catalana de F. Xavier Gil\n(setimig@wanadooadsl.net)." \ - }, - -{ "STR_CONFIRM_END_GAME", "Segur que vols acabar la partida?"}, -{ "STR_CONFIRM_TRADE", "Segur que vols usar el teu torn " \ - "per canviar fitxes?" }, -{ "STR_TRADING_REMINDER", "Prem D per acabar." }, - -#ifndef NO_REG_REQUIRED -{ "STR_NOT_UNREG_VERS", "Només funciona a la versió registrada." }, -#endif - -{ "STR_LOCAL_NAME", "%s" }, -{ "STR_NONLOCAL_NAME", "%s (remot)" }, -{ "STRSD_SUMMARYSCORED", "%s: %d" }, -{ "STRD_TRADED", "Canviades: %d" }, -{ "STR_PASSED", "Ha passat" }, -{ "STR_LOSTTURN", "Torn perdut" }, - - -{ "STR_HISTORY_TITLE", "Jugades" }, -{ "STRD_REMAINING_TILES_ADD", "+ %d [fitxes sobreres]" }, -{ "STRD_UNUSED_TILES_SUB", "- %d [fitxes no usades]" }, -{ "STR_BONUS_ALL", "Per usar les set fitxes: 50\n" }, -{ "STRD_TURN_SCORE", "Parcial de la jugada: %d\n" }, -{ "STR_ALL_IN_LINE_ERR", "Les fitxes no estan en línia." }, -{ "STR_NO_EMPTIES_ERR", "Les fitxes s'han de tocar." }, -{ "STR_FIRST_MOVE_ERR", "Has de posar dues o mes fitxes a " \ - "la primera jugada." }, - /* phony comment to get diff back in sync */ -{ "STR_MUST_CONTACT_ERR", "Les fitxes n'han de tocar d'altres (o " \ - "el quadre central a la primera jugada)." }, -{ "STR_PTS", "Punts:" }, -{ "STR_CONFIRM_DEL_GAME", "Segur que la vols esborrar?" }, - -{ "STRD_TIME_PENALTY_SUB", " - %d [per temps]" }, - -{ "STR_NO_DICT_INSTALLED", "Crosswords necessita algun diccionari." }, -{ "STR_ILLEGAL_WORD", "Ep!, %s no està al diccionari." }, - -{ "STR_FINAL_SCORES_TITLE", "Puntuació final"}, - - /* another phony comment to get diff back in sync */ - -{ "STRD_CUMULATIVE_SCORE", "Acumulat: %d\n" }, -{ "STRS_TRAY_AT_START", "Faristol inicial: %s\n" }, -{ "STRS_MOVE_ACROSS", "jugada (%s, horitzontal)\n" }, -{ "STRS_MOVE_DOWN", "jugada (%s, vertical)\n" }, -{ "STRS_NEW_TILES", "Noves fitxes: %s\n" }, -{ "STRSS_TRADED_FOR", "Canvi de %s per %s." }, -{ "STR_PASS", "passa\n" }, -{ "STR_PHONY_REJECTED", "Mot incorrecte; torn perdut!\n" }, - -{ "STR_ROBOT_MOVED", "El robot ha jugat:\n" }, -{ "STR_REMOTE_MOVED", "Un jugador remot ha jugat:\n" }, -{ "STRD_ROBOT_TRADED", "s'han canviat %d fitxes." }, -{ "STR_ROBOT_TITLE", "Punts del robot" }, - - /* The end of 4.0.5's strings */ - -{ "STR_PICK_BLANK", "Tria la fitxa per l'escarràs." }, -#ifdef FEATURE_TRAY_EDIT -{ "STRS_PICK_TILE", "Tria una nova fitxa per %s." }, -#endif - -#ifdef NODE_CAN_4 -{ "STR_CONFIRM_CONVERTDICT", "Vols convertir els diccionaris de Crosswords " \ - "al nou format? " \ - "El canvi no és reversible." }, -{ "STRS_CONFIRM_ONEDICT", "Convertir el diccionari %s?" }, -#endif -{ "STRS_CANNOT_FIND_DICT", "%s dictionary not found." }, /* translate */ -{ "STR_DICT_COPY_EXPL", "Copying dictionary from card..." },/* translate */ diff --git a/xwords4/palm/l10n/StrRes_es_ES.pre b/xwords4/palm/l10n/StrRes_es_ES.pre deleted file mode 100644 index 7bd49ed65..000000000 --- a/xwords4/palm/l10n/StrRes_es_ES.pre +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- mode: c; -*- */ -/* - * Copyright 1997 - 2002 by Eric House (xwords@eehouse.org) and others. All rights reserved. - * - * 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. - */ - -/* This table is where English user-visible strings come from (all - * strings meant to wind up in a str# resource, actually. Each entry - * is a pair of strings, first the constant name and then the string - * itself. The build system creats a str# resource with the latter - * and generates a .h file of #defines using the former. */ - -{ "STR_COMMIT_CONFIRM", "¿Aceptas la jugada?\n\n" }, -{ "STR_NOT_YOUR_TURN", "¡No puedes hacer eso; no es tu turno!" }, -{ "STR_NO_PEEK_ROBOT_TILES", "¡No mires las fichas de la máquina!" }, -#ifndef XWFEATURE_STANDALONE_ONLY -{ "STR_NO_PEEK_REMOTE_TILES", "¡No mires las fichas de los demás!" }, -{ "STR_SERVER_DICT_WINS", "Conflicto entre diccionarios: manda el del servidor." }, -{ "STR_REG_UNEXPECTED_USER", "Jugador inesperado: no se acepta" }, -{ "STR_RESEND_IR", "Error enviando el mensaje; ¿reenviar" }, -#endif -{ "STR_TOO_FEW_TILES", "Ho quedan tantas fichas." }, -{ "STR_CANT_UNDO_TILEASSIGN", "El reparto de fichas no puede deshacerse." }, - -{ "STR_VALUES_TITLE", "Counts and Values" }, /* translate */ -{ "STR_REMAINS_TITLE","Remaining tiles" }, /* translate */ -{ "STRS_VALUES_HEADER", "%s counts/values:\n" }, /* translate */ - -{ "STR_DOUBLE_LETTER", "Doble de letra" }, -{ "STR_DOUBLE_WORD", "Doble de palabra" }, -{ "STR_TRIPLE_LETTER", "Triple de letra" }, -{ "STR_TRIPLE_WORD", "Triple de palabra" }, -{ "STR_REMTILES", "Hay:%d" }, -{ "STR_CANT_TRADE_MIDTURN", "Aún tienes fichas en el tablero."}, -{ "STR_ASK_REPLACE_GAME", "¿Quieres sobreescribir la partida?" }, -{ "STR_OK", "Ok" }, /* translate */ -{ "STR_ABOUT_TITLE", "Acerca de Crosswords" }, -{ "STR_DEFAULT_NAME", "Jugador %d" }, -{ "STR_ABOUT_CONTENT", - "Crosswords " XW_PALM_VERSION_STRING " (rev. " SVN_REV ").\n" \ - "Copyright 1998-2004 by Eric House. "\ - "Todos los derechos reservados.\n\n"\ - - "El manual está en xwords.sourceforge.net\n\n" \ - - "Este programa es postalware.\nSi lo usas " \ - "manda una postal a:\n" \ - "The Houses\n" \ - "1610 NW 14th Place\n" \ - "Corvallis, OR 97330 USA\n\n" - - "Escrito sobre Debian GNU/Linux usando las prc-tools.\n\n"\ - - "Versión española por F. Xavier Gil\n(setimig@wanadooadsl.net)." \ - }, - -{ "STR_CONFIRM_END_GAME", "¿Seguro que quieres terminar la partida?"}, -{ "STR_CONFIRM_TRADE", "¿Seguro que quieres usar tu turno " \ - "para cambiar fichas?" }, -{ "STR_TRADING_REMINDER", "Pulsa D para terminar." }, - -#ifndef NO_REG_REQUIRED -{ "STR_NOT_UNREG_VERS", "Sólo funciona en la versión registrada." }, -#endif - -{ "STR_LOCAL_NAME", "%s" }, -{ "STR_NONLOCAL_NAME", "%s (remoto)" }, -{ "STRSD_SUMMARYSCORED", "%s: %d" }, -{ "STRD_TRADED", "Cambiadas: %d" }, -{ "STR_PASSED", "Ha pasado" }, -{ "STR_LOSTTURN", "Turno perdido" }, - -{ "STR_HISTORY_TITLE", "Jugadas" }, -{ "STRD_REMAINING_TILES_ADD", "+ %d [fichas sobrantes]" }, -{ "STRD_UNUSED_TILES_SUB", "- %d [fichas no usadas]" }, -{ "STR_BONUS_ALL", "Por usar las siete fichas: 50\n" }, -{ "STRD_TURN_SCORE", "Parcial de la jugada: %d\n" }, -{ "STR_ALL_IN_LINE_ERR", "Las fichas no están en línea." }, -{ "STR_NO_EMPTIES_ERR", "Las fichas deben tocarse." }, -{ "STR_FIRST_MOVE_ERR", "Debes usar dos o más fichas en " \ - "la primera jugada." }, - /* phony comment to get diff back in sync */ -{ "STR_MUST_CONTACT_ERR", "Las fichas deben tocar otras (o el " \ - "cuadrado central en la primera jugada)." }, -{ "STR_PTS", "Puntos:" }, -{ "STR_CONFIRM_DEL_GAME", "¿Seguro que quieres borrarla?" }, - -{ "STRD_TIME_PENALTY_SUB", " - %d [por tiempo]" }, - -{ "STR_NO_DICT_INSTALLED", "Crosswords necesita algún diccionario." }, -{ "STR_ILLEGAL_WORD", "¡Ei!, %s no está en el diccionario." }, - -{ "STR_FINAL_SCORES_TITLE", "Puntuación final"}, - - /* another phony comment to get diff back in sync */ - -{ "STRD_CUMULATIVE_SCORE", "Acumulado: %d\n" }, -{ "STRS_TRAY_AT_START", "Atril inicial: %s\n" }, -{ "STRS_MOVE_ACROSS", "jugada (%s, horizontal)\n" }, -{ "STRS_MOVE_DOWN", "jugada (%s, vertical)\n" }, -{ "STRS_NEW_TILES", "Nuevas fichas: %s\n" }, -{ "STRSS_TRADED_FOR", "Cambio de %s por %s." }, -{ "STR_PASS", "pasa\n" }, -{ "STR_PHONY_REJECTED", "Palabra incorrecta; ¡turno perdido!\n" }, - -{ "STR_ROBOT_MOVED", "El robot ha jugado:\n" }, -{ "STR_REMOTE_MOVED", "Un jugador remoto ha jugado:\n" }, -{ "STRD_ROBOT_TRADED", "%d fichas canviadas." }, -{ "STR_ROBOT_TITLE", "Puntos del robot" }, - - /* The end of 4.0.5's strings */ - -{ "STR_PICK_BLANK", "Escoge una ficha para el comodín." }, -#ifdef FEATURE_TRAY_EDIT -{ "STRS_PICK_TILE", "Escoge una nueva ficha para %s." }, -#endif - -#ifdef NODE_CAN_4 -{ "STR_CONFIRM_CONVERTDICT", "¿Quieres convertir los diccionarios de Crosswords " \ - "al nuevo formato? " \ - "El cambio no es reversible." }, -{ "STRS_CONFIRM_ONEDICT", "¿Convertir el diccionario %s?" }, -#endif -{ "STRS_CANNOT_FIND_DICT", "%s dictionary not found." }, /* translate */ -{ "STR_DICT_COPY_EXPL", "Copying dictionary from card..." },/* translate */ diff --git a/xwords4/palm/l10n/StrRes_fr_FR.pre b/xwords4/palm/l10n/StrRes_fr_FR.pre deleted file mode 100644 index 48b6ae46f..000000000 --- a/xwords4/palm/l10n/StrRes_fr_FR.pre +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- mode: c; compile-command: "cd .. && make ARCH=68K_ONLY MEMDEBUG=TRUE LANG=fr_FR"; -*- */ -/* - * Copyright 1997 - 2008 by Eric House (xwords@eehouse.org) and - * others. All rights reserved. Traduction en français par Francis H. - * - * Ce programm est libre de droits ; Vous pouvez le distribuer et/ou - * le modifier en respectant les termes de la licence GNU General - * Public ainsi qu'elle est publiée par la Free Software Foundation; - * que ce soit la version 2 de la Licence, ou (selon votre option), - * toute version ultérieure. - * - * Ce programme est distribué avec l'intention qu'il soit utilisé, - * mais SANS AUCUNE GARANTIE; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Voir la - * Licence GNU General Public pour plus de détails. - * - * Vous devriez avoir reçu une copie de la Licence GNU General Public - * avec ce programme ; si ce n'est pas le cas, écrivez à "Free - * Software Foundation", Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -/* This table is where French user-visible strings come from (all - * strings meant to wind up in a str# resource, actually.) Each entry - * is a pair of strings, first the constant name and then the string - * itself. The build system creats a str# resource with the latter - * and generates a .h file of #defines using the former. */ - -{ "STR_COMMIT_CONFIRM", "Confirmez-vous le coup actuel ?\n" }, -{ "STR_NOT_YOUR_TURN", "Impossible ; ce n'est pas votre tour !" }, -{ "STR_NO_PEEK_ROBOT_TILES", "Ne cherchez pas à voir les lettres du robot !" }, -#ifndef XWFEATURE_STANDALONE_ONLY -{ "STR_NO_PEEK_REMOTE_TILES", "Ne cherchez pas à voir les lettres des autres !" }, -{ "STR_SERVER_DICT_WINS", - "Conflit entre les dictionnaires Hôte et Invité ; l'hôte gagne." }, -{ "STR_REG_UNEXPECTED_USER", "Essai refusé de l'enregistrement de l'utilisateur" }, -{ "STR_REG_NEED_REMOTE", "Svp contactez un ou plusieurs joueurs qd vous " - "jouez comme Hôte." }, -{ "STR_REG_BT_NEED_HOST", "Svp, localisez l'organiseur qd Crossxords joue " - "comme Hôte." }, -{ "STR_RESEND_STANDALONE", "C'est une partie en solo. Il n'y a rien " - "à renvoyer." }, -#endif -{ "STR_TOO_FEW_TILES", "Pas assez de lettres pour échanger." }, -{ "STR_CANT_UNDO_TILEASSIGN", "Impossible d'annuler. (Le tirage initial ne peut être annulé.)" }, -/* translate me */ -{ "STR_CANT_HINT_WHILE_DISABLED", "The hint feature is disabled for this " - "game. Enable it for a new game using the " - "Preferences dialog." }, - -{ "STR_VALUES_TITLE", "Nombres et Valeurs" }, -{ "STR_REMAINS_TITLE","Lettres restantes" }, -{ "STRS_VALUES_HEADER", "%s nombres/valeurs :\n" }, - -{ "STR_DOUBLE_LETTER", "Double lettre" }, -{ "STR_DOUBLE_WORD", "Double mot" }, -{ "STR_TRIPLE_LETTER", "Triple lettre" }, -{ "STR_TRIPLE_WORD", "Triple mot" }, -{ "STR_REMTILES", "rst:%d" }, -{ "STR_CANT_TRADE_MIDTURN", "Enlevez les lettres jouées avant d'échanger."}, -{ "STR_ASK_REPLACE_GAME", "Voulez-vous remplacer la partie en cours ?" }, -{ "STR_OK", "Ok" }, -{ "STR_ABOUT_TITLE", "Au sujet de Crosswords" }, -{ "STR_DEFAULT_NAME", "Joueur %d" }, -{ "STR_CONFIRM_END_GAME", "Etes-vous sûr de vouloir arrêter la partie maintenant ?"}, -{ "STR_CONFIRM_TRADE", "Etes-vous sûr de de vouloir échanger " \ - "vos lettres ?" }, -{ "STR_TRADING_REMINDER", "Cliquez D une fois fini." }, - -{ "STR_LOCAL_NAME", "%s" }, -{ "STR_NONLOCAL_NAME", "%s (autre)" }, -{ "STRSD_SUMMARYSCORED", "%s:%d" }, -{ "STRD_TRADED", "Echangé %d" }, -{ "STR_PASSED", "Passé" }, -{ "STR_LOSTTURN", "Tour perdu" }, - -{ "STR_HISTORY_TITLE", "Historique de la partie" }, -{ "STRD_REMAINING_TILES_ADD", "+ %d [toutes lettres restantes]" }, -{ "STRD_UNUSED_TILES_SUB", "- %d [lettres inutilisées]" }, -{ "STR_BONUS_ALL", "Bonus pour placement toutes les lettres : 50\n" }, -{ "STRD_TURN_SCORE", "Score après ce tour : %d\n" }, -{ "STR_ALL_IN_LINE_ERR", "Toutes les lettres doivent être placées sur une même ligne." }, -{ "STR_NO_EMPTIES_ERR", "Des cases vides ne peuvent séparer les lettres jouées." }, -{ "STR_FIRST_MOVE_ERR", "Vous devez placer au moins deux lettres " \ - "lors du 1er coup." }, - /* phony comment to get diff back in sync */ -{ "STR_MUST_CONTACT_ERR", "Les nouvelles lettres doivent être au contact de celles " \ - "déjà en place (ou sur la case centrale lors du " \ - "premier coup)." }, -{ "STR_PTS", "Pts :" }, -{ "STR_CONFIRM_DEL_GAME", "Supprimer vraiment la partie sélectionnée ?" }, - -{ "STRD_TIME_PENALTY_SUB", " - %d [temps]" }, - -{ "STR_NO_DICT_INSTALLED", "Crosswords 4 nécessite au minimum un dictionnaire." \ - "Téléchargez-en un ou plus sur xwords.sf.net." }, -{ "STR_ILLEGAL_WORD", "Mot[s] %s non trouvé(s) dans le dictionnaire. L'utiliser quand même ?" }, - -{ "STR_FINAL_SCORES_TITLE", "Score final"}, - - /* another phony comment to get diff back in sync */ - -{ "STRD_CUMULATIVE_SCORE", "Score cumulé : %d\n" }, -{ "STRS_TRAY_AT_START", "tableau au départ : %s\n" }, -{ "STRS_MOVE_ACROSS", "coup (depuis %s horizontal)\n" }, -{ "STRS_MOVE_DOWN", "coup (depuis %s vertical)\n" }, -{ "STRS_NEW_TILES", "Nouvelles lettres : %s\n" }, -{ "STRSS_TRADED_FOR", "Echange %s pour %s." }, -{ "STR_PASS", "passé\n" }, -{ "STR_PHONY_REJECTED", "Mot incorrect ; tour perdu !\n" }, - -{ "STR_ROBOT_MOVED", "Le robot a joué ce coup :\n" }, -{ "STR_REMOTE_MOVED", "Le joueur Remote player a joué ce coup :\n" }, -{ "STRD_ROBOT_TRADED", "%d lettres changées ce coup." }, -{ "STR_ROBOT_TITLE", "Score du robot" }, - - /* The end of 4.0.5's strings */ - -{ "STR_PICK_BLANK", "Choisir la lettre en échange de la case blanche." }, -#ifdef FEATURE_TRAY_EDIT -{ "STRS_PICK_TILE", "Choisir une nouvelle lettre pour %s." }, -{ "STR_PICK_TILE_CUR", "En cours" }, -#endif - -#ifdef NODE_CAN_4 -{ "STR_CONFIRM_CONVERTDICT", "Voulez-vous convertir les dictionnaires Crosswords " \ - "existants au nouveau format? " \ - "Le changement est irréversible." }, -{ "STRS_CONFIRM_ONEDICT", "Convertir dictionnaire %s?" }, -#endif -{ "STRS_CANNOT_FIND_DICT", "%s dictionnaire non trouvé." }, -{ "STR_DICT_COPY_EXPL", "Copier dictionnaire depuis la carte..." }, - -{ "STR_LOCALPLAYERS", "Joueurs loc." }, -{ "STR_TOTALPLAYERS", "Total joueurs" }, - -#ifdef XWFEATURE_RELAY -{ "STR_RELAY_XPORTNAME", "Internet" }, -{ "STR_RELAY_TIMEOUT", "Erreur réseau : les autres joueurs n'ont pu " - "se connecter." }, -{ "STR_RELAY_LOST_OTHER", "Erreur réseau : la connexion d'un autre joueur " - "s'est arrêtée." }, -{ "STR_RELAY_GENERIC", "Erreur réseau : quelque chose ne fonctionne pas." }, -#endif - -#ifdef XWFEATURE_BLUETOOTH -{ "STR_BT_XPORTNAME", "Bluetooth" }, -{ "STR_BT_NOINIT", "Impossible initialiser Bluetooth. " - "Est-il connecté ?" }, -{ "STRS_BT_CONFIRM", "Crosswords est-il en marche sur %s " - "et est-il prêt à recevoir une connexion ? " - "(Si vous choisissez \"Non\", Crosswords " - "n'essayera pas de se connecter jusqu'à ce " - "que vous le redémarriez ou choisissiez " - "\"Renvoyer\" dans le menu.)" }, -#endif - -#ifdef XWFEATURE_IR -{ "STR_IR_XPORTNAME", "Transmission" }, -#endif - -{ "STR_ABOUT_CONTENT", -/* #ifdef XWFEATURE_BLUETOOTH */ -/* "MERCI DE VOTRE ATTENTION pour cette version beta de " */ -/* "Crosswords. Svp, regardez les notes et avertissements sur " */ -/* "xwords.sf.net/bt_palm.php. Svp, signalez les bugs à " */ -/* "xwords@eehouse.org. Au plaisir !\n\n" */ -/* #endif */ - "Crosswords " XW_PALM_VERSION_STRING " (rev. " SVN_REV ").\n" \ - "Copyright 1998-2008 par Eric House. "\ - "Réalisé sous GNU Public License.\n\n"\ - - "Voir le manuel sur xwords.sf.net ou eehouse.org/xwords/.\n\n" \ - - "Ce programme est 'postcardware'. Si vous l'appréciez, " \ - "svp, envoyez une carte postale à :\n" \ - "The Houses\n" \ - "1610 NW 14th Place\n" \ - "Corvallis, OR 97330 USA\n\n" - - "Developpé sur Debian GNU/Linux avec the prc-tools "\ - "suite.\n\n"\ - - "Traduction par Francis H." - }, diff --git a/xwords4/palm/l10n/mkstrsres.c b/xwords4/palm/l10n/mkstrsres.c deleted file mode 100644 index 7344755e0..000000000 --- a/xwords4/palm/l10n/mkstrsres.c +++ /dev/null @@ -1,78 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/**************************************************************************** - * * - * Copyright 1998-2000 by Eric House (xwords@eehouse.org). All rights reserved. * - * * - * 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. - ****************************************************************************/ - -/* - * Turn a table of string pairs into a resource file of back-to-back strings - * and an includable .h file of constants giving indices into the res file. - * - * Expects the name of the former in argv[1] and of the latter in argv[2]. - */ - -#include -#include - -#include "xwords4defines.h" - -#define FIRST_STR_INDEX 2000 - -typedef struct StringPair { - char* constName; - char* theString; -} StringPair; - -static StringPair table[] = { - // I'm expecting this as a -D option -#include LANGSTRFILE - { (char*)0L, (char*)0L } -}; - - -int -main( int argc, char** argv ) -{ - FILE* stringResFile = fopen( argv[1], "wb" ); - FILE* stringConstFile = fopen( argv[2], "w" ); - StringPair* sp = table; - short count; - - fprintf( stringConstFile, - "/***********************************************************\n" - "* This file is machine generated.\n" - "* Don't edit: your changes will be lost.\n" - "************************************************************/\n"); - - fprintf( stringConstFile, "\n#define FIRST_STR_INDEX %d\n\n", - FIRST_STR_INDEX ); - - count = 0; - for ( ; sp->constName != NULL && sp->theString != NULL; ++sp ) { - short strBytes; - - strBytes = strlen(sp->theString)+1; - fwrite( sp->theString, strBytes, 1, stringResFile ); - fprintf( stringConstFile, "#define %s %d\n", sp->constName, count ); - count += strBytes; - } - fprintf( stringConstFile, "#define %s %d\n", "STR_LAST_STRING", count ); - - fclose( stringResFile ); - fclose( stringConstFile ); - return 0; -} // main diff --git a/xwords4/palm/l10n/xwords4_en_US.rcp.pre b/xwords4/palm/l10n/xwords4_en_US.rcp.pre deleted file mode 100644 index 512130340..000000000 --- a/xwords4/palm/l10n/xwords4_en_US.rcp.pre +++ /dev/null @@ -1,621 +0,0 @@ -/* -*-mode: c; fill-column: 78; compile-command: "cd ../ && make ARCH=68K_ONLY MEMDEBUG=TRUE"; -*- */ -/***************************************************************************** - * Copyright 1999 - 2006 by Eric House (xwords@eehouse.org) and others. All - * rights reserved. - * - * 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. - ****************************************************************************/ - -#define DEFINES_ONLY 1 - -#include "xwords4defines.h" - -#define LEFTMARGIN 5 - -MENU XW_MAIN_MENU_ID -BEGIN - PULLDOWN "File" - BEGIN - MENUITEM "New game..." XW_NEWGAME_PULLDOWN_ID "N" - MENUITEM "Saved games..." XW_SAVEDGAMES_PULLDOWN_ID "S" - MENUITEM "Preferences..." XW_PREFS_PULLDOWN_ID "P" - MENUITEM SEPARATOR - MENUITEM "Beam dictionary" XW_BEAMDICT_PULLDOWN_ID - MENUITEM "Beam boards and colors" XW_BEAMBOARD_PULLDOWN_ID -#ifdef FEATURE_DUALCHOOSE - MENUITEM SEPARATOR - MENUITEM "Launch 68K vers." XW_RUN68K_PULLDOWN_ID - MENUITEM "Launch ARM vers." XW_RUNARM_PULLDOWN_ID -#endif - MENUITEM SEPARATOR - MENUITEM "About Crosswords..." XW_ABOUT_PULLDOWN_ID "A" - END - - PULLDOWN "Game" - BEGIN - MENUITEM "Tile values" XW_TILEVALUES_PULLDOWN_ID "V" - MENUITEM "Remaining tiles" XW_TILESLEFT_PULLDOWN_ID "R" - MENUITEM "Current game info..." XW_PASSWORDS_PULLDOWN_ID "G" - MENUITEM "History" XW_HISTORY_PULLDOWN_ID "Y" - MENUITEM "Final scores" XW_FINISH_PULLDOWN_ID "F" -#ifndef XWFEATURE_STANDALONE_ONLY - MENUITEM SEPARATOR - MENUITEM "Resend" XW_RESENDIR_PULLDOWN_ID -#endif - END - PULLDOWN "Move" - BEGIN - MENUITEM "Hint" XW_HINT_PULLDOWN_ID "I" -#ifdef XWFEATURE_SEARCHLIMIT - MENUITEM "Limited hint" XW_HINTCONFIG_PULLDOWN_ID "C" - MENUITEM SEPARATOR -#endif - MENUITEM "Next hint" XW_NEXTHINT_PULLDOWN_ID "M" - MENUITEM SEPARATOR - MENUITEM "Undo current" XW_UNDOCUR_PULLDOWN_ID "U" - MENUITEM "Undo last" XW_UNDOLAST_PULLDOWN_ID "Z" - MENUITEM SEPARATOR - MENUITEM "Done" XW_DONE_PULLDOWN_ID "D" - MENUITEM "Juggle" XW_JUGGLE_PULLDOWN_ID "J" - MENUITEM "Trade tiles" XW_TRADEIN_PULLDOWN_ID "T" - MENUITEM "[un]Hide tray" XW_HIDESHOWTRAY_PULLDOWN_ID "H" - END -#ifdef FOR_GREMLINS - PULLDOWN "Grem" - BEGIN - MENUITEM "divider right" XW_GREMLIN_DIVIDER_RIGHT - MENUITEM "divider left" XW_GREMLIN_DIVIDER_LEFT - END -#endif - - -#ifndef FOR_GREMLINS -#ifdef DEBUG - PULLDOWN "DBG" - BEGIN - MENUITEM "Log to file" XW_LOGFILE_PULLDOWN_ID - MENUITEM "Log to memo" XW_LOGMEMO_PULLDOWN_ID - MENUITEM "Clear logs" XW_CLEARLOGS_PULLDOWN_ID - MENUITEM "Network stats..." XW_NETSTATS_PULLDOWN_ID -#ifdef DEBUG - MENUITEM "BT stats..." XW_BTSTATS_PULLDOWN_ID -#endif -#ifdef MEM_DEBUG - MENUITEM "Mem stats..." XW_MEMSTATS_PULLDOWN_ID -#endif - END -#endif -#endif /* FOR_GREMLINS */ - -END - -MENU XW_ASK_MENU_ID -BEGIN - PULLDOWN "Edit" - BEGIN - MENUITEM "Copy" ASK_COPY_PULLDOWN_ID - MENUITEM "Select all" ASK_SELECTALL_PULLDOWN_ID - END -END - -#include "common.rcp.pre" /* these don't need localization */ - -#ifdef XWFEATURE_STANDALONE_ONLY -# define NPLAYERS_TOP 15 -# define FORM_TOP 34 -# define FORM_HEIGHT 124 -#else -# define SERVER_TOP 15 -# define NPLAYERS_TOP (SERVER_TOP+18) -# define FORM_TOP 16 -# define FORM_HEIGHT 142 -#endif -#define LABEL_TOP (NPLAYERS_TOP+18) -#define LEFTCOL 4 -#define REMOTE_COL LEFTCOL -#define NAME_COL 50 -#define ROBOT_COL 98 -#define PASSWD_COL RIGHT@156 - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_REMOTECHECK( num, offset ) \ - CHECKBOX "" ID XW_REMOTE_##num##_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+offset AUTO AUTO) USABLE -#else -#define PLAYER_REMOTECHECK( num, offset ) -#endif - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (PREVRIGHT PREVTOP 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#else -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (LEFTCOL+10 PREVBOTTOM+offset 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#endif - -#define PLAYER_ROBCHECK( num, offset ) \ - CHECKBOX "" ID XW_ROBOT_##num##_CHECKBOX_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE RIGHTANCHOR - -#define PLAYER_PASSFIELD( num, offset ) \ - SELECTORTRIGGER "" XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - AT (PREVRIGHT PREVTOP 12 11) - -/* FIELD XW_PLAYERPASSWD_##num##_FIELD_ID PREVRIGHT PREVTOP 20 \ */ -/* AUTO UNDERLINED EDITABLE SINGLELINE MAXCHARS 4 */ - -#define PLAYER_ROW( num, offset ) \ - PLAYER_REMOTECHECK( num, offset ) \ - PLAYER_NAMEFIELD( num, offset ) \ - PLAYER_ROBCHECK( num, offset ) \ - PLAYER_PASSFIELD( num, offset ) - -#define PLAYER_ROW_ID( num ) \ - ID XW_REMOTE_##num##_CHECKBOX_ID \ - ID XW_PLAYERNAME_##num##_FIELD_ID \ - ID XW_ROBOT_##num##_CHECKBOX_ID \ - ID XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - -#define PLAYER_ROW_NAV( num ) \ - ROW XW_REMOTE_##num##_CHECKBOX_ID \ - ROW XW_PLAYERNAME_##num##_FIELD_ID \ - XW_ROBOT_##num##_CHECKBOX_ID \ - XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - -//#define SERVER_GROUP_ID 2000 -#define SERVER_HEIGHT 12 - -FORM ID XW_NEWGAMES_FORM AT (2 FORM_TOP 156 FORM_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_CANCEL_BUTTON_ID -BEGIN - TITLE "Game options" - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Connect:" AUTOID AT (LEFTCOL SERVER_TOP) - GADGET ID XW_SOLO_GADGET_ID - AT (PREVRIGHT+2 SERVER_TOP 55 SERVER_HEIGHT) USABLE - GADGET ID XW_SERVER_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 24 SERVER_HEIGHT) USABLE - GADGET ID XW_CLIENT_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 30 SERVER_HEIGHT) USABLE - LIST "Stand-alone" "Host" "Guest" XW_SERVERTYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 3 NONUSABLE -#endif - -/* Pick number of players here */ - FIELD XW_TOTALP_FIELD_ID LEFTCOL NPLAYERS_TOP 58 AUTO \ - SINGLELINE NONEDITABLE MAXCHARS 16 - - SELECTORTRIGGER "" XW_NPLAYERS_SELECTOR_ID \ - AT (PREVRIGHT NPLAYERS_TOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" XW_NPLAYERS_LIST_ID AT (PREVLEFT PREVTOP 10 1) \ - VISIBLEITEMS 4 NONUSABLE - - BUTTON "J" XW_GINFO_JUGGLE_ID PREVRIGHT+3 PREVTOP 10 AUTO - - BUTTON "Other prefs..." XW_PREFS_BUTTON_ID PREVRIGHT+5 PREVTOP 63 AUTO - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Remote" XW_LOCAL_LABEL_ID REMOTE_COL LABEL_TOP FONT 1 -#endif - LABEL "Name" AUTOID NAME_COL LABEL_TOP FONT 1 - LABEL "Robot" AUTOID ROBOT_COL LABEL_TOP FONT 1 - LABEL "Pwd" AUTOID PASSWD_COL LABEL_TOP FONT 1 - - PLAYER_ROW( 1, 2 ) - PLAYER_ROW( 2, 2 ) - PLAYER_ROW( 3, 2 ) - PLAYER_ROW( 4, 2 ) - - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+10 - - SELECTORTRIGGER "Dictionary..." XW_DICT_SELECTOR_ID \ - AT (PREVRIGHT+8 PREVTOP AUTO AUTO) USABLE LEFTANCHOR - - BUTTON "Ok" XW_OK_BUTTON_ID RIGHT@154 PREVTOP AUTO AUTO - BUTTON "Cancel" XW_CANCEL_BUTTON_ID RIGHT@PREVLEFT-5 PREVTOP 30 AUTO -END /* XW_NEWGAMES_FORM */ - -#ifdef XWFEATURE_FIVEWAY -NAVIGATION ID XW_NEWGAMES_FORM -INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState -#if 0 -BEGIN - ID XW_SOLO_GADGET_ID - ID XW_SERVER_GADGET_ID - ID XW_CLIENT_GADGET_ID - - ID XW_NPLAYERS_SELECTOR_ID - ID XW_GINFO_JUGGLE_ID - ID XW_PREFS_BUTTON_ID - - PLAYER_ROW_ID( 1 ) - PLAYER_ROW_ID( 2 ) - PLAYER_ROW_ID( 3 ) - PLAYER_ROW_ID( 4 ) - - ID XW_DICT_SELECTOR_ID - ID XW_CANCEL_BUTTON_ID - ID XW_OK_BUTTON_ID -#else -NAVIGATIONMAP -#ifndef XWFEATURE_STANDALONE_ONLY - ROW XW_SOLO_GADGET_ID - XW_SERVER_GADGET_ID - XW_CLIENT_GADGET_ID -#endif - ROW XW_NPLAYERS_SELECTOR_ID - XW_GINFO_JUGGLE_ID - XW_PREFS_BUTTON_ID - - PLAYER_ROW_NAV( 1 ) - PLAYER_ROW_NAV( 2 ) - PLAYER_ROW_NAV( 3 ) - PLAYER_ROW_NAV( 4 ) - - ROW XW_DICT_SELECTOR_ID - XW_CANCEL_BUTTON_ID - XW_OK_BUTTON_ID -#endif -END /* NAVIGATION ID XW_NEWGAMES_FORM */ -#endif - -#ifdef XWFEATURE_BLUETOOTH -/* Let's define this in one place so it stays the same */ -# define BT_CONF_STRING "Ask before connecting Bluetooth" -#endif - - -#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH || defined XWFEATURE_IR -#define LEFTCOL 4 -#define CONNS_FIELD_LEFT 70 -#define LOCALIP_TOP 30 - -FORM ID XW_CONNS_FORM AT (2 66 156 93) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_CONNS_CANCEL_BUTTON_ID -BEGIN - TITLE "Connections" - - LABEL "Connect via:" AUTOID LEFTCOL 15 FONT 1 - - POPUPTRIGGER "" ID XW_CONNS_TYPE_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LIST - "" ID XW_CONNS_TYPE_LIST_ID - PREVLEFT PREVTOP 72 12 VISIBLEITEMS 2 - NONUSABLE POPUPLIST XW_CONNS_TYPE_TRIGGER_ID XW_CONNS_TYPE_LIST_ID - -#ifdef XWFEATURE_BLUETOOTH - LABEL "Host device:" XW_CONNS_BT_HOSTNAME_LABEL_ID - AT ( LEFTCOL LOCALIP_TOP+5 ) NONUSABLE - SELECTORTRIGGER "Find host..." XW_CONNS_BT_HOSTTRIGGER_ID \ - AT (CONNS_FIELD_LEFT PREVTOP 70 AUTO) NONUSABLE LEFTANCHOR - CHECKBOX BT_CONF_STRING ID XW_CONNS_BTCONFIRM_CHECKBOX_ID \ - AT ( LEFTCOL LOCALIP_TOP+21 AUTO AUTO ) NONUSABLE -#endif - -/* Relay... */ -#ifdef XWFEATURE_RELAY - LABEL "Room:" XW_CONNS_INVITE_LABEL_ID - AT ( LEFTCOL LOCALIP_TOP ) - FIELD XW_CONNS_INVITE_FIELD_ID CONNS_FIELD_LEFT PREVTOP 70 AUTO \ - SINGLELINE EDITABLE UNDERLINED MAXCHARS 32 - - LABEL "Relay name:" XW_CONNS_RELAY_LABEL_ID - AT ( LEFTCOL+10 PREVBOTTOM + 2 ) - FIELD XW_CONNS_RELAY_FIELD_ID CONNS_FIELD_LEFT PREVTOP 70 AUTO \ - SINGLELINE EDITABLE UNDERLINED MAXCHARS 32 - - LABEL "Relay port:" XW_CONNS_PORT_LABEL_ID - AT (LEFTCOL+10 PREVBOTTOM + 2) - FIELD XW_CONNS_PORT_FIELD_ID CONNS_FIELD_LEFT PREVTOP 30 AUTO \ - EDITABLE SINGLELINE UNDERLINED NUMERIC MAXCHARS 5 - -#endif - - BUTTON "Cancel" XW_CONNS_CANCEL_BUTTON_ID 42 75 AUTO AUTO - BUTTON "Ok" XW_CONNS_OK_BUTTON_ID PREVRIGHT+10 PREVTOP AUTO AUTO -END /* XW_CONNS_FORM */ -#endif - -#ifdef FEATURE_TRAY_EDIT -# define TRAY_EDIT_ADJUST 15 -#else -# define TRAY_EDIT_ADJUST 0 -#endif -#ifdef XWFEATURE_SEARCHLIMIT -# define SEARCHLIMIT_ADJUST 15 -#else -# define SEARCHLIMIT_ADJUST 0 -#endif -#ifdef XWFEATURE_BLUETOOTH -# define BTCONF_ADJUST PREFS_SPACING -#else -# define BTCONF_ADJUST 0 -#endif - -#define PREFS_MODE_TOP 15 -#define PREFS_ROW1 30 -#define PREFS_SPACING 15 - -/* #define DLG_TOP (52-TRAY_EDIT_ADJUST-SEARCHLIMIT_ADJUST) */ -#define DLG_HEIGHT (112+TRAY_EDIT_ADJUST+SEARCHLIMIT_ADJUST+BTCONF_ADJUST) -#define DLG_TOP (160 - DLG_HEIGHT - 2) -#define TIMER_TOP (74+SEARCHLIMIT_ADJUST) -#define BTCONF_TOP (TIMER_TOP+18+TRAY_EDIT_ADJUST) -#define BUTTON_TOP (BTCONF_TOP + PREFS_SPACING) -#define PREFS_LNHT 4 - -FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_PREFS_CANCEL_BUTTON_ID -BEGIN - TITLE "Preferences" - - GADGET ID XW_PREFS_ALLGAMES_GADGET_ID - AT (LEFTCOL+8 PREFS_MODE_TOP 60 SERVER_HEIGHT) USABLE - GADGET ID XW_PREFS_ONEGAME_GADGET_ID - AT (PREVRIGHT+1 PREVTOP 60 SERVER_HEIGHT) USABLE - LIST "All games" "This game" XW_PREFS_TYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 2 NONUSABLE - - /* global prefs */ - CHECKBOX "Color played tiles" ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID \ - AT (LEFTCOL PREFS_ROW1 AUTO AUTO) NONUSABLE - CHECKBOX "Show progress bar" ID XW_PREFS_PROGRESSBAR_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Larger board" ID XW_PREFS_SHOWGRID_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Enable arrow cursor" ID XW_PREFS_SHOWARROW_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Explain robot/remote scores" ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Hide tile values" ID XW_PREFS_HIDETRAYVAL_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - - /* single-game prefs */ - CHECKBOX "Smart robot" ID XW_PREFS_ROBOTSMART_CHECKBOX_ID \ - AT (LEFTCOL PREFS_ROW1 AUTO AUTO) NONUSABLE -#ifdef XWFEATURE_SEARCHLIMIT - CHECKBOX "Disallow hints" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Local hints" ID XW_PREFS_HINTRECT_CHECKBOX_ID \ - AT (PREVRIGHT+3 PREVTOP AUTO AUTO) NONUSABLE -#else - CHECKBOX "Disallow hints" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ - AT (PREVRIGHT+3 PREFS_ROW1 AUTO AUTO) NONUSABLE -#endif - - LABEL "Phonies:" XW_PREFS_PHONIES_LABEL_ID - AT (LEFTCOL PREVTOP+PREFS_SPACING) - POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - - LABEL "Board size: " XW_PREFS_BDSIZE_LABEL_ID - AT (LEFTCOL PREVTOP+PREFS_SPACING) - SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR - LIST "Ignore" "Warn" "Disallow" ID XW_PREFS_PHONIES_LIST_ID - AT (PREVLEFT PREVTOP 72 12) NONUSABLE VISIBLEITEMS 3 - POPUPLIST XW_PREFS_PHONIES_TRIGGER_ID XW_PREFS_PHONIES_LIST_ID - - LIST "15x15" "13x13" "11x11" \ - XW_PREFS_BDSIZE_LIST_ID AT (PREVLEFT PREVTOP 30 1) \ - NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES - - CHECKBOX "Enable timer (minutes:)" ID XW_PREFS_TIMERON_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - FIELD XW_PREFS_TIMER_FIELD_ID PREVRIGHT+5 PREVTOP 15 AUTO UNDERLINED \ - EDITABLE SINGLELINE NUMERIC MAXCHARS 3 - -#ifdef FEATURE_TRAY_EDIT - CHECKBOX "Pick tiles face-up" ID XW_PREFS_PICKTILES_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE -#endif - -#ifdef XWFEATURE_BLUETOOTH - CHECKBOX BT_CONF_STRING ID XW_PREFS_BTCONFIRM_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE -#endif - - /* buttons at the bottom */ - BUTTON "Cancel" XW_PREFS_CANCEL_BUTTON_ID 42 BUTTON_TOP AUTO AUTO - BUTTON "Ok" XW_PREFS_OK_BUTTON_ID PREVRIGHT+10 PREVTOP AUTO AUTO -END /* XW_PREFS_FORM */ - -NAVIGATION ID XW_PREFS_FORM -INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState -INITIALOBJECTID XW_PREFS_ONEGAME_GADGET_ID -NAVIGATIONMAP - ROW XW_PREFS_ALLGAMES_GADGET_ID - XW_PREFS_ONEGAME_GADGET_ID - - /* global prefs */ - ROW XW_PREFS_PLAYERCOLORS_CHECKBOX_ID - ROW XW_PREFS_PROGRESSBAR_CHECKBOX_ID - ROW XW_PREFS_SHOWGRID_CHECKBOX_ID - ROW XW_PREFS_SHOWARROW_CHECKBOX_ID - ROW XW_PREFS_ROBOTSCORE_CHECKBOX_ID - ROW XW_PREFS_HIDETRAYVAL_CHECKBOX_ID - - /* Per-game prefs */ - ROW XW_PREFS_ROBOTSMART_CHECKBOX_ID - ROW XW_PREFS_NOHINTS_CHECKBOX_ID -#ifdef XWFEATURE_SEARCHLIMIT - XW_PREFS_HINTRECT_CHECKBOX_ID -#endif - ROW XW_PREFS_PHONIES_TRIGGER_ID - ROW XW_PREFS_BDSIZE_SELECTOR_ID - - ROW XW_PREFS_TIMERON_CHECKBOX_ID - XW_PREFS_TIMER_FIELD_ID -#ifdef FEATURE_TRAY_EDIT - ROW XW_PREFS_PICKTILES_CHECKBOX_ID -#endif -#ifdef XWFEATURE_BLUETOOTH - ROW XW_PREFS_BTCONFIRM_CHECKBOX_ID -#endif - - /* cmd buttons */ - ROW XW_PREFS_CANCEL_BUTTON_ID - XW_PREFS_OK_BUTTON_ID -END - -#define LEFT_EDGE 10 -FORM ID XW_DICTINFO_FORM AT (2 111 156 47) -USABLE MODAL DEFAULTBTNID XW_DICTINFO_CANCEL_BUTTON_ID -BEGIN - TITLE "Dictionaries" - - LABEL "Dict:" AUTOID AT (LEFT_EDGE 15) - POPUPTRIGGER "" ID XW_DICTINFO_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LIST "" ID XW_DICTINFO_LIST_ID AT (PREVLEFT PREVTOP 72 1) - NONUSABLE VISIBLEITEMS 4 - POPUPLIST XW_DICTINFO_TRIGGER_ID XW_DICTINFO_LIST_ID - - BUTTON "Ok" XW_DICTINFO_DONE_BUTTON_ID 25 31 AUTO AUTO - BUTTON "Beam" XW_DICTINFO_BEAM_BUTTON_ID 22 PREVTOP AUTO AUTO - BUTTON "Cancel" XW_DICTINFO_CANCEL_BUTTON_ID PREVRIGHT+20 PREVTOP - AUTO AUTO -END - -FORM ID XW_ASK_FORM_ID AT (2 70 156 88) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_ASK_NO_BUTTON_ID -MENUID XW_ASK_MENU_ID -BEGIN - TITLE "Query" - - /* This has to be non-editable because the field is set via a ptr */ - FIELD XW_ASK_TXT_FIELD_ID LEFT_EDGE-5 16 135 52 \ - NONEDITABLE MULTIPLELINES - - SCROLLBAR ID XW_ASK_SCROLLBAR_ID - AT ( PREVRIGHT+2 PREVTOP RECOMMENDED_SBAR_WIDTH - PREVBOTTOM - PREVTOP) USABLE - - BUTTON "Yes" XW_ASK_YES_BUTTON_ID RIGHT@(156/2)-20 PREVBOTTOM+5 AUTO AUTO - BUTTON "No" XW_ASK_NO_BUTTON_ID 156/2+20 PREVTOP AUTO AUTO -END - -FORM ID XW_PASSWORD_DIALOG_ID AT ( 2 88 156 70 ) - MODAL SAVEBEHIND DEFAULTBTNID XW_PASSWORD_CANCEL_BUTTON -BEGIN - TITLE "Password" - - LABEL "Enter password for:" XW_PASSWORD_NAME_LABEL 10 18 FONT 1 NONUSABLE - LABEL "Enter new password for:" XW_PASSWORD_NEWNAME_LABEL 10 18 FONT 1 - NONUSABLE - FIELD XW_PASSWORD_NAME_FIELD AT (PREVLEFT PREVBOTTOM+3 90 12) NONEDITABLE - SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH - FIELD XW_PASSWORD_PASS_FIELD \ - AT (PREVRIGHT+10 PREVTOP MAX_PASSWORD_LENGTH*6 12) \ - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_PASSWORD_LENGTH - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+8 - BUTTON "Ok" XW_PASSWORD_OK_BUTTON 45 PREVTOP AUTO AUTO - BUTTON "Cancel" XW_PASSWORD_CANCEL_BUTTON PREVRIGHT+10 PREVTOP AUTO AUTO -END - -#define BLANK_PICK_TOP 15 - -FORM ID XW_BLANK_DIALOG_ID AT ( 2 74 156 83 ) USABLE - MODAL SAVEBEHIND -#ifdef FEATURE_TRAY_EDIT - DEFAULTBTNID XW_BLANK_PICK_BUTTON_ID -#endif -BEGIN - TITLE "Tile picker" - - FIELD XW_BLANK_LABEL_FIELD_ID AT (10 BLANK_PICK_TOP 110 39) - NONEDITABLE MULTIPLELINES - - LIST "" ID XW_BLANK_LIST_ID AT (PREVRIGHT+2 BLANK_PICK_TOP 28 72) - USABLE VISIBLEITEMS 6 - - BUTTON "Ok" XW_BLANK_OK_BUTTON_ID RIGHT@PREVLEFT-8 65 AUTO AUTO - -#ifdef FEATURE_TRAY_EDIT - BUTTON "Pick all!" XW_BLANK_PICK_BUTTON_ID 5 65 AUTO AUTO - BUTTON "Del" XW_BLANK_BACKUP_BUTTON_ID PREVRIGHT+5 PREVTOP 22 AUTO -#endif -END - -#ifdef XWFEATURE_SEARCHLIMIT -# define NTILES_TOP 17 -# define NTILES_BUTTON_TOP 60 -FORM ID XW_HINTCONFIG_FORM_ID AT ( 2 75 156 82 ) USABLE MODAL SAVEBEHIND -BEGIN - TITLE "Hint parameters" - - LABEL "At least this many tiles:" AUTOID 10 NTILES_TOP FONT 1 USABLE - SELECTORTRIGGER "" XW_HINTCONFIG_MINSELECTOR_ID \ - AT (PREVRIGHT+3 NTILES_TOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" "5" "6" "7" ID XW_HINTCONFIG_MINLIST_ID - AT (PREVRIGHT PREVTOP AUTO AUTO) VISIBLEITEMS 7 NONUSABLE - - LABEL "No more than this many:" AUTOID 10 PREVTOP+15 FONT 1 USABLE - SELECTORTRIGGER "" XW_HINTCONFIG_MAXSELECTOR_ID \ - AT (PREVRIGHT+3 PREVTOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" "5" "6" "7" ID XW_HINTCONFIG_MAXLIST_ID - AT (PREVRIGHT PREVTOP AUTO AUTO) VISIBLEITEMS 7 NONUSABLE - - BUTTON "Ok" XW_HINTCONFIG_OK_ID RIGHT@156-10 NTILES_BUTTON_TOP AUTO 12 - BUTTON "Cancel" XW_HINTCONFIG_CANCEL_ID RIGHT@PREVLEFT-10 PREVTOP AUTO 12 -END -#endif - -#if defined OWNER_HASH || defined NO_REG_REQUIRED -FORM ID XW_SAVEDGAMES_DIALOG_ID AT ( 2 2 156 156 ) -USABLE MODAL DEFAULTBTNID XW_SAVEDGAMES_DONE_BUTTON -BEGIN - TITLE "Saved games" - - LIST "" ID XW_SAVEDGAMES_LIST_ID AT (2 15 140 60) \ - USABLE ENABLED VISIBLEITEMS 1 - GRAFFITISTATEINDICATOR 2 120 - FIELD XW_SAVEDGAMES_NAME_FIELD AT (PREVRIGHT+10 PREVTOP 100 AUTO) - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_GAMENAME_LENGTH - - BUTTON "Mod." XW_SAVEDGAMES_USE_BUTTON RIGHT@154 PREVTOP 30 AUTO - - BUTTON "Dup." XW_SAVEDGAMES_DUPE_BUTTON 2 PREVBOTTOM+5 31 AUTO - BUTTON "Delete" XW_SAVEDGAMES_DELETE_BUTTON PREVRIGHT+5 PREVTOP 39 AUTO - BUTTON "Open" XW_SAVEDGAMES_OPEN_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO - BUTTON "Done" XW_SAVEDGAMES_DONE_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO -END /* XW_SAVEDGAMES_DIALOG_ID */ -#endif - -ALERT XW_ERROR_ALERT_ID -ERROR -BEGIN - TITLE "Oops" - MESSAGE "^1" - BUTTONS "Ok" -END - -#ifdef FOR_GREMLINS - -FORM ID XW_GREMLIN_WARN_FORM_ID AT ( 2 60 156 98 ) -USABLE MODAL -BEGIN - TITLE "Gremlin Oops" - FIELD XW_GREMLIN_WARN_FIELD_ID AT (2 15 150 75) - NONEDITABLE MULTIPLELINES -END - -#endif diff --git a/xwords4/palm/l10n/xwords4_es_CT.rcp.pre b/xwords4/palm/l10n/xwords4_es_CT.rcp.pre deleted file mode 100644 index bf11a0649..000000000 --- a/xwords4/palm/l10n/xwords4_es_CT.rcp.pre +++ /dev/null @@ -1,414 +0,0 @@ -/* -*-mode: c; fill-column: 78; -*- */ -/***************************************************************************** - * Copyright 1999 - 2002 by Eric House (xwords@eehouse.org) and others. All rights reserved. - * - * 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. - ****************************************************************************/ - -#define DEFINES_ONLY 1 - -#include "xwords4defines.h" - -#define LEFTMARGIN 5 - -MENU XW_MAIN_MENU_ID -BEGIN - PULLDOWN "Fitxer" - BEGIN - MENUITEM "Nova partida..." XW_NEWGAME_PULLDOWN_ID "N" - MENUITEM "Partides..." XW_SAVEDGAMES_PULLDOWN_ID "S" - MENUITEM "Preferències..." XW_PREFS_PULLDOWN_ID "P" - MENUITEM SEPARATOR - MENUITEM "Enviar diccionari" XW_BEAMDICT_PULLDOWN_ID - MENUITEM "Enviar tauler i colors" XW_BEAMBOARD_PULLDOWN_ID - MENUITEM SEPARATOR - MENUITEM "Sobre Crosswords..." XW_ABOUT_PULLDOWN_ID "A" - END - - PULLDOWN "Partida" - BEGIN - MENUITEM "Bossa de fitxes" XW_TILEVALUES_PULLDOWN_ID "V" - MENUITEM "Opcions..." XW_PASSWORDS_PULLDOWN_ID "G" - MENUITEM "Jugades" XW_HISTORY_PULLDOWN_ID "Y" - MENUITEM "Puntuació" XW_FINISH_PULLDOWN_ID "F" -#ifndef XWFEATURE_STANDALONE_ONLY - MENUITEM SEPARATOR - MENUITEM "Reenviar missatge" XW_RESENDIR_PULLDOWN_ID -#endif - END - PULLDOWN "Jugada" - BEGIN - MENUITEM "Pista" XW_HINT_PULLDOWN_ID "I" - MENUITEM "Més pistes" XW_NEXTHINT_PULLDOWN_ID "M" -#ifdef XWFEATURE_SEARCHLIMIT - MENUITEM "Configurat pistes..." XW_HINTCONFIG_PULLDOWN_ID "C" -#endif - MENUITEM SEPARATOR - MENUITEM "Descartar l'actual" XW_UNDOCUR_PULLDOWN_ID "U" - MENUITEM "Descartar la prèvia" XW_UNDOLAST_PULLDOWN_ID "Z" - MENUITEM SEPARATOR - MENUITEM "D'acord" XW_DONE_PULLDOWN_ID "D" - MENUITEM "Remenar el faristol" XW_JUGGLE_PULLDOWN_ID "J" - MENUITEM "Canviar fitxes" XW_TRADEIN_PULLDOWN_ID "T" - MENUITEM "Amagar el faristol" XW_HIDESHOWTRAY_PULLDOWN_ID "H" - END -#ifdef FOR_GREMLINS - PULLDOWN "Grem" - BEGIN - MENUITEM "divider right" XW_GREMLIN_DIVIDER_RIGHT - MENUITEM "divider left" XW_GREMLIN_DIVIDER_LEFT - END -#endif - - -#ifndef FOR_GREMLINS -#ifdef DEBUG - PULLDOWN "DBG" - BEGIN - MENUITEM "Show debugstrs" XW_DEBUGSHOW_PULLDOWN_ID - MENUITEM "Hide debugstrs" XW_DEBUGHIDE_PULLDOWN_ID -/* MENUITEM "Reset game" XW_RESET_PULLDOWN_ID */ - MENUITEM "Network stats..." XW_NETSTATS_PULLDOWN_ID -#ifdef MEM_DEBUG - MENUITEM "Mem stats..." XW_MEMSTATS_PULLDOWN_ID -#endif - END -#endif -#endif /* FOR_GREMLINS */ - -// NO NEED TO TRANSLATE GREMLINS or DEBUG stuff -#ifdef FOR_GREMLINS -/* PULLDOWN "Gremlins" */ -/* BEGIN */ -/* MENUITEM "Divider left" GREMLIN_DIVIDER_LEFT */ -/* MENUITEM "Divider right" GREMLIN_DIVIDER_RIGHT */ -/* END */ -#endif -END - -MENU XW_ASK_MENU_ID -BEGIN - PULLDOWN "Editar" - BEGIN - MENUITEM "Copiar" ASK_COPY_PULLDOWN_ID - MENUITEM "Seleccionar tot" ASK_SELECTALL_PULLDOWN_ID - END -END - -#include "common.rcp.pre" /* these don't need localization */ - -#ifdef XWFEATURE_STANDALONE_ONLY -# define NPLAYERS_TOP 15 -# define FORM_TOP 34 -# define FORM_HEIGHT 124 -#else -# define SERVER_TOP 15 -# define NPLAYERS_TOP (SERVER_TOP+18) -# define FORM_TOP 16 -# define FORM_HEIGHT 142 -#endif -#define LABEL_TOP (NPLAYERS_TOP+18) -#define LEFTCOL 4 -#define REMOTE_COL LEFTCOL -#define NAME_COL 50 -#define ROBOT_COL 98 -#define PASSWD_COL RIGHT@156 - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_REMOTECHECK( num, offset ) \ - CHECKBOX "" ID XW_REMOTE_##num##_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+offset AUTO AUTO) USABLE -#else -#define PLAYER_REMOTECHECK( num, offset ) -#endif - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (PREVRIGHT PREVTOP 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#else -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (LEFTCOL+10 PREVBOTTOM+offset 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#endif - -#define PLAYER_ROBCHECK( num, offset ) \ - CHECKBOX "" ID XW_ROBOT_##num##_CHECKBOX_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE RIGHTANCHOR - -#define PLAYER_PASSFIELD( num, offset ) \ - SELECTORTRIGGER "" XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - AT (PREVRIGHT PREVTOP 12 11) - -/* FIELD XW_PLAYERPASSWD_##num##_FIELD_ID PREVRIGHT PREVTOP 20 \ */ -/* AUTO UNDERLINED EDITABLE SINGLELINE MAXCHARS 4 */ - -#define PLAYER_ROW( num, offset ) \ - PLAYER_REMOTECHECK( num, offset ) \ - PLAYER_NAMEFIELD( num, offset ) \ - PLAYER_ROBCHECK( num, offset ) \ - PLAYER_PASSFIELD( num, offset ) - -//#define SERVER_GROUP_ID 2000 -#define SERVER_HEIGHT 12 -#define PLAYER_SEL_LEFT 64 - -FORM ID XW_NEWGAMES_FORM AT (2 FORM_TOP 156 FORM_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_OK_BUTTON_ID -BEGIN - TITLE "Opcions" - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Connexió:" AUTOID AT (LEFTCOL SERVER_TOP) - GADGET ID XW_SOLO_GADGET_ID AT (PREVRIGHT+2 SERVER_TOP 53 SERVER_HEIGHT) - USABLE - GADGET ID XW_SERVER_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 22 SERVER_HEIGHT) USABLE - GADGET ID XW_CLIENT_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 28 SERVER_HEIGHT) USABLE - LIST "Sense" "Servidor" "Client" XW_SERVERTYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 3 NONUSABLE -#endif - -/* Pick number of players here */ -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Locals: " XW_LOCALP_LABEL_ID AT (LEFTCOL NPLAYERS_TOP) - LABEL "Jugadors: " XW_TOTALP_LABEL_ID AT (LEFTCOL NPLAYERS_TOP) -#else - LABEL "Jugadors: " AUTOID AT (LEFTCOL NPLAYERS_TOP) -#endif - SELECTORTRIGGER "" XW_NPLAYERS_SELECTOR_ID \ - AT (PLAYER_SEL_LEFT NPLAYERS_TOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" XW_NPLAYERS_LIST_ID AT (PREVLEFT PREVTOP 10 1) \ - VISIBLEITEMS 4 NONUSABLE - - BUTTON "Més opcions..." XW_PREFS_BUTTON_ID RIGHT@154 NPLAYERS_TOP AUTO AUTO - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Client" XW_LOCAL_LABEL_ID REMOTE_COL LABEL_TOP FONT 1 -#endif - LABEL "Nom" AUTOID NAME_COL LABEL_TOP FONT 1 - LABEL "Robot" AUTOID ROBOT_COL LABEL_TOP FONT 1 - LABEL "Pwd" AUTOID PASSWD_COL LABEL_TOP FONT 1 - - PLAYER_ROW( 1, 2 ) - PLAYER_ROW( 2, 2 ) - PLAYER_ROW( 3, 2 ) - PLAYER_ROW( 4, 2 ) - - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+10 - - SELECTORTRIGGER "Diccionari..." XW_DICT_SELECTOR_ID \ - AT (PREVRIGHT+12 PREVTOP AUTO AUTO) USABLE LEFTANCHOR - - BUTTON "D'acord" XW_OK_BUTTON_ID RIGHT@154 PREVTOP 36 AUTO - BUTTON "Sortir" XW_CANCEL_BUTTON_ID RIGHT@PREVLEFT-3 PREVTOP 39 AUTO -END /* FORM XW_PLAYERINFO_FORM */ - -#ifdef FEATURE_TRAY_EDIT -# define TRAY_EDIT_ADJUST 15 -#else -# define TRAY_EDIT_ADJUST 0 -#endif - -#define PREFS_MODE_TOP 15 -#define PREFS_TOP 30 -#define DLG_TOP 41-TRAY_EDIT_ADJUST -#define DLG_HEIGHT 118+TRAY_EDIT_ADJUST -#define TIMER_TOP 87 -#define BUTTON_TOP TIMER_TOP+16+TRAY_EDIT_ADJUST - -/* FORM ID XW_PREFS_FORM AT (2 29 156 130) */ -FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_PREFS_CANCEL_BUTTON_ID -BEGIN - TITLE "Preferències" - - GADGET ID XW_PREFS_APPWIDE_CHECKBX_ID - AT (LEFTCOL+8 PREFS_MODE_TOP 75 SERVER_HEIGHT) USABLE - GADGET ID XW_PREFS_ONEGAME_CHECKBX_ID - AT (PREVRIGHT+1 PREVTOP 50 SERVER_HEIGHT) USABLE - LIST "Del programa" "De la partida" XW_PREFS_TYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 2 NONUSABLE - - /* global prefs */ - CHECKBOX "Acolorir fitxes segons el jugador" ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID \ - AT (LEFTCOL PREFS_TOP AUTO AUTO) NONUSABLE - CHECKBOX "Mostrar la barra de progrés" ID XW_PREFS_PROGRESSBAR_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - CHECKBOX "Dibuixar el tauler gran" ID XW_PREFS_SHOWGRID_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - CHECKBOX "Activar el cursor" ID XW_PREFS_SHOWARROW_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - CHECKBOX "Veure jugada del robot" ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - - /* single-game prefs */ - CHECKBOX "El robot mai no falla" ID XW_PREFS_ROBOTSMART_CHECKBOX_ID \ - AT (LEFTCOL PREFS_TOP AUTO AUTO) NONUSABLE - CHECKBOX "Desactivar pistes" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM AUTO AUTO) NONUSABLE - - LABEL "Si no troba:" XW_PREFS_PHONIES_LABEL_ID AT (LEFTCOL PREVBOTTOM+2) - POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LABEL "Tauler de: " XW_PREFS_BDSIZE_LABEL_ID - AT (LEFTCOL PREVBOTTOM+2) - SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR - LIST "Ignora" "Avisa" "No permet" ID XW_PREFS_PHONIES_LIST_ID - AT (PREVLEFT PREVTOP 72 12) NONUSABLE VISIBLEITEMS 3 - POPUPLIST XW_PREFS_PHONIES_TRIGGER_ID XW_PREFS_PHONIES_LIST_ID - - LIST "15x15" "13x13" "11x11" \ - XW_PREFS_BDSIZE_LIST_ID AT (PREVLEFT PREVTOP 30 1) \ - NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES - - CHECKBOX "Activar rellotge (minuts): " ID XW_PREFS_TIMERON_CHECKBOX_ID \ - AT (LEFTCOL TIMER_TOP AUTO AUTO) NONUSABLE - FIELD XW_PREFS_TIMER_FIELD_ID PREVRIGHT+5 PREVTOP 15 AUTO UNDERLINED \ - EDITABLE SINGLELINE NUMERIC MAXCHARS 3 - -#ifdef FEATURE_TRAY_EDIT - CHECKBOX "Faristol editable" ID XW_PREFS_PICKTILES_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM AUTO AUTO) NONUSABLE -#endif - - /* buttons at the bottom */ - BUTTON "Sortir" XW_PREFS_CANCEL_BUTTON_ID 35 BUTTON_TOP AUTO AUTO - BUTTON "D'acord" XW_PREFS_OK_BUTTON_ID PREVRIGHT+10 PREVTOP AUTO AUTO -END - -#define LEFT_EDGE 10 -FORM ID XW_DICTINFO_FORM AT (2 111 156 47) -USABLE MODAL DEFAULTBTNID XW_DICTINFO_CANCEL_BUTTON_ID -BEGIN - TITLE "Diccionaris" - - LABEL "Nom:" AUTOID AT (LEFT_EDGE 15) - POPUPTRIGGER "" ID XW_DICTINFO_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LIST "" ID XW_DICTINFO_LIST_ID AT (PREVLEFT PREVTOP 72 1) - NONUSABLE VISIBLEITEMS 4 - POPUPLIST XW_DICTINFO_TRIGGER_ID XW_DICTINFO_LIST_ID - - BUTTON "D'acord" XW_DICTINFO_DONE_BUTTON_ID 25 31 AUTO AUTO - BUTTON "Enviar" XW_DICTINFO_BEAM_BUTTON_ID 22 PREVTOP AUTO AUTO - BUTTON "Sortir" XW_DICTINFO_CANCEL_BUTTON_ID PREVRIGHT+20 PREVTOP - AUTO AUTO -END - -FORM ID XW_ASK_FORM_ID AT (2 70 156 88) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_ASK_NO_BUTTON_ID -MENUID XW_ASK_MENU_ID -BEGIN - TITLE "Pregunta" - - FIELD XW_ASK_TXT_FIELD_ID LEFT_EDGE-5 15 135 52 \ - NONEDITABLE MULTIPLELINES - - SCROLLBAR ID XW_ASK_SCROLLBAR_ID - AT ( PREVRIGHT+2 PREVTOP RECOMMENDED_SBAR_WIDTH - PREVBOTTOM - PREVTOP) USABLE - - BUTTON "D'acord" XW_ASK_YES_BUTTON_ID RIGHT@(156/2)-10 PREVBOTTOM+2 AUTO AUTO - BUTTON "Sortir" XW_ASK_NO_BUTTON_ID 156/2+10 PREVTOP - AUTO AUTO -END - -FORM ID XW_PASSWORD_DIALOG_ID AT ( 2 88 156 70 ) - MODAL SAVEBEHIND DEFAULTBTNID XW_PASSWORD_CANCEL_BUTTON -BEGIN - TITLE "Password" - - LABEL "Entra el password per:" XW_PASSWORD_NAME_LABEL 10 18 FONT 1 NONUSABLE - LABEL "Entra el nou password per:" XW_PASSWORD_NEWNAME_LABEL 10 18 FONT 1 - NONUSABLE - FIELD XW_PASSWORD_NAME_FIELD AT (PREVLEFT PREVBOTTOM+3 90 12) NONEDITABLE - SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH - FIELD XW_PASSWORD_PASS_FIELD \ - AT (PREVRIGHT+10 PREVTOP MAX_PASSWORD_LENGTH*6 12) \ - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_PASSWORD_LENGTH - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+8 - BUTTON "D'acord" XW_PASSWORD_OK_BUTTON 45 PREVTOP AUTO AUTO - BUTTON "Sortir" XW_PASSWORD_CANCEL_BUTTON PREVRIGHT+10 PREVTOP AUTO AUTO -END - -#define BLANK_PICK_TOP 15 - -FORM ID XW_BLANK_DIALOG_ID AT ( 2 74 156 83 ) USABLE - MODAL SAVEBEHIND -#ifdef FEATURE_TRAY_EDIT - DEFAULTBTNID XW_BLANK_PICK_BUTTON_ID -#endif -BEGIN - TITLE "Editar el faristol" - - FIELD XW_BLANK_LABEL_FIELD_ID AT (10 BLANK_PICK_TOP 110 39) - NONEDITABLE MULTIPLELINES - - LIST "" ID XW_BLANK_LIST_ID AT (PREVRIGHT+2 BLANK_PICK_TOP 28 72) - USABLE VISIBLEITEMS 6 - - BUTTON "D'acord" XW_BLANK_OK_BUTTON_ID RIGHT@PREVLEFT-10 65 42 AUTO - -#ifdef FEATURE_TRAY_EDIT - BUTTON "Tot!" XW_BLANK_PICK_BUTTON_ID 5 65 32 AUTO - BUTTON "Esb." XW_BLANK_BACKUP_BUTTON_ID PREVRIGHT+3 PREVTOP 23 AUTO -#endif -END - -#if defined OWNER_HASH || defined NO_REG_REQUIRED -FORM ID XW_SAVEDGAMES_DIALOG_ID AT ( 2 2 156 156 ) -USABLE MODAL DEFAULTBTNID XW_SAVEDGAMES_DONE_BUTTON -BEGIN - TITLE "Partides" - - LIST "" ID XW_SAVEDGAMES_LIST_ID AT (2 15 140 60) \ - USABLE ENABLED VISIBLEITEMS 1 - GRAFFITISTATEINDICATOR 2 120 - FIELD XW_SAVEDGAMES_NAME_FIELD AT (PREVRIGHT+10 PREVTOP 108 AUTO) - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_GAMENAME_LENGTH - - BUTTON "Modif." XW_SAVEDGAMES_USE_BUTTON RIGHT@154 PREVTOP 30 AUTO - - BUTTON "Duplic." XW_SAVEDGAMES_DUPE_BUTTON 2 PREVBOTTOM+5 33 AUTO - BUTTON "Esborrar" XW_SAVEDGAMES_DELETE_BUTTON PREVRIGHT+5 PREVTOP 41 AUTO - BUTTON "Triar" XW_SAVEDGAMES_OPEN_BUTTON PREVRIGHT+5 PREVTOP 28 AUTO - BUTTON "Tancar" XW_SAVEDGAMES_DONE_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO -END -#endif - -ALERT XW_ERROR_ALERT_ID -ERROR -BEGIN - TITLE "Alerta!" - MESSAGE "^1" - BUTTONS "D'acord" -END - -#ifdef FOR_GREMLINS - -FORM ID XW_GREMLIN_WARN_FORM_ID AT ( 2 60 156 98 ) -USABLE MODAL -BEGIN - TITLE "Gremlin Oops" - FIELD XW_GREMLIN_WARN_FIELD_ID AT (2 15 150 75) - NONEDITABLE MULTIPLELINES -END - -#endif diff --git a/xwords4/palm/l10n/xwords4_es_ES.rcp.pre b/xwords4/palm/l10n/xwords4_es_ES.rcp.pre deleted file mode 100644 index fa637bfd4..000000000 --- a/xwords4/palm/l10n/xwords4_es_ES.rcp.pre +++ /dev/null @@ -1,413 +0,0 @@ -/* -*-mode: c; fill-column: 78; -*- */ -/***************************************************************************** - * Copyright 1999 - 2002 by Eric House (xwords@eehouse.org) and others. All rights reserved. - * - * 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. - ****************************************************************************/ - -#define DEFINES_ONLY 1 - -#include "xwords4defines.h" - -#define LEFTMARGIN 5 - -MENU XW_MAIN_MENU_ID -BEGIN - PULLDOWN "Fichero" - BEGIN - MENUITEM "Nueva partida..." XW_NEWGAME_PULLDOWN_ID "N" - MENUITEM "Partidas..." XW_SAVEDGAMES_PULLDOWN_ID "S" - MENUITEM "Preferencias..." XW_PREFS_PULLDOWN_ID "P" - MENUITEM SEPARATOR - MENUITEM "Enviar diccionario" XW_BEAMDICT_PULLDOWN_ID - MENUITEM "Enviar tablero y colores" XW_BEAMBOARD_PULLDOWN_ID - MENUITEM SEPARATOR - MENUITEM "Acerca de Crosswords..." XW_ABOUT_PULLDOWN_ID "A" - END - - PULLDOWN "Partida" - BEGIN - MENUITEM "Bolsa de fichas" XW_TILEVALUES_PULLDOWN_ID "V" - MENUITEM "Opciones..." XW_PASSWORDS_PULLDOWN_ID "G" - MENUITEM "Jugadas" XW_HISTORY_PULLDOWN_ID "Y" - MENUITEM "Puntuación" XW_FINISH_PULLDOWN_ID "F" -#ifndef XWFEATURE_STANDALONE_ONLY - MENUITEM SEPARATOR - MENUITEM "Reenviar mensajes" XW_RESENDIR_PULLDOWN_ID -#endif - END - PULLDOWN "Jugada" - BEGIN - MENUITEM "Pista" XW_HINT_PULLDOWN_ID "I" - MENUITEM "Más pistas" XW_NEXTHINT_PULLDOWN_ID "M" -#ifdef XWFEATURE_SEARCHLIMIT - MENUITEM "Configurar pistas..." XW_HINTCONFIG_PULLDOWN_ID "C" -#endif - MENUITEM SEPARATOR - MENUITEM "Descartar la actual" XW_UNDOCUR_PULLDOWN_ID "U" - MENUITEM "Descartar la previa" XW_UNDOLAST_PULLDOWN_ID "Z" - MENUITEM SEPARATOR - MENUITEM "Aceptar" XW_DONE_PULLDOWN_ID "D" - MENUITEM "Remover el atril" XW_JUGGLE_PULLDOWN_ID "J" - MENUITEM "Cambiar fichas" XW_TRADEIN_PULLDOWN_ID "T" - MENUITEM "Ocultar el atril" XW_HIDESHOWTRAY_PULLDOWN_ID "H" - END -#ifdef FOR_GREMLINS - PULLDOWN "Grem" - BEGIN - MENUITEM "divider right" XW_GREMLIN_DIVIDER_RIGHT - MENUITEM "divider left" XW_GREMLIN_DIVIDER_LEFT - END -#endif - - -#ifndef FOR_GREMLINS -#ifdef DEBUG - PULLDOWN "DBG" - BEGIN - MENUITEM "Show debugstrs" XW_DEBUGSHOW_PULLDOWN_ID - MENUITEM "Hide debugstrs" XW_DEBUGHIDE_PULLDOWN_ID - MENUITEM "Network stats..." XW_NETSTATS_PULLDOWN_ID -#ifdef MEM_DEBUG - MENUITEM "Mem stats..." XW_MEMSTATS_PULLDOWN_ID -#endif - END -#endif -#endif /* FOR_GREMLINS */ - -// NO NEED TO TRANSLATE GREMLINS or DEBUG stuff -#ifdef FOR_GREMLINS -/* PULLDOWN "Gremlins" */ -/* BEGIN */ -/* MENUITEM "Divider left" GREMLIN_DIVIDER_LEFT */ -/* MENUITEM "Divider right" GREMLIN_DIVIDER_RIGHT */ -/* END */ -#endif -END - -MENU XW_ASK_MENU_ID -BEGIN - PULLDOWN "Editar" - BEGIN - MENUITEM "Copiar" ASK_COPY_PULLDOWN_ID - MENUITEM "Seleccionar todo" ASK_SELECTALL_PULLDOWN_ID - END -END - -#include "common.rcp.pre" /* these don't need localization */ - -#ifdef XWFEATURE_STANDALONE_ONLY -# define NPLAYERS_TOP 15 -# define FORM_TOP 34 -# define FORM_HEIGHT 124 -#else -# define SERVER_TOP 15 -# define NPLAYERS_TOP (SERVER_TOP+18) -# define FORM_TOP 16 -# define FORM_HEIGHT 142 -#endif -#define LABEL_TOP (NPLAYERS_TOP+18) -#define LEFTCOL 4 -#define REMOTE_COL LEFTCOL -#define NAME_COL 50 -#define ROBOT_COL 98 -#define PASSWD_COL RIGHT@156 - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_REMOTECHECK( num, offset ) \ - CHECKBOX "" ID XW_REMOTE_##num##_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+offset AUTO AUTO) USABLE -#else -#define PLAYER_REMOTECHECK( num, offset ) -#endif - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (PREVRIGHT PREVTOP 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#else -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (LEFTCOL+10 PREVBOTTOM+offset 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#endif - -#define PLAYER_ROBCHECK( num, offset ) \ - CHECKBOX "" ID XW_ROBOT_##num##_CHECKBOX_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE RIGHTANCHOR - -#define PLAYER_PASSFIELD( num, offset ) \ - SELECTORTRIGGER "" XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - AT (PREVRIGHT PREVTOP 12 11) - -/* FIELD XW_PLAYERPASSWD_##num##_FIELD_ID PREVRIGHT PREVTOP 20 \ */ -/* AUTO UNDERLINED EDITABLE SINGLELINE MAXCHARS 4 */ - -#define PLAYER_ROW( num, offset ) \ - PLAYER_REMOTECHECK( num, offset ) \ - PLAYER_NAMEFIELD( num, offset ) \ - PLAYER_ROBCHECK( num, offset ) \ - PLAYER_PASSFIELD( num, offset ) - -//#define SERVER_GROUP_ID 2000 -#define SERVER_HEIGHT 12 -#define PLAYER_SEL_LEFT 64 - -FORM ID XW_NEWGAMES_FORM AT (2 FORM_TOP 156 FORM_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_OK_BUTTON_ID -BEGIN - TITLE "Opciones" - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Conexión:" AUTOID AT (LEFTCOL SERVER_TOP) - GADGET ID XW_SOLO_GADGET_ID AT (PREVRIGHT+2 SERVER_TOP 53 SERVER_HEIGHT) - USABLE - GADGET ID XW_SERVER_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 22 SERVER_HEIGHT) USABLE - GADGET ID XW_CLIENT_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 28 SERVER_HEIGHT) USABLE - LIST "Sin" "Servidor" "Cliente" XW_SERVERTYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 3 NONUSABLE -#endif - -/* Pick number of players here */ -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Locales: " XW_LOCALP_LABEL_ID AT (LEFTCOL NPLAYERS_TOP) - LABEL "Jugadores: " XW_TOTALP_LABEL_ID AT (LEFTCOL NPLAYERS_TOP) -#else - LABEL "Jugadores: " AUTOID AT (LEFTCOL NPLAYERS_TOP) -#endif - SELECTORTRIGGER "" XW_NPLAYERS_SELECTOR_ID \ - AT (PLAYER_SEL_LEFT NPLAYERS_TOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" XW_NPLAYERS_LIST_ID AT (PREVLEFT PREVTOP 10 1) \ - VISIBLEITEMS 4 NONUSABLE - - BUTTON "Más opciones..." XW_PREFS_BUTTON_ID RIGHT@154 NPLAYERS_TOP AUTO AUTO - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Cliente" XW_LOCAL_LABEL_ID REMOTE_COL LABEL_TOP FONT 1 -#endif - LABEL "Nombre" AUTOID NAME_COL LABEL_TOP FONT 1 - LABEL "Robot" AUTOID ROBOT_COL LABEL_TOP FONT 1 - LABEL "Pwd" AUTOID PASSWD_COL LABEL_TOP FONT 1 - - PLAYER_ROW( 1, 2 ) - PLAYER_ROW( 2, 2 ) - PLAYER_ROW( 3, 2 ) - PLAYER_ROW( 4, 2 ) - - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+10 - - SELECTORTRIGGER "Diccionario..." XW_DICT_SELECTOR_ID \ - AT (PREVRIGHT+12 PREVTOP AUTO AUTO) USABLE LEFTANCHOR - - BUTTON "Aceptar" XW_OK_BUTTON_ID RIGHT@154 PREVTOP 36 AUTO - BUTTON "Cancelar" XW_CANCEL_BUTTON_ID RIGHT@PREVLEFT-3 PREVTOP 37 AUTO -END /* FORM XW_PLAYERINFO_FORM */ - -#ifdef FEATURE_TRAY_EDIT -# define TRAY_EDIT_ADJUST 15 -#else -# define TRAY_EDIT_ADJUST 0 -#endif - -#define PREFS_MODE_TOP 15 -#define PREFS_TOP 30 -#define DLG_TOP 39-TRAY_EDIT_ADJUST -#define DLG_HEIGHT 120+TRAY_EDIT_ADJUST -#define TIMER_TOP 85 -#define BUTTON_TOP 104+TRAY_EDIT_ADJUST - -FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_PREFS_CANCEL_BUTTON_ID -BEGIN - TITLE "Preferencias" - - GADGET ID XW_PREFS_APPWIDE_CHECKBX_ID - AT (LEFTCOL+8 PREFS_MODE_TOP 75 SERVER_HEIGHT) USABLE - GADGET ID XW_PREFS_ONEGAME_CHECKBX_ID - AT (PREVRIGHT+1 PREVTOP 50 SERVER_HEIGHT) USABLE - LIST "Del programa" "De la partida" XW_PREFS_TYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 2 NONUSABLE - - /* global prefs */ - CHECKBOX "Colorear fichas según el jugador" \ - ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID \ - AT (LEFTCOL PREFS_TOP AUTO AUTO) NONUSABLE - CHECKBOX "Mostrar la barra de progreso" \ - ID XW_PREFS_PROGRESSBAR_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - CHECKBOX "Dibujar el tablero grande" ID XW_PREFS_SHOWGRID_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - CHECKBOX "Activar cursor" ID XW_PREFS_SHOWARROW_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - CHECKBOX "Ver jugada del robot" ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+2 AUTO AUTO) NONUSABLE - - /* single-game prefs */ - CHECKBOX "El robot nunca falla" ID XW_PREFS_ROBOTSMART_CHECKBOX_ID \ - AT (LEFTCOL PREFS_TOP AUTO AUTO) NONUSABLE - CHECKBOX "Desactivar pistas" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM AUTO AUTO) NONUSABLE - - LABEL "Si no encuentra:" XW_PREFS_PHONIES_LABEL_ID AT (LEFTCOL PREVBOTTOM+2) - POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID \ - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LABEL "Tablero de: " XW_PREFS_BDSIZE_LABEL_ID \ - AT (LEFTCOL PREVBOTTOM+2) - SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR - LIST "Ignora" "Avisa" "No permite" ID XW_PREFS_PHONIES_LIST_ID \ - AT (PREVLEFT PREVTOP 72 12) NONUSABLE VISIBLEITEMS 3 - POPUPLIST XW_PREFS_PHONIES_TRIGGER_ID XW_PREFS_PHONIES_LIST_ID - - LIST "15x15" "13x13" "11x11" \ - XW_PREFS_BDSIZE_LIST_ID AT (PREVLEFT PREVTOP 30 1) \ - NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES - - CHECKBOX "Activar reloj (minutos): " ID XW_PREFS_TIMERON_CHECKBOX_ID \ - AT (LEFTCOL TIMER_TOP AUTO AUTO) NONUSABLE - FIELD XW_PREFS_TIMER_FIELD_ID PREVRIGHT+5 PREVTOP 15 AUTO UNDERLINED \ - EDITABLE SINGLELINE NUMERIC MAXCHARS 3 - -#ifdef FEATURE_TRAY_EDIT - CHECKBOX "Atril editable" ID XW_PREFS_PICKTILES_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM AUTO AUTO) NONUSABLE -#endif - - /* buttons at the bottom */ - BUTTON "Cancelar" XW_PREFS_CANCEL_BUTTON_ID 30 BUTTON_TOP AUTO AUTO - BUTTON "Aceptar" XW_PREFS_OK_BUTTON_ID PREVRIGHT+10 PREVTOP AUTO AUTO -END - -#define LEFT_EDGE 10 -FORM ID XW_DICTINFO_FORM AT (2 111 156 47) -USABLE MODAL DEFAULTBTNID XW_DICTINFO_CANCEL_BUTTON_ID -BEGIN - TITLE "Diccionarios" - - LABEL "Nombre:" AUTOID AT (LEFT_EDGE 15) - POPUPTRIGGER "" ID XW_DICTINFO_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LIST "" ID XW_DICTINFO_LIST_ID AT (PREVLEFT PREVTOP 72 1) - NONUSABLE VISIBLEITEMS 4 - POPUPLIST XW_DICTINFO_TRIGGER_ID XW_DICTINFO_LIST_ID - - BUTTON "Aceptar" XW_DICTINFO_DONE_BUTTON_ID 25 31 AUTO AUTO - BUTTON "Enviar" XW_DICTINFO_BEAM_BUTTON_ID 22 PREVTOP AUTO AUTO - BUTTON "Cancelar" XW_DICTINFO_CANCEL_BUTTON_ID PREVRIGHT+20 PREVTOP - AUTO AUTO -END - -FORM ID XW_ASK_FORM_ID AT (2 70 156 88) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_ASK_NO_BUTTON_ID -MENUID XW_ASK_MENU_ID -BEGIN - TITLE "Pregunta" - - FIELD XW_ASK_TXT_FIELD_ID LEFT_EDGE-5 16 135 52 \ - NONEDITABLE MULTIPLELINES - - SCROLLBAR ID XW_ASK_SCROLLBAR_ID - AT ( PREVRIGHT+2 PREVTOP RECOMMENDED_SBAR_WIDTH - PREVBOTTOM - PREVTOP) USABLE - - BUTTON "Aceptar" XW_ASK_YES_BUTTON_ID - RIGHT@(156/2)-10 PREVBOTTOM+5 AUTO AUTO - BUTTON "Cancelar" XW_ASK_NO_BUTTON_ID 156/2+10 PREVTOP - AUTO AUTO -END - -FORM ID XW_PASSWORD_DIALOG_ID AT ( 2 88 156 70 ) - MODAL SAVEBEHIND DEFAULTBTNID XW_PASSWORD_CANCEL_BUTTON -BEGIN - TITLE "Password" - - LABEL "Entra el password para:" XW_PASSWORD_NAME_LABEL 10 18 FONT 1 NONUSABLE - LABEL "Entra el nuevo password para:" XW_PASSWORD_NEWNAME_LABEL 10 18 FONT 1 - NONUSABLE - FIELD XW_PASSWORD_NAME_FIELD AT (PREVLEFT PREVBOTTOM+3 90 12) NONEDITABLE - SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH - FIELD XW_PASSWORD_PASS_FIELD \ - AT (PREVRIGHT+10 PREVTOP MAX_PASSWORD_LENGTH*6 12) \ - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_PASSWORD_LENGTH - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+8 - BUTTON "Aceptar" XW_PASSWORD_OK_BUTTON 45 PREVTOP AUTO AUTO - BUTTON "Cancelar" XW_PASSWORD_CANCEL_BUTTON PREVRIGHT+10 PREVTOP AUTO AUTO -END - -#define BLANK_PICK_TOP 15 - -FORM ID XW_BLANK_DIALOG_ID AT ( 2 74 156 83 ) USABLE - MODAL SAVEBEHIND -#ifdef FEATURE_TRAY_EDIT - DEFAULTBTNID XW_BLANK_PICK_BUTTON_ID -#endif -BEGIN - TITLE "Editar el atril" - - FIELD XW_BLANK_LABEL_FIELD_ID AT (10 BLANK_PICK_TOP 110 39) - NONEDITABLE MULTIPLELINES - - LIST "" ID XW_BLANK_LIST_ID AT (PREVRIGHT+2 BLANK_PICK_TOP 28 72) - USABLE VISIBLEITEMS 6 - - BUTTON "Aceptar" XW_BLANK_OK_BUTTON_ID RIGHT@PREVLEFT-5 65 40 AUTO - -#ifdef FEATURE_TRAY_EDIT - BUTTON "¡Todo!" XW_BLANK_PICK_BUTTON_ID 3 65 34 AUTO - BUTTON "Borr." XW_BLANK_BACKUP_BUTTON_ID PREVRIGHT+3 PREVTOP 29 AUTO -#endif -END - -#if defined OWNER_HASH || defined NO_REG_REQUIRED -FORM ID XW_SAVEDGAMES_DIALOG_ID AT ( 2 2 156 156 ) -USABLE MODAL DEFAULTBTNID XW_SAVEDGAMES_DONE_BUTTON -BEGIN - TITLE "Partidas" - - LIST "" ID XW_SAVEDGAMES_LIST_ID AT (2 15 140 60) \ - USABLE ENABLED VISIBLEITEMS 1 - GRAFFITISTATEINDICATOR 2 120 - FIELD XW_SAVEDGAMES_NAME_FIELD AT (PREVRIGHT+10 PREVTOP 108 AUTO) - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_GAMENAME_LENGTH - - BUTTON "Modif." XW_SAVEDGAMES_USE_BUTTON RIGHT@154 PREVTOP 30 AUTO - - BUTTON "Duplic." XW_SAVEDGAMES_DUPE_BUTTON 2 PREVBOTTOM+5 33 AUTO - BUTTON "Borrar" XW_SAVEDGAMES_DELETE_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO - BUTTON "Escoger" XW_SAVEDGAMES_OPEN_BUTTON PREVRIGHT+5 PREVTOP 37 AUTO - BUTTON "Cerrar" XW_SAVEDGAMES_DONE_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO -END -#endif - -ALERT XW_ERROR_ALERT_ID -ERROR -BEGIN - TITLE "¡Atención!" - MESSAGE "^1" - BUTTONS "De acuerdo" -END - -#ifdef FOR_GREMLINS -FORM ID XW_GREMLIN_WARN_FORM_ID AT ( 2 60 156 98 ) -USABLE MODAL -BEGIN - TITLE "Gremlin Oops" - FIELD XW_GREMLIN_WARN_FIELD_ID AT (2 15 150 75) - NONEDITABLE MULTIPLELINES -END -#endif diff --git a/xwords4/palm/l10n/xwords4_fr_FR.rcp.pre b/xwords4/palm/l10n/xwords4_fr_FR.rcp.pre deleted file mode 100644 index a000e39b5..000000000 --- a/xwords4/palm/l10n/xwords4_fr_FR.rcp.pre +++ /dev/null @@ -1,621 +0,0 @@ -/* -*-mode: c; fill-column: 78; compile-command: "cd ../ && make ARCH=68K_ONLY MEMDEBUG=TRUE LANG=fr_FR"; -*- */ -/***************************************************************************** - * Copyright 1999 - 2007 par Eric House (xwords@eehouse.org) et autres. Tous - * droits réservés. Tradtion en français par Francis H. - * - * Ce programm est libre de droits ; Vous pouvez le distribuer et/ou - * le modifier en respectant les termes de la licence GNU General Public - * ainsi qu'elle est publiée par la Free Software Foundation ; que ce soit la version 2 - * de la Licence, ou (selon votre option), toute version ultérieure. - * - * Ce programme est distribué avec l'intention qu'il soit utilisé, - * mais SANS AUCUNE GARANTIE ; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Voir la - * Licence GNU General Public pour plus de détails. - * - * Vous devriez avoir reçu une copie de la Licence GNU General Public - * avec ce programme ; si ce n'est pas le cas, écrivez à "Free Software - * Foundation", Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - ****************************************************************************/ - -#define DEFINES_ONLY 1 - -#include "xwords4defines.h" - -#define LEFTMARGIN 5 - -MENU XW_MAIN_MENU_ID -BEGIN - PULLDOWN "Fichier" - BEGIN - MENUITEM "Nouvelle partie..." XW_NEWGAME_PULLDOWN_ID "N" - MENUITEM "Parties sauvegardées..." XW_SAVEDGAMES_PULLDOWN_ID "S" - MENUITEM "Préférences..." XW_PREFS_PULLDOWN_ID "P" - MENUITEM SEPARATOR - MENUITEM "Transm. dictionnaire" XW_BEAMDICT_PULLDOWN_ID - MENUITEM "Transm. grilles et couleurs" XW_BEAMBOARD_PULLDOWN_ID -#ifdef FEATURE_DUALCHOOSE - MENUITEM SEPARATOR - MENUITEM "Ouvrir vers. 68K" XW_RUN68K_PULLDOWN_ID - MENUITEM "Ouvrir vers. ARM" XW_RUNARM_PULLDOWN_ID -#endif - MENUITEM SEPARATOR - MENUITEM "Au sujet de Crosswords..." XW_ABOUT_PULLDOWN_ID "A" - END - - PULLDOWN "Partie" - BEGIN - MENUITEM "Valeur des lettres" XW_TILEVALUES_PULLDOWN_ID "V" - MENUITEM "Lettres restantes" XW_TILESLEFT_PULLDOWN_ID "R" - MENUITEM "Info partie courante..." XW_PASSWORDS_PULLDOWN_ID "G" - MENUITEM "Historique" XW_HISTORY_PULLDOWN_ID "Y" - MENUITEM "Score final" XW_FINISH_PULLDOWN_ID "F" -#ifndef XWFEATURE_STANDALONE_ONLY - MENUITEM SEPARATOR - MENUITEM "Renvoyer" XW_RESENDIR_PULLDOWN_ID -#endif - END - PULLDOWN "Coup" - BEGIN - MENUITEM "Indice" XW_HINT_PULLDOWN_ID "I" -#ifdef XWFEATURE_SEARCHLIMIT - MENUITEM "Indice restreint" XW_HINTCONFIG_PULLDOWN_ID "C" - MENUITEM SEPARATOR -#endif - MENUITEM "Indice suivant" XW_NEXTHINT_PULLDOWN_ID "M" - MENUITEM SEPARATOR - MENUITEM "Annuler actuel" XW_UNDOCUR_PULLDOWN_ID "U" - MENUITEM "Annuler dernier" XW_UNDOLAST_PULLDOWN_ID "Z" - MENUITEM SEPARATOR - MENUITEM "Fait" XW_DONE_PULLDOWN_ID "D" - MENUITEM "Mélanger" XW_JUGGLE_PULLDOWN_ID "J" - MENUITEM "Echanger lettres" XW_TRADEIN_PULLDOWN_ID "T" - MENUITEM "[dé]Cacher tableau" XW_HIDESHOWTRAY_PULLDOWN_ID "H" - END -#ifdef FOR_GREMLINS - PULLDOWN "Grem" - BEGIN - MENUITEM "divider right" XW_GREMLIN_DIVIDER_RIGHT - MENUITEM "divider left" XW_GREMLIN_DIVIDER_LEFT - END -#endif - - -#ifndef FOR_GREMLINS -#ifdef DEBUG - PULLDOWN "DBG" - BEGIN - MENUITEM "Log to file" XW_LOGFILE_PULLDOWN_ID - MENUITEM "Log to memo" XW_LOGMEMO_PULLDOWN_ID - MENUITEM "Clear logs" XW_CLEARLOGS_PULLDOWN_ID - MENUITEM "Network stats..." XW_NETSTATS_PULLDOWN_ID -#ifdef DEBUG - MENUITEM "BT stats..." XW_BTSTATS_PULLDOWN_ID -#endif -#ifdef MEM_DEBUG - MENUITEM "Mem stats..." XW_MEMSTATS_PULLDOWN_ID -#endif - END -#endif -#endif /* FOR_GREMLINS */ - -END - -MENU XW_ASK_MENU_ID -BEGIN - PULLDOWN "Editer" - BEGIN - MENUITEM "Copier" ASK_COPY_PULLDOWN_ID - MENUITEM "Tout sélectionner" ASK_SELECTALL_PULLDOWN_ID - END -END - -#include "common.rcp.pre" /* these don't need localization */ - -#ifdef XWFEATURE_STANDALONE_ONLY -# define NPLAYERS_TOP 15 -# define FORM_TOP 34 -# define FORM_HEIGHT 124 -#else -# define SERVER_TOP 15 -# define NPLAYERS_TOP (SERVER_TOP+18) -# define FORM_TOP 16 -# define FORM_HEIGHT 142 -#endif -#define LABEL_TOP (NPLAYERS_TOP+18) -#define LEFTCOL 4 -#define REMOTE_COL LEFTCOL -#define NAME_COL 50 -#define ROBOT_COL 98 -#define PASSWD_COL RIGHT@156 - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_REMOTECHECK( num, offset ) \ - CHECKBOX "" ID XW_REMOTE_##num##_CHECKBOX_ID \ - AT (LEFTCOL PREVBOTTOM+offset AUTO AUTO) USABLE -#else -#define PLAYER_REMOTECHECK( num, offset ) -#endif - -#ifndef XWFEATURE_STANDALONE_ONLY -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (PREVRIGHT PREVTOP 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#else -#define PLAYER_NAMEFIELD( num, offset ) \ - FIELD XW_PLAYERNAME_##num##_FIELD_ID \ - AT (LEFTCOL+10 PREVBOTTOM+offset 100 AUTO ) \ - UNDERLINED EDITABLE SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH -#endif - -#define PLAYER_ROBCHECK( num, offset ) \ - CHECKBOX "" ID XW_ROBOT_##num##_CHECKBOX_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE RIGHTANCHOR - -#define PLAYER_PASSFIELD( num, offset ) \ - SELECTORTRIGGER "" XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - AT (PREVRIGHT PREVTOP 12 11) - -/* FIELD XW_PLAYERPASSWD_##num##_FIELD_ID PREVRIGHT PREVTOP 20 \ */ -/* AUTO UNDERLINED EDITABLE SINGLELINE MAXCHARS 4 */ - -#define PLAYER_ROW( num, offset ) \ - PLAYER_REMOTECHECK( num, offset ) \ - PLAYER_NAMEFIELD( num, offset ) \ - PLAYER_ROBCHECK( num, offset ) \ - PLAYER_PASSFIELD( num, offset ) - -#define PLAYER_ROW_ID( num ) \ - ID XW_REMOTE_##num##_CHECKBOX_ID \ - ID XW_PLAYERNAME_##num##_FIELD_ID \ - ID XW_ROBOT_##num##_CHECKBOX_ID \ - ID XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - -#define PLAYER_ROW_NAV( num ) \ - ROW XW_REMOTE_##num##_CHECKBOX_ID \ - ROW XW_PLAYERNAME_##num##_FIELD_ID \ - XW_ROBOT_##num##_CHECKBOX_ID \ - XW_PLAYERPASSWD_##num##_TRIGGER_ID \ - -//#define SERVER_GROUP_ID 2000 -#define SERVER_HEIGHT 12 - -FORM ID XW_NEWGAMES_FORM AT (2 FORM_TOP 156 FORM_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_OK_BUTTON_ID -BEGIN - TITLE "Options de la partie" - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "En jeu :" AUTOID AT (LEFTCOL SERVER_TOP) - GADGET ID XW_SOLO_GADGET_ID - AT (PREVRIGHT+5 SERVER_TOP 36 SERVER_HEIGHT) USABLE - GADGET ID XW_SERVER_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 31 SERVER_HEIGHT) USABLE - GADGET ID XW_CLIENT_GADGET_ID - AT (PREVRIGHT+1 SERVER_TOP 36 SERVER_HEIGHT) USABLE - LIST "Locale" "Hôte" "Invité" XW_SERVERTYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 3 NONUSABLE -#endif - -/* Pick number of players here */ - FIELD XW_TOTALP_FIELD_ID LEFTCOL NPLAYERS_TOP 58 AUTO \ - SINGLELINE NONEDITABLE MAXCHARS 16 - - SELECTORTRIGGER "" XW_NPLAYERS_SELECTOR_ID \ - AT (PREVRIGHT NPLAYERS_TOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" XW_NPLAYERS_LIST_ID AT (PREVLEFT PREVTOP 10 1) \ - VISIBLEITEMS 4 NONUSABLE - - BUTTON "J" XW_GINFO_JUGGLE_ID PREVRIGHT+3 PREVTOP 10 AUTO - - BUTTON "Autres préfs..." XW_PREFS_BUTTON_ID PREVRIGHT+5 PREVTOP 63 AUTO - -#ifndef XWFEATURE_STANDALONE_ONLY - LABEL "Effacer" XW_LOCAL_LABEL_ID REMOTE_COL LABEL_TOP FONT 1 -#endif - LABEL "Nom" AUTOID NAME_COL LABEL_TOP FONT 1 - LABEL "Robot" AUTOID ROBOT_COL LABEL_TOP FONT 1 - LABEL "MdP" AUTOID PASSWD_COL LABEL_TOP FONT 1 - - PLAYER_ROW( 1, 2 ) - PLAYER_ROW( 2, 2 ) - PLAYER_ROW( 3, 2 ) - PLAYER_ROW( 4, 2 ) - - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+10 - - SELECTORTRIGGER "Dictionnaire..." XW_DICT_SELECTOR_ID \ - AT (PREVRIGHT+8 PREVTOP AUTO AUTO) USABLE LEFTANCHOR - - BUTTON "Ok" XW_OK_BUTTON_ID RIGHT@154 PREVTOP 18 AUTO - BUTTON "Annuler" XW_CANCEL_BUTTON_ID RIGHT@PREVLEFT-5 PREVTOP 36 AUTO -END /* XW_NEWGAMES_FORM */ - -#ifdef XWFEATURE_FIVEWAY -NAVIGATION ID XW_NEWGAMES_FORM -INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState -#if 0 -BEGIN - ID XW_SOLO_GADGET_ID - ID XW_SERVER_GADGET_ID - ID XW_CLIENT_GADGET_ID - - ID XW_NPLAYERS_SELECTOR_ID - ID XW_GINFO_JUGGLE_ID - ID XW_PREFS_BUTTON_ID - - PLAYER_ROW_ID( 1 ) - PLAYER_ROW_ID( 2 ) - PLAYER_ROW_ID( 3 ) - PLAYER_ROW_ID( 4 ) - - ID XW_DICT_SELECTOR_ID - ID XW_CANCEL_BUTTON_ID - ID XW_OK_BUTTON_ID -#else -NAVIGATIONMAP -#ifndef XWFEATURE_STANDALONE_ONLY - ROW XW_SOLO_GADGET_ID - XW_SERVER_GADGET_ID - XW_CLIENT_GADGET_ID -#endif - ROW XW_NPLAYERS_SELECTOR_ID - XW_GINFO_JUGGLE_ID - XW_PREFS_BUTTON_ID - - PLAYER_ROW_NAV( 1 ) - PLAYER_ROW_NAV( 2 ) - PLAYER_ROW_NAV( 3 ) - PLAYER_ROW_NAV( 4 ) - - ROW XW_DICT_SELECTOR_ID - XW_CANCEL_BUTTON_ID - XW_OK_BUTTON_ID -#endif -END /* NAVIGATION ID XW_NEWGAMES_FORM */ -#endif - -#ifdef XWFEATURE_BLUETOOTH -/* Let's define this in one place so it stays the same */ -# define BT_CONF_STRING "Demander avant Bluetooth" -#endif - - -#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH || defined XWFEATURE_IR -#define LEFTCOL 4 -#define CONNS_FIELD_LEFT 73 -#define LOCALIP_TOP 30 - -FORM ID XW_CONNS_FORM AT (2 66 156 93) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_CONNS_CANCEL_BUTTON_ID -BEGIN - TITLE "Connexions" - - LABEL "Connecter via:" AUTOID LEFTCOL 15 FONT 1 - - POPUPTRIGGER "" ID XW_CONNS_TYPE_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LIST - "" ID XW_CONNS_TYPE_LIST_ID - PREVLEFT PREVTOP 72 12 VISIBLEITEMS 2 - NONUSABLE POPUPLIST XW_CONNS_TYPE_TRIGGER_ID XW_CONNS_TYPE_LIST_ID - -/* Bluetooth stuff must be here even if XWFEATURE_BLUETOOTH is not defined - since, e.g. ARM and 68K share these resources yet may not both support - BT */ -#ifdef XWFEATURE_BLUETOOTH - LABEL "Nom de l'hôte :" XW_CONNS_BT_HOSTNAME_LABEL_ID - AT ( LEFTCOL LOCALIP_TOP+5 ) NONUSABLE - SELECTORTRIGGER "Trouver l'hôte..." XW_CONNS_BT_HOSTTRIGGER_ID \ - AT (CONNS_FIELD_LEFT PREVTOP 70 AUTO) NONUSABLE LEFTANCHOR - CHECKBOX BT_CONF_STRING ID XW_CONNS_BTCONFIRM_CHECKBOX_ID \ - AT ( LEFTCOL LOCALIP_TOP+21 AUTO AUTO ) NONUSABLE -#endif - -/* Relay... */ -#ifdef XWFEATURE_RELAY - LABEL "Nom du réseau :" XW_CONNS_RELAY_LABEL_ID - AT ( LEFTCOL+10 LOCALIP_TOP ) - FIELD XW_CONNS_RELAY_FIELD_ID CONNS_FIELD_LEFT PREVTOP 70 AUTO \ - SINGLELINE EDITABLE UNDERLINED MAXCHARS 32 - - LABEL "Port du réseau :" XW_CONNS_PORT_LABEL_ID - AT (LEFTCOL PREVBOTTOM + 2) - FIELD XW_CONNS_PORT_FIELD_ID CONNS_FIELD_LEFT PREVTOP 30 AUTO \ - EDITABLE SINGLELINE UNDERLINED NUMERIC MAXCHARS 5 - - LABEL "Invite:" XW_CONNS_INVITE_LABEL_ID - AT ( LEFTCOL+10 PREVBOTTOM + 2 ) - FIELD XW_CONNS_INVITE_FIELD_ID CONNS_FIELD_LEFT PREVTOP 70 AUTO \ - SINGLELINE EDITABLE UNDERLINED MAXCHARS 32 -#endif - - BUTTON "Annuler" XW_CONNS_CANCEL_BUTTON_ID 42 75 AUTO AUTO - BUTTON "Ok" XW_CONNS_OK_BUTTON_ID PREVRIGHT+10 PREVTOP AUTO AUTO -END /* XW_CONNS_FORM */ -#endif - -#ifdef FEATURE_TRAY_EDIT -# define TRAY_EDIT_ADJUST 15 -#else -# define TRAY_EDIT_ADJUST 0 -#endif -#ifdef XWFEATURE_SEARCHLIMIT -# define SEARCHLIMIT_ADJUST 15 -#else -# define SEARCHLIMIT_ADJUST 0 -#endif -#ifdef XWFEATURE_BLUETOOTH -# define BTCONF_ADJUST PREFS_SPACING -#else -# define BTCONF_ADJUST 0 -#endif - -#define PREFS_MODE_TOP 15 -#define PREFS_ROW1 30 -#define PREFS_SPACING 15 - -/* #define DLG_TOP (52-TRAY_EDIT_ADJUST-SEARCHLIMIT_ADJUST) */ -#define DLG_HEIGHT (112+TRAY_EDIT_ADJUST+SEARCHLIMIT_ADJUST+BTCONF_ADJUST) -#define DLG_TOP (160 - DLG_HEIGHT - 2) -#define TIMER_TOP (74+SEARCHLIMIT_ADJUST) -#define BTCONF_TOP (TIMER_TOP+18+TRAY_EDIT_ADJUST) -#define BUTTON_TOP (BTCONF_TOP + PREFS_SPACING) -#define PREFS_LNHT 4 - -FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_PREFS_CANCEL_BUTTON_ID -BEGIN - TITLE "Préférences" - - GADGET ID XW_PREFS_ALLGAMES_GADGET_ID - AT (LEFTCOL+8 PREFS_MODE_TOP 76 SERVER_HEIGHT) USABLE - GADGET ID XW_PREFS_ONEGAME_GADGET_ID - AT (PREVRIGHT+1 PREVTOP 54 SERVER_HEIGHT) USABLE - LIST "Toutes les parties" "Cette partie" XW_PREFS_TYPES_LIST_ID - AT (0 0 1 1) VISIBLEITEMS 2 NONUSABLE - - /* global prefs */ - CHECKBOX "Lettres jouées en couleurs" ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID \ - AT (LEFTCOL PREFS_ROW1 AUTO AUTO) NONUSABLE - CHECKBOX "Montrer barre défilement" ID XW_PREFS_PROGRESSBAR_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Grande grille" ID XW_PREFS_SHOWGRID_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Activer curseur" ID XW_PREFS_SHOWARROW_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Expliquer robot/effacer scores" ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "Cacher valeurs des lettres" ID XW_PREFS_HIDETRAYVAL_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - - /* single-game prefs */ - CHECKBOX "Robot commence" ID XW_PREFS_ROBOTSMART_CHECKBOX_ID \ - AT (LEFTCOL PREFS_ROW1 AUTO AUTO) NONUSABLE -#ifdef XWFEATURE_SEARCHLIMIT - CHECKBOX "Désactiver indices" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - CHECKBOX "En local" ID XW_PREFS_HINTRECT_CHECKBOX_ID \ - AT (PREVRIGHT+3 PREVTOP AUTO AUTO) NONUSABLE -#else - CHECKBOX "Désactiver indices" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ - AT (PREVRIGHT+3 PREFS_ROW1 AUTO AUTO) NONUSABLE -#endif - - LABEL "Inconnus :" XW_PREFS_PHONIES_LABEL_ID - AT (LEFTCOL PREVTOP+PREFS_SPACING) - POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - - LABEL "Dimensions grille : " XW_PREFS_BDSIZE_LABEL_ID - AT (LEFTCOL PREVTOP+PREFS_SPACING) - SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \ - AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR - LIST "Ignorer" "Avertir" "Désactiver" ID XW_PREFS_PHONIES_LIST_ID - AT (PREVLEFT PREVTOP 72 12) NONUSABLE VISIBLEITEMS 3 - POPUPLIST XW_PREFS_PHONIES_TRIGGER_ID XW_PREFS_PHONIES_LIST_ID - - LIST "15x15" "13x13" "11x11" \ - XW_PREFS_BDSIZE_LIST_ID AT (PREVLEFT PREVTOP 30 1) \ - NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES - - CHECKBOX "Activer minuteur (minutes :)" ID XW_PREFS_TIMERON_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE - FIELD XW_PREFS_TIMER_FIELD_ID PREVRIGHT+2 PREVTOP 12 AUTO UNDERLINED \ - EDITABLE SINGLELINE NUMERIC MAXCHARS 3 - -#ifdef FEATURE_TRAY_EDIT - CHECKBOX "Choisir lettres à découvert" ID XW_PREFS_PICKTILES_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE -#endif - -#ifdef XWFEATURE_BLUETOOTH - CHECKBOX BT_CONF_STRING ID XW_PREFS_BTCONFIRM_CHECKBOX_ID \ - AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE -#endif - - /* buttons at the bottom */ - BUTTON "Annuler" XW_PREFS_CANCEL_BUTTON_ID 42 BUTTON_TOP AUTO AUTO - BUTTON "Ok" XW_PREFS_OK_BUTTON_ID PREVRIGHT+10 PREVTOP AUTO AUTO -END /* XW_PREFS_FORM */ - -NAVIGATION ID XW_PREFS_FORM -INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState -INITIALOBJECTID XW_PREFS_ONEGAME_GADGET_ID -NAVIGATIONMAP - ROW XW_PREFS_ALLGAMES_GADGET_ID - XW_PREFS_ONEGAME_GADGET_ID - - /* global prefs */ - ROW XW_PREFS_PLAYERCOLORS_CHECKBOX_ID - ROW XW_PREFS_PROGRESSBAR_CHECKBOX_ID - ROW XW_PREFS_SHOWGRID_CHECKBOX_ID - ROW XW_PREFS_SHOWARROW_CHECKBOX_ID - ROW XW_PREFS_ROBOTSCORE_CHECKBOX_ID - ROW XW_PREFS_HIDETRAYVAL_CHECKBOX_ID - - /* Per-game prefs */ - ROW XW_PREFS_ROBOTSMART_CHECKBOX_ID - ROW XW_PREFS_NOHINTS_CHECKBOX_ID -#ifdef XWFEATURE_SEARCHLIMIT - XW_PREFS_HINTRECT_CHECKBOX_ID -#endif - ROW XW_PREFS_PHONIES_TRIGGER_ID - ROW XW_PREFS_BDSIZE_SELECTOR_ID - - ROW XW_PREFS_TIMERON_CHECKBOX_ID - XW_PREFS_TIMER_FIELD_ID -#ifdef FEATURE_TRAY_EDIT - ROW XW_PREFS_PICKTILES_CHECKBOX_ID -#endif - ROW XW_PREFS_BTCONFIRM_CHECKBOX_ID - - /* cmd buttons */ - ROW XW_PREFS_CANCEL_BUTTON_ID - XW_PREFS_OK_BUTTON_ID -END - -#define LEFT_EDGE 10 -FORM ID XW_DICTINFO_FORM AT (2 111 156 47) -USABLE MODAL DEFAULTBTNID XW_DICTINFO_CANCEL_BUTTON_ID -BEGIN - TITLE "Dictionnaires" - - LABEL "Dict. :" AUTOID AT (LEFT_EDGE 15) - POPUPTRIGGER "" ID XW_DICTINFO_TRIGGER_ID - AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR - LIST "" ID XW_DICTINFO_LIST_ID AT (PREVLEFT PREVTOP 72 1) - NONUSABLE VISIBLEITEMS 4 - POPUPLIST XW_DICTINFO_TRIGGER_ID XW_DICTINFO_LIST_ID - - BUTTON "Ok" XW_DICTINFO_DONE_BUTTON_ID 25 31 AUTO AUTO - BUTTON "Transm." XW_DICTINFO_BEAM_BUTTON_ID 22 PREVTOP AUTO AUTO - BUTTON "Annuler" XW_DICTINFO_CANCEL_BUTTON_ID PREVRIGHT+20 PREVTOP - AUTO AUTO -END - -FORM ID XW_ASK_FORM_ID AT (2 70 156 88) -USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_ASK_NO_BUTTON_ID -MENUID XW_ASK_MENU_ID -BEGIN - TITLE "Requête" - - /* This has to be non-editable because the field is set via a ptr */ - FIELD XW_ASK_TXT_FIELD_ID LEFT_EDGE-5 16 135 52 \ - NONEDITABLE MULTIPLELINES - - SCROLLBAR ID XW_ASK_SCROLLBAR_ID - AT ( PREVRIGHT+2 PREVTOP RECOMMENDED_SBAR_WIDTH - PREVBOTTOM - PREVTOP) USABLE - - BUTTON "Oui" XW_ASK_YES_BUTTON_ID RIGHT@(156/2)-20 PREVBOTTOM+5 AUTO AUTO - BUTTON "Non" XW_ASK_NO_BUTTON_ID 156/2+20 PREVTOP AUTO AUTO -END - -FORM ID XW_PASSWORD_DIALOG_ID AT ( 2 88 156 70 ) - MODAL SAVEBEHIND DEFAULTBTNID XW_PASSWORD_CANCEL_BUTTON -BEGIN - TITLE "Mot de Passe" - - LABEL "Entrer mot de passe pour :" XW_PASSWORD_NAME_LABEL 10 18 FONT 1 NONUSABLE - LABEL "Entrer nouveau mot de passe pour :" XW_PASSWORD_NEWNAME_LABEL 10 18 FONT 1 - NONUSABLE - FIELD XW_PASSWORD_NAME_FIELD AT (PREVLEFT PREVBOTTOM+3 90 12) NONEDITABLE - SINGLELINE MAXCHARS MAX_PLAYERNAME_LENGTH - FIELD XW_PASSWORD_PASS_FIELD \ - AT (PREVRIGHT+10 PREVTOP MAX_PASSWORD_LENGTH*6 12) \ - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_PASSWORD_LENGTH - GRAFFITISTATEINDICATOR 2 PREVBOTTOM+8 - BUTTON "Ok" XW_PASSWORD_OK_BUTTON 45 PREVTOP AUTO AUTO - BUTTON "Annuler" XW_PASSWORD_CANCEL_BUTTON PREVRIGHT+10 PREVTOP AUTO AUTO -END - -#define BLANK_PICK_TOP 15 - -FORM ID XW_BLANK_DIALOG_ID AT ( 2 74 156 83 ) USABLE - MODAL SAVEBEHIND -#ifdef FEATURE_TRAY_EDIT - DEFAULTBTNID XW_BLANK_PICK_BUTTON_ID -#endif -BEGIN - TITLE "Tirage des lettres" - - FIELD XW_BLANK_LABEL_FIELD_ID AT (10 BLANK_PICK_TOP 110 39) - NONEDITABLE MULTIPLELINES - - LIST "" ID XW_BLANK_LIST_ID AT (PREVRIGHT+2 BLANK_PICK_TOP 28 72) - USABLE VISIBLEITEMS 6 - - BUTTON "Ok" XW_BLANK_OK_BUTTON_ID RIGHT@PREVLEFT-4 65 16 AUTO - -#ifdef FEATURE_TRAY_EDIT - BUTTON "Choisir toutes !" XW_BLANK_PICK_BUTTON_ID 5 65 62 AUTO - BUTTON "Suppr." XW_BLANK_BACKUP_BUTTON_ID PREVRIGHT+4 PREVTOP 28 AUTO -#endif -END - -#ifdef XWFEATURE_SEARCHLIMIT -# define NTILES_TOP 17 -# define NTILES_BUTTON_TOP 60 -FORM ID XW_HINTCONFIG_FORM_ID AT ( 2 75 156 82 ) USABLE MODAL SAVEBEHIND -BEGIN - TITLE "Paramètres de l'aide" - - LABEL "Au moins ce nb de lettres :" AUTOID 10 NTILES_TOP FONT 1 USABLE - SELECTORTRIGGER "" XW_HINTCONFIG_MINSELECTOR_ID \ - AT (PREVRIGHT+3 NTILES_TOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" "5" "6" "7" ID XW_HINTCONFIG_MINLIST_ID - AT (PREVRIGHT PREVTOP AUTO AUTO) VISIBLEITEMS 7 NONUSABLE - - LABEL "Pas plus que ce nombre :" AUTOID 10 PREVTOP+15 FONT 1 USABLE - SELECTORTRIGGER "" XW_HINTCONFIG_MAXSELECTOR_ID \ - AT (PREVRIGHT+3 PREVTOP AUTO AUTO) USABLE LEFTANCHOR - LIST "1" "2" "3" "4" "5" "6" "7" ID XW_HINTCONFIG_MAXLIST_ID - AT (PREVRIGHT PREVTOP AUTO AUTO) VISIBLEITEMS 7 NONUSABLE - - BUTTON "Ok" XW_HINTCONFIG_OK_ID RIGHT@156-10 NTILES_BUTTON_TOP AUTO 12 - BUTTON "Annuler" XW_HINTCONFIG_CANCEL_ID RIGHT@PREVLEFT-10 PREVTOP AUTO 12 -END -#endif - -#if defined OWNER_HASH || defined NO_REG_REQUIRED -FORM ID XW_SAVEDGAMES_DIALOG_ID AT ( 2 2 156 156 ) -USABLE MODAL DEFAULTBTNID XW_SAVEDGAMES_DONE_BUTTON -BEGIN - TITLE "Parties sauvegardées" - - LIST "" ID XW_SAVEDGAMES_LIST_ID AT (2 15 140 60) \ - USABLE ENABLED VISIBLEITEMS 1 - GRAFFITISTATEINDICATOR 2 120 - FIELD XW_SAVEDGAMES_NAME_FIELD AT (PREVRIGHT+10 PREVTOP 100 AUTO) - EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_GAMENAME_LENGTH - - BUTTON "Modif." XW_SAVEDGAMES_USE_BUTTON RIGHT@154 PREVTOP 30 AUTO - - BUTTON "Dupl." XW_SAVEDGAMES_DUPE_BUTTON 2 PREVBOTTOM+5 31 AUTO - BUTTON "Suppr." XW_SAVEDGAMES_DELETE_BUTTON PREVRIGHT+5 PREVTOP 39 AUTO - BUTTON "Ouvrir" XW_SAVEDGAMES_OPEN_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO - BUTTON "Fait" XW_SAVEDGAMES_DONE_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO -END /* XW_SAVEDGAMES_DIALOG_ID */ -#endif - -ALERT XW_ERROR_ALERT_ID -ERROR -BEGIN - TITLE "Erreur" - MESSAGE "^1" - BUTTONS "Ok" -END - -#ifdef FOR_GREMLINS - -FORM ID XW_GREMLIN_WARN_FORM_ID AT ( 2 60 156 98 ) -USABLE MODAL -BEGIN - TITLE "Gremlin Oops" - FIELD XW_GREMLIN_WARN_FIELD_ID AT (2 15 150 75) - NONEDITABLE MULTIPLELINES -END - -#endif diff --git a/xwords4/palm/ldscript.arm b/xwords4/palm/ldscript.arm deleted file mode 100644 index a374631c5..000000000 --- a/xwords4/palm/ldscript.arm +++ /dev/null @@ -1,8 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(ArmletEntryPoint) -SEARCH_DIR(/usr/local/arm-elf/lib); -SECTIONS -{ -.text 0x00000000 : { *(.text) *(.rodata) *(.rodata.str1.4) } -} diff --git a/xwords4/palm/newgame.c b/xwords4/palm/newgame.c deleted file mode 100644 index ce5efd856..000000000 --- a/xwords4/palm/newgame.c +++ /dev/null @@ -1,721 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2009 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 -#include -#include -#include /* for nextFieldChr */ -#include /* for GrfSetState */ -#include -#ifdef XWFEATURE_FIVEWAY -# include -#endif - -#include "callback.h" -#include "comtypes.h" -#include "palmmain.h" -#include "comms.h" -#include "strutils.h" -#include "newgame.h" -#include "xwords4defines.h" -#include "dictui.h" -#include "palmdict.h" -#include "palmutil.h" -#include "palmir.h" -#include "prefsdlg.h" -#include "connsdlg.h" -#include "LocalizedStrIncludes.h" - -static void handlePasswordTrigger( PalmAppGlobals* globals, - UInt16 controlID ); -static XP_Bool updatePlayerInfo( PalmAppGlobals* globals ); -static void loadNewGameState( PalmAppGlobals* globals ); -static void unloadNewGameState( PalmAppGlobals* globals ); -static void setNameThatFits( PalmNewGameState* state ); - -static void palmEnableColProc( void* closure, XP_U16 player, - NewGameColumn col, XP_TriEnable enable ); -static void palmEnableAttrProc( void* closure, NewGameAttr attr, - XP_TriEnable enable ); -static void palmGetColProc( void* closure, XP_U16 player, NewGameColumn col, - NgCpCallbk cpcb, const void* cbClosure ); -static void palmSetColProc( void* closure, XP_U16 player, NewGameColumn col, - const NGValue value ); -static void palmSetAttrProc( void* closure, NewGameAttr attr, - const NGValue value ); -static void handleRobotChanged( PalmNewGameState* state, XP_U16 controlID, - XP_Bool on ); - -#ifndef XWFEATURE_STANDALONE_ONLY -static void handleRemoteChanged( PalmNewGameState* state, XP_U16 controlID, - XP_Bool on ); -static Boolean checkHiliteGadget(PalmAppGlobals* globals, - const EventType* event, - PalmNewGameState* state ); -static void drawConnectGadgets( PalmAppGlobals* globals ); -static void changeGadgetHilite( PalmAppGlobals* globals, UInt16 hiliteID ); - -#else -# define checkHiliteGadget(globals, event, state) XP_FALSE -# define drawConnectGadgets( globals ) -#endif - -/***************************************************************************** - * - ****************************************************************************/ -Boolean -newGameHandleEvent( EventPtr event ) -{ - Boolean result = false; - PalmAppGlobals* globals; - FormPtr form; - CurGameInfo* gi; - PalmNewGameState* state; - Int16 chosen; - XP_S16 itemId; - Boolean on; - - CALLBACK_PROLOGUE(); - - globals = getFormRefcon(); - gi = &globals->gameInfo; - state = &globals->newGameState; - - switch ( event->eType ) { - - case frmOpenEvent: - - GlobalPrefsToLocal( globals ); - - form = FrmGetActiveForm(); - - XP_ASSERT( !state->ngc ); - XP_MEMSET( state, 0, sizeof(*state) ); - - state->form = form; - - loadNewGameState( globals ); - if ( !globals->isNewGame ) { - disOrEnableTri( form, XW_DICT_SELECTOR_ID, TRI_ENAB_DISABLED ); - } - - XP_ASSERT( !!state->dictName ); - setNameThatFits( state ); - - XP_ASSERT( !!globals->game.server ); - case frmUpdateEvent: - GrfSetState( false, false, false ); - FrmDrawForm( FrmGetActiveForm() ); - - drawConnectGadgets( globals ); - - result = true; - break; - -#ifdef XWFEATURE_FIVEWAY - /* docs say to return HANDLED for both take and lost if the right - object */ - case frmObjectFocusTakeEvent: - case frmObjectFocusLostEvent: - result = considerGadgetFocus( globals, event, XW_SOLO_GADGET_ID, - XW_CLIENT_GADGET_ID ); - break; -#endif - - case penDownEvent: - result = checkHiliteGadget( globals, event, state ); - break; - -#ifdef XWFEATURE_FIVEWAY - case keyDownEvent: - itemId = getFocusOwner(); - if ( itemId >= 0 ) { - result = tryRockerKey( event->data.keyDown.chr, itemId, - XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID ); - if ( result ) { - changeGadgetHilite( globals, itemId ); - } - } - break; -#endif - - case prefsChangedEvent: - state->forwardChange = true; - break; - - case ctlSelectEvent: - result = true; - itemId = event->data.ctlSelect.controlID; - on = event->data.ctlSelect.on; - switch ( itemId ) { - - case XW_ROBOT_1_CHECKBOX_ID: - case XW_ROBOT_2_CHECKBOX_ID: - case XW_ROBOT_3_CHECKBOX_ID: - case XW_ROBOT_4_CHECKBOX_ID: - handleRobotChanged( state, itemId, on ); - break; -#ifndef XWFEATURE_STANDALONE_ONLY - case XW_REMOTE_1_CHECKBOX_ID: - case XW_REMOTE_2_CHECKBOX_ID: - case XW_REMOTE_3_CHECKBOX_ID: - case XW_REMOTE_4_CHECKBOX_ID: - handleRemoteChanged( state, itemId, on ); - break; -#endif - - case XW_NPLAYERS_SELECTOR_ID: - XP_ASSERT( globals->isNewGame ); - chosen = LstPopupList( state->playerNumList ); - if ( chosen >= 0 ) { - NGValue value; - setSelectorFromList( XW_NPLAYERS_SELECTOR_ID, - state->playerNumList, - chosen ); - value.ng_u16 = chosen + 1; - newg_attrChanged( state->ngc, NG_ATTR_NPLAYERS, value ); - } - break; - - case XW_DICT_SELECTOR_ID: - XP_ASSERT( globals->isNewGame ); - globals->dictuiForBeaming = false; - FrmPopupForm( XW_DICTINFO_FORM ); - - /* popup dict selection dialog -- or maybe just a list if there - are no preferences to set. The results should all be - cancellable, so don't delete the existing dictionary (if - any) until OK is chosen */ - break; - - case XW_GINFO_JUGGLE_ID: - while ( !newg_juggle( state->ngc ) ) { - } - (void)newg_juggle( state->ngc ); - break; - - case XW_OK_BUTTON_ID: - if ( updatePlayerInfo( globals ) ) { - /* if we put up the prefs form from within this one and the user - clicked ok, we need to make sure the main form gets the - notification so it can make use of any changes. This event - needs to arrive before the newGame event so any changes will - be incorporated. */ - if ( state->forwardChange ) { - postEmptyEvent( prefsChangedEvent ); - state->forwardChange = false; - } - - if ( globals->isNewGame ) { - postEmptyEvent( newGameOkEvent ); - globals->postponeDraw = true; - } - - unloadNewGameState( globals ); - - FrmReturnToForm( 0 ); - } - break; - - case XW_CANCEL_BUTTON_ID: - unloadNewGameState( globals ); - postEmptyEvent( newGameCancelEvent ); - FrmReturnToForm( 0 ); - break; - - case XW_PREFS_BUTTON_ID: - /* bring up with the this-game tab selected */ - XP_ASSERT( !!globals->prefsDlgState ); - globals->prefsDlgState->stateTypeIsGlobal = false; - FrmPopupForm( XW_PREFS_FORM ); - break; - - case XW_PLAYERPASSWD_1_TRIGGER_ID: - case XW_PLAYERPASSWD_2_TRIGGER_ID: - case XW_PLAYERPASSWD_3_TRIGGER_ID: - case XW_PLAYERPASSWD_4_TRIGGER_ID: - handlePasswordTrigger( globals, itemId ); - break; - - default: /* one of the password selectors? */ - result = false; - } - break; - - case dictSelectedEvent: - /* posted by the form we raise when user clicks Dictionary selector - above. */ - if ( state->dictName != NULL ) { - XP_FREE( globals->mpool, state->dictName ); - } - state->dictName = - ((DictSelectedData*)&event->data.generic)->dictName; - setNameThatFits( state ); - break; - - case appStopEvent: /* I get these on older palms */ - unloadNewGameState( globals ); - result = false; - - default: - break; - } - - CALLBACK_EPILOGUE(); - return result; -} /* newGameHandleEvent */ - -static void -setNameThatFits( PalmNewGameState* state ) -{ - RectangleType rect; - XP_U16 width; - XP_U16 len = XP_STRLEN( (const char*)state->dictName ); - - XP_MEMCPY( state->shortDictName, state->dictName, len + 1 ); - - /* The width available is the cancel button's left minus ours */ - getObjectBounds( XW_CANCEL_BUTTON_ID, &rect ); - width = rect.topLeft.x; - getObjectBounds( XW_DICT_SELECTOR_ID, &rect ); - width -= (rect.topLeft.x + 6); - - for ( ; FntCharsWidth( (const char*)state->dictName, len ) > width; --len ) { - /* do nothing */ - } - - state->shortDictName[len] = '\0'; - CtlSetLabel( getActiveObjectPtr( XW_DICT_SELECTOR_ID ), - (const char*)state->shortDictName ); -} /* setNameThatFits */ - -/* - * Copy the local state into global state. - */ -static XP_Bool -updatePlayerInfo( PalmAppGlobals* globals ) -{ - CurGameInfo* gi; - PalmNewGameState* state = &globals->newGameState; - XP_Bool success; - - gi = &globals->gameInfo; - success = newg_store( state->ngc, gi, XP_TRUE ); - if ( success ) { - gi->boardSize = globals->prefsDlgState->curBdSize; - - replaceStringIfDifferent( globals->mpool, &gi->dictName, - globals->newGameState.dictName ); - } - return success; -} /* updatePlayerInfo */ - -/* Frame 'em, draw their text, and highlight the one that's selected - */ -#ifndef XWFEATURE_STANDALONE_ONLY - -static void -drawConnectGadgets( PalmAppGlobals* globals ) -{ - XP_U16 hiliteItem = globals->newGameState.curServerHilite - + XW_SOLO_GADGET_ID ; - ListPtr list = getActiveObjectPtr( XW_SERVERTYPES_LIST_ID ); - XP_ASSERT( !!list ); - - drawGadgetsFromList( list, XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID, - hiliteItem ); -#ifdef XWFEATURE_FIVEWAY - drawFocusRingOnGadget( globals, XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID ); -#endif -} /* drawConnectGadgets */ - -static void -changeGadgetHilite( PalmAppGlobals* globals, UInt16 hiliteID ) -{ - PalmNewGameState* state = &globals->newGameState; - XP_Bool isNewGame = globals->isNewGame; - - hiliteID -= XW_SOLO_GADGET_ID; - - if ( hiliteID != state->curServerHilite ) { - /* if it's not a new game, don't recognize the change */ - if ( isNewGame ) { - NGValue value; - - state->curServerHilite = hiliteID; - drawConnectGadgets( globals ); - - value.ng_role = hiliteID; - newg_attrChanged( state->ngc, NG_ATTR_ROLE, value ); - } else { - beep(); - } - } - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - /* Even if it didn't change, pop the connections form. It's only - informational in the non-new-game case; nothing can be changed. */ - if ( hiliteID != SERVER_STANDALONE ) { - if ( isNewGame || (hiliteID==globals->newGameState.curServerHilite) ) { - PopupConnsForm( globals, hiliteID, &state->addr ); - } - } -#endif -} /* changeGadgetHilite */ - -static Boolean -checkHiliteGadget( PalmAppGlobals* globals, const EventType* event, - PalmNewGameState* XP_UNUSED_DBG(state) ) -{ - Boolean result = false; - UInt16 selGadget; - - XP_ASSERT( &globals->newGameState == state ); - - result = penInGadget( event, &selGadget ); - if ( result ) { - changeGadgetHilite( globals, selGadget ); - } - - return result; -} /* checkHiliteGadget */ -#endif - -static void -showMaskedPwd( XP_U16 objectID, XP_Bool set ) -{ - const char* label = set? "*" : " "; - /* control owns the string passed in */ - CtlSetLabel( getActiveObjectPtr( objectID ), label ); -} - -/* If there's currently no password set, just let 'em set one. If there is - * one set, they need to know the old before setting the new. - */ -static void -handlePasswordTrigger( PalmAppGlobals* globals, UInt16 controlID ) -{ - UInt16 playerNum; - PalmNewGameState* state = &globals->newGameState; - XP_UCHAR* name; - FieldPtr nameField; - XP_U16 len; - - playerNum = (controlID - XW_PLAYERPASSWD_1_TRIGGER_ID) / NUM_PLAYER_COLS; - XP_ASSERT( playerNum < MAX_NUM_PLAYERS ); - - nameField = getActiveObjectPtr( XW_PLAYERNAME_1_FIELD_ID + - (NUM_PLAYER_COLS * playerNum) ); - name = (XP_UCHAR*)FldGetTextPtr( nameField ); - - len = sizeof(state->passwds[playerNum]); - if ( askPassword( globals, name, true, state->passwds[playerNum], &len )) { - showMaskedPwd( controlID, len > 0 ); - } -} /* handlePasswordTrigger */ - -static void -unloadNewGameState( PalmAppGlobals* globals ) -{ - PalmNewGameState* state = &globals->newGameState; - - XP_FREE( globals->mpool, state->dictName ); - state->dictName = NULL; - - newg_destroy( state->ngc ); - state->ngc = NULL; -} /* unloadNewGameState */ - -static XP_U16 -getBaseForCol( NewGameColumn col ) -{ - XP_U16 resID = 0; - switch ( col ) { -#ifndef XWFEATURE_STANDALONE_ONLY - case NG_COL_REMOTE: - resID = XW_REMOTE_1_CHECKBOX_ID; - break; -#endif - case NG_COL_NAME: - resID = XW_PLAYERNAME_1_FIELD_ID; - break; - case NG_COL_ROBOT: - resID = XW_ROBOT_1_CHECKBOX_ID; - break; - case NG_COL_PASSWD: - resID = XW_PLAYERPASSWD_1_TRIGGER_ID; - break; - default: - XP_ASSERT( XP_FALSE ); - } - XP_ASSERT( !!resID ); - return resID; -} /* getBaseForCol */ - -static XP_U16 -objIDForCol( XP_U16 player, NewGameColumn col ) -{ - XP_U16 base = getBaseForCol( col ); - return base + (NUM_PLAYER_COLS * player); -} - -static ControlPtr -getControlForCol( XP_U16 player, NewGameColumn col ) -{ - XP_U16 objID = objIDForCol( player, col ); - ControlPtr ctrl = getActiveObjectPtr( objID ); - return ctrl; -} - -static void -palmEnableColProc( void* closure, XP_U16 player, NewGameColumn col, - XP_TriEnable enable ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - PalmNewGameState* state = &globals->newGameState; - XP_U16 objID; - - /* If it's a field, there need to be three states */ - objID = objIDForCol( player, col ); - disOrEnableTri( state->form, objID, enable ); -} - -/* Palm doesn't really do "disabled." Things are visible or not. But we - * want the player count dropdown in particular visible since it give - * information. So different objects get treated differently. The code - * handling ctlEnterEvent can disable for non-newgame dialogs even if a - * control is technically enabled. - */ -static void -palmEnableAttrProc(void* closure, NewGameAttr attr, XP_TriEnable ngEnable ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - PalmNewGameState* state = &globals->newGameState; - XP_U16 objID = 0; - - switch ( attr ) { -#ifndef XWFEATURE_STANDALONE_ONLY - case NG_ATTR_ROLE: - /* always enabled */ - break; - case NG_ATTR_REMHEADER: - objID = XW_LOCAL_LABEL_ID; - break; - case NG_ATTR_CANCONFIG: /* not needed on palm */ - break; -#endif - case NG_ATTR_NPLAYERS: - objID = XW_NPLAYERS_SELECTOR_ID; - break; - case NG_ATTR_NPLAYHEADER: - break; - case NG_ATTR_CANJUGGLE: - objID = XW_GINFO_JUGGLE_ID; - break; - } - - if ( objID != 0 ) { - disOrEnableTri( state->form, objID, ngEnable ); - } -} /* palmEnableAttrProc */ - -static void -palmGetColProc( void* closure, XP_U16 player, NewGameColumn col, - NgCpCallbk cpcb, const void* cbClosure ) -{ - PalmAppGlobals* globals; - PalmNewGameState* state; - NGValue value; - XP_U16 objID = objIDForCol( player, col ); - - switch ( col ) { -#ifndef XWFEATURE_STANDALONE_ONLY - case NG_COL_REMOTE: -#endif - case NG_COL_ROBOT: - value.ng_bool = getBooleanCtrl( objID ); - break; - case NG_COL_NAME: - value.ng_cp = FldGetTextPtr( getActiveObjectPtr( objID ) ); - break; - case NG_COL_PASSWD: - globals = (PalmAppGlobals*)closure; - state = &globals->newGameState; - value.ng_cp = state->passwds[player]; - break; - default: - XP_ASSERT(0); - } - - (*cpcb)( value, cbClosure ); -} - -static void -palmSetColProc( void* closure, XP_U16 player, NewGameColumn col, - const NGValue value ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - PalmNewGameState* state = &globals->newGameState; - ControlPtr ctrl; - XP_U16 objID = objIDForCol( player, col ); - - switch ( col ) { -#ifndef XWFEATURE_STANDALONE_ONLY - case NG_COL_REMOTE: -#endif - case NG_COL_ROBOT: - ctrl = getControlForCol( player, col ); - CtlSetValue( ctrl, value.ng_bool ); - break; - case NG_COL_NAME: - setFieldStr( objID, value.ng_cp ); - break; - case NG_COL_PASSWD: - if ( !!value.ng_cp ) { - XP_SNPRINTF( state->passwds[player], sizeof(state->passwds[player]), - "%s", value.ng_cp ); - showMaskedPwd( objID, *value.ng_cp != '\0' ); - } - - default: /* shut up compiler */ - break; - } -} /* palmSetColProc */ - -static void -palmSetAttrProc( void* closure, NewGameAttr attr, const NGValue value ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - PalmNewGameState* state = &globals->newGameState; - - switch ( attr ) { -#ifndef XWFEATURE_STANDALONE_ONLY - case NG_ATTR_ROLE: - state->curServerHilite = value.ng_role; - break; - case NG_ATTR_REMHEADER: - break; -#endif - case NG_ATTR_NPLAYERS: - setSelectorFromList( XW_NPLAYERS_SELECTOR_ID, - state->playerNumList, value.ng_u16 - 1 ); - break; - case NG_ATTR_NPLAYHEADER: { - FieldPtr field = getActiveObjectPtr( XW_TOTALP_FIELD_ID ); - char* cur = FldGetTextPtr( field ); - /* Need to update to get it drawn and that flashes the whole dialog. - So avoid if possible. */ - if ( !cur || (0 != StrCompare( cur, value.ng_cp ) ) ) { - FldSetTextPtr( field, (char*)value.ng_cp ); - FrmUpdateForm( 0, frmRedrawUpdateCode ); - } - } - break; - case NG_ATTR_CANJUGGLE: - XP_ASSERT(0); /* doesn't make sense */ - case NG_ATTR_CANCONFIG: /* not needed on palm */ - break; - } -} /* palmSetAttrProc */ - -static XP_U16 -palmPlayerFromID( XP_U16 id, XP_U16 base ) -{ - XP_U16 player; - player = (id - base) / NUM_PLAYER_COLS; - return player; -} /* palmPlayerFromID */ - -static void -handleRobotChanged( PalmNewGameState* state, XP_U16 controlID, XP_Bool on ) -{ - XP_U16 player; - NGValue value; - - player = palmPlayerFromID( controlID, XW_ROBOT_1_CHECKBOX_ID ); - value.ng_bool = on; - newg_colChanged( state->ngc, player ); -} - -#ifndef XWFEATURE_STANDALONE_ONLY -static void -handleRemoteChanged( PalmNewGameState* state, XP_U16 controlID, XP_Bool on ) -{ - XP_U16 player; - NGValue value; - - XP_LOGF( "%s: controlID=%d", __func__, controlID ); - - player = palmPlayerFromID( controlID, XW_REMOTE_1_CHECKBOX_ID ); - value.ng_bool = on; - newg_colChanged( state->ngc, player ); -} -#endif - -XP_U16 -countXPorts( const PalmAppGlobals* globals ) -{ - XP_U16 xports = 0; -#ifdef XWFEATURE_IR - ++xports; -#endif -#ifdef XWFEATURE_BLUETOOTH - if ( globals->hasBTLib ) { - ++xports; - } -#endif -#ifdef XWFEATURE_RELAY - ++xports; -#endif - return xports; -} - -static void -loadNewGameState( PalmAppGlobals* globals ) -{ - CurGameInfo* gi = &globals->gameInfo; - PalmNewGameState* state = &globals->newGameState; - - state->dictName = copyString( globals->mpool, gi->dictName ); - state->playerNumList = getActiveObjectPtr( XW_NPLAYERS_LIST_ID ); - state->nXPorts = countXPorts( globals ); - - XP_ASSERT( !state->ngc ); - state->ngc = newg_make( MPPARM(globals->mpool) - globals->isNewGame, - &globals->util, - palmEnableColProc, - palmEnableAttrProc, - palmGetColProc, - palmSetColProc, - palmSetAttrProc, - globals ); - newg_load( state->ngc, gi ); - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - if ( globals->game.comms ) { - comms_getAddr( globals->game.comms, &state->addr ); - } else { - comms_getInitialAddr( &state->addr ); - } -#elif defined XWFEATURE_IR - state->addr.conType = COMMS_CONN_IR; -#endif -} /* loadNewGameState */ diff --git a/xwords4/palm/newgame.h b/xwords4/palm/newgame.h deleted file mode 100644 index b2dc9f0dd..000000000 --- a/xwords4/palm/newgame.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2001-2002 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 NEWGAME_H -#define NEWGAME_H - -#include - -#include "palmmain.h" - - -Boolean newGameHandleEvent( EventPtr event ); - -#endif diff --git a/xwords4/palm/pace_man.c b/xwords4/palm/pace_man.c deleted file mode 100644 index e5d136ae9..000000000 --- a/xwords4/palm/pace_man.c +++ /dev/null @@ -1,1432 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make ARCH=ARM_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 2004-2007 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 -#include -#include -#include - -#ifdef XWFEATURE_BLUETOOTH -#include -#include -#endif - -#include "pace_man.h" - -#include "palmmain.h" /* for custom event types */ -#include "palmsavg.h" -#include "strutils.h" - -/* Looks like I still need this??? */ -void* -memcpy( void* dest, const void* src, unsigned long n ) -{ - void* oldDest = dest; - unsigned char* d = (unsigned char*)dest; - unsigned char* s = (unsigned char*)src; - - FUNC_HEADER(memcpy); - - if ( dest < src ) { - while ( n-- > 0 ) { - *d++ = *s++; - } - } else { - d += n; - s += n; - while ( n-- > 0 ) { - *--d = *--s; - } - } - - FUNC_TAIL(memcpy); - return oldDest; -} /* memcpy */ - -unsigned long -Byte_Swap32( unsigned long l ) -{ - unsigned long result; - result = ((l >> 24) & 0xFF); - result |= ((l >> 8) & 0xFF00); - result |= ((l << 8) & 0xFF0000); - result |= ((l << 24) & 0xFF000000); - return result; -} - -unsigned short -Byte_Swap16( unsigned short l ) -{ - unsigned short result; - result = ((l >> 8) & 0xFF); - result |= ((l << 8) & 0xFF00); - return result; -} - -void -write_unaligned32( unsigned char* dest, unsigned long val ) -{ - int i; - dest += sizeof(val); - for ( i = 0; i < sizeof(val); ++i ) { - *--dest = val & 0x000000FF; - val >>= 8; - } -} /* write_unaligned32 */ - -void -write_unaligned16( unsigned char* dest, unsigned short val ) -{ - int i; - - dest += sizeof(val); - for ( i = 0; i < sizeof(val); ++i ) { - *--dest = val & 0x00FF; - val >>= 8; - } -} /* write_unaligned16 */ - -#define write_unaligned8( p, v ) *(p) = v - -unsigned short -read_unaligned16( const unsigned char* src ) -{ - int i; - unsigned short val = 0; - - for ( i = 0; i < sizeof(val); ++i ) { - val <<= 8; - val |= *src++; - } - - return val; -} /* read_unaligned16 */ - -#define read_unaligned8(cp) (*(cp)) - -unsigned long -read_unaligned32( const unsigned char* src ) -{ - int i; - unsigned long val = 0; - - for ( i = 0; i < sizeof(val); ++i ) { - val <<= 8; - val |= *src++; - } - - return val; -} /* read_unaligned32 */ - -#ifdef XWFEATURE_FIVEWAY -#include "pnostate.h" -Err -HsNavDrawFocusRing (FormType* formP, UInt16 objectID, Int16 extraInfo, - RectangleType* rP, - HsNavFocusRingStyleEnum ringStyle, Boolean forceRestore) -{ - Err result; - FUNC_HEADER(HsNavDrawFocusRing); - - RectangleType RectangleType_68K1; - SWAP_RECTANGLETYPE_ARM_TO_68K( &RectangleType_68K1, rP ); - { - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 18); - - ADD_TO_STACK2(stack, hsSelNavDrawFocusRing, 0); - ADD_TO_STACK4(stack, formP, 2); - ADD_TO_STACK2(stack, objectID, 6); - ADD_TO_STACK2(stack, extraInfo, 8); - ADD_TO_STACK4(stack, &RectangleType_68K1, 10); - ADD_TO_STACK1(stack, ringStyle, 14); - ADD_TO_STACK1(stack, forceRestore, 16); - STACK_END(stack); - - result = (Err)(*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapHsSelector), - stack, 18 ); - sp->emulStateP->regA[7] -= 2; - } - FUNC_TAIL(HsNavDrawFocusRing); - return result; -} - -Err -FrmNavDrawFocusRing(FormType* formP, UInt16 objectID, Int16 extraInfo, - RectangleType* rP, - HsNavFocusRingStyleEnum ringStyle, Boolean forceRestore) -{ - Err result; - FUNC_HEADER(FrmNavDrawFocusRing); - - RectangleType RectangleType_68K1; - SWAP_RECTANGLETYPE_ARM_TO_68K( &RectangleType_68K1, rP ); - { - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 18); - - ADD_TO_STACK2(stack, 0x0007, 0); - ADD_TO_STACK4(stack, formP, 2); - ADD_TO_STACK2(stack, objectID, 6); - ADD_TO_STACK2(stack, extraInfo, 8); - ADD_TO_STACK4(stack, &RectangleType_68K1, 10); - ADD_TO_STACK1(stack, ringStyle, 14); - ADD_TO_STACK1(stack, forceRestore, 16); - STACK_END(stack); - - result = (Err)(*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapNavSelector), - stack, 18 ); - sp->emulStateP->regA[7] -= 2; - } - FUNC_TAIL(FrmNavDrawFocusRing); - return result; -} -#endif - -/* Need to parse the format string */ -Int16 -StrPrintF( Char* s, const Char* formatStr, ... ) -{ - unsigned long* inArgs = ((unsigned long*)&formatStr) + 1; - - return StrVPrintF( s, formatStr, (_Palm_va_list)inArgs ); -} /* StrPrintF */ - -/* from file StringMgr.h */ -Int16 -StrVPrintF( Char* s, const Char* formatStr, _Palm_va_list arg ) -{ - Int16 result; - unsigned long* argv_arm = (unsigned long*)arg; - unsigned char argv_68k[48]; - unsigned short done, isLong, innerDone, useArg; - unsigned char* str = (unsigned char*)formatStr; - unsigned short offset = 0; - - for ( done = 0; !done; ) { - switch( *str++ ) { - case '\0': - done = 1; - break; - case '%': - isLong = useArg = 0; - for( innerDone = 0; !innerDone; ) { - unsigned char nxt = *str++; - switch( nxt ) { - case '%': - innerDone = 1; - break; - case 'l': - isLong = 1; - break; - case 's': - isLong = 1; - case 'd': - case 'x': - innerDone = 1; - useArg = 1; - break; - default: - if ( nxt >= '0' && nxt <= '9' ) { - /* accept %4x */ - } else { - crash(); - } - } - } - - if ( useArg ) { - unsigned long param; - param = *argv_arm++; - if ( isLong ) { - write_unaligned32( &argv_68k[offset], param ); - offset += 4; - } else { - write_unaligned16( &argv_68k[offset], - (unsigned short)param ); - offset += 2; - } - } - break; - } - } - - /* now call the OS.... */ - { - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 12); - ADD_TO_STACK4(stack, s, 0); - ADD_TO_STACK4(stack, formatStr, 4); - ADD_TO_STACK4(stack, argv_68k, 8); - STACK_END(stack); - result = (Int16) - (*sp->call68KFuncP)( sp->emulStateP, - // NOT sysTrapStrPrintF !!!! - PceNativeTrapNo(sysTrapStrVPrintF), - stack, 12 ); - } - - return result; -} /* StrVPrintF */ - -/* Events. Need to translate back and forth since the ARM struct looks - * different from the 68K version yet we have to be able to come up with a 68K - * version for the OS at various times. May also need to translate inside - * event handlers since the OS will pass the 68K struct to us there. - */ -#define EVT_DATASIZE_68K 16 /* sez sizeof(event.data) in 68K code */ -void -evt68k2evtARM( EventType* event, const unsigned char* evt68k ) -{ - event->eType = read_unaligned16( evt68k ); - event->penDown = read_unaligned8( evt68k+2 ); - event->tapCount = read_unaligned8( evt68k+3 ); - event->screenX = read_unaligned16( evt68k+4 ); - event->screenY = read_unaligned16( evt68k+6 ); - - evt68k += 8; /* skip to start of data union */ - - switch ( event->eType ) { - case frmLoadEvent: - case frmOpenEvent: - case frmCloseEvent: - case frmUpdateEvent: - XP_ASSERT( &event->data.frmLoad.formID == - &event->data.frmClose.formID ); - event->data.frmLoad.formID = read_unaligned16( evt68k ); - event->data.frmUpdate.updateCode = read_unaligned16( evt68k + 2 ); - break; - case keyDownEvent: - case keyUpEvent: - event->data.keyDown.chr = read_unaligned16( evt68k ); - event->data.keyDown.keyCode = read_unaligned16( evt68k+2 ); - event->data.keyDown.modifiers = read_unaligned16( evt68k+4 ); - break; - - case ctlSelectEvent: - event->data.ctlSelect.controlID = read_unaligned16(evt68k); - event->data.ctlSelect.pControl - = (ControlType*)read_unaligned32(evt68k+2); - event->data.ctlSelect.on = (Boolean)read_unaligned8(evt68k+6); - event->data.ctlSelect.reserved1 = read_unaligned8(evt68k+7); - event->data.ctlSelect.value = read_unaligned16(evt68k+8); - break; - -#ifdef XWFEATURE_FIVEWAY - case frmObjectFocusTakeEvent: - case frmObjectFocusLostEvent: - event->data.frmObjectFocusTake.formID = read_unaligned16(evt68k); - event->data.frmObjectFocusTake.objectID = read_unaligned16(evt68k+2); - event->data.frmObjectFocusTake.dispatchHint = read_unaligned32(evt68k+4); - break; -#endif - - case winExitEvent: - case winEnterEvent: - XP_ASSERT( &event->data.winEnter.enterWindow == - &event->data.winExit.enterWindow ); - event->data.winEnter.enterWindow - = (WinHandle)read_unaligned32( evt68k ); - event->data.winEnter.exitWindow - = (WinHandle)read_unaligned32( evt68k+4 ); - break; - - // case penDownEvent: // stuff above is enough - // case penMoveEvent: // stuff above is enough - // case penUpEvent: // stuff above is enough - case menuEvent: - event->data.menu.itemID = read_unaligned16( evt68k ); - break; - case sclRepeatEvent: - event->data.sclRepeat.scrollBarID = read_unaligned16( evt68k ); - event->data.sclRepeat.pScrollBar - = (ScrollBarType*)read_unaligned32( evt68k+2 ); - event->data.sclRepeat.value = read_unaligned16( evt68k+6 ); - event->data.sclRepeat.newValue = read_unaligned16( evt68k+8 ); - event->data.sclRepeat.time = read_unaligned32( evt68k+10 ); - break; - /* Crosswords events */ - case newGameCancelEvent: - break; - case openSavedGameEvent: - ((OpenSavedGameData*)(&event->data.generic))->newGameIndex = - read_unaligned16( evt68k ); - break; - case newGameOkEvent: - case loadGameEvent: - break; -/* case boardRedrawEvt: */ - // doResizeWinEvent - case prefsChangedEvent: - break; - - default: /* copy the data as binary so we can copy it back later */ - memcpy( &event->data, evt68k, EVT_DATASIZE_68K ); - break; - } -} /* evt68k2evtARM */ - -void -evtArm2evt68K( unsigned char* evt68k, const EventType* event ) -{ - write_unaligned16( evt68k, event->eType ); - write_unaligned8( evt68k + 2, event->penDown ); - write_unaligned8( evt68k + 3, event->tapCount ); - write_unaligned16( evt68k + 4, event->screenX ); - write_unaligned16( evt68k + 6, event->screenY ); - - evt68k += 8; - - switch ( event->eType ) { - case frmLoadEvent: - case frmOpenEvent: - case frmCloseEvent: - case frmUpdateEvent: - XP_ASSERT( &event->data.frmLoad.formID - == &event->data.frmOpen.formID ); - XP_ASSERT( &event->data.frmLoad.formID - == &event->data.frmClose.formID ); - XP_ASSERT( &event->data.frmLoad.formID - == &event->data.frmUpdate.formID ); - write_unaligned16( evt68k, event->data.frmLoad.formID ); - write_unaligned16( evt68k + 2, event->data.frmUpdate.updateCode ); - break; - case keyDownEvent: - case keyUpEvent: - write_unaligned16( evt68k, event->data.keyDown.chr ); - write_unaligned16( evt68k+2, event->data.keyDown.keyCode ); - write_unaligned16( evt68k+4, event->data.keyDown.modifiers ); - break; - - case ctlSelectEvent: - write_unaligned16( evt68k, event->data.ctlSelect.controlID ); - write_unaligned32( evt68k+2, - (unsigned long)event->data.ctlSelect.pControl ); - write_unaligned8( evt68k+6, event->data.ctlSelect.on ); - write_unaligned8( evt68k+7, event->data.ctlSelect.reserved1 ); - write_unaligned16( evt68k+8, event->data.ctlSelect.value ); - break; - -#ifdef XWFEATURE_FIVEWAY - case frmObjectFocusTakeEvent: - case frmObjectFocusLostEvent: - write_unaligned16( evt68k, event->data.frmObjectFocusTake.formID ); - write_unaligned16( evt68k+2, event->data.frmObjectFocusTake.objectID ); - write_unaligned32( evt68k+4, event->data.frmObjectFocusTake.dispatchHint ); - break; -#endif - - case winExitEvent: - case winEnterEvent: - XP_ASSERT( &event->data.winEnter.enterWindow == - &event->data.winExit.enterWindow ); - write_unaligned32( evt68k, - (unsigned long)event->data.winEnter.enterWindow ); - write_unaligned32( evt68k+4, - (unsigned long)event->data.winEnter.exitWindow ); - break; - - // case penDownEvent: // stuff above is enough - // case penMoveEvent: // stuff above is enough - // case penUpEvent: // stuff above is enough - case menuEvent: - write_unaligned16( evt68k, event->data.menu.itemID ); - break; - case sclRepeatEvent: - write_unaligned16( evt68k, event->data.sclRepeat.scrollBarID ); - write_unaligned32( evt68k+2, - (unsigned long)event->data.sclRepeat.pScrollBar ); - write_unaligned16( evt68k+6, event->data.sclRepeat.value ); - write_unaligned16( evt68k+8, event->data.sclRepeat.newValue ); - write_unaligned32( evt68k+10, event->data.sclRepeat.time ); - break; - /* Crosswords events */ - case newGameCancelEvent: - break; - case openSavedGameEvent: - write_unaligned16( evt68k, - ((OpenSavedGameData*) - (&event->data.generic))->newGameIndex ); - break; - case newGameOkEvent: - case loadGameEvent: - break; -/* case boardRedrawEvt: */ - // doResizeWinEvent - case prefsChangedEvent: - break; - - default: /* copy the data as binary so we can copy it back later */ - memcpy( evt68k, &event->data, EVT_DATASIZE_68K ); - break; - } - -} /* evtArm2evt68K */ - -/* from file SystemMgr.h */ -Boolean -SysHandleEvent( EventPtr eventP ) -{ - Boolean result; - EventType event68K; - FUNC_HEADER(SysHandleEvent); - - evtArm2evt68K( (unsigned char*)&event68K, eventP ); - - { - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 4); - ADD_TO_STACK4(stack, &event68K, 0); - STACK_END(stack); - result = (Boolean)(*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapSysHandleEvent), - stack, 4 ); - } - FUNC_TAIL(SysHandleEvent); - return result; -} /* SysHandleEvent */ - -unsigned long -handlerEntryPoint( const void* XP_UNUSED(emulStateP), - void* userData68KP, - Call68KFuncType* XP_UNUSED(call68KFuncP) ) -{ - unsigned long* data = (unsigned long*)userData68KP; - FormEventHandlerType* handler - = (FormEventHandlerType*)read_unaligned32( (unsigned char*)&data[0] ); - PNOState* state = getStorageLoc(); - unsigned long oldR10; - EventType evtArm; - Boolean result; - - /* set up stack here too? */ - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state->gotTable) ); - - evt68k2evtARM( &evtArm, - (unsigned char*)read_unaligned32( (unsigned char*)&data[1]) ); - - result = (*handler)(&evtArm); - - asm( "mov r10, %0" : : "r" (oldR10) ); - - return (unsigned long)result; -} - -/* The stub wants to look like this: - static Boolean - FormEventHandlerType( EventType *eventP ) - { - unsigned long data[] = { armEvtHandler, eventP }; - return (Boolean)PceNativeCall( handlerEntryPoint, (void*)data ); - } - */ -static unsigned char* -makeHandlerStub( FormEventHandlerType* handlerArm ) -{ - unsigned char* stub; - unsigned char code_68k[] = { - /* 0:*/ 0x4e, 0x56, 0xff, 0xf8, // linkw %fp,#-8 - /* 4:*/ 0x20, 0x2e, 0x00, 0x08, // movel %fp@(8),%d0 - /* 8:*/ 0x2d, 0x7c, 0x11, 0x22, 0x33, 0x44, // movel #287454020,%fp@(-8) - /*14:*/ 0xff, 0xf8, // ????? REQUIRED!!!! - /*16:*/ 0x2d, 0x40, 0xff, 0xfc, // movel %d0,%fp@(-4) - /*20:*/ 0x48, 0x6e, 0xff, 0xf8, // pea %fp@(-8) - /*24:*/ 0x2f, 0x3c, 0x55, 0x66, 0x77, 0x88, // movel #1432778632,%sp@- - /*30:*/ 0x4e, 0x4f, // trap #15 - /*32:*/ 0xa4, 0x5a, // 0122132 - /*34:*/ 0x02, 0x40, 0x00, 0xff, // andiw #255,%d0 - /*38:*/ 0x4e, 0x5e, // unlk %fp - /*40:*/ 0x4e, 0x75 // rts - }; - - stub = MemPtrNew( sizeof(code_68k) ); - memcpy( stub, code_68k, sizeof(code_68k) ); - - write_unaligned32( &stub[10], - /* replace 0x11223344 */ - (unsigned long)handlerArm ); - write_unaligned32( &stub[26], - /* replace 0x55667788 */ - (unsigned long)handlerEntryPoint ); - /* Need to register this stub so it can be freed (once leaking ceases to - be ok on PalmOS) */ - - return (unsigned char*)stub; -} /* makeHandlerStub */ - -void -FrmSetEventHandler( FormType* formP, FormEventHandlerType* handler ) -{ - FUNC_HEADER(FrmSetEventHandler); - { - PNOState* sp = GET_CALLBACK_STATE(); - unsigned char* stub = makeHandlerStub( handler ); - STACK_START(unsigned char, stack, 8); - ADD_TO_STACK4(stack, formP, 0); - ADD_TO_STACK4(stack, stub, 4); - STACK_END(stack); - (*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapFrmSetEventHandler), - stack, 8 ); - } - FUNC_TAIL(FrmSetEventHandler); -} /* FrmSetEventHandler */ - -void -flipRect( RectangleType* rout, const RectangleType* rin ) -{ - rout->topLeft.x = Byte_Swap16(rin->topLeft.x); - rout->topLeft.y = Byte_Swap16(rin->topLeft.y); - rout->extent.x = Byte_Swap16(rin->extent.x); - rout->extent.y = Byte_Swap16(rin->extent.y); -} /* flipRect */ - -void -flipEngSocketFromArm( unsigned char* sout, const ExgSocketType* sin ) -{ - write_unaligned16( &sout[0], sin->libraryRef ); // UInt16 libraryRef; - write_unaligned32( &sout[2], sin->socketRef ); // UInt32 socketRef; - write_unaligned32( &sout[6], sin->target ); // UInt32 target; - write_unaligned32( &sout[10], sin->count ); // UInt32 count; - - write_unaligned32( &sout[14], sin->length ); // UInt32 length; - - write_unaligned32( &sout[18], sin->time ); // UInt32 time; - write_unaligned32( &sout[22], sin->appData ); // UInt32 appData; - write_unaligned32( &sout[26], sin->goToCreator ); // UInt32 goToCreator; - write_unaligned16( &sout[30], sin->goToParams.dbCardNo ); // UInt16 goToParams.dbCardNo; - write_unaligned32( &sout[32], sin->goToParams.dbID ); // LocalID goToParams.dbID; - write_unaligned16( &sout[36], sin->goToParams.recordNum ); // UInt16 goToParams.recordNum; - write_unaligned32( &sout[38], sin->goToParams.uniqueID ); // UInt32 goToParams.uniqueID; - write_unaligned32( &sout[42], sin->goToParams.matchCustom ); // UInt32 goToParams.matchCustom; - /* bitfield. All we can do is copy the whole thing, assuming it's 16 - bits, and pray that no arm code wants to to use it. */ - write_unaligned16( &sout[46], *(UInt16*)((unsigned char*)&sin->goToParams.matchCustom) - + sizeof(sin->goToParams.matchCustom) ); - write_unaligned32( &sout[48], (unsigned long)sin->description ); // Char *description; - write_unaligned32( &sout[52], (unsigned long)sin->type ); // Char *type; - write_unaligned32( &sout[56], (unsigned long)sin->name ); // Char *name; -} /* flipEngSocketFromArm */ - -void -flipEngSocketToArm( ExgSocketType* sout, const unsigned char* sin ) -{ - sout->libraryRef = read_unaligned16( &sin[0] ); - sout->socketRef = read_unaligned32( &sin[2] ); - sout->target = read_unaligned32( &sin[6] ); - sout->count = read_unaligned32( &sin[10] ); - sout->length = read_unaligned32( &sin[14] ); - sout->time = read_unaligned32( &sin[18] ); - sout->appData = read_unaligned32( &sin[22] ); - sout->goToCreator = read_unaligned32( &sin[26] ); - sout->goToParams.dbCardNo = read_unaligned16( &sin[30] ); - sout->goToParams.dbID = read_unaligned32( &sin[32] ); - sout->goToParams.recordNum = read_unaligned16( &sin[36] ); - sout->goToParams.uniqueID = read_unaligned32( &sin[38] ); - sout->goToParams.matchCustom = read_unaligned32( &sin[42] ); - /* bitfield. All we can do is copy the whole thing, assuming it's 16 - bits, and pray that no arm code wants to to use it. */ - *(UInt16*)(((unsigned char*)&sout->goToParams.matchCustom) - + sizeof(sout->goToParams.matchCustom)) = read_unaligned16( &sin[46] ); - sout->description = (Char*)read_unaligned32( &sin[48] ); - sout->type = (Char*)read_unaligned32( &sin[52] ); - sout->name = (Char*)read_unaligned32( &sin[56] ); -} /* flipEngSocketToArm */ - -void -flipFileInfoFromArm( unsigned char* fiout, const FileInfoType* fiin ) -{ - write_unaligned32( &fiout[0], fiin->attributes ); - write_unaligned32( &fiout[4], (unsigned long)fiin->nameP ); - write_unaligned16( &fiout[8], fiin->nameBufLen ); -} - -void -flipFileInfoToArm( FileInfoType* fout, const unsigned char* fin ) -{ - fout->attributes = read_unaligned32( &fin[0] ); - fout->nameP = (Char*)read_unaligned32( &fin[4] ); - fout->nameBufLen = read_unaligned16( &fin[8] ); -} /* flipFileInfo */ - -/* from file List.h */ -void -LstSetListChoices( ListType* listP, Char** itemsText, Int16 numItems ) -{ - FUNC_HEADER(LstSetListChoices); - /* var decls */ - /* swapIns */ - { - XP_U16 i; - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 10); - /* pushes */ - ADD_TO_STACK4(stack, listP, 0); - ADD_TO_STACK4(stack, itemsText, 4); - ADD_TO_STACK2(stack, numItems, 8); - STACK_END(stack); - - for ( i = 0; i < numItems; ++i ) { - itemsText[i] = (Char*)Byte_Swap32( (unsigned long)itemsText[i] ); - } - - (*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapLstSetListChoices), - stack, 10 ); - /* swapOuts */ - } - FUNC_TAIL(LstSetListChoices); - EMIT_NAME("LstSetListChoices","'L','s','t','S','e','t','L','i','s','t','C','h','o','i','c','e','s'"); -} /* LstSetListChoices */ - -static void -params68KtoParamsArm( SysNotifyParamType* paramsArm, - const unsigned char* params68K ) -{ - paramsArm->notifyType = read_unaligned32( ¶ms68K[0] ); - paramsArm->broadcaster = read_unaligned32( ¶ms68K[4] ); - paramsArm->notifyDetailsP = (void*)read_unaligned32( ¶ms68K[8] ); - paramsArm->userDataP = (void*)read_unaligned32( ¶ms68K[12] ); - paramsArm->handled = read_unaligned8( ¶ms68K[16] ); - - /* I don't do anything with the data passed in, so no need to swap it... - But that'd change for others: make an ARM-corrected copy of the - contents of notifyDetailsP if your handler will use it. */ - switch( paramsArm->notifyType ) { - case sysNotifyVolumeUnmountedEvent: - case sysNotifyVolumeMountedEvent: - break; -#ifdef FEATURE_SILK - case sysNotifyDisplayChangeEvent: - break; -#endif - } - -} /* params68KtoParamsArm */ - -static void -paramsArmtoParams68K( unsigned char* params68K, - const SysNotifyParamType* armParams ) -{ - write_unaligned8( ¶ms68K[16], armParams->handled ); -} /* paramsArmtoParams68K */ - -static unsigned long -notifyEntryPoint( const void* XP_UNUSED_DBG(emulStateP), - void* userData68KP, - Call68KFuncType* XP_UNUSED_DBG(call68KFuncP) ) -{ - unsigned long* data = (unsigned long*)userData68KP; - SysNotifyProcPtr callback - = (SysNotifyProcPtr)read_unaligned32( (unsigned char*)&data[0] ); - SysNotifyParamType armParams; - PNOState* state = getStorageLoc(); - unsigned long oldR10; - unsigned char* params68K; - Err result; - - /* set up stack here too? */ - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state->gotTable) ); - - XP_ASSERT( emulStateP == state->emulStateP ); - XP_ASSERT( call68KFuncP == state->call68KFuncP ); - - params68K = (unsigned char*)read_unaligned32((unsigned char*)&data[1]); - params68KtoParamsArm( &armParams, params68K ); - - result = (*callback)(&armParams); - - /* at least need to write 'handled' back out... */ - paramsArmtoParams68K( params68K, &armParams ); - - asm( "mov r10, %0" : : "r" (oldR10) ); - - return (unsigned long)result; -} /* notifyEntryPoint */ - -/* The stub wants to look like this: - static Err SysNotifyProc(SysNotifyParamType *notifyParamsP) - { - unsigned long data[] = { armNotifyHandler, notifyParamsP }; - return (Err)PceNativeCall( handlerEntryPoint, (void*)data ); - } - */ -static unsigned char* -makeNotifyStub( SysNotifyProcPtr callback ) -{ - unsigned char* stub; - unsigned char code_68k[] = { - /* 0:*/ 0x4e, 0x56, 0xff, 0xf8, // linkw %fp,#-8 - /* 4:*/ 0x20, 0x2e, 0x00, 0x08, // movel %fp@(8),%d0 - /* 8:*/ 0x2d, 0x7c, 0x11, 0x22, 0x33, 0x44, // movel #287454020,%fp@(-8) - /*14:*/ 0xff, 0xf8, // ????? REQUIRED!!!! - /*16:*/ 0x2d, 0x40, 0xff, 0xfc, // movel %d0,%fp@(-4) - /*20:*/ 0x48, 0x6e, 0xff, 0xf8, // pea %fp@(-8) - /*24:*/ 0x2f, 0x3c, 0x55, 0x66, 0x77, 0x88, // movel #1432778632,%sp@- - /*30:*/ 0x4e, 0x4f, // trap #15 - /*32:*/ 0xa4, 0x5a, // 0122132 - /*34:*/ 0x4e, 0x5e, // unlk %fp - /*36:*/ 0x4e, 0x75 // rts - }; - - stub = MemPtrNew( sizeof(code_68k) ); - memcpy( stub, code_68k, sizeof(code_68k) ); - - write_unaligned32( &stub[10], - /* replace 0x11223344 */ - (unsigned long)callback ); - write_unaligned32( &stub[26], - /* replace 0x55667788 */ - (unsigned long)notifyEntryPoint ); - /* Need to register this stub so it can be freed (once leaking ceases to - be ok on PalmOS) */ - - return (unsigned char*)stub; -} /* makeNotifyStub */ - -/* from file NotifyMgr.h */ -Err -SysNotifyRegister( UInt16 cardNo, LocalID dbID, UInt32 notifyType, - SysNotifyProcPtr callbackP, Int8 priority, void* userDataP ) -{ - Err result; - FUNC_HEADER(SysNotifyRegister); - /* var decls */ - /* swapIns */ - { - PNOState* sp = GET_CALLBACK_STATE(); - unsigned char* stub = makeNotifyStub( callbackP ); - STACK_START(unsigned char, stack, 20); - /* pushes */ - ADD_TO_STACK2(stack, cardNo, 0); - ADD_TO_STACK4(stack, dbID, 2); - ADD_TO_STACK4(stack, notifyType, 6); - ADD_TO_STACK4(stack, stub, 10); - ADD_TO_STACK1(stack, priority, 14); - ADD_TO_STACK4(stack, userDataP, 16); - STACK_END(stack); - result = (Err)(*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapSysNotifyRegister), - stack, 20 ); - /* swapOuts */ - } - FUNC_TAIL(SysNotifyRegister); - EMIT_NAME("SysNotifyRegister","'S','y','s','N','o','t','i','f','y','R','e','g','i','s','t','e','r'"); - return result; -} /* SysNotifyRegister */ - -unsigned long -listDrawEntryPoint( const void* XP_UNUSED_DBG(emulStateP), - void* userData68KP, - Call68KFuncType* XP_UNUSED_DBG(call68KFuncP) ) -{ - unsigned long* data = (unsigned long*)userData68KP; - ListDrawDataFuncPtr listDrawProc - = (ListDrawDataFuncPtr)read_unaligned32( (unsigned char*)&data[0] ); - PNOState* state = getStorageLoc(); - unsigned long oldR10; - Int16 index; - char** itemsText; - RectangleType rectArm; - - /* set up stack here too? */ - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state->gotTable) ); - - flipRect( &rectArm, (RectanglePtr)read_unaligned32( (unsigned char*)&data[2] ) ); - - XP_ASSERT( emulStateP == state->emulStateP ); - XP_ASSERT( call68KFuncP == state->call68KFuncP ); - - index = (Int16)read_unaligned32( (unsigned char*)&data[1] ); - itemsText = (char**)read_unaligned32( (unsigned char*)&data[3] ); - (*listDrawProc)( index, &rectArm, itemsText ); - - asm( "mov r10, %0" : : "r" (oldR10) ); - - return 0L; /* no result to return */ -} /* listDrawEntryPoint */ - -static unsigned char* -makeListDrawStub( ListDrawDataFuncPtr func ) -{ -/* called function looks like this: - void listDrawFunc(Int16 index, RectanglePtr bounds, char** itemsText) - { - unsigned long data[] = { func, index, - bounds, itemsText }; - return (Err)PceNativeCall( listDrawEntryPoint, (void*)data ); - } - */ - unsigned char* stub; - unsigned char code_68k[] = { - /* 0:*/ 0x4e, 0x56, 0xff, 0xf0, // linkw %fp,#-16 - /* 4:*/ 0x30, 0x2e, 0x00, 0x08, // movew %fp@(8),%d0 - /* 8:*/ 0x22, 0x2e, 0x00, 0x0a, // movel %fp@(10),%d1 - /* c:*/ 0x24, 0x2e, 0x00, 0x0e, // movel %fp@(14),%d2 - /*10:*/ 0x2d, 0x7c, 0x11, 0x22,0x33,0x44,// movel #287454020,%fp@(-16) - /*16:*/ 0xff, 0xf0, - /*18:*/ 0x30, 0x40, // moveaw %d0,%a0 - /*1a:*/ 0x2d, 0x48, 0xff, 0xf4, // movel %a0,%fp@(-12) - /*1e:*/ 0x2d, 0x41, 0xff, 0xf8, // movel %d1,%fp@(-8) - /*22:*/ 0x2d, 0x42, 0xff, 0xfc, // movel %d2,%fp@(-4) - /*26:*/ 0x48, 0x6e, 0xff, 0xf0, // pea %fp@(-16) - /*2a:*/ 0x2f, 0x3c, 0x55, 0x66, 0x77, 0x88, // movel #1432778632,%sp@- - /*30:*/ 0x4e, 0x4f, // trap #15 - /*32:*/ 0xa4, 0x5a, // 0122132 - /*34:*/ 0x4e, 0x5e, // unlk %fp - /*36:*/ 0x4e, 0x75 // rts - }; - stub = MemPtrNew( sizeof(code_68k) ); - memcpy( stub, code_68k, sizeof(code_68k) ); - - write_unaligned32( &stub[0x12], - /* replace 0x11223344 */ - (unsigned long)func ); - write_unaligned32( &stub[0x2c], - /* replace 0x55667788 */ - (unsigned long)listDrawEntryPoint ); - - return (unsigned char*)stub; -} /* makeListDrawStub */ - -/* from file List.h */ -void -LstSetDrawFunction( ListType* listP, ListDrawDataFuncPtr func ) -{ - FUNC_HEADER(LstSetDrawFunction); - /* var decls */ - /* swapIns */ - { - PNOState* sp = GET_CALLBACK_STATE(); - unsigned char* stub = makeListDrawStub( func ); - STACK_START(unsigned char, stack, 8); - /* pushes */ - ADD_TO_STACK4(stack, listP, 0); - ADD_TO_STACK4(stack, stub, 4); - STACK_END(stack); - (*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapLstSetDrawFunction), - stack, 8 ); - /* swapOuts */ - } - FUNC_TAIL(LstSetDrawFunction); - EMIT_NAME("LstSetDrawFunction","'L','s','t','S','e','t','D','r','a','w','F','u','n','c','t','i','o','n'"); -} /* LstSetDrawFunction */ - -void -flipDateTimeToArm( DateTimeType* out, const unsigned char* in ) -{ - const DateTimeType* inp = (DateTimeType*)in; - out->second = Byte_Swap16( inp->second ); - out->minute = Byte_Swap16( inp->minute ); - out->hour = Byte_Swap16( inp->hour ); - out->day = Byte_Swap16( inp->day ); - out->month = Byte_Swap16( inp->month ); - out->year = Byte_Swap16( inp->year ); - out->weekDay = Byte_Swap16( inp->weekDay ); -} - -/* from file NetMgr.h */ -NetHostInfoPtr -NetLibGetHostByName( UInt16 libRefNum, const Char* nameP, - NetHostInfoBufPtr bufP, Int32 timeout, Err* errP ) -{ - NetHostInfoPtr result; - FUNC_HEADER(NetLibGetHostByName); - /* var decls */ - /* swapIns */ - { - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 18); - /* pushes */ - ADD_TO_STACK2(stack, libRefNum, 0); - ADD_TO_STACK4(stack, nameP, 2); - ADD_TO_STACK4(stack, bufP, 6); - ADD_TO_STACK4(stack, timeout, 10); - ADD_TO_STACK4(stack, errP, 14); - STACK_END(stack); - result = (NetHostInfoPtr) - (*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(netLibTrapGetHostByName), - stack, kPceNativeWantA0 | 18 ); - /* swapOuts */ - - if ( result != NULL ) { - result->nameP = Byte_Swap32( result->nameP ); - result->nameAliasesP = Byte_Swap32( result->nameAliasesP ); - result->addrType = Byte_Swap16( result->addrType ); - result->addrLen = Byte_Swap16( result->addrLen ); - result->addrListP = Byte_Swap32( result->addrListP ); - - /* we'll use only the first */ - result->addrListP[0] = Byte_Swap32( result->addrListP[0] ); - *(XP_U32*)result->addrListP[0] = - Byte_Swap32( *(XP_U32*)result->addrListP[0] ); - } - } - FUNC_TAIL(NetLibGetHostByName); - EMIT_NAME("NetLibGetHostByName","'N','e','t','L','i','b','G','e','t','H','o','s','t','B','y','N','a','m','e'"); - return result; -} /* NetLibGetHostByName */ - - -static unsigned long -exgWriteEntry( const void* XP_UNUSED_DBG(emulStateP), - void* userData68KP, - Call68KFuncType* XP_UNUSED_DBG(call68KFuncP) ) -{ - unsigned long* data = (unsigned long*)userData68KP; - unsigned long oldR10; - ExgDBWriteProcPtr exgProc - = (ExgDBWriteProcPtr)read_unaligned32( (unsigned char*)&data[0] ); - PNOState* state = getStorageLoc(); - UInt32* sizeP; - Err err; - - /* set up stack here too? */ - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state->gotTable) ); - - XP_ASSERT( emulStateP == state->emulStateP ); - XP_ASSERT( call68KFuncP == state->call68KFuncP ); - - sizeP = (UInt32*)read_unaligned32( (unsigned char*)&data[2] ); - SWAP4_NON_NULL_OUT(sizeP); - err = (*exgProc)( (const void*)read_unaligned32((unsigned char*)&data[1]), - sizeP, - (void*)read_unaligned32( (unsigned char*)&data[3] ) ); - SWAP4_NON_NULL_IN(sizeP); - - asm( "mov r10, %0" : : "r" (oldR10) ); - - return (unsigned long)err; /* no result to return */ -} /* exgWriteEntry */ - -static void -makeExgWriteStub( ExgDBWriteProcPtr proc, unsigned char* stub, - XP_U16 XP_UNUSED_DBG(stubSize) ) -{ -/* Err ExgDBWriteProc( const void *dataP, UInt32 *sizeP, void *userDataP) */ -/* { */ -/* unsigned long data[] = { */ -/* (unsigned long)0x11223344, */ -/* (unsigned long)dataP, */ -/* (unsigned long)sizeP, */ -/* (unsigned long)userDataP */ -/* }; */ -/* return (Err)PceNativeCall( (void*)0x55667788, (void*)data ); */ -/* } */ - unsigned char code_68k[] = { - /* 0:*/ 0x4e, 0x56, 0xff, 0xf0, /* linkw %fp,#-16 */ - /* 4:*/ 0x20, 0x2e, 0x00, 0x08, /* movel %fp@(8),%d0 */ - /* 8:*/ 0x22, 0x2e, 0x00, 0x0c, /* movel %fp@(12),%d1 */ - /* c:*/ 0x24, 0x2e, 0x00, 0x10, /* movel %fp@(16),%d2 */ - /*10:*/ 0x2d, 0x7c, 0x11, 0x22, 0x33, 0x44,/*movel #287454020,%fp@(-16)*/ - /*16:*/ 0xff, 0xf0, - /*18:*/ 0x2d, 0x40, 0xff, 0xf4, /* movel %d0,%fp@(-12) */ - /*1c:*/ 0x2d, 0x41, 0xff, 0xf8, /* movel %d1,%fp@(-8) */ - /*20:*/ 0x2d, 0x42, 0xff, 0xfc, /* movel %d2,%fp@(-4) */ - /*24:*/ 0x48, 0x6e, 0xff, 0xf0, /* pea %fp@(-16) */ - /*28:*/ 0x2f, 0x3c, 0x55, 0x66, 0x77, 0x88, /* movel #1432778632,%sp@- */ - /*2e:*/ 0x4e, 0x4f, /* trap #15 */ - /*30:*/ 0xa4, 0x5a, /* 0122132 */ - /*32:*/ 0x4e, 0x5e, /* unlk %fp */ - /*34:*/ 0x4e, 0x75 /* rts */ - }; - XP_ASSERT( sizeof(code_68k) <= stubSize ); - memcpy( stub, code_68k, sizeof(code_68k) ); - - write_unaligned32( &stub[0x12], - /* replace 0x11223344 */ - (unsigned long)proc ); - write_unaligned32( &stub[0x2a], - /* replace 0x55667788 */ - (unsigned long)exgWriteEntry ); -} /* makeExgWriteStub */ - -/* from file ExgMgr.h */ -Err -ExgDBWrite( ExgDBWriteProcPtr writeProcP, void* userDataP, - const char* nameP, LocalID dbID, UInt16 cardNo ) -{ - Err result; - FUNC_HEADER(ExgDBWrite); - /* var decls */ - /* swapIns */ - { - PNOState* sp = GET_CALLBACK_STATE(); - unsigned char stub[0x36]; - STACK_START(unsigned char, stack, 18); - makeExgWriteStub( writeProcP, stub, sizeof(stub) ); - - /* pushes */ - ADD_TO_STACK4(stack, stub, 0); - ADD_TO_STACK4(stack, userDataP, 4); - ADD_TO_STACK4(stack, nameP, 8); - ADD_TO_STACK4(stack, dbID, 12); - ADD_TO_STACK2(stack, cardNo, 16); - STACK_END(stack); - result = (Err)(*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(sysTrapExgDBWrite), - stack, 18 ); - /* swapOuts */ - } - FUNC_TAIL(ExgDBWrite); - EMIT_NAME("ExgDBWrite","'E','x','g','D','B','W','r','i','t','e'"); - return result; -} /* ExgDBWrite */ - -#ifdef XWFEATURE_BLUETOOTH -static void -btLibManagementEventType68K_TO_ARM( BtLibManagementEventType* out, - const unsigned char* in ) -{ - BtLibManagementEventEnum event - = (BtLibManagementEventEnum)read_unaligned8( &in[0] ); - out->event = event; - out->status = read_unaligned16( &in[2] ); - switch( event ) { - case btLibManagementEventACLConnectInbound: - case btLibManagementEventACLDisconnect: - memcpy( &out->eventData.bdAddr, &in[4], sizeof(out->eventData.bdAddr) ); - break; - case btLibManagementEventAccessibilityChange: - out->eventData.accessible - = (BtLibAccessibleModeEnum)read_unaligned8( &in[4] ); - break; - } -} - -static unsigned long -btLibManagementProcArmEntry( const void* emulStateP, - void* userData68KP, - Call68KFuncType* XP_UNUSED_DBG(call68KFuncP) ) -{ - unsigned long* data; - BtLibManagementProcPtr procPtr; - PNOState* state; - unsigned long oldR10; - BtLibManagementEventType mEvent; - const BtLibManagementEventType* mEventP; - UInt32 refCon; - - data = (unsigned long*)userData68KP; - state = getStorageLoc(); - - /* This won't be true if we're called in somebody else's context */ - if ( emulStateP == state->emulStateP ) { - /* set up stack here too? */ - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state->gotTable) ); - - XP_ASSERT( emulStateP == state->emulStateP ); /* seems to fire when call's - incoming (or maybe: a - system alert is up). - What to do? */ - XP_ASSERT( call68KFuncP == state->call68KFuncP ); - - procPtr = (BtLibManagementProcPtr)read_unaligned32( &data[0] ); - mEventP = read_unaligned32( &data[1] ); - btLibManagementEventType68K_TO_ARM( &mEvent, (unsigned char*)mEventP ); - refCon = read_unaligned32( (unsigned char*)&data[2] ); - (*procPtr)( &mEvent, refCon ); - - asm( "mov r10, %0" : : "r" (oldR10) ); - } - - return 0L; /* no result to return */ -} /* btLibManagementProcArmEntry */ - -/* BtLibSocketProcPtr and BtLibManagementProc have the same signatures as far - as 68K code goes: */ -/* static void BtLibManagementProc( BtLibManagementEventType *mEvent, UInt32 refCon ) */ -/* { */ -/* unsigned long data[] = { callbackP, mEvent, refCon }; */ -/* (void)PceNativeCall( btLibManagementProcArmEntry, (void*)data ); */ -/* } */ - -static unsigned char* -make44stub( void* callbackP, NativeFuncType armFunc ) -{ - unsigned char* stub; - unsigned char code_68k[] = { - /* 0 */ 0x4e, 0x56, 0xff, 0xf4, // linkw %fp,#-12 - /* 4 */ 0x20, 0x2e, 0x00, 0x08, // movel %fp@(8),%d0 - /* 8 */ 0x22, 0x2e, 0x00, 0x0c, // movel %fp@(12),%d1 - /* C */ 0x2d, 0x7c, 0x11, 0x22, 0x33, 0x44, // movel #287454020,%fp@(-12) - /* 12 */ 0xff, 0xf4, - /* 14 */ 0x2d, 0x40, 0xff, 0xf8, // movel %d0,%fp@(-8) - /* 18 */ 0x2d, 0x41, 0xff, 0xfc, // movel %d1,%fp@(-4) - /* 1C */ 0x48, 0x6e, 0xff, 0xf4, // pea %fp@(-12) - /* 20 */ 0x2f, 0x3c, 0x55, 0x66, 0x77, 0x88, // movel #1432778632,%sp@- - /* 26 */ 0x4e, 0x4f, // trap #15 - /* 28 */ 0xa4, 0x5a, // 0122132 - /* 2A */ 0x50, 0x8f, // addql #8,%sp - /* 2C */ 0x4e, 0x5e, // unlk %fp - /* 2E */ 0x4e, 0x75 // rts - }; - - stub = MemPtrNew( sizeof(code_68k) ); - memcpy( stub, code_68k, sizeof(code_68k) ); - - write_unaligned32( &stub[0x0E], - /* replace 0x11223344 */ - (unsigned long)callbackP ); - write_unaligned32( &stub[0x22], - /* replace 0x55667788 */ - (unsigned long)armFunc ); - - return stub; -} /* findOrMakeBTProcStub */ - -static void -btLibSocketEventType68K_TO_ARM( BtLibSocketEventType* out, const unsigned char* in ) -{ - BtLibSocketEventEnum event = read_unaligned8( &in[0] ); /* enum? */ - out->event = event; - out->socket = read_unaligned16( &in[2] ); - out->status = read_unaligned16( &in[4] ); - - switch( event ) { - case btLibSocketEventConnectedInbound: - out->eventData.newSocket = read_unaligned16( &in[6] ); - break; - case btLibSocketEventData: - out->eventData.data.dataLen = read_unaligned16( &in[6] ); - out->eventData.data.data = read_unaligned32( &in[8] ); - break; - case btLibSocketEventSdpGetPsmByUuid: - out->eventData.sdpByUuid.param.psm = read_unaligned16( &in[10] ); - break; - - /* These use status and socket only (if anything) */ - case btLibSocketEventConnectRequest: - case btLibSocketEventConnectedOutbound: - case btLibSocketEventSendComplete: - case btLibSocketEventDisconnected: - case btLibL2DiscConnPsmUnsupported: - break; - default: /* shut up, compiler */ - XP_ASSERT(0); - break; - } -} - -static unsigned long -btSocketProcArmEntry( const void* emulStateP, void* userData68KP, - Call68KFuncType* XP_UNUSED_DBG(call68KFuncP) ) -{ - BtLibSocketEventType sEvent; - BtLibSocketEventType* sEventP; - UInt32 refCon; - - unsigned long* data = (unsigned long*)userData68KP; - unsigned long oldR10; - BtLibSocketProcPtr procPtr - = (BtLibSocketProcPtr)read_unaligned32( (unsigned char*)&data[0] ); - PNOState* state = getStorageLoc(); - - /* This won't be true if we're called in somebody else's context */ - if ( emulStateP == state->emulStateP ) { - - /* set up stack here too? */ - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state->gotTable) ); - - XP_ASSERT( call68KFuncP == state->call68KFuncP ); - - sEventP = (BtLibSocketEventType*) - read_unaligned32( (unsigned char*)&data[1] ); - btLibSocketEventType68K_TO_ARM( &sEvent, (unsigned char*)sEventP ); - refCon = read_unaligned32( (unsigned char*)&data[2] ); - (*procPtr)( &sEvent, refCon ); - - asm( "mov r10, %0" : : "r" (oldR10) ); - } - return 0L; /* no result to return */ -} /* btSocketProcArmEntry */ - -/* from file BtLib.h */ -Err -BtLibRegisterManagementNotification( UInt16 btLibRefNum, - BtLibManagementProcPtr callbackP, - UInt32 refCon ) -{ - Err result; - FUNC_HEADER(BtLibRegisterManagementNotification); - /* var decls */ - /* swapIns */ - { - PNOState* sp = GET_CALLBACK_STATE(); - - unsigned char* stub = make44stub( callbackP, btLibManagementProcArmEntry ); - result = FtrSet( APPID, PACE_BT_CBK_FEATURE, stub ); - XP_LOGF( "%s: stub=%lx", __func__, stub ); - - STACK_START(unsigned char, stack, 10); - /* pushes */ - ADD_TO_STACK2(stack, btLibRefNum, 0); - ADD_TO_STACK4(stack, stub, 2); - ADD_TO_STACK4(stack, refCon, 6); - STACK_END(stack); - result = (Err)(*sp->call68KFuncP)( - sp->emulStateP, - PceNativeTrapNo(btLibTrapRegisterManagementNotification), - stack, 10 ); - /* swapOuts */ - } - FUNC_TAIL(BtLibRegisterManagementNotification); - EMIT_NAME("BtLibRegisterManagementNotification","'B','t','L','i','b','R','e','g','i','s','t','e','r','M','a','n','a','g','e','m','e','n','t','N','o','t','i','f','i','c','a','t','i','o','n'"); - return result; -} /* BtLibRegisterManagementNotification */ - -/* from file BtLib.h */ -Err -BtLibUnregisterManagementNotification( - UInt16 btLibRefNum, - BtLibManagementProcPtr XP_UNUSED_DBG(callbackP) ) -{ - Err result; - unsigned char* stub = NULL; - - FUNC_HEADER(BtLibUnregisterManagementNotification); - - result = FtrGet( APPID, PACE_BT_CBK_FEATURE, (UInt32*)&stub ); - XP_ASSERT( !!stub && errNone == result ); - XP_LOGF( "%s: stub=%lx", __func__, stub ); - -#ifdef DEBUG - { - XP_U32 bkwrds; - write_unaligned32( &bkwrds, callbackP ); - XP_ASSERT( 0 == XP_MEMCMP( &bkwrds, &stub[0x0E], sizeof(callbackP) ) ); - } -#endif - /* var decls */ - /* swapIns */ - { - PNOState* sp = GET_CALLBACK_STATE(); - STACK_START(unsigned char, stack, 6); - /* pushes */ - ADD_TO_STACK2(stack, btLibRefNum, 0); - ADD_TO_STACK4(stack, stub, 2); - STACK_END(stack); - result = (Err)(*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(btLibTrapUnregisterManagementNotification), - stack, 6 ); - /* swapOuts */ - } - MemPtrFree( stub ); - XP_LOGF( "%s: stub freed", __func__ ); - - FUNC_TAIL(BtLibUnregisterManagementNotification); - EMIT_NAME("BtLibUnregisterManagementNotification","'B','t','L','i','b','U','n','r','e','g','i','s','t','e','r','M','a','n','a','g','e','m','e','n','t','N','o','t','i','f','i','c','a','t','i','o','n'"); - return result; -} /* BtLibUnregisterManagementNotification */ - -/* from file BtLib.h */ -Err -BtLibSocketCreate( UInt16 btLibRefNum, BtLibSocketRef* socketRefP, - BtLibSocketProcPtr callbackP, UInt32 refCon, - BtLibProtocolEnum socketProtocol ) -{ - Err result; - FUNC_HEADER(BtLibSocketCreate); - /* var decls */ - /* swapIns */ - /* SWAP2_NON_NULL_IN(socketRefP); */ - { - PNOState* sp = GET_CALLBACK_STATE(); - unsigned char* stub = make44stub( callbackP, btSocketProcArmEntry ); - - STACK_START(unsigned char, stack, 16); - /* pushes */ - ADD_TO_STACK2(stack, btLibRefNum, 0); - ADD_TO_STACK4(stack, socketRefP, 2); - ADD_TO_STACK4(stack, stub, 6); - ADD_TO_STACK4(stack, refCon, 10); - ADD_TO_STACK1(stack, socketProtocol, 14); - STACK_END(stack); - result = (Err) - (*sp->call68KFuncP)( sp->emulStateP, - PceNativeTrapNo(btLibTrapSocketCreate), - stack, 16 ); - /* swapOuts */ - SWAP2_NON_NULL_OUT(socketRefP); - } - FUNC_TAIL(BtLibSocketCreate); - EMIT_NAME("BtLibSocketCreate","'B','t','L','i','b','S','o','c','k','e','t','C','r','e','a','t','e'"); - return result; -} /* BtLibSocketCreate */ - -void -flipBtConnInfoArm268K( unsigned char* out, const BtLibSocketConnectInfoType* in ) -{ - write_unaligned32( out + 0, in->remoteDeviceP ); -#if defined BT_USE_L2CAP - write_unaligned16( out + 4, in->data.L2Cap.remotePsm ); - write_unaligned16( out + 6, in->data.L2Cap.minRemoteMtu ); - write_unaligned16( out + 8, in->data.L2Cap.localMtu ); -#elif defined BT_USE_RFCOMM - write_unaligned8( out + 4, in->data.RfComm.remoteService ); - write_unaligned16( out + 6, in->data.RfComm.maxFrameSize ); - write_unaligned8( out + 7, in->data.RfComm.advancedCredit ); -#endif -} - -/* from file BtLib.h */ - -void -flipBtSocketListenInfoArm268K( unsigned char* out, - const BtLibSocketListenInfoType* in) -{ - /* Some moron didn't put a type field in BtLibSocketListenInfoType. The - interpretation of the data depends on the protocol with which the - socket (param to BtLibSocketListen) was created. We *could* pass the - socket into this function and pull the protocol out, using that to - decide which overlapping union field to swap, but let's just hard-code - btLibL2CapProtocol (field data.L2Cap) since that's what I'm using.*/ - - write_unaligned16( out + 0, in->data.L2Cap.localPsm ); - write_unaligned16( out + 2, in->data.L2Cap.localMtu ); - write_unaligned16( out + 4, in->data.L2Cap.minRemoteMtu ); -} - -void -flipBtLibSdpUuidTypeArm268K( unsigned char* out, const BtLibSdpUuidType* in ) -{ - write_unaligned8( out + 0, in->size ); /* size 1 on 68K, 4 on ARM */ - memcpy( out + 1, &in->UUID, sizeof(in->UUID) ); /* offset 68K: 1; ARM: 4 */ -} - -void -flipBtLibFriendlyNameTypeArm268K( unsigned char* out, - const BtLibFriendlyNameType* in ) -{ - write_unaligned32( out + 0, in->name ); - write_unaligned8( out + 4, in->nameLength ); -} - -#endif /* XWFEATURE_BLUETOOTH */ diff --git a/xwords4/palm/pace_man.h b/xwords4/palm/pace_man.h deleted file mode 100644 index 6282863a6..000000000 --- a/xwords4/palm/pace_man.h +++ /dev/null @@ -1,174 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2004-2007 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PACE_MAN_H_ -#define _PACE_MAN_H_ - -#ifdef XW_TARGET_PNO - -#include -#include -#include -#include -#include -#include -#ifdef XWFEATURE_BLUETOOTH -# include -# include -#endif - -#include "pnostate.h" -#include "xptypes.h" - -void* memcpy( void* dest, const void* src, unsigned long n ); -extern Int16 StrPrintF( Char* s, const Char* formatStr, ... ); -extern Int16 StrVPrintF( Char* s, const Char* formatStr, _Palm_va_list arg ); -extern Boolean SysHandleEvent( EventPtr eventP ); -extern void FrmSetEventHandler( FormType* formP, - FormEventHandlerType* handler ); -extern void LstSetListChoices( ListType* listP, Char** itemsText, - Int16 numItems ); -extern Err SysNotifyRegister( UInt16 cardNo, LocalID dbID, - UInt32 notifyType, SysNotifyProcPtr callbackP, - Int8 priority, void* userDataP ); -extern void LstSetDrawFunction( ListType* listP, ListDrawDataFuncPtr func ); -extern Err ExgDBWrite( ExgDBWriteProcPtr writeProcP, void* userDataP, - const char* nameP, LocalID dbID, UInt16 cardNo ); - -#if 0 -# define FUNC_HEADER(n) XP_LOGF( #n " called" ) -# define FUNC_TAIL(n) XP_LOGF( #n " done" ) -#else -# define FUNC_HEADER(n) -# define FUNC_TAIL(n) -#endif - -#define STACK_START(typ, var, siz ) typ var[siz] -#define STACK_END(s) -#define ADD_TO_STACK4(s,val,offset) \ - write_unaligned32( &s[offset], (unsigned long)val ) -#define ADD_TO_STACK2(s,val,offset) \ - write_unaligned16( &s[offset], (unsigned short)val ) -#define ADD_TO_STACK1(s,val,offset) \ - s[offset] = (unsigned char)val; \ - s[offset+1] = 0 - -#define SWAP1_NON_NULL_IN(ptr) if ( !!(ptr) ) { *(ptr) = Byte_Swap16(*(ptr)); } -#define SWAP2_NON_NULL_IN(ptr) if ( !!(ptr) ) { *(ptr) = Byte_Swap16(*(ptr)); } -#define SWAP4_NON_NULL_IN(ptr) if ( !!(ptr) ) { *(ptr) = Byte_Swap32(*(ptr)); } -#define SWAP1_NON_NULL_OUT(ptr) SWAP1_NON_NULL_IN(ptr) -#define SWAP2_NON_NULL_OUT(ptr) SWAP2_NON_NULL_IN(ptr) -#define SWAP4_NON_NULL_OUT(ptr) SWAP4_NON_NULL_IN(ptr) - -#define SET_SEL_REG(trap, sp) ((unsigned long*)((sp)->emulStateP))[3] = (trap) - -void evt68k2evtARM( EventType* event, const unsigned char* evt68k ); -#define SWAP_EVENTTYPE_68K_TO_ARM( dp, sp ) evt68k2evtARM( (dp), (sp) ) -void evtArm2evt68K( unsigned char* evt68k, const EventType* event ); -#define SWAP_EVENTTYPE_ARM_TO_68K( dp, sp ) evtArm2evt68K( (dp), (sp) ) - -void flipRect( RectangleType* rout, const RectangleType* rin ); -#define SWAP_RECTANGLETYPE_ARM_TO_68K( dp, sp ) flipRect( (dp), (sp) ) -#define SWAP_RECTANGLETYPE_68K_TO_ARM SWAP_RECTANGLETYPE_ARM_TO_68K - -void flipFieldAttr( FieldAttrType* fout, const FieldAttrType* fin ); -#define SWAP_FIELDATTRTYPE_ARM_TO_68K( dp, sp ) flipFieldAttr( (dp), (sp) ) - -void flipEngSocketFromArm( unsigned char* sout, const ExgSocketType* sin ); -#define SWAP_EXGSOCKETTYPE_ARM_TO_68K( dp, sp ) flipEngSocketFromArm( (dp), (sp) ) -void flipEngSocketToArm( ExgSocketType* out, const unsigned char* sin ); -#define SWAP_EXGSOCKETTYPE_68K_TO_ARM( dp, sp ) flipEngSocketToArm( (dp), (sp) ) - -void flipFileInfoFromArm( unsigned char* fiout, const FileInfoType* fiin ); -#define SWAP_FILEINFOTYPE_ARM_TO_68K( dp, sp ) \ - flipFileInfoFromArm( (unsigned char*)(dp), (sp) ) -void flipFileInfoToArm( FileInfoType* fout, const unsigned char* fin ); -#define SWAP_FILEINFOTYPE_68K_TO_ARM( dp, sp ) flipFileInfoToArm( (dp), (sp) ) - - -#define SWAP_DATETIMETYPE_ARM_TO_68K( dp, sp ) /* nothing for now */ -void flipDateTimeToArm( DateTimeType* out, const unsigned char* in ); -#define SWAP_DATETIMETYPE_68K_TO_ARM( dp, sp ) flipDateTimeToArm( (dp), (sp) ) - -NetHostInfoPtr NetLibGetHostByName( UInt16 libRefNum, - const Char* nameP, NetHostInfoBufPtr bufP, - Int32 timeout, Err* errP ); - -#ifdef XWFEATURE_BLUETOOTH -void flipBtConnInfoArm268K( unsigned char* out, const BtLibSocketConnectInfoType* in ); -void flipBtSocketListenInfoArm268K( unsigned char* out, - const BtLibSocketListenInfoType* in); - -# define SWAP_BTLIBSOCKETCONNECTINFOTYPE_ARM_TO_68K( out, in ) \ - flipBtConnInfoArm268K( out, in ) -# define SWAP_BTLIBSOCKETCONNECTINFOTYPE_68K_TO_ARM( out, in ) /* nop */ -# define SWAP_BTLIBSOCKETLISTENINFOTYPE_ARM_TO_68K( out, in ) \ - flipBtSocketListenInfoArm268K( out, in ) -# define SWAP_BTLIBSOCKETLISTENINFOTYPE_68K_TO_ARM( out, in ) /* nop */ - -void flipBtLibSdpUuidTypeArm268K( unsigned char* out, - const BtLibSdpUuidType* in ); -void flipBtLibFriendlyNameTypeArm268K( unsigned char* out, - const BtLibFriendlyNameType* in ); - -# define SWAP_BTLIBSDPUUIDTYPE_ARM_TO_68K( out, in ) \ - flipBtLibSdpUuidTypeArm268K( out, in ) -# define SWAP_BTLIBSDPUUIDTYPE_68K_TO_ARM( out, in ) /* nothing */ -# define SWAP_BTLIBFRIENDLYNAMETYPE_ARM_TO_68K( out, in ) \ - flipBtLibFriendlyNameTypeArm268K( out, in ) -# define SWAP_BTLIBFRIENDLYNAMETYPE_68K_TO_ARM( out, in ) /* nothing? */ - -#endif /* XWFEATURE_BLUETOOTH */ - -PNOState* getStorageLoc(void); -#define GET_CALLBACK_STATE() getStorageLoc() - -#define crash() *(int*)1L = 1 - -unsigned long Byte_Swap32( unsigned long l ); -unsigned short Byte_Swap16( unsigned short l ); -void write_unaligned16( unsigned char* dest, unsigned short val ); -void write_unaligned32( unsigned char* dest, unsigned long val ); -#define write_unaligned8( p, v ) *(p) = v - -unsigned short read_unaligned16( const unsigned char* src ); - -#ifdef DEBUG -# define EMIT_NAME(name,bytes) \ - asm( "bal done_" name ); \ - asm( ".byte " bytes ); \ - asm( ".align" ); \ - asm( "done_" name ":" ) - -#else -# define EMIT_NAME(n,b) -#endif - -/* Temporary until can generate */ -#ifdef XWFEATURE_FIVEWAY -#include -extern Err HsNavDrawFocusRing( FormType* formP, UInt16 objectID, - Int16 extraInfo, - RectangleType* boundsInsideRingP, - HsNavFocusRingStyleEnum ringStyle, - Boolean forceRestore); -#endif - -#endif -#endif diff --git a/xwords4/palm/palmblnk.c b/xwords4/palm/palmblnk.c deleted file mode 100644 index ff8ff0ce9..000000000 --- a/xwords4/palm/palmblnk.c +++ /dev/null @@ -1,160 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=ARM_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 1999 - 2009 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 "palmutil.h" -#include "LocalizedStrIncludes.h" - -static Boolean -handleKeysInBlank( EventPtr event ) -{ - Boolean handled = false; - - if ( event->eType == keyDownEvent ) { - char ch = event->data.keyDown.chr; - - if ( ch >= 'a' && ch <= 'z' ) { - ch += 'A' - 'a'; - } - if ( ch >= 'A' && ch <= 'Z' ) { - ListPtr lettersList = getActiveObjectPtr( XW_BLANK_LIST_ID ); - XP_U16 nItems; - XP_U16 ii; - - XP_ASSERT( !!lettersList ); - nItems = LstGetNumberOfItems( lettersList ); - - for ( ii = 0; ii < nItems; ++ii ) { - XP_UCHAR* itext = LstGetSelectionText( lettersList, ii ); - - if ( !!itext && (itext[0] == ch) ) { - LstSetSelection( lettersList, ii ); - LstMakeItemVisible( lettersList, ii ); - handled = true; - break; - } - } - } else if ( ch == '\n' ) { - EventType eventToPost; - - eventToPost.eType = ctlSelectEvent; - eventToPost.data.ctlSelect.controlID = XW_BLANK_OK_BUTTON_ID; - eventToPost.data.ctlSelect.pControl = - getActiveObjectPtr( XW_BLANK_OK_BUTTON_ID ); - EvtAddEventToQueue( &eventToPost ); - } - } - - return handled; -} /* handleKeysInBlank */ - -XP_S16 -askBlankValue( PalmAppGlobals* globals, XP_U16 playerNum, const PickInfo* pi, - XP_U16 nTiles, const XP_UCHAR** texts ) -{ - FormPtr form, prevForm; - ListPtr lettersList; - ListData ld; - XP_U16 i; - XP_S16 chosen; - XP_UCHAR labelBuf[96]; - XP_UCHAR* name; - const XP_UCHAR* labelFmt; - FieldPtr fld; - XP_U16 tapped; -#ifdef FEATURE_TRAY_EDIT - XP_Bool forBlank = pi->why == PICK_FOR_BLANK; -#endif - - initListData( MEMPOOL &ld, nTiles ); - - for ( i = 0; i < nTiles; ++i ) { - addListTextItem( MEMPOOL &ld, texts[i] ); - } - - prevForm = FrmGetActiveForm(); - form = FrmInitForm( XW_BLANK_DIALOG_ID ); - FrmSetActiveForm( form ); - -#ifdef FEATURE_TRAY_EDIT - disOrEnable( form, XW_BLANK_PICK_BUTTON_ID, !forBlank ); - disOrEnable( form, XW_BLANK_BACKUP_BUTTON_ID, - !forBlank && pi->thisPick > 0 ); -#endif - - lettersList = getActiveObjectPtr( XW_BLANK_LIST_ID ); - setListChoices( &ld, lettersList, NULL ); - - LstSetSelection( lettersList, 0 ); - - name = globals->gameInfo.players[playerNum].name; - labelFmt = getResString( globals, -#ifdef FEATURE_TRAY_EDIT - !forBlank? STRS_PICK_TILE: -#endif - STR_PICK_BLANK ); - XP_SNPRINTF( labelBuf, sizeof(labelBuf), labelFmt, name ); - -#ifdef FEATURE_TRAY_EDIT - if ( !forBlank ) { - const char* cur = getResString( globals, STR_PICK_TILE_CUR ); - XP_U16 lenSoFar; - XP_U16 i; - - lenSoFar = XP_STRLEN(labelBuf); - lenSoFar += XP_SNPRINTF( labelBuf + lenSoFar, - sizeof(labelBuf) - lenSoFar, - " (%d/%d)\n%s", pi->thisPick+1, pi->nTotal, - cur ); - - for ( i = 0; i < pi->nCurTiles; ++i ) { - lenSoFar += XP_SNPRINTF( labelBuf+lenSoFar, - sizeof(labelBuf)-lenSoFar, "%s%s", - i==0?": ":", ", pi->curTiles[i] ); - } - } -#endif - - fld = getActiveObjectPtr( XW_BLANK_LABEL_FIELD_ID ); - FldSetTextPtr( fld, labelBuf ); - FldRecalculateField( fld, false ); - - FrmDrawForm( form ); - - FrmSetEventHandler( form, handleKeysInBlank ); - tapped = FrmDoDialog( form ); - - if ( 0 ) { -#ifdef FEATURE_TRAY_EDIT - } else if ( tapped == XW_BLANK_PICK_BUTTON_ID ) { - chosen = PICKER_PICKALL; - } else if ( tapped == XW_BLANK_BACKUP_BUTTON_ID ) { - chosen = PICKER_BACKUP; -#endif - } else { - chosen = LstGetSelection( lettersList ); - } - - FrmDeleteForm( form ); - FrmSetActiveForm( prevForm ); - - freeListData( MEMPOOL &ld ); - - return chosen; -} /* askBlankValue */ diff --git a/xwords4/palm/palmblnk.h b/xwords4/palm/palmblnk.h deleted file mode 100644 index b31015d45..000000000 --- a/xwords4/palm/palmblnk.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 _PALMBLNK_H_ -#define _PALMBLNK_H_ - -XP_S16 -askBlankValue( PalmAppGlobals* globals, XP_U16 playerNum, const PickInfo* pi, - XP_U16 nTiles, const XP_UCHAR** texts ); - -#endif diff --git a/xwords4/palm/palmbt.c b/xwords4/palm/palmbt.c deleted file mode 100644 index a95ed4811..000000000 --- a/xwords4/palm/palmbt.c +++ /dev/null @@ -1,1664 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 2006-2007 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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. - */ - -#ifdef XWFEATURE_BLUETOOTH - -#include "xptypes.h" -#include "palmbt.h" -#include "strutils.h" -#include "palmutil.h" - -# include -# include - -#if defined BT_USE_L2CAP -# define SEL_PROTO btLibL2CapProtocol -# define TRUE_IF_RFCOMM XP_FALSE -#elif defined BT_USE_RFCOMM -# define SEL_PROTO btLibRfCommProtocol -# define TRUE_IF_RFCOMM XP_TRUE -# define INITIAL_CREDIT 50 -#endif - -#define L2CAPSOCKETMTU 500 -#define SOCK_INVAL ((BtLibSocketRef)-1) - -#define DO_SERVICE_RECORD 1 -#define ACL_WAIT_INTERVAL 4 - -typedef enum { PBT_UNINIT = 0, PBT_MASTER, PBT_SLAVE } PBT_PicoRole; - -typedef enum { - PBT_ACT_NONE - , PBT_ACT_MASTER_RESET - , PBT_ACT_SLAVE_RESET - , PBT_ACT_SETUP_LISTEN - , PBT_ACT_CONNECT_ACL - , PBT_ACT_GETSDP /* slave only */ - , PBT_ACT_CONNECT_DATA /* l2cap or rfcomm */ - , PBT_ACT_TELLCONN - , PBT_ACT_GOTDATA /* can be duplicated */ - , PBT_ACT_TRYSEND -} PBT_ACTION; - -#define DUPLICATES_OK(a) ((a) >= PBT_ACT_GOTDATA) - -typedef enum { - PBTST_NONE - , PBTST_LISTENING /* master */ - , PBTST_ACL_CONNECTING /* slave */ - , PBTST_ACL_CONNECTED /* slave */ - , PBTST_SDP_QUERYING /* slave */ - , PBTST_SDP_QUERIED /* slave */ - , PBTST_DATA_CONNECTING /* slave; l2cap or rfcomm */ - , PBTST_DATA_CONNECTED /* slave; l2cap or rfcomm */ -} PBT_STATE; - -#define PBT_MAX_ACTS 8 /* six wasn't enough */ -#define HASWORK(s) ((s)->queueLen > 0) -#define MAX_PACKETS 4 - -typedef struct PBT_queue { - XP_U16 lens[MAX_PACKETS]; - XP_U8 bufs[L2CAPSOCKETMTU*2]; /* what's the mmu? */ -} PBT_queue; - -typedef struct PalmBTStuff { - PalmAppGlobals* globals; - - XP_U16 btLibRefNum; - - struct { - PBT_queue in; - PBT_queue out; - - XP_Bool sendInProgress; - } vol; - - /* peer's addr: passed in by UI in case of slave, received via connection - in case of master. Piconet master will need an array of these. */ - BtLibDeviceAddressType otherAddr; - BtLibSocketRef dataSocket; - PBT_PicoRole picoRole; - PBT_STATE p_connState; - BtLibAccessibleModeEnum accState; - - PBT_ACTION actQueue[PBT_MAX_ACTS]; - XP_U16 queueLen; - - struct /*union*/ { - struct { -#if defined BT_USE_L2CAP - BtLibL2CapPsmType remotePsm; -#elif defined BT_USE_RFCOMM - BtLibRfCommServerIdType remoteService; -#endif - BtLibSocketRef sdpSocket; - } slave; - struct { - BtLibSocketRef listenSocket; -#ifdef DO_SERVICE_RECORD - BtLibSdpRecordHandle sdpRecordH; -#endif - } master; - } u; - -#ifdef DEBUG - struct { - XP_U32 totalSent; - XP_U32 totalRcvd; - XP_U16 maxQueueLen; - } stats; -#endif -} PalmBTStuff; - -#ifdef DEBUG -static void palm_bt_log( const char* btfunc, const char* func, Err err ); -#define LOG_ERR(f,e) palm_bt_log( #f, __func__, e ) -#define CALL_ERR(e,f,...) \ - XP_LOGF( "%s: calling %s", __func__, #f ); \ - e = f(__VA_ARGS__); \ - LOG_ERR(f,e); \ - if ( e == btLibErrFailed ) { XP_WARNF( "%s=>btLibErrFailed", #f ); } -#else -#define CALL_ERR(e,f,...) e = f(__VA_ARGS__) -#endif - -static const BtLibSdpUuidType XWORDS_UUID = { - btLibUuidSize128, - XW_BT_UUID -}; - -static PalmBTStuff* pbt_checkInit( PalmAppGlobals* globals, - XP_Bool* userCancelled ); -static Err pbd_discover( PalmBTStuff* btStuff, BtLibDeviceAddressType* addr ); -static void pbt_setup_slave( PalmBTStuff* btStuff, const CommsAddrRec* addr ); -static void pbt_takedown_slave( PalmBTStuff* btStuff ); -static void pbt_setup_master( PalmBTStuff* btStuff ); -static void pbt_takedown_master( PalmBTStuff* btStuff ); -static void pbt_do_work( PalmBTStuff* btStuff, BtCbEvtProc proc ); -static void pbt_postpone( PalmBTStuff* btStuff, PBT_ACTION act ); -static XP_S16 pbt_enqueue( PBT_queue* queue, const XP_U8* data, XP_S16 len, - XP_Bool addLen, XP_Bool append ); -static void pbt_handoffIncoming( PalmBTStuff* btStuff, BtCbEvtProc proc ); - -static void waitACL( PalmBTStuff* btStuff ); -static void pbt_reset_buffers( PalmBTStuff* btStuff ); -static void pbt_killLinks( PalmBTStuff* btStuff ); -static XP_Bool pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr ); -static Err pbt_nameForAddr( PalmBTStuff* btStuff, - const BtLibDeviceAddressType* addr, - char* const out, XP_U16 outlen ); - -#ifdef DEBUG -static void pbt_setstate( PalmBTStuff* btStuff, PBT_STATE newState, - const char* whence ); -# define SET_STATE(b,s) pbt_setstate((b),(s),__func__) -#else -# define SET_STATE(b,s) (b)->p_connState = (s) -#endif -#define GET_STATE(b) ((b)->p_connState) - -#ifdef DEBUG -static const char* btErrToStr( Err err ); -static const char* btEvtToStr( BtLibSocketEventEnum evt ); -static const char* mgmtEvtToStr( BtLibManagementEventEnum event ); -static const char* actToStr(PBT_ACTION act); -static const char* stateToStr(PBT_STATE st); -static const char* connEnumToStr( BtLibAccessibleModeEnum mode ); -static const char* proleToString( PBT_PicoRole r ); - -#else -# define btErrToStr( err ) "" -# define btEvtToStr( evt ) "" -# define mgmtEvtToStr( evt ) "" -# define actToStr(act) "" -# define stateToStr(st) "" -# define connEnumToStr(mode) "" -# define proleToString(r) "" -#endif - -/* callbacks */ -static void libMgmtCallback( BtLibManagementEventType* mEvent, UInt32 refCon ); -static void socketCallback( BtLibSocketEventType* sEvent, UInt32 refCon ); - -XP_Bool -palm_bt_init( PalmAppGlobals* globals, XP_Bool* userCancelled ) -{ - XP_Bool inited; - PalmBTStuff* btStuff; - - LOG_FUNC(); - - btStuff = globals->btStuff; - if ( !btStuff ) { - btStuff = pbt_checkInit( globals, userCancelled ); - } else { - pbt_reset_buffers( btStuff ); - pbt_killLinks( btStuff ); - } - - /* Don't try starting master or slave: we don't know which we are yet. - Wait for the first send attempt.*/ - - inited = !!btStuff; - if ( inited ) { - btStuff->picoRole = PBT_UNINIT; - } - LOG_RETURNF( "%d", (XP_U16)inited ); - return inited; -} /* palm_bt_init */ - -void -palm_bt_reset( PalmAppGlobals* globals ) -{ - PalmBTStuff* btStuff = globals->btStuff; - - if ( !!btStuff ) { - if ( btStuff->picoRole == PBT_MASTER ) { - pbt_takedown_master( btStuff ); - pbt_postpone( btStuff, PBT_ACT_MASTER_RESET ); - } else if ( btStuff->picoRole == PBT_SLAVE ) { - pbt_takedown_slave( btStuff ); - pbt_postpone( btStuff, PBT_ACT_SLAVE_RESET ); - } - } -} - -void -palm_bt_close( PalmAppGlobals* globals ) -{ - PalmBTStuff* btStuff = globals->btStuff; - - if ( !!btStuff ) { - XP_U16 btLibRefNum = btStuff->btLibRefNum; - if ( btLibRefNum != 0 ) { - Err err; - - if ( btStuff->picoRole == PBT_MASTER ) { - pbt_takedown_master( btStuff ); - } else if ( btStuff->picoRole == PBT_SLAVE ) { - pbt_takedown_slave( btStuff ); - } - - /* Need to unregister callbacks */ - CALL_ERR( err, BtLibUnregisterManagementNotification, btLibRefNum, - libMgmtCallback ); - XP_ASSERT( errNone == err ); - CALL_ERR( err, BtLibClose, btLibRefNum ); - XP_ASSERT( errNone == err ); - } - XP_FREE( globals->mpool, btStuff ); - globals->btStuff = NULL; - } else { - XP_LOGF( "%s: btStuff null", __func__ ); - } -} /* palm_bt_close */ - -void -palm_bt_amendWaitTicks( PalmAppGlobals* globals, Int32* result ) -{ - PalmBTStuff* btStuff = globals->btStuff; - if ( !!btStuff && HASWORK(btStuff) ) { - *result = 0; - } -} - -XP_Bool -palm_bt_doWork( PalmAppGlobals* globals, BtCbEvtProc proc, BtUIState* btUIStateP ) -{ - PalmBTStuff* btStuff = globals->btStuff; - XP_Bool haveWork = !!btStuff && HASWORK(btStuff); - - if ( haveWork ) { - pbt_do_work( btStuff, proc ); - } - if ( !!btStuff && !!btUIStateP ) { - BtUIState btUIState = BTUI_NONE; /* default */ - switch( GET_STATE(btStuff) ) { - case PBTST_NONE: - break; - case PBTST_LISTENING: - btUIState = BTUI_LISTENING; - break; - case PBTST_ACL_CONNECTING: - case PBTST_ACL_CONNECTED: - case PBTST_SDP_QUERYING: - case PBTST_SDP_QUERIED: - case PBTST_DATA_CONNECTING: - btUIState = BTUI_CONNECTING; - break; - case PBTST_DATA_CONNECTED: - btUIState = btStuff->picoRole == PBT_MASTER? - BTUI_SERVING : BTUI_CONNECTED; - break; - default: - XP_ASSERT(0); /* Don't add new states without handling here */ - break; - } - *btUIStateP = btUIState; - } - return haveWork; -} /* palm_bt_doWork */ - -void -palm_bt_addrString( PalmAppGlobals* globals, const XP_BtAddr* btAddr, - XP_BtAddrStr* str ) -{ - PalmBTStuff* btStuff = pbt_checkInit( globals, NULL ); - str->chars[0] = '\0'; - if ( !!btStuff ) { - Err err; - CALL_ERR( err, BtLibAddrBtdToA, btStuff->btLibRefNum, - (BtLibDeviceAddressType*)btAddr, - (char*)str, sizeof(*str) ); - XP_LOGF( "BtLibAddrBtdToA=>%s from:", str ); - LOG_HEX( btAddr, sizeof(*btAddr), "" ); - } -} /* palm_bt_addrString */ - -XP_Bool -palm_bt_browse_device( PalmAppGlobals* globals, XP_BtAddr* btAddr, - XP_UCHAR* out, XP_U16 len ) -{ - XP_Bool success = XP_FALSE; - PalmBTStuff* btStuff; - - LOG_FUNC(); - - btStuff = pbt_checkInit( globals, NULL ); - if ( NULL != btStuff ) { - BtLibDeviceAddressType addr; - Err err = pbd_discover( btStuff, &addr ); - - if ( errNone == err ) { - XP_MEMCPY( btAddr, &addr, sizeof(addr) ); - LOG_HEX( &btAddr, sizeof(btAddr), __func__ ); - - err = pbt_nameForAddr( btStuff, &addr, out, len ); - } - success = errNone == err; - } - LOG_RETURNF( "%d", (XP_U16)success ); - return success; -} /* palm_bt_browse_device */ - -#ifdef DEBUG -void -palm_bt_getStats( PalmAppGlobals* globals, XWStreamCtxt* stream ) -{ - PalmBTStuff* btStuff = globals->btStuff; - if ( !btStuff ) { - stream_catString( stream, "bt not initialized" ); - } else { - char buf[64]; - XP_U16 cur; - - XP_SNPRINTF( buf, sizeof(buf), "Role: %s\n", - btStuff->picoRole == PBT_MASTER? "master": - (btStuff->picoRole == PBT_SLAVE? "slave":"unknown") ); - stream_catString( stream, buf ); - XP_SNPRINTF( buf, sizeof(buf), "State: %s\n", - stateToStr( GET_STATE(btStuff)) ); - stream_catString( stream, buf ); - - XP_SNPRINTF( buf, sizeof(buf), "%d actions queued:\n", - btStuff->queueLen ); - stream_catString( stream, buf ); - for ( cur = 0; cur < btStuff->queueLen; ++cur ) { - XP_SNPRINTF( buf, sizeof(buf), " - %s\n", - actToStr( btStuff->actQueue[cur] ) ); - stream_catString( stream, buf ); - } - - XP_SNPRINTF( buf, sizeof(buf), "total sent: %ld\n", - btStuff->stats.totalSent ); - stream_catString( stream, buf ); - XP_SNPRINTF( buf, sizeof(buf), "total rcvd: %ld\n", - btStuff->stats.totalRcvd ); - stream_catString( stream, buf ); - XP_SNPRINTF( buf, sizeof(buf), "max act queue len seen: %d\n", - btStuff->stats.maxQueueLen ); - stream_catString( stream, buf ); - } -} -#endif - -static Err -pbt_nameForAddr( PalmBTStuff* btStuff, const BtLibDeviceAddressType* addr, - char* const out, XP_U16 outlen ) -{ - Err err; - UInt8 name[PALM_BT_NAME_LEN]; - BtLibFriendlyNameType nameType = { - .name = name, - .nameLength = sizeof(name) - }; - - CALL_ERR( err, BtLibGetRemoteDeviceName, btStuff->btLibRefNum, - (BtLibDeviceAddressType*)addr, &nameType, - btLibCachedThenRemote ); - if ( errNone == err ) { - XP_LOGF( "%s: got name %s", __func__, nameType.name ); - - XP_ASSERT( outlen >= nameType.nameLength ); - XP_MEMCPY( out, nameType.name, nameType.nameLength ); - } - return err; -} - -static XP_U16 -pbt_peekQueue( const PBT_queue* queue, const XP_U8** bufp ) -{ - XP_U16 len = queue->lens[0]; - if ( len > 0 ) { - *bufp = &queue->bufs[0]; - } - LOG_RETURNF( "%d", len ); - return len; -} - -static XP_U16 -pbt_shiftQueue( PBT_queue* queue ) -{ - XP_U16 len = queue->lens[0]; - XP_ASSERT( len != 0 ); - XP_MEMCPY( &queue->lens[0], &queue->lens[1], - sizeof(queue->lens) - sizeof(queue->lens[0]) ); - queue->lens[MAX_PACKETS-1] = 0; /* be safe */ - XP_MEMCPY( queue->bufs, queue->bufs + len, - sizeof(queue->bufs) - len ); - return len; -} /* pbt_shiftQueue */ - -static void -pbt_send_pending( PalmBTStuff* btStuff ) -{ - Err err; - LOG_FUNC(); - - if ( !btStuff->vol.sendInProgress && (SOCK_INVAL != btStuff->dataSocket)) { - const XP_U8* buf; - XP_U16 len = pbt_peekQueue( &btStuff->vol.out, &buf ); - if ( len > 0 ) { -#ifdef LOG_BTIO - LOG_HEX( buf, len, "to BtLibSocketSend" ); -#endif - XP_LOGF( "sending on socket %d", btStuff->dataSocket ); - CALL_ERR( err, BtLibSocketSend, btStuff->btLibRefNum, - btStuff->dataSocket, (char*)buf, len ); - if ( btLibErrPending == err ) { - btStuff->vol.sendInProgress = XP_TRUE; - } - } - } - LOG_RETURN_VOID(); -} /* pbt_send_pending */ - -XP_S16 -palm_bt_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, - PalmAppGlobals* globals, XP_Bool* userCancelled ) -{ - XP_S16 nSent = -1; - PalmBTStuff* btStuff; - CommsAddrRec remoteAddr; - PBT_PicoRole picoRole; - XP_LOGF( "%s(len=%d)", __func__, len); - - XP_ASSERT( !!globals->game.comms ); - - btStuff = pbt_checkInit( globals, userCancelled ); - if ( !!btStuff ) { - /* addr is NULL when client has not established connection to host */ - if ( !addr ) { - comms_getAddr( globals->game.comms, &remoteAddr ); - addr = &remoteAddr; - } - XP_ASSERT( !!addr ); - - picoRole = btStuff->picoRole; - XP_LOGF( "%s: role=%s", __func__, proleToString(picoRole) ); - if ( picoRole == PBT_UNINIT ) { - XP_Bool amMaster = comms_getIsServer( globals->game.comms ); - picoRole = amMaster? PBT_MASTER : PBT_SLAVE; - } - - (void)pbt_checkAddress( btStuff, addr ); - - if ( picoRole == PBT_MASTER ) { - pbt_setup_master( btStuff ); - } else { - pbt_setup_slave( btStuff, addr ); - } - - nSent = pbt_enqueue( &btStuff->vol.out, buf, len, TRUE_IF_RFCOMM, XP_FALSE ); - pbt_send_pending( btStuff ); - } - LOG_RETURNF( "%d", nSent ); - return nSent; -} /* palm_bt_send */ - - -#ifdef DO_SERVICE_RECORD -static XP_Bool -setupServiceRecord( PalmBTStuff* btStuff ) -{ - Err err; - /* 3. BtLibSdpServiceRecordCreate: allocate a memory chunk that - represents an SDP service record. */ - CALL_ERR( err, BtLibSdpServiceRecordCreate, - btStuff->btLibRefNum, &btStuff->u.master.sdpRecordH ); - - /* 4. BtLibSdpServiceRecordSetAttributesForSocket: initialize an - SDP memory record so it can represent the newly-created L2CAP - listener socket as a service */ - if ( errNone == err ) { - CALL_ERR( err, BtLibSdpServiceRecordSetAttributesForSocket, - btStuff->btLibRefNum, btStuff->u.master.listenSocket, - (BtLibSdpUuidType*)&XWORDS_UUID, 1, XW_BT_NAME, - StrLen(XW_BT_NAME), btStuff->u.master.sdpRecordH ); - - /* 5. BtLibSdpServiceRecordStartAdvertising: make an SDP memory - record representing a local SDP service record visible to - remote devices. */ - if ( errNone == err ) { - CALL_ERR( err, BtLibSdpServiceRecordStartAdvertising, - btStuff->btLibRefNum, btStuff->u.master.sdpRecordH ); - } - } - /* If this fails commonly, need to free the structure and try again */ - XP_ASSERT( errNone == err ); - return errNone == err; -} /* setupServiceRecord */ -#else -# define setupServiceRecord(b) XP_TRUE -#endif - -static void -pbt_setup_master( PalmBTStuff* btStuff ) -{ - if ( btStuff->picoRole == PBT_SLAVE ) { - pbt_takedown_slave( btStuff ); - } - btStuff->picoRole = PBT_MASTER; - - if ( btStuff->u.master.listenSocket == SOCK_INVAL ) { - /* Will eventually want to create a piconet here for more than two - devices to play.... */ - - Err err; - BtLibSocketListenInfoType listenInfo; - - /* 1. BtLibSocketCreate: create an L2CAP socket. */ - CALL_ERR( err, BtLibSocketCreate, btStuff->btLibRefNum, - &btStuff->u.master.listenSocket, socketCallback, - (UInt32)btStuff, SEL_PROTO ); - XP_ASSERT( errNone == err ); - - /* 2. BtLibSocketListen: set up an L2CAP socket as a listener. */ - XP_MEMSET( &listenInfo, 0, sizeof(listenInfo) ); -#if defined BT_USE_L2CAP - listenInfo.data.L2Cap.localPsm = BT_L2CAP_RANDOM_PSM; - listenInfo.data.L2Cap.localMtu = L2CAPSOCKETMTU; - listenInfo.data.L2Cap.minRemoteMtu = L2CAPSOCKETMTU; -#elif defined BT_USE_RFCOMM - // remoteService: assigned by rfcomm - listenInfo.data.RfComm.maxFrameSize = BT_RF_DEFAULT_FRAMESIZE; - listenInfo.data.RfComm.advancedCredit = INITIAL_CREDIT; -#endif - /* Doesn't send events; returns errNone unless no resources avail. */ - CALL_ERR( err, BtLibSocketListen, btStuff->btLibRefNum, - btStuff->u.master.listenSocket, &listenInfo ); - if ( (errNone == err) && setupServiceRecord( btStuff ) ) { - /* Set state here to indicate I'm available, at least for - debugging? */ - SET_STATE( btStuff, PBTST_LISTENING ); - } else { - CALL_ERR( err, BtLibSocketClose, btStuff->btLibRefNum, - btStuff->u.master.listenSocket ); - btStuff->u.master.listenSocket = SOCK_INVAL; - pbt_postpone( btStuff, PBT_ACT_SETUP_LISTEN ); - } - } - XP_ASSERT( NULL != btStuff->u.master.sdpRecordH ); -} /* pbt_setup_master */ - -static void -pbt_close_datasocket( PalmBTStuff* btStuff ) -{ - if ( SOCK_INVAL != btStuff->dataSocket ) { - Err err; - CALL_ERR( err, BtLibSocketClose, btStuff->btLibRefNum, - btStuff->dataSocket ); - XP_ASSERT( err == errNone ); - btStuff->dataSocket = SOCK_INVAL; - } -} - -static void -pbt_close_sdpsocket( PalmBTStuff* btStuff ) -{ - XP_ASSERT( PBT_SLAVE == btStuff->picoRole ); - if ( SOCK_INVAL != btStuff->u.slave.sdpSocket ) { - Err err; - CALL_ERR( err, BtLibSocketClose, btStuff->btLibRefNum, btStuff->u.slave.sdpSocket ); - btStuff->u.slave.sdpSocket = SOCK_INVAL; - } -} - -static void -pbt_takedown_master( PalmBTStuff* btStuff ) -{ - XP_U16 btLibRefNum; - Err err; - - LOG_FUNC(); - - XP_ASSERT( btStuff->picoRole == PBT_MASTER ); - btLibRefNum = btStuff->btLibRefNum; - - pbt_close_datasocket( btStuff ); - -#ifdef DO_SERVICE_RECORD - if ( !!btStuff->u.master.sdpRecordH ) { - CALL_ERR( err, BtLibSdpServiceRecordStopAdvertising, - btLibRefNum, btStuff->u.master.sdpRecordH ); - XP_ASSERT( errNone == err ); /* no errors if it was being advertised */ - - CALL_ERR( err, BtLibSdpServiceRecordDestroy, btLibRefNum, - btStuff->u.master.sdpRecordH ); - btStuff->u.master.sdpRecordH = NULL; - } -#endif - - if ( SOCK_INVAL != btStuff->u.master.listenSocket ) { - CALL_ERR( err, BtLibSocketClose, btLibRefNum, - btStuff->u.master.listenSocket ); - btStuff->u.master.listenSocket = SOCK_INVAL; - XP_ASSERT( err == errNone ); - } - - btStuff->picoRole = PBT_UNINIT; - SET_STATE( btStuff, PBTST_NONE ); - LOG_RETURN_VOID(); -} /* pbt_takedown_master */ - -#if 0 -static void -debug_logQueue( const PalmBTStuff* const btStuff ) -{ - XP_U16 i; - XP_U16 len = btStuff->queueLen; - XP_LOGF( "%s: queue len = %d", __func__, len ); - for ( i = 0; i < len; ++i ) { - XP_LOGF( "\t%d: %s", i, actToStr( btStuff->actQueue[i] ) ); - } -} -#else -#define debug_logQueue( bts ) -#endif - -static void -pbt_do_work( PalmBTStuff* btStuff, BtCbEvtProc proc ) -{ - PBT_ACTION act; - Err err; - XP_U16 btLibRefNum = btStuff->btLibRefNum; - BtCbEvtInfo info; - - debug_logQueue( btStuff ); - - act = btStuff->actQueue[0]; - --btStuff->queueLen; - XP_MEMCPY( &btStuff->actQueue[0], &btStuff->actQueue[1], - btStuff->queueLen * sizeof(btStuff->actQueue[0]) ); - - XP_LOGF( "%s: evt=%s; state=%s", __func__, actToStr(act), - stateToStr(GET_STATE(btStuff)) ); - - switch( act ) { - case PBT_ACT_MASTER_RESET: - pbt_setup_master( btStuff ); - break; - case PBT_ACT_SLAVE_RESET: - pbt_setup_slave( btStuff, NULL ); - break; - case PBT_ACT_SETUP_LISTEN: - pbt_setup_master( btStuff ); - break; - - case PBT_ACT_CONNECT_ACL: - XP_ASSERT( PBT_SLAVE == btStuff->picoRole ); - if ( GET_STATE(btStuff) == PBTST_NONE ) { - UInt8 name[PALM_BT_NAME_LEN]; - (void)pbt_nameForAddr( btStuff, &btStuff->otherAddr, - name, sizeof(name) ); - info.evt = BTCBEVT_CONFIRM; - info.u.confirm.hostName = name; - info.u.confirm.confirmed = XP_TRUE; - (*proc)( btStuff->globals, &info ); - if ( !info.u.confirm.confirmed ) { - break; - } - - /* sends btLibManagementEventACLConnectOutbound */ - CALL_ERR( err, BtLibLinkConnect, btLibRefNum, - &btStuff->otherAddr ); - if ( btLibErrPending == err ) { - SET_STATE( btStuff, PBTST_ACL_CONNECTING ); - } else if ( btLibErrAlreadyConnected == err ) { - SET_STATE( btStuff, PBTST_ACL_CONNECTED ); - pbt_postpone( btStuff, PBT_ACT_GETSDP ); - } - } - break; - - case PBT_ACT_GETSDP: - if ( PBTST_ACL_CONNECTED == GET_STATE(btStuff) ) { - XP_ASSERT( SOCK_INVAL == btStuff->u.slave.sdpSocket ); - CALL_ERR( err, BtLibSocketCreate, btStuff->btLibRefNum, - &btStuff->u.slave.sdpSocket, socketCallback, (UInt32)btStuff, - btLibSdpProtocol ); - if ( err == errNone ) { -#if defined BT_USE_L2CAP - XP_LOGF( "sending on sdpSocket socket %d", btStuff->u.slave.sdpSocket ); - CALL_ERR( err, BtLibSdpGetPsmByUuid, btStuff->btLibRefNum, - btStuff->u.slave.sdpSocket, &btStuff->otherAddr, - (BtLibSdpUuidType*)&XWORDS_UUID, 1 ); -#elif defined BT_USE_RFCOMM - CALL_ERR( err, BtLibSdpGetServerChannelByUuid, - btStuff->btLibRefNum, btStuff->u.slave.sdpSocket, - &btStuff->otherAddr, - (BtLibSdpUuidType*)&XWORDS_UUID, 1 ); -#endif - if ( err == errNone ) { - SET_STATE( btStuff, PBTST_SDP_QUERIED ); - pbt_postpone( btStuff, PBT_ACT_CONNECT_DATA ); - break; - } else if ( err == btLibErrPending ) { - SET_STATE( btStuff, PBTST_SDP_QUERYING ); - break; - } else if ( err == btLibErrNoAclLink ) { - /* fall through to waitACL below */ - } else { - XP_ASSERT(0); - } - } - } - /* Presumably state's been reset since PBT_ACT_GETSDP issued */ - XP_LOGF( "aborting b/c state wrong" ); - XP_ASSERT( PBT_SLAVE == btStuff->picoRole ); - pbt_close_sdpsocket( btStuff ); - SET_STATE( btStuff, PBTST_NONE ); - waitACL( btStuff ); - break; - - case PBT_ACT_CONNECT_DATA: - XP_ASSERT( btStuff->picoRole == PBT_SLAVE ); - if ( GET_STATE(btStuff) == PBTST_SDP_QUERIED ) { - pbt_close_datasocket( btStuff ); - CALL_ERR( err, BtLibSocketCreate, btLibRefNum, - &btStuff->dataSocket, - socketCallback, (UInt32)btStuff, SEL_PROTO ); - - if ( btLibErrNoError == err ) { - BtLibSocketConnectInfoType connInfo; - connInfo.remoteDeviceP = &btStuff->otherAddr; -#if defined BT_USE_L2CAP - connInfo.data.L2Cap.remotePsm = btStuff->u.slave.remotePsm; - connInfo.data.L2Cap.localMtu = L2CAPSOCKETMTU; - connInfo.data.L2Cap.minRemoteMtu = L2CAPSOCKETMTU; -#elif defined BT_USE_RFCOMM - connInfo.data.RfComm.remoteService - = btStuff->u.slave.remoteService; - connInfo.data.RfComm.maxFrameSize = BT_RF_DEFAULT_FRAMESIZE; - connInfo.data.RfComm.advancedCredit = INITIAL_CREDIT; -#else - XP_ASSERT(0); -#endif - /* sends btLibSocketEventConnectedOutbound */ - CALL_ERR( err, BtLibSocketConnect, btLibRefNum, - btStuff->dataSocket, &connInfo ); - if ( errNone == err ) { - SET_STATE( btStuff, PBTST_DATA_CONNECTED ); - } else if ( btLibErrPending == err ) { - SET_STATE( btStuff, PBTST_DATA_CONNECTING ); - } else { - SET_STATE( btStuff, PBTST_NONE ); - waitACL( btStuff ); - } - } else { - btStuff->dataSocket = SOCK_INVAL; - } - } - - break; - - case PBT_ACT_GOTDATA: -#ifdef BT_USE_RFCOMM - CALL_ERR( err, BtLibSocketAdvanceCredit, btLibRefNum, btStuff->dataSocket, 5 ); -#endif - pbt_handoffIncoming( btStuff, proc ); - break; - - case PBT_ACT_TRYSEND: - pbt_send_pending( btStuff ); - break; - - case PBT_ACT_TELLCONN: - XP_ASSERT( !!proc ); - info.evt = BTCBEVT_CONN; - (*proc)( btStuff->globals, &info ); - break; - - default: - XP_ASSERT( 0 ); - } - LOG_RETURN_VOID(); -} /* pbt_do_work */ - -static void -pbt_postpone( PalmBTStuff* btStuff, PBT_ACTION act ) -{ - postEmptyEvent( noopEvent ); - - XP_LOGF( "%s(%s)", __func__, actToStr(act) ); - - if ( DUPLICATES_OK(act) - || (btStuff->queueLen == 0) - || (act != btStuff->actQueue[btStuff->queueLen-1]) ) { - btStuff->actQueue[ btStuff->queueLen++ ] = act; - XP_ASSERT( btStuff->queueLen < PBT_MAX_ACTS ); -#ifdef DEBUG - if ( btStuff->queueLen > btStuff->stats.maxQueueLen ) { - btStuff->stats.maxQueueLen = btStuff->queueLen; - } -#endif - } else { - XP_LOGF( "%s already at tail of queue; not adding", actToStr(act) ); - } - debug_logQueue( btStuff ); -} - -static void -getSizeIndex( PBT_queue* queue, XP_U16* index, XP_U16* totalP ) -{ - XP_U16 i; - XP_U16 total = 0; - for ( i = 0; i < MAX_PACKETS; ++i ) { - XP_U16 curlen = queue->lens[i]; - if ( !curlen ) { - break; - } - total += curlen; - } - XP_LOGF( "%s=>index:%d, total: %d", __func__, i, total ); - *index = i; - *totalP = total; -} /* getSizeIndex */ - -static XP_S16 -pbt_enqueue( PBT_queue* queue, const XP_U8* data, const XP_S16 len, - XP_Bool addLen, XP_Bool append ) -{ - XP_S16 result; - XP_U16 index; - XP_U16 total = 0; - XP_U16 lensiz = 0; - - XP_ASSERT( len > 0 || !addLen ); - - if ( addLen ) { - lensiz = sizeof(len); - } - - getSizeIndex( queue, &index, &total ); - - if ( append ) { - XP_ASSERT( index > 0 ); - --index; - } - - if ( (index < MAX_PACKETS) && ((total + len + lensiz) < sizeof(queue->bufs)) ) { - if ( !append ) { - queue->lens[index] = 0; - } - - queue->lens[index] += len + lensiz; - if ( addLen ) { - XP_U16 plen = XP_HTONS(len); - XP_LOGF( "writing plen: %x", plen ); - XP_MEMCPY( &queue->bufs[total], &plen, sizeof(plen) ); - total += sizeof(plen); - } - XP_MEMCPY( &queue->bufs[total], data, len ); -/* XP_LOGF( "%s: adding %d; total now %d (%d packets)", - __func__, */ -/* len, len+total, i+1 ); */ - result = len; - } else { - XP_LOGF( "%s: dropping packet of len %d", __func__, len ); - result = -1; - } - return result; -} /* pbt_enqueue */ - -static void -pbt_handoffIncoming( PalmBTStuff* btStuff, BtCbEvtProc proc ) -{ - const XP_U8* buf; - XP_U16 len; - - len = pbt_peekQueue( &btStuff->vol.in, &buf ); - - if ( len > 0 ) { - BtCbEvtInfo info; - CommsAddrRec fromAddr; - - XP_ASSERT( !!proc ); - - fromAddr.conType = COMMS_CONN_BT; - XP_MEMCPY( &fromAddr.u.bt.btAddr, &btStuff->otherAddr, - sizeof(fromAddr.u.bt.btAddr) ); - - info.evt = BTCBEVT_DATA; - info.u.data.fromAddr = &fromAddr; -#ifdef BT_USE_RFCOMM - XP_LOGF( "plen=%d; len=%d", *(XP_U16*)buf, len-2 ); - XP_ASSERT( *(XP_U16*)buf == len - sizeof(XP_U16) ); /* firing */ - info.u.data.len = len - sizeof(XP_U16); - info.u.data.data = buf + sizeof(XP_U16); -#else - info.u.data.len = len; - info.u.data.data = buf; -#endif - (*proc)( btStuff->globals, &info ); - - pbt_shiftQueue( &btStuff->vol.in ); - } -} /* pbt_handoffIncoming */ - -static void -pbt_reset_buffers( PalmBTStuff* btStuff ) -{ - LOG_FUNC(); - XP_MEMSET( &btStuff->vol, 0, sizeof(btStuff->vol) ); - - LOG_RETURN_VOID(); -} - -static XP_Bool -btTimerProc( void* closure, XWTimerReason why ) -{ - PalmBTStuff* btStuff; - XP_ASSERT( why == TIMER_ACL_BACKOFF ); - btStuff = (PalmBTStuff*)closure; - if ( GET_STATE(btStuff) != PBTST_NONE ) { - XP_LOGF( "%s ignoring; have changed states", __func__ ); - } else if ( PBT_SLAVE != btStuff->picoRole ) { - XP_LOGF( "%s ignoring; have changed roles", __func__ ); - } else { - pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL ); - } - return XP_TRUE; -} - -static void -waitACL( PalmBTStuff* btStuff ) -{ - util_setTimer( &btStuff->globals->util, TIMER_ACL_BACKOFF, - ACL_WAIT_INTERVAL, btTimerProc, btStuff ); -} - -static Err -pbd_discover( PalmBTStuff* btStuff, BtLibDeviceAddressType* addr ) -{ - Err err; - const BtLibClassOfDeviceType deviceFilter - = btLibCOD_ServiceAny - | btLibCOD_Major_Any // btLibCOD_Major_Computer - | btLibCOD_Minor_Comp_Any; //btLibCOD_Minor_Comp_Palm; - - CALL_ERR( err, BtLibDiscoverSingleDevice, btStuff->btLibRefNum, - "Crosswords host", (BtLibClassOfDeviceType*)&deviceFilter, 1, - addr, false, false ); - return err; -} /* pbd_discover */ - -static void -pbt_setup_slave( PalmBTStuff* btStuff, const CommsAddrRec* addr ) -{ - XP_LOGF( "%s; state=%s", __func__, stateToStr(GET_STATE(btStuff))); - - if ( btStuff->picoRole == PBT_MASTER ) { - pbt_takedown_master( btStuff ); - } - btStuff->picoRole = PBT_SLAVE; - btStuff->u.slave.sdpSocket = SOCK_INVAL; - - if ( !!addr ) { - char buf[64]; - if ( errNone == - BtLibAddrBtdToA( btStuff->btLibRefNum, - (BtLibDeviceAddressType*)&addr->u.bt.btAddr, - buf, sizeof(buf) ) ) { - XP_LOGF( "%s(%s)", __func__, buf ); - } - } else { - XP_LOGF( "null addr" ); - } - - if ( GET_STATE(btStuff) == PBTST_NONE ) { - pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL ); - } else { - XP_LOGF( "%s: doing nothing", __func__ ); - } - LOG_RETURN_VOID(); -} /* pbt_setup_slave */ - -static void -pbt_takedown_slave( PalmBTStuff* btStuff ) -{ - pbt_killLinks( btStuff ); - btStuff->picoRole = PBT_UNINIT; -} - -static PalmBTStuff* -pbt_checkInit( PalmAppGlobals* globals, XP_Bool* userCancelledP ) -{ - PalmBTStuff* btStuff = globals->btStuff; - XP_Bool userCancelled = XP_FALSE; - if ( !btStuff ) { - Err err; - XP_U16 btLibRefNum; - - CALL_ERR( err, SysLibFind, btLibName, &btLibRefNum ); - if ( errNone == err ) { - CALL_ERR( err, BtLibOpen, btLibRefNum, false ); - - userCancelled = err == btLibErrBluetoothOff; - - /* BT is probably off if this fails */ - if ( errNone == err ) { - btStuff = XP_MALLOC( globals->mpool, sizeof(*btStuff) ); - XP_ASSERT( !!btStuff ); - globals->btStuff = btStuff; - - XP_MEMSET( btStuff, 0, sizeof(*btStuff) ); - btStuff->globals = globals; - btStuff->btLibRefNum = btLibRefNum; - - btStuff->dataSocket = SOCK_INVAL; - btStuff->u.master.listenSocket = SOCK_INVAL; - btStuff->u.slave.sdpSocket = SOCK_INVAL; - - CALL_ERR( err, BtLibRegisterManagementNotification, - btLibRefNum, libMgmtCallback, (UInt32)btStuff ); - } - } - } - - if ( !!userCancelledP ) { - *userCancelledP = userCancelled; - } - - return btStuff; -} /* pbt_checkInit */ - -static void -pbt_killLinks( PalmBTStuff* btStuff ) -{ - Err err; - - pbt_close_datasocket( btStuff ); - - if ( PBT_SLAVE == btStuff->picoRole ) { - pbt_close_sdpsocket( btStuff ); - } - - /* Harm in calling this when not connected? */ - if ( GET_STATE(btStuff) != PBTST_NONE ) { - SET_STATE( btStuff, PBTST_NONE ); /* set first */ - /* sends btLibManagementEventACLDisconnect */ - CALL_ERR( err, BtLibLinkDisconnect, btStuff->btLibRefNum, - &btStuff->otherAddr ); - } -} /* pbt_killLinks */ - -static XP_Bool -pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr ) -{ - XP_Bool addrOk; - LOG_FUNC(); - XP_ASSERT( !!addr ); - - addrOk = 0 == XP_MEMCMP( &btStuff->otherAddr, &addr->u.bt.btAddr.bits, - sizeof(addr->u.bt.btAddr.bits) ); - if ( !addrOk ) { - LOG_HEX( &btStuff->otherAddr, sizeof(addr->u.bt.btAddr.bits), - "cur" ); - LOG_HEX( &addr->u.bt.btAddr.bits, sizeof(addr->u.bt.btAddr.bits), - "new" ); - - pbt_killLinks( btStuff ); - - XP_MEMCPY( &btStuff->otherAddr, &addr->u.bt.btAddr, - sizeof(btStuff->otherAddr) ); - } - LOG_RETURNF( "%d", (int)addrOk ); - return addrOk; -} /* pbt_checkAddress */ - -#ifdef DEBUG -static void -pbt_setstate( PalmBTStuff* btStuff, PBT_STATE newState, const char* whence ) -{ - btStuff->p_connState = newState; - XP_LOGF( "setting state to %s, from %s", stateToStr(newState), whence ); -} -#endif - -#ifdef BT_USE_RFCOMM - -static XP_U16 -pbt_packetPending( PalmBTStuff* btStuff ) -{ - XP_U16 pending; - XP_U16 index, total; - PBT_queue* queue = &btStuff->vol.in; - - /* Packet consists of two bytes of len plus len bytes of data. An - incomplete packet has len but less than len bytes of data. When we - write the len we add a packet but that's all. - - Total and index get us beyond the last packet written. If index is 0, - nothing's been written so packet is pending. Otherwise we can back - index off and look at the buffer there. Buffer starts at total - lens[--index]. - Len will be written there. If lens[index] is less, it's pending. - */ - getSizeIndex( queue, &index, &total ); - if ( total < sizeof(XP_U16) ) { - XP_ASSERT( total == 0 ); - pending = 0; - } else { - XP_U16 curLen, plen; - XP_U8* curStart; - --index; - curLen = queue->lens[index]; - curStart = &queue->bufs[total-curLen]; - plen = *(XP_U16*)curStart; - pending = plen - (curLen - sizeof(plen)); - } - LOG_RETURNF( "%d", pending ); - return pending; -} - -static void -pbt_assemble( PalmBTStuff* btStuff, unsigned char* data, XP_U16 len ) -{ - XP_U16 bytesPending = pbt_packetPending( btStuff); - LOG_FUNC(); - if ( bytesPending == 0 ) { - XP_U16 plen; - /* will need to handle case where len comes in separate packets!!!! */ - XP_ASSERT( len >= sizeof(plen) ); - plen = *(XP_U16*)data; - data += sizeof(plen); - len -= sizeof(plen); - bytesPending = XP_NTOHS(plen); - - /* Start the packet */ - pbt_enqueue( &btStuff->vol.in, (XP_U8*)&bytesPending, sizeof(bytesPending), - XP_FALSE, XP_FALSE ); - } - - /* if len is >= bytesPending, we have a packet. Add bytesPending bytes, - then recurse with remaining bytes. If len is < bytesPending, just - consume the bytes and return. */ - pbt_enqueue( &btStuff->vol.in, data, XP_MIN( len, bytesPending ), - XP_FALSE, XP_TRUE ); - - if ( len >= bytesPending ) { - len -= bytesPending; - data += bytesPending; - pbt_postpone( btStuff, PBT_ACT_GOTDATA ); - if ( len > 0 ) { - pbt_assemble( btStuff, data, len ); - } - } -} -#endif - -static void -socketCallback( BtLibSocketEventType* sEvent, UInt32 refCon ) -{ - PalmBTStuff* btStuff = (PalmBTStuff*)refCon; - BtLibSocketEventEnum event = sEvent->event; - Err err; - - XP_LOGF( "%s(%s); status:%s", __func__, btEvtToStr(event), - btErrToStr(sEvent->status) ); - - switch( event ) { - case btLibSocketEventConnectRequest: - if ( btStuff->picoRole == PBT_MASTER ) { - /* sends btLibSocketEventConnectedInbound */ - CALL_ERR( err, BtLibSocketRespondToConnection, btStuff->btLibRefNum, - sEvent->socket, true ); - } else { - XP_LOGF( "ignoring b/c not master" ); - } - break; - case btLibSocketEventConnectedInbound: - XP_ASSERT( btStuff->picoRole == PBT_MASTER ); - if ( sEvent->status == errNone ) { - btStuff->dataSocket = sEvent->eventData.newSocket; - XP_LOGF( "we have a data socket!!!" ); - pbt_postpone( btStuff, PBT_ACT_TELLCONN ); - SET_STATE( btStuff, PBTST_DATA_CONNECTED ); - } - break; - case btLibSocketEventConnectedOutbound: - if ( errNone == sEvent->status ) { - SET_STATE( btStuff, PBTST_DATA_CONNECTED ); - pbt_postpone( btStuff, PBT_ACT_TELLCONN ); - } - break; - case btLibSocketEventData: - XP_ASSERT( sEvent->status == errNone ); - XP_ASSERT( sEvent->socket == btStuff->dataSocket ); - { - XP_U8* data = sEvent->eventData.data.data; - XP_U16 len = sEvent->eventData.data.dataLen; -#ifdef LOG_BTIO - LOG_HEX( data, len, "btLibSocketEventData" ); -#endif -#if defined BT_USE_RFCOMM - pbt_assemble( btStuff, data, len ); -#else - if ( 0 < pbt_enqueue( &btStuff->vol.in, data, len, XP_FALSE, XP_FALSE ) ) { - pbt_postpone( btStuff, PBT_ACT_GOTDATA ); - } -#endif -#ifdef DEBUG - btStuff->stats.totalRcvd += sEvent->eventData.data.dataLen; -#endif - } - break; - - case btLibSocketEventSendComplete: - btStuff->vol.sendInProgress = XP_FALSE; -#ifdef DEBUG - btStuff->stats.totalSent += -#endif - pbt_shiftQueue( &btStuff->vol.out ); - pbt_postpone( btStuff, PBT_ACT_TRYSEND ); /* in case there's more */ - break; - - case btLibSocketEventDisconnected: - if ( PBT_SLAVE == btStuff->picoRole ) { - pbt_killLinks( btStuff ); - waitACL( btStuff ); - } else if ( PBT_MASTER == btStuff->picoRole ) { - pbt_close_datasocket( btStuff ); - SET_STATE( btStuff, PBTST_LISTENING ); - } - break; - -#if defined BT_USE_L2CAP - case btLibSocketEventSdpGetPsmByUuid: -#elif defined BT_USE_RFCOMM - case btLibSocketEventSdpGetServerChannelByUuid: -#endif - XP_ASSERT( sEvent->socket == btStuff->u.slave.sdpSocket ); - pbt_close_sdpsocket( btStuff ); - if ( sEvent->status == errNone ) { -#if defined BT_USE_L2CAP - btStuff->u.slave.remotePsm = sEvent->eventData.sdpByUuid.param.psm; -#elif defined BT_USE_RFCOMM - btStuff->u.slave.remoteService - = sEvent->eventData.sdpByUuid.param.channel; - XP_LOGF( "got remoteService of %d", - btStuff->u.slave.remoteService ); -#endif - SET_STATE( btStuff, PBTST_SDP_QUERIED ); - pbt_postpone( btStuff, PBT_ACT_CONNECT_DATA ); - } else if ( sEvent->status == btLibErrSdpQueryDisconnect ) { - /* Maybe we can just ignore this... */ - XP_ASSERT( GET_STATE(btStuff) == PBTST_NONE ); /* still still firing!!! */ - pbt_killLinks( btStuff ); - waitACL( btStuff ); - } else { - if ( sEvent->status == btLibErrSdpAttributeNotSet ) { - XP_LOGF( "**** Host not running!!! ****" ); - } - /* try again???? */ - SET_STATE( btStuff, PBTST_ACL_CONNECTED ); - pbt_postpone( btStuff, PBT_ACT_GETSDP ); - } - /* Do we want to try again in a few seconds? Is this where the timer - belongs? */ - break; - - case btLibL2DiscConnPsmUnsupported: - XP_ASSERT( 0 ); /* is this getting called? It's an event *and* status??? */ - /* Probably need to warn the user when this happens since not having - established trust will be a common error. Or: figure out if - there's a way to fall back and establish trust programatically. - For alpha just do the error message. :-) Also, no point in - continuing to try to connect. User will have to quit in order to - establish trust. So warn once per inited session. */ - break; - - default: - break; - } - LOG_RETURN_VOID(); -} /* socketCallback */ - -/*********************************************************************** - * Callbacks - ***********************************************************************/ -static void -libMgmtCallback( BtLibManagementEventType* mEvent, UInt32 refCon ) -{ - PalmBTStuff* btStuff = (PalmBTStuff*)refCon; - BtLibManagementEventEnum event = mEvent->event; - XP_LOGF( "%s(%s); status=%s", __func__, mgmtEvtToStr(event), - btErrToStr(mEvent->status) ); - - switch( event ) { - case btLibManagementEventAccessibilityChange: - XP_LOGF( "%s", connEnumToStr(mEvent->eventData.accessible) ); - btStuff->accState = mEvent->eventData.accessible; - break; - case btLibManagementEventRadioState: -/* XP_LOGF( "status: %s", btErrToStr(mEvent->status) ); */ - break; - case btLibManagementEventACLConnectOutbound: - if ( btLibErrNoError == mEvent->status ) { - SET_STATE( btStuff, PBTST_ACL_CONNECTED ); - XP_LOGF( "successful ACL connection to master!" ); - pbt_postpone( btStuff, PBT_ACT_GETSDP ); - } else { - SET_STATE( btStuff, PBTST_NONE ); - waitACL( btStuff ); - } - break; - - case btLibManagementEventACLConnectInbound: - if ( btLibErrNoError == mEvent->status ) { - XP_LOGF( "successful ACL connection!" ); - XP_MEMCPY( &btStuff->otherAddr, - &mEvent->eventData.bdAddr, - sizeof(btStuff->otherAddr) ); - SET_STATE( btStuff, PBTST_ACL_CONNECTED ); - } - break; - case btLibManagementEventACLDisconnect: - if ( mEvent->status == btLibMeStatusLocalTerminated ) { - /* We caused this, probably switching roles. Perhaps we've already - done what's needed, e.g. opened socket to listen */ - } else { - /* This is getting called from inside the BtLibLinkDisconnect - call!!!! */ - XP_ASSERT( 0 == XP_MEMCMP( &mEvent->eventData.bdAddr, - &btStuff->otherAddr, 6 ) ); - pbt_close_datasocket( btStuff ); - SET_STATE( btStuff, PBTST_NONE ); - /* See comment at btLibSocketEventDisconnected */ - if ( PBT_SLAVE == btStuff->picoRole ) { - waitACL( btStuff ); - } - } - break; - default: - XP_LOGF( "%s: %s not handled", __func__, mgmtEvtToStr(event)); - break; - } - LOG_RETURN_VOID(); -} /* libMgmtCallback */ - -/*********************************************************************** - * Debug helpers for verbose logging - ***********************************************************************/ -#ifdef DEBUG -# define CASESTR(e) case(e): return #e - -static const char* -stateToStr(PBT_STATE st) -{ - switch( st ) { - CASESTR(PBTST_NONE); - CASESTR(PBTST_LISTENING); - CASESTR(PBTST_ACL_CONNECTING); - CASESTR(PBTST_SDP_QUERYING); - CASESTR(PBTST_SDP_QUERIED); - CASESTR(PBTST_ACL_CONNECTED); - CASESTR(PBTST_DATA_CONNECTING); - CASESTR(PBTST_DATA_CONNECTED); - default: - XP_ASSERT(0); - return ""; - } -} /* stateToStr */ - -static const char* -actToStr(PBT_ACTION act) -{ - switch( act ) { - CASESTR(PBT_ACT_NONE); - CASESTR(PBT_ACT_MASTER_RESET); - CASESTR(PBT_ACT_SLAVE_RESET); - CASESTR(PBT_ACT_SETUP_LISTEN); - CASESTR(PBT_ACT_CONNECT_ACL); - CASESTR(PBT_ACT_GETSDP); - CASESTR(PBT_ACT_CONNECT_DATA); - CASESTR(PBT_ACT_GOTDATA); - CASESTR(PBT_ACT_TRYSEND); - CASESTR(PBT_ACT_TELLCONN); - default: - XP_ASSERT(0); - return ""; - } -} /* actToStr */ - -static const char* -connEnumToStr( BtLibAccessibleModeEnum mode ) -{ - switch( mode ) { - CASESTR(btLibNotAccessible); - CASESTR(btLibConnectableOnly); - CASESTR(btLibDiscoverableAndConnectable); - case 0x0006: - /* I've seen this on 68K even. Seems to happen when the other - device changes roles (temporarily). */ - return "undoc_06"; - case 0x00F8: /* seen on ARM only */ - return "undoc_F8"; - default: - XP_ASSERT(0); - XP_LOGF( "%s: got 0x%x", __func__, mode ); - return ""; - } -} - -static const char* -btEvtToStr( BtLibSocketEventEnum evt ) -{ - switch( evt ) { - CASESTR(btLibSocketEventConnectRequest); - CASESTR(btLibSocketEventConnectedOutbound); - CASESTR(btLibSocketEventConnectedInbound); - CASESTR(btLibSocketEventDisconnected); - CASESTR(btLibSocketEventData); - CASESTR(btLibSocketEventSendComplete); - CASESTR(btLibSocketEventSdpServiceRecordHandle); - CASESTR(btLibSocketEventSdpGetAttribute); - CASESTR(btLibSocketEventSdpGetStringLen); - CASESTR(btLibSocketEventSdpGetNumListEntries); - CASESTR(btLibSocketEventSdpGetNumLists); - CASESTR(btLibSocketEventSdpGetRawAttribute); - CASESTR(btLibSocketEventSdpGetRawAttributeSize); - CASESTR(btLibSocketEventSdpGetServerChannelByUuid); - CASESTR(btLibSocketEventSdpGetPsmByUuid); - default: - XP_ASSERT(0); - return ""; - } -} /* btEvtToStr */ - -static const char* -mgmtEvtToStr( BtLibManagementEventEnum event ) -{ - switch( event ) { - CASESTR(btLibManagementEventRadioState); - CASESTR(btLibManagementEventInquiryResult); - CASESTR(btLibManagementEventInquiryComplete); - CASESTR(btLibManagementEventInquiryCanceled); - CASESTR(btLibManagementEventACLDisconnect); - CASESTR(btLibManagementEventACLConnectInbound); - CASESTR(btLibManagementEventACLConnectOutbound); - CASESTR(btLibManagementEventPiconetCreated); - CASESTR(btLibManagementEventPiconetDestroyed); - CASESTR(btLibManagementEventModeChange); - CASESTR(btLibManagementEventAccessibilityChange); - CASESTR(btLibManagementEventEncryptionChange); - CASESTR(btLibManagementEventRoleChange); - CASESTR(btLibManagementEventNameResult); - CASESTR(btLibManagementEventLocalNameChange); - CASESTR(btLibManagementEventAuthenticationComplete); - CASESTR(btLibManagementEventPasskeyRequest); - CASESTR(btLibManagementEventPasskeyRequestComplete); - CASESTR(btLibManagementEventPairingComplete); - default: - XP_ASSERT(0); - return "unknown"; - } -} /* mgmtEvtToStr */ - -static const char* -btErrToStr( Err err ) -{ - switch ( err ) { - CASESTR(errNone); - CASESTR(btLibErrError); - CASESTR(btLibErrNotOpen); - CASESTR(btLibErrBluetoothOff); - CASESTR(btLibErrNoPrefs); - CASESTR(btLibErrAlreadyOpen); - CASESTR(btLibErrOutOfMemory); - CASESTR(btLibErrFailed); - CASESTR(btLibErrInProgress); - CASESTR(btLibErrParamError); - CASESTR(btLibErrTooMany); - CASESTR(btLibErrPending); - CASESTR(btLibErrNotInProgress); - CASESTR(btLibErrRadioInitFailed); - CASESTR(btLibErrRadioFatal); - CASESTR(btLibErrRadioInitialized); - CASESTR(btLibErrRadioSleepWake); - CASESTR(btLibErrNoConnection); - CASESTR(btLibErrAlreadyRegistered); - CASESTR(btLibErrNoAclLink); - CASESTR(btLibErrSdpRemoteRecord); - CASESTR(btLibErrSdpAdvertised); - CASESTR(btLibErrSdpFormat); - CASESTR(btLibErrSdpNotAdvertised); - CASESTR(btLibErrSdpQueryVersion); - CASESTR(btLibErrSdpQueryHandle); - CASESTR(btLibErrSdpQuerySyntax); - CASESTR(btLibErrSdpQueryPduSize); - CASESTR(btLibErrSdpQueryContinuation); - CASESTR(btLibErrSdpQueryResources); - CASESTR(btLibErrSdpQueryDisconnect); - CASESTR(btLibErrSdpInvalidResponse); - CASESTR(btLibErrSdpAttributeNotSet); - CASESTR(btLibErrSdpMapped); - CASESTR(btLibErrSocket); - CASESTR(btLibErrSocketProtocol); - CASESTR(btLibErrSocketRole); - CASESTR(btLibErrSocketPsmUnavailable); - CASESTR(btLibErrSocketChannelUnavailable); - CASESTR(btLibErrSocketUserDisconnect); - CASESTR(btLibErrCanceled); - CASESTR(btLibErrBusy); - CASESTR(btLibMeStatusUnknownHciCommand); - CASESTR(btLibMeStatusNoConnection); - CASESTR(btLibMeStatusHardwareFailure); - CASESTR(btLibMeStatusPageTimeout); - CASESTR(btLibMeStatusAuthenticateFailure); - CASESTR(btLibMeStatusMissingKey); - CASESTR(btLibMeStatusMemoryFull); - CASESTR(btLibMeStatusConnnectionTimeout); - CASESTR(btLibMeStatusMaxConnections); - CASESTR(btLibMeStatusMaxScoConnections); - CASESTR(btLibMeStatusMaxAclConnections); - CASESTR(btLibMeStatusCommandDisallowed); - CASESTR(btLibMeStatusLimitedResources); - CASESTR(btLibMeStatusSecurityError); - CASESTR(btLibMeStatusPersonalDevice); - CASESTR(btLibMeStatusHostTimeout); - CASESTR(btLibMeStatusUnsupportedFeature); - CASESTR(btLibMeStatusInvalidHciParam); - CASESTR(btLibMeStatusUserTerminated); - CASESTR(btLibMeStatusLowResources); - CASESTR(btLibMeStatusPowerOff); - CASESTR(btLibMeStatusLocalTerminated); - CASESTR(btLibMeStatusRepeatedAttempts); - CASESTR(btLibMeStatusPairingNotAllowed); - CASESTR(btLibMeStatusUnknownLmpPDU); - CASESTR(btLibMeStatusUnsupportedRemote); - CASESTR(btLibMeStatusScoOffsetRejected); - CASESTR(btLibMeStatusScoIntervalRejected); - CASESTR(btLibMeStatusScoAirModeRejected); - CASESTR(btLibMeStatusInvalidLmpParam); - CASESTR(btLibMeStatusUnspecifiedError); - CASESTR(btLibMeStatusUnsupportedLmpParam); - CASESTR(btLibMeStatusRoleChangeNotAllowed); - CASESTR(btLibMeStatusLmpResponseTimeout); - CASESTR(btLibMeStatusLmpTransdCollision); - CASESTR(btLibMeStatusLmpPduNotAllowed); - CASESTR(btLibL2DiscReasonUnknown); - CASESTR(btLibL2DiscUserRequest); - CASESTR(btLibL2DiscRequestTimeout); - CASESTR(btLibL2DiscLinkDisc); - CASESTR(btLibL2DiscQosViolation); - CASESTR(btLibL2DiscSecurityBlock); - CASESTR(btLibL2DiscConnPsmUnsupported); - CASESTR(btLibL2DiscConnSecurityBlock); - CASESTR(btLibL2DiscConnNoResources); - CASESTR(btLibL2DiscConfigUnacceptable); - CASESTR(btLibL2DiscConfigReject); - CASESTR(btLibL2DiscConfigOptions); - CASESTR(btLibServiceShutdownAppUse); - CASESTR(btLibServiceShutdownPowerCycled); - CASESTR(btLibServiceShutdownAclDrop); - CASESTR(btLibServiceShutdownTimeout); - CASESTR(btLibServiceShutdownDetached); - CASESTR(btLibErrInUseByService); - CASESTR(btLibErrNoPiconet); - CASESTR(btLibErrRoleChange); - CASESTR(btLibErrSdpNotMapped); - CASESTR(btLibErrAlreadyConnected); - CASESTR(btLibErrStackNotOpen); - CASESTR(btLibErrBatteryTooLow); - CASESTR(btLibErrNotFound); - CASESTR(btLibNotYetSupported); - default: - return "unknown err"; - } -} /* btErrToStr */ - -static const char* -proleToString( PBT_PicoRole r ) -{ - switch ( r ) { - CASESTR(PBT_UNINIT); - CASESTR(PBT_MASTER); - CASESTR(PBT_SLAVE); - default: - XP_ASSERT(0); - return ""; - } -} - -static void -palm_bt_log( const char* btfunc, const char* func, Err err ) -{ -/* if ( errNone != err ) { */ - XP_LOGF( "%s=>%s (in %s)", btfunc, btErrToStr(err), func ); -/* } */ -} - -#endif /* DEBUG */ - -/* -use piconet? With that, HOST sets it up and clients join. That establishes -ACL links that can then be used to open sockets. I think. How to get from -piconet advertising to clients connecting? - -See http://www.palmos.com/dev/support/docs/palmos/BTCompanion.html - -NOTE: I've read conflicting reports on whether a listening socket is good for -accepting more than one inbound connection. Confirm. Or just do a piconet. - -*/ -#endif /* #ifdef XWFEATURE_BLUETOOTH */ diff --git a/xwords4/palm/palmbt.h b/xwords4/palm/palmbt.h deleted file mode 100644 index 0c6e0a395..000000000 --- a/xwords4/palm/palmbt.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2006 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PALMBT_H_ -#define _PALMBT_H_ - -#ifdef XWFEATURE_BLUETOOTH - -#include "comms.h" -#include "palmmain.h" - -#define PALM_BT_NAME_LEN 48 - -/* Needed: feedback to main so status can be posted on the board. Events we - * might care about: - * - * - BT disconnected -- not available - * - Server up and socket available - * - client trying to connect (includes having ACL conn) - * - client has a connection (L2CAP socket open) - * - received data - * - sending data - * - done sending data - */ - -/** - * palm_bt_appendWaitTicks - * reduce waitTicks if have work to do - */ - - -void palm_bt_amendWaitTicks( PalmAppGlobals* globals, Int32* result ); - -XP_Bool palm_bt_init( PalmAppGlobals* globals, XP_Bool* userCancelled ); -void palm_bt_reset( PalmAppGlobals* globals ); -void palm_bt_close( PalmAppGlobals* globals ); - -typedef enum { - BTCBEVT_CONFIRM, BTCBEVT_CONN, BTCBEVT_DATA -} BtCbEvt; -typedef struct BtCbEvtInfo { - BtCbEvt evt; - union { - struct { - const char* hostName; - XP_Bool confirmed; - } confirm; - struct { - const void* data; - const CommsAddrRec* fromAddr; - XP_U8 len; - } data; - } u; -} BtCbEvtInfo; - -typedef void (*BtCbEvtProc)( PalmAppGlobals* globals, BtCbEvtInfo* evt ); -XP_Bool palm_bt_doWork( PalmAppGlobals* globals, BtCbEvtProc proc, BtUIState* btState ); - -void palm_bt_addrString( PalmAppGlobals* globals, const XP_BtAddr* btAddr, - XP_BtAddrStr* str ); - -XP_S16 palm_bt_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, - PalmAppGlobals* globals, XP_Bool* userCancelled ); - -XP_Bool palm_bt_browse_device( PalmAppGlobals* globals, XP_BtAddr* btAddr, - XP_UCHAR* out, XP_U16 len ); - -#ifdef DEBUG -void palm_bt_getStats( PalmAppGlobals* globals, XWStreamCtxt* stream ); -#endif -#endif /* XWFEATURE_BLUETOOTH */ -#endif diff --git a/xwords4/palm/palmdbg.c b/xwords4/palm/palmdbg.c deleted file mode 100644 index 567b2e897..000000000 --- a/xwords4/palm/palmdbg.c +++ /dev/null @@ -1,320 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2006 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -#ifdef DEBUG - -#include "palmdbg.h" -#include "palmmain.h" -#include "xwords4defines.h" - -#define CASESTR(s) case s: return #s - -#define FUNC(f) #f - -const char* -frmObjId_2str( XP_U16 id ) -{ - switch( id ) { - CASESTR( XW_MAIN_FORM ); - CASESTR( XW_NEWGAMES_FORM ); - CASESTR( XW_ERROR_ALERT_ID ); - CASESTR( XW_DICTINFO_FORM ); - CASESTR( XW_ASK_FORM_ID ); - CASESTR( XW_PASSWORD_DIALOG_ID ); - CASESTR( XW_BLANK_DIALOG_ID ); - CASESTR( XW_COLORPREF_DIALOG_ID ); - CASESTR( XW_PREFS_FORM ); - CASESTR( XW_SAVEDGAMES_DIALOG_ID ); - CASESTR( XW_HINTCONFIG_FORM_ID ); - CASESTR( XW_CONNS_FORM ); -#ifdef FOR_GREMLINS - CASESTR( XW_GREMLIN_WARN_FORM_ID ); - CASESTR( GREMLIN_BOARD_GADGET_IDAUTOID ); - CASESTR( GREMLIN_TRAY_GADGET_IDAUTOID ); - CASESTR( XW_GREMLIN_DIVIDER_RIGHT ); - CASESTR( XW_GREMLIN_DIVIDER_LEFT ); - CASESTR( XW_GREMLIN_WARN_FIELD_ID ); -#endif -/* CASESTR( XW_ASK_MENU_ID ); */ -/* CASESTR( ASK_COPY_PULLDOWN_ID ); */ -/* CASESTR( ASK_SELECTALL_PULLDOWN_ID ); */ -/* CASESTR( XW_MAIN_MENU_ID ); */ - CASESTR( XW_MAIN_FLIP_BUTTON_ID ); - CASESTR( XW_MAIN_VALUE_BUTTON_ID ); - CASESTR( XW_MAIN_TRAY_BUTTON_ID ); - CASESTR( XW_MAIN_SCROLLBAR_ID ); - CASESTR( XW_MAIN_DONE_BUTTON_ID ); - CASESTR( XW_MAIN_JUGGLE_BUTTON_ID ); - CASESTR( XW_MAIN_TRADE_BUTTON_ID ); - CASESTR( XW_MAIN_HIDE_BUTTON_ID ); - CASESTR( XW_MAIN_HINT_BUTTON_ID ); - CASESTR( XW_MAIN_SHOWTRAY_BUTTON_ID ); -#ifdef FOR_GREMLINS -#endif - CASESTR( XW_NEWGAME_PULLDOWN_ID ); - CASESTR( XW_SAVEDGAMES_PULLDOWN_ID ); - CASESTR( XW_BEAMDICT_PULLDOWN_ID ); - CASESTR( XW_BEAMBOARD_PULLDOWN_ID ); - CASESTR( XW_PREFS_PULLDOWN_ID ); - CASESTR( XW_ABOUT_PULLDOWN_ID ); - CASESTR( XW_TILEVALUES_PULLDOWN_ID ); - CASESTR( XW_TILESLEFT_PULLDOWN_ID ); - CASESTR( XW_PASSWORDS_PULLDOWN_ID ); - CASESTR( XW_HISTORY_PULLDOWN_ID ); - CASESTR( XW_FINISH_PULLDOWN_ID ); - CASESTR( XW_RESENDIR_PULLDOWN_ID ); - CASESTR( XW_HINT_PULLDOWN_ID ); - CASESTR( XW_NEXTHINT_PULLDOWN_ID ); - CASESTR( XW_HINTCONFIG_PULLDOWN_ID ); - CASESTR( XW_UNDOCUR_PULLDOWN_ID ); - CASESTR( XW_UNDOLAST_PULLDOWN_ID ); - CASESTR( XW_DONE_PULLDOWN_ID ); - CASESTR( XW_JUGGLE_PULLDOWN_ID ); - CASESTR( XW_TRADEIN_PULLDOWN_ID ); - CASESTR( XW_HIDESHOWTRAY_PULLDOWN_ID ); -#ifdef FEATURE_DUALCHOOSE - CASESTR( XW_RUN68K_PULLDOWN_ID ); - CASESTR( XW_RUNARM_PULLDOWN_ID ); -#endif - CASESTR( XW_LOGFILE_PULLDOWN_ID ); - CASESTR( XW_LOGMEMO_PULLDOWN_ID ); - CASESTR( XW_CLEARLOGS_PULLDOWN_ID ); - CASESTR( XW_NETSTATS_PULLDOWN_ID ); - CASESTR( XW_MEMSTATS_PULLDOWN_ID ); - CASESTR( XW_BTSTATS_PULLDOWN_ID ); - CASESTR( XW_DICT_SELECTOR_ID ); - CASESTR( XW_OK_BUTTON_ID ); - CASESTR( XW_CANCEL_BUTTON_ID ); - CASESTR( XW_PLAYERNAME_1_FIELD_ID ); - CASESTR( XW_ROBOT_1_CHECKBOX_ID ); - CASESTR( XW_REMOTE_1_CHECKBOX_ID ); - CASESTR( XW_PLAYERPASSWD_1_TRIGGER_ID ); - CASESTR( XW_PLAYERNAME_2_FIELD_ID ); - CASESTR( XW_ROBOT_2_CHECKBOX_ID ); - CASESTR( XW_REMOTE_2_CHECKBOX_ID ); - CASESTR( XW_PLAYERPASSWD_2_TRIGGER_ID ); - CASESTR( XW_PLAYERNAME_3_FIELD_ID ); - CASESTR( XW_ROBOT_3_CHECKBOX_ID ); - CASESTR( XW_REMOTE_3_CHECKBOX_ID ); - CASESTR( XW_PLAYERPASSWD_3_TRIGGER_ID ); - CASESTR( XW_PLAYERNAME_4_FIELD_ID ); - CASESTR( XW_ROBOT_4_CHECKBOX_ID ); - CASESTR( XW_REMOTE_4_CHECKBOX_ID ); - CASESTR( XW_PLAYERPASSWD_4_TRIGGER_ID ); - CASESTR( XW_NPLAYERS_LIST_ID ); - CASESTR( XW_NPLAYERS_SELECTOR_ID ); - CASESTR( XW_PREFS_BUTTON_ID ); - CASESTR( XW_GINFO_JUGGLE_ID ); - CASESTR( XW_SOLO_GADGET_ID ); - CASESTR( XW_SERVER_GADGET_ID ); - CASESTR( XW_CLIENT_GADGET_ID ); - CASESTR( XW_SERVERTYPES_LIST_ID ); - CASESTR( XW_LOCAL_LABEL_ID ); - CASESTR( XW_TOTALP_FIELD_ID ); - CASESTR( XW_LOCALP_LABEL_ID ); - CASESTR( REFCON_GADGET_ID ); - CASESTR( XW_ASK_TXT_FIELD_ID ); - CASESTR( XW_ASK_YES_BUTTON_ID ); - CASESTR( XW_ASK_NO_BUTTON_ID ); - CASESTR( XW_ASK_SCROLLBAR_ID ); - CASESTR( XW_PASSWORD_CANCEL_BUTTON ); - CASESTR( XW_PASSWORD_NAME_LABEL ); - CASESTR( XW_PASSWORD_NEWNAME_LABEL ); - CASESTR( XW_PASSWORD_NAME_FIELD ); - CASESTR( XW_PASSWORD_PASS_FIELD ); - CASESTR( XW_PASSWORD_OK_BUTTON ); - CASESTR( XW_BLANK_LIST_ID ); - CASESTR( XW_BLANK_LABEL_FIELD_ID ); - CASESTR( XW_BLANK_OK_BUTTON_ID ); - CASESTR( XW_BLANK_PICK_BUTTON_ID ); - CASESTR( XW_BLANK_BACKUP_BUTTON_ID ); - CASESTR( XW_COLORS_FACTORY_BUTTON_ID ); - CASESTR( XW_COLORS_OK_BUTTON_ID ); - CASESTR( XW_COLORS_CANCEL_BUTTON_ID ); - CASESTR( XW_DICTINFO_LIST_ID ); - CASESTR( XW_DICTINFO_TRIGGER_ID ); - CASESTR( XW_PHONIES_TRIGGER_ID ); - CASESTR( XW_PHONIES_LABLE_ID ); - CASESTR( XW_PHONIES_LIST_ID ); - CASESTR( XW_DICTINFO_DONE_BUTTON_ID ); - CASESTR( XW_DICTINFO_BEAM_BUTTON_ID ); - CASESTR( XW_DICTINFO_CANCEL_BUTTON_ID ); - CASESTR( XW_PREFS_ALLGAMES_GADGET_ID ); - CASESTR( XW_PREFS_ONEGAME_GADGET_ID ); - CASESTR( XW_PREFS_TYPES_LIST_ID ); - CASESTR( XW_PREFS_PLAYERCOLORS_CHECKBOX_ID ); - CASESTR( XW_PREFS_PROGRESSBAR_CHECKBOX_ID ); - CASESTR( XW_PREFS_SHOWGRID_CHECKBOX_ID ); - CASESTR( XW_PREFS_SHOWARROW_CHECKBOX_ID ); - CASESTR( XW_PREFS_ROBOTSCORE_CHECKBOX_ID ); - CASESTR( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID ); - CASESTR( XW_PREFS_ROBOTSMART_CHECKBOX_ID ); - CASESTR( XW_PREFS_PHONIES_LABEL_ID ); - CASESTR( XW_PREFS_PHONIES_TRIGGER_ID ); - CASESTR( XW_PREFS_BDSIZE_LABEL_ID ); - CASESTR( XW_PREFS_BDSIZE_SELECTOR_ID ); - CASESTR( XW_PREFS_NOHINTS_CHECKBOX_ID ); - CASESTR( XW_PREFS_TIMERON_CHECKBOX_ID ); - CASESTR( XW_PREFS_TIMER_FIELD_ID ); - CASESTR( XW_PREFS_PICKTILES_CHECKBOX_ID ); - CASESTR( XW_PREFS_HINTRECT_CHECKBOX_ID ); -#ifdef XWFEATURE_FIVEWAY - CASESTR( XW_BOARD_GADGET_ID ); - CASESTR( XW_SCOREBOARD_GADGET_ID ); - CASESTR( XW_TRAY_GADGET_ID ); -#endif - CASESTR( XW_PREFS_PHONIES_LIST_ID ); - CASESTR( XW_PREFS_BDSIZE_LIST_ID ); - CASESTR( XW_PREFS_CANCEL_BUTTON_ID ); - CASESTR( XW_PREFS_OK_BUTTON_ID ); - CASESTR( XW_SAVEDGAMES_LIST_ID ); - CASESTR( XW_SAVEDGAMES_NAME_FIELD ); - CASESTR( XW_SAVEDGAMES_USE_BUTTON ); - CASESTR( XW_SAVEDGAMES_DUPE_BUTTON ); - CASESTR( XW_SAVEDGAMES_DELETE_BUTTON ); - CASESTR( XW_SAVEDGAMES_OPEN_BUTTON ); - CASESTR( XW_SAVEDGAMES_DONE_BUTTON ); - CASESTR( XW_CONNS_CANCEL_BUTTON_ID ); - CASESTR( XW_CONNS_OK_BUTTON_ID ); - CASESTR( XW_CONNS_TYPE_TRIGGER_ID ); - CASESTR( XW_CONNS_TYPE_LIST_ID ); -#ifdef XWFEATURE_RELAY - CASESTR( XW_CONNS_RELAY_LABEL_ID ); - CASESTR( XW_CONNS_INVITE_FIELD_ID ); - CASESTR( XW_CONNS_INVITE_LABEL_ID ); - CASESTR( XW_CONNS_PORT_LABEL_ID ); - CASESTR( XW_CONNS_RELAY_FIELD_ID ); - CASESTR( XW_CONNS_PORT_FIELD_ID ); -#endif -#ifdef XWFEATURE_BLUETOOTH - CASESTR( XW_CONNS_BT_HOSTNAME_LABEL_ID ); - CASESTR( XW_CONNS_BT_HOSTTRIGGER_ID ); -#endif - CASESTR( XW_HINTCONFIG_MINLIST_ID ); - CASESTR( XW_HINTCONFIG_MAXLIST_ID ); - CASESTR( XW_HINTCONFIG_MAXSELECTOR_ID ); - CASESTR( XW_HINTCONFIG_MINSELECTOR_ID ); - CASESTR( XW_HINTCONFIG_OK_ID ); - CASESTR( XW_HINTCONFIG_CANCEL_ID ); - default: return FUNC(__func__) " unknown"; - } -} - -const char* -eType_2str( eventsEnum eType ) -{ - switch( eType ) { - CASESTR(nilEvent); - CASESTR(penDownEvent); - CASESTR(penUpEvent); - CASESTR(penMoveEvent); - CASESTR(keyDownEvent); - CASESTR(winEnterEvent); - CASESTR(winExitEvent); - CASESTR(ctlEnterEvent); - CASESTR(ctlExitEvent); - CASESTR(ctlSelectEvent); - CASESTR(ctlRepeatEvent); - CASESTR(lstEnterEvent); - CASESTR(lstSelectEvent); - CASESTR(lstExitEvent); - CASESTR(popSelectEvent); - CASESTR(fldEnterEvent); - CASESTR(fldHeightChangedEvent); - CASESTR(fldChangedEvent); - CASESTR(tblEnterEvent); - CASESTR(tblSelectEvent); - CASESTR(daySelectEvent); - CASESTR(menuEvent); - CASESTR(appStopEvent); - CASESTR(frmLoadEvent); - CASESTR(frmOpenEvent); - CASESTR(frmGotoEvent); - CASESTR(frmUpdateEvent); - CASESTR(frmSaveEvent); - CASESTR(frmCloseEvent); - CASESTR(frmTitleEnterEvent); - CASESTR(frmTitleSelectEvent); - CASESTR(tblExitEvent); - CASESTR(sclEnterEvent); - CASESTR(sclExitEvent); - CASESTR(sclRepeatEvent); - CASESTR(tsmConfirmEvent); - CASESTR(tsmFepButtonEvent); - CASESTR(tsmFepModeEvent); - CASESTR(attnIndicatorEnterEvent); - CASESTR(attnIndicatorSelectEvent); - CASESTR(menuCmdBarOpenEvent); - CASESTR(menuOpenEvent); - CASESTR(menuCloseEvent); - CASESTR(frmGadgetEnterEvent); - CASESTR(frmGadgetMiscEvent); - - CASESTR(firstINetLibEvent); - CASESTR(firstWebLibEvent); - CASESTR(telAsyncReplyEvent); - - CASESTR(keyUpEvent); - CASESTR(keyHoldEvent); - CASESTR(frmObjectFocusTakeEvent); - CASESTR(frmObjectFocusLostEvent); - - CASESTR(firstLicenseeEvent); - CASESTR(lastLicenseeEvent); - - CASESTR(lastUserEvent); - - CASESTR( dictSelectedEvent ); - CASESTR( newGameOkEvent ); - CASESTR( newGameCancelEvent); - CASESTR( loadGameEvent); - CASESTR( prefsChangedEvent); - CASESTR( openSavedGameEvent); -#ifdef XWFEATURE_FIVEWAY - CASESTR( updateAfterFocusEvent); -#endif - CASESTR( DOWN_ARROW_RESID ); - CASESTR( RIGHT_ARROW_RESID ); - CASESTR( FLIP_BUTTON_BMP_RES_ID ); - CASESTR( VALUE_BUTTON_BMP_RES_ID ); - CASESTR( HINT_BUTTON_BMP_RES_ID ); - CASESTR( TRAY_BUTTONS_BMP_RES_ID ); - CASESTR( SHOWTRAY_BUTTON_BMP_RES_ID ); - CASESTR( STAR_BMP_RES_ID ); - -#ifdef XWFEATURE_BLUETOOTH - CASESTR( BTSTATUS_NONE_RES_ID ); - CASESTR( BTSTATUS_LISTENING_RES_ID ); - CASESTR( BTSTATUS_SEEKING_RES_ID ); - CASESTR( BTSTATUS_CONNECTED_RES_ID ); -#endif - -#ifdef FEATURE_SILK - CASESTR( doResizeWinEvent ); -#endif - default: - return ""; - break; - } -} /* eType_2str */ - -#undef CASESTR -#undef FUNC - -#endif diff --git a/xwords4/palm/palmdbg.h b/xwords4/palm/palmdbg.h deleted file mode 100644 index 736ff142c..000000000 --- a/xwords4/palm/palmdbg.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2006-2007 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 _PALMDBG_H_ -#define _PALMDBG_H_ - -#include "comtypes.h" -#include - -const char* frmObjId_2str( XP_U16 id ); -const char* eType_2str( eventsEnum eType ); - -/* Useful for writing pace_man functions. */ -#define LOG_OFFSET( s, f ) \ - { s _s; \ - XP_LOGF( "offset of " #f " in " #s \ - ": %d (size: %ld)", OFFSET_OF( s, f ), \ - sizeof(_s.f) ); \ - } - -#endif diff --git a/xwords4/palm/palmdict.c b/xwords4/palm/palmdict.c deleted file mode 100644 index f56645c9a..000000000 --- a/xwords4/palm/palmdict.c +++ /dev/null @@ -1,498 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 1997-2009 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include -#include - -#include "dictnryp.h" -#include "dawg.h" -#include "strutils.h" -#include "palmdict.h" -#include "dictlist.h" -#include "dictui.h" -#include "palmmain.h" -#include "pace_man.h" /* READ_UNALIGNED16 */ -#include "LocalizedStrIncludes.h" - -typedef struct DictStart { - unsigned long indexStart; - array_edge* array; -} DictStart; - - -#define NO_REFCOUNT -2 - -struct PalmDictionaryCtxt { - DictionaryCtxt super; - dawg_header* headerRecP; - DmOpenRef dbRef; - XP_U16 nRecords; - UInt16 cardNo; /* added to track VFS imported file for */ - LocalID dbID; /* deletion later */ - XP_UCHAR location; /* VFS or storage mem */ - XP_S8 refCount; - PalmDictList* dl; - DictStart dictStarts[1]; -}; - -#ifdef NODE_CAN_4 -typedef unsigned short FaceType; -#else -typedef unsigned char FaceType; -#endif - -static void palm_dictionary_destroy( DictionaryCtxt* dict ); -static XP_U16 countSpecials( FaceType* ptr, UInt16 nChars ); -static void setupSpecials( MPFORMAL PalmDictionaryCtxt* ctxt, - Xloc_specialEntry* specialStart, XP_U16 nSpecials ); -static array_edge* palm_dict_edge_for_index_multi( const DictionaryCtxt* dict, - XP_U32 index ); - -DictionaryCtxt* -palm_dictionary_make( MPFORMAL PalmAppGlobals* globals, - const XP_UCHAR* dictName, PalmDictList* dl ) -{ - Boolean found; - UInt16 cardNo; - LocalID dbID; - DmOpenRef dbRef; - PalmDictionaryCtxt tDictBuf; - PalmDictionaryCtxt* ctxt; - MemHandle tmpH; - dawg_header* headerRecP; - unsigned char* charPtr; - UInt16 nChars, nSpecials; - XP_U32 offset; - DictListEntry* dle; - Err err; - XP_U16 ii; - FaceType* facePtr; -#ifdef NODE_CAN_4 - XP_U16 flags; - XP_U16 nodeSize = 3; /* init to satisfy compiler */ -#endif - XP_U32 totalSize; - - /* check and see if there's already a dict for this name. If yes, - increment its refcount and return. */ - if ( !!dictName && getDictWithName( dl, dictName, &dle ) ) { - PalmDictionaryCtxt* dict = (PalmDictionaryCtxt*)dle->dict; - if ( !!dict ) { - ++dict->refCount; - return (DictionaryCtxt*)dict; - } - } - - if ( !!dictName ) { - ctxt = &tDictBuf; - } else { - /* If the name's NULL, we still need to create a dict, as the server - may be called to fill it in from the stream later. */ - ctxt = XP_MALLOC( mpool, sizeof(*ctxt) ); - } - - XP_MEMSET( ctxt, 0, sizeof(*ctxt) ); - MPASSIGN( ctxt->super.mpool, mpool ); - - dict_super_init( (DictionaryCtxt*)ctxt ); - - if ( !!dictName ) { - XP_U8 buf[64]; - XP_ASSERT( XP_STRLEN((const char*)dictName) > 0 ); - - ctxt->super.name = copyString( mpool, dictName ); - ctxt->super.destructor = palm_dictionary_destroy; - - found = getDictWithName( dl, dictName, &dle ); - - if ( !found ) { - goto errExit; - } - - if ( dle->location == DL_VFS ) { - const XP_UCHAR* str = getResString( globals, STR_DICT_COPY_EXPL ); - WinDrawChars( str, XP_STRLEN(str), 5, 40 ); - - err = VFSImportDatabaseFromFile( dle->u.vfsData.volNum, - (const char*)dle->path, - &cardNo, &dbID ); - if ( err != errNone ) { - goto errExit; - } - } else { - cardNo = dle->u.dmData.cardNo; - dbID = dle->u.dmData.dbID; - } - - ctxt->refCount = 1; - ctxt->dl = dl; - ctxt->dbID = dbID; - ctxt->cardNo = cardNo; - ctxt->location = dle->location; - - ctxt->dbRef = dbRef = DmOpenDatabase( cardNo, dbID, dmModeReadOnly ); - tmpH = DmQueryRecord( dbRef, 0 ); // <- should be a constant - ctxt->headerRecP = headerRecP = (dawg_header*)MemHandleLock( tmpH ); - XP_ASSERT( MemHandleLockCount(tmpH) == 1 ); - -#ifdef NODE_CAN_4 - flags = XP_NTOHS( headerRecP->flags ); - if ( flags == 0x0002 ) { - XP_ASSERT( nodeSize == 3 ); - } else if ( flags == 0x0003 ) { - nodeSize = 4; - } else { - XP_WARNF( "got flags of %d", flags ); - XP_ASSERT(0); - return NULL; - } -#endif - - tmpH = DmQueryRecord( dbRef, headerRecP->charTableRecNum ); - XP_ASSERT( !!tmpH ); - facePtr = (FaceType*)MemHandleLock( tmpH ); - XP_ASSERT( MemHandleLockCount( tmpH ) == 1 ); - ctxt->super.nFaces = nChars = MemPtrSize(facePtr) / sizeof(*facePtr); - for ( ii = 0; ii < nChars; ++ii ) { - XP_ASSERT( ii < VSIZE(buf) ); -#ifdef NODE_CAN_4 - buf[ii] = READ_UNALIGNED16( &facePtr[ii] ); -#else - buf[ii] = facePtr[ii]; -#endif - } - dict_splitFaces( &ctxt->super, buf, nChars, nChars ); - nSpecials = countSpecials( facePtr, nChars ); - MemPtrUnlock( facePtr ); - - tmpH = DmQueryRecord( dbRef, headerRecP->valTableRecNum ); - charPtr = (unsigned char*)MemHandleLock(tmpH); - XP_ASSERT( MemHandleLockCount( tmpH ) == 1 ); - // use 2; ARM thinks sizeof(Xloc_header) is 4. - ctxt->super.langCode = *charPtr; - ctxt->super.countsAndValues = charPtr + 2; - - /* for those dicts with special chars */ - if ( nSpecials > 0 ) { - Xloc_specialEntry* specialStart = (Xloc_specialEntry*) - (ctxt->super.countsAndValues + (ctxt->super.nFaces*2)); - setupSpecials( MPPARM(mpool) ctxt, specialStart, nSpecials ); - } - - if ( headerRecP->firstEdgeRecNum == 0 ) { /* emtpy dict */ - ctxt->super.topEdge = NULL; - ctxt->nRecords = 0; - } else { - MemHandle record; - XP_U16 size; - short index; - XP_U16 nRecords; - - nRecords = DmNumRecords(dbRef) - headerRecP->firstEdgeRecNum; - - /* alloacate now that we know the size. */ - ctxt = XP_MALLOC( mpool, - sizeof(*ctxt) + (nRecords * sizeof(DictStart))); - XP_MEMCPY( ctxt, &tDictBuf, sizeof(tDictBuf) ); - ctxt->nRecords = nRecords; -#ifdef NODE_CAN_4 - ctxt->super.nodeSize = (XP_U8)nodeSize; - ctxt->super.is_4_byte = nodeSize == 4; -#endif - - totalSize = 0; - for ( index = 0; index < nRecords; ++index ) { - record = DmQueryRecord( dbRef, index - + headerRecP->firstEdgeRecNum); - totalSize += MemHandleSize( record ); - } - - /* NOTE: need to use more than one feature to support having - multiple dicts open at once. */ - err = ~errNone; /* so test below will pass if nRecords == 1 */ -#ifdef XWFEATURE_COMBINEDAWG - if ( nRecords > 1 ) { - void* dawgBase; - err = FtrPtrNew( APPID, DAWG_STORE_FEATURE, totalSize, - &dawgBase ); - if ( err == errNone ) { - for ( index = 0, offset = 0; index < nRecords; ++index ) { - record = DmQueryRecord( dbRef, index - + headerRecP->firstEdgeRecNum ); - size = MemHandleSize( record ); - err = DmWrite( dawgBase, offset, - MemHandleLock( record ), size ); - XP_ASSERT( err == errNone ); - MemHandleUnlock( record ); - offset += size; -#ifdef DEBUG -#ifdef NODE_CAN_4 - ctxt->super.numEdges += size / nodeSize; -#else - ctxt->super.numEdges += size / 3; -#endif -#endif - } - - ctxt->super.base = dawgBase; - ctxt->super.topEdge = dawgBase; - } else { - XP_LOGF( "unable to use Ftr for dict; err=%d", err ); - } - } -#endif - - if ( err != errNone ) { - offset = 0; - for ( index = 0; index < nRecords; ++index ) { - record = DmQueryRecord( dbRef, index + headerRecP->firstEdgeRecNum ); - size = MemHandleSize( record ); - - ctxt->dictStarts[index].indexStart = offset; - - /* cast to short to avoid libc call */ - XP_ASSERT( size < 0xFFFF ); -#ifdef NODE_CAN_4 - XP_ASSERT( 0 == (size % nodeSize) ); - offset += size / nodeSize; -#else - XP_ASSERT( ((unsigned short)size % 3 )==0); - offset += ((unsigned short)size) / 3; -#endif - ctxt->dictStarts[index].array = - (array_edge*)MemHandleLock( record ); - XP_ASSERT( MemHandleLockCount(record) == 1 ); - } - - XP_ASSERT( index == ctxt->nRecords ); - ctxt->dictStarts[index].indexStart = 0xFFFFFFFFL; - - ctxt->super.topEdge = ctxt->dictStarts[0].array; -#ifdef DEBUG - ctxt->super.numEdges = offset; -#endif - ctxt->super.func_edge_for_index - = palm_dict_edge_for_index_multi; - } - } - - setBlankTile( (DictionaryCtxt*)ctxt ); - - cacheDictForName( dl, dictName, (DictionaryCtxt*)ctxt ); - } else { - ctxt->refCount = NO_REFCOUNT; - } - - return (DictionaryCtxt*)ctxt; - - errExit: - if ( !!ctxt ) { - XP_ASSERT( ctxt == &tDictBuf ); - } - return NULL; -} /* palm_dictionary_make */ - -void -dict_splitFaces( DictionaryCtxt* dict, const XP_U8* bytes, - XP_U16 nBytes, XP_U16 nFaces ) -{ - XP_U16 facesLen = nFaces * 2; - XP_UCHAR* faces = XP_MALLOC( dict->mpool, facesLen ); - XP_UCHAR** ptrs = XP_MALLOC( dict->mpool, nFaces * sizeof(ptrs[0])); - XP_U16 ii; - XP_UCHAR* next = faces; - - for ( ii = 0; ii < nFaces; ++ii ) { - ptrs[ii] = next; - *next++ = *bytes++; - *next++ = '\0'; - } - XP_ASSERT( next == faces + facesLen ); - XP_ASSERT( !dict->faces ); - dict->faces = faces; - XP_ASSERT( !dict->facePtrs ); - dict->facePtrs = ptrs; -} /* dict_splitFaces */ - -static XP_U16 -countSpecials( FaceType* ptr, UInt16 nChars ) -{ - XP_U16 result = 0; - - while ( nChars-- ) { - FaceType face; -#ifdef NODE_CAN_4 - XP_ASSERT( sizeof(face) == 2 ); - face = READ_UNALIGNED16( ptr ); - ++ptr; -#else - face = *ptr++; -#endif - if ( IS_SPECIAL(face) ) { - ++result; - } - } - return result; -} /* countSpecials */ - -/* We need an array of ptrs to bitmaps plus an array of ptrs to the text - * equivalents. - */ -static void -setupSpecials( MPFORMAL PalmDictionaryCtxt* ctxt, - Xloc_specialEntry* specialStart, XP_U16 nSpecials ) -{ - XP_U16 i; - char* base; - XP_UCHAR** chars; - SpecialBitmaps* bitmaps; - - base = (char*)specialStart; - chars = XP_MALLOC( mpool, nSpecials * sizeof(*chars) ); - bitmaps = XP_MALLOC( mpool, nSpecials * sizeof(*bitmaps) ); - - XP_MEMSET( bitmaps, 0, nSpecials * sizeof(*bitmaps ) ); - - for ( i = 0; i < nSpecials; ++i ) { - XP_U16 hasLarge, hasSmall; - - chars[i] = specialStart->textVersion; - - /* This may not work! Get rid of NTOHS???? */ - hasLarge = READ_UNALIGNED16( &specialStart->hasLarge ); - if ( hasLarge ) { - bitmaps[i].largeBM = base + hasLarge; - } - hasSmall = READ_UNALIGNED16( &specialStart->hasSmall ); - if ( hasSmall ) { - bitmaps[i].smallBM = base + hasSmall; - } - ++specialStart; - } - - ctxt->super.bitmaps = bitmaps; - ctxt->super.chars = chars; -} /* setupSpecials */ - -static void -palm_dictionary_destroy( DictionaryCtxt* dict ) -{ - PalmDictionaryCtxt* ctxt = (PalmDictionaryCtxt*)dict; - - if ( ctxt->refCount != NO_REFCOUNT && --ctxt->refCount == 0 ) { - short i; - DmOpenRef dbRef; - dawg_header* headerRecP; - - if ( !!ctxt->super.name ) { - /* Remove from dict list */ - removeFromDictCache( ctxt->dl, ctxt->super.name ); - } - - dbRef = ctxt->dbRef; - headerRecP = ctxt->headerRecP; - - XP_ASSERT( !!dbRef ); - - MemPtrUnlock( ctxt->super.countsAndValues - 2 );//sizeof(Xloc_header) ); - - XP_FREE( dict->mpool, ctxt->super.facePtrs ); - XP_FREE( dict->mpool, ctxt->super.faces ); - -#ifdef XWFEATURE_COMBINEDAWG - /* Try first to delete the feature. */ - if ( FtrPtrFree( APPID, DAWG_STORE_FEATURE ) == ftrErrNoSuchFeature ) { -#endif - for ( i = 0; i < ctxt->nRecords; ++i ) { - XP_ASSERT( !!ctxt->dictStarts[i].array ); - MemPtrUnlock( ctxt->dictStarts[i].array ); - } -#ifdef XWFEATURE_COMBINEDAWG - } else { - XP_ASSERT( ctxt->dictStarts[0].array == NULL ); - } -#endif - - MemPtrUnlock( headerRecP ); - - DmCloseDatabase( dbRef ); - - if ( !!ctxt->super.name ) { - XP_FREE( dict->mpool, ctxt->super.name ); - } - if ( !!ctxt->super.bitmaps ) { - XP_FREE( dict->mpool, ctxt->super.bitmaps ); - } - if ( !!ctxt->super.chars ) { - XP_FREE( dict->mpool, ctxt->super.chars ); - } - - /* if we copied the db to memory we should nuke it, since user would - have copied it himself if he wanted it here permanently */ - if ( ctxt->location == DL_VFS ) { - DmDeleteDatabase( ctxt->cardNo, ctxt->dbID ); - } - - XP_FREE( dict->mpool, dict ); - } -} /* palm_dictionary_destroy */ - -#ifdef OVERRIDE_EDGE_FOR_INDEX -static array_edge* -palm_dict_edge_for_index_multi( const DictionaryCtxt* dict, XP_U32 index ) -{ - PalmDictionaryCtxt* ctxt = (PalmDictionaryCtxt*)dict; - array_edge* result; - - XP_ASSERT( index < dict->numEdges ); - - if ( index == 0 ) { - result = NULL; - } else { - DictStart* headerP; - for ( headerP = &ctxt->dictStarts[1]; - index >= headerP->indexStart; - ++headerP ) { - /* do nothing */ - } - --headerP; - index -= headerP->indexStart; - - /* To avoid linking in __mulsi3, do the math without a variable */ - if ( 0 ) { -#ifdef NODE_CAN_4 - } else if ( dict->nodeSize == 4 ) { - index *= 4; /* better to shift (<<= 2) here? */ -# ifdef DEBUG - } else if ( dict->nodeSize != 3 ) { - XP_ASSERT( 0 ); -# endif -#endif - } else { - index *= 3; - } - result = headerP->array + index; - } - - return result; -} /* dict_edge_for_index */ - -#endif diff --git a/xwords4/palm/palmdict.h b/xwords4/palm/palmdict.h deleted file mode 100644 index 5a3a81f85..000000000 --- a/xwords4/palm/palmdict.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PALMDICT_H_ -#define _PALMDICT_H_ - -#include "dictnry.h" -#include "mempool.h" -#include "dictui.h" - -DictionaryCtxt* palm_dictionary_make( MPFORMAL PalmAppGlobals* globals, - const XP_UCHAR* dictName, /* copied */ - PalmDictList* dl ); - -#ifdef NODE_CAN_4 -void offerConvertOldDicts( PalmAppGlobals* globals ); -#else -# define offerConvertOldDicts(g) -#endif - -typedef struct PalmDictionaryCtxt PalmDictionaryCtxt; - -#endif /* _PALMDICT_H_ */ diff --git a/xwords4/palm/palmdraw.c b/xwords4/palm/palmdraw.c deleted file mode 100644 index dd44ab9ce..000000000 --- a/xwords4/palm/palmdraw.c +++ /dev/null @@ -1,1569 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE";-*- */ -/* - * Copyright 1999 - 2008 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 -#include -#ifdef XWFEATURE_FIVEWAY -# include -#endif - -#include "draw.h" -#include "dbgutil.h" - -#include "palmmain.h" -#include "xwords4defines.h" -#include "LocalizedStrIncludes.h" - -#define CHARRECT_WIDTH 12 -#define CHARRECT_HEIGHT 14 - -#define FONT_HEIGHT 8 -#define LINE_SPACING 1 - -#define SCORE_SEP ':' -#define SCORE_SEPSTR ":" - -#define TILE_SUBSCRIPT 1 /* draw tile with numbers below letters? */ - -/* Let's try both for a while */ -#define DRAW_FOCUS_FRAME 1 -#ifdef DRAW_FOCUS_FRAME -# define TREAT_AS_CURSOR(d,f) ((((f) & CELL_ISCURSOR) != 0) && !(d)->topFocus ) -# define FOCUS_BORDER_WIDTH 6 -#else -# define TREAT_AS_CURSOR(d,f) (((f) & CELL_ISCURSOR) != 0) -#endif - -static XP_Bool palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, - const XP_UCHAR* letters, - const XP_Bitmaps* bitmaps, Tile tile, - XP_S16 owner, XWBonusType bonus, - HintAtts hintAtts, CellFlags flags ); -static void palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx, - const XP_Rect* rInner, - const XP_Rect* rOuter, - const DrawScoreInfo* dsi ); -static XP_Bool palm_bnw_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 owner, DrawFocusState dfs ); -static void palm_clr_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP ); -static void palm_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text, - const XP_Rect* rect, void** closureP ); -static void doDrawPlayer( PalmDrawCtx* dctx, const DrawScoreInfo* dsi, - const XP_Rect* rInner ); - -#define HIGHRES_PUSH_LOC( dctx ) \ - { \ - XP_U16 oldVal = 0; \ - if ( (dctx)->doHiRes ) { \ - oldVal = WinSetCoordinateSystem( kCoordinatesNative ); \ - } -#define HIGHRES_POP_LOC(dctx) \ - if ( (dctx)->doHiRes ) { \ - (void)WinSetCoordinateSystem( oldVal ); \ - (dctx)->oldCoord = 0; \ - } \ - } -#define HIGHRES_PUSH_NOPOP( dctx ) \ - if ( (dctx)->doHiRes ) { \ - WinSetCoordinateSystem( kCoordinatesNative ); \ - } -#define HIGHRES_PUSH( dctx ) \ - if ( (dctx)->doHiRes ) { \ - XP_ASSERT( (dctx)->oldCoord == 0 ); \ - (dctx)->oldCoord = WinSetCoordinateSystem( kCoordinatesNative ); \ - } -#define HIGHRES_POP(dctx) \ - if ( (dctx)->doHiRes ) { \ - (void)WinSetCoordinateSystem( (dctx)->oldCoord ); \ - (dctx)->oldCoord = 0; \ - } - -static void -pmEraseRect( /* PalmDrawCtx* dctx, */const XP_Rect* rect ) -{ - WinEraseRectangle( (const RectangleType*)rect, 0 ); -} /* pmEraseRect */ - -static void -insetRect2( XP_Rect* rect, XP_S16 byX, XP_S16 byY ) -{ - XP_U16 i; - rect->left += byX; - rect->top += byY; - for ( i = 0; i < 2; ++i ) { - rect->width -= byX; - rect->height -= byY; - } -} /* insetRect */ - -static void -insetRect( XP_Rect* rect, XP_S16 by ) -{ - insetRect2( rect, by, by ); -} /* insetRect */ - -static void -drawBitmapAt( DrawCtx* XP_UNUSED(p_dctx), Int16 resID, Int16 x, Int16 y ) -{ - MemHandle handle; - handle = DmGetResource( bitmapRsc, resID ); - XP_ASSERT( handle != NULL ); - - if ( handle != NULL ) { - WinDrawBitmap( (BitmapPtr)MemHandleLock(handle), x, y ); - XP_ASSERT( MemHandleLockCount(handle ) == 1 ); - MemHandleUnlock( handle ); - DmReleaseResource( handle ); - } -} /* drawBitmapAt */ - -static void -bitmapInRect( PalmDrawCtx* dctx, Int16 resID, const XP_Rect* rectP ) -{ - XP_U16 left = rectP->left; - XP_U16 top = rectP->top; - if ( dctx->globals->gState.showGrid ) { - ++left; - ++top; - } - drawBitmapAt( (DrawCtx*)dctx, resID, left, top ); -} /* bitmapInRect */ - -# define BMP_WIDTH 16 -# define BMP_HT 16 - -static void -measureFace( PalmDrawCtx* dctx, XP_UCHAR face, PalmFontHtInfo* fhi ) -{ - WinHandle win; - BitmapType* bitmap; - Coord x, y; - Err err; - XP_Bool gotIt; - XP_U16 top = 0; - XP_U16 bottom = 0; - XP_UCHAR ch = (XP_UCHAR)face; - - bitmap = BmpCreate( BMP_WIDTH, BMP_HT, 1, NULL, &err ); - if ( err == errNone ) { - win = WinCreateBitmapWindow( bitmap, &err ); - if ( err == errNone ) { - WinHandle oldWin = WinSetDrawWindow( win ); - - WinSetBackColor( 0 ); /* white */ - (void)WinSetTextColor( 1 ); /* black */ - (void)WinSetDrawMode( winOverlay ); - - WinDrawChars( &ch, 1, 0, 0 ); - - /* Scan from top for top, then from bottom for botton */ - gotIt = XP_FALSE; - for ( y = 0; !gotIt && y < BMP_HT; ++y ) { - for ( x = 0; !gotIt && x < BMP_WIDTH; ++x ) { - IndexedColorType pxl = WinGetPixel( x, y ); - if ( pxl != 0 ) { - top = y; - gotIt = XP_TRUE; - } - } - } - - gotIt = XP_FALSE; - for ( y = BMP_HT - 1; !gotIt && y >= 0; --y ) { - for ( x = 0; !gotIt && x < BMP_WIDTH; ++x ) { - IndexedColorType pxl = WinGetPixel( x, y ); - if ( pxl != 0 ) { - bottom = y; - gotIt = XP_TRUE; - } - } - } - - (void)WinSetDrawWindow( oldWin ); - WinDeleteWindow( win, false ); - - /* There should be a way to avoid this, but HIGHRES_PUSH after - WinSetDrawWindow isn't working... Fix this... */ - if ( dctx->doHiRes ) { - top *= 2; - bottom *= 2; - } - - fhi->topOffset = top; - fhi->height = bottom - top + 1; - - } - BmpDelete( bitmap ); - } -} /* measureFace */ - -static void -checkFontOffsets( PalmDrawCtx* dctx, const DictionaryCtxt* dict ) -{ - XP_LangCode code; - XP_U16 nFaces; - Tile tile; - - code = dict_getLangCode( dict ); - if ( code != dctx->fontLangCode ) { - - if ( !!dctx->fontHtInfo ) { - XP_FREE( dctx->mpool, dctx->fontHtInfo ); - } - - nFaces = dict_numTileFaces( dict ); - dctx->fontHtInfo = XP_MALLOC( dctx->mpool, - nFaces * sizeof(*dctx->fontHtInfo) ); - - for ( tile = 0; tile < nFaces; ++tile ) { - XP_UCHAR face[2]; - if ( 1 == dict_tilesToString( dict, &tile, 1, - face, sizeof(face) ) ) { - measureFace( dctx, face[0], &dctx->fontHtInfo[tile] ); - } - } - - dctx->fontLangCode = code; - } -} - -static XP_Bool -palm_common_draw_boardBegin( DrawCtx* p_dctx, const XP_Rect* rect, - DrawFocusState dfs ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - PalmAppGlobals* globals = dctx->globals; - if ( !globals->gState.showGrid ) { - WinDrawRectangleFrame(rectangleFrame, (RectangleType*)rect); - } - -#ifdef DRAW_FOCUS_FRAME - dctx->topFocus = dfs == DFS_TOP; -#endif - return XP_TRUE; -} /* palm_common_draw_boardBegin */ - -#ifdef COLOR_SUPPORT -static XP_Bool -palm_clr_draw_boardBegin( DrawCtx* p_dctx, const XP_Rect* rect, - DrawFocusState dfs ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - WinPushDrawState(); - - WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] ); - WinSetTextColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] ); - WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_WHITE] ); - - HIGHRES_PUSH_NOPOP(dctx); - - palm_common_draw_boardBegin( p_dctx, rect, dfs ); - - return XP_TRUE; -} /* palm_clr_draw_boardBegin */ - -static void -palm_draw_objFinished( DrawCtx* p_dctx, BoardObjectType typ, - const XP_Rect* rect, DrawFocusState dfs ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; -#if defined XWFEATURE_FIVEWAY && defined DRAW_FOCUS_FRAME - if ( (dfs == DFS_TOP) && (typ == OBJ_BOARD) ) { - XP_Rect r; - XP_U16 i; - IndexedColorType oldColor; - - oldColor - = WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] ); - - r.left = rect->left + 1; - r.top = rect->top + 1; - r.width = rect->width - 1; - r.height = rect->height - 1; - - for ( i = dctx->doHiRes?FOCUS_BORDER_WIDTH:FOCUS_BORDER_WIDTH/2; - i > 0; --i ) { - insetRect( &r, 1 ); - WinDrawRectangleFrame(rectangleFrame, (RectangleType*)&r ); - } - (void)WinSetForeColor( oldColor ); - } -#endif - - if ( typ == OBJ_BOARD ) { - WinPopDrawState(); - } else if ( typ == OBJ_TRAY ) { - WinSetClip( &dctx->oldTrayClip ); - WinPopDrawState(); - } else if ( typ == OBJ_SCORE ) { - WinSetClip( &dctx->oldScoreClip ); - HIGHRES_POP(dctx); - } -} /* palm_draw_objFinished */ - -static XP_Bool -palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, - const XP_UCHAR* letters, const XP_Bitmaps* bitmaps, - Tile tile, XP_S16 owner, XWBonusType bonus, - HintAtts hintAtts, CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - IndexedColorType color; - XP_U16 index; - XP_Bool isCursor = TREAT_AS_CURSOR( dctx, flags ); - XP_Bool isPending = ((flags & CELL_HIGHLIGHT) != 0); - XP_Bool dragSrc = ((flags & CELL_DRAGSRC) != 0); - - if ( isCursor ) { - index = COLOR_CURSOR; - } else if ( isPending && !dragSrc ) { - /* don't color background if will invert */ - index = COLOR_WHITE; - } else if ( (!!bitmaps || !!letters) && !dragSrc ) { - index = COLOR_TILE; - } else if ( bonus == BONUS_NONE ) { - index = COLOR_EMPTY; - } else { - index = COLOR_DBL_LTTR + bonus - 1; - } - color = dctx->drawingPrefs->drawColors[index]; - WinSetBackColor( color ); - - if ( !!letters ) { - if ( (owner >= 0) && !isPending ) { - index = COLOR_PLAYER1 + owner; - } else { - index = COLOR_BLACK; - } - - color = dctx->drawingPrefs->drawColors[index]; - WinSetTextColor( color ); - } - - return palm_common_draw_drawCell( p_dctx, rect, letters, bitmaps, - tile, owner, bonus, hintAtts, flags ); -} /* palm_clr_draw_drawCell */ - -static void -palm_clr_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, - const DrawScoreInfo* dsi ) -{ - XP_U16 playerNum = dsi->playerNum; - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - XP_U16 txtIndex; - IndexedColorType newColor; - - WinPushDrawState(); - - if ( dsi->flags && CELL_ISCURSOR ) { - WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] ); - pmEraseRect( rOuter ); - } - - if ( dsi->selected ) { - XP_Rect r = *rInner; - insetRect2( &r, (r.width - rOuter->width) >> 2, - (r.height - rOuter->height) >> 2 ); - WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] ); - pmEraseRect( &r ); - txtIndex = COLOR_WHITE; - } else { - txtIndex = COLOR_PLAYER1+playerNum; - } - - newColor = dctx->drawingPrefs->drawColors[txtIndex]; - (void)WinSetTextColor( newColor ); - (void)WinSetForeColor( newColor ); - - doDrawPlayer( dctx, dsi, rInner ); - - WinPopDrawState(); -} /* palm_clr_draw_score_drawPlayer */ -#endif /* #ifdef COLOR_SUPPORT */ - -static void -palmDrawHintBorders( PalmDrawCtx* dctx, const XP_Rect* rect, - HintAtts hintAtts ) -{ - if ( 0 != (HINT_BORDER_EDGE & hintAtts) ) { - XP_Rect frame = *rect; - XP_U16 width = dctx->doHiRes ? 4 : 2; - XP_Bool showGrid = dctx->globals->gState.showGrid; - if ( showGrid ) { - ++width; - } - - if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) { - XP_Rect r = frame; - r.width = width; - WinDrawRectangle( (RectangleType*)&r, 0 ); - } - if ( (hintAtts & HINT_BORDER_TOP) != 0 ) { - XP_Rect r = frame; - r.height = width; - WinDrawRectangle( (RectangleType*)&r, 0 ); - } - if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) { - XP_Rect r = frame; - r.left += r.width - width; - if ( showGrid ) { - ++r.left; - } - r.width = width; - WinDrawRectangle( (RectangleType*)&r, 0 ); - } - if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) { - XP_Rect r = frame; - r.top += r.height - width; - if ( showGrid ) { - ++r.top; - } - r.height = width; - WinDrawRectangle( (RectangleType*)&r, 0 ); - } - } -} /* palmDrawHintBorders */ - -static XP_Bool -palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, - const XP_UCHAR* letters, const XP_Bitmaps* bitmaps, - Tile tile, XP_S16 owner, XWBonusType bonus, - HintAtts hintAtts, CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - GraphicsAbility able = dctx->able; - XP_Rect localR = *rect; - XP_U16 len; - RectangleType saveClip, intersectR; - PalmAppGlobals* globals = dctx->globals; - Boolean showGrid = globals->gState.showGrid; - Boolean showBonus = bonus != BONUS_NONE; - Boolean complete; - XP_Bool showEmpty = 0 != (flags & (CELL_ISEMPTY|CELL_DRAGSRC)); - - if ( showGrid ) { - ++localR.width; - ++localR.height; - } - - WinGetClip( &saveClip ); - - RctGetIntersection( &saveClip, (RectangleType*)&localR, &intersectR ); - - /* If there's no rect left inside the clip rgn, exit. But if the rect's - only partial go ahead and draw, but still return false indicating that - we'd like to be allowed to draw again. This is necessary when a cell - needs to be redrawn for two reasons, e.g. because its bottom half - overlaps a form that's gone away (and that supplied the clip region) - and because its top is covered by the trading miniwindow that's also - going away. Under no circumstances draw outside the clip region or - risk overdrawing menus, other forms, etc. */ - - if ( intersectR.extent.x == 0 || intersectR.extent.y == 0 ) { - return XP_FALSE; - } else if ( intersectR.extent.x < localR.width || - intersectR.extent.y < localR.height ) { - complete = XP_FALSE; - } else { - complete = XP_TRUE; - } - WinSetClip( (RectangleType*)&intersectR ); - - if ( showGrid ) { - insetRect( &localR, 1 ); - } - - pmEraseRect( &localR ); - - if ( showEmpty ) { - /* do nothing */ - } else if ( !!bitmaps ) { - XP_Bool doColor = (able == COLOR) && (owner >= 0); - XP_U16 x = localR.left+1; - XP_U16 y = localR.top+1; - /* cheating again; this belongs in a palm_clr method. But the - special bitmaps are rare enough that we shouldn't change the palm - draw state every time. */ - if ( doColor ) { - WinSetForeColor( - dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] ); - } - - if ( dctx->doHiRes ) { - ++x; - ++y; - } - XP_ASSERT( bitmaps->nBitmaps > 0 ); - WinDrawBitmap( bitmaps->bmps[0], x, y ); - if ( doColor ) { - WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] ); - } - showBonus = doColor; /* skip bonus in B&W case; can't draw both! */ - } else if ( !!letters ) { - len = XP_STRLEN( (const char*)letters ); - XP_ASSERT( len > 0 ); - if ( len > 0 ) { - XP_S16 strWidth = FntCharsWidth( (const char*)letters, len ); - XP_U16 x, y; - x = localR.left + ((localR.width-strWidth) / 2); - y = localR.top - dctx->fontHtInfo[tile].topOffset; - /* '+ 1' below causes us to round up. Without this "Q" is drawn - with its top higher than other ASCII letters because it's - taller; looks bad. */ - y += (localR.height + 1 - dctx->fontHtInfo[tile].height) / 2; - if ( len == 1 ) { - ++x; - } - - WinDrawChars( (const char*)letters, len, x, y ); - - showBonus = XP_FALSE; - } - } - - if ( ((flags & CELL_ISSTAR) != 0) && showEmpty ) { - bitmapInRect( dctx, STAR_BMP_RES_ID, rect ); - } else if ( showBonus && (able == ONEBIT) ) { - /* this is my one refusal to totally factor bandw and color - code */ - WinSetPattern( (const CustomPatternType*) - &dctx->u.bnw.valuePatterns[bonus-1] ); - WinFillRectangle( (RectangleType*)&localR, 0 ); - } else if ( !showBonus && showEmpty && !showGrid ) { - /* should this be in the v-table so I don't have to test each - time? */ - RectangleType r; - r.topLeft.x = localR.left + ((PALM_BOARD_SCALE-1)/2); - r.topLeft.y = localR.top + ((PALM_BOARD_SCALE-1)/2); - - if ( dctx->doHiRes ) { - r.topLeft.x += PALM_BOARD_SCALE/2; - r.topLeft.y += PALM_BOARD_SCALE/2; - } - - if ( globals->romVersion >= 35 ) { - WinDrawPixel( r.topLeft.x, r.topLeft.y ); - } else { - r.extent.x = r.extent.y = 1; - WinDrawRectangle( &r, 0 ); - } - } - - if ( !showEmpty && (flags & CELL_HIGHLIGHT) != 0 ) { - if ( !TREAT_AS_CURSOR( dctx, flags ) ) { - XP_ASSERT( !!bitmaps || - (!!letters && XP_STRLEN((const char*)letters)>0)); - WinInvertRectangle( (RectangleType*)&localR, 0 ); - } - } - - if ( showGrid ) { - WinDrawRectangleFrame(rectangleFrame, (RectangleType*)&localR); - } - - if ( ((flags & CELL_ISBLANK) != 0) && !showEmpty ) { - WinEraseRectangleFrame( roundFrame, (RectangleType*)&localR ); - } - - palmDrawHintBorders( dctx, rect, hintAtts ); - - WinSetClip( &saveClip ); - return complete; -} /* palm_common_draw_drawCell */ - -void -palm_draw_destroyCtxt( DrawCtx* p_dctx ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - XP_FREE( dctx->mpool, p_dctx->vtable ); - if ( !!dctx->fontHtInfo ) { - XP_FREE( dctx->mpool, dctx->fontHtInfo ); - } - XP_FREE( dctx->mpool, dctx ); -} /* palm_draw_destroyCtxt */ - - -static void -palm_draw_dictChanged( DrawCtx* p_dctx, const DictionaryCtxt* dict ) -{ - checkFontOffsets( (PalmDrawCtx*)p_dctx, dict ); -} - -static void -palm_draw_invertCell( DrawCtx* p_dctx, const XP_Rect* rect ) -{ - XP_Rect localR = *rect; - /* insetRect( &localR, 3 ); */ - localR.top += 3; - localR.left += 3; - localR.width -= 5; - localR.height -= 5; - - HIGHRES_PUSH_LOC( (PalmDrawCtx*)p_dctx ); - WinInvertRectangle( (RectangleType*)&localR, 0 ); - HIGHRES_POP_LOC( (PalmDrawCtx*)p_dctx ); -} /* palm_draw_invertCell */ - -static XP_Bool -palm_clr_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 owner, DrawFocusState dfs ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - dctx->trayOwner = owner; - - WinPushDrawState(); - WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_TILE] ); - WinSetTextColor( dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] ); - WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] ); - - HIGHRES_PUSH_NOPOP(dctx); - - palm_bnw_draw_trayBegin( p_dctx, rect, owner, dfs ); - return XP_TRUE; -} /* palm_clr_draw_trayBegin */ - -static XP_Bool -palm_bnw_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 XP_UNUSED(owner), - DrawFocusState dfs ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - WinGetClip( &dctx->oldTrayClip ); - WinSetClip( (RectangleType*)rect ); - dctx->topFocus = dfs == DFS_TOP; - return XP_TRUE; -} /* palm_bnw_draw_trayBegin */ - -static void -smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y ) -{ - UInt32 oldMode = WinSetScalingMode( kTextScalingOff ); - FontID curFont = FntGetFont(); - FntSetFont( boldFont ); - - /* negative x means position backwards from it */ - if ( x < 0 ) { - x = (-x) - FntCharsWidth( str, len ); - } - - WinDrawChars( str, len, x, y ); - - FntSetFont( curFont ); - WinSetScalingMode( oldMode ); -} /* smallBoldStringAt */ - -static void -palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, - const XP_UCHAR* letters, const XP_Bitmaps* bitmaps, - XP_U16 val, CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - char valBuf[3]; - XP_Rect localR = *rect; - XP_U16 len, width; - XP_U16 doubler = 1; - const XP_Bool cursor = (flags & CELL_ISCURSOR) != 0; - XP_Bool empty = (flags & CELL_ISEMPTY) != 0; - - WinPushDrawState(); - - if ( dctx->doHiRes ) { - doubler = 2; - } - - draw_clearRect( p_dctx, &localR ); - - if ( cursor ) { - (void)WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] ); - if ( dctx->topFocus ) { - WinEraseRectangle( (const RectangleType*)&localR, 0 ); - } - } - - localR.height -= 3 * doubler; - localR.top += 2 * doubler; - localR.width -= 3 * doubler; - localR.left += 2 * doubler; - - if ( (cursor && !dctx->topFocus) || (!empty && !cursor) ) { - /* this will fill it with the tile background color */ - WinEraseRectangle( (const RectangleType*)&localR, 0 ); - } - - if ( !empty ) { - /* Draw the number before the letter. Some PalmOS version don't - honor the winOverlay flag and erase. Better to erase the value - than the letter. */ - if ( (flags & CELL_VALHIDDEN) == 0 ) { - (void)StrPrintF( valBuf, "%d", val ); - len = XP_STRLEN((const char*)valBuf); - - if ( dctx->doHiRes && dctx->oneDotFiveAvail ) { - smallBoldStringAt( valBuf, len, - -(localR.left + localR.width), - localR.top + localR.height - dctx->fntHeight - - 1 ); - } else { - width = FntCharsWidth( valBuf, len ); - WinDrawChars( valBuf, len, localR.left + localR.width - width, - localR.top + localR.height - (10*doubler) ); - } - } - - if ( !!bitmaps ) { - XP_ASSERT( bitmaps->nBitmaps > 1 ); - WinDrawBitmap( (BitmapPtr)(bitmaps->bmps[1]), - localR.left+(2*doubler), - localR.top+(2*doubler) ); - } else if ( !!letters ) { - if ( *letters != LETTER_NONE ) { /* blank */ - FontID curFont = FntSetFont( largeFont ); - - HIGHRES_PUSH_LOC( dctx ); - - WinDrawChars( (char*)letters, 1, - localR.left + (1*doubler), - localR.top + (0*doubler) ); - - HIGHRES_POP_LOC(dctx); - - FntSetFont( curFont ); - } - } - - WinDrawRectangleFrame( rectangleFrame, (RectangleType*)&localR ); - if ( (flags & CELL_HIGHLIGHT) != 0 ) { - insetRect( &localR, 1 ); - WinDrawRectangleFrame(rectangleFrame, (RectangleType*)&localR ); - if ( dctx->doHiRes ) { - insetRect( &localR, 1 ); - WinDrawRectangleFrame(rectangleFrame, - (RectangleType*)&localR ); - } - } - } - WinPopDrawState(); -} /* palm_draw_drawTile */ - -#ifdef POINTER_SUPPORT -static void -palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect, - const XP_UCHAR* letters, const XP_Bitmaps* bitmaps, - XP_U16 val, XP_U16 owner, CellFlags flags ) -{ - /* let trayBegin code take care of pushing color env changes. */ - draw_trayBegin( p_dctx, rect, owner, DFS_NONE ); - palm_draw_drawTile( p_dctx, rect, letters, bitmaps, val, flags ); - draw_objFinished( p_dctx, OBJ_TRAY, rect, DFS_NONE ); -} -#endif - -static void -palm_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect, CellFlags flags ) -{ - palm_draw_drawTile( p_dctx, rect, "?", (XP_Bitmap)NULL, - 0, (flags & CELL_ISCURSOR) | CELL_VALHIDDEN ); -} /* palm_draw_drawTileBack */ - -static void -palm_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect, - CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - XP_Rect lRect = *rect; - XP_Bool selected = (flags & CELL_HIGHLIGHT) != 0; - XP_Bool cursor = TREAT_AS_CURSOR(dctx, flags); - - if ( cursor ) { - (void)WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] ); - } - WinEraseRectangle( (const RectangleType*)&lRect, 0 ); - - ++lRect.left; - --lRect.width; - if ( cursor ) { - insetRect( &lRect, 2 ); - } - - if ( selected ) { - short pattern[] = { 0xFF00, 0xFF00, 0xFF00, 0xFF00 }; - - WinSetPattern( (const CustomPatternType*)&pattern ); - WinFillRectangle( (RectangleType*)&lRect, 0 ); - - } else { - WinDrawRectangle( (RectangleType*)&lRect, 0 ); - } -} /* palm_draw_drawTrayDivider */ - -static void -palm_bnw_draw_clearRect( DrawCtx* XP_UNUSED(p_dctx), const XP_Rect* rectP ) -{ - pmEraseRect( rectP ); -} /* palm_draw_clearRect */ - -static void -palm_clr_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - IndexedColorType oldColor; - - oldColor = WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_WHITE] ); - pmEraseRect( rectP ); - WinSetBackColor( oldColor ); -} /* palm_clr_draw_clearRect */ - -static void -palm_clr_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text, - const XP_Rect* rect, void** closureP ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_WHITE] ); - WinSetTextColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] ); - - palm_draw_drawMiniWindow( p_dctx, text, rect, closureP ); -} /* palm_clr_draw_drawMiniWindow */ - -static void -palm_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rectP, - XWBonusType XP_UNUSED(cursorBonus), XP_Bool vertical, - HintAtts hintAtts, CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - RectangleType oldClip; - - Int16 resID = vertical? DOWN_ARROW_RESID:RIGHT_ARROW_RESID; - - WinGetClip( &oldClip ); - WinSetClip( (RectangleType*)rectP ); - - bitmapInRect( dctx, resID, rectP ); - palmDrawHintBorders( dctx, rectP, hintAtts ); - - WinSetClip( &oldClip ); -} /* palm_draw_drawBoardArrow */ - -#ifdef COLOR_SUPPORT -static void -palm_clr_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rectP, - XWBonusType cursorBonus, XP_Bool vertical, - HintAtts hintAtts, CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - XP_U16 index; - - if ( TREAT_AS_CURSOR( dctx, flags ) ) { - index = COLOR_CURSOR; - } else if ( cursorBonus == BONUS_NONE ) { - index = COLOR_EMPTY; - } else { - index = COLOR_DBL_LTTR + cursorBonus - 1; - } - - WinSetBackColor( dctx->drawingPrefs->drawColors[index] ); - palm_draw_drawBoardArrow( p_dctx, rectP, cursorBonus, vertical, - hintAtts, flags ); -} /* palm_clr_draw_drawBoardArrow */ -#endif - -static void -palm_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 XP_UNUSED(numPlayers), - const XP_S16* XP_UNUSED(scores), - XP_S16 XP_UNUSED(remCount), - DrawFocusState XP_UNUSED(dfs) ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - HIGHRES_PUSH( dctx ); - - WinGetClip( &dctx->oldScoreClip ); - WinSetClip( (RectangleType*)rect ); - - pmEraseRect( rect ); -} /* palm_draw_scoreBegin */ - -/* rectContainsRect: Dup of something in board.c. They could share if I were - * willing to link from here out. - */ -static XP_Bool -rectContainsRect( const XP_Rect* rect1, const XP_Rect* rect2 ) -{ - return ( rect1->top <= rect2->top - && rect1->left <= rect2->left - && rect1->top + rect1->height >= rect2->top + rect2->height - && rect1->left + rect1->width >= rect2->left + rect2->width ); -} /* rectContainsRect */ - -static XP_Bool -palm_draw_vertScrollBoard( DrawCtx* XP_UNUSED(p_dctx), XP_Rect* rect, - XP_S16 dist, DrawFocusState dfs ) -{ - RectangleType clip; - XP_Bool canDoIt; - - /* if the clip rect doesn't contain the scroll rect we can't do anything - right now: WinScrollRectangle won't do its job. */ - WinGetClip( &clip ); - canDoIt = rectContainsRect( (XP_Rect*)&clip, rect ); - - if ( canDoIt ) { - RectangleType vacated; - WinDirectionType dir; - - if ( dist >= 0 ) { - dir = winUp; - } else { - dir = winDown; - dist = -dist; - } - -#ifdef PERIMETER_FOCUS - if ( dfs == DFS_TOP ) { - rect->height -= FOCUS_BORDER_WIDTH; - if ( dir == winDown ) { - rect->top += FOCUS_BORDER_WIDTH; - } - } -#endif - - WinScrollRectangle( (RectangleType*)rect, dir, dist, &vacated ); - *rect = *(XP_Rect*)&vacated; - } - return canDoIt; -} /* palm_draw_vertScrollBoard */ - -/* Given some text, determine its bounds and draw it if requested, else - * return the bounds. If the width of the string exceeds that of the rect in - * which it can be fit, split it at ':'. - */ -static void -palmMeasureDrawText( PalmDrawCtx* dctx, XP_Rect* bounds, XP_UCHAR* txt, - XP_Bool vertical, XP_Bool isTurn, XP_UCHAR skipChar, - XP_Bool draw ) -{ - XP_U16 len = XP_STRLEN( (const char*)txt ); - XP_U16 widths[2]; - XP_U16 maxWidth, height; - XP_U16 nLines = 1; - XP_U16 secondLen = 0; - XP_UCHAR* second = NULL; - XP_U16 doubler = 1; - - if ( dctx->doHiRes ) { - doubler = 2; - } - - widths[0] = FntCharsWidth( (const char*)txt, len ) + 1; - - if ( widths[0] > bounds->width ) { - XP_UCHAR ch[2]; - ch[0] = skipChar; - ch[1] = '\0'; - - XP_ASSERT( skipChar ); - second = (XP_UCHAR*)StrStr( (const char*)txt, (const char*)ch ); - XP_ASSERT( !!second ); - ++second; /* colon's on the first line */ - secondLen = XP_STRLEN( (const char*)second ); - - len -= secondLen; - - if ( skipChar ) { - --len; - } - - widths[0] = FntCharsWidth( (const char*)txt, len ); - widths[1] = FntCharsWidth( (const char*)second, secondLen ); - maxWidth = XP_MAX( widths[0], widths[1] ); - ++nLines; - } else { - maxWidth = widths[0]; - } - - height = nLines * FONT_HEIGHT + ( LINE_SPACING * (nLines-1) ); - if ( vertical && isTurn ) { - height += 5; /* for the horizontal bars */ - } - height *= doubler; - - XP_ASSERT( height <= bounds->height ); - XP_ASSERT( maxWidth <= bounds->width ); - - if ( draw ) { - XP_U16 x, y; - - /* Center what we'll be drawing by advancing the appropriate - coordinate to eat up half the extra space */ - x = bounds->left + 1;// + (bounds->width - widths[0]) / 2; - y = bounds->top; - if ( vertical && isTurn ) { - y += 1; - } else { - y -= 2; - if ( dctx->doHiRes ) { - --y; /* tweak it up one high-res pixel */ - } - } - - WinDrawChars( (const char*)txt, len, x, y ); - if ( nLines == 2 ) { - XP_ASSERT( vertical ); - y += (FONT_HEIGHT + LINE_SPACING) * doubler; - x = bounds->left + ((bounds->width - widths[1]) / 2); - WinDrawChars( (const char*)second, secondLen, x, y ); - } - - } else { - /* return the measurements */ - bounds->width = maxWidth; - bounds->height = height; - } - -} /* palmMeasureDrawText */ - -static void -palmFormatRemText( PalmDrawCtx* dctx, XP_UCHAR* buf, XP_S16 nTilesLeft ) -{ - const XP_UCHAR* remStr = (*dctx->getResStrFunc)(dctx->globals, - STR_REMTILES); - if ( nTilesLeft < 0 ) { - nTilesLeft = 0; - } - (void)StrPrintF( (char*)buf, (const char*)remStr, nTilesLeft ); -} /* palmFormatRemText */ - -static void -palm_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* rect, - XP_S16 nTilesLeft, XP_U16* widthP, XP_U16* heightP ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - PalmAppGlobals* globals = dctx->globals; - XP_UCHAR buf[10]; - XP_Rect localRect; - XP_Bool isVertical = !globals->gState.showGrid; - - palmFormatRemText( dctx, buf, nTilesLeft ); - - localRect = *rect; - palmMeasureDrawText( dctx, &localRect, buf, isVertical, XP_FALSE, - ':', XP_FALSE ); - - *widthP = localRect.width; - *heightP = localRect.height; -} /* palm_draw_measureRemText */ - -static void -palm_draw_drawRemText( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, XP_S16 nTilesLeft, - XP_Bool focussed ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - PalmAppGlobals* globals = dctx->globals; - XP_UCHAR buf[10]; - - XP_Bool isVertical = !globals->gState.showGrid; - - if ( focussed ) { - WinPushDrawState(); - WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] ); - pmEraseRect( rOuter ); - } - - palmFormatRemText( dctx, buf, nTilesLeft ); - - palmMeasureDrawText( dctx, (XP_Rect*)rInner, buf, isVertical, XP_FALSE, - ':', XP_TRUE ); - - if ( focussed ) { - WinPopDrawState(); - } -} /* palm_draw_drawRemText */ - -/* Measure text that'll be drawn for player. If vertical, it'll often get - * split into two lines, esp after the number of remaining tiles appears. - */ -static void -palmFormatScore( char* buf, const DrawScoreInfo* dsi, XP_Bool vertical ) -{ - char borders[] = {'•', '\0'}; - char remBuf[10]; - char* remPart = remBuf; - - if ( vertical || !dsi->isTurn ) { - borders[0] = '\0'; - } - - if ( dsi->nTilesLeft >= 0 ) { - StrPrintF( remPart, SCORE_SEPSTR "%d", dsi->nTilesLeft ); - } else { - *remPart = '\0'; - } - - (void)StrPrintF( buf, "%s%d%s%s", borders, dsi->totalScore, - remPart, borders ); -} /* palmFormatScore */ - -static void -palm_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* rect, - const DrawScoreInfo* dsi, - XP_U16* widthP, XP_U16* heightP ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - PalmAppGlobals* globals = dctx->globals; - char buf[20]; - /* FontID oldFont = 0; */ - XP_Bool vertical = !globals->gState.showGrid; - XP_Rect localRect = *rect; - - /* if ( !vertical && dsi->selected ) { */ - /* oldFont = FntGetFont(); */ - /* FntSetFont( boldFont ); */ - /* } */ - - palmFormatScore( buf, dsi, vertical ); - palmMeasureDrawText( dctx, &localRect, (XP_UCHAR*)buf, dsi->isTurn, - vertical, SCORE_SEP, XP_FALSE ); - - *widthP = localRect.width; - *heightP = localRect.height; - - /* result = widthAndText( buf, score, nTilesInTray, isTurn, */ - /* !globals->gState.showGrid, &ignore, ignoreLines ); */ - - /* if ( !vertical && dsi->selected ) { */ - /* FntSetFont( oldFont ); */ - /* } */ -} /* palm_draw_measureScoreText */ - -static void -doDrawPlayer( PalmDrawCtx* dctx, const DrawScoreInfo* dsi, - const XP_Rect* rInner ) -{ - PalmAppGlobals* globals = dctx->globals; - XP_Bool vertical = !globals->gState.showGrid; - XP_UCHAR scoreBuf[20]; - - palmFormatScore( (char*)scoreBuf, dsi, vertical ); - palmMeasureDrawText( dctx, (XP_Rect*)rInner, (XP_UCHAR*)scoreBuf, vertical, - dsi->isTurn, SCORE_SEP, XP_TRUE ); - - if ( vertical && dsi->isTurn ) { - RectangleType r = *(RectangleType*)rInner; - XP_U16 x, y; - - x = r.topLeft.x; - y = r.topLeft.y + 1; - - WinDrawLine( x, y, x + r.extent.x - 1, y); - y += r.extent.y - 3; - WinDrawLine( x, y, x + r.extent.x - 1, y ); - } -} - -static void -palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, - const DrawScoreInfo* dsi ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - doDrawPlayer( dctx, dsi, rInner ); - - if ( dsi->selected ) { - WinInvertRectangle( (RectangleType*)rInner, 0 ); - } -} /* palm_bnw_draw_score_drawPlayer */ - -#define PENDING_DIGITS 3 -static void -palm_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect, - XP_S16 score, XP_U16 XP_UNUSED(playerNum), - CellFlags flags ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - char buf[PENDING_DIGITS+1] = "000"; - RectangleType oldClip, newClip; - XP_U16 x = rect->left + 1; - IndexedColorType oclr = 0; - - XP_ASSERT( flags == CELL_NONE || flags == CELL_ISCURSOR ); - - HIGHRES_PUSH_LOC(dctx); - - if ( flags != CELL_NONE ) { - oclr = WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] ); - } - - WinGetClip( &oldClip ); - RctGetIntersection( &oldClip, (RectangleType*)rect, &newClip ); - if ( newClip.extent.y > 0 ) { - WinSetClip( &newClip ); - pmEraseRect( rect ); - - if ( score >= 0 ) { - XP_UCHAR tbuf[4]; - UInt16 len; - if ( score <= 999 ) { - StrPrintF( (char*)tbuf, "%d", score ); - } else { - StrCopy( (char*)tbuf, "wow" ); /* thanks, Marcus :-) */ - } - len = XP_STRLEN( (const char*)tbuf ); - XP_MEMCPY( &buf[PENDING_DIGITS-len], tbuf, len ); - } else { - StrCopy( buf, "???" ); - } - - /* There's no room for the pts string if we're in highres mode and - WinSetScalingMode isn't available. */ - if ( !dctx->doHiRes || dctx->oneDotFiveAvail ) { - const XP_UCHAR* str = (*dctx->getResStrFunc)( dctx->globals, - STR_PTS ); - - if ( dctx->oneDotFiveAvail ) { - smallBoldStringAt( (const char*)str, XP_STRLEN((const char*)str), - x, rect->top ); - } else { - WinDrawChars( (const char*)str, - XP_STRLEN((const char*)str), x, rect->top ); - } - } - - WinDrawChars( buf, PENDING_DIGITS, x, - rect->top + (rect->height/2) - 1 ); - WinSetClip( &oldClip ); - } - - if ( flags != 0 ) { - (void)WinSetBackColor( oclr ); - } - - HIGHRES_POP_LOC(dctx); -} /* palm_draw_score_pendingScore */ - -static void -palmFormatTimerText( XP_UCHAR* buf, XP_S16 secondsLeft ) -{ - XP_U16 minutes, seconds; - XP_UCHAR secBuf[6]; - - if ( secondsLeft < 0 ) { - *buf++ = '-'; - secondsLeft *= -1; - } - minutes = secondsLeft / 60; - seconds = secondsLeft % 60; - - /* StrPrintF can't do 0-padding; do it manually. Otherwise 5:03 will - come out 5:3 */ - StrPrintF( (char*)secBuf, "0%d", seconds ); - StrPrintF( (char*)buf, "%d:%s", minutes, - secBuf[2] == '\0'? secBuf:&secBuf[1] ); -} /* palmFormatTimerText */ - -static void -palm_draw_drawTimer( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 XP_UNUSED(player), XP_S16 secondsLeft ) -{ - /* This is called both from within drawScoreboard and not, meaning that - * sometimes draw_boardBegin() and draw_boardFinished() bracket it and - * sometimes they don't. So it has to do its own HIGHRES_PUSH_LOC stuff. - */ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - XP_UCHAR buf[10]; - XP_Rect localR = *rect; - RectangleType saveClip; - XP_U16 len, width, y; - - HIGHRES_PUSH_LOC(dctx); - - palmFormatTimerText( buf, secondsLeft ); - len = XP_STRLEN( (const char*)buf ); - - width = FntCharsWidth( (const char*)buf, len ); - - pmEraseRect( &localR ); - - if ( width < localR.width ) { - localR.left += localR.width - width; - localR.width = width; - } - - y = localR.top - 2; - if ( dctx->doHiRes ) { - y -= 1; /* tweak it up one high-res pixel */ - } - - WinGetClip( &saveClip ); - WinSetClip( (RectangleType*)&localR ); - - WinDrawChars( (const char*)buf, len, localR.left, y ); - WinSetClip( &saveClip ); - - HIGHRES_POP_LOC(dctx); -} /* palm_draw_drawTimer */ - -#define MINI_LINE_HT 12 -#define MINI_V_PADDING 6 -#define MINI_H_PADDING 8 - -static const XP_UCHAR* -palm_draw_getMiniWText( DrawCtx* p_dctx, XWMiniTextType textHint ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - const XP_UCHAR* str; - XP_U16 strID = 0; /* make compiler happy */ - - switch( textHint ) { - case BONUS_DOUBLE_LETTER: - strID = STR_DOUBLE_LETTER; break; - case BONUS_DOUBLE_WORD: - strID = STR_DOUBLE_WORD; break; - case BONUS_TRIPLE_LETTER: - strID = STR_TRIPLE_LETTER; break; - case BONUS_TRIPLE_WORD: - strID = STR_TRIPLE_WORD; break; - case INTRADE_MW_TEXT: - strID = STR_TRADING_REMINDER; break; - default: - XP_ASSERT( XP_FALSE ); - } - - str = (*dctx->getResStrFunc)( dctx->globals, strID ); - - return str; -} /* palm_draw_getMiniWText */ - -static void -splitString( const XP_UCHAR* str, XP_U16* nBufsP, XP_UCHAR** bufs ) -{ - XP_U16 nBufs = 0; - - for ( ; ; ) { - XP_UCHAR* nextStr = StrStr( str, XP_CR ); - XP_U16 len = nextStr==NULL? XP_STRLEN(str): nextStr - str; - - XP_ASSERT( nextStr != str ); - - XP_MEMCPY( bufs[nBufs], str, len ); - bufs[nBufs][len] = '\0'; - ++nBufs; - - if ( nextStr == NULL ) { - break; - } - str = nextStr + XP_STRLEN(XP_CR); /* skip '\n' */ - } - *nBufsP = nBufs; -} /* splitString */ - -#define VALUE_HINT_RECT_HEIGHT 12 -#define VALUE_HINT_RECT_HEIGHT_HR 24 -static XP_U16 -getMiniLineHt( PalmDrawCtx* dctx ) -{ - if ( dctx->doHiRes ) { - return VALUE_HINT_RECT_HEIGHT_HR; - } else { - return VALUE_HINT_RECT_HEIGHT; - } -} /* getMiniLineHt */ - -static void -palm_draw_measureMiniWText( DrawCtx* p_dctx, const XP_UCHAR* str, - XP_U16* widthP, XP_U16* heightP ) -{ - XP_U16 maxWidth, height; - XP_UCHAR buf1[48]; - XP_UCHAR buf2[48]; - XP_UCHAR* bufs[2] = { buf1, buf2 }; - XP_U16 nBufs, i; - - HIGHRES_PUSH_LOC( (PalmDrawCtx*)p_dctx ); - FntSetFont( stdFont ); - - splitString( str, &nBufs, bufs ); - - for ( height = 0, maxWidth = 0, i = 0; i < nBufs; ++i ) { - XP_U16 oneWidth = 8 + FntCharsWidth( (const char*)bufs[i], - XP_STRLEN(bufs[i]) ); - - maxWidth = XP_MAX( maxWidth, oneWidth ); - height += getMiniLineHt((PalmDrawCtx*)p_dctx); - } - - *widthP = maxWidth; - *heightP = height + 4; - - HIGHRES_POP_LOC( (PalmDrawCtx*)p_dctx ); -} /* palm_draw_measureMiniWText */ - -static void -palm_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text, - const XP_Rect* rect, void** XP_UNUSED(closureP) ) -{ - XP_Rect localR; - XP_UCHAR buf1[48]; - XP_UCHAR buf2[48]; - XP_UCHAR* bufs[2] = { buf1, buf2 }; - XP_U16 nBufs, i, offset; - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - - HIGHRES_PUSH_LOC(dctx); - - localR = *rect; - insetRect( &localR, 1 ); - WinEraseRectangle( (RectangleType*)&localR, 0 ); - localR.left++; - localR.top++; - localR.width -= 3; - localR.height -= 3; - WinDrawRectangleFrame( popupFrame, (RectangleType*)&localR ); - - splitString( text, &nBufs, bufs ); - - offset = 0; - for ( i = 0; i < nBufs; ++i ) { - XP_UCHAR* txt = bufs[i]; - XP_U16 len = XP_STRLEN( txt ); - XP_U16 width = FntCharsWidth( txt, len ); - - WinDrawChars( (const char*)txt, len, - localR.left + ((localR.width-width)/2), - localR.top + 1 + offset ); - offset += getMiniLineHt( dctx ); - } - - HIGHRES_POP_LOC( dctx ); -} /* palm_draw_drawMiniWindow */ - -static void -draw_doNothing( DrawCtx* XP_UNUSED(dctx), ... ) -{ -} /* draw_doNothing */ - -DrawCtx* -palm_drawctxt_make( MPFORMAL GraphicsAbility able, - PalmAppGlobals* globals, - GetResStringFunc getRSF, DrawingPrefs* drawprefs ) -{ - PalmDrawCtx* dctx; - XP_U16 i; - XP_U16 cWinWidth, cWinHeight; - - dctx = XP_MALLOC( mpool, sizeof(PalmDrawCtx) ); - XP_MEMSET( dctx, 0, sizeof(PalmDrawCtx) ); - - MPASSIGN(dctx->mpool, mpool); - - dctx->able = able; - dctx->doHiRes = globals->hasHiRes && globals->width == 320; - dctx->globals = globals; - dctx->getResStrFunc = getRSF; - dctx->drawingPrefs = drawprefs; - - dctx->vtable = XP_MALLOC( mpool, - sizeof(*(((PalmDrawCtx*)dctx)->vtable)) ); - for ( i = 0; i < sizeof(*dctx->vtable)/4; ++i ) { - ((void**)(dctx->vtable))[i] = draw_doNothing; - } - - /* To keep the number of entry points this file has to 1, all - functions but the initter called from here must go through a - vtable call. so....*/ - dctx->drawBitmapFunc = drawBitmapAt; - - SET_VTABLE_ENTRY( dctx->vtable, draw_destroyCtxt, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_dictChanged, palm ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_invertCell, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTile, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTileBack, palm ); -#ifdef POINTER_SUPPORT - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTileMidDrag, palm ); -#endif - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTrayDivider, palm ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, palm ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreBegin, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_vertScrollBoard, palm ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_measureRemText, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawRemText, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_measureScoreText, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_objFinished, palm ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, palm ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, palm ); - - if ( able == COLOR ) { -#ifdef COLOR_SUPPORT - SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, palm_clr ); - - SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, palm_clr ); -#else - XP_ASSERT(0); -#endif - } else { - SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, palm_common ); - SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, palm_common ); - SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, palm_bnw ); - SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, palm_bnw ); - SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_bnw ); - } - - cWinWidth = CHARRECT_WIDTH; - cWinHeight = CHARRECT_HEIGHT; - if ( dctx->doHiRes ) { - cWinWidth *= 2; - cWinHeight *= 2; - } - - if ( able == COLOR ) { - } else { - short patBits[] = { 0x8844, 0x2211, 0x8844, 0x2211, - 0xaa55, 0xaa55, 0xaa55, 0xaa55, - 0xCC66, 0x3399, 0xCC66, 0x3399, - 0xCCCC, 0x3333, 0xCCCC, 0x3333 }; - XP_MEMCPY( &dctx->u.bnw.valuePatterns[0], patBits, sizeof(patBits) ); - } - - dctx->fntHeight = FntBaseLine(); - dctx->oneDotFiveAvail = globals->oneDotFiveAvail; - - return (DrawCtx*)dctx; -} /* palm_drawctxt_make */ - diff --git a/xwords4/palm/palmip.c b/xwords4/palm/palmip.c deleted file mode 100644 index 5dc9d28a1..000000000 --- a/xwords4/palm/palmip.c +++ /dev/null @@ -1,378 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -#ifdef XWFEATURE_RELAY - -#include - -#include "palmip.h" -#include "memstream.h" - -#define NETLIB_TIMEOUT (5 * sysTicksPerSecond) -#define NAMELOOKUP_TIMEOUT (60*sysTicksPerSecond) - -void -palm_ip_setup( PalmAppGlobals* globals ) -{ - globals->nlStuff.socket = -1; - globals->nlStuff.netLibRef = 0; /* probably unnecessary */ -} - -static void -close_socket( PalmAppGlobals* globals ) -{ - if ( globals->nlStuff.socket != -1 ) { - Err ignore; - NetLibSocketClose( globals->nlStuff.netLibRef, - globals->nlStuff.socket, 0, &ignore); - globals->nlStuff.socket = -1; - } -} /* close_socket */ - -void -palm_ip_close( PalmAppGlobals* globals ) -{ - if ( globals->nlStuff.netLibRef != 0 ) { - - close_socket( globals ); - - NetLibClose(globals->nlStuff.netLibRef, 0); - - globals->nlStuff.netLibRef = 0; - } -} /* palm_ip_close */ - -static XP_Bool -openNetLibIfNot( PalmAppGlobals* globals ) -{ - Err err; - XP_Bool done = globals->nlStuff.netLibRef != 0; - - if ( !done ) { - UInt16 libRef; - err = SysLibFind( "Net.lib", &libRef); - if ( err == errNone ) { - UInt16 ifErrs; - err = NetLibOpen( libRef, &ifErrs ); - if ( err == errNone ) { - globals->nlStuff.netLibRef = libRef; - done = XP_TRUE; - XP_LOGF( "successful netlib open" ); - } else { - XP_LOGF( "NetLibOpen failed: err=%d; ifErrs=%d", - err, ifErrs ); - } - } - } - - return done; -} /* openNetLibIfNot */ - -static XP_Bool -connectSocket( PalmAppGlobals* globals, const CommsAddrRec* addr ) -{ - XP_Bool success; - Err err; - NetSocketAddrINType socketAddr; - - socketAddr.family = netSocketAddrINET; - socketAddr.port = XP_HTONS( addr->u.ip_relay.port ); - socketAddr.addr = XP_HTONL( addr->u.ip_relay.ipAddr ); - - success = ( 0 == NetLibSocketConnect( globals->nlStuff.netLibRef, - globals->nlStuff.socket, - (NetSocketAddrType*)&socketAddr, - sizeof(socketAddr), NETLIB_TIMEOUT, - &err ) ); - if ( !success ) { - XP_LOGF( "NetLibSocketConnect => %d", err ); - } - return success; -} /* connectSocket */ - -static XP_Bool -openSocketIfNot( PalmAppGlobals* globals, const CommsAddrRec* addr ) -{ - XP_Bool open = globals->nlStuff.socket != -1; - - if ( !open ) { - Err err; - NetSocketRef socket; - - XP_ASSERT( globals->nlStuff.netLibRef != 0 ); - - socket = NetLibSocketOpen( globals->nlStuff.netLibRef, - netSocketAddrINET, - netSocketTypeStream, - 0, /* protocol (ignored) */ - NETLIB_TIMEOUT, &err ); - if ( err == errNone ) { - NetSocketLingerType lt; - - XP_LOGF( "Opened socket %d", socket ); - - /* Just for grins, turn linger off; suggested by - * http://tomfrauen.blogspot.com/2005/01/some-palm-os-network-programming.html - */ - lt.onOff = true; - lt.time = 0; - NetLibSocketOptionSet( globals->nlStuff.netLibRef, socket, - netSocketOptLevelSocket, - netSocketOptSockLinger, <, sizeof(lt), - NETLIB_TIMEOUT, &err ); - - globals->nlStuff.socket = socket; - open = connectSocket( globals, addr ); - if ( !open ) { - close_socket( globals ); - } - - } else { - XP_LOGF( "Failed to open socket: %d", err ); - } - } - return open; -} /* openSocketIfNot */ - -static XP_Bool -resolveAddressIfNot( PalmAppGlobals* globals, CommsAddrRec* addr, - XP_Bool* resolvedP ) -{ - XP_Bool resolved = addr->u.ip_relay.ipAddr != 0 - && !globals->nlStuff.ipAddrInval; - *resolvedP = XP_FALSE; - - if ( !resolved ) { - NetHostInfoBufType niBuf; - NetHostInfoPtr result; - Err err; - - result = NetLibGetHostByName( globals->nlStuff.netLibRef, - addr->u.ip_relay.hostName, - &niBuf, NAMELOOKUP_TIMEOUT, &err ); - if ( result == NULL ) { - XP_LOGF( "NetLibGetHostByName => %d", err ); - } else { - - XP_ASSERT( result->addrLen == sizeof(addr->u.ip_relay.ipAddr) ); - /* Addresses are in host byte order. So just copy. */ - XP_MEMCPY( &addr->u.ip_relay.ipAddr, result->addrListP[0], - sizeof( addr->u.ip_relay.ipAddr ) ); - XP_LOGF( "got address 0x%lx for %s", addr->u.ip_relay.ipAddr, - addr->u.ip_relay.hostName ); - - *resolvedP = resolved = XP_TRUE; - globals->nlStuff.ipAddrInval = XP_FALSE; - - comms_setAddr( globals->game.comms, addr ); - } - } - return resolved; -} /* resolveAddressIfNot */ - -void -ip_addr_change( PalmAppGlobals* globals, const CommsAddrRec* oldAddr, - const CommsAddrRec* newAddr ) -{ - /* If host name changing, close any open socket and set up to inval - the cached ip address. */ - if ( 0 != XP_STRNCMP( oldAddr->u.ip_relay.hostName, - newAddr->u.ip_relay.hostName, - sizeof( oldAddr->u.ip_relay.hostName ) ) ) { - - close_socket( globals ); - globals->nlStuff.ipAddrInval = XP_TRUE; - } - -} /* ip_addr_change */ - -/* Deal with NetLibSend's willingness to send less than the full buffer */ -static XP_Bool -sendLoop( PalmAppGlobals* globals, const XP_U8* buf, XP_U16 len ) -{ - XP_U16 totalSent = 0; - - do { - XP_S16 thisSent; - Err err; - thisSent = NetLibSend( globals->nlStuff.netLibRef, - globals->nlStuff.socket, - (void*)(buf + totalSent), - len - totalSent, 0, /* flags */ - NULL, 0, NETLIB_TIMEOUT, &err ); - - if ( thisSent == 0 ) { - globals->nlStuff.socket = -1; /* mark socket closed */ - break; - } else if ( thisSent < 0 ) { - XP_LOGF( "NetLibSend => %d", err ); - break; - } else { - totalSent += thisSent; - if ( totalSent < len ) { - XP_LOGF( "looping in sendLoop: %d of %d sent so far", - totalSent, len ); - } - } - } while ( totalSent < len ); - - return totalSent == len; -} /* sendLoop */ - -XP_S16 -palm_ip_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addrp, - PalmAppGlobals* globals ) -{ - CommsAddrRec localRec; - CommsAddrRec* addr = &localRec; - XP_S16 nSent = -1; - - XP_LOGF( "%s: len=%d", __func__, len ); - XP_ASSERT( len < MAX_MSG_LEN ); - - if ( !!addrp ) { - XP_MEMCPY( addr, addrp, sizeof(*addr) ); - } else { - comms_getAddr( globals->game.comms, addr ); - } - - if ( openNetLibIfNot( globals ) ) { - XP_Bool resolved = XP_FALSE; - if ( resolveAddressIfNot( globals, addr, &resolved ) ) { - if ( resolved ) { - comms_setAddr( globals->game.comms, addr ); - } - - if ( openSocketIfNot( globals, addr ) ) { - XP_U16 netlen; - - /* Send the length */ - netlen = XP_HTONS( len ); - if ( sendLoop( globals, (XP_U8*)&netlen, sizeof(netlen) ) - && sendLoop( globals, buf, len ) ) { - nSent = len; - } - } - } else { - XP_LOGF( "%s: dropping because resolveAddressIfNot failed", __func__ ); - } - } - LOG_RETURNF( "%d", nSent ); - return nSent; -} /* palm_ip_send */ - -/* Deal with NetLibReceive's willingness to return will fewer bytes than - requested. */ -static XP_Bool -recvLoop( PalmAppGlobals* globals, XP_U8* buf, XP_U16 lenSought ) -{ - XP_U32 timeout = TimGetSeconds() + 5; - XP_U16 totalRead = 0; -/* NetSocketAddrINType fromAddr; */ -/* void* fromAddrP; */ -/* UInt16 fromLen; */ - -/* fromAddrP = NULL; */ -/* fromLen = 0; */ - - /* Be sure there's a way to timeout quickly here!!! */ - while ( (totalRead < lenSought) && (TimGetSeconds() < timeout) ) { - Err err; - Int16 nRead = NetLibReceive( globals->nlStuff.netLibRef, - globals->nlStuff.socket, - buf+totalRead, lenSought-totalRead, - 0, /* flags */ - NULL, NULL,//&fromLen, - NETLIB_TIMEOUT, &err ); - - if ( (nRead < 0) && (err != netErrTimeout) ) { - XP_LOGF( "NetLibReceive => %x", err ); - break; - } else if ( nRead == 0 ) { - XP_LOGF( "NetLibReceive; socket close" ); - globals->nlStuff.socket = -1; - break; - } else { - totalRead += nRead; - } - } - - XP_LOGF( "recvLoop got %d bytes", totalRead ); - return totalRead == lenSought; -} /* recvLoop */ - -static XWStreamCtxt* -packetToStream( PalmAppGlobals* globals ) -{ - XP_U8 buf[MAX_MSG_LEN]; - XWStreamCtxt* result = NULL; - XP_U16 netlen; - - if ( recvLoop( globals, (XP_U8*)&netlen, sizeof(netlen) ) ) { - netlen = XP_NTOHS( netlen ); - XP_LOGF( "netlen = %d", netlen ); - if ( recvLoop( globals, buf, netlen ) ) { - - result = mem_stream_make( MEMPOOL globals->vtMgr, - globals, 0, NULL ); - stream_open( result ); - stream_putBytes( result, buf, netlen ); - } - } - - return result; -} /* packetToStream */ - -void -checkHandleNetEvents( PalmAppGlobals* globals ) -{ - if ( ipSocketIsOpen( globals ) ) { - NetFDSetType readFDs; - NetFDSetType writeFDs; - NetFDSetType ignoreFDs; - XP_S16 nSockets; - UInt16 width; - Err err; - - netFDZero( &readFDs ); - netFDZero( &writeFDs ); - netFDZero( &ignoreFDs ); - - netFDSet( globals->nlStuff.socket, &readFDs ); - netFDSet( sysFileDescStdIn, &readFDs ); - width = XP_MAX( globals->nlStuff.socket, sysFileDescStdIn ); - - XP_ASSERT( globals->nlStuff.netLibRef != 0 ); - nSockets = NetLibSelect( globals->nlStuff.netLibRef, - width + 1, - &readFDs, &writeFDs, &ignoreFDs, - globals->runningOnPOSE? 0 : NETLIB_TIMEOUT, - &err ); - - if ( nSockets > 0 && netFDIsSet(globals->nlStuff.socket, &readFDs) ) { - - XWStreamCtxt* instream = packetToStream( globals ); - if ( !!instream ) { - checkAndDeliver( globals, NULL, instream, COMMS_CONN_RELAY ); - } - } - } -} /* checkHandleNetEvents */ - -#endif diff --git a/xwords4/palm/palmip.h b/xwords4/palm/palmip.h deleted file mode 100644 index 1276bd845..000000000 --- a/xwords4/palm/palmip.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2001 - 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PALMIP_H_ -#define _PALMIP_H_ - -#include "palmmain.h" - -void palm_ip_setup( PalmAppGlobals* globals ); -void palm_ip_close( PalmAppGlobals* globals ); -XP_S16 palm_ip_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, - PalmAppGlobals* globals ); -void ip_addr_change( PalmAppGlobals* globals, const CommsAddrRec* oldAddr, - const CommsAddrRec* newAddr ); -void checkHandleNetEvents( PalmAppGlobals* globals ); - -#endif diff --git a/xwords4/palm/palmir.c b/xwords4/palm/palmir.c deleted file mode 100644 index e82e6c581..000000000 --- a/xwords4/palm/palmir.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -#ifdef XWFEATURE_IR - -#include - -#include "palmir.h" - -#include "callback.h" -#include "xwords4defines.h" -#include "comms.h" -#include "memstream.h" -#include "palmutil.h" -#include "LocalizedStrIncludes.h" - -/* We're passed an address as we've previously defined it and a buffer - * containing a message to send. Prepend any palm/ir specific headers to the - * message, save the buffer somewhere, and fire up the state machine that - * will eventually get it sent to the address. - * - * Note that the caller will queue the message for possible resend, but - * won't automatically schedule that resend whatever results we return. - * - * NOTE also that simply stuffing the buf ptr into the packet won't work - * if there's any ir-specific packet header I need to prepend to what's - * outgoing. - */ -XP_S16 -palm_ir_send( const XP_U8* buf, XP_U16 len, PalmAppGlobals* globals ) -{ - UInt32 sent = 0; - Err err; - ExgSocketType exgSocket; - XP_MEMSET( &exgSocket, 0, sizeof(exgSocket) ); - exgSocket.description = "Crosswords data"; - exgSocket.length = len; - exgSocket.target = APPID; - - if ( globals->romVersion >= 40 ) { - exgSocket.name = exgBeamPrefix; - } - - err = ExgPut( &exgSocket ); - while ( !err && sent < len ) { - sent += ExgSend( &exgSocket, buf+sent, len-sent, &err ); - XP_ASSERT( sent < 0x7FFF ); - } - err = ExgDisconnect( &exgSocket, err ); - - return err==0? sent : 0; -} /* palm_ir_send */ - -void -palm_ir_receiveMove( PalmAppGlobals* globals, ExgSocketPtr socket ) -{ - UInt32 nBytesReceived = -1; - Err err; - - err = ExgAccept( socket ); - if ( err == 0 ) { - XWStreamCtxt* instream; - - instream = mem_stream_make( MEMPOOL globals->vtMgr, globals, - CHANNEL_NONE, NULL ); - stream_open( instream ); - - for ( ; ; ) { - UInt8 buf[128]; - nBytesReceived = ExgReceive( socket, buf, sizeof(buf), &err ); - if ( nBytesReceived == 0 || err != 0 ) { - break; - } - - stream_putBytes( instream, buf, nBytesReceived ); - } - (void)ExgDisconnect( socket, err ); - - if ( nBytesReceived == 0 ) { /* successful loop exit */ - checkAndDeliver( globals, NULL, instream, COMMS_CONN_IR ); - } - } -} /* palm_ir_receiveMove */ - -#endif /* XWFEATURE_IR */ diff --git a/xwords4/palm/palmir.h b/xwords4/palm/palmir.h deleted file mode 100644 index 2a8302eab..000000000 --- a/xwords4/palm/palmir.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PALMIR_H_ -#define _PALMIR_H_ - -#include "comms.h" -#include "palmmain.h" - -/* IR strategy. We'll attempt to keep the IR link up, but won't bring it up - * in the first place, or fix it once it goes down, until there's something - * to send. - * - * So when there's a packet to send, if the link is up - * (state==IR_STATE_CANDODATA) we just send it. Otherwise we do what's - * needed to get to that state. What state we're actually in (in the - * difficult case where we brought the link up before but the players have - * had their machines separated and the link's died) will, I hope, be - * tracable by the messages passed to each device's callback. - * - * This isn't going to make a game between three or four devices very easy - * to manage, but perhaps that will have to wait until whatever's wrong with - * shutting down and restarting links gets fixed. - */ -enum { /* values for IR_STATE */ - IR_STATE_NONE = 0, /* nothing's up or been done */ - IR_STATE_DISCOVERY_COMPLETE = 1,/* nothing to do til there's a message to - send */ - /* Discovery */ - IR_STATE_NOTHING_TO_DO = 2, /* exists just for testing against */ - IR_STATE_NO_OTHER_FOUND = 3, /* first discovery attempt failed */ - IR_STATE_DO_DISCOVERY = 4, - IR_STATE_REDO_DISCOVERY = 5, - IR_STATE_DISCOVERY_SENT = 6, - IR_STATE_DOLAP = 7, - - /* IR Lap */ - IR_STATE_LAP_SENT = 8, - IR_STATE_LAP_ESTAB = 9,//was IR_STATE_DOLMP, - - /* LMP */ -/* IR_STATE_CONNECTREQ_SENT, */ - IR_STATE_LMPREQ_SENT = 10, /* was IR_STATE_CONNECTREQ_SENT */ - IR_STATE_LMP_ESTAB = 11, //was IR_STATE_SEND_READY, - - /* Send */ - IR_STATE_SEND_DONE = 12, - IR_STATE_CAN_DISCONNECT = 13, - - /* receive (doesn't require even discovery) */ - IR_STATE_CONN_RECD = 14, /* triggered by LEVENT_LAP_CON_IND */ - IR_STATE_LAP_RCV = 15, //was IR_STATE_DOLMP_RCV, - IR_STATE_LMPRCV_REQ_SENT = 16, - IR_STATE_CONN_INCOMMING = 17, /* triggered by LEVENT_LM_CON_IND */ - IR_STATE_MESSAGE_RECD = 18 -}; - -#define ir_work_exists(g) \ - ((g)->ir_state > IR_STATE_NOTHING_TO_DO || (getSendQueueHead(g)!=NULL)) - -MyIrPacket* getSendQueueHead( PalmAppGlobals* globals ); - -void ir_callback_out( IrConnect* con, IrCallBackParms* parms ); - -Boolean ir_do_work( PalmAppGlobals* globals ); -void ir_show_status( PalmAppGlobals* globals ); -void ir_cleanup( PalmAppGlobals* globals ); - -void receiveMove( ExgSocketPtr cmdPBP ); -XP_Bool loadReceivedMove( PalmAppGlobals* globals, MemHandle moveData ); - -void palm_ir_receiveMove( PalmAppGlobals* globals, ExgSocketPtr socket ); - -XP_S16 palm_ir_send( const XP_U8* buf, XP_U16 len, PalmAppGlobals* globals ); - -#ifdef XWFEATURE_STANDALONE_ONLY -# define palm_ir_send (TransportSend)NULL -#endif - -#endif diff --git a/xwords4/palm/palmmain.c b/xwords4/palm/palmmain.c deleted file mode 100644 index 39420185c..000000000 --- a/xwords4/palm/palmmain.c +++ /dev/null @@ -1,4109 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=ARM_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 1999 - 2009 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef FEATURE_SILK -# include -#endif -#ifdef XWFEATURE_BLUETOOTH -# include -#endif -#include "comtypes.h" -#include "comms.h" - -#include "xwords4defines.h" -#include "palmmain.h" -#include "newgame.h" -#include "palmdbg.h" -#include "dbgutil.h" -#include "dictui.h" -#include "dictlist.h" -#include "palmutil.h" -#include "palmdict.h" -#include "palmsavg.h" -#include "memstream.h" -#include "strutils.h" -#include "palmir.h" -#include "palmip.h" -#include "palmbt.h" -#include "xwcolors.h" -#include "prefsdlg.h" -#include "connsdlg.h" -#include "gameutil.h" -#include "dictui.h" -#include "palmblnk.h" -#include "LocalizedStrIncludes.h" - -#ifdef XWFEATURE_FIVEWAY -# include -/* # include */ -#endif - -#include "callback.h" -#include "pace_man.h" /* for crash() macro */ - -#ifdef SUPPORT_SONY_JOGDIAL -#include "SonyChars.h" -#endif - -#define PALM_TIMER_DELAY 25 - -/*-------------------------------- defines and consts-----------------------*/ -/* #define COLORCHANGE_THRESHOLD 300 */ - -/*-------------------------------- prototypes ------------------------------*/ -static XP_Bool startApplication( PalmAppGlobals** globalsP ); -static void eventLoop( PalmAppGlobals* globals ); -static void stopApplication( PalmAppGlobals* globals ); -static Boolean applicationHandleEvent( EventPtr event ); -static Boolean mainViewHandleEvent( EventPtr event ); - -static UInt16 romVersion( void ); -static Boolean handleHintRequest( PalmAppGlobals* globals ); -static XP_Bool timeForTimer( PalmAppGlobals* globals, XWTimerReason* why, - XP_U32* when ); -static XP_S16 palm_send( const XP_U8* buf, XP_U16 len, - const CommsAddrRec* addr, void* closure ); -#ifdef COMMS_HEARTBEAT -static void palm_reset( void* closure ); -#endif -static void palm_relayStatus( void* closure, CommsRelayState newState ); -static void palm_send_on_close( XWStreamCtxt* stream, void* closure ); - -/* callbacks */ -static VTableMgr* palm_util_getVTManager( XW_UtilCtxt* uc ); -static void palm_util_userError( XW_UtilCtxt* uc, UtilErrID id ); -static XP_Bool palm_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, - XWStreamCtxt* stream ); -static XWBonusType palm_util_getSquareBonus( XW_UtilCtxt* uc, - const ModelCtxt* model, - XP_U16 col, XP_U16 row ); -static XP_S16 palm_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi, - XP_U16 playerNum, const XP_UCHAR** texts, - XP_U16 nTiles ); -static XP_Bool palm_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name, - XP_UCHAR* buf, XP_U16* len ); -static void palm_util_trayHiddenChange( XW_UtilCtxt* uc, - XW_TrayVisState newState, - XP_U16 nVisibleRows ); -static void palm_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 oldOffset, - XP_U16 newOffset ); -static void palm_util_notifyGameOver( XW_UtilCtxt* uc ); -static XP_Bool palm_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, - XP_U16 row ); -static XP_Bool palm_util_engineProgressCallback( XW_UtilCtxt* uc ); -static void palm_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when, - XWTimerProc proc, void* closure ); -static void palm_util_clearTimer( XW_UtilCtxt* uc, XWTimerReason why ); -static XP_Bool palm_util_altKeyDown( XW_UtilCtxt* uc ); -static XP_U32 palm_util_getCurSeconds( XW_UtilCtxt* uc ); -static void palm_util_requestTime( XW_UtilCtxt* uc ); -static DictionaryCtxt* palm_util_makeEmptyDict( XW_UtilCtxt* uc ); - -#ifndef XWFEATURE_STANDALONE_ONLY -static XWStreamCtxt* palm_util_makeStreamFromAddr( XW_UtilCtxt* uc, - XP_PlayerAddr channelNo ); -#endif -static const XP_UCHAR* palm_util_getUserString( XW_UtilCtxt* uc, - XP_U16 stringCode ); -static XP_Bool palm_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, - XP_U16 turn, XP_Bool turnLost ); -static void palm_util_remSelected(XW_UtilCtxt* uc); - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY -static void palm_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr, - const CommsAddrRec* newAddr ); -#endif -#ifdef XWFEATURE_BLUETOOTH -static void btEvtHandler( PalmAppGlobals* globals, BtCbEvtInfo* evt ); -#endif - -#ifdef XWFEATURE_SEARCHLIMIT -static XP_Bool palm_util_getTraySearchLimits( XW_UtilCtxt* uc, XP_U16* min, - XP_U16* max ); -#endif -static void userErrorFromStrId( PalmAppGlobals* globals, XP_U16 strID ); -static XP_Bool askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream, - XP_S16 titleID, Boolean closeAndDestroy ); -static void displayFinalScores( PalmAppGlobals* globals ); -static void updateScrollbar( PalmAppGlobals* globals, Int16 newValue ); -static void askStartNewGame( PalmAppGlobals* globals ); -static void palmSetCtrlsForTray( PalmAppGlobals* globals ); -static void drawFormButtons( PalmAppGlobals* globals ); -static MemHandle findXWPrefsRsrc( PalmAppGlobals* globals, UInt32 resType, - UInt16 resID ); -#ifdef SHOW_PROGRESS -static void palm_util_engineStarting( XW_UtilCtxt* uc, XP_U16 nBlanks ); -static void palm_util_engineStopping( XW_UtilCtxt* uc ); -#endif - -static void initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame ); -#ifdef XWFEATURE_FIVEWAY -static XP_Bool isBoardObject( XP_U16 id ); -#endif - -/*-------------------------------- Globals ---------------------------------*/ -/* NONE!!! */ - -/***************************************************************************** - * - ****************************************************************************/ -#define XW_MOVE_EXG_TYPE "XwMv" -UInt32 -PM2(PilotMain)( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) -{ - PalmAppGlobals* globals; - if ( cmd == sysAppLaunchCmdNormalLaunch ) { - if ( (launchFlags & sysAppLaunchFlagNewGlobals) != 0) { -#ifdef XW_TARGET_PNO - /* SVN_REV isn't a string in ARM. Fix that */ - XP_LOGF( "%s: arch=ARM", __func__ ); -#else - XP_LOGF( "%s: arch=68K, rev=%s", __func__, SVN_REV ); -#endif -#ifdef MEM_DEBUG - { - char date[MAX_GAMENAME_LENGTH]; - makeDefaultGameName( date ); - XP_LOGF( "date: %s", date ); - } -#endif - if ( startApplication( &globals ) ) { - XP_ASSERT( (launchFlags & sysAppLaunchFlagNewGlobals) != 0 ); - // Initialize the application's global variables and database. - eventLoop( globals ); - } - } - stopApplication( globals ); - -#ifdef XWFEATURE_IR - } else if ( cmd == sysAppLaunchCmdExgAskUser ) { - if ( (launchFlags & sysAppLaunchFlagSubCall) != 0 ) { - ((ExgAskParamPtr)cmdPBP)->result = exgAskOk; - } - } else if ( cmd == sysAppLaunchCmdSyncNotify ) { - if ( romVersion() >= 30 ) { - ExgRegisterData( APPID, exgRegTypeID, XW_MOVE_EXG_TYPE ); - } - } else if ( cmd == sysAppLaunchCmdExgReceiveData ) { - if ( (launchFlags & sysAppLaunchFlagSubCall) != 0 ) { - globals = getFormRefcon(); - palm_ir_receiveMove( globals, (ExgSocketPtr)cmdPBP ); - } -#endif - } - return 0; -} /* PilotMain */ - -/***************************************************************************** - * - ****************************************************************************/ -static UInt16 -romVersion( void ) -{ - UInt32 dwOSVer; - UInt16 result; - Err err; - - err = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &dwOSVer ); - XP_ASSERT( errNone == err ); - /* should turn 3 and 5 into 35 */ - result = (sysGetROMVerMajor(dwOSVer)*10) + sysGetROMVerMinor(dwOSVer); - - return result; -} /* romVersion */ - -#ifdef COLOR_SUPPORT -/***************************************************************************** - * - ****************************************************************************/ -static UInt32 -cur_screen_depth( void ) -{ - UInt32 curDepth; - - XP_ASSERT( romVersion() >= 30 ); /* */ - - WinScreenMode( winScreenModeGet, 0, 0, &curDepth, 0 ); - return curDepth; -} /* cur_screen_depth */ -#endif - -static void -getSizes( PalmAppGlobals* globals ) -{ - XP_U16 width, height; - width = 160; - height = 160; - - if ( globals->hasHiRes ) { - XP_U32 tmp; - - if ( WinScreenGetAttribute( winScreenWidth, &tmp ) == errNone ) { - width = tmp; - } - if ( WinScreenGetAttribute( winScreenHeight, &tmp ) == errNone ) { - height = tmp; - } - } - - if ( width == 320 ) { - FormPtr form = FrmGetActiveForm(); - WinGetDisplayExtent( &width, &height ); - - if ( !!form ) { - RectangleType r; - r.topLeft.x = 0; - r.topLeft.y = 0; - r.extent.x = width; - r.extent.y = height; - - WinSetBounds( FrmGetWindowHandle(FrmGetActiveForm()), &r ); - } - - width *= 2; - height *= 2; - globals->useHiRes = width >= 320 && height >= 320; - } - - globals->width = width; - globals->height = height; -} /* getSizes */ - -/* The resources place the tray-related buttons for the high-res case. If - * the device is going to want them in the higher low-res position, move them - * here. And resize 'em too. - */ -static void -locateTrayButtons( PalmAppGlobals* globals ) -{ - if ( !globals->useHiRes ) { - /* we need to put the buttons into the old position and set their - sizes for the larger tray. */ - XP_U16 buttonInfoTriplets[] = { XW_MAIN_HIDE_BUTTON_ID, - TRAY_BUTTONS_Y_LR, - - XW_MAIN_JUGGLE_BUTTON_ID, - TRAY_BUTTONS_Y_LR, - - XW_MAIN_TRADE_BUTTON_ID, - TRAY_BUTTONS_Y_LR - + TRAY_BUTTON_HEIGHT_LR, - - XW_MAIN_DONE_BUTTON_ID, - TRAY_BUTTONS_Y_LR - + TRAY_BUTTON_HEIGHT_LR - }; - XP_U16* ptr; - XP_U16 i; - - for ( i = 0, ptr = buttonInfoTriplets; i < 4; ++i, ptr += 2 ) { - RectangleType rect; - getObjectBounds( ptr[0], &rect ); - rect.topLeft.y = ptr[1]; - rect.extent.y = TRAY_BUTTON_HEIGHT_LR; - setObjectBounds( ptr[0], &rect ); - } - } -} /* locateTrayButtons */ - -static XP_Bool -positionBoard( PalmAppGlobals* globals ) -{ - XP_U16 bWidth = globals->width; - XP_Bool erase = XP_FALSE; - XP_Bool isLefty = globals->isLefty; - XP_U16 nCols, leftEdge; - XP_U16 scale = PALM_BOARD_SCALE; - XP_U16 scaleH, scaleV; - XP_U16 boardHeight, trayTop, trayScaleV; - XP_U16 boardTop, scoreTop, scoreLeft, scoreWidth, scoreHeight; - XP_U16 timerWidth, timerLeft; - XP_U16 freeSpaceH; - XP_Bool showGrid = globals->gState.showGrid; - XP_U16 doubler = globals->useHiRes? 2 : 1; -#ifdef SHOW_PROGRESS - RectangleType bounds; -#endif - - XP_ASSERT( !!globals->game.model ); - nCols = model_numCols( globals->game.model ); - XP_ASSERT( nCols <= PALM_MAX_ROWS ); - - /* With the screen having variable width and height, we do away with - * constants and calculate everything on the fly. Horizontally, the - * screen consists of the board and scrollbar/buttons. Vertically, it's - * the scoreboard, the board, and the tray. If the board is square the - * tray must overlap the board -- but not if the smallest font we can fit - * in a cell allows the squares to squeeze down! - * - * Be careful with squeezing cells! Custom chars won't allow it. So - * cell size needs to stay constant... For now we only avoid overlap - * cute when the screen is taller than it is wide. - */ - - /* since we only want the lines between cells one pixel wide, we can - increase scale more than 2x when doubling. */ - if ( !showGrid ) { - --scale; - } - scale = scale * doubler; - scaleV = scaleH = scale; - if ( globals->useHiRes ) { - scaleV -= 2; - } - - freeSpaceH = ((PALM_MAX_COLS-nCols)/2) * scaleH; - if ( isLefty ) { - leftEdge = bWidth - (nCols * scaleH) - freeSpaceH - 1; - } else { - leftEdge = PALM_BOARD_LEFT_RH + freeSpaceH; - } - - /* position the timer. There are really four cases: width depends on - whether the grid's visible, and left edge depends on isLefty _and_ - width in the non-lefty case. */ - - if ( showGrid ) { - timerWidth = FntCharsWidth( "-00:00", 6 ); /* the ideal */ - } else { - timerWidth = PALM_GRIDLESS_SCORE_WIDTH; - } - timerWidth *= doubler; - - if ( isLefty && !showGrid ) { - timerLeft = 0; - } else { - timerLeft = bWidth - timerWidth; - } - board_setTimerLoc( globals->game.board, timerLeft, PALM_TIMER_TOP, - timerWidth, PALM_TIMER_HEIGHT * doubler ); - - if ( showGrid ) { - boardTop = PALM_BOARD_TOP; - scoreLeft = PALM_SCORE_LEFT; - scoreTop = PALM_SCORE_TOP; - scoreWidth = (bWidth/doubler) - PALM_SCORE_LEFT - (timerWidth/doubler); - scoreHeight = PALM_SCORE_HEIGHT; - } else { - boardTop = PALM_GRIDLESS_BOARD_TOP; - scoreLeft = isLefty? 0: PALM_GRIDLESS_SCORE_LEFT; - scoreTop = PALM_GRIDLESS_SCORE_TOP; - scoreWidth = PALM_GRIDLESS_SCORE_WIDTH; - scoreHeight = PALM_TRAY_TOP - PALM_GRIDLESS_SCORE_TOP - 2; - - if ( !isLefty ) { - leftEdge += doubler; /* for the frame */ - } - } - - boardTop *= doubler; - scoreLeft *= doubler; - scoreTop *= doubler; - scoreWidth *= doubler; - scoreHeight *= doubler; - - board_setPos( globals->game.board, leftEdge, - boardTop, isLefty ); - board_setScale( globals->game.board, scaleH, scaleV ); - - board_setScoreboardLoc( globals->game.board, scoreLeft, scoreTop, - scoreWidth, scoreHeight, showGrid ); - - board_setYOffset( globals->game.board, 0 ); - - /* figure location for the tray. If possible, make it smaller than the - ideal to avoid using a scrollbar. Also, note at this point whether a - scrollbar will be required. */ - globals->needsScrollbar = false; /* default */ - boardHeight = scaleV * nCols; - - if ( globals->useHiRes ) { - trayTop = ((160 - TRAY_HEIGHT_HR) * doubler) - 1; - globals->needsScrollbar = false; - } else { - trayTop = 160 - TRAY_HEIGHT_LR; - globals->needsScrollbar = showGrid && (nCols == PALM_MAX_COLS); - } - - trayScaleV = - globals->useHiRes? (TRAY_HEIGHT_HR*doubler) + 1: - TRAY_HEIGHT_LR; - board_setTrayLoc( globals->game.board, - (isLefty? PALM_TRAY_LEFT_LH:PALM_TRAY_LEFT_RH) * doubler, - trayTop, - PALM_TRAY_WIDTH * doubler, trayScaleV, - PALM_DIVIDER_WIDTH ); - - board_prefsChanged( globals->game.board, &globals->gState.cp ); - -#ifdef SHOW_PROGRESS - if ( showGrid ) { - getObjectBounds( XW_MAIN_SCROLLBAR_ID, &bounds ); - - bounds.topLeft.x += doubler; - bounds.extent.x -= (doubler << 1); - } else { - bounds.topLeft.y = (PALM_TIMER_HEIGHT + 2) * doubler; - bounds.topLeft.x = (globals->isLefty? FLIP_BUTTON_WIDTH+3: - PALM_GRIDLESS_SCORE_LEFT+2) * doubler; - - bounds.extent.x = (RECOMMENDED_SBAR_WIDTH + 2) * doubler; - bounds.extent.y = (PALM_GRIDLESS_SCORE_TOP - bounds.topLeft.y - 2) - * doubler; - } - globals->progress.boundsRect = bounds; -#endif - - updateScrollbar( globals, globals->scrollValue ); /* changing visibility? */ - palmSetCtrlsForTray( globals ); - drawFormButtons( globals ); - - return erase; -} /* positionBoard */ - -static XWStreamCtxt* -makeSimpleStream( PalmAppGlobals* globals, MemStreamCloseCallback cb ) -{ - return mem_stream_make( MPPARM(globals->mpool) - globals->vtMgr, - globals, - CHANNEL_NONE, cb ); -} /* makeSimpleStream */ - -static XWStreamCtxt* -gameRecordToStream( PalmAppGlobals* globals, XP_U16 index ) -{ - XWStreamCtxt* recStream = NULL; - LocalID id; - MemHandle handle; - Err err; - - id = DMFINDDATABASE( globals, CARD_0, XW_GAMES_DBNAME ); - if ( id != 0 ) { - UInt16 numRecs; - DmOpenRef dbP; - - dbP = DMOPENDATABASE( globals, CARD_0, id, dmModeReadOnly ); - numRecs = DmNumRecords( dbP ); - - if ( index < numRecs ) { - handle = DmGetRecord( dbP, index ); - - recStream = makeSimpleStream( globals, NULL ); - stream_open( recStream ); - stream_putBytes( recStream, MemHandleLock(handle), - MemHandleSize(handle) ); - MemHandleUnlock(handle); - err = DmReleaseRecord( dbP, index, false ); - XP_ASSERT( err == 0 ); - } - DMCLOSEDATABASE( dbP ); - } - return recStream; -} /* gameRecordToStream */ - -static void -loadGamePrefs( /*PalmAppGlobals* globals, */XWStreamCtxt* stream ) -{ - /* Keep in sync with games saved in prev version, which foolishly saved - hintsNotAllowed separate from the current game's value for the same - thing. When the version changes get rid of this bit. PENDING */ - (void)stream_getBits( stream, 1 ); -} /* loadGamePrefs */ - -static void -saveGamePrefs( /*PalmAppGlobals* globals, */XWStreamCtxt* stream ) -{ - stream_putBits( stream, 1, 0 ); -} /* saveGamePrefs */ - -static void -keySafeCustomAlert( PalmAppGlobals* globals, const XP_UCHAR* buf ) -{ - /* Another gross hack to get around the OS sending a spurious keyDown - event when a dialog is invoked while still processing a keyUp event. - We just pull all events off the queue until the keyDown is found. In - practice that's always the first event, but let's leave logging on for - a while in case this causes problems. */ - while ( globals->handlingKeyEvent ) { - EventType event; - EvtGetEvent( &event, 0 ); - XP_LOGF( "%s: consumed %s", __func__, eType_2str(event.eType) ); - if ( event.eType == keyDownEvent || event.eType == nilEvent ) { - break; - } - } - (void)FrmCustomAlert( XW_ERROR_ALERT_ID, (const char*)buf, " ", " " ); -} - -static void -reportMissingDict( PalmAppGlobals* globals, XP_UCHAR* name ) -{ - /* FrmCustomAlert crashes on some OS versions when there's no form under - it to "return" to. */ - if ( FrmGetActiveForm() != NULL ) { - XP_UCHAR buf[48]; - const XP_UCHAR* str = getResString( globals, STRS_CANNOT_FIND_DICT ); - StrPrintF( buf, str, name ); - keySafeCustomAlert( globals, buf ); - } -} /* reportMissingDict */ - -static void -palmInitTProcs( PalmAppGlobals* globals, TransportProcs* procs ) -{ - XP_MEMSET( procs, 0, sizeof(*procs) ); - procs->send = palm_send; -#ifdef COMMS_HEARTBEAT - procs->reset = palm_reset; -#endif -#ifdef XWFEATURE_RELAY - procs->rstatus = palm_relayStatus; -#endif - - procs->closure = globals; -} - -static XP_Bool -loadCurrentGame( PalmAppGlobals* globals, XP_U16 gIndex, - XWGame* game, CurGameInfo* ginfo ) -{ - XP_Bool hasDict; - XWStreamCtxt* recStream; - XP_Bool success = XP_FALSE; - DictionaryCtxt* dict; - - recStream = gameRecordToStream( globals, gIndex ); - - /* now read everything out of the stream */ - if ( !!recStream ) { - char ignore[MAX_GAMENAME_LENGTH]; - - /* skip the name */ - stream_getBytes( recStream, ignore, MAX_GAMENAME_LENGTH ); - - loadGamePrefs( /*globals, */recStream ); - - hasDict = stream_getU8( recStream ); - if ( hasDict ) { - XP_UCHAR name[33]; - stringFromStreamHere( recStream, name, sizeof(name) ); - dict = palm_dictionary_make( MPPARM(globals->mpool) globals, - name, globals->dictList ); - success = dict != NULL; - - if ( !success ) { - reportMissingDict( globals, name ); - beep(); - } - } else { - dict = NULL; - success = XP_TRUE; - } - - if ( success ) { - TransportProcs procs; - palmInitTProcs( globals, &procs ); - success = game_makeFromStream( MEMPOOL recStream, game, ginfo, - dict, &globals->util, - globals->draw, &globals->gState.cp, - &procs ); - } - - stream_destroy( recStream ); - } - - return success; -} /* loadCurrentGame */ - -static void -initUtilFuncs( PalmAppGlobals* globals ) -{ - UtilVtable* vtable = globals->util.vtable = - XP_MALLOC( globals->mpool, sizeof( UtilVtable ) ); - globals->util.closure = (void*)globals; - globals->util.gameInfo = &globals->gameInfo; - - MPASSIGN( globals->util.mpool, globals->mpool ); - - vtable->m_util_getVTManager = palm_util_getVTManager; - vtable->m_util_userError = palm_util_userError; - vtable->m_util_getSquareBonus = palm_util_getSquareBonus; - vtable->m_util_userQuery = palm_util_userQuery; - vtable->m_util_userPickTile = palm_util_userPickTile; - vtable->m_util_askPassword = palm_util_askPassword; - vtable->m_util_trayHiddenChange = palm_util_trayHiddenChange; - vtable->m_util_yOffsetChange = palm_util_yOffsetChange; - vtable->m_util_notifyGameOver = palm_util_notifyGameOver; - vtable->m_util_hiliteCell = palm_util_hiliteCell; - vtable->m_util_engineProgressCallback = palm_util_engineProgressCallback; - vtable->m_util_setTimer = palm_util_setTimer; - vtable->m_util_clearTimer = palm_util_clearTimer; - vtable->m_util_requestTime = palm_util_requestTime; - vtable->m_util_altKeyDown = palm_util_altKeyDown; - vtable->m_util_getCurSeconds = palm_util_getCurSeconds; - vtable->m_util_makeEmptyDict = palm_util_makeEmptyDict; -#ifndef XWFEATURE_STANDALONE_ONLY - vtable->m_util_makeStreamFromAddr = palm_util_makeStreamFromAddr; -#endif - vtable->m_util_getUserString = palm_util_getUserString; - vtable->m_util_warnIllegalWord = palm_util_warnIllegalWord; - vtable->m_util_remSelected = palm_util_remSelected; -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - vtable->m_util_addrChange = palm_util_addrChange; -#endif -#ifdef XWFEATURE_SEARCHLIMIT - vtable->m_util_getTraySearchLimits = palm_util_getTraySearchLimits; -#endif -#ifdef SHOW_PROGRESS - vtable->m_util_engineStarting = palm_util_engineStarting; - vtable->m_util_engineStopping = palm_util_engineStopping; -#endif -} /* initUtilFuncs */ - -#ifdef COLOR_SUPPORT -static void -loadColorsFromRsrc( DrawingPrefs* prefs, MemHandle colorH ) -{ - RGBColorType color; - UInt8* colorP; - short index = 0; - UInt32 count; - - count = MemHandleSize( colorH ); - XP_ASSERT( count < 0xFFFF ); - XP_ASSERT( (((XP_U16)count) % 3) == 0 ); - colorP = MemHandleLock( colorH ); - - do { - color.r = *colorP++; - color.g = *colorP++; - color.b = *colorP++; - prefs->drawColors[index++] = WinRGBToIndex( &color ); - } while ( (count -= 3) != 0 ); - -#ifdef XWFEATURE_FIVEWAY - prefs->drawColors[COLOR_CURSOR] - = UIColorGetTableEntryIndex( UIObjectSelectedFill ); -#endif - MemHandleUnlock( colorH ); -} /* loadColorsFromRsrc */ -#endif - -static void -palmInitPrefs( PalmAppGlobals* globals ) -{ - globals->gState.showGrid = true; - globals->gState.versionNum = CUR_PREFS_VERS; - globals->gState.cp.showBoardArrow = XP_TRUE; - globals->gState.cp.showRobotScores = XP_TRUE; - -#ifdef SHOW_PROGRESS - globals->gState.showProgress = true; -#endif - -} /* palmInitPrefs */ - -static void -openXWPrefsDB( PalmAppGlobals* globals ) -{ - Err err; - - err = DmCreateDatabase( CARD_0, XW_PREFS_DBNAME, - APPID, XWORDS_PREFS_TYPE, true ); - XP_ASSERT( err == errNone || err == dmErrAlreadyExists ); - globals->boardDBID = DmFindDatabase( CARD_0, XW_PREFS_DBNAME ); - globals->boardDBP = DmOpenDatabase( CARD_0, globals->boardDBID, - dmModeWrite ); -} /* openXWPrefsDB */ - -static XP_Bool -setupBonusPtrs( PalmAppGlobals* globals ) -{ - XP_U16 i; - for ( i = 0; i < NUM_BOARD_SIZES; ++i ) { - MemHandle hand = findXWPrefsRsrc( globals, BOARD_RES_TYPE, - BOARD_RES_ID + i ); - if ( !hand ) { - return XP_FALSE; - } - - XP_ASSERT( MemHandleLockCount(hand) == 0 ); - globals->bonusResPtr[i] = MemHandleLock( hand ); - } - return XP_TRUE; -} /* setupBonusPtrs */ - -static void -unlockBonusPtrs( PalmAppGlobals* globals ) -{ - XP_U16 i; - for ( i = 0; i < NUM_BOARD_SIZES; ++i ) { - MemPtrUnlock( (MemPtr)globals->bonusResPtr[i] ); - } -} /* unlockBonusPtrs */ - -static void -openGamesDB( PalmAppGlobals* globals ) -{ - Err err; - - err = DmCreateDatabase( CARD_0, XW_GAMES_DBNAME, - APPID, XWORDS_GAMES_TYPE, false ); - globals->gamesDBID = DmFindDatabase( CARD_0, XW_GAMES_DBNAME ); - globals->gamesDBP = DmOpenDatabase( CARD_0, globals->gamesDBID, - dmModeReadWrite ); - XP_ASSERT( !!globals->gamesDBP ); -} /* openGamesDB */ - -static MemHandle -findXWPrefsRsrc( PalmAppGlobals* globals, UInt32 resType, UInt16 resID ) -{ - Int16 index; - MemHandle handle = NULL; - Boolean beenThere = XP_FALSE; - - for ( ; ; ) { - XP_ASSERT( !!globals->boardDBP ); - index = DmFindResource( globals->boardDBP, resType, resID, NULL ); - - if ( index == -1 ) { /* not found */ - MemHandle builtinH; - MemHandle newH; - UInt32 size; - - if ( !beenThere ) { - builtinH = DmGetResource( resType, resID ); - XP_ASSERT( !!builtinH ); - size = MemHandleSize( builtinH ); - newH = DmNewResource( globals->boardDBP, resType, - resID, size ); - XP_ASSERT( !!newH ); - DmWrite( MemHandleLock( newH ), 0, MemHandleLock(builtinH), - size ); - MemHandleUnlock( newH ); - MemHandleUnlock( builtinH ); - DmReleaseResource( newH ); - DmReleaseResource( builtinH ); - - beenThere = XP_TRUE; - continue; - } - break; - } - - handle = DmGetResourceIndex( globals->boardDBP, index ); - break; - } - - return handle; -} /* findXWPrefsRsrc */ - -static XP_Bool -initResources( PalmAppGlobals* globals ) -{ - /* strings */ - MemHandle hand; - - XP_ASSERT( !globals->stringsResPtr ); - - hand = DmGetResource( STRL_RES_TYPE, STRL_RES_ID ); - XP_ASSERT( !!hand ); - XP_ASSERT( MemHandleLockCount(hand) == 0 ); - globals->stringsResPtr = (XP_UCHAR*)MemHandleLock( hand ); - - /* bonus square and color values. These live in a separate database, - which we create if it doesn't already exist. */ - openXWPrefsDB( globals ); - if ( !setupBonusPtrs( globals ) ) { - return XP_FALSE; - } - - openGamesDB( globals ); - - if ( globals->able == COLOR ) { - hand = findXWPrefsRsrc( globals, COLORS_RES_TYPE, COLORS_RES_ID ); - if ( !hand ) { - return XP_FALSE; - } - loadColorsFromRsrc( &globals->drawingPrefs, hand ); - DmReleaseResource( hand ); - } - - return XP_TRUE; -} /* initResources */ - -static void -freeAndUnlockPtr( MemPtr ptr ) -{ - MemHandle hand; - XP_ASSERT( !!ptr ); - hand = MemPtrRecoverHandle(ptr ); - XP_ASSERT( !!hand ); - MemHandleUnlock( hand ); - DmReleaseResource( hand ); -} /* freeAndUnlockPtr */ - -static void -uninitResources( PalmAppGlobals* globals ) -{ - XP_U16 i; - - /* strings */ - freeAndUnlockPtr( globals->stringsResPtr ); - globals->stringsResPtr = NULL; - - /* bonus square values */ - for ( i = 0; i < NUM_BOARD_SIZES; ++i ) { - freeAndUnlockPtr( globals->bonusResPtr[i] ); - } - - XP_ASSERT( !!globals->boardDBP ); - DmCloseDatabase( globals->boardDBP ); - -} /* uninitResources */ - -const XP_UCHAR* -getResString( PalmAppGlobals* globals, XP_U16 strID ) -{ - XP_ASSERT( !!globals->stringsResPtr ); - XP_ASSERT( strID < MemPtrSize( globals->stringsResPtr ) ); - XP_ASSERT( (strID == 0) || (globals->stringsResPtr[strID-1] == '\0') ); - XP_ASSERT( strID < STR_LAST_STRING ); - return &globals->stringsResPtr[strID]; -} /* getResString */ - -static Err -volChangeEventProc( SysNotifyParamType* XP_UNUSED_SILK(notifyParamsP) ) -{ -#if 0 - if ( notifyParamsP->notifyType == sysNotifyVolumeUnmountedEvent ) { - - DictListHandleUnmount( globals->dictList ); - - } else if ( notifyParamsP->notifyType == sysNotifyVolumeMountedEvent ) { - - DictListHandleMount( &globals->dictList ); - - } else { - XP_ASSERT(0); - return errNone; - } -#endif - -#ifdef FEATURE_SILK - if ( notifyParamsP->notifyType == sysNotifyDisplayChangeEvent ) { - postEmptyEvent( doResizeWinEvent ); - return errNone; - } -#endif - /* for now, just blow outta here! Force the app to rebuild - datastructures when it's relaunched. This is a hack but I like - it. :-) */ -#ifndef REALLY_HANDLE_MEDIA - postEmptyEvent( appStopEvent ); -#endif - - return errNone; -} /* volChangeEventProc */ - -static void -doCallbackReg( PalmAppGlobals* globals, XP_Bool reg ) -{ - /* The mounted/unmounted events aren't there unless we're PalmOS version - 4.0 or greater. No need to use FtrGet to check for Notification Mgr - here, as it's useless without these. */ - if ( globals->romVersion >= 40 ) { - XP_U16 i; - UInt32 notifyTypes[] = { sysNotifyVolumeUnmountedEvent - , sysNotifyVolumeMountedEvent -#ifdef FEATURE_SILK - , sysNotifyDisplayChangeEvent -#endif - }; - - - for ( i = 0; i < VSIZE(notifyTypes); ++i ) { - UInt32 notifyType = notifyTypes[i]; - - if ( reg ) { - SysNotifyRegister( 0, 0, notifyType, volChangeEventProc, - sysNotifyNormalPriority, globals ); - } else { - SysNotifyUnregister( 0, 0, notifyType, - sysNotifyNormalPriority); - } - } - } -} /* doCallbackReg */ - -/* temp workarounds for some sony include file trouble */ -# ifdef FEATURE_SILK -extern Err SilkLibEnableResizeFoo(UInt16 refNum) - SILK_LIB_TRAP(sysLibTrapCustom+1); -extern Err VskSetStateFoo(UInt16 refNum, UInt16 stateType, UInt16 state) - SILK_LIB_TRAP(sysLibTrapCustom+3+3); -# endif - -static XP_Bool -isOnZodiac( void ) -{ - // from http://tamspalm.tamoggemon.com/2006/03/02/determining-if-your-app-runs-on-a-zodiac/ - const XP_U32 twCreatorID = 'Tpwv'; - Err err; - UInt32 manufacturer; - XP_Bool result; - err = FtrGet( sysFileCSystem, sysFtrNumOEMCompanyID, &manufacturer ); - result = (err == errNone) && (manufacturer == twCreatorID); - LOG_RETURNF( "%d", (int)result ); - return result; -} - -static void -initHighResGlobals( PalmAppGlobals* globals ) -{ - Err err; - XP_U32 vers; - - err = FtrGet( sysFtrCreator, sysFtrNumWinVersion, &vers ); - XP_ASSERT( err == errNone ); - globals->hasHiRes = (err == errNone) && (vers >= 4) && !globals->isZodiac; - XP_LOGF( "hasHiRes = %d", (XP_U16)globals->hasHiRes ); - globals->oneDotFiveAvail = globals->hasHiRes - && (err == errNone) && (vers >= 5); - -#ifdef XWFEATURE_FIVEWAY -# ifndef hsFtrIDNavigationSupported -# define hsFtrIDNavigationSupported 14 -# endif - /* sysFtrNumUIHardwareFlags unavailable on PalmOS 4 */ - err = FtrGet( sysFtrCreator, sysFtrNumUIHardwareFlags, &vers ); - globals->generatesKeyUp = ( (err == errNone) && - ((vers & sysFtrNumUIHardwareHasKbd) != 0) ) - || globals->isZodiac; - globals->hasTreoFiveWay = (err == errNone) - && ((vers & sysFtrNumUIHardwareHas5Way) != 0) && !globals->isZodiac; - - err = FtrGet( hsFtrCreator, hsFtrIDNavigationSupported, &vers ); - if ( errNone == err ) { - XP_ASSERT( vers == 1 || vers == 2 ); - globals->isTreo600 = (err == errNone) && (vers == 1); - } -#endif - -#ifdef FEATURE_SILK - if ( globals->hasHiRes ) { - XP_U16 ref; - - err = SysLibFind(sonySysLibNameSilk, &ref ); - if ( err == sysErrLibNotFound ) { - err = SysLibLoad( 'libr', sonySysFileCSilkLib, &ref ); - } - - if ( err == errNone ) { - XP_U32 tmp; - globals->sonyLibRef = ref; - - err = FtrGet( sonySysFtrCreator, sonySysFtrNumVskVersion, &tmp ); - if ( err == errNone ) { - globals->doVSK = XP_TRUE; - if ( VskOpen( ref ) == errNone ) { - VskSetStateFoo( ref, vskStateEnable, 1 ); - } - } else { - if ( SilkLibOpen( ref ) == errNone ) { - SilkLibEnableResizeFoo( ref ); - } - } - } - } -#endif -} /* initHighResGlobals */ - -static void -uninitHighResGlobals( PalmAppGlobals* XP_UNUSED_SILK(globals) ) -{ -#ifdef FEATURE_SILK - if ( globals->hasHiRes && globals->sonyLibRef != 0 ) { - if ( globals->doVSK ) { - VskClose( globals->sonyLibRef ); - } else { - SilkLibClose( globals->sonyLibRef ); - } - } -#endif -} /* uninitHighResGlobals */ - -static XP_Bool -canConvertPrefs( XWords4PreferenceType* prefs, UInt16 prefSize, XP_S16 vers ) -{ - XP_Bool success = XP_FALSE; - - if ( vers == VERSION_NUM_405 ) { - if ( prefSize < sizeof(XWords4PreferenceType) ) { - XP_U8* newRgn = ((XP_U8*)prefs) + prefSize; - XP_MEMSET( newRgn, 0, sizeof(XWords4PreferenceType) - prefSize ); - } - success = XP_TRUE; - } - - return success; -} /* canConvertPrefs */ - -/***************************************************************************** - * - ****************************************************************************/ -static XP_Bool -startApplication( PalmAppGlobals** globalsP ) -{ - UInt16 prefSize; - Boolean prefsFound; - XWords4PreferenceType prefs; - PalmAppGlobals* globals; - Boolean leftyFlag; - Int16 vers; - UInt32 ignore; -#if defined XWFEATURE_BLUETOOTH - Err err; -#endif - MPSLOT; - -#if defined FOR_GREMLINS - SysRandom( 1 ); -#else - SysRandom( TimGetTicks() ); /* initialize */ -#endif - -#ifdef MEM_DEBUG - mpool = mpool_make(); -#endif - - globals = (PalmAppGlobals*)XP_MALLOC( mpool, sizeof( PalmAppGlobals ) ); - *globalsP = globals; - setFormRefcon( globals ); - XP_MEMSET( globals, 0, sizeof(PalmAppGlobals) ); - MPASSIGN( globals->mpool, mpool ); - - globals->isZodiac = isOnZodiac(); - - initHighResGlobals( globals ); - getSizes( globals ); - - globals->runningOnPOSE = FtrGet( 'pose', 0, &ignore) != ftrErrNoSuchFeature; - -#if defined XWFEATURE_BLUETOOTH - err = FtrGet( btLibFeatureCreator, btLibFeatureVersion, &ignore ); - /* could expand the test to skip version 1 and the Treo650 :-) */ - globals->hasBTLib = ftrErrNoSuchFeature != err; -# ifdef MEM_DEBUG - if ( errNone == err ) { - /* Sprint Treo650 is returning 0036 */ - /* Treo 700 on VWZ: sysFileCBtLib version: 00000003 */ - /* Treo 650 on Sprint: sysFileCBtLib version: 00000001 */ - XP_LOGF( "sysFileCBtLib version: %lx", ignore ); - } else { - XP_LOGF( "no sysFileCBtLib via FtrGet: OS too old?" ); - } - /* Make the UI elements easier to test */ - if ( globals->runningOnPOSE ) { - globals->hasBTLib = XP_TRUE; - } -# endif -#endif - - globals->vtMgr = make_vtablemgr( MPPARM_NOCOMMA(globals->mpool) ); - - globals->romVersion = romVersion(); - - globals->isFirstLaunch = true; - - leftyFlag = 0; - if ( !PrefGetAppPreferencesV10('Lfty', 1, &leftyFlag, - sizeof(leftyFlag) )) { - leftyFlag = 0; - } - globals->isLefty = leftyFlag != 0; - -#ifdef COLOR_SUPPORT - if ( (globals->romVersion >= 35) && (cur_screen_depth() >= 8) ) { - globals->able = COLOR; - } else { - globals->able = ONEBIT; - } -#else - globals->able = ONEBIT; -#endif - - if ( !initResources( globals ) ) { - return XP_FALSE; - } - -#ifdef XWFEATURE_RELAY - palm_ip_setup( globals ); -#endif - - doCallbackReg( globals, XP_TRUE ); - - initUtilFuncs( globals ); - - offerConvertOldDicts( globals ); - - globals->dictList = DictListMake( MPPARM_NOCOMMA(globals->mpool) ); - if ( DictListCount( globals->dictList ) == 0 ) { - userErrorFromStrId( globals, STR_NO_DICT_INSTALLED ); - return XP_FALSE; - } - - prefSize = sizeof( prefs ); - vers = PrefGetAppPreferences( AppType, PrefID, &prefs, &prefSize, true); - if ( vers == VERSION_NUM ) { - prefsFound = XP_TRUE; - } else if ( vers != noPreferenceFound ) { - prefsFound = canConvertPrefs( &prefs, prefSize, vers ); - } else { - prefsFound = XP_FALSE; - } - - if ( prefsFound ) { - prefs.versionNum = XP_NTOHS( prefs.versionNum ); - prefs.curGameIndex = XP_NTOHS( prefs.curGameIndex ); - prefs.focusItem = XP_NTOHS( prefs.focusItem ); - - MemMove( &globals->gState, &prefs, sizeof(prefs) ); - } - - globals->draw = palm_drawctxt_make( MPPARM(globals->mpool) - globals->able, - globals, - getResString, - &globals->drawingPrefs ); - - FrmGotoForm( XW_MAIN_FORM ); - - /* do this first so players who don't exist have default names */ - gi_initPlayerInfo( MEMPOOL &globals->gameInfo, - getResString( globals, STR_DEFAULT_NAME ) ); - - if ( prefsFound && loadCurrentGame( globals, globals->gState.curGameIndex, - &globals->game, &globals->gameInfo) ) { - postEmptyEvent( loadGameEvent ); - globals->isFirstLaunch = false; - } else { - TransportProcs procs; - DictListEntry* dlep; - - /* if we're here because dict missing, don't re-init all prefs! */ - if ( !prefsFound ) { - palmInitPrefs( globals ); - } else { - /* increment count so we get a new game rather than replace - existing one. We want it still there if somebody puts the - missing dict back. */ - globals->gState.curGameIndex = countGameRecords( globals ); - } - globals->isNewGame = true; - - getNthDict( globals->dictList, 0, &dlep ); - globals->gameInfo.dictName = copyString( globals->mpool, - dlep->baseName ); - - palmInitTProcs( globals, &procs ); - game_makeNewGame( MEMPOOL &globals->game, &globals->gameInfo, - &globals->util, globals->draw, - &globals->gState.cp, &procs ); - - FrmPopupForm( XW_NEWGAMES_FORM ); - } - - return XP_TRUE; -} /* startApplication */ - -/* save the stream's contents to a database. */ -static void -writeToDb( XWStreamCtxt* stream, void* closure ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - Err err; - - err = DmCreateDatabase( CARD_0, XW_GAMES_DBNAME, - APPID, XWORDS_GAMES_TYPE, false ); - - streamToGameRecord( globals, stream, globals->gState.curGameIndex ); -} /* writeToDb */ - -static void -saveOpenGame( PalmAppGlobals* globals ) -{ - if ( !!globals->game.server ) { - XWStreamCtxt* memStream; - DictionaryCtxt* dict; - const XP_UCHAR* dictName; - char namebuf[MAX_GAMENAME_LENGTH]; - - if ( gi_countLocalHumans( &globals->gameInfo ) > 1 ) { - board_hideTray( globals->game.board ); /* so won't be visible when - next opened */ - } - memStream = makeSimpleStream( globals, writeToDb ); - stream_open( memStream ); - - /* write the things's name. Name is first because we want to be able - to manipulate it without knowing about the other stuff. */ - nameFromRecord( globals, globals->gState.curGameIndex, namebuf ); - stream_putBytes( memStream, namebuf, MAX_GAMENAME_LENGTH ); - - saveGamePrefs( /*globals, */memStream ); - - /* the dictionary */ - dict = model_getDictionary( globals->game.model ); - dictName = !!dict? dict_getName( dict ) : NULL; - stream_putU8( memStream, !!dictName ); - if ( !!dictName ) { - stringToStream( memStream, dictName ); - } - - game_saveToStream( &globals->game, &globals->gameInfo, memStream ); - - stream_destroy( memStream ); - } -} /* saveOpenGame */ - -/***************************************************************************** - * - ****************************************************************************/ -static void -stopApplication( PalmAppGlobals* globals ) -{ - if ( globals != NULL ) { -#ifdef XWFEATURE_FIVEWAY - Int16 focusItem = getFocusOwner(); -#endif - MPSLOT; - - saveOpenGame( globals ); - - FrmCloseAllForms(); - - uninitResources( globals ); - -#ifdef XWFEATURE_BLUETOOTH - palm_bt_close( globals ); -#endif - - /* Write the state information -- once we're ready to read it in. - But skip the save if user cancelled launching the first time. */ - if ( !globals->isFirstLaunch ) { - XWords4PreferenceType prefs; - /* temporarily don't save prefs since we crash on opening - them. */ - XP_MEMCPY( &prefs, &globals->gState, sizeof(prefs) ); - prefs.versionNum = XP_HTONS( prefs.versionNum ); - prefs.curGameIndex = XP_HTONS( prefs.curGameIndex ); - -#ifdef XWFEATURE_FIVEWAY - prefs.focusItem = XP_HTONS(focusItem); -#endif - - PrefSetAppPreferences( AppType, PrefID, VERSION_NUM, - &prefs, sizeof(prefs), true ); - } - - if ( !!globals->draw ) { - draw_destroyCtxt( globals->draw ); - } - - game_dispose( &globals->game ); - gi_disposePlayerInfo( MEMPOOL &globals->gameInfo ); - -#ifdef XWFEATURE_RELAY - palm_ip_close( globals ); -#endif - - if ( !!globals->dictList ) { - DictListFree( MPPARM(globals->mpool) globals->dictList ); - } - - if ( !!globals->util.vtable ) { - XP_FREE( globals->mpool, globals->util.vtable ); - } - - if ( !!globals->prefsDlgState ) { - XP_FREE( globals->mpool, globals->prefsDlgState ); - } - - if ( !!globals->savedGamesState && !globals->isFirstLaunch ) { - freeSavedGamesData( MPPARM(globals->mpool) - globals->savedGamesState ); - XP_FREE( globals->mpool, globals->savedGamesState ); - } - - uninitHighResGlobals( globals ); - - XP_ASSERT( !!globals->gamesDBP ); - DmCloseDatabase( globals->gamesDBP ); - - if ( !!globals->vtMgr ) { - vtmgr_destroy( MPPARM(globals->mpool) globals->vtMgr ); - } - - doCallbackReg( globals, XP_FALSE ); - - MPASSIGN( mpool, globals->mpool ); - XP_FREE( globals->mpool, globals ); - mpool_destroy( mpool ); - } -} /* stopApplication */ - -static Int32 -figureWaitTicks( PalmAppGlobals* globals ) -{ - Int32 result = evtWaitForever; - XP_U32 when; - XWTimerReason why; - - if ( 0 ) { -#ifdef XWFEATURE_RELAY - } else if ( ipSocketIsOpen(globals) ) { -/* we'll do our sleeping in NetLibSelect */ - result = 0; -#endif - } else if ( globals->timeRequested || globals->hintPending ) { - result = 0; - } else if ( timeForTimer( globals, &why, &when ) ) { - result = when - TimGetTicks(); - if ( result < 0 ) { - result = 0; - } - } else { - /* leave it */ - } - /* XP_DEBUGF( "figureWaitTicks returning %d", result ); */ - -# ifdef XWFEATURE_BLUETOOTH - if ( !!globals->mainForm ) { - palm_bt_amendWaitTicks( globals, &result ); - } -# endif - - return result; -} /* figureWaitTicks */ - -static XP_Bool -closeNonMainForms( PalmAppGlobals* globals ) -{ -#if 1 - return FrmGetActiveForm() == globals->mainForm; -#else - /* This doesn't work. If there's a form in front of the main form - sending it the close event closes it, but then FrmGetActiveForm() - returns null the next time called.*/ - FormPtr prevActive; - FormPtr curActive = NULL; - - for ( ; ; ) { - EventType event; - - prevActive = curActive; - curActive = FrmGetActiveForm(); - if ( prevActive == curActive ) { - return XP_FALSE; - } - - if ( curActive == globals->mainForm ) { - return XP_TRUE; - } - event.eType = frmCloseEvent; - event.data.frmClose.formID = FrmGetFormId(curActive); - FrmDispatchEvent( &event ); - } -#endif -} /* closeNonMainForms */ - -/***************************************************************************** - * - ****************************************************************************/ -static void -eventLoop( PalmAppGlobals* globals ) -{ - EventType event; - - do { -#ifdef XWFEATURE_RELAY - if ( !!globals->game.comms - && (comms_getConType(globals->game.comms) == COMMS_CONN_RELAY) ) { - checkHandleNetEvents( globals ); - } -#endif - - /* EvtGetEvent( &event, evtWaitForever ); */ - EvtGetEvent( &event, figureWaitTicks(globals) ); - - if ( event.eType == keyDownEvent ) { - if ( 0 ) { -#ifdef FOR_GREMLINS - } else if ( event.data.keyDown.chr == findChr ) { - continue; -#endif - } else if ( (event.data.keyDown.modifiers & commandKeyMask) != 0 - && ( (event.data.keyDown.chr == autoOffChr) - || (event.data.keyDown.chr == hardPowerChr) ) - && !!globals->game.board ) { - if ( !globals->menuIsDown /* hi Marcus :-) */ - && closeNonMainForms(globals) - && gi_countLocalHumans( &globals->gameInfo ) > 1 - && board_hideTray( globals->game.board ) ) { - board_draw( globals->game.board ); - } - } - } - - /* Give the system a chance to handle the event. */ - if ( !SysHandleEvent(&event)) { - UInt16 error; - if ( !MenuHandleEvent( NULL, &event, &error)) { - if ( !applicationHandleEvent( &event )) { - FrmDispatchEvent(&event); - } - } - } - } while (event.eType != appStopEvent); -} /* eventLoop */ - -/********************************************************************** - * applicationHandleEvent - **********************************************************************/ -static Boolean -applicationHandleEvent( EventPtr event ) -{ - FormPtr frm = NULL; - Int16 formId; - Boolean result = false; - FormEventHandlerType* handler = NULL; - - if ( event->eType == frmLoadEvent ) { - /*Load the form resource specified in the event then activate the - form.*/ - formId = event->data.frmLoad.formID; - frm = FrmInitForm(formId); - FrmSetActiveForm(frm); - - switch (formId) { - case XW_MAIN_FORM: - handler = mainViewHandleEvent; - break; - case XW_NEWGAMES_FORM: - handler = newGameHandleEvent; - break; - case XW_DICTINFO_FORM: - handler = dictFormHandleEvent; - break; - case XW_PREFS_FORM: - handler = PrefsFormHandleEvent; - break; -#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH - case XW_CONNS_FORM: - handler = ConnsFormHandleEvent; - break; -#endif - case XW_SAVEDGAMES_DIALOG_ID: - handler = savedGamesHandleEvent; - break; - } - if ( !!handler ) { - XP_ASSERT( !!frm ); - result = true; - FrmSetEventHandler( frm, handler ); - } - } - - return result; -} // applicationHandleEvent - -#if 0 -static void -destroy_on_close( XWStreamCtxt* p_stream ) -{ - MemStreamCtxt* stream = (MemStreamCtxt*)p_stream; - /* PalmAppGlobals* globals = stream->globals; */ - MemHandle handle; - - XP_WARNF( "destroy_on_close called" ); - handle = stream->bufHandle; - MemHandleFree( handle ); - stream_destroy( p_stream ); -} /* destroy_on_close */ -#endif - -static void -palmFireTimer( PalmAppGlobals* globals, XWTimerReason why ) -{ - XWTimerProc proc = globals->timerProcs[why]; - void* closure = globals->timerClosures[why]; - XP_ASSERT( TimGetTicks() >= globals->timerFireAt[why] ); - globals->timerProcs[why] = NULL; - (*proc)( closure, why ); -} /* fireTimer */ - -static XP_Bool -timeForTimer( PalmAppGlobals* globals, XWTimerReason* why, XP_U32* when ) -{ - XP_U16 ii; - XWTimerReason nextWhy = 0; - XP_U32 nextWhen = 0xFFFFFFFF; - XP_Bool found; - - for ( ii = 1; ii < NUM_PALM_TIMERS; ++ii ) { - if ( (globals->timerProcs[ii] != NULL) && - (globals->timerFireAt[ii] < nextWhen) ) { - nextWhy = ii; - nextWhen = globals->timerFireAt[ii]; - } - } - - found = nextWhy != 0; - if ( found ) { - *why = nextWhy; - *when = nextWhen; - } - return found; -} /* timeForTimer */ - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY -static void -showConnState( PalmAppGlobals* globals ) -{ - CommsCtxt* comms = globals->game.comms; - Int16 resID = 0; - if ( !!comms ) { - CommsConnType typ = comms_getConType( comms ); - if ( 0 ) { -#ifdef XWFEATURE_BLUETOOTH - } else if ( COMMS_CONN_BT == typ ){ - switch( globals->netState.btUIState ) { - case BTUI_NOBT: - break; - case BTUI_NONE: - resID = BTSTATUS_NONE_RES_ID; break; - case BTUI_LISTENING: - resID = BTSTATUS_LISTENING_RES_ID; break; - case BTUI_CONNECTING: - resID = BTSTATUS_SEEKING_RES_ID; break; - case BTUI_CONNECTED: - case BTUI_SERVING: - resID = BTSTATUS_CONNECTED_RES_ID; break; - } -#endif -#ifdef XWFEATURE_RELAY - } else if ( COMMS_CONN_RELAY == typ ) { - /* resID = RELAYSTATUS_NONE_RESID; */ - if ( globals->lastSendGood ) { - switch( globals->netState.relayState ) { - case COMMS_RELAYSTATE_UNCONNECTED: - case COMMS_RELAYSTATE_DENIED: - case COMMS_RELAYSTATE_CONNECT_PENDING: - resID = RELAYSTATUS_PENDING_RESID; - break; - case COMMS_RELAYSTATE_CONNECTED: - case COMMS_RELAYSTATE_RECONNECTED: - resID = RELAYSTATUS_CONN_RESID; - break; - case COMMS_RELAYSTATE_ALLCONNECTED: - resID = RELAYSTATUS_ALLCONN_RESID; - break; - } - } -#endif - } - } - if ( globals->lastNetStatusRes != resID ) { - RectangleType bounds; - getObjectBounds( XW_NETSTATUS_GADGET_ID, &bounds ); - if ( resID != 0 ) { - draw_drawBitmapAt( globals->draw, resID, - bounds.topLeft.x, bounds.topLeft.y ); - } else { - if ( globals->useHiRes ) { - bounds.extent.x = (1 + bounds.extent.x) >> 1; - bounds.extent.y = (1 + bounds.extent.y) >> 1; - } - WinEraseRectangle( &bounds, 0 ); - } - globals->lastNetStatusRes = resID; - } -} /* showConnState */ -#endif - -#ifdef XWFEATURE_BLUETOOTH -static void -btEvtHandler( PalmAppGlobals* globals, BtCbEvtInfo* evt ) -{ - switch ( evt->evt ) { - case BTCBEVT_CONFIRM: - if ( globals->suspendBT ) { - evt->u.confirm.confirmed = XP_FALSE; - } else if ( globals->gameInfo.confirmBTConnect ) { - const XP_UCHAR* fmt; - char buf[256]; /* fmt is 182+ bytes in English */ - XP_ASSERT( !!globals->game.comms && - !comms_getIsServer(globals->game.comms) ); - fmt = getResString( globals, STRS_BT_CONFIRM ); - XP_SNPRINTF( buf, sizeof(buf), fmt, evt->u.confirm.hostName ); - evt->u.confirm.confirmed = palmask( globals, buf, NULL, -1 ); - globals->suspendBT = !evt->u.confirm.confirmed; - } else { - evt->u.confirm.confirmed = XP_TRUE; - } - break; - case BTCBEVT_CONN: - if ( !!globals->game.comms ) { - comms_resendAll( globals->game.comms ); - } - break; - case BTCBEVT_DATA: - if ( COMMS_CONN_BT == comms_getConType( globals->game.comms ) ) { - XWStreamCtxt* instream; - instream = makeSimpleStream( globals, NULL ); - stream_putBytes( instream, evt->u.data.data, evt->u.data.len ); - checkAndDeliver( globals, evt->u.data.fromAddr, - instream, COMMS_CONN_BT ); - } else { - /* If we're no longer using BT (meaning somebody loaded a new game - that doesn't use it), close it down. We don't want to do it as - part of unloading the old game since it's expensive to stop/start - BT and the new game will probably use the same connection. But if - we get here, a non-bt game's been loaded and we should shut - down.*/ - postEmptyEvent( closeBtLibEvent ); - } - break; - default: - XP_ASSERT(0); - } -} /* btEvtHandler */ -#endif - -static Boolean -handleNilEvent( PalmAppGlobals* globals ) -{ - Boolean handled = true; - XP_U32 when; - XWTimerReason why; - - if ( 0 ) { -#ifdef XWFEATURE_BLUETOOTH - } else if ( (handled = (!globals->suspendBT) - && palm_bt_doWork( globals, btEvtHandler, - &globals->netState.btUIState ) ) - ,showConnState( globals ) - ,handled ) { - /* nothing to do */ -#endif - } else if ( timeForTimer( globals, &why, &when ) - && (when <= TimGetTicks()) ) { - palmFireTimer( globals, why ); - } else if ( globals->menuIsDown ) { - /* do nothing */ - } else if ( globals->hintPending ) { - handled = handleHintRequest( globals ); - } else if ( globals->timeRequested ) { - globals->timeRequested = false; - if ( globals->msgReceivedDraw ) { - XP_ASSERT ( !!globals->game.board ); - board_draw( globals->game.board ); - globals->msgReceivedDraw = XP_FALSE; - } - handled = server_do( globals->game.server ); - } else { - handled = false; - } - - return handled; -} /* handleNilEvent */ - -static Boolean -handleFlip( PalmAppGlobals* globals ) -{ - XP_ASSERT( !!globals->game.board ); - return board_flip( globals->game.board ); -} /* handle_flip_button */ - -static Boolean -handleValueToggle( PalmAppGlobals* globals ) -{ - return board_toggle_showValues( globals->game.board ); -} /* handleValueToggle */ - -static Boolean -handleHideTray( PalmAppGlobals* globals ) -{ - Boolean draw; - if ( TRAY_REVEALED == board_getTrayVisState( globals->game.board ) ) { - draw = board_hideTray( globals->game.board ); - } else { - draw = board_showTray( globals->game.board ); - } - - return draw; -} /* handleHideTray */ - -#ifdef XWFEATURE_SEARCHLIMIT -static Boolean -popupLists( EventPtr event ) -{ - Boolean handled = false; - XP_U16 ctlID; - ListPtr list = NULL; - XP_S16 chosen; - - if ( event->eType == ctlSelectEvent ) { - ctlID = event->data.ctlSelect.controlID; - if ( ctlID == XW_HINTCONFIG_MINSELECTOR_ID ) { - list = getActiveObjectPtr( XW_HINTCONFIG_MINLIST_ID ); - } else if ( ctlID == XW_HINTCONFIG_MAXSELECTOR_ID ) { - list = getActiveObjectPtr( XW_HINTCONFIG_MAXLIST_ID ); - } - - if ( !!list ) { - chosen = LstPopupList( list ); - if ( chosen >= 0 ) { - setSelectorFromList( ctlID, list, chosen ); - } - handled = true; - } - } - - return handled; -} /* popupLists */ - -static XP_Bool -doHintConfig( XP_U16* minP, XP_U16* maxP ) -{ - FormPtr form, prevForm; - ListPtr listMin, listMax; - XP_Bool confirmed; - - prevForm = FrmGetActiveForm(); - form = FrmInitForm( XW_HINTCONFIG_FORM_ID ); - FrmSetEventHandler( form, popupLists ); - FrmSetActiveForm( form ); - - listMin = getActiveObjectPtr( XW_HINTCONFIG_MINLIST_ID ); - LstSetSelection( listMin, *minP - 1 ); - setSelectorFromList( XW_HINTCONFIG_MINSELECTOR_ID, - listMin, *minP - 1 ); - - listMax = getActiveObjectPtr( XW_HINTCONFIG_MAXLIST_ID ); - LstSetSelection( listMax, *maxP - 1 ); - setSelectorFromList( XW_HINTCONFIG_MAXSELECTOR_ID, - listMax, *maxP - 1 ); - - confirmed = FrmDoDialog( form ) == XW_HINTCONFIG_OK_ID; - if ( confirmed ) { - *minP = LstGetSelection( listMin ) + 1; - *maxP = LstGetSelection( listMax ) + 1; - } - - FrmDeleteForm( form ); - FrmSetActiveForm( prevForm ); - - return confirmed; -} /* doHintConfig */ -#endif - -static Boolean -handleHintRequest( PalmAppGlobals* globals ) -{ - Boolean notDone; - Boolean draw; - - XP_ASSERT( !!globals->game.board ); - - draw = board_requestHint( globals->game.board, -#ifdef XWFEATURE_SEARCHLIMIT - globals->askTrayLimits, -#endif - - ¬Done ); - globals->hintPending = notDone; - return draw; -} /* handleHintRequest */ - -static Boolean -handleDone( PalmAppGlobals* globals ) -{ - return board_commitTurn( globals->game.board ); -} /* handleDone */ - -static Boolean -handleJuggle( PalmAppGlobals* globals ) -{ - return board_juggleTray( globals->game.board ); -} /* handleJuggle */ - -static Boolean -handleTrade( PalmAppGlobals* globals ) -{ - return board_beginTrade( globals->game.board ); -} /* handleJuggle */ - -static Boolean -buttonIsUsable( ControlPtr button ) -{ - return CtlEnabled( button ); -} /* buttonIsUsable */ - -static void -drawBitmapButton( PalmAppGlobals* globals, UInt16 ctrlID, UInt16 resID, - XP_Bool eraseIfDisabled ) -{ - FormPtr form; - UInt16 index; - RectangleType bounds; - - form = FrmGetActiveForm(); - index = FrmGetObjectIndex( form, ctrlID ); - FrmGetObjectBounds( form, index, &bounds ); - - if ( buttonIsUsable( getActiveObjectPtr( ctrlID ) ) ) { - draw_drawBitmapAt( globals->draw, resID, bounds.topLeft.x, - bounds.topLeft.y ); - } else if ( eraseIfDisabled ) { - /* gross hack; the button represents a larger bitmap; erase the - whole thing.*/ -#ifndef EIGHT_TILES - if ( ctrlID == XW_MAIN_HIDE_BUTTON_ID ) { - bounds.extent.x += TRAY_BUTTON_WIDTH + 1; - bounds.extent.y += TRAY_BUTTON_WIDTH + 1; - } -#endif - WinEraseRectangle( &bounds, 0 ); - } -} /* drawBitmapButton */ - -static void -drawFormButtons( PalmAppGlobals* globals ) -{ -#ifdef XWFEATURE_FIVEWAY - Int16 focusItem; -#endif - XP_U16 pairs[] = { - XW_MAIN_FLIP_BUTTON_ID, FLIP_BUTTON_BMP_RES_ID, XP_TRUE, - XW_MAIN_VALUE_BUTTON_ID, VALUE_BUTTON_BMP_RES_ID, XP_TRUE, - XW_MAIN_HINT_BUTTON_ID, HINT_BUTTON_BMP_RES_ID, XP_TRUE, -#ifndef EIGHT_TILES - XW_MAIN_HIDE_BUTTON_ID, TRAY_BUTTONS_BMP_RES_ID, XP_TRUE, -#endif - XW_MAIN_SHOWTRAY_BUTTON_ID, SHOWTRAY_BUTTON_BMP_RES_ID, XP_FALSE, - 0, - }; - XP_U16* pair = (XP_U16*)pairs; - - if ( FrmGetActiveFormID() == XW_MAIN_FORM ) { - while ( !!*pair ) { - drawBitmapButton( globals, pair[0], pair[1], pair[2] ); - pair += 3; - } - } - -#ifdef XWFEATURE_FIVEWAY - if ( globals->hasTreoFiveWay ) { - focusItem = globals->gState.focusItem; - if ( focusItem > 0 ) { - if ( isFormObject( globals->mainForm, focusItem ) ) { -/* XP_WARNF( "setting focus: %s", frmObjId_2str(focusItem) ); */ - setFormFocus( globals->mainForm, focusItem ); - if ( !isBoardObject( focusItem ) - && buttonIsUsable( getActiveObjectPtr(focusItem) ) ) { - drawFocusRingOnGadget( globals, focusItem, focusItem ); - } - } - globals->gState.focusItem = -1; - } else { - drawFocusRingOnGadget( globals, XW_MAIN_DONE_BUTTON_ID, - XW_MAIN_HIDE_BUTTON_ID ); - } - } -#endif -} /* drawFormButtons */ - -static void -updateScrollbar( PalmAppGlobals* globals, Int16 newValue ) -{ - if ( FrmGetActiveFormID() == XW_MAIN_FORM ) { - ScrollBarPtr scroll = getActiveObjectPtr( XW_MAIN_SCROLLBAR_ID ); - XW_TrayVisState state = board_getTrayVisState( globals->game.board ); - XP_U16 max, min; - - max = model_numRows( globals->game.model ); - min = max; - if ( globals->needsScrollbar && (max == SBAR_MAX) - && state != TRAY_HIDDEN ) { - min -= 2; /* fragile!!! PENDING */ - } - - SclSetScrollBar( scroll, newValue + min, min, max, SBAR_PAGESIZE ); - } -} /* updateScrollbar */ - -static void -palmSetCtrlsForTray( PalmAppGlobals* globals ) -{ - XW_TrayVisState state = board_getTrayVisState( globals->game.board ); - FormPtr form = globals->mainForm; - - /* In rare circumstances, e.g. when an appStopEvent comes in while the - prefs dialog is up, this'll get called when the main form's not on - top. In that case it's probably ok to just do nothing. But if not - I'll need to queue an event of some sort so it gets done later. */ - if ( FrmGetActiveFormID() == XW_MAIN_FORM ) { - - disOrEnable( form, XW_MAIN_HINT_BUTTON_ID, - (state==TRAY_REVEALED) && - !globals->gameInfo.hintsNotAllowed ); - -#ifndef EIGHT_TILES - disOrEnable( form, XW_MAIN_DONE_BUTTON_ID, state==TRAY_REVEALED ); - disOrEnable( form, XW_MAIN_JUGGLE_BUTTON_ID, state==TRAY_REVEALED ); - disOrEnable( form, XW_MAIN_TRADE_BUTTON_ID, state==TRAY_REVEALED ); - disOrEnable( form, XW_MAIN_HIDE_BUTTON_ID, state!=TRAY_HIDDEN ); -#endif - disOrEnable( form, XW_MAIN_SHOWTRAY_BUTTON_ID, state==TRAY_HIDDEN - && globals->gameInfo.nPlayers > 0 ); - - globals->scrollValue = board_getYOffset( globals->game.board ); - updateScrollbar( globals, globals->scrollValue ); - - /* PENDING(ehouse) Can't the board just do this itself? */ - if ( state==TRAY_HIDDEN ) { - board_setYOffset( globals->game.board, 0 ); - } - } -} /* palmSetCtrlsForTray */ - -static Boolean -scrollBoard( PalmAppGlobals* globals, Int16 newValue, Boolean fromBar ) -{ - XP_Bool result = XP_FALSE; - - XP_ASSERT( !!globals->game.board ); - - result = board_setYOffset( globals->game.board, newValue ); - - if ( !fromBar ) { - updateScrollbar( globals, newValue ); - } - return result; -} /* scrollBoard */ - -/* We can't create the board back in newgame.c because the wrong form's - * frontmost at that point. So we do it here instead -- and must also call - * server_do. - */ -static void -initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame ) -{ - DictionaryCtxt* dict; - XP_UCHAR* newDictName = globals->gameInfo.dictName; - - /* This needs to happen even when !newGame because it's how the dict - slots in PlayerInfo get loaded. That really ought to happen earlier, - though. */ - XP_ASSERT( !!globals->game.model ); - dict = model_getDictionary( globals->game.model ); - - if ( !!dict ) { - const XP_UCHAR* dictName = dict_getName( dict ); - if ( !!newDictName && 0 != XP_STRCMP( (const char*)dictName, - (const char*)newDictName ) ) { - dict_destroy( dict ); - dict = NULL; - } else { - replaceStringIfDifferent( globals->mpool, - &globals->gameInfo.dictName, dictName ); - } - } - - if ( !dict ) { - XP_ASSERT( !!newDictName ); - dict = palm_dictionary_make( MPPARM(globals->mpool) globals, - newDictName, globals->dictList ); - XP_ASSERT( !!dict ); - model_setDictionary( globals->game.model, dict ); - } - - if ( newGame ) { - TransportProcs procs; - palmInitTProcs( globals, &procs ); - game_reset( MEMPOOL &globals->game, &globals->gameInfo, - &globals->util, &globals->gState.cp, &procs ); - -#ifndef XWFEATURE_STANDALONE_ONLY - if ( !!globals->game.comms ) { - comms_setAddr( globals->game.comms, - &globals->newGameState.addr ); - } else if ( globals->gameInfo.serverRole != SERVER_STANDALONE ) { - XP_ASSERT(0); - } -#endif - } - - XP_ASSERT( !!globals->game.board ); - getSizes( globals ); - (void)positionBoard( globals ); - -#ifndef XWFEATURE_STANDALONE_ONLY - if ( !!globals->game.comms ) { - comms_start( globals->game.comms ); - } - - if ( newGame && globals->gameInfo.serverRole == SERVER_ISCLIENT ) { - XWStreamCtxt* stream; - XP_ASSERT( !!globals->game.comms ); - stream = makeSimpleStream( globals, palm_send_on_close ); - server_initClientConnection( globals->game.server, stream ); - } -#endif - /* Used to call server_do here, but if it's a robot's turn it'll run - without drawing the board first. This allows work to get done almost - as quickly. If the board starts flashing on launch this is why; - server_do might need to take a bool param skip-robot */ - palm_util_requestTime( &globals->util ); - - board_invalAll( globals->game.board ); - board_draw( globals->game.board ); - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY -# ifdef XWFEATURE_BLUETOOTH - globals->suspendBT = XP_FALSE; -# endif - showConnState( globals ); -#endif - - globals->isNewGame = false; -} /* initAndStartBoard */ - -#ifdef DEBUG -static void -toggleBoolFtr( XP_U16 ftr ) -{ - UInt32 val; - FtrGet( APPID, ftr, &val ); - val = !val; - FtrSet( APPID, ftr, val ); - XP_WARNF( "Turned %s.", val==0? "OFF" : "ON" ); -} /* toggleBoolFtr */ - -static void -askOnClose( XWStreamCtxt* stream, void* closure ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - - (void)askFromStream( globals, stream, -1, false ); -} /* askOnClose */ -#endif - -static void -updateForLefty( PalmAppGlobals* globals, FormPtr form ) -{ - XP_S16 idsAndXs[] = { - /* ButtonID, x-coord-when-lefty, */ - XW_MAIN_FLIP_BUTTON_ID, 0, - XW_MAIN_VALUE_BUTTON_ID, 0, - XW_MAIN_HINT_BUTTON_ID, 0, - XW_MAIN_SCROLLBAR_ID, 0, - XW_MAIN_SHOWTRAY_BUTTON_ID, 0, - -#ifdef FOR_GREMLINS - GREMLIN_BOARD_GADGET_IDAUTOID, 9, - GREMLIN_TRAY_GADGET_IDAUTOID, 9, -#endif - -#ifndef EIGHT_TILES - XW_MAIN_HIDE_BUTTON_ID, -1, - XW_MAIN_JUGGLE_BUTTON_ID, TRAY_BUTTON_WIDTH-1, - XW_MAIN_TRADE_BUTTON_ID, -1, - XW_MAIN_DONE_BUTTON_ID, TRAY_BUTTON_WIDTH-1, -#endif -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - XW_NETSTATUS_GADGET_ID, 0, -#endif - 0, - }; - if ( globals->isLefty ) { - UInt16 id; - UInt16* idp = (UInt16*)idsAndXs; - for ( id = *idp; !!id; id = *(idp+=2) ) { - XP_S16 x, y; - UInt16 objIndex = FrmGetObjectIndex( form, id ); - FrmGetObjectPosition( form, objIndex, &x, &y ); - - FrmSetObjectPosition( form, objIndex, idp[1], y ); - } - } -} /* updateForLefty */ - -static void -beamBoard( PalmAppGlobals* globals ) -{ - Err err; - XP_UCHAR prcName[50]; - - unlockBonusPtrs( globals ); - DmCloseDatabase( globals->boardDBP ); - - /* do we need to close the db first, and reopen after? */ - XP_SNPRINTF( prcName, sizeof(prcName), (XP_UCHAR*)"%s.prc", - XW_PREFS_DBNAME ); - err = sendDatabase( CARD_0, globals->boardDBID, - prcName, (XP_UCHAR*)"board prefs" ); - - globals->boardDBP = DmOpenDatabase( CARD_0, globals->boardDBID, - dmModeWrite ); - setupBonusPtrs( globals ); -} /* beamBoard */ - -static XP_Bool -considerMenuShow( EventPtr event ) -{ - XP_S16 y = event->screenY; - XP_Bool penInRightPlace = (y < PALM_BOARD_TOP) && (y >= 0); - - if ( penInRightPlace ) { - EventType menuEvent; - XP_MEMSET( &menuEvent, 0, sizeof(menuEvent) ); - menuEvent.eType = keyDownEvent; - menuEvent.data.keyDown.chr = menuChr; - menuEvent.data.keyDown.keyCode = 0; - menuEvent.data.keyDown.modifiers = commandKeyMask; - EvtAddEventToQueue( &menuEvent ); - } - - return penInRightPlace; -} /* considerMenuShow */ - -/* Draw immediately, because we've made a change we need reflected - immediately. */ -static void -drawChangedBoard( PalmAppGlobals* globals ) -{ - if ( !!globals->game.board && !globals->menuIsDown ) { - board_draw( globals->game.board ); - } -} /* drawChangedBoard */ - -static XP_Bool -tryLoadSavedGame( PalmAppGlobals* globals, XP_U16 newIndex ) -{ - XWGame tmpGame; - CurGameInfo tmpGInfo; - XP_Bool loaded; - - XP_MEMSET( &tmpGame, 0, sizeof(tmpGame) ); - XP_MEMSET( &tmpGInfo, 0, sizeof(tmpGInfo) ); - - loaded = loadCurrentGame( globals, newIndex, &tmpGame, &tmpGInfo ); - - /* Nuke the one we don't want */ - game_dispose( loaded? &globals->game : &tmpGame ); - gi_disposePlayerInfo( MEMPOOL (loaded? &globals->gameInfo : &tmpGInfo) ); - - if ( loaded ) { - XP_MEMCPY( &globals->game, &tmpGame, sizeof(globals->game) ); - XP_MEMCPY( &globals->gameInfo, &tmpGInfo, sizeof(globals->gameInfo) ); - globals->gState.curGameIndex = newIndex; - } - - return loaded; -} /* tryLoadSavedGame */ - -static XP_U16 -hresX( PalmAppGlobals* globals, XP_U16 screenX ) -{ - if ( globals->useHiRes ) { - screenX *= 2; - } - return screenX; -} - -static XP_U16 -hresY( PalmAppGlobals* globals, XP_U16 screenY ) -{ - if ( globals->useHiRes ) { - screenY *= 2; - } - return screenY; -} - -static void -hresRect( PalmAppGlobals* globals, RectangleType* r ) -{ - if ( globals->useHiRes ) { - r->topLeft.x *= 2; - r->topLeft.y *= 2; - r->extent.x *= 2; - r->extent.y *= 2; - } -} - -#ifdef XWFEATURE_FIVEWAY -static void -invalRectAroundButton( PalmAppGlobals* globals, XP_U16 objectID ) -{ - RectangleType rect; - getObjectBounds( objectID, &rect ); - - rect.topLeft.x -= 3; - rect.topLeft.y -= 3; - rect.extent.x += 6; - rect.extent.y += 6; - hresRect( globals, &rect ); - - board_invalRect( globals->game.board, (XP_Rect*)&rect ); -} - -static XP_Bool -isBoardObject( XP_U16 id ) -{ - return id == XW_BOARD_GADGET_ID - || id == XW_SCOREBOARD_GADGET_ID - || id == XW_TRAY_GADGET_ID; -} - -static XP_Bool -handleFocusEvent( PalmAppGlobals* globals, const EventType* event, - XP_Bool* drawP ) -{ - XP_U16 objectID = event->data.frmObjectFocusTake.objectID; - XP_Bool isBoardObj = isBoardObject( objectID ); - XP_Bool take; - BoardObjectType typ; - - XP_ASSERT( &event->data.frmObjectFocusTake.objectID - == &event->data.frmObjectFocusLost.objectID ); - take = event->eType == frmObjectFocusTakeEvent; - -/* XP_LOGF( "%s(%s,%s)", __func__, frmObjId_2str(objectID), */ -/* (take? "take":"lost") ); */ - - if ( take && !globals->initialTakeDropped && - (objectID == XW_SCOREBOARD_GADGET_ID) ) { - /* Work around OS's insistence on sending initial take event. */ - globals->initialTakeDropped = XP_TRUE; - } else { - /* Need to invalidate the neighborhood of buttons on which palm draws - the focus ring when they lose focus -- to redraw where the focus - ring may have been. No need unless we have the focus now, - however, since we'll otherwise have drawn the object correctly - (unfocussed). */ - - if ( (!take) && (!isBoardObj) && isBoardObject( getFocusOwner() ) ) { - EventType event; - event.eType = updateAfterFocusEvent; - event.data.generic.datum[0] = objectID; - EvtAddEventToQueue( &event ); - } - - /* Board needs to know about any change involving it, including - something else taking the focus it may think it has. Why? - Because takes preceed losses, yet the board must draw itself - without focus before some button draws itself with focus and snags - as part of the background the board in focussed state. */ - - typ = isBoardObj? OBJ_BOARD + (objectID - XW_BOARD_GADGET_ID) : OBJ_NONE; - *drawP = board_focusChanged( globals->game.board, typ, take ); - if ( isBoardObj && take ) { - setFormFocus( globals->mainForm, objectID ); - } - } - return isBoardObj; -} /* handleFocusEvent */ -#endif - -#ifdef DO_TUNGSTEN_FIVEWAY -/* These are supposed to be defined in some SDK headers but I can't find 'em, - * and if I could they're obscure enough that I wouldn't want the build to - * depend on 'em since they're copyrighted and I couldn't distribute. */ -# define vchrNavChange (vchrPalmMin + 3) -# define navBitUp 0x0001 -# define navBitDown 0x0002 -# define navBitLeft 0x0004 -# define navBitRight 0x0008 -# define navBitSelect 0x0010 -# define navBitsAll 0x001F - -# define navChangeUp 0x0100 -# define navChangeDown 0x0200 -# define navChangeLeft 0x0400 -# define navChangeRight 0x0800 -# define navChangeSelect 0x1000 -# define navChangeBitsAll 0x1F00 -#endif - -static XP_Bool -handleKeyEvent( PalmAppGlobals* globals, const EventType* event, - XP_Bool* handledP ) -{ - /* keyDownEvent: be very careful here. keyUpEvent is only sent on - devices with a hard keyboard. Do not assume keyUpEvent or all - non-Treos will be broken!!! */ - - XP_Bool draw = XP_FALSE; - XP_Key xpkey; - XP_Bool handled = XP_FALSE; - XP_Bool altOn = (event->data.keyUp.modifiers & shiftKeyMask) != 0; - XP_Bool treatAsUp = !globals->generatesKeyUp - || (event->eType == keyUpEvent); - XP_U16 keyCode = event->data.keyDown.keyCode; - Int16 chr; - XP_Bool (*handler)( BoardCtxt*, XP_Key, XP_Bool* ); - BoardCtxt* board = globals->game.board; - XP_S16 incr = 0; /* needed for tungsten and zodiac, but not treo since - the OS handled focus movement between objects. */ - - globals->handlingKeyEvent = XP_TRUE; - -#ifdef DO_TUNGSTEN_FIVEWAY - if ( !globals->generatesKeyUp ) { /* this is the Tungsten case */ - if ( event->data.keyDown.chr == vchrNavChange ) { - if ( (keyCode & (/* navBitUp | */navChangeUp )) != 0 ) { - keyCode = vchrRockerUp; - incr = -1; - } else if ( (keyCode & (/* navBitDown | */navChangeDown )) != 0 ) { - keyCode = vchrRockerDown; - incr = 1; - } else if ( (keyCode & (navBitLeft /* |navChangeLeft */ )) != 0 ) { - keyCode = vchrRockerLeft; - incr = -1; - } else if ( (keyCode & ( navBitRight /*|navChangeRight*/ )) != 0 ) { - keyCode = vchrRockerRight; - incr = 1; - } else if ( (keyCode & (navBitSelect /*|navChangeSelect*/)) != 0 ) { - keyCode = vchrRockerCenter; - } - } else { - keyCode = event->data.keyUp.chr; - } - } -#endif - - /* We're assuming the same layout for keyUp and keyDown event data. - Let's make sure they're the same.... */ - XP_ASSERT( OFFSET_OF(EventType, data.keyUp.modifiers) - == OFFSET_OF(EventType, data.keyDown.modifiers) ); - XP_ASSERT( OFFSET_OF(EventType, data.keyUp.keyCode) - == OFFSET_OF(EventType, data.keyDown.keyCode) ); - - if ( !globals->generatesKeyUp ) { - handler = board_handleKey; - } else if ( event->eType == keyUpEvent ) { - handler = board_handleKeyUp; - globals->lastKeyDown = XP_KEY_NONE; - } else if ( (event->data.keyDown.modifiers & autoRepeatKeyMask) != 0 ) { - handler = board_handleKeyRepeat; - } else { - handler = board_handleKeyDown; - XP_ASSERT( globals->lastKeyDown == XP_KEY_NONE ); - globals->lastKeyDown = event->data.keyDown.keyCode; - } - - /* Unlike Treo, zodiac doesn't use keyCode as documented */ - if ( globals->isZodiac ) { - keyCode = event->data.keyDown.chr; - } - - /* Treo gets at least one of these wrong in the chr field, but puts the - right value in the keyCode. So use that. On other platforms must set - it first. */ - switch ( keyCode ) { -#ifdef XWFEATURE_FIVEWAY - case vchrRockerCenter: - xpkey = XP_RETURN_KEY; - break; - case vchrRockerLeft: - xpkey = altOn ? XP_CURSOR_KEY_ALTLEFT : XP_CURSOR_KEY_LEFT; - incr = -1; - break; - case vchrRockerRight: - xpkey = altOn ? XP_CURSOR_KEY_ALTRIGHT : XP_CURSOR_KEY_RIGHT; - incr = 1; - break; - case vchrRockerUp: - xpkey = altOn ? XP_CURSOR_KEY_ALTUP : XP_CURSOR_KEY_UP; - incr = -1; - break; - case vchrRockerDown: - xpkey = altOn ? XP_CURSOR_KEY_ALTDOWN : XP_CURSOR_KEY_DOWN; - incr = 1; - break; - case chrSpace: - xpkey = XP_RAISEFOCUS_KEY; - break; -#endif - default: - /* Zodiac doesn't send keyUp events for printing chars, which somehow - includes backspace */ - if ( globals->isZodiac ) { - handler = board_handleKey; - } - - xpkey = XP_KEY_NONE; - chr = event->data.keyUp.chr; - /* I'm not interested in being dependent on a particular version - of the OS, (can't manage to link against the intl library - anyway) and so don't want to use the 3.5-only text tests. So - let's give the board two shots at each char, one lower case - and another upper. */ - if ( !!handler && (chr < 255) && (chr > ' ') ) { /* space is first - printing char */ - draw = (*handler)( board, chr, &handled ); - if ( !handled && chr >= 'a' ) { - draw = (*handler)( board, chr - ('a' - 'A'), &handled ); - } - } else { - switch ( chr ) { - case pageUpChr: - draw = treatAsUp && scrollBoard( globals, 0, false ); - break; - case pageDownChr: - draw = treatAsUp && scrollBoard( globals, 2, false ); - break; - case backspaceChr: - xpkey = XP_CURSOR_KEY_DEL; - break; - case chrSpace: - xpkey = XP_RAISEFOCUS_KEY; - break; - } - } - } - - if ( xpkey != XP_KEY_NONE ) { - XP_ASSERT( !!handler ); - draw = (*handler)( board, xpkey, &handled ); - - if ( 0 ) { -#ifdef DO_TUNGSTEN_FIVEWAY - /* If it's a tungsten or zodiac, there's no built-in focus xfer - so we do it here. Don't do it for Treo, and don't do it on - key-down for zodiac since it has keyUp too. */ - } else if ( !globals->hasTreoFiveWay && treatAsUp - && !handled && (incr != 0) ) { - /* order'll be different if scoreboard is vertical */ - BoardObjectType typs[] = { OBJ_SCORE, OBJ_BOARD, OBJ_TRAY }; - BoardObjectType nxt = board_getFocusOwner( board ); - XP_U16 indx = 0; - if ( nxt != OBJ_NONE ) { - for ( ; indx < VSIZE(typs); ++indx ){ - if ( nxt == typs[indx] ) { - indx = (indx + (VSIZE(typs) + incr)); - indx %= VSIZE(typs); - break; - } - } - } - draw = board_focusChanged( board, typs[indx], XP_TRUE ) || draw; -#endif - } else if ( draw && !handled ) { - /* If handled comes back false yet something changed (draw), - we'll be getting another event shortly. Put the draw off - until then so we don't flash the tray focussed then not. This - is a hack, but I can't think of a way to integrate it into - board.c logic without making too many palm-centric assumptions - there. */ - draw = XP_FALSE; - } - } else { - /* remove this and break focus drilldown. Why? */ - handled = draw; - } - *handledP = handled; - - globals->handlingKeyEvent = XP_FALSE; - - return draw; -} /* handleKeyEvent */ - -static void -showRemaining( PalmAppGlobals* globals ) -{ - if ( !!globals->game.board ) { - XWStreamCtxt* stream = makeSimpleStream( globals, NULL ); - board_formatRemainingTiles( globals->game.board, stream ); - (void)askFromStream( globals, stream, STR_REMAINS_TITLE, true ); - } -} - -/***************************************************************************** - * - ****************************************************************************/ -static Boolean -mainViewHandleEvent( EventPtr event ) -{ - XP_Bool handled = XP_TRUE; - XP_Bool draw = XP_FALSE; - Boolean erase; -#if defined CURSOR_MOVEMENT && defined DEBUG - CursorDirection cursorDir; - Boolean movePiece; -#endif - PalmAppGlobals* globals; - OpenSavedGameData* savedGameData; - char newName[MAX_GAMENAME_LENGTH]; - XP_U16 prevSize; - XWStreamCtxt* stream; - - CALLBACK_PROLOGUE(); - - globals = getFormRefcon(); - -/* XP_LOGF( "%s(%s)", __func__, eType_2str(event->eType) ); */ - - switch ( event->eType ) { - - case nilEvent: - draw = handled = handleNilEvent( globals ); - break; - - - case noopEvent: - /* do nothing! Exists just to force EvtGetEvent to return */ - XP_ASSERT( handled ); - break; - - case newGameCancelEvent: - /* If user cancelled the new game dialog that came up the first time - he launched (i.e. when there's no game to fall back to) then just - quit. It's easier than dealing with everything that can go wrong - in this state. */ - if ( globals->isFirstLaunch ) { - postEmptyEvent( appStopEvent ); - } - globals->isNewGame = false; - break; - - case openSavedGameEvent: - globals->postponeDraw = XP_FALSE; - prevSize = globals->gameInfo.boardSize; - savedGameData = (OpenSavedGameData*)&event->data.generic; - - if ( tryLoadSavedGame( globals, savedGameData->newGameIndex ) ) { - if ( prevSize > globals->gameInfo.boardSize ) { - WinEraseWindow(); - } - initAndStartBoard( globals, XP_FALSE ); - } - draw = true; - break; - - case newGameOkEvent: - if ( globals->newGameIsNew ) { - globals->gState.curGameIndex = countGameRecords( globals ); - } - globals->postponeDraw = false; - makeDefaultGameName( newName ); - writeNameToGameRecord( globals, globals->gState.curGameIndex, - newName, XP_STRLEN(newName) ); - globals->isFirstLaunch = false; /* so we'll save the game */ - /* FALLTHRU */ - case loadGameEvent: - XP_ASSERT( !!globals->game.server ); - initAndStartBoard( globals, event->eType == newGameOkEvent ); - draw = true; - XP_ASSERT( !!globals->game.board ); - break; - -#ifdef XWFEATURE_BLUETOOTH - case closeBtLibEvent: - palm_bt_close( globals ); - break; -#endif - -#ifdef FEATURE_SILK - case doResizeWinEvent: - getSizes( globals ); - positionBoard( globals ); - board_invalAll( globals->game.board ); - FrmUpdateForm( 0, frmRedrawUpdateCode ); - break; -#endif - - case prefsChangedEvent: - erase = LocalPrefsToGlobal( globals ); - draw = board_prefsChanged( globals->game.board, &globals->gState.cp ); - server_prefsChanged( globals->game.server, &globals->gState.cp ); - /* watch out for short-circuiting. Both must be called */ - erase = positionBoard( globals ) || erase; - if ( erase ) { - WinEraseWindow(); - } - globals->postponeDraw = false; - FrmUpdateForm( 0, frmRedrawUpdateCode ); /* <- why is this necessary? */ - break; - -#ifdef XWFEATURE_FIVEWAY - case updateAfterFocusEvent: - invalRectAroundButton( globals, event->data.generic.datum[0] ); - draw = XP_TRUE; - break; -#endif - - case winExitEvent: - if ( event->data.winExit.exitWindow == (WinHandle)FrmGetActiveForm() ){ - globals->menuIsDown = true; - } - if ( globals->lastKeyDown != XP_KEY_NONE ) { - EventType event; - XP_Bool ignore; - - event.eType = keyUpEvent; - event.data.keyUp.chr = event.data.keyUp.keyCode - = globals->lastKeyDown; - draw = handleKeyEvent( globals, &event, &ignore ); - } - break; - - case winEnterEvent: - // From PalmOS's "Knowledge base": In the current code, the menu - // doesn't remove itself when it receives a winExitEvent so we need - // an extra check to make sure that the window being entered is the - // first form. This may be different in your implementation (ie: if - // the first form opened is not the one you are currently watching - // for) - if (event->data.winEnter.enterWindow == (WinHandle)FrmGetActiveForm() && - event->data.winEnter.enterWindow == (WinHandle)FrmGetFirstForm() ){ - globals->menuIsDown = false; - } - break; - - case frmOpenEvent: - globals->mainForm = FrmGetActiveForm(); - locateTrayButtons( globals ); - updateForLefty( globals, globals->mainForm ); - FrmDrawForm( globals->mainForm ); - break; - - case frmUpdateEvent: - FrmDrawForm( globals->mainForm ); /* on 3.5 and higher, this erases - the window before drawing, so - there's nothing to be done about - the erase after user clicks OK - in prefs dialog. */ - if ( !!globals->game.board ) { - RectangleType clip; - WinGetClip( &clip ); - - drawFormButtons( globals ); - hresRect( globals, &clip ); - board_invalRect( globals->game.board, (XP_Rect*)&clip ); - draw = !globals->postponeDraw; -#ifdef XWFEATURE_RELAY - showConnState( globals ); -#endif - } - break; - - case penDownEvent: - draw = board_handlePenDown( globals->game.board, - hresX(globals, event->screenX), - hresY(globals, event->screenY), - &handled ); - globals->penDown = handled; - break; - - case penMoveEvent: - if ( globals->penDown ) { - handled = board_handlePenMove( globals->game.board, - hresX( globals, event->screenX ), - hresY( globals, event->screenY )); - draw = handled; - } - break; - - case penUpEvent: - if ( globals->penDown ) { - draw = board_handlePenUp( globals->game.board, - hresX( globals, event->screenX), - hresY( globals, event->screenY ) ); - handled = draw; /* this is wrong!!!! */ - globals->penDown = false; - - if ( !handled ) { - handled = considerMenuShow( event ); - } - } - break; - - case menuEvent: - MenuEraseStatus(0); - switch ( event->data.menu.itemID ) { - - case XW_TILEVALUES_PULLDOWN_ID: - if ( !!globals->game.server ) { - stream = makeSimpleStream( globals, NULL ); - - server_formatDictCounts( globals->game.server, stream, - 4 ); /* 4: ncols */ - - (void)askFromStream( globals, stream, STR_VALUES_TITLE, true ); - } - break; - - case XW_TILESLEFT_PULLDOWN_ID: - showRemaining( globals ); - break; - - case XW_HISTORY_PULLDOWN_ID: - if ( !!globals->game.server ) { - XP_Bool gameOver = server_getGameIsOver(globals->game.server); - stream = makeSimpleStream( globals, NULL ); - - model_writeGameHistory( globals->game.model, stream, - globals->game.server, gameOver ); - if ( stream_getSize( stream ) > 0 ) { - (void)askFromStream( globals, stream, STR_HISTORY_TITLE, - XP_FALSE ); - } else { - beep(); - } - stream_destroy( stream ); - } - break; - - case XW_NEWGAME_PULLDOWN_ID: - askStartNewGame( globals ); - break; - - case XW_SAVEDGAMES_PULLDOWN_ID: - saveOpenGame( globals );/* so it can be accurately duped */ - /* save game changes state; reflect on screen before - popping up dialog */ - drawChangedBoard( globals ); - FrmPopupForm( XW_SAVEDGAMES_DIALOG_ID ); - break; - - case XW_FINISH_PULLDOWN_ID: - if ( server_getGameIsOver( globals->game.server ) ) { - displayFinalScores( globals ); - } else if ( palmaskFromStrId( globals, STR_CONFIRM_END_GAME, -1 ) ) { - server_endGame( globals->game.server ); - draw = true; - } - break; - -#ifndef XWFEATURE_STANDALONE_ONLY - /* Would be better to beep when no remote players.... */ - case XW_RESENDIR_PULLDOWN_ID: - if ( !!globals->game.comms ) { -#ifdef XWFEATURE_BLUETOOTH - globals->suspendBT = XP_FALSE; -#endif - (void)comms_resendAll( globals->game.comms ); - } else { - userErrorFromStrId( globals, STR_RESEND_STANDALONE ); - } - break; -#endif - case XW_BEAMDICT_PULLDOWN_ID: - globals->dictuiForBeaming = true; - FrmPopupForm( XW_DICTINFO_FORM ); - break; - - case XW_BEAMBOARD_PULLDOWN_ID: - beamBoard( globals ); - break; - -#ifdef FEATURE_DUALCHOOSE - /* This probably goes away at ship.... */ - case XW_RUN68K_PULLDOWN_ID: - case XW_RUNARM_PULLDOWN_ID: { - Err err; - LocalID dbID; - - (void)FtrUnregister( APPID, FEATURE_WANTS_68K ); - err = FtrSet( APPID, FEATURE_WANTS_68K, - event->data.menu.itemID == XW_RUN68K_PULLDOWN_ID? - WANTS_68K : WANTS_ARM ); - - dbID = DmFindDatabase( CARD_0, APPNAME ); - if ( dbID != 0 ) { - (void)SysUIAppSwitch( 0, dbID, - sysAppLaunchCmdNormalLaunch, NULL ); - } - } - break; -#endif - - case XW_PASSWORDS_PULLDOWN_ID: - globals->isNewGame = false; - FrmPopupForm( XW_NEWGAMES_FORM ); - break; - -#ifdef COLOR_EDIT - case XW_EDITCOLORS_PULLDOWN_ID: - if ( globals->able == COLOR ) { - FrmPopupForm( XW_COLORPREF_DIALOG_ID ); - } - break; -# ifdef DEBUG - case XW_DUMPCOLORS_PULLDOWN_ID: - dumpColors( globals ); - break; -# endif -#endif - - case XW_PREFS_PULLDOWN_ID: - globals->stateTypeIsGlobal = XP_TRUE; - GlobalPrefsToLocal( globals ); - FrmPopupForm( XW_PREFS_FORM ); - break; - - case XW_ABOUT_PULLDOWN_ID: - palmaskFromStrId( globals, STR_ABOUT_CONTENT, STR_ABOUT_TITLE ); - break; - - case XW_HINT_PULLDOWN_ID: - board_resetEngine( globals->game.board ); - globals->askTrayLimits = XP_FALSE; - - case XW_NEXTHINT_PULLDOWN_ID: - draw = handleHintRequest( globals ); - break; - -#ifdef XWFEATURE_SEARCHLIMIT - case XW_HINTCONFIG_PULLDOWN_ID: - board_resetEngine( globals->game.board ); - globals->askTrayLimits = XP_TRUE; - draw = handleHintRequest( globals ); - break; -#endif - - case XW_UNDOCUR_PULLDOWN_ID: - draw = board_replaceTiles( globals->game.board ); - break; - - case XW_UNDOLAST_PULLDOWN_ID: - draw = server_handleUndo( globals->game.server ); - break; - - case XW_DONE_PULLDOWN_ID: - draw = handleDone( globals ); - break; - - case XW_JUGGLE_PULLDOWN_ID: - draw = handleJuggle( globals ); - break; - - case XW_TRADEIN_PULLDOWN_ID: - draw = handleTrade( globals ); - break; - - case XW_HIDESHOWTRAY_PULLDOWN_ID: - draw = handleHideTray( globals ); - break; - -#ifdef FOR_GREMLINS - case XW_GREMLIN_DIVIDER_RIGHT: - if ( !!globals->game.board ) { - board_moveDivider( globals->game.board, XP_TRUE ); - draw = XP_TRUE; - } - break; - case XW_GREMLIN_DIVIDER_LEFT: - if ( !!globals->game.board ) { - board_moveDivider( globals->game.board, XP_FALSE ); - draw = XP_TRUE; - } - break; -#endif - -#ifdef DEBUG - case XW_LOGFILE_PULLDOWN_ID: - toggleBoolFtr( LOG_FILE_FEATURE ); - break; - case XW_LOGMEMO_PULLDOWN_ID: - toggleBoolFtr( LOG_MEMO_FEATURE ); - break; - - case XW_CLEARLOGS_PULLDOWN_ID: - PalmClearLogs(); - break; -# if 0 - case XW_RESET_PULLDOWN_ID: { - postEmptyEvent( appStopEvent ); - } - - globals->resetGame = true; - break; -# endif - - case XW_NETSTATS_PULLDOWN_ID: - if ( !!globals->game.comms ) { - stream = makeSimpleStream( globals, askOnClose ); - comms_getStats( globals->game.comms, stream ); - stream_destroy( stream ); - } - break; -#if defined XWFEATURE_BLUETOOTH && defined DEBUG - case XW_BTSTATS_PULLDOWN_ID: - stream = makeSimpleStream( globals, askOnClose ); - palm_bt_getStats( globals, stream ); - stream_destroy( stream ); - break; -#endif - -#ifdef MEM_DEBUG - case XW_MEMSTATS_PULLDOWN_ID : - if ( !!globals->mpool ) { - stream = makeSimpleStream( globals, askOnClose ); - mpool_stats( globals->mpool, stream ); - stream_destroy( stream ); - } - break; -#endif - -#endif - - default: - break; - } - break; - -#ifdef XWFEATURE_FIVEWAY - case frmObjectFocusTakeEvent: - case frmObjectFocusLostEvent: - handled = globals->hasTreoFiveWay - && handleFocusEvent( globals, event, &draw ); - break; -#endif - - case keyUpEvent: - XP_ASSERT( globals->generatesKeyUp ); - /* work around not yet being able to set generatesKeyUp accurately - using FtrGet */ - if ( !globals->generatesKeyUp ) { - globals->generatesKeyUp = XP_TRUE; - globals->keyDownReceived = XP_FALSE; /* drop the event this once */ - } else if ( globals->keyDownReceived ) { - globals->keyDownReceived = XP_FALSE; - draw = handleKeyEvent( globals, event, &handled ); - } - break; - case keyDownEvent: - if ( !globals->menuIsDown ) { - globals->keyDownReceived = XP_TRUE; - draw = handleKeyEvent( globals, event, &handled ); - } - break; - - case sclRepeatEvent: - draw = scrollBoard( globals, event->data.sclRepeat.newValue-SBAR_MIN, - true ); - handled = false; - break; - - case ctlSelectEvent: - handled = true; - switch ( event->data.ctlEnter.controlID ) { - case XW_MAIN_FLIP_BUTTON_ID: - draw = handleFlip( globals ); - break; - case XW_MAIN_VALUE_BUTTON_ID: - draw = handleValueToggle( globals ); - break; - case XW_MAIN_HINT_BUTTON_ID: - draw = handleHintRequest( globals ); - break; -#ifndef EIGHT_TILES - case XW_MAIN_DONE_BUTTON_ID: - draw = handleDone( globals ); - break; - case XW_MAIN_JUGGLE_BUTTON_ID: - draw = handleJuggle( globals ); - break; - case XW_MAIN_TRADE_BUTTON_ID: - draw = handleTrade( globals ); - break; - case XW_MAIN_HIDE_BUTTON_ID: - draw = handleHideTray( globals ); - break; -#endif - case XW_MAIN_SHOWTRAY_BUTTON_ID: - draw = board_showTray( globals->game.board ); - break; - - default: - handled = false; - break; - } /* switch event->data.ctlEnter.controlID */ - - default: - handled = false; - break; - } - - if ( draw && !!globals->game.board && !globals->menuIsDown ) { - XP_Bool drewAll = board_draw( globals->game.board ); - if ( !drewAll ) { - globals->msgReceivedDraw = XP_TRUE; - palm_util_requestTime( &globals->util ); - } - } - - CALLBACK_EPILOGUE(); - return handled; -} /* mainViewHandleEvent */ - -static void -askStartNewGame( PalmAppGlobals* globals ) -{ - if ( palmaskFromStrId( globals, STR_ASK_REPLACE_GAME, -1 )) { - /* do nothing; popping up the NEWGAMES dlg will do it -- if not - cancelled */ - globals->newGameIsNew = XP_FALSE; - } else { - saveOpenGame( globals ); - - drawChangedBoard( globals ); - - globals->newGameIsNew = XP_TRUE; - } - globals->isNewGame = true; - globals->isFirstLaunch = false; - FrmPopupForm( XW_NEWGAMES_FORM ); -} /* askStartNewGame */ - -static void -displayFinalScores( PalmAppGlobals* globals ) -{ - XWStreamCtxt* stream; - - stream = makeSimpleStream( globals, NULL ); - server_writeFinalScores( globals->game.server, stream ); - stream_putU8( stream, '\0' ); - - (void)askFromStream( globals, stream, STR_FINAL_SCORES_TITLE, true ); -} /* displayFinalScores */ - -XP_S16 -palm_memcmp( XP_U8* p1, XP_U8* p2, XP_U16 nBytes ) -{ - /* man memcmp: The memcmp() function compares the first n bytes of the - memory areas s1 and s2. It returns an integer less than, equal to, or - greater than zero if s1 is found, respectively, to be less than, to - match, or be greater than s2.*/ - XP_S16 result = 0; - while ( result == 0 && nBytes-- ) { - result = *p1++ - *p2++; - } - return result; -} /* palm_memcmp */ - -static void -askScrollbarAdjust( PalmAppGlobals* globals, FieldPtr field ) -{ - UInt16 scrollPos; - UInt16 textHeight; - UInt16 fieldHeight; - UInt16 maxValue; - ScrollBarPtr scroll; - - FldGetScrollValues( field, &scrollPos, &textHeight, &fieldHeight ); - - if ( textHeight > fieldHeight ) { - maxValue = textHeight - fieldHeight; - } else if ( scrollPos != 0 ) { - maxValue = scrollPos; - } else { - maxValue = 0; - } - - scroll = getActiveObjectPtr( XW_ASK_SCROLLBAR_ID ); - SclSetScrollBar( scroll, scrollPos, 0, maxValue, fieldHeight-1 ); - globals->prevScroll = scrollPos; -} /* askScrollbarAdjust */ - -static void -getWindowBounds( WinHandle wHand, RectangleType* r ) -{ - WinHandle prev = WinSetDrawWindow( wHand ); - WinGetDrawWindowBounds( r ); - (void)WinSetDrawWindow( prev ); -} /* getWindowBounds */ - -static void -tryGrowAskToFit( FormPtr form, FieldPtr field, const XP_UCHAR* str ) -{ - RectangleType fieldRect, dlgRect; - UInt16 scrollPos; - UInt16 textHeight; - UInt16 fieldHeight; - WinHandle wHand; - XP_S16 fldWidth, fldHeight, maxHeight, needsHeight; - XP_U16 lineHeight; - XP_U16 growthAmt, i; - RectangleType objBounds; - - FldGetScrollValues( field, &scrollPos, &textHeight, &fieldHeight ); - - getObjectBounds( XW_ASK_TXT_FIELD_ID, &fieldRect ); - fldWidth = fieldRect.extent.x; - fldHeight = fieldRect.extent.y; - - /* max is cur height plus diff between dialog's height and what it could - be */ - wHand = FrmGetWindowHandle( form ); - getWindowBounds( wHand, &dlgRect ); - maxHeight = fldHeight + (156 - dlgRect.extent.y); - - lineHeight = FntLineHeight(); - - needsHeight = FldCalcFieldHeight((const char*)str, fldWidth) * lineHeight; - - if ( needsHeight > maxHeight ) { - /* make window as large as it can be */ - needsHeight = maxHeight; - } - - /* now round down to a multiple of lineHeight */ - needsHeight = (needsHeight / lineHeight) * lineHeight; - - growthAmt = needsHeight - fldHeight; - - /* now reflect the new size by moving things around. Window first */ - dlgRect.topLeft.y -= growthAmt; - dlgRect.extent.y += growthAmt; - WinSetBounds( wHand, &dlgRect ); - - /* then the field */ - fieldRect.extent.y += growthAmt; - setObjectBounds( XW_ASK_TXT_FIELD_ID, &fieldRect ); - - /* the scrollbar */ - getObjectBounds( XW_ASK_SCROLLBAR_ID, &objBounds ); - objBounds.extent.y = fieldRect.extent.y; - setObjectBounds( XW_ASK_SCROLLBAR_ID, &objBounds ); - - /* and the buttons */ - XP_ASSERT( XW_ASK_NO_BUTTON_ID - XW_ASK_YES_BUTTON_ID == 1 ); - for ( i = XW_ASK_YES_BUTTON_ID; i <= XW_ASK_NO_BUTTON_ID; ++i ){ - getObjectBounds( i, &objBounds ); - objBounds.topLeft.y += growthAmt; - setObjectBounds( i, &objBounds ); - } -} /* tryGrowAskToFit */ - -static Boolean -handleScrollInAsk( EventPtr event ) -{ - UInt16 linesToScroll = 0; - Boolean scrollFromButton = false; - Boolean result = true; - WinDirectionType direction = 5; - PalmAppGlobals* globals = (PalmAppGlobals*)getFormRefcon(); - FieldPtr field; - UInt16 endPosition; - - XP_ASSERT ( !!globals ); - - field = getActiveObjectPtr( XW_ASK_TXT_FIELD_ID ); - - switch ( event->eType ) { - - case penUpEvent: - /* When user drags pen through text and causes a scroll the scrollbar - will get out of sync. So we listen to the event but don't claim to - have handled it. */ - askScrollbarAdjust( globals, field ); - result = false; - break; - - case keyDownEvent: - if ( globals->ignoreFirstKeyDown ) { - globals->ignoreFirstKeyDown = XP_FALSE; - XP_ASSERT( result ); - } else if ( FrmGetWindowHandle( FrmGetActiveForm() ) - == WinGetDrawWindow() ) { - /* don't scroll a menu if open! */ - switch ( event->data.keyDown.chr ) { - case pageUpChr: - case vchrRockerUp: - direction = winUp; - break; - case pageDownChr: - case vchrRockerDown: - direction = winDown; - break; - default: - result = false; - } - linesToScroll = 3; - scrollFromButton = true; - } - break; - - case sclRepeatEvent: { - XP_S16 newVal = event->data.sclRepeat.newValue; - XP_S16 tmp = newVal - globals->prevScroll; - linesToScroll = XP_ABS( tmp ); - XP_ASSERT( linesToScroll != 0 ); - direction = newVal > globals->prevScroll? winDown: winUp; - globals->prevScroll = newVal; - scrollFromButton = false; - } - break; - - case menuEvent: - MenuEraseStatus(0); - result = true; - switch ( event->data.menu.itemID ) { - case ASK_COPY_PULLDOWN_ID: - FldCopy( field ); - break; - case ASK_SELECTALL_PULLDOWN_ID: - endPosition = FldGetTextLength( field ); - FldSetSelection( field, 0, endPosition ); - break; - } - break; - - default: - result = false; - } - - if ( result && FldScrollable( field, direction ) ) { - FldScrollField( field, linesToScroll, direction ); - if ( scrollFromButton ) { - askScrollbarAdjust( globals, field ); - } else { - result = false; /* for some reason this is necessary to make - scrolbar work right. */ - } - } - - return result; -} /* handleScrollInAsk */ - -/* Swap the two elements, preserving their outside borders */ -static void -moveLeftOf( UInt16 rightID, UInt16 leftID ) -{ - UInt16 leftIndex, rightIndex; - UInt16 middleMargin; - RectangleType leftBounds, rightBounds; - FormPtr form = FrmGetActiveForm(); - - leftIndex = FrmGetObjectIndex( form, leftID ); - rightIndex = FrmGetObjectIndex( form, rightID ); - - FrmGetObjectBounds( form, rightIndex, &rightBounds ); - FrmGetObjectBounds( form, leftIndex, &leftBounds ); - - XP_ASSERT( rightBounds.topLeft.y == leftBounds.topLeft.y ); - - middleMargin = rightBounds.topLeft.x - - (leftBounds.topLeft.x+leftBounds.extent.x); - - FrmSetObjectPosition( form, rightIndex, leftBounds.topLeft.x, - leftBounds.topLeft.y ); - - FrmSetObjectPosition( - form, leftIndex, - leftBounds.topLeft.x + rightBounds.extent.x + middleMargin, - leftBounds.topLeft.y ); - -} /* moveLeftOf */ - -XP_Bool -palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId, XP_S16 titleID ) -{ - const XP_UCHAR* message; - const XP_UCHAR* yes; - message = getResString( globals, strId ); - XP_ASSERT( !!message ); - yes = titleID < 0? NULL: getResString( globals, STR_OK ); - return palmask( globals, message, yes, titleID ); -} /* palmaskFromStrId */ - -XP_Bool -palmask( PalmAppGlobals* globals, const XP_UCHAR* str, - const XP_UCHAR* yesButton, XP_S16 titleID ) -{ - FormPtr form, prevForm; - FieldPtr field; - const XP_UCHAR* title; - UInt16 buttonHit; - XP_U16 buttons[] = { XW_ASK_YES_BUTTON_ID, XW_ASK_NO_BUTTON_ID }; - XP_U16 nButtons; - - if ( !!globals->game.board ) { - board_pushTimerSave( globals->game.board ); - } - - title = titleID >= 0? getResString( globals, titleID ): NULL; - - prevForm = FrmGetActiveForm(); - form = FrmInitForm( XW_ASK_FORM_ID ); - - FrmSetActiveForm( form ); - - if ( !!yesButton ) { - CtlSetLabel( getActiveObjectPtr(XW_ASK_YES_BUTTON_ID), - (const char*)yesButton ); - fitButtonToString( XW_ASK_YES_BUTTON_ID ); - } - - /* Hack: take advantage of fact that for now only non-queries should not - have a cancel button. */ - if ( title == NULL ) { - nButtons = 2; - } else { - FrmSetTitle( form, (char*)title ); - disOrEnable( form, XW_ASK_NO_BUTTON_ID, false ); - nButtons = 1; - } - /* always center: some localized buttons are bigger */ - centerControls( form, buttons, nButtons ); - - /* If we're running OS5 (oneDotFiveAvail), then eat the first keyDown. - If an earlier OS (Treo600) then we won't see that spurious event. */ - if ( globals->handlingKeyEvent && globals->oneDotFiveAvail ) { - globals->ignoreFirstKeyDown = XP_TRUE; - } - - FrmSetEventHandler( form, handleScrollInAsk ); - - globals->prevScroll = 0; - - if ( globals->isLefty ) { - moveLeftOf( XW_ASK_SCROLLBAR_ID, XW_ASK_TXT_FIELD_ID ); - } - - field = getActiveObjectPtr( XW_ASK_TXT_FIELD_ID ); - FldSetTextPtr( field, (char*)str ); - - FldRecalculateField( field, true ); - - if ( globals->romVersion >= 35 ) { - /* I'm not sure how to do this pre 3.5 */ - tryGrowAskToFit( form, field, str ); - } - - askScrollbarAdjust( globals, field ); - - FrmDrawForm( form ); - - buttonHit = FrmDoDialog( form ); - - FrmDeleteForm( form ); - FrmSetActiveForm( prevForm ); - - if ( !!globals->game.board ) { - board_popTimerSave( globals->game.board ); - } - - return buttonHit == XW_ASK_YES_BUTTON_ID; -} /* palmask */ - -static XP_Bool -askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream, XP_S16 titleID, - Boolean closeAndDestroy ) -{ - XP_U16 nBytes = stream_getSize( stream ); - XP_Bool result; - XP_UCHAR* buffer; - - XP_ASSERT( nBytes < maxFieldTextLen ); - - buffer = XP_MALLOC( globals->mpool, nBytes + 1 ); - stream_getBytes( stream, buffer, nBytes ); - /* nuke trailing chars to they don't extend length of field */ - while ( buffer[nBytes-1] == '\n' ) { - --nBytes; - } - buffer[nBytes] = '\0'; /* just to be safe */ - - result = palmask( globals, buffer, - getResString( globals, STR_OK ), titleID ); - - XP_FREE( globals->mpool, buffer ); - - if ( closeAndDestroy ) { - stream_destroy( stream ); - } - - return result; -} /* askFromStream */ - -XP_Bool -askPassword( PalmAppGlobals* globals, const XP_UCHAR* name, XP_Bool isNew, - XP_UCHAR* retbuf, XP_U16* len ) -{ - XP_Bool result = XP_FALSE; - FormPtr prevForm, form; - FieldPtr field; - UInt16 showMe; - - prevForm = FrmGetActiveForm(); - form = FrmInitForm( XW_PASSWORD_DIALOG_ID ); - FrmSetActiveForm( form ); - - if ( isNew ) { - showMe = XW_PASSWORD_NEWNAME_LABEL; - } else { - showMe = XW_PASSWORD_NAME_LABEL; - } - FrmShowObject( form, FrmGetObjectIndex( form, showMe ) ); - - FrmDrawForm( form ); - - if ( !!name ) { - field = getActiveObjectPtr( XW_PASSWORD_NAME_FIELD ); - FldSetTextPtr( field, (char*)name ); - FldDrawField( field ); - } - - if ( !globals->hasTreoFiveWay ) { - FrmSetFocus( form, FrmGetObjectIndex( form, XW_PASSWORD_PASS_FIELD ) ); - } - - if ( FrmDoDialog( form ) == XW_PASSWORD_OK_BUTTON ) { - char* enteredPass; - XP_U16 enteredLen; - field = getActiveObjectPtr( XW_PASSWORD_PASS_FIELD ); - enteredPass = FldGetTextPtr( field ); - enteredLen = enteredPass? StrLen(enteredPass) : 0; - if ( enteredLen < *len ) { - result = XP_TRUE; - if ( enteredLen > 0 ) { - XP_MEMCPY( retbuf, enteredPass, enteredLen ); - } - retbuf[enteredLen] = '\0'; - *len = enteredLen; - } - } - - FrmDeleteForm( form ); - FrmSetActiveForm( prevForm ); - - return result; -} /* askPassword */ - -/***************************************************************************** - * Callbacks - ****************************************************************************/ -static VTableMgr* -palm_util_getVTManager( XW_UtilCtxt* uc ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - return globals->vtMgr; -} /* palm_util_getVTManager */ - -static void -palm_util_userError( XW_UtilCtxt* uc, UtilErrID id ) -{ - PalmAppGlobals* globals; - XP_U16 strID = STR_LAST_STRING; - - switch( id ) { - case ERR_TILES_NOT_IN_LINE: - strID = STR_ALL_IN_LINE_ERR; - break; - case ERR_NO_EMPTIES_IN_TURN: - strID = STR_NO_EMPTIES_ERR; - break; - - case ERR_TWO_TILES_FIRST_MOVE: - strID = STR_FIRST_MOVE_ERR; - break; - case ERR_TILES_MUST_CONTACT: - strID = STR_MUST_CONTACT_ERR; - break; - case ERR_NOT_YOUR_TURN: - strID = STR_NOT_YOUR_TURN; - break; - case ERR_NO_PEEK_ROBOT_TILES: - strID = STR_NO_PEEK_ROBOT_TILES; - break; - -#ifndef XWFEATURE_STANDALONE_ONLY - case ERR_NO_PEEK_REMOTE_TILES: - strID = STR_NO_PEEK_REMOTE_TILES; - break; - case ERR_SERVER_DICT_WINS: - strID = STR_SERVER_DICT_WINS; - break; - case ERR_REG_UNEXPECTED_USER: - strID = STR_REG_UNEXPECTED_USER; - break; - case ERR_REG_SERVER_SANS_REMOTE: - strID = STR_REG_NEED_REMOTE; - break; - case STR_NEED_BT_HOST_ADDR: - strID = STR_REG_BT_NEED_HOST; - break; -#endif - - case ERR_CANT_TRADE_MID_MOVE: - strID = STR_CANT_TRADE_MIDTURN; - break; - - case ERR_TOO_FEW_TILES_LEFT_TO_TRADE: - strID = STR_TOO_FEW_TILES; - break; - - case ERR_CANT_UNDO_TILEASSIGN: - strID = STR_CANT_UNDO_TILEASSIGN; - break; - - case ERR_CANT_HINT_WHILE_DISABLED: - strID = STR_CANT_HINT_WHILE_DISABLED; - break; - -#ifdef XWFEATURE_RELAY - case ERR_RELAY_BASE + XWRELAY_ERROR_TIMEOUT: - strID = STR_RELAY_TIMEOUT; - break; - case ERR_RELAY_BASE + XWRELAY_ERROR_HEART_YOU: - strID = STR_RELAY_GENERIC; - break; - case ERR_RELAY_BASE + XWRELAY_ERROR_HEART_OTHER: - case ERR_RELAY_BASE + XWRELAY_ERROR_LOST_OTHER: - strID = STR_RELAY_LOST_OTHER; - break; -#endif - - default: - XP_DEBUGF( "errcode=%d", id ); - break; - } - - XP_LOGF( "%s(%d)", __func__, strID ); - - XP_ASSERT( strID < STR_LAST_STRING ); - globals = (PalmAppGlobals*)uc->closure; - userErrorFromStrId( globals, strID ); -} /* palm_util_userError */ - -static void -userErrorFromStrId( PalmAppGlobals* globals, XP_U16 strID ) -{ - const XP_UCHAR* message = getResString( globals, strID ); - keySafeCustomAlert( globals, message ); -} /* userErrorFromStrId */ - -static XP_Bool -palm_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - XP_U16 strID = STR_LAST_STRING; /* error if not changed */ - - switch( id ) { - case QUERY_COMMIT_TURN: - return askFromStream( globals, stream, -1, false ); - break; - case QUERY_COMMIT_TRADE: - strID = STR_CONFIRM_TRADE; - break; - case QUERY_ROBOT_MOVE: - case QUERY_ROBOT_TRADE: - return askFromStream( globals, stream, STR_ROBOT_TITLE, false ); - break; - default: - XP_ASSERT(0); - break; - } - - return (XP_Bool)palmaskFromStrId( globals, strID, -1 ); -} /* palm_util_userQuery */ - -static XWBonusType -palm_util_getSquareBonus( XW_UtilCtxt* uc, const ModelCtxt* model, - XP_U16 col, XP_U16 row ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - XP_U16 nCols, nRows; - XP_U16 midCol, index, resIndex; - XP_UCHAR* bonusResPtr; - XP_U8 value; - - XP_ASSERT( !!model ); - - nCols = model_numCols( model ); - nRows = model_numRows( model ); - midCol = nCols / 2; - resIndex = (PALM_MAX_COLS - nCols) / 2; - bonusResPtr = globals->bonusResPtr[resIndex]; - - if ( col > midCol ) col = nCols - 1 - col; - if ( row > midCol ) row = nRows - 1 - row; - index = (row*(midCol+1)) + col; - - XP_ASSERT( index/2 < MemPtrSize(bonusResPtr) ); - - value = bonusResPtr[index/2]; - if ( index%2 == 0 ) { - value >>= 4; - } - - return value & 0x0F; -} /* palm_util_getSquareBonus */ - -static XP_S16 -palm_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi, - XP_U16 playerNum, const XP_UCHAR** texts, - XP_U16 nTiles ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - return askBlankValue( globals, playerNum, pi, nTiles, texts ); -} /* palm_util_userPickTile */ - -static XP_Bool -palm_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name, - XP_UCHAR* buf, XP_U16* len ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - return askPassword( globals, name, false, buf, len ); -} /* palm_util_askPassword */ - -static void -palm_util_trayHiddenChange( XW_UtilCtxt* uc, - XW_TrayVisState XP_UNUSED(newState), - XP_U16 XP_UNUSED(nVisibleRows) ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - palmSetCtrlsForTray( globals ); - - drawFormButtons( globals ); -} /* palm_util_trayHiddenChange */ - -static void -palm_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 XP_UNUSED_DBG(oldOffset), - XP_U16 newOffset ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - XP_ASSERT( oldOffset != newOffset ); - updateScrollbar( globals, newOffset ); -} /* palm_util_yOffsetChange */ - -static void -palm_util_notifyGameOver( XW_UtilCtxt* uc ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - board_draw( globals->game.board ); /* refresh scoreboard so it agrees - with dialog */ - displayFinalScores( globals ); -} /* palm_util_notifyGameOver */ - -static XP_Bool -palm_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row ) -{ - /* EvtSysEventAvail, not EvtEventAvail, because the former ignores nil - events, and it appears that when there's an IR connection up the - system floods us with nil events.*/ - XP_Bool eventPending = EvtSysEventAvail( true ); -#ifdef SHOW_PROGRESS - if ( !eventPending ) { - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - if ( globals->progress.curLine >= 0 ) { - board_hiliteCellAt( globals->game.board, col, row ); - } - } -#endif - - return !eventPending; -} /* palm_util_hiliteCell */ - -static XP_Bool -palm_util_engineProgressCallback( XW_UtilCtxt* uc ) -{ -#ifdef SHOW_PROGRESS - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - if ( globals->gState.showProgress && globals->progress.curLine >= 0 ) { - RectangleType rect = globals->progress.boundsRect; - short line; - Boolean draw; - - globals->progress.curLine %= rect.extent.y * 2; - draw = globals->progress.curLine < rect.extent.y; - - line = globals->progress.curLine % (rect.extent.y) + 1; - line = rect.topLeft.y + rect.extent.y - line; - if ( draw ) { - WinDrawLine( rect.topLeft.x, line, - rect.topLeft.x + rect.extent.x - 1, line); - } else { - WinEraseLine( rect.topLeft.x, line, - rect.topLeft.x + rect.extent.x - 1, - line ); - } - ++globals->progress.curLine; - } -#endif - return !EvtSysEventAvail( true ); -} /* palm_util_engineProgressCallback */ - -static void -palm_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, - XP_U16 secsFromNow, - XWTimerProc proc, void* closure ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - XP_U32 now = TimGetTicks(); - - if ( why == TIMER_PENDOWN ) { - now += PALM_TIMER_DELAY; - } else if ( why == TIMER_TIMERTICK ) { - now += SysTicksPerSecond(); -#if defined XWFEATURE_RELAY || defined COMMS_HEARTBEAT - } else if ( why == TIMER_COMMS ) { - now += (secsFromNow * SysTicksPerSecond()); -#endif -#ifdef XWFEATURE_BLUETOOTH - } else if ( why == TIMER_ACL_BACKOFF ) { - now += (secsFromNow * SysTicksPerSecond()); -#endif - } else { - XP_ASSERT( 0 ); - } - - XP_ASSERT( why < VSIZE(globals->timerProcs) ); - globals->timerProcs[why] = proc; - globals->timerClosures[why] = closure; - globals->timerFireAt[why] = now; - - /* Post an event to force us back out of EvtGetEvent. Required if this - * is called from inside some BT callback. */ - postEmptyEvent( noopEvent ); -} /* palm_util_setTimer */ - -static void -palm_util_clearTimer( XW_UtilCtxt* uc, XWTimerReason why ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - globals->timerProcs[why] = NULL; -} - -static XP_Bool -palm_util_altKeyDown( XW_UtilCtxt* XP_UNUSED(uc) ) -{ - XP_LOGF( "%s unimplemented", __func__ ); - return XP_FALSE; -} - -static void -palm_util_requestTime( XW_UtilCtxt* uc ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - globals->timeRequested = true; -} /* palm_util_requestTime */ - -static XP_U32 -palm_util_getCurSeconds( XW_UtilCtxt* XP_UNUSED(uc) ) -{ - return TimGetSeconds(); -} /* palm_util_getCurSeconds */ - -static DictionaryCtxt* -palm_util_makeEmptyDict( XW_UtilCtxt* uc ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - DictionaryCtxt* result = palm_dictionary_make( MPPARM(uc->mpool) - globals, NULL, NULL ); - XP_ASSERT( !!result ); - return result; -} /* palm_util_makeEmptyDict */ - -#ifndef XWFEATURE_STANDALONE_ONLY -static XWStreamCtxt* -palm_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_PlayerAddr channelNo ) -{ - XWStreamCtxt* stream; - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - - XP_ASSERT( !!globals->game.comms ); /* shouldn't be making stream in case - where can't send -- or should I - just be passing a null on-close - function? */ - XP_LOGF( "making stream for channel %d", channelNo ); - stream = makeSimpleStream( globals, palm_send_on_close ); - stream_setAddress( stream, channelNo ); - return stream; -} /* palm_util_makeStreamFromAddr */ -#endif - -static void -palm_send_on_close( XWStreamCtxt* stream, void* closure ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - - XP_ASSERT( !!globals->game.comms ); - comms_send( globals->game.comms, stream ); -} /* palm_send_on_close */ - -#ifdef XWFEATURE_BLUETOOTH -static void -handleUserBTCancel( PalmAppGlobals* globals ) -{ - XP_ASSERT( !globals->userCancelledBT ); - globals->userCancelledBT = XP_TRUE; - userErrorFromStrId( globals, STR_BT_NOINIT ); -} -#endif - -static XP_S16 -palm_send( const XP_U8* buf, XP_U16 len, - const CommsAddrRec* addr, void* closure ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - XP_S16 result = 0; - - XP_ASSERT( !!globals->game.comms ); - - switch( comms_getConType( globals->game.comms ) ) { -#ifdef XWFEATURE_IR - case COMMS_CONN_IR: - result = palm_ir_send( buf, len, globals ); - break; -#endif -#ifdef XWFEATURE_RELAY - case COMMS_CONN_RELAY: - result = palm_ip_send( buf, len, addr, globals ); - globals->lastSendGood = result != -1; - break; -#endif -#ifdef XWFEATURE_BLUETOOTH - case COMMS_CONN_BT: - if ( !!globals->mainForm && !globals->userCancelledBT ) { - XP_Bool userCancelled; - result = palm_bt_send( buf, len, addr, globals, &userCancelled ); - if ( userCancelled ) { - handleUserBTCancel( globals ); - } - } - break; -#endif - default: - XP_ASSERT(0); - } - return result; -} /* palm_send */ - -#ifdef XWFEATURE_RELAY -static void -palm_relayStatus( void* closure, CommsRelayState newState ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - globals->netState.relayState = newState; - showConnState( globals ); -} -#endif - -#ifdef COMMS_HEARTBEAT -static void -palm_reset( void* closure ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)closure; - XP_ASSERT( !!globals->game.comms ); - - switch( comms_getConType( globals->game.comms ) ) { -#ifdef XWFEATURE_BLUETOOTH - case COMMS_CONN_BT: - palm_bt_reset( globals ); - break; -#endif - default: - XP_ASSERT(0); - break; - } -} -#endif - -void -checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr, - XWStreamCtxt* instream, CommsConnType conType ) -{ - /* For now we'll just drop incoming packets on transports not the same as - the current game's. We *could* however alert the user, or even - volunteer to switch e.g. from BT to IR as two passengers board a - plane. That'd require significant changes. */ - CommsCtxt* comms = globals->game.comms; - if ( !!comms && (conType == comms_getConType( comms )) ) { - if ( comms_checkIncomingStream( comms, instream, addr ) ) { - (void)server_receiveMessage( globals->game.server, instream ); - globals->msgReceivedDraw = true; - } - palm_util_requestTime( &globals->util ); - } - stream_destroy( instream ); -} /* checkAndDeliver */ - -static const XP_UCHAR* -palm_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - const XP_UCHAR* str = getResString( globals, stringCode ); - return str; -} /* palm_util_getUserString */ - -static void -formatBadWords( BadWordInfo* bwi, char buf[] ) -{ - XP_U16 i; - - for ( i = 0, buf[0] = '\0'; ; ) { - char wordBuf[18]; - StrPrintF( wordBuf, "\"%s\"", bwi->words[i] ); - StrCat( buf, wordBuf ); - if ( ++i == bwi->nWords ) { - break; - } - StrCat( buf, ", " ); - } -} /* formatBadWords */ - -static XP_Bool -palm_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, - XP_U16 XP_UNUSED(turn), - XP_Bool turnLost ) -{ - XP_Bool result = XP_TRUE; - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - - const XP_UCHAR* resStr = getResString( globals, - turnLost? STR_PHONY_REJECTED : STR_ILLEGAL_WORD ); - if ( turnLost ) { - keySafeCustomAlert( globals, resStr ); - } else { - char wordsBuf[150]; - XP_UCHAR buf[200]; - formatBadWords( bwi, wordsBuf ); - StrPrintF( (char*)buf, (const char*)resStr, wordsBuf ); - result = palmask( globals, buf, NULL, -1 ); - } - - return result; -} /* palm_util_warnIllegalWord */ - -static void -palm_util_remSelected(XW_UtilCtxt* uc) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - showRemaining( globals ); -} - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY -static void -palm_util_addrChange( XW_UtilCtxt* uc, - const CommsAddrRec* XP_UNUSED_RELAY(oldAddr), - const CommsAddrRec* newAddr ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - -# ifdef XWFEATURE_BLUETOOTH - XP_Bool isBT = COMMS_CONN_BT == newAddr->conType; - if ( !isBT ) { - XP_ASSERT( !!globals->mainForm ); - palm_bt_close( globals ); - showConnState( globals ); - } -# endif - - if ( 0 ) { -# ifdef XWFEATURE_RELAY - } else if ( COMMS_CONN_RELAY == newAddr->conType ) { - ip_addr_change( globals, oldAddr, newAddr ); - showConnState( globals ); -# endif -# ifdef XWFEATURE_BLUETOOTH - } else if ( isBT && !globals->userCancelledBT ) { - XP_Bool userCancelled; - XP_ASSERT( !!globals->mainForm ); - if ( !palm_bt_init( globals, &userCancelled ) ) { - if ( userCancelled ) { - handleUserBTCancel( globals ); - } - } -# endif - } -} /* palm_util_addrChange */ -#endif /* #if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY */ - -#ifdef XWFEATURE_SEARCHLIMIT -static XP_Bool -palm_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc), - XP_U16* min, XP_U16* max ) -{ - return doHintConfig( min, max ); -} /* palm_util_getTraySearchLimits */ -#endif - -#ifdef SHOW_PROGRESS -static void -palm_util_engineStarting( XW_UtilCtxt* uc, XP_U16 nBlanks ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - - if ( globals->gState.showProgress -#ifdef XW_TARGET_PNO - && ( nBlanks > 0 ) -#endif - ) { - RectangleType* bounds = &globals->progress.boundsRect; - - WinEraseRectangle( bounds, 0 ); - WinDrawRectangleFrame( rectangleFrame, bounds ); - - globals->progress.curLine = 0; - } else { - globals->progress.curLine = -1; - } -} /* palm_util_engineStarting */ - -static void -palm_util_engineStopping( XW_UtilCtxt* uc ) -{ - PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure; - if ( globals->gState.showProgress && globals->progress.curLine >= 0 ) { - - WinEraseRectangle( &globals->progress.boundsRect, 0 ); - WinEraseRectangleFrame( rectangleFrame, - &globals->progress.boundsRect ); - - if ( globals->needsScrollbar ) { - SclDrawScrollBar( getActiveObjectPtr( XW_MAIN_SCROLLBAR_ID ) ); - } - } -} /* palm_util_engineStopping */ -#endif diff --git a/xwords4/palm/palmmain.h b/xwords4/palm/palmmain.h deleted file mode 100644 index 660e19787..000000000 --- a/xwords4/palm/palmmain.h +++ /dev/null @@ -1,450 +0,0 @@ -/* -*-mode: C; fill-column: 76; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2007 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PALMMAIN_H_ -#define _PALMMAIN_H_ - -#define AppType APPID -#define PrefID 0 -#define VERSION_NUM_405 1 -#define VERSION_NUM 2 /* 1 to 2 moving to ARM */ - -#include -#include -#include -#include -#include -#include -#ifdef XWFEATURE_RELAY -# include -#endif - -#include "game.h" -#include "util.h" -#include "mempool.h" -#include "nwgamest.h" - -/* #include "prefsdlg.h" */ -#include "xwcolors.h" - -#include "xwords4defines.h" - -#ifdef MEM_DEBUG -# define MEMPOOL globals->mpool, -#else -# define MEMPOOL -#endif - - -enum { ONEBIT, /* GREYSCALE, */COLOR }; -typedef unsigned char GraphicsAbility; /* don't let above be 4 bytes */ -typedef struct PalmAppGlobals PalmAppGlobals; - -typedef const XP_UCHAR* (*GetResStringFunc)( PalmAppGlobals* globals, - XP_U16 strID ); - -typedef struct { - XP_S16 topOffset; /* how many pixels from the top of the - drawing area is the first pixel set in - the glyph */ - XP_U16 height; /* How many rows tall is the image? */ -} PalmFontHtInfo; - -typedef struct PalmDrawCtx { - DrawCtxVTable* vtable; - PalmAppGlobals* globals; - - void (*drawBitmapFunc)( DrawCtx* dc, Int16 resID, Int16 x, Int16 y ); - GetResStringFunc getResStrFunc; - - DrawingPrefs* drawingPrefs; - - RectangleType oldScoreClip; - RectangleType oldTrayClip; - - XP_S16 trayOwner; - XP_U16 fntHeight; - - GraphicsAbility able; - - UInt16 oldCoord; - XP_Bool doHiRes; - XP_Bool oneDotFiveAvail; - XP_Bool topFocus; - - XP_LangCode fontLangCode; - PalmFontHtInfo* fontHtInfo; - - union { - struct { - XP_U8 reserved; /* make CW compiler happy */ - } clr; - struct { - CustomPatternType valuePatterns[4]; - } bnw; - } u; - MPSLOT -} PalmDrawCtx; - -#define draw_drawBitmapAt(dc,id,x,y) \ - (*((((PalmDrawCtx*)dc))->drawBitmapFunc))((dc),(id),(x),(y)) - -typedef struct ListData { - unsigned char** strings; - unsigned char* storage; - XP_U16 nItems; - XP_U16 storageLen; - XP_U16 nextIndex; - XP_S16 selIndex; -#ifdef DEBUG - XP_Bool choicesSet; /* ARM hack: don't use strings after PACE - swaps.... */ -#endif -} ListData; - -typedef struct XWords4PreferenceType { - Int16 versionNum; - - Int16 curGameIndex; /* which game is currently open */ - - /* these are true global preferences */ - Boolean showProgress; - Boolean showGrid; - Boolean _unused; /* was showColors */ - Boolean reserved; /* was oneTimeShown */ - Boolean reserved1[4]; /* pad out to 12 for ARM */ - - /* New for 0x0405 */ - CommonPrefs cp; - - Int16 focusItem; -} XWords4PreferenceType; - -typedef struct MyIrConnect { - IrConnect irCon; - PalmAppGlobals* globals; -} MyIrConnect; - -typedef XP_U8 IR_STATE; /* enums are in palmir.h */ - -#define IR_BUF_SIZE 256 - -typedef struct MyIrPacket MyIrPacket; - -typedef struct ProgressCtxt { - RectangleType boundsRect; - XP_S16 curLine; -} ProgressCtxt; - -/* I *hate* having to define these globally... */ -typedef struct SavedGamesState { - struct PalmAppGlobals* globals; - FormPtr form; - ListPtr gamesList; - FieldPtr nameField; - char** stringPtrs; - Int16 nStrings; - Int16 displayGameIndex; -} SavedGamesState; - -typedef struct PrefsDlgState { - ListPtr playerBdSizeList; - ListPtr phoniesList; - - CommonPrefs cp; - - XP_U16 gameSeconds; - XP_Bool stateTypeIsGlobal; - - XP_U8 phoniesAction; - XP_U8 curBdSize; - XP_Bool smartRobot; - XP_Bool showProgress; - XP_Bool showGrid; - XP_Bool hintsNotAllowed; - XP_Bool timerEnabled; - XP_Bool allowPickTiles; - XP_Bool allowHintRect; -#ifdef XWFEATURE_BLUETOOTH - XP_Bool confirmBTConnect; -#endif -} PrefsDlgState; - -typedef struct DictState { - ListPtr dictList; - ListData sLd; - XP_U16 nDicts; -} DictState; - -typedef struct PalmNewGameState { - FormPtr form; - ListPtr playerNumList; - NewGameCtx* ngc; - XP_U16 nXPorts; - XP_UCHAR passwds[MAX_PASSWORD_LENGTH+1][MAX_NUM_PLAYERS]; - XP_UCHAR* dictName; - XP_UCHAR shortDictName[32]; /* as long as a dict name can be */ - - XP_Bool forwardChange; - DeviceRole curServerHilite; -#ifndef XWFEATURE_STANDALONE_ONLY - CommsAddrRec addr; -#endif -} PalmNewGameState; - -typedef struct PalmDictList PalmDictList; - -#ifdef XWFEATURE_RELAY -typedef struct NetLibStuff { - UInt16 netLibRef; - NetSocketRef socket; - XP_Bool ipAddrInval; -} NetLibStuff; -#define ipSocketIsOpen(g) ((g)->nlStuff.socket != -1) -#endif - -#define MAX_DLG_PARAMS 2 - -#ifdef XWFEATURE_BLUETOOTH -typedef enum { - BTUI_NOBT - , BTUI_NONE - , BTUI_LISTENING - , BTUI_CONNECTING - , BTUI_CONNECTED /* slave */ - , BTUI_SERVING /* master */ -} BtUIState; -#endif - -#ifdef XWFEATURE_BLUETOOTH -# define TIMER_ACL_BACKOFF NUM_TIMERS_PLUS_ONE -# define NUM_PALM_TIMERS (NUM_TIMERS_PLUS_ONE + 1) -#else -# define NUM_PALM_TIMERS NUM_TIMERS_PLUS_ONE -#endif - -struct PalmAppGlobals { - FormPtr mainForm; - PrefsDlgState* prefsDlgState; - SavedGamesState* savedGamesState; - XWGame game; - DrawCtx* draw; - XW_UtilCtxt util; - - XP_U32 dlgParams[MAX_DLG_PARAMS]; - - VTableMgr* vtMgr; - - XWords4PreferenceType gState; - - DrawingPrefs drawingPrefs; - - PalmDictList* dictList; - - DmOpenRef boardDBP; - LocalID boardDBID; - - DmOpenRef gamesDBP; - LocalID gamesDBID; - -#ifdef XWFEATURE_RELAY - UInt16 exgLibraryRef; /* what library did user choose for sending? */ -#endif - - XP_UCHAR* stringsResPtr; - XP_U8* bonusResPtr[NUM_BOARD_SIZES]; - Boolean penDown; - Boolean isNewGame; - Boolean stateTypeIsGlobal; - Boolean timeRequested; - Boolean hintPending; - Boolean isLefty; - Boolean dictuiForBeaming; - Boolean postponeDraw; - Boolean needsScrollbar; - Boolean msgReceivedDraw; - Boolean isFirstLaunch; - Boolean menuIsDown; - XP_Bool newGameIsNew; - XP_Bool runningOnPOSE; /* Needed for NetLibSelect */ -#ifdef XWFEATURE_FIVEWAY - XP_Bool isTreo600; -#endif -#ifdef XWFEATURE_BLUETOOTH - XP_Bool userCancelledBT; - XP_Bool hasBTLib; -#endif - - GraphicsAbility able; - XP_U16 prevScroll; /* for scrolling in 'ask' dialog */ - UInt16 romVersion; - - XP_U8 scrollValue; /* 0..2: scrolled position of board */ - -#ifdef SHOW_PROGRESS - ProgressCtxt progress; -#endif - - XP_U16 width, height; - XP_U16 sonyLibRef; - XP_Bool doVSK; - XP_Bool hasHiRes; - XP_Bool oneDotFiveAvail; - XP_Bool useHiRes; - XP_Bool hasTreoFiveWay; - XP_Bool generatesKeyUp; - XP_Bool isZodiac; - XP_Bool keyDownReceived; - XP_Bool initialTakeDropped; /* work around apparent OS bug */ - /* PalmOS seems pretty broken w.r.t. key events. If I put up a modal - dialog while in the process of handling a keyUp, that form gets a - keyDown (and not with the repeat bit set either.) Hack around it. */ - XP_Bool handlingKeyEvent; - XP_Bool ignoreFirstKeyDown; - - XP_U16 lastKeyDown; - -#ifdef XWFEATURE_SEARCHLIMIT - XP_Bool askTrayLimits; -#endif - - CurGameInfo gameInfo; /* for the currently open, or new, game */ - - /* dialog/forms state */ - PalmNewGameState newGameState; - - DictState dictState; - - struct ConnsDlgState* connState; - - XWTimerProc timerProcs[NUM_PALM_TIMERS]; - void* timerClosures[NUM_PALM_TIMERS]; - XP_U32 timerFireAt[NUM_PALM_TIMERS]; - -#ifdef XWFEATURE_RELAY - NetLibStuff nlStuff; - XP_U32 heartTimerFireAt; - XP_Bool lastSendGood; -#endif - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY - XP_U16 lastNetStatusRes; - -# ifdef XWFEATURE_BLUETOOTH - struct PalmBTStuff* btStuff; - XP_Bool suspendBT; -# endif - - union { -# ifdef XWFEATURE_BLUETOOTH - BtUIState btUIState; /* For showing user what's up */ -# endif -# ifdef XWFEATURE_RELAY - CommsRelayState relayState; -# endif - } netState; -#endif - -#ifdef DEBUG - UInt8 save_rLsap; - IR_STATE ir_state_prev; - XP_U16 yCount; -/* Boolean resetGame; */ -#endif - MPSLOT -}; /* PalmAppGlobals */ - -/* custom events */ -enum { noopEvent = firstUserEvent /* 0x6000 */ - ,dictSelectedEvent - ,newGameOkEvent - ,newGameCancelEvent - ,loadGameEvent - ,prefsChangedEvent - ,openSavedGameEvent -#ifdef XWFEATURE_FIVEWAY - ,updateAfterFocusEvent -#endif -#if defined XWFEATURE_BLUETOOTH - ,closeBtLibEvent -#endif -#ifdef FEATURE_SILK - ,doResizeWinEvent -#endif -}; - -enum { - PNOLET_STORE_FEATURE = 1 /* where FtrPtr to pnolet code lives */ - , GLOBALS_FEATURE /* for passing globals to form handlers */ - , LOG_FILE_FEATURE /* these three for debugging */ - , LOG_MEMO_FEATURE - , LOG_SCREEN_FEATURE -#ifdef FEATURE_DUALCHOOSE - , FEATURE_WANTS_68K /* support for (pre-ship) ability to choose - armlet or 68K */ -#endif -#ifdef XWFEATURE_COMBINEDAWG - , DAWG_STORE_FEATURE -#endif - , PACE_BT_CBK_FEATURE -}; -enum { WANTS_68K, WANTS_ARM }; - - -/* If we're calling the old PilotMain (in palmmain.c) from from the one in - enter68k.c it needs a different name. But if this is the 68K-only app - then that is the entry point. */ -#ifdef FEATURE_PNOAND68K -# define PM2(pm) pm2_ ## pm -UInt32 PM2(PilotMain)(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags); -#else -# define PM2(pm) pm -#endif - -DrawCtx* palm_drawctxt_make( MPFORMAL GraphicsAbility able, - PalmAppGlobals* globals, - GetResStringFunc getRSF, - DrawingPrefs* drawprefs ); -void palm_drawctxt_destroy( DrawCtx* dctx ); - -void palm_warnf( char* format, ... ); - -XP_Bool askPassword( PalmAppGlobals* globals, const XP_UCHAR* name, - XP_Bool isNew, XP_UCHAR* retbuf, XP_U16* len ); -XP_Bool palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId, - XP_S16 titleID ); -void freeSavedGamesData( MPFORMAL SavedGamesState* state ); - -void writeNameToGameRecord( PalmAppGlobals* globals, XP_S16 index, - char* newName, XP_U16 len ); - -const XP_UCHAR* getResString( PalmAppGlobals* globals, XP_U16 strID ); -XP_Bool palmask( PalmAppGlobals* globals, const XP_UCHAR* str, - const XP_UCHAR* altButton, XP_S16 titleID ); -void checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr, - XWStreamCtxt* instream, CommsConnType conType ); - -#ifdef XW_TARGET_PNO -# define READ_UNALIGNED16(n) read_unaligned16((unsigned char*)(n)) -#else -# define READ_UNALIGNED16(n) *(n) -#endif - -#define IS_T600(g) (g)->isTreo600 - -#endif /* _PALMMAIN_H_ */ diff --git a/xwords4/palm/palmsavg.c b/xwords4/palm/palmsavg.c deleted file mode 100644 index 9dc1dd58c..000000000 --- a/xwords4/palm/palmsavg.c +++ /dev/null @@ -1,261 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/**************************************************************************** - * * - * Copyright 1999, 2001 by Eric House (xwords@eehouse.org). All rights reserved. * - * * - * - * 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 -#include -#include - -#include "callback.h" -#include "strutils.h" -#include "palmsavg.h" -#include "palmmain.h" -#include "palmutil.h" -#include "gameutil.h" - -#include "xwords4defines.h" -#include "LocalizedStrIncludes.h" - -/* Prototypes */ -static void populateGameList( SavedGamesState* state ); -static void setFieldToSelText( SavedGamesState* state ); -static void listDrawFunc(Int16 index, RectanglePtr bounds, char** itemsText); - -/***************************************************************************** - * Handler for dictionary info form. - ****************************************************************************/ -#define USE_POPULATE 1 -Boolean -savedGamesHandleEvent( EventPtr event ) -{ - Boolean result; - PalmAppGlobals* globals; - SavedGamesState* state; - XP_S16 newGameIndex; - Int16* curGameIndexP; - char* newName; - - CALLBACK_PROLOGUE(); - - result = false; - globals = getFormRefcon(); - state = globals->savedGamesState; - - curGameIndexP = &globals->gState.curGameIndex; - - switch ( event->eType ) { - case frmOpenEvent: - - if ( !state ) { - state = globals->savedGamesState = XP_MALLOC( globals->mpool, - sizeof(*state) ); - } - XP_MEMSET( state, 0, sizeof(*state) ); - - state->globals = globals; - state->form = FrmGetActiveForm(); - - /* dictionary list setup */ - state->gamesList = getActiveObjectPtr( XW_SAVEDGAMES_LIST_ID ); - state->nameField = getActiveObjectPtr( XW_SAVEDGAMES_NAME_FIELD ); - state->displayGameIndex = globals->gState.curGameIndex; - XP_ASSERT( state->displayGameIndex < countGameRecords(globals) ); - - /* must preceed drawing calls so they have a valid window */ - FrmDrawForm( state->form ); - - /* LstSetDrawFunction must follow FrmDrawForm since populateGameList - must be called before listDrawFunc has valid globals; can't let - listDrawFunc get called from FrmDrawForm until set up correctly. */ - LstSetDrawFunction( state->gamesList, listDrawFunc ); - populateGameList( state ); - setFieldToSelText( state ); - break; - - case frmUpdateEvent: - FrmDrawForm( state->form ); - /* don't update field here! The keyboard may have been the form whose - disappearance triggered the frmUpdateEvent, and resetting the field - would undo the user's edits. Also causes a crash in Keyboard.c in - the ROMs for reasons I don't understand. */ - break; - - case lstSelectEvent: - state->displayGameIndex = LstGetSelection( state->gamesList ); - setFieldToSelText( state ); - result = true; - break; - - case ctlSelectEvent: - result = true; - switch ( event->data.ctlEnter.controlID ) { - - case XW_SAVEDGAMES_USE_BUTTON: /* write the new name to the selected - record */ - newName = FldGetTextPtr( state->nameField ); - if ( !!newName && (*newName != '\0') ) { - XP_U16 len = FldGetTextLength( state->nameField ); - writeNameToGameRecord( globals, state->displayGameIndex, - newName, len ); - - populateGameList( state ); - setFieldToSelText( state ); - } - break; - - case XW_SAVEDGAMES_DUPE_BUTTON: /* copy the selected record */ - newGameIndex = duplicateGameRecord( globals, - state->displayGameIndex ); - state->displayGameIndex = newGameIndex; - if ( *curGameIndexP >= newGameIndex ) { - ++*curGameIndexP; - } - populateGameList( state ); - setFieldToSelText( state ); - break; - - case XW_SAVEDGAMES_DELETE_BUTTON: /* delete the selected record. - Refuse if it's open. */ - if ( state->displayGameIndex == *curGameIndexP ) { - beep(); - } else if ( palmaskFromStrId( globals, STR_CONFIRM_DEL_GAME, -1) ) { - XP_S16 index = state->displayGameIndex; - deleteGameRecord( globals, index ); - if ( *curGameIndexP > index ) { - --*curGameIndexP; - } - if ( index == countGameRecords(globals) ) { - --index; - } - state->displayGameIndex = index; - populateGameList( state ); - } - break; - - case XW_SAVEDGAMES_OPEN_BUTTON: /* open the selected db if not already - open. */ - if ( *curGameIndexP != state->displayGameIndex ) { - EventType eventToPost = { .eType = openSavedGameEvent }; - ((OpenSavedGameData*)&eventToPost.data.generic)->newGameIndex - = state->displayGameIndex; - EvtAddEventToQueue( &eventToPost ); - globals->postponeDraw = true; - } - - case XW_SAVEDGAMES_DONE_BUTTON: - /* Update the app's idea of which record to save the current game - into -- in case any with lower IDs have been deleted. */ - FrmReturnToForm( 0 ); - - freeSavedGamesData( MPPARM(globals->mpool) state ); - - break; - } - - default: - break; - } /* switch */ - - CALLBACK_EPILOGUE(); - return result; -} /* savedGamesHandleEvent */ - -static void -setFieldToSelText( SavedGamesState* state ) -{ - FieldPtr field = state->nameField; - char name[MAX_GAMENAME_LENGTH]; - nameFromRecord( state->globals, state->displayGameIndex, name ); - XP_ASSERT( XP_STRLEN(name) < MAX_GAMENAME_LENGTH ); - XP_ASSERT( XP_STRLEN(name) > 0 ); - - FldSetSelection( field, 0, FldGetTextLength(field) ); - - FldInsert( field, name, XP_STRLEN(name) ); - FldSetSelection( field, 0, FldGetTextLength(field) ); -#ifdef XWFEATURE_FIVEWAY - setFormFocus( state->form, XW_SAVEDGAMES_NAME_FIELD ); -#endif - FldDrawField( field ); -} /* setFieldToSelText */ - -void -freeSavedGamesData( MPFORMAL SavedGamesState* state ) -{ - if ( !!state->stringPtrs ) { - XP_FREE( mpool, state->stringPtrs ); - state->stringPtrs = NULL; - } -} /* freeSavedGamesData */ - -static void -populateGameList( SavedGamesState* state ) -{ - XP_U16 nRecords; - PalmAppGlobals* globals = state->globals; - ListPtr gamesList = state->gamesList; - - nRecords = countGameRecords( globals ); - if ( state->nStrings != nRecords ) { - char** stringPtrs; - XP_U16 i; - - LstEraseList( gamesList ); - - freeSavedGamesData( MPPARM(globals->mpool) state ); - - state->nStrings = nRecords; - state->stringPtrs = stringPtrs = - XP_MALLOC( globals->mpool, - (nRecords+1) * sizeof(state->stringPtrs[0] ) ); - - stringPtrs[0] = (char*)globals; - for ( i = 1; i <= nRecords; ++i ) { - stringPtrs[i] = ""; - } - - LstSetListChoices( gamesList, &state->stringPtrs[1], nRecords ); - LstSetHeight( gamesList, XP_MIN(nRecords, 9) ); - } - - LstSetSelection( gamesList, state->displayGameIndex ); - XP_ASSERT( state->displayGameIndex < nRecords ); - LstMakeItemVisible( gamesList, state->displayGameIndex ); - LstDrawList( gamesList ); -} /* populateGameList */ - -static void -listDrawFunc( Int16 index, RectanglePtr bounds, char** itemsText ) -{ - char buf[MAX_GAMENAME_LENGTH]; - XP_U16 len; - PalmAppGlobals* globals; - - CALLBACK_PROLOGUE(); - - globals = (PalmAppGlobals*)itemsText[-1]; - - nameFromRecord( globals, index, buf ); - len = XP_STRLEN( buf ); - XP_ASSERT( len > 0 ); - WinDrawChars( buf, len, bounds->topLeft.x, bounds->topLeft.y ); - - CALLBACK_EPILOGUE(); -} /* listDrawFunc */ diff --git a/xwords4/palm/palmsavg.h b/xwords4/palm/palmsavg.h deleted file mode 100644 index 06a5db645..000000000 --- a/xwords4/palm/palmsavg.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/**************************************************************************** - * * - * Copyright 1999 - 2001 by Eric House (xwords@eehouse.org). All rights reserved. * - * * - * - * 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 _PALMSAVG_H_ -#define _PALMSAVG_H_ - -typedef struct OpenSavedGameData { - Int16 newGameIndex; -} OpenSavedGameData; - -Boolean savedGamesHandleEvent( EventPtr event ); - -#endif diff --git a/xwords4/palm/palmutil.c b/xwords4/palm/palmutil.c deleted file mode 100644 index 706518dfe..000000000 --- a/xwords4/palm/palmutil.c +++ /dev/null @@ -1,854 +0,0 @@ -// -*-mode: C; fill-column: 80; c-basic-offset: 4; -*- -/**************************************************************************** - * * - * Copyright 1998-2001 by Eric House (xwords@eehouse.org). All rights reserved. * - * * - * - * 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 -#include -#include -#include -#include -#include -#include -#ifdef XWFEATURE_FIVEWAY -# include -#endif - -#include "strutils.h" -#include "palmutil.h" -#include "xwords4defines.h" -#include "palmmain.h" -#include "palmdbg.h" -#include "comtypes.h" - -#define MEMO "MemoDB" -#define LOGFILE "XWLogfile" - -/***************************************************************************** - * This is meant to be replaced by an actual beep.... - ****************************************************************************/ -#if defined FEATURE_BEEP || defined XW_FEATURE_UTILS -void beep( void ) { - SndPlaySystemSound( sndError ); -} /* beep */ -#endif - -/***************************************************************************** - * - ****************************************************************************/ -MemPtr -getActiveObjectPtr( UInt16 objectID ) -{ - FormPtr form = FrmGetActiveForm(); - Int16 index = FrmGetObjectIndex( form, objectID ); - XP_ASSERT( index >= 0 ); - XP_ASSERT( FrmGetObjectPtr( form, index )!= NULL ); - return FrmGetObjectPtr( form, index ); -} /* getActiveObjectPtr */ - -/***************************************************************************** - * - ****************************************************************************/ -void -getObjectBounds( UInt16 objectID, RectangleType* rectP ) -{ - FormPtr form = FrmGetActiveForm(); - Int16 index = FrmGetObjectIndex( form, objectID ); - XP_ASSERT( index >= 0 ); - FrmGetObjectBounds( form, index, rectP ); -} /* getObjectBounds */ - -#if defined XW_FEATURE_UTILS -/***************************************************************************** - * - ****************************************************************************/ -void -setObjectBounds( UInt16 objectID, RectangleType* rectP ) -{ - FormPtr form = FrmGetActiveForm(); - Int16 index = FrmGetObjectIndex( form, objectID ); - XP_ASSERT( index >= 0 ); - FrmSetObjectBounds( form, index, rectP ); -} /* getObjectBounds */ - -/***************************************************************************** - * - ****************************************************************************/ -void -setBooleanCtrl( UInt16 objectID, Boolean isSet ) -{ - CtlSetValue( getActiveObjectPtr( objectID ), isSet ); -} /* setBooleanCtrl */ - -void -setFieldEditable( UInt16 objectID, Boolean editable ) -{ - FieldPtr fld = getActiveObjectPtr( objectID ); - FieldAttrType attrs; - - FldGetAttributes( fld, &attrs ); - if ( attrs.editable != editable ) { - attrs.editable = editable; - FldSetAttributes( fld, &attrs ); - } -} /* setFieldEditable */ - -void -postEmptyEvent( eventsEnum typ ) -{ - EventType eventToPost; - eventToPost.eType = typ; - EvtAddEventToQueue( &eventToPost ); -} /* postEmptyEvent */ - -void -disOrEnable( FormPtr form, UInt16 id, Boolean enable ) -{ - UInt16 index = FrmGetObjectIndex( form, id ); - FormObjectKind typ; - - if ( enable ) { - FrmShowObject( form, index ); - } else { - FrmHideObject( form, index ); - } - - typ = FrmGetObjectType( form, index ); - if ( typ == frmControlObj ) { - ControlPtr ctl = getActiveObjectPtr( id ); - CtlSetEnabled( ctl, enable ); - } -} /* disOrEnable */ - -void -disOrEnableTri( FormPtr form, UInt16 id, XP_TriEnable enable ) -{ - UInt16 index; - XP_ASSERT( enable != TRI_ENAB_NONE ); - - index = FrmGetObjectIndex( form, id ); - - if ( enable == TRI_ENAB_HIDDEN ) { - FrmHideObject( form, index ); - } else { - FormObjectKind typ = FrmGetObjectType( form, index ); - XP_Bool active = enable == TRI_ENAB_ENABLED; - - FrmShowObject( form, index ); - - switch( typ ) { - case frmFieldObj: - setFieldEditable( id, active ); - break; - case frmControlObj: - CtlSetEnabled( getActiveObjectPtr( id ), enable ); - break; - case frmLabelObj: /* what to do? */ - break; - default: - XP_WARNF( "%s: %d not handled", __func__, (XP_U16)typ ); - XP_ASSERT(0); - } - } -} /* disOrEnableTri */ - -void -disOrEnableSet( FormPtr form, const UInt16* ids, Boolean enable ) -{ - for ( ; ; ) { - XP_U16 id = *ids++; - if ( !id ) { - break; - } - disOrEnable( form, id, enable ); - } -} /* disOrEnableSet */ - -/* Space a row of controls evenly across their container. This will center a - * single control or space several regardless of their size. Assumption, - * enforced by an assertion, is that they fit without overlapping. Another, not - * enforced, is that all have the same y coordinates. This was originally - * written for localized dialogs with different-length button text. - */ -void -centerControls( FormPtr form, const UInt16* id, XP_U16 nIds ) -{ - XP_U16 i, width, prev; - RectangleType bounds; - - - /* Two passes. First, figure total width outside controls. */ - FrmGetFormBounds( form, &bounds ); - width = bounds.extent.x; - for ( i = 0; i < nIds; ++i ) { - UInt16 index = FrmGetObjectIndex( form, id[i] ); - FrmGetObjectBounds( form, index, &bounds ); - XP_ASSERT( width >= bounds.extent.x ); - width -= bounds.extent.x; - } - - /* Then layout */ - width /= nIds + 1; /* space between controls */ - prev = width; - for ( i = 0; i < nIds; ++i ) { - UInt16 index = FrmGetObjectIndex( form, id[i] ); - FrmGetObjectBounds( form, index, &bounds ); - bounds.topLeft.x = prev; - FrmSetObjectBounds( form, index, &bounds ); - prev += bounds.extent.x + width; - } -} /* centerControls */ - -/***************************************************************************** - * - ****************************************************************************/ -Boolean -getBooleanCtrl( UInt16 objectID ) -{ - return CtlGetValue( getActiveObjectPtr( objectID ) ); -} /* getBooleanCtrl */ - -void -setFieldStr( XP_U16 id, const XP_UCHAR* buf ) -{ - FieldPtr field = getActiveObjectPtr( id ); - UInt16 len = FldGetTextLength( field ); - - if ( !buf ) { - buf = ""; - } - - FldSetSelection( field, 0, len ); - FldInsert( field, buf, XP_STRLEN(buf) ); -} /* setFieldStr */ - -#ifdef XWFEATURE_RELAY -void -getFieldStr( XP_U16 id, XP_UCHAR* buf, XP_U16 max ) -{ - FieldPtr field = getActiveObjectPtr( id ); - XP_UCHAR* str = FldGetTextPtr( field ); - XP_U16 len = FldGetTextLength( field ); - if ( len >= max ) { - len = max - 1; - } - XP_MEMCPY( buf, str, len ); - buf[len] = '\0'; -} /* strFromField */ -#endif - -/***************************************************************************** - * Set up to build the string and ptr-to-string lists needed for the - * LstSetListChoices system call. - ****************************************************************************/ -void -initListData( MPFORMAL ListData* ld, XP_U16 nItems ) -{ - /* include room for the closure */ - ld->strings = XP_MALLOC( mpool, ((nItems+1) * sizeof(*ld->strings)) ); - - ld->storage = XP_MALLOC( mpool, 1 ); - ld->storage[0] = '\0'; - ld->storageLen = 1; - - ld->nItems = nItems; - ld->nextIndex = 0; - ld->selIndex = -1; -#ifdef DEBUG - ld->choicesSet = XP_FALSE; -#endif -} /* initListData */ - -void -addListTextItem( MPFORMAL ListData* ld, const XP_UCHAR* txt ) -{ - XP_U16 curLen = ld->storageLen; - XP_U16 strLen = XP_STRLEN( txt ) + 1; /* null byte */ - XP_S32 diff; - unsigned char* storage; - XP_S16 i; - - storage = XP_REALLOC( mpool, ld->storage, curLen + strLen ); - XP_MEMCPY( storage + curLen, txt, strLen ); - - /* Now update all the existing ptrs since storage may have moved. - Remember to skip item 0. */ - diff = storage - ld->storage; - for ( i = ld->nextIndex; i > 0; --i ) { - ld->strings[i] += diff; - } - - ld->storage = storage; - ld->strings[++ld->nextIndex] = storage + curLen; - ld->storageLen += strLen; -} /* addListTextItem */ - -/***************************************************************************** - * Turn the list of offsets into ptrs, free the offsets list, and call - * LstSetListChoices - ****************************************************************************/ -void -setListChoices( ListData* ld, ListPtr list, void* closure ) -{ - ld->strings[0] = closure; - LstSetListChoices( list, (Char**)&ld->strings[1], ld->nextIndex ); -#ifdef DEBUG - ld->choicesSet = XP_TRUE; -#endif - if ( ld->selIndex >= 0 ) { - LstSetSelection( list, ld->selIndex ); - } -} /* setListChoices */ - -/***************************************************************************** - * Given a string, figure out which item it matches and save off that item's - * index so that at show time it can be used to set the selection. Note that - * anything that changes the order will invalidate this, but also that there's - * no harm in calling it again. - ****************************************************************************/ -void -setListSelection( ListData* ld, const char* selName ) -{ - ld->selIndex = 0; - XP_ASSERT( !ld->choicesSet ); - - if ( !!selName ) { - XP_U16 i; - for ( i = 0; i < ld->nextIndex; ++i ) { - if ( StrCompare( ld->strings[i+1], selName ) == 0 ) { - ld->selIndex = i; - break; - } - } - } -} /* setListSelection */ - -/***************************************************************************** - * Meant to be called after all items are added to the list, this function - * sorts them in place. For now I'll build in a call to StrCompare; later - * it could be a callback passed in. - ****************************************************************************/ -void -sortList( ListData* ld ) -{ - XP_S16 i, j, smallest; - unsigned char** strings = ld->strings; - char* tmp; - - XP_ASSERT( !ld->choicesSet ); /* if ARM, strings are reversed. Use list - API at this point. */ - - for ( i = 1; i <= ld->nextIndex; ++i ) { /* skip 0th (closure) slot */ - for ( smallest = i, j = i+1; j <= ld->nextIndex; ++j ) { - if ( StrCompare( strings[smallest], strings[j] ) > 0 ) { - smallest = j; - } - } - - if ( smallest == i ) { /* we got to the end without finding anything */ - break; - } - - tmp = strings[i]; - strings[i] = strings[smallest]; - strings[smallest] = tmp; - } -} /* sortList */ - -/***************************************************************************** - * Dispose the memory. Docs don't say whether LstSetListChoices does this for - * me so I assume not. It'll crash if I'm wrong. :-) - ****************************************************************************/ -void -freeListData( MPFORMAL ListData* ld ) -{ - XP_FREE( mpool, ld->storage ); - XP_FREE( mpool, ld->strings ); -} /* freeListData */ - -/***************************************************************************** - * - ****************************************************************************/ -void -setSelectorFromList( UInt16 triggerID, ListPtr list, XP_S16 listSelIndex ) -{ - XP_ASSERT( list != NULL ); - XP_ASSERT( getActiveObjectPtr( triggerID ) != NULL ); - XP_ASSERT( !!LstGetSelectionText( list, listSelIndex ) ); - CtlSetLabel( getActiveObjectPtr( triggerID ), - LstGetSelectionText( list, listSelIndex ) ); -} /* setTriggerFromList */ - -XP_Bool -penInGadget( const EventType* event, UInt16* whichGadget ) -{ - UInt16 x = event->screenX; - UInt16 y = event->screenY; - FormPtr form = FrmGetActiveForm(); - UInt16 nObjects, i; - XP_Bool result = XP_FALSE; - - for ( i = 0, nObjects = FrmGetNumberOfObjects(form); i < nObjects; ++i ) { - if ( frmGadgetObj == FrmGetObjectType( form, i ) ) { - UInt16 objId = FrmGetObjectId( form, i ); - if ( objId != REFCON_GADGET_ID ) { - RectangleType rect; - FrmGetObjectBounds( form, i, &rect ); - if ( RctPtInRectangle( x, y, &rect ) ) { - *whichGadget = objId; - result = XP_TRUE; - break; - } - } - } - } - - return result; -} /* penInGadget */ - -void -drawOneGadget( UInt16 id, const char* text, Boolean hilite ) -{ - RectangleType divRect; - XP_U16 len = XP_STRLEN(text); - XP_U16 width = FntCharsWidth( text, len ); - XP_U16 left; - - getObjectBounds( id, &divRect ); - WinDrawRectangleFrame( rectangleFrame, &divRect ); - WinEraseRectangle( &divRect, 0 ); - left = divRect.topLeft.x; - left += (divRect.extent.x - width) / 2; - WinDrawChars( text, len, left, divRect.topLeft.y ); - if ( hilite ) { - WinInvertRectangle( &divRect, 0 ); - } -} /* drawOneGadget */ - -#ifdef XWFEATURE_FIVEWAY -XP_S16 -getFocusOwner( void ) -{ - FormPtr form = FrmGetActiveForm(); - XP_S16 ownerID = -1; - XP_S16 focus = FrmGetFocus( form ); - if ( focus >= 0 ) { - ownerID = FrmGetObjectId( form, focus ); - } - return ownerID; -} /* getFocusOwner */ - -void -setFormFocus( FormPtr form, XP_U16 objectID ) -{ - Int16 index = FrmGetObjectIndex( form, objectID ); - XP_ASSERT( index >= 0 ); - FrmSetFocus( form, index ); -} /* setFormFocus */ - -XP_Bool -isFormObject( FormPtr form, XP_U16 objectID ) -{ - Int16 index = FrmGetObjectIndex( form, objectID ); - return index >= 0; -} - -#ifndef XW_TARGET_PNO -/* Warning: gross hack. HsNavDrawFocusRing doesn't work on newer Palms, - e.g. Tungsten T. It's been replaced by FrmNavDrawFocusRing. But that - requires the sdk-5r4 headers which require significant changes I don't want - to make right before shipping. So here's a hack: define FrmNavDrawFocusRing - based on info in the r4 header info without actually including any headers. -*/ -Err FrmNavDrawFocusRing( FormType* fp, UInt16 oid, Int16 ei, - RectangleType* birp, - HsNavFocusRingStyleEnum rs, Boolean fr ) - _SYSTEM_API(_CALL_WITH_UNPOPPED_16BIT_SELECTOR)(_SYSTEM_TABLE, - sysTrapNavSelector, - 0x07 ); -#endif - -void -drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow, XP_U16 idHigh ) -{ - FormPtr form; - XP_S16 index; - XP_U16 focusID; - - form = FrmGetActiveForm(); - index = FrmGetFocus( form ); - if ( index >= 0 ) { - focusID = FrmGetObjectId( form, index ); - - if ( (focusID >= idLow) && (focusID <= idHigh) ) { - Err err; - RectangleType rect; - - getObjectBounds( focusID, &rect ); - - /* growing the rect didn't work to fix glitches in ring drawing. */ - if ( IS_T600(globals) ) { - err = HsNavDrawFocusRing( form, focusID, 0, &rect, - hsNavFocusRingStyleObjectTypeDefault, - false ); - } else { - err = FrmNavDrawFocusRing( form, focusID, 0, &rect, - hsNavFocusRingStyleObjectTypeDefault, - false ); - } - XP_ASSERT( err == errNone ); - } - } -} /* drawFocusRingOnGadget */ - -XP_Bool -considerGadgetFocus( PalmAppGlobals* globals, const EventType* event, XP_U16 idLow, XP_U16 idHigh ) -{ - XP_Bool handled; - XP_U16 objectID; - - XP_ASSERT( event->eType == frmObjectFocusLostEvent - || event->eType == frmObjectFocusTakeEvent ); - XP_ASSERT( event->data.frmObjectFocusTake.formID == FrmGetActiveFormID() ); - XP_ASSERT( &event->data.frmObjectFocusTake.objectID - == &event->data.frmObjectFocusLost.objectID ); - - objectID = event->data.frmObjectFocusTake.objectID; - handled = (objectID >= idLow) && (objectID <= idHigh); - if ( handled ) { - if ( event->eType == frmObjectFocusTakeEvent ) { - FormPtr form = FrmGetActiveForm(); - setFormFocus( form, objectID ); - drawFocusRingOnGadget( globals, idLow, idHigh ); - } - } - - return handled; -} /* considerGadgetFocus */ - -XP_Bool -tryRockerKey( XP_U16 key, XP_U16 selGadget, XP_U16 idLow, XP_U16 idHigh ) -{ - XP_Bool result = XP_FALSE; - - if ( vchrRockerCenter == key ) { - if ( selGadget >= idLow && selGadget <= idHigh ) { - result = XP_TRUE; - } - } - return result; -} /* tryRockerKey */ -#endif - -void -drawGadgetsFromList( ListPtr list, XP_U16 idLow, XP_U16 idHigh, - XP_U16 hiliteItem ) -{ - XP_U16 i; - XP_ASSERT( idLow <= idHigh ); - - for ( i = 0; idLow <= idHigh; ++i, ++idLow ) { - const char* text = LstGetSelectionText( list, i ); - Boolean hilite = idLow == hiliteItem; - drawOneGadget( idLow, text, hilite ); - } -} /* drawGadgetsFromList */ - -void -setFormRefcon( void* refcon ) -{ -#ifdef DEBUG - Err err = -#endif - FtrSet( APPID, GLOBALS_FEATURE, (UInt32)refcon ); - XP_ASSERT( err == errNone ); -} /* setFormRefcon */ - -void* -getFormRefcon() -{ - UInt32 ptr; -#ifdef DEBUG - Err err = -#endif - FtrGet( APPID, GLOBALS_FEATURE, &ptr ); - XP_ASSERT( err == errNone ); - XP_ASSERT( ptr != 0L ); - return (void*)ptr; -} /* getFormRefcon */ - -void -fitButtonToString( XP_U16 id ) -{ - ControlPtr button = getActiveObjectPtr( id ); - const char* label = CtlGetLabel( button ); - XP_U16 width = FntCharsWidth( label, XP_STRLEN(label) ); - RectangleType rect; - width += 14; /* 7 pixels at either end */ - - getObjectBounds( id, &rect ); - rect.topLeft.x -= (rect.extent.x - width); - rect.extent.x = width; - - setObjectBounds( id, &rect ); -} /* fitButtonToString */ - -#endif - -#if defined FEATURE_REALLOC || defined XW_FEATURE_UTILS -XP_U8* -palm_realloc( XP_U8* in, XP_U16 size ) -{ - MemPtr ptr = (MemPtr)in; - XP_U32 oldsize = MemPtrSize( ptr ); - MemPtr newptr = MemPtrNew( size ); - XP_ASSERT( !!newptr ); - XP_MEMCPY( newptr, ptr, oldsize ); - MemPtrFree( ptr ); - return newptr; -} /* palm_realloc */ - -XP_U16 -palm_snprintf( XP_UCHAR* buf, XP_U16 XP_UNUSED_DBG(len), - const XP_UCHAR* format, ... ) -{ - XP_U16 nChars; - /* PENDING use len to avoid writing too many chars */ - va_list ap; - - va_start( ap, format ); - nChars = StrVPrintF( (char*)buf, (char*)format, ap ); - va_end( ap ); - XP_ASSERT( len >= nChars ); - return nChars; -} /* palm_snprintf */ -#endif - -#ifdef FOR_GREMLINS -static Boolean -doNothing( EventPtr event ) -{ - return true; -} /* doNothing */ -#endif - -#ifdef DEBUG -void -palm_warnf( char* format, ... ) -{ - char buf[200]; - va_list ap; - - va_start( ap, format ); - StrVPrintF( buf, format, ap ); - va_end( ap ); - -#ifdef FOR_GREMLINS - /* If gremlins are active, we want all activity to stop here! That - means no cancellation */ - { - FormPtr form; - FieldPtr field; - - form = FrmInitForm( XW_GREMLIN_WARN_FORM_ID ); - - FrmSetActiveForm( form ); - - FrmSetEventHandler( form, doNothing ); - - field = getActiveObjectPtr( XW_GREMLIN_WARN_FIELD_ID ); - FldSetTextPtr( field, buf ); - FldRecalculateField( field, true ); - - FrmDrawForm( form ); -#if 1 - /* This next may freeze X (go to a console to kill POSE), but when - you look at the logs you'll see what event you were on when the - ASSERT fired. Otherwise the events just keep coming and POSE - fills up the log. */ - while(1); -#endif - /* this should NEVER return */ - (void)FrmDoDialog( form ); - } -#else - (void)FrmCustomAlert( XW_ERROR_ALERT_ID, buf, " ", " " ); -#endif -} /* palm_warnf */ - -void -palm_assert( Boolean b, int line, const char* func, const char* file ) -{ - if ( !b ) { - /* force file logging on if not already */ - FtrSet( APPID, LOG_FILE_FEATURE, 1 ); - XP_LOGF( "ASSERTION FAILED: line %d, %s(), %s", line, func, file ); - - XP_WARNF( "ASSERTION FAILED: line %d, %s(), %s", line, func, file ); - } -} /* palmassert */ - -static void -logToDB( const char* buf, const char* dbName, XP_U32 dbCreator, XP_U32 dbType ) -{ - const XP_U16 MAX_MEMO_SIZE = 4000; - const XP_U16 MAX_NRECORDS = 200; - DmOpenRef ref; - UInt16 nRecords, index; - UInt16 len = XP_STRLEN( buf ); - UInt16 hSize, slen; - MemHandle hand; - MemPtr ptr; - char tsBuf[20]; - UInt16 tsLen; - DateTimeType dtType; - LocalID dbID; - - TimSecondsToDateTime( TimGetSeconds(), &dtType ); - StrPrintF( tsBuf, "\n%d:%d:%d-", dtType.hour, dtType.minute, - dtType.second ); - tsLen = XP_STRLEN(tsBuf); - - (void)DmCreateDatabase( CARD_0, dbName, dbCreator, dbType, false ); - dbID = DmFindDatabase( CARD_0, dbName ); - ref = DmOpenDatabase( CARD_0, dbID, dmModeWrite ); - - nRecords = DmNumRecordsInCategory( ref, dmAllCategories ); - if ( nRecords == 0 ) { - index = dmMaxRecordIndex; - hSize = 0; - hand = DmNewRecord( ref, &index, 1 ); - DmReleaseRecord( ref, index, true ); - } else { - - while ( nRecords > MAX_NRECORDS ) { - index = 0; - DmSeekRecordInCategory( ref, &index, 0, dmSeekForward, - dmAllCategories); - DmRemoveRecord( ref, index ); - --nRecords; - } - - index = 0; - DmSeekRecordInCategory( ref, &index, nRecords, dmSeekForward, - dmAllCategories); - hand = DmGetRecord( ref, index ); - - XP_ASSERT( !!hand ); - hSize = MemHandleSize( hand ) - 1; - ptr = MemHandleLock( hand ); - slen = XP_STRLEN(ptr); - MemHandleUnlock(hand); - - if ( hSize > slen ) { - hSize = slen; - } - (void)DmReleaseRecord( ref, index, false ); - } - - if ( (hSize + len + tsLen) > MAX_MEMO_SIZE ) { - index = dmMaxRecordIndex; - hand = DmNewRecord( ref, &index, len + tsLen + 1 ); - hSize = 0; - } else { - (void)DmResizeRecord( ref, index, len + hSize + tsLen + 1 ); - hand = DmGetRecord( ref, index ); - } - - ptr = MemHandleLock( hand ); - DmWrite( ptr, hSize, tsBuf, tsLen ); - DmWrite( ptr, hSize + tsLen, buf, len + 1 ); - MemHandleUnlock( hand ); - - DmReleaseRecord( ref, index, true ); - DmCloseDatabase( ref ); -} /* logToDB */ - -static void -deleteDB( const char* dbName ) -{ - LocalID dbID; - dbID = DmFindDatabase( CARD_0, dbName ); - if ( 0 != dbID ) { - Err err = DmDeleteDatabase( CARD_0, dbID ); - XP_ASSERT( errNone == err ); - } else { - XP_WARNF( "%s(%s): got back 0", __func__, dbName ); - } -} /* deleteDB */ - -void -PalmClearLogs( void ) -{ - deleteDB( MEMO ); - deleteDB( LOGFILE ); -} - -static void -logToMemo( const char* buf ) -{ - UInt32 val = 0L; - Err err = FtrGet( APPID, LOG_MEMO_FEATURE, (UInt32*)&val ); - if ( errNone == err && val != 0 ) { - logToDB( buf, MEMO, 'memo', 'DATA' ); - } -} - -static void -logToFile( const char* buf ) -{ -#if 0 - logToDB( buf, LOGFILE, 'XWLG', 'TEXT' ); -#else - UInt32 val = 0L; - Err err = FtrGet( APPID, LOG_FILE_FEATURE, (UInt32*)&val ); - if ( errNone == err && val != 0 ) { - logToDB( buf, LOGFILE, 'XWLG', 'TEXT' ); - } -#endif -} - -void -palm_debugf( char* format, ...) -{ - char buf[200]; - va_list ap; - - va_start( ap, format ); - StrVPrintF( buf, format, ap ); - va_end( ap ); - - logToMemo( buf ); - logToFile( buf ); -} /* debugf */ - -void -palm_logf( char* format, ... ) -{ - char buf[200]; - va_list ap; - - va_start( ap, format ); - StrVPrintF( buf, format, ap ); - va_end( ap ); - - logToMemo( buf ); - logToFile( buf ); -} /* palm_logf */ - -#endif /* DEBUG */ diff --git a/xwords4/palm/palmutil.h b/xwords4/palm/palmutil.h deleted file mode 100644 index 5b5f9350a..000000000 --- a/xwords4/palm/palmutil.h +++ /dev/null @@ -1,105 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/**************************************************************************** - * * - * Copyright 1998-1999, 2001 by Eric House (xwords@eehouse.org). All rights reserved. * - * * - * - * 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 _PALMUTIL_H_ -#define _PALMUTIL_H_ - -#include -#include -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include "xwdefines.h" */ -/* #include "xwords.h" */ -/* #include "xwdebug.h" */ - -#include "palmmain.h" - -/* short myMemCmp( unsigned char* src1, unsigned char* src2, short size ); */ -/* void userError( CharPtr* str ); */ -/* void userErrorRes( short resId ); */ -/* void userErrorResS( short resId, CharPtr data ); */ -void beep( void ); - -MemPtr getActiveObjectPtr( UInt16 objectID ); -void getObjectBounds( UInt16 objectID, RectangleType* rectP ); -void setObjectBounds( UInt16 objectID, RectangleType* rectP ); - -void disOrEnable( FormPtr form, UInt16 id, Boolean enable ); -void disOrEnableSet( FormPtr form, const UInt16* id, Boolean enable ); - -void disOrEnableTri( FormPtr form, UInt16 id, XP_TriEnable enable ); - -void centerControls( FormPtr form, const UInt16* id, XP_U16 nIds ); - -void setBooleanCtrl( UInt16 objectID, Boolean isSet ); -Boolean getBooleanCtrl( UInt16 objectID ); - -void setFieldStr( XP_U16 id, const XP_UCHAR* buf ); -#ifdef XWFEATURE_RELAY -void getFieldStr( XP_U16 id, XP_UCHAR* buf, XP_U16 max ); -#endif -void setFieldEditable( UInt16 objectID, Boolean editable ); - -void postEmptyEvent( eventsEnum typ ); - -/* list item stuff */ -void initListData( MPFORMAL ListData* ld, XP_U16 nItems ); -void addListTextItem( MPFORMAL ListData* ld, const XP_UCHAR* txt ); -void setListChoices( ListData* ld, ListPtr list, void* closure ); -void setListSelection( ListData* ld, const char* selName ); -void sortList( ListData* ld ); -void freeListData( MPFORMAL ListData* ld ); - -/* this should work on either trigger or selector */ -void setSelectorFromList( UInt16 selectorID, ListPtr list, - short listSelIndex ); - -void sizeGadgetsForStrings( FormPtr form, ListPtr list, XP_U16 firstGadgetID ); -void drawGadgetsFromList( ListPtr list, XP_U16 idLow, XP_U16 idHigh, - XP_U16 hiliteItem ); - -XP_Bool penInGadget( const EventType* event, UInt16* whichGadget ); -void drawOneGadget( UInt16 id, const char* text, Boolean hilite ); -# ifdef XWFEATURE_FIVEWAY -XP_S16 getFocusOwner( void ); -void setFormFocus( FormPtr form, XP_U16 objectID ); -XP_Bool isFormObject( FormPtr form, XP_U16 objectID ); -void drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow, - XP_U16 idHigh ); -XP_Bool considerGadgetFocus( PalmAppGlobals* globals, const EventType* event, - XP_U16 idLow, XP_U16 idHigh ); - -XP_Bool tryRockerKey( XP_U16 key, XP_U16 selGadget, - XP_U16 idLow, XP_U16 idHigh ); -# endif - -void setFormRefcon( void* refcon ); -void* getFormRefcon(void); -void fitButtonToString( XP_U16 id ); - - -#ifdef DEBUG -void PalmClearLogs( void ); -#endif - -#endif diff --git a/xwords4/palm/pnolet.c b/xwords4/palm/pnolet.c deleted file mode 100644 index f8349fd07..000000000 --- a/xwords4/palm/pnolet.c +++ /dev/null @@ -1,161 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2004 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include "pnostate.h" -#include "pace_gen.h" -#include "pace_man.h" /* for the ExgSocketType flippers */ -#include "palmmain.h" - -typedef union ParamStub { - ExgAskParamType exgAskParamType; - ExgSocketType exgSocketType; -} ParamStub; - -unsigned long -realArmletEntryPoint( const void *emulStateP, - void *userData68KP, - Call68KFuncType* call68KFuncP ); - -/* With arm-palmos-gcc, there can't be any .GOT references in the entry point - (since those values get put inline BEFORE the function rather than - after.) */ -unsigned long -ArmletEntryPoint( const void *emulStateP, - void *userData68KP, - Call68KFuncType* call68KFuncP ) -{ - return realArmletEntryPoint( emulStateP, - userData68KP, - call68KFuncP ); -} - -#ifdef XWFEATURE_IR -static XP_Bool -convertParamToArm( UInt16 cmd, ParamStub* armParam, MemPtr parm68K ) -{ - XP_Bool revert; - - if ( cmd == sysAppLaunchCmdExgAskUser ) { - /* We don't read the data, but we do write to one field. */ - revert = XP_TRUE; - } else if ( cmd == sysAppLaunchCmdExgReceiveData ) { - flipEngSocketToArm( &armParam->exgSocketType, - (const unsigned char*)parm68K ); - revert = XP_TRUE; /* just to be safe */ - } else { - revert = XP_FALSE; - } - - return revert; -} /* convertParamToArm */ - -static void -convertParamFromArm( UInt16 cmd, MemPtr parm68K, ParamStub* armParam ) -{ - if ( cmd == sysAppLaunchCmdExgAskUser ) { - write_unaligned8( &((unsigned char*)parm68K)[4], - armParam->exgAskParamType.result ); - } else if ( cmd == sysAppLaunchCmdExgReceiveData ) { - flipEngSocketFromArm( parm68K, &armParam->exgSocketType ); - } else { - XP_ASSERT(0); - } -} -#endif - -unsigned long -realArmletEntryPoint( const void *emulStateP, - void *userData68KP, - Call68KFuncType* call68KFuncP ) -{ - PNOState* loc; - PNOState state; - PnoletUserData* dataP; - unsigned long result; - unsigned long oldR10; - UInt16 cmd; - MemPtr cmdPBP; - MemPtr oldVal; - ParamStub ptrStorage; - XP_Bool mustRevert; - - loc = getStorageLoc(); - - dataP = (PnoletUserData*)userData68KP; - dataP->stateSrc = (PNOState*)Byte_Swap32((unsigned long)&state); - dataP->stateDest = (PNOState*)Byte_Swap32((unsigned long)loc); - - state.gotTable = (unsigned long*) - Byte_Swap32((unsigned long)dataP->gotTable); - - if ( !dataP->recursive ) { - STACK_START(unsigned char, stack, 4 ); - ADD_TO_STACK4(stack, userData68KP, 0); - STACK_END(stack); - - state.emulStateP = emulStateP; - state.call68KFuncP = call68KFuncP; - - (*call68KFuncP)( emulStateP, - Byte_Swap32((unsigned long)dataP->storageCallback), - stack, 4 ); - } - - asm( "mov %0, r10" : "=r" (oldR10) ); - asm( "mov r10, %0" : : "r" (state.gotTable) ); - - cmd = Byte_Swap16( dataP->cmd ); - cmdPBP = (MemPtr)Byte_Swap32((unsigned long)dataP->cmdPBP); - -#ifdef XWFEATURE_IR - /* if the cmd is sysAppLaunchCmdExgAskUser or - sysAppLaunchCmdExgReceiveData then we're going to be making use of the - cmdPBP value in PilotMain. Need to convert it here. */ - mustRevert = convertParamToArm( cmd, &ptrStorage, cmdPBP ); -#endif - - oldVal = cmdPBP; - cmdPBP = &ptrStorage; - - result = PM2(PilotMain)( cmd, cmdPBP, Byte_Swap16(dataP->launchFlags) ); - -#ifdef XWFEATURE_IR - if ( mustRevert ) { - convertParamFromArm( cmd, oldVal, &ptrStorage ); - } -#endif - - asm( "mov r10, %0" : : "r" (oldR10) ); - return result; -} /* realArmletEntryPoint( */ - -PNOState* -getStorageLoc( void ) -{ - asm( "adr r0,data" ); - asm( "mov pc,lr" ); - asm( "data:" ); - /* we need sizeof(PNOState) worth of bytes after the data label. */ - asm( "nop" ); - asm( "nop" ); - return (PNOState*)0L; /* shut up compiler; overwrite me!!!! */ - /* The compiler's adding a "mov pc,lr" here too that we can overwrite. */ -} - diff --git a/xwords4/palm/pnostate.h b/xwords4/palm/pnostate.h deleted file mode 100644 index 362f25f5f..000000000 --- a/xwords4/palm/pnostate.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ - -#ifndef _PNOSTATE_H_ -#define _PNOSTATE_H_ - -#include -#include - -/* from http://news.palmos.com/read/messages?id=159373 */ -typedef struct EmulStateType { - UInt32 instr; - UInt32 regD[8]; - UInt32 regA[8]; - UInt32 regPC; -} EmulStateType; - -/* This gets written into the code by the callback below. */ -typedef struct PNOState { - const EmulStateType* emulStateP; - Call68KFuncType* call68KFuncP; - void* gotTable; -} PNOState; - -/* I can't get the circular decls to work now */ -typedef void StorageCallback(/*PnoletUserData*/void* dataP); - -/* This is how armlet and 68K stub communicate on startup */ -typedef struct PnoletUserData { - unsigned long* pnoletEntry; - unsigned long* gotTable; - StorageCallback* storageCallback; /* armlet calls this */ - PNOState* stateSrc; /* armlet fills in */ - PNOState* stateDest; /* armlet fills in */ - - /* PilotMain params */ - MemPtr cmdPBP; - UInt16 cmd; - UInt16 launchFlags; - - /* Other.... */ - Boolean recursive; /* PilotMain called from inside PilotMain */ -} PnoletUserData; - -#endif diff --git a/xwords4/palm/prefsdlg.c b/xwords4/palm/prefsdlg.c deleted file mode 100644 index a5c711fa8..000000000 --- a/xwords4/palm/prefsdlg.c +++ /dev/null @@ -1,441 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE"; -*- */ -/* - * Copyright 1999 - 2006 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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. - */ - -#ifdef XWFEATURE_FIVEWAY -# include -#endif - -#include "prefsdlg.h" -#include "callback.h" -#include "palmutil.h" -#include "xwords4defines.h" - -void localPrefsToGlobal( PalmAppGlobals* globals ); -static void localPrefsToControls( PrefsDlgState* state ); -static void drawPrefsTypeGadgets( PalmAppGlobals* globals ); -static void showHidePrefsWidgets( PalmAppGlobals* globals, FormPtr form ); -static void checkPrefsHiliteGadget( PalmAppGlobals* globals, UInt16 selGadget ); -static void controlsToLocalPrefs( PrefsDlgState* state ); -static XP_Bool ignoredUnlessNewgame( XP_U16 id ); - -Boolean -PrefsFormHandleEvent( EventPtr event ) -{ - Boolean result = false; - PalmAppGlobals* globals; - PrefsDlgState* state; - FormPtr form; - Int16 chosen; - XP_S16 selGadget; - - CALLBACK_PROLOGUE(); - globals = getFormRefcon(); - state = globals->prefsDlgState; - - switch ( event->eType ) { - - case frmOpenEvent: - - if ( !state ) { - GlobalPrefsToLocal( globals ); - state = globals->prefsDlgState; - } - - state->playerBdSizeList = - getActiveObjectPtr( XW_PREFS_BDSIZE_LIST_ID ); - state->phoniesList = - getActiveObjectPtr( XW_PREFS_PHONIES_LIST_ID ); - - case frmUpdateEvent: - form = FrmGetActiveForm(); - - localPrefsToControls( state ); - - showHidePrefsWidgets( globals, form ); - - FrmDrawForm( form ); - - drawPrefsTypeGadgets( globals ); - break; - - case penDownEvent: - result = penInGadget( event, &selGadget ); - if ( result ) { - checkPrefsHiliteGadget( globals, selGadget ); - } - break; - -#ifdef XWFEATURE_FIVEWAY - case keyDownEvent: - selGadget = getFocusOwner(); - if ( selGadget >= 0 ) { - if ( tryRockerKey( event->data.keyDown.chr, selGadget, - XW_PREFS_ALLGAMES_GADGET_ID, - XW_PREFS_ONEGAME_GADGET_ID ) ) { - checkPrefsHiliteGadget( globals, selGadget ); - result = XP_TRUE; - } else if ( !globals->isNewGame - && vchrRockerCenter == event->data.keyDown.chr ) { - result = ignoredUnlessNewgame( selGadget ); - } - } - break; - - case frmObjectFocusTakeEvent: - case frmObjectFocusLostEvent: - result = considerGadgetFocus( globals, event, XW_PREFS_ALLGAMES_GADGET_ID, - XW_PREFS_ONEGAME_GADGET_ID ); - break; -#endif - - case ctlSelectEvent: - result = true; - switch ( event->data.ctlSelect.controlID ) { - -#ifdef XWFEATURE_SEARCHLIMIT - case XW_PREFS_NOHINTS_CHECKBOX_ID: { - Boolean checked = getBooleanCtrl( XW_PREFS_NOHINTS_CHECKBOX_ID ); - disOrEnable( FrmGetActiveForm(), XW_PREFS_HINTRECT_CHECKBOX_ID, - !checked ); - } - break; -#endif - case XW_PREFS_PHONIES_TRIGGER_ID: - chosen = LstPopupList( state->phoniesList ); - if ( chosen >= 0 ) { - setSelectorFromList( XW_PREFS_PHONIES_TRIGGER_ID, - state->phoniesList, chosen ); - state->phoniesAction = chosen; - } - break; - - case XW_PREFS_BDSIZE_SELECTOR_ID: - XP_ASSERT( globals->isNewGame ); /* above disables otherwise */ - chosen = LstPopupList( state->playerBdSizeList ); - if ( chosen >= 0 ) { - setSelectorFromList( XW_PREFS_BDSIZE_SELECTOR_ID, - state->playerBdSizeList, chosen ); - state->curBdSize = PALM_MAX_ROWS - (chosen*2); - } - break; - - case XW_PREFS_TIMERON_CHECKBOX_ID: - XP_ASSERT( globals->isNewGame ); - form = FrmGetActiveForm(); - showHidePrefsWidgets( globals, form ); - break; - - case XW_PREFS_OK_BUTTON_ID: - controlsToLocalPrefs( state ); - postEmptyEvent( prefsChangedEvent ); - globals->postponeDraw = true; - - case XW_PREFS_CANCEL_BUTTON_ID: - FrmReturnToForm( 0 ); - break; - } - break; - - default: - break; - } - - CALLBACK_EPILOGUE(); - return result; -} /* prefsFormHandleEvent */ - -static XP_Bool -ignoredUnlessNewgame( XP_U16 id ) -{ - XP_Bool ignored = XP_FALSE; - switch ( id ) { - case XW_PREFS_NOHINTS_CHECKBOX_ID: - case XW_PREFS_BDSIZE_SELECTOR_ID: - case XW_PREFS_TIMERON_CHECKBOX_ID: - case XW_PREFS_TIMER_FIELD_ID: -#ifdef FEATURE_TRAY_EDIT - case XW_PREFS_PICKTILES_CHECKBOX_ID: -#endif - ignored = XP_TRUE; - break; - } - return ignored; -} /* ignoredUnlessNewgame */ - -void -GlobalPrefsToLocal( PalmAppGlobals* globals ) -{ - PrefsDlgState* state = globals->prefsDlgState; - - if ( !state ) { - state = globals->prefsDlgState = XP_MALLOC( globals->mpool, - sizeof(*state) ); - } - - state->curBdSize = !!globals->game.model? - model_numRows( globals->game.model ) : PALM_MAX_ROWS; - - state->smartRobot = globals->util.gameInfo->robotSmartness == SMART_ROBOT; - state->showGrid = globals->gState.showGrid; - state->showProgress = globals->gState.showProgress; - XP_MEMCPY( &state->cp, &globals->gState.cp, sizeof(state->cp) ); - XP_ASSERT( !!globals->game.server ); - - state->phoniesAction = globals->util.gameInfo->phoniesAction; - state->hintsNotAllowed = globals->gameInfo.hintsNotAllowed; -#ifdef XWFEATURE_SEARCHLIMIT - state->allowHintRect = globals->gameInfo.allowHintRect; -#endif - state->timerEnabled = globals->util.gameInfo->timerEnabled; - state->gameSeconds = globals->util.gameInfo->gameSeconds; -#ifdef FEATURE_TRAY_EDIT - state->allowPickTiles = globals->util.gameInfo->allowPickTiles; -#endif - -#ifdef XWFEATURE_BLUETOOTH - state->confirmBTConnect = globals->util.gameInfo->confirmBTConnect; -#endif - - state->stateTypeIsGlobal = globals->stateTypeIsGlobal; -} /* GlobalPrefsToLocal */ - -XP_Bool -LocalPrefsToGlobal( PalmAppGlobals* globals ) -{ - PrefsDlgState* state = globals->prefsDlgState; - XP_Bool erase = XP_FALSE; - - /* curBdSize handled elsewhere */ - - globals->util.gameInfo->robotSmartness = - state->smartRobot? SMART_ROBOT:DUMB_ROBOT; - - erase = globals->gState.showGrid != state->showGrid; - globals->gState.showGrid = state->showGrid; - - XP_MEMCPY( &globals->gState.cp, &state->cp, sizeof(globals->gState.cp) ); - - globals->gState.showProgress = state->showProgress; - - globals->util.gameInfo->phoniesAction = state->phoniesAction; - - globals->gameInfo.hintsNotAllowed = state->hintsNotAllowed; -#ifdef XWFEATURE_SEARCHLIMIT - globals->gameInfo.allowHintRect = state->allowHintRect; -#endif - globals->util.gameInfo->timerEnabled = state->timerEnabled; - globals->util.gameInfo->gameSeconds = state->gameSeconds; - -#ifdef FEATURE_TRAY_EDIT - globals->util.gameInfo->allowPickTiles = state->allowPickTiles; -#endif - -#ifdef XWFEATURE_BLUETOOTH - globals->util.gameInfo->confirmBTConnect = state->confirmBTConnect; -#endif - - return erase; -} /* LocalPrefsToGlobal */ - -static void -numToField( UInt16 id, XP_S16 num ) -{ - FieldPtr field; - char buf[16]; - - StrIToA( buf, num ); - field = getActiveObjectPtr( id ); - FldInsert( field, buf, StrLen(buf) ); -} /* numToField */ - -static void -localPrefsToControls( PrefsDlgState* state ) -{ - setSelectorFromList( XW_PREFS_BDSIZE_SELECTOR_ID, - state->playerBdSizeList, - (PALM_MAX_ROWS - state->curBdSize) / 2 ); - - setSelectorFromList( XW_PREFS_PHONIES_TRIGGER_ID, state->phoniesList, - state->phoniesAction ); - - setBooleanCtrl( XW_PREFS_PLAYERCOLORS_CHECKBOX_ID, state->cp.showColors ); - setBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID, state->showProgress ); - setBooleanCtrl( XW_PREFS_NOHINTS_CHECKBOX_ID, state->hintsNotAllowed ); -#ifdef XWFEATURE_SEARCHLIMIT - setBooleanCtrl( XW_PREFS_HINTRECT_CHECKBOX_ID, state->allowHintRect ); -#endif - setBooleanCtrl( XW_PREFS_ROBOTSMART_CHECKBOX_ID, state->smartRobot ); - setBooleanCtrl( XW_PREFS_SHOWGRID_CHECKBOX_ID, state->showGrid ); - setBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID, state->cp.showBoardArrow ); - setBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID, - state->cp.showRobotScores ); - setBooleanCtrl( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID, - state->cp.hideTileValues ); - - setBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID, state->timerEnabled ); - -#ifdef FEATURE_TRAY_EDIT - setBooleanCtrl( XW_PREFS_PICKTILES_CHECKBOX_ID, state->allowPickTiles ); -#endif - -#ifdef XWFEATURE_BLUETOOTH - setBooleanCtrl( XW_PREFS_BTCONFIRM_CHECKBOX_ID, state->confirmBTConnect ); -#endif - - numToField( XW_PREFS_TIMER_FIELD_ID, state->gameSeconds/60 ); -} /* localPrefsToControls */ - -static XP_S16 -fieldToNum( UInt16 id ) -{ - FieldPtr field; - char* txt; - - field = getActiveObjectPtr( id ); - txt = FldGetTextPtr( field ); - return StrAToI( txt ); -} /* fieldToNum */ - -static void -controlsToLocalPrefs( PrefsDlgState* state ) -{ - state->cp.showColors = getBooleanCtrl( XW_PREFS_PLAYERCOLORS_CHECKBOX_ID ); - state->smartRobot = getBooleanCtrl( XW_PREFS_ROBOTSMART_CHECKBOX_ID ); - state->showGrid = getBooleanCtrl( XW_PREFS_SHOWGRID_CHECKBOX_ID ); - state->cp.showBoardArrow = - getBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID ); - state->cp.showRobotScores = - getBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID ); - state->cp.hideTileValues = - getBooleanCtrl( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID ); - - state->showProgress = getBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID ); - - /* trapping ctlEnterEvent should mean it can't have changed, so no need - to test before grabbing the value. */ - state->hintsNotAllowed = getBooleanCtrl( XW_PREFS_NOHINTS_CHECKBOX_ID ); -#ifdef XWFEATURE_SEARCHLIMIT - state->allowHintRect = getBooleanCtrl( XW_PREFS_HINTRECT_CHECKBOX_ID ); -#endif - - state->timerEnabled = getBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID ); - state->gameSeconds = fieldToNum( XW_PREFS_TIMER_FIELD_ID ) * 60; - -#ifdef FEATURE_TRAY_EDIT - state->allowPickTiles = - getBooleanCtrl( XW_PREFS_PICKTILES_CHECKBOX_ID ); -#endif - -#ifdef XWFEATURE_BLUETOOTH - state->confirmBTConnect = getBooleanCtrl( XW_PREFS_BTCONFIRM_CHECKBOX_ID ); -#endif - -} /* controlsToLocalPrefs */ - -static void -drawPrefsTypeGadgets( PalmAppGlobals* globals ) -{ - ListPtr list; - UInt16 active; - - list = getActiveObjectPtr( XW_PREFS_TYPES_LIST_ID ); - XP_ASSERT( !!list ); - XP_ASSERT( !!globals->prefsDlgState ); - - active = globals->prefsDlgState->stateTypeIsGlobal ? - XW_PREFS_ALLGAMES_GADGET_ID : XW_PREFS_ONEGAME_GADGET_ID; - - drawGadgetsFromList( list, XW_PREFS_ALLGAMES_GADGET_ID, - XW_PREFS_ONEGAME_GADGET_ID, active ); -#ifdef XWFEATURE_FIVEWAY - drawFocusRingOnGadget( globals, XW_PREFS_ALLGAMES_GADGET_ID, - XW_PREFS_ONEGAME_GADGET_ID ); -#endif - LOG_RETURN_VOID(); -} /* drawPrefsTypeGadgets */ - -static void -doOneSet( FormPtr form, XP_U16 first, XP_U16 last, XP_Bool enable, - XP_Bool isNewGame ) -{ - while ( first <= last ) { - XP_TriEnable stat = enable? TRI_ENAB_ENABLED : TRI_ENAB_HIDDEN; - - if ( enable && !isNewGame && ignoredUnlessNewgame( first ) ) { - stat = TRI_ENAB_DISABLED; - } - disOrEnableTri( form, first, stat ); - - ++first; - } -} /* doOneSet */ - -/* Which set of controls is supposed to be visible changes depending on which - * gadget is selected. - */ -static void -showHidePrefsWidgets( PalmAppGlobals* globals, FormPtr form ) -{ - XP_Bool isGlobal; - XP_Bool isNewGame = globals->isNewGame; - XP_U16 firstToEnable, lastToEnable, firstToDisable, lastToDisable; - - isGlobal = globals->prefsDlgState->stateTypeIsGlobal; - - /* Need to do the disabling first */ - if ( isGlobal ) { - firstToEnable = XW_PREFS_FIRST_GLOBAL_ID; - lastToEnable = XW_PREFS_LAST_GLOBAL_ID; - firstToDisable = XW_PREFS_FIRST_PERGAME_ID; - lastToDisable = XW_PREFS_LAST_PERGAME_ID; - } else { - firstToDisable = XW_PREFS_FIRST_GLOBAL_ID; - lastToDisable = XW_PREFS_LAST_GLOBAL_ID; - firstToEnable = XW_PREFS_FIRST_PERGAME_ID; - lastToEnable = XW_PREFS_LAST_PERGAME_ID; - } - - doOneSet( form, firstToDisable, lastToDisable, XP_FALSE, isNewGame ); - doOneSet( form, firstToEnable, lastToEnable, XP_TRUE, isNewGame ); - - if ( !isGlobal ) { - Boolean on = getBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID ); - disOrEnable( form, XW_PREFS_TIMER_FIELD_ID, on ); - } -} /* showHidePrefsWidgets */ - -static void -checkPrefsHiliteGadget( PalmAppGlobals* globals, UInt16 selGadget ) -{ - FormPtr form = FrmGetActiveForm(); - Boolean result = false; - - XP_Bool globalChosen = selGadget == XW_PREFS_ALLGAMES_GADGET_ID; - XP_LOGF( "%s: selGadget=%d", __func__, selGadget ); - - result = globalChosen != globals->prefsDlgState->stateTypeIsGlobal; - - if ( result ) { - globals->prefsDlgState->stateTypeIsGlobal = globalChosen; - - showHidePrefsWidgets( globals, form ); - drawPrefsTypeGadgets( globals ); - } -} /* checkPrefsHiliteGadget */ diff --git a/xwords4/palm/prefsdlg.h b/xwords4/palm/prefsdlg.h deleted file mode 100644 index f777147ad..000000000 --- a/xwords4/palm/prefsdlg.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _PREFSDLG_H_ -#define _PREFSDLG_H_ - -#include - -#include "palmmain.h" - -/* How prefs work. - * - * Prefs can be called either directly from the main form or from the new - * game form. If it's called directly, it creates and initializes a - * PrefsDlgState instance. If it's called indirectly, the caller does that - * for it (or in the newGame case may do it anyway so it has defaults to use - * if it's never called). If the user cancels the direct call, any changes - * are ignored. If the user cancels when called from the newGame form we'll - * re-init the structure. - */ - -/* both newgame and prefs need to know about this */ -Boolean PrefsFormHandleEvent( EventPtr event ); -void GlobalPrefsToLocal( PalmAppGlobals* globals ); -XP_Bool LocalPrefsToGlobal( PalmAppGlobals* globals ); - -#endif diff --git a/xwords4/palm/undef_hack.h b/xwords4/palm/undef_hack.h deleted file mode 100644 index c67f9941f..000000000 --- a/xwords4/palm/undef_hack.h +++ /dev/null @@ -1,6 +0,0 @@ -/* HsPhoneTraps.h includes this gem: */ -/* #if (CPU_TYPE == CPU_68K) */ -/* #define PHN_LIB_TRAP(trapNum) SYS_TRAP(trapNum) */ -/* #endif */ - -#define PHN_LIB_TRAP(x) diff --git a/xwords4/palm/xptypes.h b/xwords4/palm/xptypes.h deleted file mode 100644 index 864feb0b7..000000000 --- a/xwords4/palm/xptypes.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 1999-2009 by Eric House (xwords@eehouse.org). All rights - * reserved. - * - * 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 _XPTYPES_H_ -#define _XPTYPES_H_ - -#include -#include -#include -#include - -#define XP_TRUE ((XP_Bool)(1==1)) -#define XP_FALSE ((XP_Bool)(1==0)) - -typedef unsigned char XP_U8; -typedef signed char XP_S8; -typedef unsigned char XP_UCHAR; - -typedef UInt16 XP_U16; -typedef Int16 XP_S16; - -typedef unsigned long XP_U32; -typedef signed long XP_S32; - -typedef signed short XP_FontCode; /* not sure how I'm using this yet */ -typedef Boolean XP_Bool; -typedef XP_U32 XP_Time; - -void palm_debugf(char*, ...); -void palm_assert(Boolean b, int line, const char* func, const char* file ); -void palm_warnf( char* format, ... ); -void palm_logf( char* format, ... ); -XP_U16 palm_snprintf( XP_UCHAR* buf, XP_U16 len, const XP_UCHAR* format, ... ); -XP_S16 palm_memcmp( XP_U8* p1, XP_U8* p2, XP_U16 nBytes ); -XP_U8* palm_realloc(XP_U8* in, XP_U16 size); - -#define XP_CR "\n" -#define XP_S "%s" - -#define XP_RANDOM() SysRandom(0) - -#ifdef MEM_DEBUG -# define XP_PLATMALLOC(nbytes) MemPtrNew(nbytes) -# define XP_PLATREALLOC(p,s) palm_realloc((p),(s)) -# define XP_PLATFREE(p) MemChunkFree(p) -#else -# define XP_MALLOC(p,nbytes) MemPtrNew(nbytes) -# define XP_REALLOC(p,ptr,nbytes) palm_realloc((ptr),(nbytes)) -# define XP_FREE(pool,p) MemChunkFree(p) -#endif - - -#define XP_MEMSET(src, val, nbytes) MemSet( (src), (nbytes), (val) ) -#define XP_MEMCPY(d,s,l) MemMove((d),(s),(l)) -#define XP_MEMCMP( a1, a2, l ) palm_memcmp((XP_U8*)(a1),(XP_U8*)(a2),(l)) -/* MemCmp is reputed not to work on some versions of PalmOS */ -/* #define XP_MEMCMP( a1, a2, l ) MemCmp((a1),(a2),(l)) */ -#define XP_STRLEN(s) StrLen((const char*)s) -#define XP_STRNCMP(s1,s2,l) StrNCompare((const char*)(s1), \ - (const char*)(s2),(l)) -#define XP_STRCMP(s1,s2) StrCompare((s1),(s2)) -#define XP_STRCAT(d,s) StrCat((d),(s)) -#define XP_SNPRINTF palm_snprintf -#define XP_STRNCPY( out, in, len ) StrCopy( out, in ) - -#define XP_MIN(a,b) ((a)<(b)?(a):(b)) -#define XP_MAX(a,b) ((a)>(b)?(a):(b)) -#define XP_ABS(a) ((a)>=0?(a):-(a)) - -#ifdef DEBUG -#define XP_ASSERT(b) palm_assert(b, __LINE__, __func__, __FILE__) -#else -#define XP_ASSERT(b) -#endif - -#ifdef DEBUG -# define XP_DEBUGF(...) palm_debugf(__VA_ARGS__) -#else -# define XP_DEBUGF(...) -#endif - -#define XP_STATUSF XP_LOGF /* for now */ - -#ifdef DEBUG -#define XP_LOGF(...) palm_logf(__VA_ARGS__) -#define XP_WARNF(...) palm_warnf(__VA_ARGS__) -#else -#define XP_WARNF(...) -#define XP_LOGF(...) -#endif - -/* Assumes big-endian, of course */ -#if defined __LITTLE_ENDIAN -# include "pace_man.h" -# define XP_NTOHL(l) Byte_Swap32(l) -# define XP_NTOHS(s) Byte_Swap16(s) -# define XP_HTONL(l) Byte_Swap32(l) -# define XP_HTONS(s) Byte_Swap16(s) -#elif defined __BIG_ENDIAN -# define XP_NTOHL(l) (l) -# define XP_NTOHS(s) (s) -# define XP_HTONL(l) (l) -# define XP_HTONS(s) (s) -#else -# error "pick one!!!" -#endif - -#define XP_LD "%ld" -#define XP_P "%lx" - -#ifdef FEATURE_SILK -# define XP_UNUSED_SILK(x) x -#else -# define XP_UNUSED_SILK(x) XP_UNUSED(x) -#endif - -#ifndef XWFEATURE_IR -# define XP_UNUSED_IR(x) x -#else -# define XP_UNUSED_IR(x) XP_UNUSED(x) -#endif - -#endif - diff --git a/xwords4/palm/xwcolors.h b/xwords4/palm/xwcolors.h deleted file mode 100644 index ca47d0373..000000000 --- a/xwords4/palm/xwcolors.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 2000-2001 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _XWCOLORS_H_ -#define _XWCOLORS_H_ - -#include - -enum { - COLOR_BLACK, - COLOR_WHITE, - - COLOR_PLAYER1, - COLOR_PLAYER2, - COLOR_PLAYER3, - COLOR_PLAYER4, - - COLOR_DBL_LTTR, - COLOR_DBL_WORD, - COLOR_TRPL_LTTR, - COLOR_TRPL_WORD, - - COLOR_EMPTY, - COLOR_TILE, - COLOR_CURSOR, /* not read from resource */ - - COLOR_NCOLORS /* 12 */ -}; - -typedef struct DrawingPrefs { - IndexedColorType drawColors[COLOR_NCOLORS]; -} DrawingPrefs; - -#endif diff --git a/xwords4/palm/xwords4defines.h b/xwords4/palm/xwords4defines.h deleted file mode 100644 index 3fae1fc57..000000000 --- a/xwords4/palm/xwords4defines.h +++ /dev/null @@ -1,464 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * Copyright 1999 - 2008 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _XWORDS4DEFINES_H_ -#define _XWORDS4DEFINES_H_ - - - -#define RECOMMENDED_SBAR_WIDTH 7 -#define SBAR_MIN 13 -#define SBAR_MAX 15 -#define SBAR_PAGESIZE 13 -#define SBAR_START_VALUE SBAR_MIN - -#define TRAY_HEIGHT_LR 21 -#define TRAY_BUTTON_HEIGHT_LR 10 - -#define TRAY_HEIGHT_HR 16 -#define TRAY_BUTTON_HEIGHT_HR 8 -#define TRAY_BUTTON_WIDTH 9 - -#define FLIP_BUTTON_WIDTH 8 -#define FLIP_BUTTON_HEIGHT FLIP_BUTTON_WIDTH -#define BOARD_TOP 8 - -#define TRAY_BUTTONS_Y_LR (160-TRAY_HEIGHT_LR) -#define TRAY_BUTTONS_Y_HR (160-TRAY_HEIGHT_HR) -#define SHOWTRAY_BUTTON_Y (160-FLIP_BUTTON_HEIGHT-5) - -#define IR_STATUS_HEIGHT 12 - -#define PALM_FLIP_LEFT 160-FLIP_BUTTON_WIDTH -#define PALM_TRAY_BUTTON_LEFT 143 - -#define XW_MAIN_FORM 1000 -#define XW_NEWGAMES_FORM 1001 -#define XW_ERROR_ALERT_ID 1002 -#define XW_DICTINFO_FORM 1003 -#define XW_ASK_FORM_ID 1004 -#define XW_PASSWORD_DIALOG_ID 1005 -#define XW_BLANK_DIALOG_ID 1006 -#define XW_COLORPREF_DIALOG_ID 1007 -#define XW_PREFS_FORM 1008 -#define XW_SAVEDGAMES_DIALOG_ID 1009 -#define XW_HINTCONFIG_FORM_ID 1010 -#define XW_CONNS_FORM 1011 -#ifdef FOR_GREMLINS -# define XW_GREMLIN_WARN_FORM_ID 1012 -#endif - -#define XW_ASK_MENU_ID 1001 -#define ASK_COPY_PULLDOWN_ID 1000 -#define ASK_SELECTALL_PULLDOWN_ID 1001 - -#define XW_MAIN_MENU_ID 1000 -#define XW_MAIN_FLIP_BUTTON_ID 1016 -#define XW_MAIN_VALUE_BUTTON_ID 1017 -#define XW_MAIN_TRAY_BUTTON_ID 1018 -#define XW_MAIN_SCROLLBAR_ID 1019 -#ifndef EIGHT_TILES -#define XW_MAIN_DONE_BUTTON_ID 1020 -#define XW_MAIN_JUGGLE_BUTTON_ID 1021 -#define XW_MAIN_TRADE_BUTTON_ID 1022 -#define XW_MAIN_HIDE_BUTTON_ID 1023 -#endif -#define XW_MAIN_HINT_BUTTON_ID 1024 -#define XW_MAIN_SHOWTRAY_BUTTON_ID 1026 -//#define XW_MAIN_OK_BUTTON_ID 1026 - -#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY -# define XW_NETSTATUS_GADGET_ID 1099 /* change later */ -#endif - -#ifdef FOR_GREMLINS -# define GREMLIN_BOARD_GADGET_IDAUTOID 1027 -# define GREMLIN_TRAY_GADGET_IDAUTOID 1028 -#endif - -/* File menu */ -#define XW_NEWGAME_PULLDOWN_ID 1050 -#define XW_SAVEDGAMES_PULLDOWN_ID 1051 -#define XW_BEAMDICT_PULLDOWN_ID 1052 -#define XW_BEAMBOARD_PULLDOWN_ID 1053 -#define XW_PREFS_PULLDOWN_ID 1054 -#define XW_ABOUT_PULLDOWN_ID 1055 - -/* Game menu */ -#define XW_TILEVALUES_PULLDOWN_ID 1056 -#define XW_TILESLEFT_PULLDOWN_ID 1057 -#define XW_PASSWORDS_PULLDOWN_ID 1058 -#define XW_HISTORY_PULLDOWN_ID 1059 -#define XW_FINISH_PULLDOWN_ID 1060 -#ifndef XWFEATURE_STANDALONE_ONLY -# define XW_RESENDIR_PULLDOWN_ID 1061 -#endif - -/* Move menu */ -#define XW_HINT_PULLDOWN_ID 1062 -#define XW_NEXTHINT_PULLDOWN_ID 1063 -#ifdef XWFEATURE_SEARCHLIMIT -# define XW_HINTCONFIG_PULLDOWN_ID 1064 -#endif -#define XW_UNDOCUR_PULLDOWN_ID 1065 -#define XW_UNDOLAST_PULLDOWN_ID 1066 -#define XW_DONE_PULLDOWN_ID 1067 -#define XW_JUGGLE_PULLDOWN_ID 1068 -#define XW_TRADEIN_PULLDOWN_ID 1069 -#define XW_HIDESHOWTRAY_PULLDOWN_ID 1070 - -#ifdef FEATURE_DUALCHOOSE -# define XW_RUN68K_PULLDOWN_ID 1071 -# define XW_RUNARM_PULLDOWN_ID 1072 -#endif - -/* debug menu */ -#ifdef DEBUG -# define XW_LOGFILE_PULLDOWN_ID 2000 -# define XW_LOGMEMO_PULLDOWN_ID 2001 -# define XW_CLEARLOGS_PULLDOWN_ID 2002 -# define XW_NETSTATS_PULLDOWN_ID 2003 -# define XW_MEMSTATS_PULLDOWN_ID 2004 -# define XW_BTSTATS_PULLDOWN_ID 2005 -#endif - -#ifdef FOR_GREMLINS -#define XW_GREMLIN_DIVIDER_RIGHT 2010 -#define XW_GREMLIN_DIVIDER_LEFT 2011 -#endif - -#define XW_DICT_SELECTOR_ID 1038 -#define XW_OK_BUTTON_ID 1039 -#define XW_CANCEL_BUTTON_ID 1040 -/* #define XW_DICT_BUTTON_ID 1040 */ - -#define MAX_GAMENAME_LENGTH 32 -#define MAX_PLAYERNAME_LENGTH 32 - -#define NUM_PLAYER_COLS 4 /* name, local, robot and passwd */ -#define PALM_MAX_ROWS 15 /* max is a 15x15 grid on palm */ -#define PALM_MAX_COLS 15 /* max is a 15x15 grid on palm */ - -#define NUM_BOARD_SIZES 3 /* 15x15, 13x13 and 11x11 */ - -#define XW_PLAYERNAME_1_FIELD_ID 2100 -#define XW_ROBOT_1_CHECKBOX_ID 2101 -#define XW_REMOTE_1_CHECKBOX_ID 2102 -#define XW_PLAYERPASSWD_1_TRIGGER_ID 2103 - -#define XW_PLAYERNAME_2_FIELD_ID 2104 -#define XW_ROBOT_2_CHECKBOX_ID 2105 -#define XW_REMOTE_2_CHECKBOX_ID 2106 -#define XW_PLAYERPASSWD_2_TRIGGER_ID 2107 - -#define XW_PLAYERNAME_3_FIELD_ID 2108 -#define XW_ROBOT_3_CHECKBOX_ID 2109 -#define XW_REMOTE_3_CHECKBOX_ID 2110 -#define XW_PLAYERPASSWD_3_TRIGGER_ID 2111 - -#define XW_PLAYERNAME_4_FIELD_ID 2112 -#define XW_ROBOT_4_CHECKBOX_ID 2113 -#define XW_REMOTE_4_CHECKBOX_ID 2114 -#define XW_PLAYERPASSWD_4_TRIGGER_ID 2115 - -#define XW_NPLAYERS_LIST_ID 2121 -#define XW_NPLAYERS_SELECTOR_ID 2122 -#define XW_PREFS_BUTTON_ID 2123 -#define XW_GINFO_JUGGLE_ID 2124 - -#ifndef XWFEATURE_STANDALONE_ONLY -#define XW_SOLO_GADGET_ID 2125 -#define XW_SERVER_GADGET_ID 2126 -#define XW_CLIENT_GADGET_ID 2127 -#define XW_SERVERTYPES_LIST_ID 2128 -#endif - -#ifdef FOR_GREMLINS -# define XW_GREMLIN_WARN_FIELD_ID 2129 -#endif - - -/* we need to hide these labels, so no AUTOID */ -#ifndef XWFEATURE_STANDALONE_ONLY -# define XW_LOCAL_LABEL_ID 2130 -# define XW_TOTALP_FIELD_ID 2131 -# define XW_LOCALP_LABEL_ID 2132 -#endif - -#define REFCON_GADGET_ID 3000 - -#define XW_ASK_TXT_FIELD_ID 2200 -#define XW_ASK_YES_BUTTON_ID 2201 -#define XW_ASK_NO_BUTTON_ID 2202 -#define XW_ASK_SCROLLBAR_ID 2203 - -#define MAX_PASSWORD_LENGTH 4 /* server.c has no limit */ -#define XW_PASSWORD_CANCEL_BUTTON 2300 -#define XW_PASSWORD_NAME_LABEL 2301 -#define XW_PASSWORD_NEWNAME_LABEL 2302 -#define XW_PASSWORD_NAME_FIELD 2303 -#define XW_PASSWORD_PASS_FIELD 2304 -#define XW_PASSWORD_OK_BUTTON 2305 - -#define XW_BLANK_LIST_ID 2401 -#define XW_BLANK_LABEL_FIELD_ID 2402 -#define XW_BLANK_OK_BUTTON_ID 2403 -#define XW_BLANK_PICK_BUTTON_ID 2404 -#define XW_BLANK_BACKUP_BUTTON_ID 2405 - -#define XW_COLORS_FACTORY_BUTTON_ID 2520 -#define XW_COLORS_OK_BUTTON_ID 2521 -#define XW_COLORS_CANCEL_BUTTON_ID 2522 - -#define STRL_RES_TYPE 'StrL' -#define XW_STRL_RESOURCE_ID 1000 - -#define BOARD_RES_TYPE 'Xbrd' -#define BOARD_RES_ID 1000 - -#define COLORS_RES_TYPE 'Clrs' -#define COLORS_RES_ID 1000 - -#define CARD_0 0 -#ifdef DEBUG -# define XW_GAMES_DBNAME "xw4games_dbg" -# define XWORDS_GAMES_TYPE 'Xwdg' -# define XW_PREFS_DBNAME "xw4prefs_dbg" -# define XWORDS_PREFS_TYPE 'Xwpd' -#else -# define XW_GAMES_DBNAME "xw4games" -# define XWORDS_GAMES_TYPE 'Xwgm' -# define XW_PREFS_DBNAME "xw4prefs" -# define XWORDS_PREFS_TYPE 'Xwpr' -#endif - -#define XW_DICTINFO_LIST_ID 2601 -#define XW_DICTINFO_TRIGGER_ID 2602 -#define XW_PHONIES_TRIGGER_ID 2603 -#define XW_PHONIES_LABLE_ID 2604 -#define XW_PHONIES_LIST_ID 2605 -#define XW_DICTINFO_DONE_BUTTON_ID 2606 -#define XW_DICTINFO_BEAM_BUTTON_ID 2607 -#define XW_DICTINFO_CANCEL_BUTTON_ID 2608 - -/* - * prefs dialog - */ -#define XW_PREFS_ALLGAMES_GADGET_ID 2700 -#define XW_PREFS_ONEGAME_GADGET_ID 2701 -#define XW_PREFS_TYPES_LIST_ID 2702 - -/* global */ -#define XW_PREFS_PLAYERCOLORS_CHECKBOX_ID 2708 -#define XW_PREFS_PROGRESSBAR_CHECKBOX_ID 2709 -#define XW_PREFS_SHOWGRID_CHECKBOX_ID 2710 -#define XW_PREFS_SHOWARROW_CHECKBOX_ID 2711 -#define XW_PREFS_ROBOTSCORE_CHECKBOX_ID 2712 -#define XW_PREFS_HIDETRAYVAL_CHECKBOX_ID 2713 - -/* per-game */ -#define XW_PREFS_ROBOTSMART_CHECKBOX_ID 2715 -#define XW_PREFS_PHONIES_LABEL_ID 2716 -#define XW_PREFS_PHONIES_TRIGGER_ID 2717 -#define XW_PREFS_BDSIZE_LABEL_ID 2718 -#define XW_PREFS_BDSIZE_SELECTOR_ID 2719 -#define XW_PREFS_NOHINTS_CHECKBOX_ID 2720 -#define XW_PREFS_TIMERON_CHECKBOX_ID 2721 -#define XW_PREFS_TIMER_FIELD_ID 2722 - -#ifdef FEATURE_TRAY_EDIT -# define XW_PREFS_PICKTILES_CHECKBOX_ID 2723 -# ifdef XWFEATURE_SEARCHLIMIT -# define XW_PREFS_HINTRECT_CHECKBOX_ID 2724 -# endif -#else -# ifdef XWFEATURE_SEARCHLIMIT -# define XW_PREFS_HINTRECT_CHECKBOX_ID 2723 -# endif -#endif - -/* May be overridden below */ -#define XW_PREFS_LAST_PERGAME_ID XW_PREFS_PICKTILES_CHECKBOX_ID - -#ifdef XWFEATURE_BLUETOOTH -# define XW_PREFS_BTCONFIRM_CHECKBOX_ID 2725 -# undef XW_PREFS_LAST_PERGAME_ID -# define XW_PREFS_LAST_PERGAME_ID XW_PREFS_BTCONFIRM_CHECKBOX_ID -#endif - -#ifdef XWFEATURE_FIVEWAY -/* These should be in same order as BoardObjectType */ -# define XW_BOARD_GADGET_ID 3001 -# define XW_SCOREBOARD_GADGET_ID 3002 -# define XW_TRAY_GADGET_ID 3003 -#endif - - -/* These aren't part of the hide/show thing as they're displayed only - * explicitly byother controls */ -#define XW_PREFS_PHONIES_LIST_ID 2750 -#define XW_PREFS_BDSIZE_LIST_ID 2751 - -/* These are used to set/clear the "pages" of the prefs dialog. */ -#define XW_PREFS_FIRST_GLOBAL_ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID -#define XW_PREFS_LAST_GLOBAL_ID XW_PREFS_HIDETRAYVAL_CHECKBOX_ID -#define XW_PREFS_FIRST_PERGAME_ID XW_PREFS_ROBOTSMART_CHECKBOX_ID - -/* #if defined XWFEATURE_SEARCHLIMIT */ -/* # define XW_PREFS_LAST_PERGAME_ID XW_PREFS_HINTRECT_CHECKBOX_ID */ -/* #elif defined FEATURE_TRAY_EDIT */ -/* # define XW_PREFS_LAST_PERGAME_ID XW_PREFS_PICKTILES_CHECKBOX_ID */ -/* #else */ -/* # define XW_PREFS_LAST_PERGAME_ID XW_PREFS_TIMER_FIELD_ID */ -/* #endif */ - -#define XW_PREFS_CANCEL_BUTTON_ID 2726 -#define XW_PREFS_OK_BUTTON_ID 2727 - -/* - * saved games dialog - */ -#define XW_SAVEDGAMES_LIST_ID 2800 -#define XW_SAVEDGAMES_NAME_FIELD 2801 -#define XW_SAVEDGAMES_USE_BUTTON 2802 -#define XW_SAVEDGAMES_DUPE_BUTTON 2803 -#define XW_SAVEDGAMES_DELETE_BUTTON 2804 -#define XW_SAVEDGAMES_OPEN_BUTTON 2805 -#define XW_SAVEDGAMES_DONE_BUTTON 2806 -#define MAX_GAME_NAME_LENGTH 31 - -/* - * Connections dlg (XW_CONNS_FORM) - */ -#define XW_CONNS_CANCEL_BUTTON_ID 2900 -#define XW_CONNS_OK_BUTTON_ID 2901 -#define XW_CONNS_TYPE_TRIGGER_ID 2902 -#define XW_CONNS_TYPE_LIST_ID 2903 -#ifdef XWFEATURE_RELAY -# define XW_CONNS_RELAY_LABEL_ID 2904 -# define XW_CONNS_INVITE_FIELD_ID 2905 -# define XW_CONNS_INVITE_LABEL_ID 2906 -# define XW_CONNS_PORT_LABEL_ID 2907 -# define XW_CONNS_RELAY_FIELD_ID 2908 -# define XW_CONNS_PORT_FIELD_ID 2909 -#endif - -#ifdef XWFEATURE_BLUETOOTH -# define XW_CONNS_BT_HOSTNAME_LABEL_ID 2911 -# define XW_CONNS_BT_HOSTTRIGGER_ID 2912 -# define XW_CONNS_BTCONFIRM_CHECKBOX_ID 2913 -#endif - -/* - * selector for number of tiles during hint - */ -#define XW_HINTCONFIG_MINLIST_ID 2950 -#define XW_HINTCONFIG_MAXLIST_ID 2951 -#define XW_HINTCONFIG_MAXSELECTOR_ID 2952 -#define XW_HINTCONFIG_MINSELECTOR_ID 2953 -#define XW_HINTCONFIG_OK_ID 2954 -#define XW_HINTCONFIG_CANCEL_ID 2955 - -#define PALM_BOARD_TOP 8 -#define PALM_GRIDLESS_BOARD_TOP 2 - -#define PALM_BOARD_SCALE 10 -#define PALM_SCORE_LEFT 0 -#define PALM_SCORE_TOP 0 -#define PALM_SCORE_HEIGHT BOARD_TOP - -#define PALM_GRIDLESS_SCORE_WIDTH 22 -#define PALM_GRIDLESS_SCORE_LEFT (160-PALM_GRIDLESS_SCORE_WIDTH) -#define PALM_GRIDLESS_SCORE_TOP 42 - -#define PALM_TIMER_TOP 0 -#define PALM_TIMER_HEIGHT PALM_SCORE_HEIGHT - -/* #define PALM_TRAY_LEFT 0 */ -#define PALM_TRAY_TOP (160-PALM_TRAY_SCALEV-1) -#define PALM_TRAY_TOP_MAX 144 /* the lowest we can put the top */ -#define PALM_TRAY_WIDTH 143 -#ifdef EIGHT_TILES -#define PALM_TRAY_SCALEV 18 -#else -#define PALM_TRAY_SCALEV 20 -#endif -#define PALM_DIVIDER_WIDTH 3 - -#define PALM_BOARD_LEFT_LH 9 -#define PALM_BOARD_LEFT_RH 0 -#define PALM_TRAY_LEFT_LH 17 -#define PALM_TRAY_LEFT_RH 0 - - -/* resource IDs */ -#define DOWN_ARROW_RESID 2001 -#define RIGHT_ARROW_RESID 2002 -#define FLIP_BUTTON_BMP_RES_ID 2003 -#define VALUE_BUTTON_BMP_RES_ID 2004 -#define HINT_BUTTON_BMP_RES_ID 2005 -#define TRAY_BUTTONS_BMP_RES_ID 2007 -#define SHOWTRAY_BUTTON_BMP_RES_ID 2008 -#define STAR_BMP_RES_ID 2009 - -#ifdef XWFEATURE_BLUETOOTH -# define BTSTATUS_NONE_RES_ID 2010 -# define BTSTATUS_LISTENING_RES_ID 2011 -# define BTSTATUS_SEEKING_RES_ID 2012 -# define BTSTATUS_CONNECTED_RES_ID 2013 -#endif - -#ifdef XWFEATURE_RELAY -# define RELAYSTATUS_NONE_RESID 2014 -# define RELAYSTATUS_PENDING_RESID 2015 -# define RELAYSTATUS_CONN_RESID 2016 -# define RELAYSTATUS_ALLCONN_RESID 2017 -#endif - -#define STRL_RES_TYPE 'StrL' -#define STRL_RES_ID 0x03e8 - -#if 0 -# define DMFINDDATABASE(g,c,n) DmFindDatabase( (c),(n) ) -# define DMOPENDATABASE(g,c,i,m) DmOpenDatabase( (c),(i),(m)) -# define DMCLOSEDATABASE(d) DmCloseDatabase( d ) -#else -# define DMFINDDATABASE(g,c,n) (g)->gamesDBID -# define DMOPENDATABASE(g,c,i,m) (g)->gamesDBP -# define DMCLOSEDATABASE(d) -#endif - -#define kFrmNavHeaderFlagsObjectFocusStartState 0x00000001 -#define kFrmNavHeaderFlagsAppFocusStartState 0x00000002 - -/* versioning stuff */ - -#if defined XWFEATURE_RELAY -# define XW_PALM_VERSION_STRING "4.4a1" -#elif defined XWFEATURE_BLUETOOTH -# define XW_PALM_VERSION_STRING "4.3b6" -#else -/* There's a separate branch for 2.4 releases now. */ -# define XW_PALM_VERSION_STRING "4.2.1" -#endif -#define CUR_PREFS_VERS 0x0405 - - - -#endif diff --git a/xwords4/symbian/aif/lrgicon.bmp b/xwords4/symbian/aif/lrgicon.bmp deleted file mode 100755 index ff4c530e6..000000000 Binary files a/xwords4/symbian/aif/lrgicon.bmp and /dev/null differ diff --git a/xwords4/symbian/aif/lrgiconmask.bmp b/xwords4/symbian/aif/lrgiconmask.bmp deleted file mode 100755 index 348a59b47..000000000 Binary files a/xwords4/symbian/aif/lrgiconmask.bmp and /dev/null differ diff --git a/xwords4/symbian/aif/xwaif.rss b/xwords4/symbian/aif/xwaif.rss deleted file mode 100755 index 6a69ff0ab..000000000 --- a/xwords4/symbian/aif/xwaif.rss +++ /dev/null @@ -1,15 +0,0 @@ -// -*- mode: c; -*- -// -// -#include - -RESOURCE AIF_DATA -{ - caption_list = { - CAPTION { code = ELangEnglish; caption = "Crosswords"; } - }; - - app_uid = 0x10206D64; - - num_icons = 1; -} diff --git a/xwords4/symbian/bmps/downarrow_80.bmp b/xwords4/symbian/bmps/downarrow_80.bmp deleted file mode 100644 index dba735702..000000000 Binary files a/xwords4/symbian/bmps/downarrow_80.bmp and /dev/null differ diff --git a/xwords4/symbian/bmps/rightarrow_80.bmp b/xwords4/symbian/bmps/rightarrow_80.bmp deleted file mode 100644 index 2047ced4a..000000000 Binary files a/xwords4/symbian/bmps/rightarrow_80.bmp and /dev/null differ diff --git a/xwords4/symbian/bmps/robot_80.bmp b/xwords4/symbian/bmps/robot_80.bmp deleted file mode 100644 index 969f1b65f..000000000 Binary files a/xwords4/symbian/bmps/robot_80.bmp and /dev/null differ diff --git a/xwords4/symbian/bmps/robotmask_80.bmp b/xwords4/symbian/bmps/robotmask_80.bmp deleted file mode 100644 index 74870557c..000000000 Binary files a/xwords4/symbian/bmps/robotmask_80.bmp and /dev/null differ diff --git a/xwords4/symbian/bmps/star_80.bmp b/xwords4/symbian/bmps/star_80.bmp deleted file mode 100644 index 2823e2114..000000000 Binary files a/xwords4/symbian/bmps/star_80.bmp and /dev/null differ diff --git a/xwords4/symbian/bmps/turnicon_80.bmp b/xwords4/symbian/bmps/turnicon_80.bmp deleted file mode 100755 index 8d965ebfa..000000000 Binary files a/xwords4/symbian/bmps/turnicon_80.bmp and /dev/null differ diff --git a/xwords4/symbian/bmps/turniconmask_80.bmp b/xwords4/symbian/bmps/turniconmask_80.bmp deleted file mode 100755 index cd9eaace4..000000000 Binary files a/xwords4/symbian/bmps/turniconmask_80.bmp and /dev/null differ diff --git a/xwords4/symbian/group/.cvsignore b/xwords4/symbian/group/.cvsignore deleted file mode 100644 index 7f4de9a8f..000000000 --- a/xwords4/symbian/group/.cvsignore +++ /dev/null @@ -1,24 +0,0 @@ -XWORDS.DSP -XWORDS.opt -ABLD.BAT -XWORDS.plg -XWORDS.SUP.MAKE -XWORDS.DSW -XWORDS.DSP -XWORDS.UID.CPP -xwords_*.mbg -xwords_*.pkg -xwords_*.aif -xwords_*.aifspec -xwords_*.ex1 -xwords_*.mbm -xwords_*.sis -xwords_*.rsg -xwords_*.app -xwords_*.rsc -icon.series*.mbm -*.def -*.ilk -*.pdb -*.ncb -*.OPT diff --git a/xwords4/symbian/group/Makefile b/xwords4/symbian/group/Makefile deleted file mode 100644 index e5853a5e7..000000000 --- a/xwords4/symbian/group/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -*- mode: makefile; -*- - -# The braindead build system doesn't remove object files from these -# dirs. So add to the clean target manually -# COMMON_OBJ_DIR = $(EPOC)/BUILD/CYGWIN$(shell pwd)/xwords/symbian/group/common/armi/urel -# XWORDS_OBJ_DIR = $(EPOC)/BUILD/CYGWIN$(shell pwd)/xwords/symbian/group/XWORDS/armi/urel - -ifdef VERB -BLDMAKE_FLAGS = -v -endif - -# There are no rules for building these puppies -- the symbian build -# system does that. But they'd better exist by the time we get to the -# .pkg target. -SISFILES = \ - $(EPOC)/release/armi/urel/xwords.APP \ - $(EPOC)\\data/z/system/apps/xwords/xwords.rsc \ - $(EPOC)\\data/z/system/apps/xwords/xwords.aif \ - $(EPOC)\\data/z/system/apps/xwords/xwords.mbm \ - ../../dawg/English/BasEnglish2to8.xwd \ - -all: wins - -ABLD.BAT: - bldmake $(BLDMAKE_FLAGS) bldfiles - -wins: ABLD.BAT - $< build $(BLDMAKE_FLAGS) wins udeb - -armi: ABLD.BAT - $< build $(BLDMAKE_FLAGS) armi urel - -# depends on wins because that's where the .aif file gets built -sis: wins armi xwords.pkg - makesis -v xwords.pkg - -# If this xwords.pkg target generates errors -- especially the &EN -# part -- you're probably running symbian's make instead of cygwin's. -# Try invoking this Makefile with /usr/bin/make explicitly: -# /usr/bin/make sis -xwords.pkg: Makefile $(SISFILES) - rm -f $@ - @echo "&EN" | tr -d '\r' >> $@ - @echo '#{"Crosswords"},(0x10206D64),1,0,0' | tr -d '\r' >> $@ - @for f in $(SISFILES); do \ - bname=$$(basename "$$f"); \ - echo \"$$f\"-\"C:\\system\\apps\\xwords\\$$bname\" >> $@; \ - done - -# build project files for M$ VC++ version 6, e.g. for source-level -# debugging -vc6: - makmake.exe xwords vc6 - -clean: - rm -f xwords.SIS xwords.pkg - rm -f $(COMMON_OBJ_DIR)/*.o - rm -f $(XWORDS_OBJ_DIR)/*.o - if [ -f abLD.BAT ]; then \ - ./abLD.BAT clean wins udeb; \ - ./abLD.BAT clean armi udeb; \ - fi - bldmake $(BLDMAKE_FLAGS) clean diff --git a/xwords4/symbian/group/bld.inf b/xwords4/symbian/group/bld.inf deleted file mode 100644 index ad40c8577..000000000 --- a/xwords4/symbian/group/bld.inf +++ /dev/null @@ -1,5 +0,0 @@ -PRJ_MMPFILES - -common.mmp -xwords.mmp - diff --git a/xwords4/symbian/group/bldlinux.mk b/xwords4/symbian/group/bldlinux.mk deleted file mode 100644 index 9d10fe7c0..000000000 --- a/xwords4/symbian/group/bldlinux.mk +++ /dev/null @@ -1,186 +0,0 @@ -# -*- mode: Makefile; compile-command: "make -f bldlinux.mk" -*- - -SERIES ?= 80 -DEBUG ?= TRUE - -# User should define EPOC_80 and/or EPOC_60 in the environment -EPOC = $(EPOC_$(SERIES)) - - -PATH = $(EPOC)/bin:/local/bin:/usr/bin:/bin - -BMCONV = bmconv - -include $(EPOC)/lib/makerules/eikon - -COMMONDIR = ../../common -PLATFORM = SYMB_$(SERIES) -XWORDS_DIR = \"xwords_$(SERIES)\" - -include ../../common/config.mk - -#STANDALONE_ONLY ?= -DXWFEATURE_STANDALONE_ONLY -BEYOND_IR = -DBEYOND_IR - -LIBS_ALLSERIES = \ - $(EPOCTRGREL)/euser.lib \ - $(EPOCTRGREL)/apparc.lib \ - $(EPOCTRGREL)/cone.lib \ - $(EPOCTRGREL)/gdi.lib \ - $(EPOCTRGREL)/eikcoctl.lib \ - $(EPOCTRGREL)/eikcore.lib \ - $(EPOCTRGREL)/bafl.lib \ - $(EPOCTRGREL)/egul.lib \ - $(EPOCTRGREL)/estlib.lib \ - $(EPOCTRGREL)/flogger.lib \ - $(EPOCTRGREL)/commonengine.lib \ - $(EPOCTRGREL)/eikdlg.lib \ - $(EPOCTRGREL)/fbscli.lib \ - $(EPOCTRGREL)/efsrv.lib \ - $(EPOCTRGREL)/estor.lib \ - $(EPOCTRGREL)/ws32.lib \ - $(EPOCTRGREL)/insock.lib \ - $(EPOCTRGREL)/esock.lib \ - -LIBS_60 = \ - $(EPOCTRGREL)/eikcore.lib \ - $(EPOCTRGREL)/avkon.lib \ - $(EPOCTRGREL)/eikcdlg.lib \ - -LIBS_80 = \ - $(EPOCTRGREL)/ckndlg.lib \ - $(EPOCTRGREL)/ckncore.lib \ - $(EPOCTRGREL)/eikfile.lib \ - $(EPOCTRGREL)/eikctl.lib \ - $(EPOCTRGREL)/bitgdi.lib \ - -LIBS = $(LIBS_ALLSERIES) $(LIBS_$(SERIES)) - -# fntstr.lib \ -# $(EPOCTRGREL)/bitgdi.lib \ - -NAME = xwords_$(SERIES) -USERNAME = Crosswords -ARCH = series$(SERIES) -SYMARCH = SERIES_$(SERIES) - -SRCDIR = ../src -INCDIR = -I. -I $(EPOC)/include -I $(EPOC)/include/libc -I../inc \ - $(subst ../,../../,$(COMMON_INCS)) -LCLSRC = \ - $(SRCDIR)/xwmain.cpp \ - $(SRCDIR)/xwapp.cpp \ - $(SRCDIR)/symaskdlg.cpp \ - $(SRCDIR)/symdraw.cpp \ - $(SRCDIR)/xwappview.cpp \ - $(SRCDIR)/symdict.cpp \ - $(SRCDIR)/symutil.cpp \ - $(SRCDIR)/xwappui.cpp \ - $(SRCDIR)/xwdoc.cpp \ - $(SRCDIR)/symgmmgr.cpp \ - $(SRCDIR)/symgmdlg.cpp \ - $(SRCDIR)/symblnk.cpp \ - $(SRCDIR)/symgamdl.cpp \ - $(SRCDIR)/symgamed.cpp \ - $(SRCDIR)/symssock.cpp \ - -IMG_SRC = ../bmps/downarrow_80.bmp \ - ../bmps/rightarrow_80.bmp \ - ../bmps/star_80.bmp \ - ../bmps/turnicon_80.bmp \ - ../bmps/turniconmask_80.bmp \ - ../bmps/robot_80.bmp \ - ../bmps/robotmask_80.bmp \ - -AIF = ../aif -ICON_SRC = \ - $(AIF)/lrgicon.bmp \ - $(AIF)/lrgiconmask.bmp \ - -OBJDIR = $(SRCDIR)/$(PLATFORM) - -OBJECTS = $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(LCLSRC:.cpp=.o)) $(COMMONOBJ) - -THEAPP = $(NAME).app -MAJOR = 4 -MINOR = 1 -PKGVERS = $(MAJOR),$(MINOR) -SISNAME = $(NAME)-$(MAJOR).$(MINOR)-$(ARCH).sis - -MBG = $(NAME).mbg - -PKGFILES=$(THEAPP) $(NAME).aif $(NAME).rsc $(NAME).mbm BasEnglish2to8.xwd - -U1 = 1000007a -U2 = 100039ce -U3 = 10206D64 - -ifeq ($(DEBUG),TRUE) -DEBUG_FLAGS = -DDEBUG -DMEM_DEBUG -else -OPT = -O2 -fomit-frame-pointer -endif - -CFLAGS += $(OPT) -I. -DUID3=0x$(U3) $(DEBUG_FLAGS) \ - -DXWORDS_DIR=$(XWORDS_DIR) \ - -D__LITTLE_ENDIAN -DKEYBOARD_NAV \ - -DKEY_SUPPORT -DFEATURE_TRAY_EDIT -DNODE_CAN_4 \ - $(STANDALONE_ONLY) -D$(SYMARCH) \ - -DSYM_ARMI -DOS_INITS_DRAW $(BEYOND_IR) \ - $(INCDIR) - -# This violates the no-data rule. Don't allow it for ARMI build. -# It's ok for WINS builds since the rules are relaxed there. - -# CFLAGS += -DSTUBBED_DICT - -CPFLAGS = $(CFLAGS) -DCPLUS - -# Following is used for the resource file -CPPFLAGS += -D_EPOC32_6 -DCPLUS -I../inc -D$(SYMARCH) \ - $(subst ../,../../,$(COMMON_INCS)) - -all: _sanity $(PKGFILES) $(NAME).sis - mv $(NAME).sis $(SISNAME) -ifdef XW_UPLOAD_CMD - $(XW_UPLOAD_CMD) $(SISNAME) -endif - -_sanity: - @if [ "$(EPOC_$(SERIES))" = "" ]; then \ - echo " ---> ERROR: EPOC_$(SERIES) undefined in env"; \ - exit 1; \ - fi - -$(THEAPP): $(NAME).rsc $(MBG) $(OBJECTS) - -icon.$(ARCH).mbm: $(ICON_SRC) - $(BMCONV) $@ $(subst ..,/c8..,$^) - -$(NAME).aifspec: icon.$(ARCH).mbm - @echo "mbmfile=$<" > $@ - @echo "ELangEnglish=$(USERNAME)" >> $@ - -# I'm adding my own rules here because I can't figure out how to use -# the default ones when src and obj live in different directories. -$(COMMONOBJDIR)/%.o: $(COMMONDIR)/%.c - mkdir -p $(COMMONOBJDIR) - $(CC) $(CFLAGS) -c -o $@ $< - -$(OBJDIR)/%.o: $(SRCDIR)/%.cpp - mkdir -p $(OBJDIR) - $(CCC) $(CPFLAGS) -c -o $@ $< - -$(NAME).mbg $(NAME).mbm: $(IMG_SRC) - $(BMCONV) /h$(NAME).mbg $(NAME).mbm $(subst ..,/2..,$(IMG_SRC)) - -# temporary hack until I get 'round to breaking the .rss file into -# common, 60 and 80 (with the latter two including the first). -$(NAME).rss: xwords.rss - ln -s $< $@ - -BasEnglish2to8.xwd: ../../dawg/English/BasEnglish2to8.xwd - ln -s $< $@ - -clean: - rm -f $(GENERATED) $(NAME).aifspec $(OBJECTS) $(MBG) *.mbm diff --git a/xwords4/symbian/group/bldwin.mk b/xwords4/symbian/group/bldwin.mk deleted file mode 100755 index a201da672..000000000 --- a/xwords4/symbian/group/bldwin.mk +++ /dev/null @@ -1,303 +0,0 @@ -# -*- mode: Makefile; compile-command: "/usr/bin/make -f bldwin.mk" -*- - -SERIES ?= 80 -TARGET ?= WINS - -#U1 = 1000007a -U1 = 10000079 -U2 = 100039ce -U3 = 10206D64 - -# User should define EPOC_80 and/or EPOC_60 in the environment -EPOC = $(EPOC_$(SERIES)) -NAME = xwords_$(SERIES) -DESTDIR = $(EPOC)/wins/c/system/Apps/$(NAME) -DICT = ../../dawg/English/BasEnglish2to8.xwd -EDLL_LIB = $(EPOC)/release/wins/udeb/edll.lib - -#CPP = $(EPOC)/gcc/bin/gcc -E -CPP = $(EPOC)/gcc/arm-epoc-pe/bin/gcc.exe -E - -RC = rcomp -GA = genaif -PT = $(EPOC)/tools/petran -LIB = lib.exe -PERL = c:/activePerl/bin/perl -MAKEDEF = makedef.pl -EPOCRC = epocrc.pl -ECOPYFILE = ecopyfile.pl -LINK = $(MSVC_DIR)/Bin/link.exe -DUMPBIN = $(MSVC_DIR)/Bin/dumpbin.exe -LIB = $(MSVC_DIR)/Bin/lib.exe -ECHO = /usr/bin/echo - -#STANDALONE_ONLY = -DXWFEATURE_STANDALONE_ONLY - -COMMON_FLAGS = \ - -D$(SYMARCH) -D__LITTLE_ENDIAN -DKEYBOARD_NAV \ - -DKEY_SUPPORT -DFEATURE_TRAY_EDIT -DNODE_CAN_4 \ - -DOS_INITS_DRAW $(STANDALONE_ONLY) - -RSS_DEFS = $(COMMON_FLAGS) - -################################################## -# WINS- vs ARMI-specific settings -################################################## -ifeq ($(TARGET),WINS) -######################### -# WINS -######################### -CC = $(VSDIR)/VC98/Bin/CL.EXE -CL_FLAGS = \ - /MDd /Zi /Yd /Od /nologo /Zp4 /GF /QIfist /X /W4 \ - /D _DEBUG /D _UNICODE /D UNICODE /D "__SYMBIAN32__" \ - /D "__VC32__" /D "__WINS__" \ - -CFLAGS += $(CL_FLAGS) -I. -DUID3=0x$(U3) $(DEBUG_FLAGS) \ - -D$(SYMARCH) $(COMMON_FLAGS) \ - -DSYM_WINS \ - $(INCDIR) - -else -ifeq ($(TARGET),ARMI) -######################### -# ARMI (incomplete; build -# with linux. :-) -######################### - -CC = $(EPOC)/gcc/bin/g++.exe - -endif -endif - -BMCONV = bmconv - -COMMONDIR = ../../common -PLATFORM = SYMB_$(SERIES)_$(TARGET) -XWORDS_DIR = \"xwords_$(SERIES)\" - -include $(COMMONDIR)/config.mk - -EPOCTRGREL = $(EPOC)/release/wins/udeb - -LIBS_ALLSERIES = \ - $(EPOCTRGREL)/euser.lib \ - $(EPOCTRGREL)/apparc.lib \ - $(EPOCTRGREL)/cone.lib \ - $(EPOCTRGREL)/gdi.lib \ - $(EPOCTRGREL)/eikcoctl.lib \ - $(EPOCTRGREL)/eikcore.lib \ - $(EPOCTRGREL)/bafl.lib \ - $(EPOCTRGREL)/egul.lib \ - $(EPOCTRGREL)/estlib.lib \ - $(EPOCTRGREL)/flogger.lib \ - $(EPOCTRGREL)/commonengine.lib \ - $(EPOCTRGREL)/eikdlg.lib \ - $(EPOCTRGREL)/fbscli.lib \ - $(EPOCTRGREL)/efsrv.lib \ - $(EPOCTRGREL)/estor.lib \ - $(EPOCTRGREL)/ws32.lib \ - $(EPOCTRGREL)/insock.lib \ - $(EPOCTRGREL)/esock.lib \ - -LIBS_60 = \ - $(EPOCTRGREL)/eikcore.lib \ - $(EPOCTRGREL)/avkon.lib \ - $(EPOCTRGREL)/eikcdlg.lib \ - -LIBS_80 = \ - $(EPOCTRGREL)/ckndlg.lib \ - $(EPOCTRGREL)/ckncore.lib \ - $(EPOCTRGREL)/eikfile.lib \ - $(EPOCTRGREL)/eikctl.lib \ - $(EPOCTRGREL)/bitgdi.lib \ - -LIBS = $(LIBS_ALLSERIES) $(LIBS_$(SERIES)) - -STAGE_BOTH_LINK_FLAGS = \ - $(EDLL_LIB) $(LIBS) /nologo \ - /include:"?_E32Dll@@YGHPAXI0@Z" /nodefaultlib \ - /entry:"_E32Dll" /subsystem:windows /dll \ - /out:$(NAME).app \ - /machine:IX86 \ - -STAGE1_LINK_FLAGS = $(STAGE_BOTH_LINK_FLAGS) \ - /incremental:no \ - -STAGE2_LINK_FLAGS = $(STAGE_BOTH_LINK_FLAGS) \ - $(NAME).exp /debug \ - -ARCH = series$(SERIES) -SYMARCH = SERIES_$(SERIES) - -INC = ../inc -SRCDIR = ../src -UID_CPP = $(SRCDIR)/$(NAME).UID.cpp -INCDIR = -I $(EPOC)/include -I $(EPOC)/include/libc -I$(INC) \ - $(subst ../,../../,$(COMMON_INCS)) - -LCLSRC = \ - $(SRCDIR)/xwmain.cpp \ - $(UID_CPP) \ - $(SRCDIR)/xwapp.cpp \ - $(SRCDIR)/symaskdlg.cpp \ - $(SRCDIR)/symdraw.cpp \ - $(SRCDIR)/xwappview.cpp \ - $(SRCDIR)/symdict.cpp \ - $(SRCDIR)/symutil.cpp \ - $(SRCDIR)/xwappui.cpp \ - $(SRCDIR)/xwdoc.cpp \ - $(SRCDIR)/symgmmgr.cpp \ - $(SRCDIR)/symgmdlg.cpp \ - $(SRCDIR)/symblnk.cpp \ - $(SRCDIR)/symgamdl.cpp \ - $(SRCDIR)/symgamed.cpp \ - $(SRCDIR)/symssock.cpp \ - -IMG_SRC = ../bmps/downarrow_80.bmp \ - ../bmps/rightarrow_80.bmp \ - ../bmps/star_80.bmp \ - ../bmps/turnicon_80.bmp \ - ../bmps/turniconmask_80.bmp \ - ../bmps/robot_80.bmp \ - ../bmps/robotmask_80.bmp \ - -INCLUDES = \ - $(NAME).rsg \ - $(NAME).mbg \ - $(INC)/symaskdlg.h \ - $(INC)/symblnk.h \ - $(INC)/symdict.h \ - $(INC)/symdraw.h \ - $(INC)/symgamdl.h \ - $(INC)/symgamed.h \ - $(INC)/symgmdlg.h \ - $(INC)/symgmmgr.h \ - $(INC)/symutil.h \ - $(INC)/xptypes.h \ - $(INC)/xwapp.h \ - $(INC)/xwappui.h \ - $(INC)/xwappview.h \ - $(INC)/xwdoc.h \ - $(INC)/xwords.hrh \ - $(INC)/LocalizedStrIncludes.h \ - -AIF = ../aif -ICON_SRC = \ - $(AIF)/lrgicon.bmp \ - $(AIF)/lrgiconmask.bmp \ - -OBJDIR = $(SRCDIR)/$(PLATFORM) - -OBJECTS = $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(LCLSRC:.cpp=.o)) $(COMMONOBJ) - -MAJOR = 4 -MINOR = 1 -PKGVERS = $(MAJOR),$(MINOR) - -MBG = $(NAME).mbg - -#PKGFILES=$(THEAPP) $(NAME).aif $(NAME).rsc $(NAME).mbm BasEnglish2to8.xwd -PKGFILES = $(NAME).app $(NAME).rsc $(NAME).mbm $(NAME).pdb $(DICT) - -DEBUG_FLAGS = -DDEBUG -DMEM_DEBUG - -CPFLAGS = $(CFLAGS) -DCPLUS - -# Following is used for the resource file -CPPFLAGS = -I$(EPOC)/include -I../inc - -ifdef VERBOSE -else -AMP = @ -endif - -ifeq ($(TARGET),WINS) -all: wins -else -ifeq ($(TARGET),ARMI) -all: armi -else -all: define_TARGET_please -endif -endif - -wins: _sanity $(PKGFILES) - @mkdir -p $(DESTDIR) - cp $(PKGFILES) $(DESTDIR) - -_sanity: - @if [ "$(EPOC_$(SERIES))" = "" ]; then \ - $(ECHO) " ---> ERROR: EPOC_$(SERIES) undefined in env"; \ - exit 1; \ - fi - -icon.$(ARCH).mbm: $(ICON_SRC) - $(BMCONV) $@ $(subst ..,/c8..,$^) - -$(NAME).aifspec: icon.$(ARCH).mbm - @$(ECHO) "mbmfile=$<" > $@ - @$(ECHO) "ELangEnglish=$(NAME)" >> $@ - -# I'm adding my own rules here because I can't figure out how to use -# the default ones when src and obj live in different directories. -$(COMMONOBJDIR)/%.o: $(COMMONDIR)/%.c - $(AMP)mkdir -p $(COMMONOBJDIR) - $(AMP)$(CC) $(CFLAGS) /c /Fo$@ $< - -$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(INCLUDES) - $(AMP)mkdir -p $(OBJDIR) - $(AMP)$(CC) $(CPFLAGS) /c /Fo$@ $< - -$(NAME).mbg $(NAME).mbm: $(IMG_SRC) - $(BMCONV) /h$(NAME).mbg $(NAME).mbm $(subst ..,/2..,$(IMG_SRC)) - -$(NAME).rss: xwords.rss - cp $< $@ - -clean: - rm -rf $(GENERATED) $(NAME).aifspec $(OBJECTS) $(MBG) *.mbm *.rpp *.rsc \ - *.rsg *.app $(UID_CPP) - -# remove saved games and data file -clean_state: - rm -rf $(EPOC)/wins/c/system/Apps/$(NAME)/* - rm -rf $(EPOC)/wins/c/system/Apps/$(NAME) - rm -rf $(EPOC)/release/wins/udeb/z/system/apps/$(NAME)/* - rm -rf $(EPOC)/release/wins/udeb/z/system/apps/$(NAME) - -############################################################################# -# from here down added from the linux build system or stolen from -# makefiles generated by the symbian system -############################################################################# - -$(UID_CPP): ./bldwin.mk - rm -f $@ - $(ECHO) "// Make-generated uid source file" >> $@ - $(ECHO) "#include " >> $@ - $(ECHO) "#pragma data_seg(\".E32_UID\")" >> $@ - $(ECHO) "__WINS_UID(0x$(U1),0x$(U2),0x$(U3))" >> $@ - $(ECHO) "#pragma data_seg()" >> $@ - -%.rsc %.rsg: %.rss - $(PERL) -S $(EPOCRC) $(RSS_DEFS) -I "." -I "..\inc" \ - $(subst ../,../../,$(COMMON_INCS)) -I- -I $(EPOC)/include \ - -DLANGUAGE_SC -u $< -o$*.rsc -h$*.rsg -l./ - -%.aif: %.aifspec - @$(ECHO) "[GENAIF] $*" - $(AMP)$(GA) -u 0x$(U3) $< $@ - -$(NAME).app : $(OBJECTS) $(EDLL_LIB) $(LIBS) - @$(ECHO) building $@ - $(AMP)$(LINK) $(STAGE1_LINK_FLAGS) $(OBJECTS) - $(AMP)rm -f $@ $(NAME).exp - $(AMP)$(DUMPBIN) /exports /out:$(NAME).inf $(NAME).lib - $(AMP)rm -f $(NAME).lib - $(AMP)$(PERL) -S $(MAKEDEF) -Inffile $(NAME).inf \ - -1 ?NewApplication@@YAPAVCApaApplication@@XZ $(NAME).def - $(AMP)rm $(NAME).inf - $(AMP)$(LIB) /nologo /machine:i386 /nodefaultlib \ - /name:$@ /def:$(NAME).def /out:$(NAME).lib - $(AMP)rm -f $(NAME).lib - $(AMP)$(LINK) $(STAGE2_LINK_FLAGS) $(OBJECTS) - $(AMP)rm -f $(NAME).exp diff --git a/xwords4/symbian/group/common.mmp b/xwords4/symbian/group/common.mmp deleted file mode 100644 index 7c257bc87..000000000 --- a/xwords4/symbian/group/common.mmp +++ /dev/null @@ -1,31 +0,0 @@ -TARGET common.lib -TARGETTYPE lib - -MACRO DEBUG MEM_DEBUG -MACRO __LITTLE_ENDIAN KEYBOARD_NAV OS_INITS_DRAW -MACRO KEY_SUPPORT FEATURE_TRAY_EDIT NODE_CAN_4 -MACRO XWFEATURE_STANDALONE_ONLY - -SOURCEPATH ..\..\common -SOURCE board.c -SOURCE tray.c -SOURCE draw.c -SOURCE model.c -SOURCE mscore.c -SOURCE server.c -SOURCE pool.c -SOURCE game.c -SOURCE dictnry.c -SOURCE engine.c -SOURCE memstream.c -SOURCE comms.c -SOURCE mempool.c -SOURCE movestak.c -SOURCE strutils.c -SOURCE vtabmgr.c - - -USERINCLUDE ..\inc -SYSTEMINCLUDE \epoc32\include -SYSTEMINCLUDE \epoc32\include\libc - diff --git a/xwords4/symbian/group/xwords.mmp b/xwords4/symbian/group/xwords.mmp deleted file mode 100644 index 11d463fb1..000000000 --- a/xwords4/symbian/group/xwords.mmp +++ /dev/null @@ -1,88 +0,0 @@ -TARGET xwords.app -TARGETTYPE app - -UID 0x100039CE 0x10206D64 - -// Comment the next line out for a non-debug build. Isn't this build -// system advanced? -MACRO DEBUG MEM_DEBUG _DEBUG -MACRO CPLUS -MACRO __LITTLE_ENDIAN KEYBOARD_NAV OS_INITS_DRAW -MACRO KEY_SUPPORT FEATURE_TRAY_EDIT NODE_CAN_4 -MACRO XWFEATURE_STANDALONE_ONLY -MACRO SERIES_80 SYMBIAN - - -//FOOBAR - -TARGETPATH \system\apps\xwords -LANG SC - -SOURCEPATH ..\src -SOURCE xwmain.cpp -SOURCE xwapp.cpp -SOURCE xwappview.cpp -SOURCE xwappui.cpp -SOURCE xwdoc.cpp -SOURCE symdraw.cpp -SOURCE symutil.cpp -SOURCE symaskdlg.cpp -SOURCE symgamdl.cpp -SOURCE symdict.cpp -SOURCE symblnk.cpp -SOURCE symgmmgr.cpp -SOURCE symgmdlg.cpp -SOURCE symgamed.cpp - -SOURCEPATH ..\group -RESOURCE xwords.rss - -USERINCLUDE ..\inc -USERINCLUDE ..\..\common - -SYSTEMINCLUDE \epoc32\include -SYSTEMINCLUDE \epoc32\include\libc - -START BITMAP xwords.mbm -HEADER -SOURCEPATH ..\bmps -SOURCE 2 downarrow_80.bmp -SOURCE 2 rightarrow_80.bmp -SOURCE 2 star_80.bmp -SOURCE C12 turnicon_80.bmp -SOURCE 2 turniconmask_80.bmp -SOURCE C12 robot_80.bmp -SOURCE 2 robotmask_80.bmp -END - -LIBRARY common.lib - -LIBRARY gdi.lib -LIBRARY euser.lib -LIBRARY apparc.lib -LIBRARY cone.lib -LIBRARY eikcore.lib -LIBRARY eikcoctl.lib -LIBRARY bafl.lib -LIBRARY egul.lib -LIBRARY ckndlg.lib -LIBRARY ckncore.lib -LIBRARY estlib.lib -LIBRARY flogger.lib -LIBRARY commonengine.lib -LIBRARY eikdlg.lib -LIBRARY EIKFILE.lib -LIBRARY eikctl.lib -// Bitmaps -LIBRARY bitgdi.lib -LIBRARY fbscli.lib -// FindWildByDir etc. -LIBRARY EFSRV.lib -// convert to unicode -// LIBRARY CHARCONV.lib -// RFileReadStream -LIBRARY ESTOR.lib -// Window.Invalidate -LIBRARY WS32.lib - -AIF xwords.aif ..\aif xwaif.rss c8 lrgicon.bmp lrgiconmask.bmp diff --git a/xwords4/symbian/group/xwords.rss b/xwords4/symbian/group/xwords.rss deleted file mode 100644 index b4632fdfd..000000000 --- a/xwords4/symbian/group/xwords.rss +++ /dev/null @@ -1,620 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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. - */ - -NAME XWRD - -/* I can't get macros in MMC to be honored here; though the compiler complains - about double-definition it doesn't honor the one in the mmp file. */ - -#include -#include - -#if defined SERIES_60 -# include -# include -#endif - -#include "xwords.hrh" - -#define CANT_DO_TYPEDEF -#include "xwrelay.h" -#undef CANT_DO_TYPEDEF - -// --------------------------------------------------------- -// -// Define the resource file signature -// This resource should be empty. -// -// --------------------------------------------------------- -// -RESOURCE RSS_SIGNATURE { } - -// --------------------------------------------------------- -// -// Default Document Name -// -// --------------------------------------------------------- -// -RESOURCE TBUF r_default_document_name { buf=""; } - -// --------------------------------------------------------- -// -// Define default menu, hotkeys and CBA keys. -// -// --------------------------------------------------------- -// -RESOURCE EIK_APP_INFO -{ - menubar = r_xwords_menubar; - cba = r_xwords_cba; - hotkeys = r_xwords_hotkeys; -} - -// --------------------------------------------------------- -// -// r_xwords_hotkeys -// -// --------------------------------------------------------- -// -RESOURCE HOTKEYS r_xwords_hotkeys -{ - control = - { - HOTKEY - { - command = EEikCmdExit; - key = 'e'; - } - }; -} - -// --------------------------------------------------------- -// -// r_xwords_cba -// -// --------------------------------------------------------- -// -RESOURCE CBA r_xwords_cba -{ - buttons= - { - CBA_BUTTON - { - id=XW_JUGGLE_COMMAND; - txt="Juggle"; - }, - CBA_BUTTON - { - id=XW_NEXTHINT_COMMAND; - txt="Next Hint"; - }, - CBA_BUTTON - { - id=XW_HIDETRAY_COMMAND; - txt="Hide tray"; - }, - CBA_BUTTON - { - id=XW_DONE_COMMAND; - txt="Done"; - } - }; -} - -// --------------------------------------------------------- -// -// r_xwords_menubar -// -// --------------------------------------------------------- -// -RESOURCE MENU_BAR r_xwords_menubar - { - titles = - { - MENU_TITLE {menu_pane = r_xwords_file_menu; txt = "File";} - ,MENU_TITLE {menu_pane = r_xwords_game_menu; txt = "Game";} - ,MENU_TITLE {menu_pane = r_xwords_move_menu; txt = "Move";} - }; - } - - -// --------------------------------------------------------- -// -// r_xwords_file_menu -// Menu for "Options" -// -// --------------------------------------------------------- -// -RESOURCE MENU_PANE r_xwords_file_menu -{ - items = - { - MENU_ITEM {command = XW_NEWGAME_COMMAND; txt = "New game";} - ,MENU_ITEM {command = XW_SAVEDGAMES_COMMAND; txt = "Saved games";} - ,MENU_ITEM {command = XW_PREFS_COMMAND; txt = "Preferences";} - ,MENU_ITEM {command = XW_ABOUT_COMMAND; txt = "About";} - - ,MENU_ITEM {command = EEikCmdExit; txt = "Exit";} - }; -} - -RESOURCE MENU_PANE r_xwords_game_menu -{ - items = - { - MENU_ITEM {command = XW_VALUES_COMMAND; txt = "Tile values";} - ,MENU_ITEM {command = XW_REMAIN_COMMAND; txt = "Remaining tiles";} - ,MENU_ITEM {command = XW_CURINFO_COMMAND; txt = "Game info";} - ,MENU_ITEM {command = XW_HISTORY_COMMAND; txt = "History";} - ,MENU_ITEM {command = XW_FINALSCORES_COMMAND; txt = "Final scores";} - ,MENU_ITEM {command = XW_FLIP_COMMAND; txt = "Flip board"; } - ,MENU_ITEM {command = XW_TOGGLEVALS_COMMAND; txt = "Toggle values"; } -#ifndef XWFEATURE_STANDALONE_ONLY - ,MENU_ITEM {command = XW_RESEND_COMMAND; txt = "Resend messages"; } -#endif - }; -} - -RESOURCE MENU_PANE r_xwords_move_menu -{ - items = - { - MENU_ITEM {command = XW_HINT_COMMAND; txt = "Hint";} -/* #ifdef XWFEATURE_SEARCHLIMIT */ -/* ,MENU_ITEM {command = XW_LIMHINT_COMMAND; txt = "Limited hint";} */ -/* #endif */ - ,MENU_ITEM {command = XW_NEXTHINT_COMMAND; txt = "Next hint";} - ,MENU_ITEM {command = XW_UNDOCUR_COMMAND; txt = "Undo current";} - ,MENU_ITEM {command = XW_UNDOLAST_COMMAND; txt = "Undo last";} - ,MENU_ITEM {command = XW_DONE_COMMAND; txt = "Turn done";} -/* ,MENU_ITEM {command = XW_JUGGLE_COMMAND; txt = "Juggle";} */ - ,MENU_ITEM {command = XW_TRADE_COMMAND; txt = "Trade";} -/* ,MENU_ITEM {command = XW_HIDETRAY_COMMAND; txt = "[Un]hide tray";} */ - }; -} - -/* Apparently you have to use a resource type large enough to hold the - string. There are TBUF16, TBUF32, TBUF40, TBUF48,TBUF64, 128 and - 256. Why a system that can generate constants from the resource - IDs can't match resource types to strings is beyond me. -*/ - -RESOURCE TBUF32 r_no_peek_alert { - buf="No peeking at the robot's tiles."; } - -RESOURCE TBUF40 r_tiles_in_line_alert { - buf ="All tiles played must be in a line."; -} - -RESOURCE TBUF64 r_no_empties_sep_alert { - buf ="Empty squares cannot separate pieces played."; -} - -RESOURCE TBUF64 r_two_tiles_first_move_alert { - buf = "Must play two or more pieces on the first move."; -} - -RESOURCE TBUF128 r_placed_must_contact_alert { - buf = "New tiles must contact others already in place (or the middle square on the first move)."; -} - -RESOURCE TBUF32 r_too_few_to_trade_alert { - buf = "Too few tiles left to trade."; -} - -RESOURCE TBUF64 r_not_your_turn_alert { - buf = "You can't do that; it's not your turn!"; -} - -RESOURCE TBUF40 r_remove_first_alert { - buf = "Remove played tiles before trading."; -} - -RESOURCE TBUF64 r_nothing_to_undo_alert { - buf = "Nothing to undo. (Initial tile picking cannot be undone.)"; -} - -RESOURCE TBUF64 r_confirm_end_game { - buf = "Are you sure you want to end the game now?"; -} - -RESOURCE TBUF64 r_alert_no_dicts { - buf = "Crosswords requires at least one dictionary."; -} - -RESOURCE TBUF32 r_alert_feature_pending { - buf = "Feature not yet implemented."; -} - -RESOURCE TBUF64 r_alert_no_delete_open_game { - buf = "You can't delete the current game."; -} - -RESOURCE TBUF64 r_confirm_trade { - buf = "Are you sure you want to use your turn trading tiles?"; -} - -RESOURCE TBUF64 r_confirm_delgame { - buf = "Are you sure you want delete the selected game?"; -} - -RESOURCE TBUF64 r_alert_no_rename_open_game { - buf = "You can't rename the current game."; -} - -RESOURCE TBUF32 r_alert_rename_target_exists { - buf = "Name already in use."; -} - -RESOURCE TBUF32 r_alert_rename_target_badname { - buf = "Illegal game name"; -} - - -#define XW_EFLAGS EEikEdwinNoAutoSelection | EEikEdwinReadOnly | EEikEdwinResizable -// EEikEdwinDisplayOnly | - -RESOURCE DIALOG r_xwords_confirmation_query -{ - title = "Query"; -#if ! defined SERIES_60 - buttons = R_EIK_BUTTONS_NO_YES; -#endif - flags = EEikDialogFlagWait | EEikDialogFlagNotifyEsc; - items = - { - DLG_LINE - { - control = EDWIN { flags = XW_EFLAGS; - width = 50; - lines = 4; - }; - type = EEikCtEdwin; - id = EAskContents; - } - }; -} - -RESOURCE DIALOG r_xwords_info_only -{ - title = "Info"; -#if ! defined SERIES_60 - buttons = R_EIK_BUTTONS_CONTINUE; -#endif - flags = EEikDialogFlagWait | EEikDialogFlagNotifyEsc; - items = - { - DLG_LINE - { - control = EDWIN { flags = XW_EFLAGS; - width = 50; - lines = 4; - }; - type = EEikCtEdwin; - id = EAskContents; - } - }; -} - -#ifndef XWFEATURE_STANDALONE_ONLY -RESOURCE ARRAY r_conn_roles -{ - items = { - LBUF { txt = "Standalone"; } - ,LBUF { txt = "Host"; } - ,LBUF { txt = "Guest"; } - }; -} - -RESOURCE ARRAY r_conn_types -{ - items = { - LBUF { txt = "Cellular internet"; } - ,LBUF { txt = "Bluetooth"; } - ,LBUF { txt = "IR"; } - }; -} - -RESOURCE ARRAY r_xwords_newgame_page_conn -{ - items = - { - DLG_LINE - { - prompt = "Role"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { array_id = r_conn_roles; }; -#endif - id = EConnectionRole; - // itemflags = - }, - DLG_LINE - { - prompt = "Connect via"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { array_id = r_conn_types; }; -#elif defined SERIES_60 - control = AVKON_LIST_QUERY_CONTROL { - listtype = EAknCtSingleHeadingPopupMenuListBox; - listbox = LISTBOX { - flags = EAknListBoxMenuList; - height = 5; - width = 20; - array_id = r_conn_types; - }; -/* heading = qtn_aknexquery_list_title; */ - }; -#endif - id = EConnectionType; - // itemflags = - }, - DLG_LINE { - prompt = "Game name"; - type = EEikCtEdwin; - id = ECookie; - control = EDWIN { width = 10; maxlength = MAX_COOKIE_LEN; }; - }, - DLG_LINE { - prompt = "Relay name"; - type = EEikCtEdwin; - id = ERelayName; - control = EDWIN { width = 10; maxlength = 32; }; - }, - DLG_LINE { - prompt = "Port number"; - id = ERelayPort; - type = EEikCtNumberEditor; - control = NUMBER_EDITOR { min = 0; max = 0xFFFF; }; - } - }; -} -#endif - -RESOURCE ARRAY r_four_nums -{ - items = { - LBUF { txt = "1"; } - ,LBUF { txt = "2"; } - ,LBUF { txt = "3"; } - ,LBUF { txt = "4"; } - }; -} - -RESOURCE ARRAY r_xwords_newgame_page_players -{ - items = - { - DLG_LINE { - - prompt = "Number of players"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { array_id = r_four_nums; }; -#endif - id = ENPlayersList; - - }, DLG_LINE { - - prompt = "Show player"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { maxdisplaychar = 2; }; -#endif - id = ENPlayersWhichList; - - }, DLG_LINE { - - prompt = "Location"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { array_id = r_location_choices; }; -#endif - id = EPlayerLocationChoice; - - } ,DLG_LINE { - - prompt = "Name"; - control = EDWIN { width = 20; maxlength = 32; }; - type = EEikCtEdwin; - id = EPlayerName; - - } ,DLG_LINE { - - prompt = "Species"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { array_id = r_player_species; }; -#endif - id = EPlayerSpeciesChoice; - - } ,DLG_LINE { - - type = EEikCtSecretEd; - prompt = "Password"; - id = EDecryptPassword; - control = SECRETED { num_letters = 5; }; - } - }; -} - -RESOURCE ARRAY r_player_species -{ - items = { - LBUF { txt = "Human"; } - ,LBUF { txt = "Robot"; } - }; -} - -RESOURCE ARRAY r_location_choices -{ - items = { - LBUF { txt = "Local"; } - ,LBUF { txt = "Remote"; } - }; -} - -/* This flag goes on editors in pages on series 60 */ -/* avkon_flags = EAknEditorFlagNoEditIndicators; \ */ - -#ifdef SERIES_60 -RESOURCE DLG_BUTTONS r_dict_browse_button -{ - buttons = { - DLG_BUTTON - { - id = EDictBrowseButton; - button = CMBUT { txt = "Browse"; }; -/* hotkey = "B"; */ - } - }; -} -#endif - -RESOURCE ARRAY r_xwords_newgame_page_dict -{ - items = { - DLG_LINE { - prompt = "Game dictionary"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { flags = EEikChlistArrayOwnedExternally; }; -#endif - id = ESelDictChoice; - } -#ifdef SERIES_60 -/* ,DLG_LINE { */ -/* buttons = r_dict_browse_button; */ -/* } */ -#endif - }; -} - -RESOURCE ARRAY r_xwords_newgame_pages -{ - items = - { -#ifndef XWFEATURE_STANDALONE_ONLY - PAGE{ text="Connection"; id=EPageConn; lines=r_xwords_newgame_page_conn;} - , -#endif - PAGE{ text="Players"; id=EPagePlayers; - lines=r_xwords_newgame_page_players;} - ,PAGE{ text="Dictionary"; id=EPageDict; - lines=r_xwords_newgame_page_dict;} - }; -} - -RESOURCE DIALOG r_xwords_newgame_dlg -{ - title = "Game setup"; - /* This doesn't work in series 60. How do I differentiate? Sep .rss - files? */ -#if defined SERIES_80 - buttons = R_EIK_BUTTONS_CANCEL_OK; -#endif - flags = EEikDialogFlagWait | EEikDialogFlagNotifyEsc; - pages = r_xwords_newgame_pages; -} - -RESOURCE DIALOG r_xwords_blank_picker -{ - title = "Tile picker"; -#if defined SERIES_80 - buttons = R_EIK_BUTTONS_CONTINUE; -#endif - flags = EEikDialogFlagWait | EEikDialogFlagNotifyEsc; - items = { - DLG_LINE { - prompt = "Choose one"; - type = EEikCtChoiceList; -#if defined SERIES_80 - control = CHOICELIST { flags = EEikChlistArrayOwnedExternally; }; -#elif defined SERIES_60 -#endif - id = ESelBlankChoice; - } - }; -} - -RESOURCE DLG_BUTTONS r_savedgames_buttons -{ - buttons = { - DLG_BUTTON { - id = XW_SGAMES_RENAME_COMMAND; - buttontype = EEikCtCommandButton; - button = CMBUT { txt = "Rename"; }; - }, DLG_BUTTON { - id = XW_SGAMES_OPEN_COMMAND; - buttontype = EEikCtCommandButton; -/* flags = EEikLabeledButtonIsDefault; */ - button = CMBUT { txt = "Open"; }; - }, DLG_BUTTON { - id = XW_SGAMES_DELETE_COMMAND; - buttontype = EEikCtCommandButton; - button = CMBUT { txt = "Delete"; }; - }, DLG_BUTTON { - id = EEikBidCancel; - buttontype = EEikCtCommandButton; - button = CMBUT { txt = "Cancel"; }; - } - }; -} - -RESOURCE DIALOG r_xwords_savedgames_dlg -{ - title = "Saved games"; - buttons = r_savedgames_buttons; - flags = EEikDialogFlagWait | EEikDialogFlagNotifyEsc; - items = { - DLG_LINE { - prompt = "Open:"; - id = ESelGameChoice; -#if 0 - type = EEikCtChoiceList; - control = CHOICELIST { flags = EEikChlistArrayOwnedExternally; }; -#else - type = EEikCtListBox; - control = LISTBOX { flags = EEikListBoxMultipleSelection; - width = 20; - }; -#endif - } - }; -} - -RESOURCE DIALOG r_xwords_editname_dlg -{ - title = "Change name"; -#if defined SERIES_80 - buttons = R_EIK_BUTTONS_CANCEL_OK; -#endif - flags = EEikDialogFlagWait | EEikDialogFlagNotifyEsc; - items = { - DLG_LINE { - prompt = "New name"; - id = EEditNameEdwin; - type = EEikCtFileNameEd; - control = FILENAMEEDITOR { width = 32; }; - } - }; -} diff --git a/xwords4/symbian/inc/LocalizedStrIncludes.h b/xwords4/symbian/inc/LocalizedStrIncludes.h deleted file mode 100644 index 5a2a8291b..000000000 --- a/xwords4/symbian/inc/LocalizedStrIncludes.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2002-2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -/* This is the symbian version of what's always been a palm file. - * There's probably a better way of doing this, but this is it for - * now. - */ - -#ifndef _LOCALIZEDSTRINCLUDES_H_ -#define _LOCALIZEDSTRINCLUDES_H_ - -enum { - STRD_REMAINING_TILES_ADD, - STRD_UNUSED_TILES_SUB, - STR_COMMIT_CONFIRM, - STR_BONUS_ALL, - STRD_TURN_SCORE, - STR_LOCAL_NAME, - STR_NONLOCAL_NAME, - STRD_TIME_PENALTY_SUB, - - STRD_CUMULATIVE_SCORE, - STRS_TRAY_AT_START, - STRS_MOVE_DOWN, - STRS_MOVE_ACROSS, - STRS_NEW_TILES, - STRSS_TRADED_FOR, - STR_PASS, - STR_PHONY_REJECTED, - - STRD_ROBOT_TRADED, - STR_ROBOT_MOVED, - STR_REMOTE_MOVED, - - STR_PASSED, - STRSD_SUMMARYSCORED, - STRD_TRADED, - STR_LOSTTURN, - - STRS_VALUES_HEADER, - - STR_LOCALPLAYERS, - STR_TOTALPLAYERS, - - STR_NOT_USED -}; - -#endif diff --git a/xwords4/symbian/inc/symaskdlg.h b/xwords4/symbian/inc/symaskdlg.h deleted file mode 100644 index eb1150f60..000000000 --- a/xwords4/symbian/inc/symaskdlg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _XWASKDLG_H_ -#define _XWASKDLG_H_ - -extern "C" { -#include "comtypes.h" -#include "xwstream.h" -#include "mempool.h" -} - -#include -#include - -class CXWAskDlg : public CEikDialog -{ - public: - static TBool DoAskDlg( MPFORMAL XWStreamCtxt* aStream, TBool aKillStream ); - static TBool DoAskDlg( MPFORMAL TBuf16<128>* aMessage ); - - static void DoInfoDlg( MPFORMAL XWStreamCtxt* aStream, TBool aKillStream ); - - ~CXWAskDlg(); - - private: - CXWAskDlg( MPFORMAL XWStreamCtxt* aStream, TBool aKillStream ); - CXWAskDlg( MPFORMAL TBuf16<128>* aMessage); - - private: - TBool OkToExitL( TInt aKeyCode ); - void PreLayoutDynInitL(); - - /* One or the other of these will be set/used */ - XWStreamCtxt* iStream; - TBuf16<128>* iMessage; - - TBool iKillStream; - MPSLOT -}; - -#endif diff --git a/xwords4/symbian/inc/symblnk.h b/xwords4/symbian/inc/symblnk.h deleted file mode 100644 index ea4963d62..000000000 --- a/xwords4/symbian/inc/symblnk.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 _SYMBLNK_H_ -#define _SYMBLNK_H_ - -extern "C" { -#include "comtypes.h" -} - -#include -#include - -class CXWBlankSelDlg : public CEikDialog -{ - public: - static void UsePickTileDialogL( const XP_UCHAR4* texts, TInt aNTiles, - TInt* result ); - - CXWBlankSelDlg( const XP_UCHAR4* texts, TInt aNTiles, TInt* aResultP ); - /* no need for destructor; we give the control ownership of iFacesList */ - - void PreLayoutDynInitL(); - TBool OkToExitL( TInt aKeyCode ); - - private: - const XP_UCHAR4* iTexts; - TInt iNTiles; - TInt* iResultP; - CDesC16ArrayFlat* iFacesList; -}; -#endif diff --git a/xwords4/symbian/inc/symdict.h b/xwords4/symbian/inc/symdict.h deleted file mode 100644 index 8696d8850..000000000 --- a/xwords4/symbian/inc/symdict.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SYMDICT_H_ -#define _SYMDICT_H_ - -#if defined SERIES_60 -#elif defined SERIES_80 -# include -#endif - -extern "C" { -#include "comtypes.h" -#include "mempool.h" -} - -DictionaryCtxt* sym_dictionary_makeL( MPFORMAL TFileName* path, - const XP_UCHAR* aDictName ); - - -#endif diff --git a/xwords4/symbian/inc/symdraw.h b/xwords4/symbian/inc/symdraw.h deleted file mode 100644 index ce0088550..000000000 --- a/xwords4/symbian/inc/symdraw.h +++ /dev/null @@ -1,47 +0,0 @@ -// -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SYMDRAW_H_ -#define _SYMDRAW_H_ - -extern "C" { - -#include "draw.h" -#include "board.h" - -} /* extern "C" */ - -#if defined SERIES_60 -# include -# include -#elif defined SERIES_80 -# include -#endif - -#define scaleBoardV 13 -#define scaleBoardH 15 -#define scaleTrayV 37 -#define scaleTrayH 32 - -#define CUR_PREFS_VERS 0x0405 - -DrawCtx* sym_drawctxt_make( MPFORMAL CWindowGc* gc, CCoeEnv* aCoeEnv, - CEikonEnv* aEikonEnv, CEikApplication* aApp ); - -#endif diff --git a/xwords4/symbian/inc/symgamdl.h b/xwords4/symbian/inc/symgamdl.h deleted file mode 100644 index caf4ff0a7..000000000 --- a/xwords4/symbian/inc/symgamdl.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SYMGAMDL_H_ -#define _SYMGAMDL_H_ - -extern "C" { -#include "comtypes.h" -#include "xwstream.h" -#include "mempool.h" -#include "game.h" -#include "comms.h" -} - -#include -#include - -class TGameInfoBuf -{ - public: - TGameInfoBuf::TGameInfoBuf( const CurGameInfo* aGi, -#ifndef XWFEATURE_STANDALONE_ONLY - const CommsAddrRec* aCommsAddr, -#endif - CDesC16ArrayFlat* aDictList ); - CDesC16ArrayFlat* GetDictList() { return iDictList; } - void CopyToL( MPFORMAL CurGameInfo* aGi -#ifndef XWFEATURE_STANDALONE_ONLY - , CommsAddrRec* aCommsAddr -#endif - ); - - TBool iIsRobot[MAX_NUM_PLAYERS]; - TBool iIsLocal[MAX_NUM_PLAYERS]; - - TBuf16<32> iPlayerNames[MAX_NUM_PLAYERS]; - - CDesC16ArrayFlat* iDictList; /* owned externally! */ - TInt iDictIndex; - TInt iNPlayers; - -#ifndef XWFEATURE_STANDALONE_ONLY - Connectedness iServerRole; - CommsAddrRec iCommsAddr; -#endif -}; - -class CXWGameInfoDlg : public CEikDialog /* CEikForm instead? */ -{ - public: - static TBool DoGameInfoDlgL( MPFORMAL TGameInfoBuf* aGib, - TBool aNewGame ); - - ~CXWGameInfoDlg(); - - private: - CXWGameInfoDlg( MPFORMAL TGameInfoBuf* aGib, TBool aNewGame ); - - private: - void PreLayoutDynInitL(); - void HandleControlStateChangeL( TInt aControlId ); - TBool OkToExitL( TInt aKeyCode ); - - void LoadPlayerInfo( TInt aWhich ); - void SavePlayerInfo( TInt aWhich ); - void SetPlayerShown( TInt aPlayer ); - void HideAndShow(); - - CDesC16ArrayFlat* MakeNumListL( TInt aFirst, TInt aLast ); - - TBool iIsNewGame; - TGameInfoBuf* iGib; - - TInt iCurPlayerShown; - - MPSLOT -}; - -#endif diff --git a/xwords4/symbian/inc/symgamed.h b/xwords4/symbian/inc/symgamed.h deleted file mode 100755 index b74adf9a0..000000000 --- a/xwords4/symbian/inc/symgamed.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SYMGAMED_H_ -#define _SYMGAMED_H_ - -/* extern "C" { */ -/* #include "comtypes.h" */ -/* #include "mempool.h" */ -/* #include "util.h" */ -/* } */ - -#include -#include - -#include "symgmmgr.h" - -class CNameEditDlg : public CEikDialog -{ - public: - static TBool EditName( TGameName* aGameName ); - - private: - CNameEditDlg( TGameName* aGameName ); - - TBool OkToExitL( TInt aKeyCode ); - void PreLayoutDynInitL(); - - TGameName* iGameName; -}; - -#endif diff --git a/xwords4/symbian/inc/symgmdlg.h b/xwords4/symbian/inc/symgmdlg.h deleted file mode 100755 index 977303676..000000000 --- a/xwords4/symbian/inc/symgmdlg.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SYMGMDLG_H_ -#define _SYMGMDLG_H_ - -extern "C" { -#include "comtypes.h" -#include "mempool.h" -#include "util.h" -} - -#include -#include - -#include "symgmmgr.h" - -class CXWordsAppView; - -enum { - SYM_QUERY_CONFIRM_DELGAME = QUERY_LAST_COMMON -}; - -class CXSavedGamesDlg : public CEikDialog -{ - public: - static TBool DoGamesPicker( MPFORMAL CXWordsAppView* aOwner, - CXWGamesMgr* aGameMgr, - const TGameName* aCurName, TGameName* result ); - - private: - CXSavedGamesDlg( MPFORMAL CXWordsAppView* aOwner, CXWGamesMgr* aGameMgr, - const TGameName* aCurName, TGameName* result ); - - TBool OkToExitL( TInt aKeyCode ); - void PreLayoutDynInitL(); - - void ResetNames( TInt aPrefIndex, const TGameName* aSelName ); - TBool EditSelName( const TGameName* aSelName, TGameName* aNewName ); - - CXWordsAppView* iOwner;/* uses: don't own this!!! */ - CXWGamesMgr* iGameMgr; /* I don't own this */ - const TGameName* iCurName; - TGameName* iResultP; /* ditto */ - MPSLOT -}; - - -#endif diff --git a/xwords4/symbian/inc/symgmmgr.h b/xwords4/symbian/inc/symgmmgr.h deleted file mode 100755 index dbfbd4091..000000000 --- a/xwords4/symbian/inc/symgmmgr.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). - * - * 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 _SYMGMMGR_H_ -#define _SYMGMMGR_H_ - -extern "C" { -#include "comtypes.h" -#include "memstream.h" -#include "mempool.h" -} - -#include -#include -#include -#include - -typedef TBuf16<32> TGameName; - -/* This class tracks games, each of which is (currently) saved in a - * file in a hidden directory. - */ -class CXWGamesMgr : public CBase -{ - private: - CXWGamesMgr( MPFORMAL CCoeEnv* aCoeEnv, TFileName* aBasePath ); - - void BuildListL(); - TBool DeleteFileFor( TPtrC16* aName ); - void GameNameToPath( TFileName* path, const TDesC16* name ); - - public: - static CXWGamesMgr* NewL( MPFORMAL CCoeEnv* aCoeEnv, TFileName* aBasePath ); - - TInt GetNGames() const; - /* Will be used by dialog */ - CDesC16Array* GetNames() const; - - /* Come up with some unique name */ - void MakeDefaultName( TGameName* aName ); - - void StoreGameL( const TGameName* aName, XWStreamCtxt* stream ); - void LoadGameL( const TGameName* aName, XWStreamCtxt* stream ); - - TBool DeleteSelected( TInt aIndex ); - TBool Exists( TGameName* aName ); - TBool IsLegalName( const TGameName* aName ); - void Rename( const TDesC16* aCurName, const TDesC16* aNewName ); - - private: - - CDesC16ArrayFlat* iNamesList; - TFileName iDir; - CCoeEnv* iCoeEnv; - TInt iGameCount; - MPSLOT -}; - -#endif diff --git a/xwords4/symbian/inc/symrsock.h b/xwords4/symbian/inc/symrsock.h deleted file mode 100644 index 2b0da3b2b..000000000 --- a/xwords4/symbian/inc/symrsock.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 XWFEATURE_STANDALONE_ONLY - -#ifndef _SYMRSOCK_H_ -#define _SYMRSOCK_H_ - -#include -#include -#include "comms.h" - -const TInt KMaxRcvMsgLen = 512; - -class CReadSocket : public CActive { - - public: - typedef void (*ReadNotifyCallback)( const TDesC8* aBuf, - void *closure ); - - static CReadSocket* NewL( ReadNotifyCallback aGotData, - void* aCallbackClosure ); - ~CReadSocket(); - - void SetListenPort( TInt aPort ); - void Start(); - void Stop(); - - protected: - void RunL(); /* from CActive */ - void DoCancel(); /* from CActive */ - - private: - CReadSocket( ReadNotifyCallback aGotData, void* aCallbackClosure ); - void ConstructL(); - void RequestRecv(); - void Bind(); - - enum TReadState { - ENotReading - ,EReading - }; - - TReadState iReadState; - ReadNotifyCallback iGotData; - void* iCallbackClosure; - RSocket iListenSocket; - TInt iPort; - TBuf8 iInBuf; - TSockXfrLength iReadLength; - RSocketServ iSocketServer; - TInetAddr iRecvAddr; -}; - -#endif - -#endif /* XWFEATURE_STANDALONE_ONLY */ diff --git a/xwords4/symbian/inc/symssock.h b/xwords4/symbian/inc/symssock.h deleted file mode 100644 index 579a4ebfe..000000000 --- a/xwords4/symbian/inc/symssock.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 _SYMSSOCK_H_ -#define _SYMSSOCK_H_ - -#ifndef XWFEATURE_STANDALONE_ONLY - -#include -#include -#include "comms.h" - -const TInt KMaxMsgLen = 512; - -class CSendSocket : public CActive { - - public: - - typedef void (*ReadNotifyCallback)( const TDesC8* aBuf, - void *aClosure ); - static CSendSocket* NewL( ReadNotifyCallback aCallback, void* aClosure ); - - ~CSendSocket(); - - TBool SendL( const XP_U8* aBuf, XP_U16 aLen, const CommsAddrRec* aAddr ); - TBool Listen(); - - void ConnectL( const CommsAddrRec* aAddr ); - void Disconnect(); - - protected: - void RunL(); /* from CActive */ - void DoCancel(); /* from CActive */ - - private: - CSendSocket( ReadNotifyCallback aCallback, void* aClosure ); - void ConstructL(); - void DoActualSend(); - - void ConnectL(); - void ConnectL( TUint32 aIpAddr ); - - TBool CancelListen(); - void ResetState(); - - enum TSSockState { ENotConnected - ,ELookingUp - ,EConnecting - ,EConnected - ,ESending - ,EListening - }; - - TSSockState iSSockState; - RSocket iSendSocket; - RSocketServ iSocketServer; - RHostResolver iResolver; - TInetAddr iAddress; - TBuf8 iSendBuf; - TInt iDataLen; /* How big should next packet be */ - TUint8 iInBuf[KMaxMsgLen]; - TPtr8* iInBufDesc; /* points to above buffer */ - CommsAddrRec iCurAddr; - TNameEntry iNameEntry; - TNameRecord iNameRecord; - TBool iAddrSet; - TBool iListenPending; - - ReadNotifyCallback iCallback; - void* iClosure; -}; - -#endif -#endif diff --git a/xwords4/symbian/inc/symutil.h b/xwords4/symbian/inc/symutil.h deleted file mode 100644 index 921a6adc4..000000000 --- a/xwords4/symbian/inc/symutil.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _SYMUTIL_H_ -#define _SYMUTIL_H_ - -/* Functions in this file can use C++ types etc since they're not - * extern "C" - */ - -void symReplaceStrIfDiff( MPFORMAL XP_UCHAR** loc, const TDesC16& desc ); -void symReplaceStrIfDiff( MPFORMAL XP_UCHAR** loc, const XP_UCHAR* str ); - -#ifdef DEBUG -void XP_LOGDESC16( const TDesC16* desc ); -#else -# define XP_LOGDESC16(d) -#endif - -#endif diff --git a/xwords4/symbian/inc/xptypes.h b/xwords4/symbian/inc/xptypes.h deleted file mode 100644 index cab6c10d1..000000000 --- a/xwords4/symbian/inc/xptypes.h +++ /dev/null @@ -1,137 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 1999-2004 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 _XPTYPES_H_ -#define _XPTYPES_H_ - -#include -#include - -/* #include */ - -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ - -/* #include */ - -#ifdef CPLUS -extern "C" { -#endif - -#define XP_TRUE ((XP_Bool)(1==1)) -#define XP_FALSE ((XP_Bool)(1==0)) - -typedef TUint16 XP_U16; -typedef TInt16 XP_S16; - -typedef TUint32 XP_U32; -typedef TInt32 XP_S32; - -typedef TUint8 XP_U8; -typedef TInt8 XP_S8; -typedef unsigned char XP_UCHAR; -//typedef TText XP_UCHAR; /* native two-byte char */ - -typedef signed short XP_FontCode; /* not sure how I'm using this yet */ -typedef TBool XP_Bool; -typedef XP_U32 XP_Time; - -#define SC(t,val) static_cast(val) - -#define XP_CR "\n" - -#ifndef DEBUG -void p_ignore( char* fmt, ... ); -#endif - -void sym_debugf( char* aFmt, ...); -int sym_snprintf( XP_UCHAR* buf, XP_U16 len, const XP_UCHAR* format, ... ); - -XP_U32 sym_flip_long( unsigned long l ); -XP_U16 sym_flip_short(unsigned short s); -void* sym_malloc(XP_U32 nbytes ); -void* sym_realloc(void* p, XP_U32 nbytes); -void sym_free( void* p ); -void sym_assert(XP_Bool b, XP_U32 line, const char* file ); -void sym_memset( void* dest, XP_UCHAR val, XP_U32 nBytes ); -XP_S16 sym_strcmp( XP_UCHAR* str1, XP_UCHAR* str2 ); -XP_U32 sym_strlen( XP_UCHAR* str ); -XP_S16 sym_strncmp( XP_UCHAR* str1, XP_UCHAR* str2, XP_U32 len ); -void sym_memcpy( void* dest, const void* src, XP_U32 nbytes ); -XP_S16 sym_memcmp( void* m1, void* m2, XP_U32 nbytes ); -char* sym_strcat( XP_UCHAR* dest, const XP_UCHAR* src ); - -#define XP_RANDOM() rand() - -#ifdef MEM_DEBUG -# define XP_PLATMALLOC(nbytes) sym_malloc(nbytes) -# define XP_PLATREALLOC(p,s) sym_realloc((p), (s)) -# define XP_PLATFREE(p) sym_free(p) -#else -# define XP_MALLOC(pool, nbytes) sym_malloc(nbytes) -# define XP_REALLOC(pool, p, bytes) sym_realloc((p), (bytes)) -# define XP_FREE(pool, p) sym_free(p) -#endif - -#define XP_MEMSET(src, val, nbytes) \ - sym_memset( (src), (val), (nbytes) ) -#define XP_MEMCPY(d,s,l) sym_memcpy((d),(s),(l)) -#define XP_MEMCMP( a1, a2, l ) sym_memcmp( (a1),(a2),(l)) -#define XP_STRLEN(s) sym_strlen((unsigned char*)(s)) -#define XP_STRCMP(s1,s2) sym_strcmp((XP_UCHAR*)(s1),(XP_UCHAR*)(s2)) -#define XP_STRNCMP(s1,s2,l) sym_strncmp((char*)(s1),(char*)(s2),(l)) -#define XP_STRCAT(d,s) sym_strcat((d),(s)) - -#define XP_SNPRINTF sym_snprintf - -#define XP_MIN(a,b) ((a)<(b)?(a):(b)) -#define XP_MAX(a,b) ((a)>(b)?(a):(b)) - -#ifdef DEBUG -# define XP_ASSERT(b) sym_assert((XP_Bool)(b), __LINE__, __FILE__ ) -#else -# define XP_ASSERT(b) -#endif - -#define XP_STATUSF XP_DEBUGF -#define XP_WARNF XP_DEBUGF - -#ifdef DEBUG -# define XP_LOGF sym_debugf -# define XP_DEBUGF sym_debugf -#else -# define XP_LOGF if(0)p_ignore -# define XP_DEBUGF if(0)p_ignore -#endif - -#define XP_NTOHL(l) sym_flip_long(l) -#define XP_NTOHS(s) sym_flip_short(s) -#define XP_HTONL(l) sym_flip_long(l) -#define XP_HTONS(s) sym_flip_short(s) - -#define XP_LD "%d" - -#ifdef CPLUS -} -#endif - -#endif diff --git a/xwords4/symbian/inc/xwapp.h b/xwords4/symbian/inc/xwapp.h deleted file mode 100644 index c37627b06..000000000 --- a/xwords4/symbian/inc/xwapp.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 __XWAPP_H__ -#define __XWAPP_H__ - -#include - -/*! - @class CXWordsApplication -*/ -class CXWordsApplication : public CEikApplication -{ - public: // from CEikApplication - - /*! - @function AppDllUid - */ - TUid AppDllUid() const; - - protected: // from CEikApplication - /*! - @function CreateDocumentL - */ - CApaDocument* CreateDocumentL(); -}; - -#endif // __XWAPP_H__ diff --git a/xwords4/symbian/inc/xwappui.h b/xwords4/symbian/inc/xwappui.h deleted file mode 100644 index 00ece83ee..000000000 --- a/xwords4/symbian/inc/xwappui.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 _XWAPPUI_H_ -#define _XWAPPUI_H_ - -#include - -// Forward reference -class CXWordsAppView; - -/*! - @class CXWordsAppUi - - @discussion An instance of class CXWordsAppUi is the UserInterface - part of the Eikon application framework for XWords. - */ -class CXWordsAppUi : public CEikAppUi -{ - public: - /*! - @function ConstructL - */ - void ConstructL(); - - /*! - @function CXWordsAppUi - */ - CXWordsAppUi(); - - - /*! - @function ~CXWordsAppUi - - @discussion Destroy the object and release all memory objects - */ - ~CXWordsAppUi(); - - - public: // from CEikAppUi - /*! - @function HandleCommandL - */ - void HandleCommandL( TInt aCommand ); - TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, - TEventCode aType ); - - private: - /*! @var iAppView The application view */ - CXWordsAppView* iAppView; -}; - - -#endif // _XWAPPUI_H_ diff --git a/xwords4/symbian/inc/xwappview.h b/xwords4/symbian/inc/xwappview.h deleted file mode 100644 index 8c64e8d82..000000000 --- a/xwords4/symbian/inc/xwappview.h +++ /dev/null @@ -1,232 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 _XWORDSAPPVIEW_H_ -#define _XWORDSAPPVIEW_H_ - - -#include - -#include "game.h" -#include "comms.h" -#include "memstream.h" -#include "symdraw.h" -#include "symgmmgr.h" -#include "symssock.h" -#include "symrsock.h" -#include "xwrelay.h" - -typedef enum { - EGamesLoc - ,EDictsLoc - ,EPrefsLoc -} TDriveReason; - -/*! - @class CXWordsAppView - - @discussion This is the main view for Crosswords. Owns all the - common-code-created objects, passes events to them, etc. Should be - the only sample code file modified to any significant degree. - */ -//class CXWordsAppView : public CEikBorderedControl // ( which : CCoeControl ) -class CXWordsAppView : public CCoeControl -{ - public: - - /*! - @function NewL - - @discussion Create a CXWordsAppView object, which will draw itself to aRect - @param aRect the rectangle this view will be drawn to - @result a pointer to the created instance of CXWordsAppView - */ - static CXWordsAppView* NewL(const TRect& aRect, CEikApplication* aApp ); - - /*! - @function NewLC - - @discussion Create a CXWordsAppView object, which will draw itself to aRect - @param aRect the rectangle this view will be drawn to - @result a pointer to the created instance of CXWordsAppView - */ - static CXWordsAppView* NewLC(const TRect& aRect, CEikApplication* aApp ); - - - /*! - @function ~CXWordsAppView - - @discussion Destroy the object and release all memory objects - */ - ~CXWordsAppView(); - - - public: // from CEikBorderedControl - /*! - @function Draw - - @discussion Draw this CXWordsAppView to the screen - @param aRect the rectangle of this view that needs updating - */ - void Draw(const TRect& aRect) const; - - - private: - /*! - @function ConstructL - - @discussion Perform the second phase construction of a CXWordsAppView object - @param aRect the rectangle this view will be drawn to - */ - void ConstructL(const TRect& aRect); - - /*! - @function CXWordsAppView - - @discussion Perform the first phase of two phase construction - */ - CXWordsAppView( CEikApplication* aApp ); - - /* Added by eeh */ - public: - int HandleCommand( TInt aCommand ); - void Exiting(); - TBool HandleKeyEvent( const TKeyEvent& aKeyEvent ); - void UserErrorFromID( TInt aResource ); - XP_Bool UserQuery( UtilQueryID aId, XWStreamCtxt* aStream ); - - private: - typedef enum { - EUtilRequest - , EProcessPacket - , ENumReasons - } XWTimerReason_symb ; - - /* open game from prefs or start a new one. */ - void MakeOrLoadGameL(); - void DeleteGame(); - void SetUpUtil(); - void PositionBoard(); - void DisplayFinalScoresL(); - XWStreamCtxt* MakeSimpleStream( MemStreamCloseCallback cb, - XP_U16 channelNo = CHANNEL_NONE ); - TBool AskFromResId( TInt aResource ); - TBool FindAllDicts(); - TBool LoadPrefs(); - TBool AskSaveGame() { return ETrue; } - void SaveCurrentGame() {} - void NotImpl(); - void GetXwordsRWDir( TFileName* aPathRef, TDriveReason aWhy ); - void InitPrefs(); - void WritePrefs(); - void SaveCurGame(); - - void LoadOneGameL( TGameName* aGameName ); - void StoreOneGameL( TGameName* aGameName ); - TBool DoSavedGames(); - TBool DoNewGame(); - void DoImmediateDraw(); - void DrawGameName() const; - void StartIdleTimer( XWTimerReason_symb aWhy ); - - static void sym_util_requestTime( XW_UtilCtxt* uc ); - static VTableMgr* sym_util_getVTManager( XW_UtilCtxt* uc ); - static XP_U32 sym_util_getCurSeconds( XW_UtilCtxt* uc ); - static void sym_util_notifyGameOverL( XW_UtilCtxt* uc ); - static void sym_util_userError( XW_UtilCtxt* uc, UtilErrID id ); - static DictionaryCtxt* sym_util_makeEmptyDict( XW_UtilCtxt* uc ); - static XWStreamCtxt* sym_util_makeStreamFromAddr( XW_UtilCtxt* uc, - XP_U16 channelNo ); - - static void sym_util_setTimer( XW_UtilCtxt* uc, - XWTimerReason why, XP_U16 when, - TimerProc proc, void* closure ); -#ifdef BEYOND_IR - static void sym_util_listenPortChange( XW_UtilCtxt* uc, - XP_U16 listenPort ); - static void sym_util_addrChange( XW_UtilCtxt* uc, - const CommsAddrRec* aOld, - const CommsAddrRec* aNew ); -#endif - -#ifdef XWFEATURE_STANDALONE_ONLY -# define SYM_SEND (TransportSend)NULL -#else -# define SYM_SEND sym_send - - static XP_S16 sym_send( XP_U8* buf, XP_U16 len, - const CommsAddrRec* addr, void* closure ); - static void sym_send_on_close( XWStreamCtxt* stream, - void* closure ); - static void PacketReceived( const TDesC8* aBuf, void* aClosure ); - -#endif - - static TInt TimerCallback( TAny* aThis ); - static TInt HeartbeatTimerCallback( TAny* closure ); - - void SetHeartbeatCB( TimerProc aHBP, void* aHBC) { - iHeartbeatProc =aHBP; iHeartbeatClosure = aHBC; - } - void GetHeartbeatCB( TimerProc* aHBP, void** aHBC) { - *aHBP = iHeartbeatProc; *aHBC = iHeartbeatClosure; - } - - CEikApplication* iApp; /* remove if there's some way to get from - env */ - CurGameInfo iGi; - CommonPrefs iCp; -#ifndef XWFEATURE_STANDALONE_ONLY - CommsAddrRec iCommsAddr; /* for default settings */ -#endif - XW_UtilCtxt iUtil; - XWGame iGame; - DrawCtx* iDraw; - TGameName iCurGameName; - TRect iTitleBox; - - VTableMgr* iVtMgr; - TTime iStartTime; - TInt iTimerRunCount; - CIdle* iRequestTimer; - TInt iTimerReasons[ENumReasons]; - - CXWGamesMgr* iGamesMgr; - - CDesC16ArrayFlat* iDictList; /* to pass into the dialog */ - - CDeltaTimer* iDeltaTimer; - - TimerProc iHeartbeatProc; - void* iHeartbeatClosure; - TCallBack iHeartbeatCB; - TDeltaTimerEntry iHeartbeatDTE; - XP_Bool iHBQueued; - -#ifndef XWFEATURE_STANDALONE_ONLY - CSendSocket* iSendSock; - CDesC8ArrayFlat* iNewPacketQueue; -#endif - - MPSLOT -}; - -#endif // _XWORDSAPPVIEW_H_ diff --git a/xwords4/symbian/inc/xwdoc.h b/xwords4/symbian/inc/xwdoc.h deleted file mode 100644 index 1736232f3..000000000 --- a/xwords4/symbian/inc/xwdoc.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 __XWDOC_H__ -#define __XWDOC_H__ - -#include - -// Forward references -class CXWordsAppUi; -class CEikApplication; - -/*! - @class CXWordsDocument - - @discussion An instance of class CXWordsDocument is the Document part of the - Eikon application framework for the XWords example application - */ -class CXWordsDocument : public CEikDocument -{ - public: - - /*! - @function NewL - - @discussion Construct a CXWordsDocument for the Eikon - application aApp using two phase construction, and return a - pointer to the created object @param aApp application creating - this document @result a pointer to the created instance of - CXWordsDocument - */ - static CXWordsDocument* NewL(CEikApplication& aApp); - - /*! - @function NewLC - - @discussion Construct a CXWordsDocument for the Eikon - application aApp using two phase construction, and return a - pointer to the created object @param aApp application creating - this document @result a pointer to the created instance of - CXWordsDocument - */ - static CXWordsDocument* NewLC(CEikApplication& aApp); - - /*! - @function ~CXWordsDocument - - @discussion Destroy the object and release all memory objects - */ - ~CXWordsDocument(); - - public: // from CEikDocument - /*! - @function CreateAppUiL - - @discussion Create a CXWordsAppUi object and return a - pointer to it @result a pointer to the created instance of the - AppUi created - */ - CEikAppUi* CreateAppUiL(); - - private: - - /*! - @function ConstructL - - @discussion Perform the second phase construction of a - CXWordsDocument object - */ - void ConstructL(); - - /*! - @function CXWordsDocument - - @discussion Perform the first phase of two phase construction - @param aApp application creating this document - */ - CXWordsDocument(CEikApplication& aApp); - -}; - -#endif //__XWDOC_H__ diff --git a/xwords4/symbian/inc/xwords.hrh b/xwords4/symbian/inc/xwords.hrh deleted file mode 100644 index e61d81192..000000000 --- a/xwords4/symbian/inc/xwords.hrh +++ /dev/null @@ -1,96 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 __XWORDS_HRH__ -#define __XWORDS_HRH__ - -// HelloWorldBasic enumerate command codes -enum TXWordsIds { - XW_TIMEREQ_COMMAND = 0x6000 // convention is for >= 0x6000 -- they say - ,XW_NEWGAME_COMMAND - ,XW_SAVEDGAMES_COMMAND - ,XW_PREFS_COMMAND - ,XW_ABOUT_COMMAND - - ,XW_VALUES_COMMAND - ,XW_REMAIN_COMMAND - ,XW_CURINFO_COMMAND - ,XW_HISTORY_COMMAND - ,XW_FINALSCORES_COMMAND - - ,XW_HINT_COMMAND - /* #ifdef XWFEATURE_SEARCHLIMIT */ - /* ,XW_LIMHINT_COMMAND */ - /* #endif */ - ,XW_NEXTHINT_COMMAND - ,XW_UNDOCUR_COMMAND - ,XW_UNDOLAST_COMMAND - ,XW_DONE_COMMAND - ,XW_JUGGLE_COMMAND - ,XW_TRADE_COMMAND - ,XW_HIDETRAY_COMMAND - ,XW_FLIP_COMMAND - ,XW_TOGGLEVALS_COMMAND - - ,XW_SGAMES_DELETE_COMMAND - ,XW_SGAMES_RENAME_COMMAND - ,XW_SGAMES_OPEN_COMMAND - - ,EAskContents /* edit control in generic ask dlg */ - - ,EPlayerLocationChoice - ,EPlayerName - ,EPlayerSpeciesChoice - ,EDecryptPassword - -#ifndef XWFEATURE_STANDALONE_ONLY - ,XW_RESEND_COMMAND /* out of place for a menu command... */ - ,EConnectionRole - ,EConnectionType - ,ECookie - ,ERelayName - ,ERelayPort - ,EPageConn -#endif - ,EPagePlayers - ,EPageDict - - ,ESelDictName - ,ESelDictChoice - ,EPlayerSpecies - - ,ENPlayersList - ,ENPlayersWhichList - - ,ESelBlankChoice - ,ESelGameChoice - - ,EEditNameEdwin - -#if defined SERIES_60 - ,EDictBrowseButton -#endif -}; - -#define XW_UID3 0x10206D64 - -#endif // __XWORDS_HRH__ - diff --git a/xwords4/symbian/inc/xwords.pan b/xwords4/symbian/inc/xwords.pan deleted file mode 100644 index 1327fd208..000000000 --- a/xwords4/symbian/inc/xwords.pan +++ /dev/null @@ -1,37 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 __XWORDS_PAN__ -#define __XWORDS_PAN__ - -/** XWords application panic codes */ -enum TXwordsPanics { - EXWordsUi = 1 - // add further panics here -}; - -inline void Panic(TXwordsPanics aReason) -{ - _LIT(applicationName,"Crosswords"); - User::Panic(applicationName, aReason); -} - -#endif // __XWORDS_PAN__ diff --git a/xwords4/symbian/src/.cvsignore b/xwords4/symbian/src/.cvsignore deleted file mode 100644 index f0357870c..000000000 --- a/xwords4/symbian/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -SYMB_80_WINS -xwords*.UID.cpp diff --git a/xwords4/symbian/src/symaskdlg.cpp b/xwords4/symbian/src/symaskdlg.cpp deleted file mode 100644 index d7511fab3..000000000 --- a/xwords4/symbian/src/symaskdlg.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include - -#include "symaskdlg.h" -# include "xwords.hrh" -#ifdef SERIES_60 -# include "xwords_60.rsg" -#elif defined SERIES_80 -# include "xwords_80.rsg" -#endif - -CXWAskDlg::CXWAskDlg( MPFORMAL XWStreamCtxt* aStream, TBool aKillStream ) : - iStream(aStream), iMessage(NULL), iKillStream(aKillStream) -{ - MPASSIGN( this->mpool, mpool ); -} - -CXWAskDlg::CXWAskDlg( MPFORMAL TBuf16<128>* aMessage) - : iStream(NULL), iMessage(aMessage) -{ - MPASSIGN( this->mpool, mpool ); -} - -CXWAskDlg::~CXWAskDlg() -{ - if ( iKillStream && iStream != NULL ) { - stream_destroy( iStream ); - } -} - -static void -SwapInSymbLinefeed( TDes16& buf16 ) -{ - TBuf16<1> lfDescNew; - lfDescNew.Append( CEditableText::ELineBreak ); - TBuf8<4> tmp( (unsigned char*)XP_CR ); - TBuf16<4> lfDescOld; - lfDescOld.Copy( tmp ); - - XP_LOGF( "starting search-and-replace" ); -#if 0 - TInt len = buf16.Length(); - TPtrC16 rightPart = buf16.Right(len); - TInt leftLen = 0; - for ( ; ; ) { - TInt pos = rightPart.Find( lfDescOld ); - if ( pos == KErrNotFound ) { - break; - } - buf16.Replace( leftLen + pos, 1, lfDescNew ); - leftLen += pos; - len -= pos; - /* This won't compile. Need to figure out how to replace without - starting the search at the beginning each time */ - rightPart = buf16.Right(len); - } -#else - for ( ; ; ) { - TInt pos = buf16.Find( lfDescOld ); - if ( pos == KErrNotFound ) { - break; - } - buf16.Replace( pos, 1, lfDescNew ); - } -#endif - XP_LOGF( "search-and-replace done" ); -} - -void -CXWAskDlg::PreLayoutDynInitL() -{ - CEikEdwin* contents = (CEikEdwin*)Control( EAskContents ); - - // Load the stream's contents into a read-only edit control. - if ( iStream ) { - TInt size = stream_getSize( iStream ); - XP_U16* buf16 = new(ELeave) XP_U16[size]; - CleanupStack::PushL( buf16 ); - - unsigned char* buf8 = (unsigned char*)XP_MALLOC( mpool, size ); - /* PENDING This belongs on the leave stack */ - User::LeaveIfNull( buf8 ); - stream_getBytes( iStream, buf8, SC(XP_U16,size) ); - - TPtrC8 desc8( buf8, size ); - TPtr16 desc16( buf16, size ); -#if 0 - if ( ConvertToDblByteL( desc16, desc8 ) ) { - contents->SetTextL( &desc16 ); - } -#else - desc16.Copy( desc8 ); - SwapInSymbLinefeed( desc16 ); - contents->SetTextL( &desc16 ); -#endif - XP_FREE( mpool, buf8 ); - CleanupStack::PopAndDestroy( buf16 ); - } else { - contents->SetTextL( iMessage ); - } -} /* PreLayoutDynInitL */ - -TBool CXWAskDlg::OkToExitL( TInt aButtonID /* pressed button */ ) -{ - /* The function should return ETrue if it is OK to exit, and EFalse to - keep the dialog active. It should always return ETrue if the button - with ID EEikBidOK was activated. */ - - XP_LOGF( "CXWAskDlg::OkToExitL passed %d", aButtonID ); - - return ETrue; -} - -/* static */ TBool -CXWAskDlg::DoAskDlg( MPFORMAL XWStreamCtxt* aStream, TBool aKillStream ) -{ - CXWAskDlg* me = new(ELeave)CXWAskDlg( MPPARM(mpool) aStream, aKillStream ); - return me->ExecuteLD( R_XWORDS_CONFIRMATION_QUERY ); -} - -/* static */ TBool -CXWAskDlg::DoAskDlg( MPFORMAL TBuf16<128>* aMessage ) -{ - CXWAskDlg* me = new(ELeave)CXWAskDlg( MPPARM(mpool) aMessage ); - return me->ExecuteLD( R_XWORDS_CONFIRMATION_QUERY ); -} - -/* static */ void -CXWAskDlg::DoInfoDlg( MPFORMAL XWStreamCtxt* aStream, TBool aKillStream ) -{ - CXWAskDlg* me = new(ELeave)CXWAskDlg( MPPARM(mpool) aStream, aKillStream ); - (void)me->ExecuteLD( R_XWORDS_INFO_ONLY ); -} - diff --git a/xwords4/symbian/src/symblnk.cpp b/xwords4/symbian/src/symblnk.cpp deleted file mode 100644 index adbac6af9..000000000 --- a/xwords4/symbian/src/symblnk.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 -#include -#if defined SERIES_60 -# include -# include "xwords_60.rsg" -#elif defined SERIES_80 -# include -# include "xwords_80.rsg" -#endif - -#include "xwords.hrh" -#include "symblnk.h" - - -CXWBlankSelDlg::CXWBlankSelDlg( const XP_UCHAR4* aTexts, - TInt aNTiles, TInt* aResultP ) - :iTexts(aTexts), - iNTiles(aNTiles), - iResultP(aResultP), - iFacesList(NULL) -{ - // nothing else -} - -void -CXWBlankSelDlg::PreLayoutDynInitL() -{ - // stuff the array -#if defined SERIES_80 - CEikChoiceList* list; -#elif defined SERIES_60 - CAknListQueryControl* list; -#endif - CDesC16ArrayFlat* facesList = new (ELeave)CDesC16ArrayFlat( iNTiles ); - - TInt i; - for ( i = 0; i < iNTiles; ++i ) { - TBuf16<4> buf16; - buf16.Copy( TPtrC8(iTexts[i]) ); - facesList->AppendL( buf16 ); - } - -#if defined SERIES_80 - list = static_cast(Control(ESelBlankChoice)); - list->SetArrayExternalOwnership( EFalse ); - list->SetArrayL( facesList ); -#elif defined SERIES_60 - list = static_cast(Control(ESelBlankChoice)); -#endif -} - -TBool -CXWBlankSelDlg::OkToExitL( TInt /*aKeyCode*/ ) -{ -#if defined SERIES_80 - CEikChoiceList* list = static_cast - (Control(ESelBlankChoice)); - *iResultP = list->CurrentItem(); -#endif - return ETrue; -} // OkToExitL - -/* static */ void -CXWBlankSelDlg::UsePickTileDialogL( const XP_UCHAR4* texts, TInt aNTiles, - TInt* resultP ) -{ - CXWBlankSelDlg* dlg = new (ELeave) CXWBlankSelDlg( texts, aNTiles, - resultP ); - (void)dlg->ExecuteLD( R_XWORDS_BLANK_PICKER ); -} // UsePickTileDialogL diff --git a/xwords4/symbian/src/symdict.cpp b/xwords4/symbian/src/symdict.cpp deleted file mode 100644 index d76d69d3b..000000000 --- a/xwords4/symbian/src/symdict.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - -extern "C" { -#include "dictnryp.h" -#include "mempool.h" -#include "xptypes.h" -} - -#include -#include "symdict.h" -#include "symutil.h" - - -typedef struct SymDictCtxt { - DictionaryCtxt super; - -} SymDictCtxt; - -static void sym_dictionary_destroy( DictionaryCtxt* dict ); - - - -static XP_U8 -readXP_U8( RFile* file ) -{ - TBuf8<1> buf; - TInt err = file->Read( buf, 1 ); - XP_ASSERT( err == KErrNone ); - return *buf.Ptr(); -} // readXP_U8 - -static XP_U16 -readXP_U16( RFile* file ) -{ - TBuf8<2> buf; - TInt err = file->Read( buf, 2 ); - XP_ASSERT( err == KErrNone ); - return XP_NTOHS( *(XP_U16*)buf.Ptr() ); -} // readXP_U16 - -static XP_U32 -readXP_U32( RFile* file ) -{ - TBuf8<4> buf; - TInt err = file->Read( buf, 4 ); - XP_ASSERT( err == KErrNone ); - return XP_NTOHL( *(XP_U32*)buf.Ptr() ); -} // readXP_U32 - -static XP_U16 -symCountSpecials( SymDictCtxt* ctxt ) -{ - XP_U16 result = 0; - XP_U16 i; - - for ( i = 0; i < ctxt->super.nFaces; ++i ) { - if ( IS_SPECIAL(ctxt->super.faces16[i] ) ) { - ++result; - } - } - - return result; -} /* symCountSpecials */ - -#ifdef DEBUG -static void -printBitmap( CFbsBitmap* bmp ) -{ - TSize bmpSize = bmp->SizeInPixels(); - TBitmapUtil butil( bmp ); - butil.Begin( TPoint(0,0) ); - TInt row, col; - - for ( row = 0; row < bmpSize.iHeight; ++row ) { - char buf[64]; - for ( col = 0; col < bmpSize.iWidth; ++col ) { - butil.SetPos( TPoint(col, row) ); - if ( butil.GetPixel() ) { - buf[col] = '*'; - } else { - buf[col] = '_'; - } - } - buf[col] = '\0'; - XP_LOGF( "row %d: %s", row, buf ); - } - - butil.End(); -} -#else -#define printBitmap(b) -#endif - -static XP_Bitmap* -symMakeBitmap( SymDictCtxt* /*ctxt*/, RFile* file ) -{ - XP_U8 nCols = readXP_U8( file ); - CFbsBitmap* bitmap = (CFbsBitmap*)NULL; - const TDisplayMode dispMode = EGray2; - - if ( nCols > 0 ) { - - XP_U8 nRows = readXP_U8( file ); - XP_U8 srcByte = 0; - XP_U16 nBits; - bitmap = new (ELeave) CFbsBitmap(); - bitmap->Create( TSize(nCols, nRows), dispMode ); - - TBitmapUtil butil( bitmap ); - butil.Begin( TPoint(0,0) ); - - TInt col, row; - nBits = nRows * nCols; - TInt curBit = 0; - for ( row = 0; curBit < nBits; ++row ) { - for ( col = 0; col < nCols; ++col ) { - TUint32 value; - TInt index = curBit % 8; - - if ( index == 0 ) { - srcByte = readXP_U8( file ); - } - - value = ((srcByte & 0x80) == 0) ? 1L : 0L; - - butil.SetPos( TPoint(col, row) ); - butil.SetPixel( value ); - - srcByte <<= 1; - ++curBit; - } - } - butil.End(); - - printBitmap( bitmap ); - } - - return (XP_Bitmap*)bitmap; -} /* symMakeBitmap */ - -static void -symLoadSpecialData( SymDictCtxt* ctxt, RFile* file ) -{ - TInt i; - TInt nSpecials = symCountSpecials( ctxt ); - XP_UCHAR** texts; - SpecialBitmaps* bitmaps; - - XP_DEBUGF( "loadSpecialData: there are %d specials", nSpecials ); - - texts = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool, - nSpecials * sizeof(*texts) ); - bitmaps = (SpecialBitmaps*) - XP_MALLOC( ctxt->super.mpool, nSpecials * sizeof(*bitmaps) ); - - for ( i = 0; i < ctxt->super.nFaces; ++i ) { - - XP_CHAR16 face = ctxt->super.faces16[(short)i]; - if ( IS_SPECIAL(face) ) { - - /* get the string */ - XP_U8 txtlen = readXP_U8( file ); - XP_UCHAR* text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1); - TPtr8 desc( text, txtlen ); - file->Read( desc, txtlen ); - text[txtlen] = '\0'; - XP_ASSERT( face < nSpecials ); - texts[face] = text; - - XP_DEBUGF( "making bitmaps for %s", texts[face] ); - bitmaps[face].largeBM = symMakeBitmap( ctxt, file ); - bitmaps[face].smallBM = symMakeBitmap( ctxt, file ); - } - } - - ctxt->super.chars = texts; - ctxt->super.bitmaps = bitmaps; - XP_LOGF( "returning from symLoadSpecialData" ); -} // symLoadSpecialData - -static void -readFileToBuf( XP_UCHAR* dictBuf, const RFile* file ) -{ - XP_U32 offset = 0; - for ( ; ; ) { - TBuf8<1024> buf; - TInt err = file->Read( buf, buf.MaxLength() ); - XP_ASSERT( err == KErrNone ); - TInt nRead = buf.Size(); - if ( nRead <= 0 ) { - break; - } - XP_MEMCPY( (void*)(dictBuf + offset), (void*)buf.Ptr(), nRead ); - offset += nRead; - } -} // readFileToBuf - -DictionaryCtxt* -sym_dictionary_makeL( MPFORMAL TFileName* base, const XP_UCHAR* aDictName ) -{ - if ( !aDictName ) { - SymDictCtxt* ctxt = (SymDictCtxt*)XP_MALLOC( mpool, sizeof( *ctxt ) ); - XP_MEMSET( ctxt, 0, sizeof(*ctxt) ); - MPASSIGN( ctxt->super.mpool, mpool ); - return &ctxt->super; - } else { - - TBuf16<32> dname16; - dname16.Copy( TPtrC8(aDictName) ); - base->Append( dname16 ); - base->Append( _L(".xwd") ); - SymDictCtxt* ctxt = NULL; - - RFs fileSession; - User::LeaveIfError(fileSession.Connect()); - CleanupClosePushL(fileSession); - - RFile file; - TInt err = file.Open( fileSession, *base, EFileRead ); - if ( err != KErrNone ) { - XP_LOGDESC16( base ); - XP_LOGF( "file.Open => %d", err ); - } - User::LeaveIfError( err ); - CleanupClosePushL(file); - - ctxt = (SymDictCtxt*)XP_MALLOC( mpool, sizeof(*ctxt) ); - User::LeaveIfNull( ctxt ); - XP_MEMSET( ctxt, 0, sizeof( *ctxt ) ); - MPASSIGN( ctxt->super.mpool, mpool ); - - dict_super_init( (DictionaryCtxt*)ctxt ); - - ctxt->super.destructor = sym_dictionary_destroy; - XP_ASSERT( ctxt->super.name == NULL ); - symReplaceStrIfDiff( MPPARM(mpool) &ctxt->super.name, aDictName ); - - XP_U16 flags = readXP_U16( &file ); - XP_LOGF( "read flags are: 0x%x", (TInt)flags ); - - TInt numFaces = readXP_U8( &file ); - ctxt->super.nFaces = (XP_U8)numFaces; - XP_DEBUGF( "read %d faces from dict", (TInt)numFaces ); - - ctxt->super.faces16 = (XP_U16*) - XP_MALLOC( mpool, numFaces * sizeof(ctxt->super.faces16[0]) ); -#ifdef NODE_CAN_4 - if ( flags == 0x0002 ) { - ctxt->super.nodeSize = 3; - } else if ( flags == 0x0003 ) { - ctxt->super.nodeSize = 4; - } else { - XP_DEBUGF( "flags=0x%x", flags ); - XP_ASSERT( 0 ); - } - - ctxt->super.is_4_byte = ctxt->super.nodeSize == 4; - TInt i; - for ( i = 0; i < numFaces; ++i ) { - ctxt->super.faces16[i] = readXP_U16( &file ); - } -#else - error will robinson....; -#endif - - ctxt->super.countsAndValues = - (XP_U8*)XP_MALLOC( mpool, numFaces*2 ); - (void)readXP_U16( &file ); // skip xloc header - - for ( i = 0; i < numFaces*2; i += 2 ) { - ctxt->super.countsAndValues[i] = readXP_U8( &file ); - ctxt->super.countsAndValues[i+1] = readXP_U8( &file ); - } - - symLoadSpecialData( ctxt, &file ); - - // Now, until we figure out how/whether Symbian does memory - // mapping of files, we need to allocate a buffer to hold the - // entire freaking DAWG... :-( - TInt dawgSize; - (void)file.Size( dawgSize ); - TInt pos = 0; - file.Seek( ESeekCurrent, pos ); - dawgSize -= pos; - - if ( dawgSize > SC(TInt, sizeof(XP_U32)) ) { - XP_U32 offset = readXP_U32( &file ); - dawgSize -= sizeof(XP_U32); - - XP_ASSERT( dawgSize % ctxt->super.nodeSize == 0 ); -# ifdef DEBUG - ctxt->super.numEdges = dawgSize / ctxt->super.nodeSize; -# endif - - if ( dawgSize > 0 ) { - XP_DEBUGF( "setting topEdge; offset = %d", offset ); - - XP_U8* dictBuf = (XP_U8*)XP_MALLOC( mpool, dawgSize ); - User::LeaveIfNull( dictBuf ); // will leak ctxt (PENDING...) - - readFileToBuf( dictBuf, &file ); - - ctxt->super.base = (array_edge*)dictBuf; - - ctxt->super.topEdge = ctxt->super.base - + (offset * ctxt->super.nodeSize); - ctxt->super.topEdge = ctxt->super.base - + (offset * ctxt->super.nodeSize); - } else { - ctxt->super.topEdge = (array_edge*)NULL; - ctxt->super.base = (array_edge*)NULL; - } - } - - CleanupStack::PopAndDestroy( &file ); // file - CleanupStack::PopAndDestroy( &fileSession ); // fileSession - - return &ctxt->super; - } -} // sym_dictionary_make - -static void -sym_dictionary_destroy( DictionaryCtxt* dict ) -{ - SymDictCtxt* sctx = (SymDictCtxt*)dict; - XP_U16 nSpecials = symCountSpecials( sctx ); - XP_U16 i; - - if ( dict->countsAndValues != NULL ) { - XP_FREE( sctx->super.mpool, dict->countsAndValues ); - } - if ( dict->faces16 != NULL ) { - XP_FREE( sctx->super.mpool, dict->faces16 ); - } - - if ( !!sctx->super.chars ) { - for ( i = 0; i < nSpecials; ++i ) { - XP_UCHAR* text = sctx->super.chars[i]; - if ( !!text ) { - XP_FREE( sctx->super.mpool, text ); - } - } - XP_FREE( dict->mpool, dict->chars ); - } - - if ( !!sctx->super.bitmaps ) { - for ( i = 0; i < nSpecials; ++i ) { - CFbsBitmap* bitmap = (CFbsBitmap*)dict->bitmaps[i].smallBM; - delete bitmap; - bitmap = (CFbsBitmap*)dict->bitmaps[i].largeBM; - delete bitmap; - } - XP_FREE( dict->mpool, dict->bitmaps ); - } - - if ( dict->base != NULL ) { - XP_FREE( dict->mpool, dict->base ); - } - - if ( dict->name ) { - XP_FREE( dict->mpool, dict->name ); - } - - XP_FREE( dict->mpool, dict ); -} diff --git a/xwords4/symbian/src/symdraw.cpp b/xwords4/symbian/src/symdraw.cpp deleted file mode 100644 index a9d8440ef..000000000 --- a/xwords4/symbian/src/symdraw.cpp +++ /dev/null @@ -1,872 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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. - */ - - -extern "C" { -#include "comtypes.h" -#include "board.h" -#include "draw.h" -#include "mempool.h" - -} // extern "C" - -#include - -#if defined SERIES_60 - -# include -# include -# include "xwords_60.mbg" - -# define BMNAME( file, bm ) file ## _60 ## bm - -#elif defined SERIES_80 -# include -# include -# include -# include "xwords_80.mbg" - -# define BMNAME( file, bm ) file ## _80 ## bm - -#else -# error define a series platform!!!! -#endif - -#include - -#include "symdraw.h" - -#define TRAY_CURSOR_HT 2 - -enum { - COLOR_BLACK, - COLOR_WHITE, - COLOR_CURSOR, - - COLOR_PLAYER1, - COLOR_PLAYER2, - COLOR_PLAYER3, - COLOR_PLAYER4, - - COLOR_DBL_LTTR, - COLOR_DBL_WORD, - COLOR_TRPL_LTTR, - COLOR_TRPL_WORD, - - COLOR_EMPTY, - COLOR_TILE, - - COLOR_NCOLORS /* 12 */ -}; - -#ifdef SERIES_60 -# define CONST_60 const -#else -# define CONST_60 -#endif - -typedef struct SymDrawCtxt { - /* Must be first */ - DrawCtxVTable* vtable; - - CWindowGc* iGC; - - CEikonEnv* iiEikonEnv; /* iEikonEnv is a macro in Symbian headers!!! */ - CCoeEnv* iCoeEnv; - - CFbsBitmap* iRightArrow; - CFbsBitmap* iDownArrow; - CFbsBitmap* iStar; - CFbsBitmap* iTurnIcon; - CFbsBitmap* iTurnIconMask; - CFbsBitmap* iRobotIcon; - CFbsBitmap* iRobotIconMask; - - CONST_60 CFont* iTileFaceFont; - CONST_60 CFont* iTileValueFont; - CONST_60 CFont* iBoardFont; - CONST_60 CFont* iScoreFont; - - XP_U16 iTrayOwner; - XP_Bool iAllFontsSame; - TRgb colors[COLOR_NCOLORS]; - - MPSLOT -} SymDrawCtxt; - -static void -symLocalRect( TRect* dest, const XP_Rect* src ) -{ - dest->Move( src->left, src->top ); - dest->SetWidth( src->width + 1 ); - dest->SetHeight( src->height + 1 ); -} // symLocalRect - -static void -symClearRect( SymDrawCtxt* sctx, const TRect* rect, TInt clearTo ) -{ - sctx->iGC->SetBrushColor( sctx->colors[clearTo] ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - sctx->iGC->SetPenStyle( CGraphicsContext::ENullPen ); - sctx->iGC->DrawRect( *rect ); -} // symClearRect - -static void -drawFocusRect( SymDrawCtxt* sctx, const XP_Rect* rect, XP_Bool hasfocus ) -{ - TRect lRect; - symLocalRect( &lRect, rect ); - - lRect.Grow( 2, 2 ); // This is space board.c doesn't know about - - sctx->iGC->SetBrushStyle( CGraphicsContext::ENullBrush ); - sctx->iGC->SetPenStyle( CGraphicsContext::ESolidPen ); - XP_U16 index = SC(XP_U16,(hasfocus? COLOR_CURSOR : COLOR_WHITE)); - sctx->iGC->SetPenColor( sctx->colors[index] ); - TInt i; - for ( i = 0; i < 2; ++i ) { - sctx->iGC->DrawRect( lRect ); - lRect.Shrink( 1, 1 ); - } -} // drawFocusRect - -static void -getBonusColor( SymDrawCtxt* sctx, XWBonusType bonus, TRgb* rgb ) -{ - TInt index; - if ( bonus == BONUS_NONE ) { - index = COLOR_WHITE; - } else { - index = COLOR_DBL_LTTR + bonus - 1; - } - *rgb = sctx->colors[index]; -} // getBonusColor - -static void -drawBitmap( SymDrawCtxt* sctx, CFbsBitmap* bmp, CFbsBitmap* mask, - const TRect* aRect ) -{ - TRect rect( *aRect ); - TSize bmpSize = bmp->SizeInPixels(); - if ( bmpSize.iWidth <= rect.Width() - && bmpSize.iHeight <= rect.Height() ) { - - rect.Move( (rect.Width() - bmpSize.iWidth) / 2, - (rect.Height() - bmpSize.iHeight) / 2 ); - rect.SetSize( bmpSize ); - - TRect imgRect( TPoint(0,0), bmpSize ); - sctx->iGC->BitBltMasked( rect.iTl, bmp, imgRect, mask, ETrue ); - } else { - XP_LOGF( "bitmap too big" ); - } -} /* drawBitmap */ - -static void -sym_draw_destroyCtxt( DrawCtx* p_dctx ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - XP_LOGF( "freeing draw ctxt" ); - - CWsScreenDevice* sdev = sctx->iCoeEnv->ScreenDevice(); - sdev->ReleaseFont( sctx->iTileFaceFont ); - if ( ! sctx->iAllFontsSame ) { - sdev->ReleaseFont( sctx->iTileValueFont ); - sdev->ReleaseFont( sctx->iBoardFont ); - sdev->ReleaseFont( sctx->iScoreFont ); - } - - delete sctx->iRightArrow; - delete sctx->iDownArrow; - delete sctx->iStar; - delete sctx->iTurnIcon; - delete sctx->iTurnIconMask; - delete sctx->iRobotIcon; - delete sctx->iRobotIconMask; - - XP_ASSERT( sctx ); - XP_ASSERT( sctx->vtable ); - XP_FREE( sctx->mpool, sctx->vtable ); - XP_FREE( sctx->mpool, sctx ); -} - -static XP_Bool -sym_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* dict, - const XP_Rect* rect, XP_Bool hasfocus ) -{ - XP_LOGF( "sym_draw_boardBegin" ); - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - drawFocusRect( sctx, rect, hasfocus ); - return XP_TRUE; -} - -static void -sym_draw_boardFinished( DrawCtx* /*p_dctx*/ ) -{ -} - -#ifdef DEBUG -static XP_Bool -sym_draw_vertScrollBoard( DrawCtx* /*p_dctx*/, XP_Rect* /*rect*/, - XP_S16 /*dist*/ ) -{ - XP_ASSERT(0); - return XP_FALSE; -} -#endif - -static XP_Bool -sym_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 owner, XP_Bool hasfocus ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - sctx->iTrayOwner = owner; - - drawFocusRect( sctx, rect, hasfocus ); - - return XP_TRUE; -} - -static void -sym_draw_trayFinished( DrawCtx* /*dctx*/ ) -{ -} - -static void -makeRemText( TBuf16<64>* buf, XP_S16 nLeft ) -{ - if ( nLeft < 0 ) { - nLeft = 0; - } - buf->Num( nLeft ); - buf->Insert( 0, _L("Tiles left in pool: ") ); -} // makeRemText - -static void -sym_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* /*r*/, - XP_S16 nTilesLeft, - XP_U16* widthP, XP_U16* heightP ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TBuf16<64> tbuf; - makeRemText( &tbuf, nTilesLeft ); - - CONST_60 CFont* font = sctx->iScoreFont; - *widthP = (XP_S16)font->TextWidthInPixels( tbuf ); - *heightP = (XP_S16)font->HeightInPixels(); -} // sym_draw_measureRemText - -static void -sym_draw_drawRemText(DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* /*rOuter*/, XP_S16 nTilesLeft) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TBuf16<64> tbuf; - makeRemText( &tbuf, nTilesLeft ); - - TRect lRect; - symLocalRect( &lRect, rInner ); - - sctx->iGC->SetPenStyle( CGraphicsContext::ESolidPen ); - sctx->iGC->SetPenColor( KRgbBlack ); - sctx->iGC->SetBrushColor( KRgbGray ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - - CONST_60 CFont* font = sctx->iScoreFont; - sctx->iGC->UseFont( font ); - sctx->iGC->DrawText( tbuf, lRect, lRect.Height() - 2 ); - sctx->iGC->DiscardFont(); -} // sym_draw_drawRemText - -static void -sym_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 /*numPlayers*/, XP_Bool hasfocus ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - drawFocusRect( sctx, rect, hasfocus ); -} - -static void -sym_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* /*r*/, - const DrawScoreInfo* /*dsi*/, - XP_U16* widthP, XP_U16* heightP ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - CONST_60 CFont* font = sctx->iScoreFont; - TInt height = font->HeightInPixels(); - - *widthP = 10; /* whatever; we're only using rOuter */ - *heightP = SC( XP_U16, height ); -} /* sym_draw_measureScoreText */ - -/* We want the elements of a scoreboard to line up in columns. So draw them - * one at a time. NAME SCORE TILE_LEFT ?LAST_SCORE? Might be better to show - * robot-ness and local/remoteness with colors? Turn is with an icon. - */ -static void -sym_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* /*rInner*/, - const XP_Rect* rOuter, const DrawScoreInfo* dsi ) -{ - const TInt KTurnIconWidth = 16; - const TInt KNameColumnWidth = 90; - const TInt KScoreColumnWidth = 25; -/* const TInt KTilesLeftColumnWidth = 15; */ - const TInt KLastMoveColumnWidth = 100; /* will be clipped down */ - - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - CONST_60 CFont* font = sctx->iScoreFont; - - TRect lRect; - symLocalRect( &lRect, rOuter ); - TInt rightEdge = lRect.iBr.iX; - symClearRect( sctx, &lRect, dsi->selected? COLOR_BLACK:COLOR_WHITE ); - - TInt fontHeight = font->AscentInPixels(); - TInt baseline = fontHeight + ((lRect.Height() - fontHeight) / 2); - - /* The y coords of the rect stay the same, but the x coords change as we - do each column. The first time, turn-icon column, the left edge is - already where we want it. */ - lRect.iBr.iX = lRect.iTl.iX + KTurnIconWidth; - symClearRect( sctx, &lRect, COLOR_WHITE ); - if ( dsi->isTurn ) { - drawBitmap( sctx, sctx->iTurnIcon, sctx->iTurnIconMask, &lRect ); - } else if ( dsi->isRobot ) { - drawBitmap( sctx, sctx->iRobotIcon, sctx->iRobotIconMask, &lRect ); - } - - XP_U16 playerNum = dsi->playerNum; - if ( dsi->selected ) { - sctx->iGC->SetPenColor( sctx->colors[COLOR_WHITE] ); - } else { - sctx->iGC->SetPenColor( sctx->colors[playerNum + COLOR_PLAYER1] ); - } - sctx->iGC->SetBrushStyle( CGraphicsContext::ENullBrush ); - - TBuf16<64> tbuf; - sctx->iGC->UseFont( font ); - - /* Draw name */ - lRect.iTl.iX = lRect.iBr.iX + 1; /* add one to get name away from edge */ - lRect.iBr.iX += KNameColumnWidth; - tbuf.Copy( TBuf8<32>(dsi->name) ); - if ( dsi->isRemote ) { - tbuf.Insert( 0, _L("[") ); - tbuf.Append( _L("]") ); - } - sctx->iGC->DrawText( tbuf, lRect, baseline ); - - /* Draw score, right-justified */ - lRect.iTl.iX = lRect.iBr.iX; - lRect.iBr.iX += KScoreColumnWidth; - tbuf.Num( dsi->score ); - sctx->iGC->DrawText( tbuf, lRect, baseline, CGraphicsContext::ERight ); - - /* Draw last move */ - lRect.iTl.iX = lRect.iBr.iX + 6; /* 6 gives it some spacing from - r-justified score */ - lRect.iBr.iX += KLastMoveColumnWidth; - XP_UCHAR buf[32]; - XP_U16 len = sizeof(buf); - if ( (*dsi->lsc)( dsi->lscClosure, playerNum, buf, &len ) ) { - tbuf.Copy( TBuf8<32>(buf) ); - if ( lRect.iBr.iX > rightEdge ) { - lRect.iBr.iX = rightEdge; - } - sctx->iGC->DrawText( tbuf, lRect, baseline ); - } - - sctx->iGC->DiscardFont(); -} /* sym_draw_score_drawPlayer */ - -static void -sym_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect, - XP_S16 score, XP_U16 /*playerNum*/ ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TRect lRect; - symLocalRect( &lRect, rect ); - lRect.Shrink( 1, 1 ); - lRect.SetHeight( lRect.Height() - TRAY_CURSOR_HT ); - sctx->iGC->SetPenColor( sctx->colors[COLOR_BLACK] ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - sctx->iGC->SetBrushColor( sctx->colors[COLOR_WHITE] ); - - sctx->iGC->UseFont( sctx->iTileValueFont ); - - TInt halfHeight = lRect.Height() / 2; - lRect.iBr.iY -= halfHeight; - sctx->iGC->DrawText( _L("Pts:"), lRect, halfHeight-2, - CGraphicsContext::ERight ); - - TBuf16<8> buf; - if ( score >= 0 ) { - buf.Num( score ); - } else { - buf.Copy( _L("???") ); - } - - lRect.iTl.iY += halfHeight; - lRect.iBr.iY += halfHeight; - sctx->iGC->DrawText( buf, lRect, halfHeight-2, CGraphicsContext::ERight ); - - sctx->iGC->DiscardFont(); -} - -static void -sym_draw_scoreFinished( DrawCtx* /*dctx*/ ) -{ -} - -static void -sym_draw_drawTimer( DrawCtx* /*p_dctx*/, const XP_Rect* /*rInner*/, - const XP_Rect* /*rOuter*/, - XP_U16 /*player*/, XP_S16 /*secondsLeft*/ ) -{ -} - -static void -textInCell( SymDrawCtxt* sctx, const XP_UCHAR* text, const TRect* lRect, - TBool highlight ) -{ - if ( highlight ) { - sctx->iGC->SetPenColor( sctx->colors[COLOR_WHITE] ); - } else { - sctx->iGC->SetPenColor( sctx->colors[COLOR_BLACK] ); - } - sctx->iGC->SetBrushStyle( CGraphicsContext::ENullBrush ); - CONST_60 CFont* font = sctx->iBoardFont; - - TBuf16<64> tbuf; - tbuf.Copy( TPtrC8(text) ); - - TInt ht = font->AscentInPixels(); - TInt baseOffset = ht + ((lRect->Height() - ht) / 2); - - sctx->iGC->UseFont( font ); - sctx->iGC->DrawText( tbuf, *lRect, baseOffset, CGraphicsContext::ECenter ); - sctx->iGC->DiscardFont(); -} /* textInCell */ - -static XP_Bool -sym_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, - /* at least one of these two will be null */ - const XP_UCHAR* text, XP_Bitmap bitmap, - Tile tile, XP_S16 /*owner*/, /* -1 means don't use */ - XWBonusType bonus, HintAtts /*hintAtts*/, - XP_Bool isBlank, XP_Bool highlight, - XP_Bool isStar ) -{ - TRect lRect; - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - - symLocalRect( &lRect, rect ); - - TRgb rgb; - if ( highlight ) { - rgb = sctx->colors[COLOR_BLACK]; - } else if ( !!bitmap || (!!text && XP_STRLEN((const char*)text) > 0)) { - rgb = sctx->colors[COLOR_TILE]; - } else { - getBonusColor( sctx, bonus, &rgb ); - } - - sctx->iGC->SetPenColor( sctx->colors[COLOR_BLACK] ); - sctx->iGC->SetPenStyle( CGraphicsContext::ESolidPen ); - sctx->iGC->SetBrushColor( rgb ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - sctx->iGC->DrawRect( lRect ); - - if ( !!bitmap ) { - drawBitmap( sctx, (CFbsBitmap*)bitmap, (CFbsBitmap*)bitmap, &lRect ); - } else if ( !!text && (*text != '\0') ) { - TRect r2(lRect); - textInCell( sctx, text, &r2, highlight ); - } else if ( isStar ) { - drawBitmap( sctx, sctx->iStar, sctx->iStar, &lRect ); - } - - if ( isBlank ) { - lRect.Shrink( 1, 0 ); - sctx->iGC->DrawLine( lRect.iTl, TPoint(lRect.iTl.iX, lRect.iBr.iY ) ); - lRect.Shrink( 1, 0 ); - /* draws to right of points; second Shrink is easier than subbing 1 - from x coords */ - sctx->iGC->DrawLine( TPoint(lRect.iBr.iX, lRect.iTl.iY), lRect.iBr ); - } - - return XP_TRUE; -} /* sym_draw_drawCell */ - -static void -sym_draw_invertCell( DrawCtx* /*p_dctx*/, const XP_Rect* /*rect*/ ) -{ -} - -static void -sym_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, - /* at least 1 of these two will be null*/ - const XP_UCHAR* text, XP_Bitmap bitmap, - XP_S16 val, XP_Bool highlighted ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - XP_U16 index = SC(XP_U16,COLOR_PLAYER1 + sctx->iTrayOwner); - - TRect lRect; - symLocalRect( &lRect, rect ); - symClearRect( sctx, &lRect, COLOR_WHITE ); - - lRect.Shrink( 1, 1 ); - lRect.SetHeight( lRect.Height() - TRAY_CURSOR_HT ); - - sctx->iGC->SetPenColor( sctx->colors[index] ); - sctx->iGC->SetPenStyle( CGraphicsContext::ESolidPen ); - sctx->iGC->SetBrushColor( sctx->colors[COLOR_TILE] ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - sctx->iGC->DrawRect( lRect ); - - lRect.Shrink( 1, 1 ); - if ( highlighted ) { - sctx->iGC->DrawRect( lRect ); - } - - lRect.Shrink( 2, 2 ); - - // now put the text in the thing - if ( !!bitmap ) { - drawBitmap( sctx, (CFbsBitmap*)bitmap, (CFbsBitmap*)bitmap, &lRect ); - } else if ( !!text ) { - CONST_60 CFont* font = sctx->iTileFaceFont; - - TBuf16<4> txtbuf; - txtbuf.Copy( TBuf8<4>(text) ); - TInt ht = font->AscentInPixels(); - TPoint point( lRect.iTl.iX, lRect.iTl.iY + ht ); - - sctx->iGC->UseFont( font ); - sctx->iGC->DrawText( txtbuf, point ); - sctx->iGC->DiscardFont(); - } - - if ( val >= 0 ) { - CONST_60 CFont* font = sctx->iTileValueFont; - - TBuf16<5> txtbuf; - txtbuf.Num( val ); - TInt width = font->TextWidthInPixels( txtbuf ); - TPoint point( lRect.iBr.iX - width, lRect.iBr.iY ); - - sctx->iGC->UseFont( font ); - sctx->iGC->DrawText( txtbuf, point ); - sctx->iGC->DiscardFont(); - } -} // sym_draw_drawTile - -static void -sym_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect ) -{ - sym_draw_drawTile( p_dctx, rect, (XP_UCHAR*)"?", NULL, -1, XP_FALSE ); -} - -static void -sym_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect, - XP_Bool /*selected*/ ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TRect lRect; - symLocalRect( &lRect, rect ); - symClearRect( sctx, &lRect, COLOR_WHITE ); - - lRect.Shrink( 1, 1 ); - lRect.SetHeight( lRect.Height() - TRAY_CURSOR_HT ); - - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - sctx->iGC->SetBrushColor( sctx->colors[COLOR_PLAYER1 + sctx->iTrayOwner] ); - - sctx->iGC->DrawRect( lRect ); -} - -static void -sym_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rect ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TRect lRect; - symLocalRect( &lRect, rect ); - symClearRect( sctx, &lRect, COLOR_WHITE ); -} - -static void -sym_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rect, - XWBonusType bonus, XP_Bool vert, - HintAtts /*hintAtts*/ ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - - TRect lRect; - symLocalRect( &lRect, rect ); - - TRgb rgb; - getBonusColor( sctx, bonus, &rgb ); - sctx->iGC->SetBrushColor( rgb ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - - CFbsBitmap* arrow = vert? sctx->iDownArrow : sctx->iRightArrow; - drawBitmap( sctx, arrow, arrow, &lRect ); -} /* sym_draw_drawBoardArrow */ - -#ifdef KEY_SUPPORT -static void -sym_draw_drawTrayCursor( DrawCtx* p_dctx, const XP_Rect* rect ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TRect lRect; - symLocalRect( &lRect, rect ); - lRect.iTl.iY += lRect.Height() - TRAY_CURSOR_HT; - symClearRect( sctx, &lRect, COLOR_WHITE ); - - sctx->iGC->SetBrushColor( sctx->colors[COLOR_CURSOR] ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ESolidBrush ); - sctx->iGC->SetPenStyle( CGraphicsContext::ENullPen ); - sctx->iGC->DrawRect( lRect ); -} - -static void -sym_draw_drawBoardCursor( DrawCtx* p_dctx, const XP_Rect* rect ) -{ - SymDrawCtxt* sctx = (SymDrawCtxt*)p_dctx; - TRect lRect; - symLocalRect( &lRect, rect ); - - - sctx->iGC->SetPenColor( sctx->colors[COLOR_CURSOR] ); - sctx->iGC->SetPenStyle( CGraphicsContext::ESolidPen ); - sctx->iGC->SetBrushStyle( CGraphicsContext::ENullBrush ); - TInt i; - for ( i = 0; i <= 1; ++i ) { - sctx->iGC->DrawRect( lRect ); - lRect.Shrink( 1, 1 ); - } -} -#endif - -static XP_UCHAR* -sym_draw_getMiniWText( DrawCtx* /*p_dctx*/, - XWMiniTextType /*textHint*/ ) -{ - return (XP_UCHAR*)""; -} - -static void -sym_draw_measureMiniWText( DrawCtx* /*p_dctx*/, const XP_UCHAR* /*textP*/, - XP_U16* /*width*/, XP_U16* /*height*/ ) -{ -} - -static void -sym_draw_drawMiniWindow( DrawCtx* /*p_dctx*/, const XP_UCHAR* /*text*/, - const XP_Rect* /*rect*/, void** /*closure*/ ) -{ -} - -static void -sym_draw_eraseMiniWindow( DrawCtx* /*p_dctx*/, const XP_Rect* /*rect*/, - XP_Bool /*lastTime*/, void** /*closure*/, - XP_Bool* /*invalUnder*/ ) -{ -} - -static void -figureFonts( SymDrawCtxt* sctx ) -{ - /* Look at FontUtils class for info on fonts. */ -#if defined SERIES_80 - XP_LOGF( "figureFonts" ); - TBuf<128> fontName; - CWsScreenDevice* sdev = sctx->iCoeEnv->ScreenDevice(); - TInt nTypes = sdev->NumTypefaces(); - XP_LOGF( "count = %d", nTypes ); - - TTypefaceSupport tfSupport; - TInt smallIndex = -1; - TInt smallSize = 0x7FFF; - - for ( TInt i = 0; i < nTypes; ++i ) { - sdev->TypefaceSupport( tfSupport, i ); - if ( -#ifdef SYM_ARMI - tfSupport.iIsScalable && -#endif - tfSupport.iMinHeightInTwips < smallSize ) { - smallIndex = i; - smallSize = tfSupport.iMinHeightInTwips; - } - } - - // Now use the smallest guy - if ( smallIndex != -1 ) { - sdev->TypefaceSupport( tfSupport, smallIndex ); - fontName = tfSupport.iTypeface.iName.Des(); - - TFontSpec fontSpecBoard( fontName, scaleBoardV ); - sdev->GetNearestFontInPixels( sctx->iBoardFont, fontSpecBoard ); - - TInt tileHt = scaleTrayV - TRAY_CURSOR_HT; - TFontSpec fontSpecTray( fontName, tileHt * 3 / 4 ); - sdev->GetNearestFontInPixels( sctx->iTileFaceFont, fontSpecTray ); - - TFontSpec fontSpecVal( fontName, tileHt / 3 ); - sdev->GetNearestFontInPixels( sctx->iTileValueFont, fontSpecVal ); - - TFontSpec fontSpecScore( fontName, scaleBoardV ); - sdev->GetNearestFontInPixels( sctx->iScoreFont, fontSpecScore ); - - } else { - sctx->iTileFaceFont = (CFont*)sctx->iCoeEnv->NormalFont(); - sctx->iTileValueFont = sctx->iTileFaceFont; - sctx->iBoardFont = sctx->iTileFaceFont; - sctx->iScoreFont = sctx->iTileFaceFont; - sctx->iAllFontsSame = XP_TRUE; - } - -#elif defined SERIES_60 - CCoeEnv* ce = sctx->iCoeEnv; - sctx->iTileFaceFont = ce->NormalFont(); - sctx->iTileValueFont = sctx->iiEikonEnv->DenseFont(); - sctx->iBoardFont = sctx->iiEikonEnv->LegendFont(); - sctx->iScoreFont = sctx->iiEikonEnv->TitleFont(); -#endif - - XP_LOGF( "figureFonts done" ); -} // figureFonts - -DrawCtx* -sym_drawctxt_make( MPFORMAL CWindowGc* aGC, CCoeEnv* aCoeEnv, - CEikonEnv* aEikonEnv, CEikApplication* aApp ) -{ - XP_LOGF( "in sym_drawctxt_make" ); - SymDrawCtxt* sctx = (SymDrawCtxt*)XP_MALLOC( mpool, sizeof( *sctx ) ); - - XP_ASSERT( aGC != NULL ); - - if ( sctx != NULL ) { - XP_MEMSET( sctx, 0, sizeof( *sctx ) ); - MPASSIGN( sctx->mpool, mpool ); - sctx->iGC = aGC; - sctx->iCoeEnv = aCoeEnv; - sctx->iiEikonEnv = aEikonEnv; - - sctx->vtable = (DrawCtxVTable*)XP_MALLOC( mpool, sizeof(*sctx->vtable) ); - if ( sctx->vtable != NULL ) { - - SET_VTABLE_ENTRY( sctx->vtable, draw_destroyCtxt, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_boardBegin, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_boardFinished, sym ); -#ifdef DEBUG - /* Shouldn't get called as thing stand now */ - SET_VTABLE_ENTRY( sctx->vtable, draw_vertScrollBoard, sym ); -#endif - SET_VTABLE_ENTRY( sctx->vtable, draw_trayBegin, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_trayFinished, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_measureRemText, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawRemText, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_scoreBegin, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_measureScoreText, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_score_drawPlayer, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_score_pendingScore, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_scoreFinished, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawTimer, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawCell, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_invertCell, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawTile, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawTileBack, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawTrayDivider, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_clearRect, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawBoardArrow, sym ); -#ifdef KEY_SUPPORT - SET_VTABLE_ENTRY( sctx->vtable, draw_drawTrayCursor, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawBoardCursor, sym ); -#endif - SET_VTABLE_ENTRY( sctx->vtable, draw_getMiniWText, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_measureMiniWText, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_drawMiniWindow, sym ); - SET_VTABLE_ENTRY( sctx->vtable, draw_eraseMiniWindow, sym ); - - sctx->colors[COLOR_BLACK] = KRgbBlack; - sctx->colors[COLOR_WHITE] = KRgbWhite; - sctx->colors[COLOR_CURSOR] = TRgb(0x0000FF); - sctx->colors[COLOR_TILE] = TRgb(0x80ffff); // light yellow - //sctx->colors[COLOR_TILE] = KRgbYellow; - - sctx->colors[COLOR_PLAYER1] = KRgbBlack; - sctx->colors[COLOR_PLAYER2] = KRgbDarkRed; - sctx->colors[COLOR_PLAYER4] = KRgbDarkBlue; - sctx->colors[COLOR_PLAYER3] = KRgbDarkGreen; - - sctx->colors[COLOR_DBL_LTTR] = KRgbYellow; - sctx->colors[COLOR_DBL_WORD] = KRgbBlue; - sctx->colors[COLOR_TRPL_LTTR] = KRgbMagenta; - sctx->colors[COLOR_TRPL_WORD] = KRgbCyan; - - figureFonts( sctx ); - - TFileName bitmapFile = aApp->BitmapStoreName(); - - XP_LOGF( "loading bitmaps0" ); - sctx->iDownArrow = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iDownArrow-> - Load(bitmapFile, - BMNAME(EMbmXwords,Downarrow_80) ) ); - sctx->iRightArrow = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iRightArrow-> - Load(bitmapFile, - BMNAME(EMbmXwords,Rightarrow_80) ) ); - sctx->iStar = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iStar-> - Load(bitmapFile, - BMNAME(EMbmXwords,Star_80) ) ); - - sctx->iTurnIcon = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iTurnIcon-> - Load(bitmapFile, - BMNAME(EMbmXwords,Turnicon_80) ) ); - sctx->iTurnIconMask = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iTurnIconMask-> - Load(bitmapFile, - BMNAME(EMbmXwords,Turniconmask_80) ) ); - - sctx->iRobotIcon = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iRobotIcon-> - Load(bitmapFile, - BMNAME(EMbmXwords,Robot_80) ) ); - sctx->iRobotIconMask = new (ELeave) CFbsBitmap(); - User::LeaveIfError( sctx->iRobotIconMask-> - Load(bitmapFile, - BMNAME(EMbmXwords,Robotmask_80) ) ); - - XP_LOGF( "done loading bitmaps" ); - } else { - XP_FREE( mpool, sctx ); - sctx = NULL; - } - } - - XP_LOGF( "leaving sym_drawctxt_make" ); - - return (DrawCtx*)sctx; -} diff --git a/xwords4/symbian/src/symgamdl.cpp b/xwords4/symbian/src/symgamdl.cpp deleted file mode 100644 index f17301057..000000000 --- a/xwords4/symbian/src/symgamdl.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#if defined SERIES_60 -# include "xwords_60.rsg" -#elif defined SERIES_80 -# include -# include "xwords_80.rsg" -#endif - -#include "symgamdl.h" -#include "symutil.h" -#include "xwords.hrh" - -/*************************************************************************** - * TGameInfoBuf - ***************************************************************************/ -TGameInfoBuf::TGameInfoBuf( const CurGameInfo* aGi, -#ifndef XWFEATURE_STANDALONE_ONLY - const CommsAddrRec* aCommsAddr, -#endif - CDesC16ArrayFlat* aDictList ) - : iDictList(aDictList), - iDictIndex(0) -{ - TInt i; - - for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) { - iIsRobot[i] = aGi->players[i].isRobot; - iIsLocal[i] = aGi->players[i].isLocal; - if ( aGi->players[i].name != NULL ) { - XP_LOGF( "name[%d] = %s", i, aGi->players[i].name ); - TBuf8<32> tmp( aGi->players[i].name ); - iPlayerNames[i].Copy( tmp ); - } else { - iPlayerNames[i].Copy( _L("") ); - } - } - iNPlayers = aGi->nPlayers; - - if ( aGi->dictName != NULL ) { - TBuf8<32> tmp( aGi->dictName ); - TBuf16<32> dictName; - dictName.Copy( tmp ); - (void)iDictList->Find( dictName, iDictIndex ); /*iDictIndex ref passed*/ - } - -#ifndef XWFEATURE_STANDALONE_ONLY - iServerRole = aGi->serverRole; - iCommsAddr = *aCommsAddr; -#endif -} /* TGameInfoBuf::TGameInfoBuf */ - -void -TGameInfoBuf::CopyToL( MPFORMAL CurGameInfo* aGi -#ifndef XWFEATURE_STANDALONE_ONLY - , CommsAddrRec* aCommsAddr -#endif - ) -{ - TInt i; - for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) { - aGi->players[i].isRobot = iIsRobot[i]; - aGi->players[i].isLocal = iIsLocal[i]; - - symReplaceStrIfDiff( MPPARM(mpool) &aGi->players[i].name, - iPlayerNames[i] ); - } - - aGi->nPlayers = SC( XP_U8, iNPlayers ); - - TPtrC16 dictName = (*iDictList)[iDictIndex]; - symReplaceStrIfDiff( MPPARM(mpool) &aGi->dictName, dictName ); - -#ifndef XWFEATURE_STANDALONE_ONLY - aGi->serverRole = iServerRole; - *aCommsAddr = iCommsAddr; -#endif -} - -/*************************************************************************** - * CXWGameInfoDlg - ***************************************************************************/ -CXWGameInfoDlg::CXWGameInfoDlg( MPFORMAL TGameInfoBuf* aGib, TBool aNewGame ) - : iIsNewGame(aNewGame), iGib(aGib) -{ -/* XP_LOGF( "CXWGameInfoDlg::CXWGameInfoDlg" ); */ - MPASSIGN( this->mpool, mpool ); -} - -CXWGameInfoDlg::~CXWGameInfoDlg() -{ -/* XP_LOGF( "CXWGameInfoDlg::~CXWGameInfoDlg" ); */ -} - -void -CXWGameInfoDlg::PreLayoutDynInitL() -{ -/* XP_LOGF( "CXWGameInfoDlg::PreLayoutDynInitL" ); */ -#if defined SERIES_80 - - /* This likely belongs in its own method */ -#ifndef XWFEATURE_STANDALONE_ONLY - const TInt deps[] = { - EConnectionRole - }; - TInt i; - for ( i = 0; i < sizeof(deps)/sizeof(deps[0]); ++i ) { - HandleControlStateChangeL( deps[i] ); - } -#endif - - CEikChoiceList* list; - list = static_cast(Control(ENPlayersList)); - XP_ASSERT( list != NULL ); - list->SetCurrentItem( iGib->iNPlayers - 1 ); - - list = static_cast(Control(ENPlayersWhichList)); - XP_ASSERT( list != NULL ); - list->SetArrayExternalOwnership( EFalse ); - list->SetArrayL( MakeNumListL( 1, iGib->iNPlayers ) ); - - list = static_cast(Control(ESelDictChoice)); - XP_ASSERT( list != NULL ); - list->SetArrayL( iGib->iDictList ); - list->SetCurrentItem( iGib->iDictIndex ); - - iCurPlayerShown = 0; - LoadPlayerInfo( iCurPlayerShown ); - -#ifndef XWFEATURE_STANDALONE_ONLY - list = static_cast(Control(EConnectionRole)); - XP_ASSERT( list != NULL ); - TInt sel = (TInt)iGib->iServerRole; - list->SetCurrentItem( sel ); - list->DrawDeferred(); - - list = static_cast(Control(EConnectionType)); - XP_ASSERT( list != NULL ); - sel = (TInt)(iGib->iCommsAddr.conType) - 2; /* first 2 unused */ - XP_ASSERT( sel >= 0 ); - list->SetCurrentItem( sel ); - list->DrawDeferred(); - - CEikEdwin* edwin = static_cast(Control(ECookie)); - TBuf16 cookieBuf; - cookieBuf.Copy( TBuf8 - (iGib->iCommsAddr.u.ip_relay.cookie) ); - edwin->SetTextL( &cookieBuf ); - edwin->DrawDeferred(); - - edwin = static_cast(Control(ERelayName)); - TBuf16 nameBuf; - nameBuf.Copy( TBuf8 - (iGib->iCommsAddr.u.ip_relay.hostName) ); - edwin->SetTextL( &nameBuf ); - edwin->DrawDeferred(); - - TInt num = iGib->iCommsAddr.u.ip_relay.port; - CEikNumberEditor* hostPort - = static_cast(Control(ERelayPort)); - hostPort->SetNumber( num ); - hostPort->DrawDeferred(); - - HideAndShow(); -#endif -#endif -} /* PreLayoutDynInitL */ - -void -CXWGameInfoDlg::HideAndShow() -{ -/* XP_LOGF( "HideAndShow" ); */ -#if defined SERIES_80 - /* if it's standalone, hide all else. Then if it's not IP, hide all - below. */ - -#ifndef XWFEATURE_STANDALONE_ONLY - CEikChoiceList* list; - TBool showConnect; - list = static_cast(Control(EConnectionRole)); - XP_ASSERT( list != NULL ); - showConnect = list->CurrentItem() != 0; - - TBool showIP = showConnect; - if ( showIP ) { - list = static_cast(Control(EConnectionType)); - XP_ASSERT( list != NULL ); - showIP = list->CurrentItem() == 0; - } - - MakeLineVisible( EConnectionType, showConnect ); - MakeLineVisible( ECookie, showIP ); - MakeLineVisible( ERelayName, showIP ); - MakeLineVisible( ERelayPort, showIP ); -#endif -#endif -} /* HideAndShow */ - -void -CXWGameInfoDlg::HandleControlStateChangeL( TInt aControlId ) -{ -/* XP_LOGF( "HandleControlStateChangeL got %d", aControlId ); */ -#if defined SERIES_80 - CEikChoiceList* list; - CEikChoiceList* whichList; - TInt item; - TBool show; - - switch ( aControlId ) { -#ifndef XWFEATURE_STANDALONE_ONLY - case EConnectionRole: - case EConnectionType: - HideAndShow(); - break; -#endif - case ENPlayersList: - /* The ENPlayersWhichList must match the number of players available, - and we need to display a different player if we're currently - showing one who no longer exists. */ - list = static_cast - (Control( ENPlayersList )); - item = list->CurrentItem(); - - whichList = static_cast - (Control( ENPlayersWhichList )); - whichList->SetArrayL( MakeNumListL( 1, item + 1 ) ); - - if ( item < iCurPlayerShown ) { - /* HandleControlStateChangeL seems not to get called for this - change. But the DrawDeferred()s below make it ok */ - whichList->SetCurrentItem( item ); - SetPlayerShown( item ); - } else { - whichList->SetCurrentItem( iCurPlayerShown ); - } - whichList->DrawDeferred(); - - break; - - case ENPlayersWhichList: - list = static_cast - (Control( ENPlayersWhichList )); - SetPlayerShown( list->CurrentItem() ); - HandleControlStateChangeL( EPlayerLocationChoice ); - break; - - case EPlayerLocationChoice: - list = static_cast - (Control(EPlayerLocationChoice )); - show = list->CurrentItem() == 0; - - MakeLineVisible( EPlayerName, show ); - MakeLineVisible( EPlayerSpeciesChoice, show ); - MakeLineVisible( EDecryptPassword, show ); - break; - - default: - break; - } -#endif -} - -TBool -CXWGameInfoDlg::OkToExitL( TInt /*aKeyCode*/ ) -{ -#if defined SERIES_80 - CEikChoiceList* list; - - /* Dictionary */ - list = static_cast(Control(ESelDictChoice)); - iGib->iDictIndex = list->CurrentItem(); - - /* Player data (all but displayed already saved) */ - SavePlayerInfo( iCurPlayerShown ); - - /* number of players */ - list = static_cast(Control(ENPlayersList)); - iGib->iNPlayers = list->CurrentItem() + 1; -#endif - -#ifndef XWFEATURE_STANDALONE_ONLY - list = static_cast(Control(EConnectionRole)); - TInt sel = list->CurrentItem(); - iGib->iServerRole = (Connectedness)sel; - - if ( iGib->iServerRole != SERVER_STANDALONE ) { - - list = static_cast(Control(EConnectionType)); - iGib->iCommsAddr.conType = SC(CommsConnType, list->CurrentItem() + 2 ); - - if ( iGib->iCommsAddr.conType == COMMS_CONN_RELAY ) { - /* cookie */ - CEikEdwin* edwin = static_cast(Control(ECookie)); - TBuf16 cookieBuf; - edwin->GetText( cookieBuf ); - TBuf8 buf8cookie; - buf8cookie.Copy( cookieBuf ); - TInt len = buf8cookie.Length(); - XP_MEMCPY( iGib->iCommsAddr.u.ip_relay.cookie, - (void*)buf8cookie.Ptr(), len ); - iGib->iCommsAddr.u.ip_relay.cookie[len] = '\0'; - - /* hostname */ - edwin = static_cast(Control(ERelayName)); - TBuf16 nameBuf; - edwin->GetText( nameBuf ); - TBuf8 buf8; - buf8.Copy( nameBuf ); - len = buf8.Length(); - XP_MEMCPY( iGib->iCommsAddr.u.ip_relay.hostName, - (void*)buf8.Ptr(), len ); - iGib->iCommsAddr.u.ip_relay.hostName[len] = '\0'; - - /* port */ - CEikNumberEditor* hostPort - = static_cast(Control(ERelayPort)); - iGib->iCommsAddr.u.ip_relay.port = SC( XP_U16, hostPort->Number() ); - } - } -#endif - return ETrue; -} /* OkToExitL */ - -void -CXWGameInfoDlg::LoadPlayerInfo( TInt aWhich ) -{ - /* location */ -#ifndef XWFEATURE_STANDALONE_ONLY -#endif - - /* name */ - XP_LOGF( "setting name" ); - CEikEdwin* nameEditor = static_cast(Control(EPlayerName)); - nameEditor->SetTextL( &iGib->iPlayerNames[aWhich] ); - nameEditor->DrawDeferred(); - - XP_LOGF( "done setting name" ); - -#if defined SERIES_80 - /* species */ - CEikChoiceList* list = static_cast - (Control(EPlayerSpeciesChoice )); - TInt oldVal = list->CurrentItem(); - TInt newVal = iGib->iIsRobot[aWhich]? 1:0; - if ( oldVal != newVal ) { - list->SetCurrentItem( newVal ); - list->DrawDeferred(); - } - - /* remoteness */ - list = static_cast(Control(EPlayerLocationChoice )); - oldVal = list->CurrentItem(); - newVal = iGib->iIsLocal[aWhich]? 0:1; - if ( oldVal != newVal ) { - list->SetCurrentItem( newVal ); - list->DrawDeferred(); - } -#endif - - /* password */ -} - -void -CXWGameInfoDlg::SavePlayerInfo( TInt aWhich ) -{ - - /* name */ - CEikEdwin* nameEditor = static_cast(Control(EPlayerName)); - nameEditor->GetText( iGib->iPlayerNames[aWhich] ); - - /* species */ -#if defined SERIES_80 - CEikChoiceList* list = static_cast - (Control(EPlayerSpeciesChoice )); - iGib->iIsRobot[aWhich] = (list->CurrentItem() == 1); - - list = static_cast(Control(EPlayerLocationChoice )); - iGib->iIsLocal[aWhich] = (list->CurrentItem() == 0); -#endif -} - -void -CXWGameInfoDlg::SetPlayerShown( TInt aPlayer ) -{ - if ( aPlayer != iCurPlayerShown ) { - SavePlayerInfo( iCurPlayerShown ); - LoadPlayerInfo( aPlayer ); - iCurPlayerShown = aPlayer; - } -} - -CDesC16ArrayFlat* -CXWGameInfoDlg::MakeNumListL( TInt aFirst, TInt aLast ) -{ - XP_ASSERT( aFirst <= aLast ); - - CDesC16ArrayFlat* list = new (ELeave)CDesC16ArrayFlat(aLast - aFirst + 1); - TInt i; - for ( i = aFirst; i <= aLast; ++i ) { - TBuf16<4> num; - num.Num( i ); - list->AppendL( num ); - } - - return list; -} /* MakeNumListL */ - -/* static*/ TBool -CXWGameInfoDlg::DoGameInfoDlgL( MPFORMAL TGameInfoBuf* aGib, TBool aNewGame ) -{ - XP_LOGF( "CXWGameInfoDlg::DoGameInfoDlgL called" ); - CXWGameInfoDlg* me = - new(ELeave)CXWGameInfoDlg( MPPARM(mpool) aGib, aNewGame ); - XP_LOGF( "calling ExecuteLD" ); - return me->ExecuteLD( R_XWORDS_NEWGAME_DLG ); -} diff --git a/xwords4/symbian/src/symgamed.cpp b/xwords4/symbian/src/symgamed.cpp deleted file mode 100755 index 5bf008578..000000000 --- a/xwords4/symbian/src/symgamed.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). - * - * 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. - */ - -#if defined SERIES_80 -# include -# include "xwords_80.rsg" -#elif defined SERIES_60 -# include "xwords_60.rsg" -#endif -#include "xwords.hrh" -#include "symgamed.h" - - -CNameEditDlg::CNameEditDlg( TGameName* aGameName ) - : iGameName( aGameName ) -{ -} - -TBool -CNameEditDlg::OkToExitL( TInt aKeyCode ) -{ -#ifdef SERIES_80 - CEikFileNameEditor* ed; - ed = static_cast(Control(EEditNameEdwin)); - - if ( aKeyCode != EEikBidCancel ) { - TInt len = ed->TextLength(); - XP_ASSERT( len <= iGameName->MaxLength() ); - TGameName tmp; - ed->GetText( tmp ); - iGameName->Copy( tmp ); - } -#endif - return ETrue; -} // OkToExitL - -void -CNameEditDlg::PreLayoutDynInitL() -{ -#ifdef SERIES_80 - CEikFileNameEditor* ed; - ed = static_cast(Control(EEditNameEdwin)); - ed->SetTextL( iGameName ); - ed->SetTextLimit( iGameName->MaxLength() ); -#endif -} - -/* static */ TBool -CNameEditDlg::EditName( TGameName* aGameName ) -{ - CNameEditDlg* me = new CNameEditDlg( aGameName ); - User::LeaveIfNull( me ); - - return me->ExecuteLD( R_XWORDS_EDITNAME_DLG ); -} diff --git a/xwords4/symbian/src/symgmdlg.cpp b/xwords4/symbian/src/symgmdlg.cpp deleted file mode 100755 index d4b674c7e..000000000 --- a/xwords4/symbian/src/symgmdlg.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). - * - * 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 -#include -#if defined SERIES_60 -# include "xwords_60.rsg" -#elif defined SERIES_80 -# include -# include "xwords_80.rsg" -#endif -#include - -#include "symgmdlg.h" -#include "symutil.h" -#include "symgamed.h" -#include "xwords.hrh" -#include "xwappview.h" - - -CXSavedGamesDlg::CXSavedGamesDlg( MPFORMAL CXWordsAppView* aOwner, - CXWGamesMgr* aGameMgr, - const TGameName* aCurName, - TGameName* result ) - : iOwner(aOwner), iGameMgr(aGameMgr), iCurName(aCurName), iResultP(result) -{ - MPASSIGN( this->mpool, mpool ); -} - -void -CXSavedGamesDlg::PreLayoutDynInitL() -{ - ResetNames( -1, iCurName ); -} - -TBool -CXSavedGamesDlg::OkToExitL( TInt aKeyCode ) -{ -#if defined SERIES_60 - return ETrue; -#elif defined SERIES_80 - TBool canReturn = EFalse; - CEikTextListBox* box; - const CListBoxView::CSelectionIndexArray* indices; - box = static_cast(Control(ESelGameChoice)); - TInt index = box->CurrentItemIndex(); - TDesC16 selName = (*iGameMgr->GetNames())[index]; - - XP_LOGF( "CXSavedGamesDlg::OkToExitL(%d) called", aKeyCode ); - - switch( aKeyCode ) { - case XW_SGAMES_OPEN_COMMAND: - indices = box->SelectionIndexes(); - if ( indices->Count() > 1 ) { - XP_LOGF( "too many selected" ); - } else { - /* Don't use indices: invalid when multi-select isn't on? */ - // TInt index = indices->At(0); - XP_LOGF( "the %dth is selected:", index ); - *iResultP = (*iGameMgr->GetNames())[index]; - XP_LOGDESC16( iResultP ); - canReturn = ETrue; - } - break; - - case XW_SGAMES_RENAME_COMMAND: - if ( 0 == selName.Compare(*iCurName) ) { - iOwner->UserErrorFromID( R_ALERT_NO_RENAME_OPEN_GAME ); - } else { - TGameName newName; - if ( EditSelName( static_cast(&selName), &newName ) ) { - ResetNames( -1, &newName ); - box->DrawDeferred(); - } - } - break; - - case XW_SGAMES_DELETE_COMMAND: { - XP_LOGF( "delete" ); - if ( 0 == selName.Compare(*iCurName) ) { - iOwner->UserErrorFromID( R_ALERT_NO_DELETE_OPEN_GAME ); - } else if ( iOwner->UserQuery( (UtilQueryID)SYM_QUERY_CONFIRM_DELGAME, - NULL ) ) { - if ( iGameMgr->DeleteSelected( index ) ) { - ResetNames( index, NULL ); - box->DrawDeferred(); - } - } - } - break; - case EEikBidCancel: - canReturn = ETrue; - } - - return canReturn; -#endif -} /* OkToExitL */ - -void -CXSavedGamesDlg::ResetNames( TInt aPrefIndex, - const TGameName* aSelName ) -{ - /* PENDING aPrefIndex is a hint what to select next */ -#if defined SERIES_60 -#elif defined SERIES_80 - CDesC16Array* names = iGameMgr->GetNames(); - TInt index = 0; /* make compiler happy */ - const TGameName* seekName = NULL; - - if ( aPrefIndex >= 0 ) { - index = aPrefIndex; - } else if ( aSelName != NULL ) { - seekName = aSelName; - } else { - seekName = iCurName; - } - - if ( seekName != NULL && ( 0 != names->Find( *seekName, index ) ) ) { - XP_LOGF( "Unable to find" ); - XP_LOGDESC16( seekName ); - XP_ASSERT( 0 ); - index = 0; /* safe default if not found */ - } - - CEikTextListBox* box; - box = static_cast(Control(ESelGameChoice)); - - box->Model()->SetItemTextArray( names ); - box->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); - box->HandleItemAdditionL(); - - box->SetCurrentItemIndex( index ); -#endif -} /* ResetNames */ - -TBool -CXSavedGamesDlg::EditSelName( const TGameName* aSelName, TGameName* aNewName ) -{ - aNewName->Copy( *aSelName ); - TBool renamed = EFalse; - - if ( CNameEditDlg::EditName( aNewName ) ) { - if ( iGameMgr->Exists( aNewName ) ) { - iOwner->UserErrorFromID( R_ALERT_RENAME_TARGET_EXISTS ); - } else if ( !iGameMgr->IsLegalName( aNewName ) ) { - iOwner->UserErrorFromID( R_ALERT_RENAME_TARGET_BADNAME ); - } else { - iGameMgr->Rename( aSelName, aNewName ); - renamed = ETrue; - } - } - return renamed; -} - -/* static */ TBool -CXSavedGamesDlg::DoGamesPicker( MPFORMAL CXWordsAppView* aOwner, - CXWGamesMgr* aGameMgr, - const TGameName* aCurName, TGameName* result ) -{ - CXSavedGamesDlg* me = new CXSavedGamesDlg( MPPARM(mpool) aOwner, - aGameMgr, aCurName, result ); - User::LeaveIfNull( me ); - - return me->ExecuteLD( R_XWORDS_SAVEDGAMES_DLG ); -} // DoGamesPicker diff --git a/xwords4/symbian/src/symgmmgr.cpp b/xwords4/symbian/src/symgmmgr.cpp deleted file mode 100755 index 318c3926f..000000000 --- a/xwords4/symbian/src/symgmmgr.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). - * - * 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 "symgmmgr.h" - -extern "C" { -#include "xwstream.h" -} -#include "symutil.h" - -#if defined SERIES_60 -# include -#endif -#include - -_LIT( kGameTypeExt, ".xwg" ); - - -// private -CXWGamesMgr::CXWGamesMgr( MPFORMAL CCoeEnv* aCoeEnv, TFileName* aBasePath ) - : iCoeEnv(aCoeEnv), iGameCount(0) -{ - MPASSIGN( this->mpool, mpool ); - - iDir.Copy( *aBasePath ); - iDir.Append( _L("xwgames" ) ); - iDir.Append( _L("\\" ) ); -} // CXWGamesMgr - -/* static */ CXWGamesMgr* -CXWGamesMgr::NewL( MPFORMAL CCoeEnv* aCoeEnv, TFileName* aBasePath ) -{ - CXWGamesMgr* self = new CXWGamesMgr( MPPARM(mpool) aCoeEnv, aBasePath ); - User::LeaveIfNull( self ); - - // Create the games directory if it doesn't already exist -#if defined SERIES_80 - RFs fs = aCoeEnv->FsSession(); -#elif defined SERIES_60 - RFs fs = CEikonEnv::Static()->FsSession(); -#endif - TInt err = fs.MkDirAll( self->iDir ); - - if ( err != KErrNone && err != KErrAlreadyExists ) { - XP_LOGF( "MkDir failed: %d", err ); - User::Leave( err ); - } - - err = fs.SetAtt( self->iDir, KEntryAttHidden, KEntryAttNormal ); - - self->BuildListL(); - - return self; -} // NewL - -void -CXWGamesMgr::BuildListL() -{ - delete iNamesList; - - RFs fs = iCoeEnv->FsSession(); - - CDir* file_list; - TFindFile file_finder( fs ); - TBuf16<6> gameNamePat( _L("*") ); - gameNamePat.Append( kGameTypeExt ); - TInt err = file_finder.FindWildByDir( gameNamePat, iDir, file_list ); - // Leave it empty (null) if nothing in the list. - if ( err == KErrNone ) { - CleanupStack::PushL( file_list ); - - TInt gameCount = file_list->Count(); - iNamesList = new (ELeave)CDesC16ArrayFlat( gameCount ); - - TInt i; - for ( i = 0; i < file_list->Count(); i++ ) { - TParse fullentry; - fullentry.Set( (*file_list)[i].iName, &file_finder.File(), NULL ); - iNamesList->AppendL( fullentry.Name() ); - } - CleanupStack::PopAndDestroy(file_list); // file_list - } -} // BuildListL - -TInt -CXWGamesMgr::GetNGames() const -{ - if ( !iNamesList ) { - return 0; - } else { - return iNamesList->MdcaCount(); - } -} // GetNGames - -CDesC16Array* -CXWGamesMgr::GetNames() const -{ - return iNamesList; -} // GetNames - -TBool -CXWGamesMgr::Exists( TGameName* aName ) -{ - RFs fs = iCoeEnv->FsSession(); - - TFileName nameD; - GameNameToPath( &nameD, aName ); - - TUint attValue; - TInt err = fs.Att( nameD, attValue ); - XP_LOGF( "fs.Att(%S) => %d", aName, err ); - return err == KErrNone; -} - -TBool -CXWGamesMgr::IsLegalName( const TGameName* aName ) -{ - RFs fs = iCoeEnv->FsSession(); - return fs.IsValidName( *aName ); -} /* IsLegalName */ - -void -CXWGamesMgr::GameNameToPath( TFileName* aPath, const TDesC16* aName ) -{ - aPath->Copy( iDir ); - aPath->Append( *aName ); - aPath->Append( kGameTypeExt ); -} - -void -CXWGamesMgr::MakeDefaultName( TGameName* aName ) -{ - RFs fs = iCoeEnv->FsSession(); - TFileName nameD; - TGameName tmpName( _L("game") ); - GameNameToPath( &nameD, &tmpName ); - - TInt err = CApaApplication::GenerateFileName( fs, nameD ); - User::LeaveIfError( err ); - - TParse nameParser; - nameParser.Set( nameD, NULL, NULL ); - - aName->Copy( nameParser.Name() ); -} // MakeDefaultName - -void -CXWGamesMgr::StoreGameL( const TGameName* aName, /* does not have extension */ - XWStreamCtxt* aStream ) -{ - RFs fs = iCoeEnv->FsSession(); - - // write the stream to a file - TFileName nameD; - GameNameToPath( &nameD, aName ); - RFile file; - TInt err = file.Replace( fs, nameD, EFileWrite ); - XP_ASSERT( err == KErrNone ); - User::LeaveIfError( err ); - CleanupClosePushL(file); - - TInt siz = stream_getSize( aStream ); - TUint8* buf = new (ELeave) TUint8[siz]; - stream_getBytes( aStream, buf, SC(XP_U16, siz) ); - TPtrC8 tbuf( buf, siz ); - err = file.Write( tbuf, siz ); - XP_ASSERT( err == KErrNone ); - delete [] buf; - - CleanupStack::PopAndDestroy( &file ); // file - - BuildListL(); -} // StoreGameL - -void -CXWGamesMgr::LoadGameL( const TGameName* aName, XWStreamCtxt* aStream ) -{ - RFs fs = iCoeEnv->FsSession(); - - TFileName nameD; - GameNameToPath( &nameD, aName ); - - RFile file; - TInt err = file.Open( fs, nameD, EFileRead ); - if ( err != KErrNone ) { - XP_LOGF( "file.Open() => %d", err ); - } - User::LeaveIfError( err ); - CleanupClosePushL(file); - - for ( ; ; ) { - TBuf8<256> buf; - file.Read( buf, buf.MaxLength() ); - TInt nRead = buf.Size(); - if ( nRead <= 0 ) { - break; - } - stream_putBytes( aStream, (void*)buf.Ptr(), SC(XP_U16, nRead) ); - } - - CleanupStack::PopAndDestroy( &file ); -} // LoadGame - -TBool -CXWGamesMgr::DeleteSelected( TInt aIndex ) -{ - TPtrC16 name = (*iNamesList)[aIndex]; - return DeleteFileFor( &name ); -} /* DeleteSelected */ - -TBool -CXWGamesMgr::DeleteFileFor( TPtrC16* aName ) -{ - TFileName nameD; - GameNameToPath( &nameD, aName ); - - RFs fs = iCoeEnv->FsSession(); - TInt err = fs.Delete( nameD ); - TBool success = err == KErrNone; - if ( success ) { - BuildListL(); - } - return success; -} - -void -CXWGamesMgr::Rename( const TDesC16* aCurName, const TDesC16* aNewName ) -{ - TFileName newName; - GameNameToPath( &newName, aNewName ); - - TFileName anOldName; - GameNameToPath( &anOldName, aCurName ); - - RFs fs = iCoeEnv->FsSession(); - TInt err = fs.Rename( anOldName, newName ); - XP_ASSERT( err == KErrNone ); - User::LeaveIfError( err ); - - BuildListL(); -} /* Rename */ diff --git a/xwords4/symbian/src/symrsock.cpp b/xwords4/symbian/src/symrsock.cpp deleted file mode 100644 index 7cd459bdc..000000000 --- a/xwords4/symbian/src/symrsock.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 XWFEATURE_STANDALONE_ONLY - -#include "symrsock.h" - -/*static*/ CReadSocket* -CReadSocket::NewL( ReadNotifyCallback aCallback, void* aCallbackClosure ) -{ - CReadSocket* self = new (ELeave) CReadSocket( aCallback, aCallbackClosure ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; -} - -CReadSocket::CReadSocket( ReadNotifyCallback aGotData, void* aCallbackClosure ) - : iGotData(aGotData) - , iCallbackClosure(aCallbackClosure) - , iReadState(ENotReading) - , iPort(0) - , CActive(EPriorityStandard) -{ - iInBuf.SetLength(0); -} - -CReadSocket::~CReadSocket() -{ - Cancel(); - iSocketServer.Close(); -} - -void -CReadSocket::ConstructL() -{ - CActiveScheduler::Add( this ); - TInt err = iSocketServer.Connect(); - XP_LOGF( "iSocketServer.Connect => %d", err ); - - err = iListenSocket.Open( iSocketServer, KAfInet, - KSockDatagram, KProtocolInetUdp ); - XP_LOGF( "iListenSocket.Open => %d", err ); - - if ( iPort != 0 ) { - Bind(); - } -} - -void -CReadSocket::Bind() -{ - XP_ASSERT( iPort != 0 ); - TSockAddr iSockAddress( KProtocolInetUdp ); - iSockAddress.SetPort( iPort ); - - TInt err = iListenSocket.Bind( iSockAddress ); - XP_LOGF( "iListenSocket.Bind => %d", err ); -} /* Bind */ - -void -CReadSocket::SetListenPort( TInt aPort ) -{ - XP_LOGF( "SetListenPort(%d)", aPort ); - if ( aPort != iPort ) { - TBool wasActive = iReadState == EReading && IsActive(); - if ( wasActive ) { - Cancel(); /* stop anything ongoing */ - } - iPort = aPort; - Bind(); - if ( wasActive ) { - RequestRecv(); - } - } -} /* SetListenPort */ - -void -CReadSocket::RequestRecv() -{ - XP_ASSERT( !IsActive() ); - - XP_LOGF( "calling iListenSocket.RecvFrom" ); - iListenSocket.RecvFrom( iInBuf, iRecvAddr, 0, iStatus ); - - iReadState = EReading; - SetActive(); -} /* RequestRead */ - -void -CReadSocket::RunL() -{ - XP_ASSERT( iStatus.Int() == KErrNone ); - XP_ASSERT( iReadState == EReading ); - if ( iStatus.Int() == KErrNone ) { - XP_LOGF( "SUCCESS: packet received!" ); - (*iGotData)( &iInBuf, iCallbackClosure ); - iInBuf.SetLength(0); - } - iReadState = ENotReading; - - RequestRecv(); /* We just keep listening... */ -} /* RunL */ - -void -CReadSocket::DoCancel() -{ - if ( iReadState == EReading ) { - iListenSocket.CancelRecv(); - } -} - -void -CReadSocket::Start() -{ - if ( !IsActive() ) { - RequestRecv(); - } -} - -void -CReadSocket::Stop() -{ - Cancel(); -} - -#endif diff --git a/xwords4/symbian/src/symssock.cpp b/xwords4/symbian/src/symssock.cpp deleted file mode 100644 index 6f1dd1429..000000000 --- a/xwords4/symbian/src/symssock.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 XWFEATURE_STANDALONE_ONLY - -#include "symssock.h" -#include "symutil.h" - -void -CSendSocket::RunL() -{ - XP_LOGF( "CSendSocket::RunL called; iStatus=%d", iStatus.Int() ); -/* iSendTimer.Cancel(); */ - - TBool statusGood = iStatus.Int() == KErrNone; - switch ( iSSockState ) { - case ELookingUp: - iResolver.Close(); /* we probably won't need this again */ - if ( statusGood ) { - iNameRecord = iNameEntry(); - XP_LOGF( "name resolved" ); - ConnectL( TInetAddr::Cast(iNameRecord.iAddr).Address() ); - } else { - ResetState(); - } - break; - case EConnecting: - if ( statusGood ) { - iSSockState = EConnected; - XP_LOGF( "connect successful" ); - if ( iSendBuf.Length() > 0 ) { - DoActualSend(); - } else if ( iListenPending ) { - Listen(); - } - } else { - ResetState(); - } - break; - case ESending: - if ( statusGood ) { - XP_LOGF( "send successful" ); - } else { - /* Depending on error, might need to close socket, reconnect, etc. - For now we'll just trust the upper layers to figure out they - didn't get through, or user to resend. */ - XP_LOGF( "send failed with error %d", iStatus.Int() ); - } - - iSSockState = EConnected; - iSendBuf.SetLength(0); - - if ( iListenPending ) { - Listen(); - } - break; - - case EListening: - if ( statusGood ) { - if ( iDataLen == 0 ) { - /* Do nothing; we need to read again via Listen call */ - iDataLen = XP_NTOHS( *(XP_U16*)iInBufDesc->Ptr() ); - XP_LOGF( "Recv succeeded with length; now looking for %d byte" - "packet", iDataLen ); - } else { - iDataLen = 0; - XP_LOGF( "Got packet! Calling callback" ); - (*iCallback)( iInBufDesc, iClosure ); - } - iSSockState = EConnected; - Listen(); /* go back to listening */ - } else { - XP_LOGF( "listen failed with error %d", iStatus.Int() ); - ResetState(); - } - } -} /* RunL */ - -void -CSendSocket::ResetState() -{ - iSendBuf.SetLength(0); - iSSockState = ENotConnected; -} - -TBool -CSendSocket::Listen() -{ - XP_LOGF( "CSendSocket::Listen" ); - iListenPending = ETrue; - - if ( IsActive() ) { - /* since iListenPending is set, we'll eventually get to listening once - all the RunL()s get called. Do nothing. */ - } else { - if ( iSSockState == ENotConnected ) { - ConnectL(); - } else if ( iSSockState == EConnected ) { - delete iInBufDesc; - - TInt seekLen = iDataLen == 0? 2: iDataLen; - iInBufDesc = new TPtr8( iInBuf, seekLen ); - XP_LOGF( "calling iSendSocket.Recv; looking for %d bytes", - iInBufDesc->MaxSize() ); - iSendSocket.Recv( *iInBufDesc, 0, iStatus ); - - SetActive(); - iSSockState = EListening; - iListenPending = EFalse; - } else { - XP_LOGF( "iSSockState=%d", iSSockState ); - XP_ASSERT( 0 ); - } - } - return ETrue; -} /* Listen */ - -TBool -CSendSocket::CancelListen() -{ - TBool result = iSSockState == EListening; - if ( result ) { - XP_ASSERT( IsActive() ); - Cancel(); - } - return result; -} /* CancelListen */ - -void -CSendSocket::DoCancel() -{ - if ( iSSockState == ESending ) { - iSendSocket.CancelWrite(); - iSSockState = EConnected; - } else if ( iSSockState == EConnecting ) { - iSendSocket.CancelConnect(); - iSSockState = ENotConnected; - } else if ( iSSockState == ELookingUp ) { - iResolver.Cancel(); - iResolver.Close(); - } else if ( iSSockState == EListening ) { - iSendSocket.CancelRecv(); - } -} /* DoCancel */ - -CSendSocket::CSendSocket( ReadNotifyCallback aCallback, - void* aClosure ) - : CActive(EPriorityStandard) - ,iSSockState(ENotConnected) - ,iAddrSet( EFalse ) - ,iCallback(aCallback) - ,iClosure(aClosure) - ,iListenPending(EFalse) - ,iInBufDesc( NULL ) - ,iDataLen( 0 ) -{ -} - -CSendSocket::~CSendSocket() -{ - Cancel(); - iSocketServer.Close(); -} - -void -CSendSocket::ConstructL() -{ - CActiveScheduler::Add( this ); - XP_LOGF( "calling iSocketServer.Connect()" ); - TInt err = iSocketServer.Connect( 2 ); - XP_LOGF( "Connect=>%d", err ); - User::LeaveIfError( err ); -} - -/*static*/ CSendSocket* -CSendSocket::NewL( ReadNotifyCallback aCallback, void* aClosure ) -{ - CSendSocket* me = new CSendSocket( aCallback, aClosure ); - CleanupStack::PushL( me ); - me->ConstructL(); - CleanupStack::Pop( me ); - return me; -} - -void -CSendSocket::ConnectL( TUint32 aIpAddr ) -{ - XP_LOGF( "ConnectL( 0x%x )", aIpAddr ); - - TInt err = iSendSocket.Open( iSocketServer, KAfInet, - KSockStream, KProtocolInetTcp ); - XP_LOGF( "iSocket.Open => %d", err ); - User::LeaveIfError( err ); - - // Set up address information - iAddress.SetPort( iCurAddr.u.ip_relay.port ); - iAddress.SetAddress( aIpAddr ); - - // Initiate socket connection - XP_LOGF( "calling iSendSocket.Connect" ); - iSendSocket.Connect( iAddress, iStatus ); - - SetActive(); - iSSockState = EConnecting; - - // Start a timeout - /* iSendTimer.After( iConnectTimeout ); */ - -} /* ConnectL */ - -void -CSendSocket::ConnectL() -{ - XP_LOGF( "CSendSocket::ConnectL" ); - if ( iSSockState == ENotConnected ) { - TInetAddr ipAddr; - - if ( iCurAddr.u.ip_relay.hostName && iCurAddr.u.ip_relay.hostName[0] ) { - - XP_LOGF( "connecting to %s", iCurAddr.u.ip_relay.hostName ); - - TBuf16 tbuf; - tbuf.Copy( TBuf8(iCurAddr.u.ip_relay.hostName) ); - TInt err = ipAddr.Input( tbuf ); - XP_LOGF( "ipAddr.Input => %d", err ); - - if ( err != KErrNone ) { - /* need to look it up */ - err = iResolver.Open( iSocketServer, KAfInet, KProtocolInetUdp ); - XP_LOGF( "iResolver.Open => %d", err ); - User::LeaveIfError( err ); - - iResolver.GetByName( tbuf, iNameEntry, iStatus ); - iSSockState = ELookingUp; - - SetActive(); - } else { - ConnectL( ipAddr.Address() ); - } - } else { - /* PENDING FIX THIS!!!! */ - XP_LOGF( "Can't connect: no relay name" ); - } - } -} /* ConnectL */ - -void -CSendSocket::ConnectL( const CommsAddrRec* aAddr ) -{ - /* If we're connected and the address is the same, do nothing. Otherwise - disconnect, change the address, and reconnect. */ - - TBool sameAddr = iAddrSet && - (0 == XP_MEMCMP( (void*)&iCurAddr, (void*)aAddr, sizeof(aAddr) ) ); - - if ( sameAddr && iSSockState >= EConnected ) { - /* do nothing */ - } else { - Disconnect(); - - iCurAddr = *aAddr; - iAddrSet = ETrue; - - ConnectL(); - } -} /* ConnectL */ - -void -CSendSocket::Disconnect() -{ - XP_LOGF( "CSendSocket::Disconnect" ); - Cancel(); - if ( iSSockState >= EConnected ) { - iSendSocket.Close(); - } - iSSockState = ENotConnected; -} /* Disconnect */ - -TBool -CSendSocket::SendL( const XP_U8* aBuf, XP_U16 aLen, const CommsAddrRec* aAddr ) -{ - XP_LOGF( "CSendSocket::SendL called" ); - TBool success; - - XP_ASSERT( iSSockState == EListening || !IsActive() ); - if ( iSSockState == ESending ) { - success = EFalse; - } else if ( aLen > KMaxMsgLen ) { - success = EFalse; - } else if ( iSendBuf.Length() != 0 ) { - XP_LOGF( "old buffer not sent yet" ); - success = EFalse; - } else { - /* TCP-based protocol requires 16-bits of length, in network - byte-order, followed by data. */ - XP_U16 netLen = XP_HTONS( aLen ); - iSendBuf.Append( (TUint8*)&netLen, sizeof(netLen) ); - iSendBuf.Append( aBuf, aLen ); - - if ( iSSockState == ENotConnected ) { - ConnectL( aAddr ); - } else if ( iSSockState == EConnected || iSSockState == EListening ) { - DoActualSend(); - } else { - XP_ASSERT( 0 ); /* not sure why we'd be here */ - } - success = ETrue; - } - - return success; -} /* SendL */ - -void -CSendSocket::DoActualSend() -{ - XP_LOGF( "CSendSocket::DoActualSend called" ); - - if ( CancelListen() ) { - iListenPending = ETrue; - } - - iSendSocket.Write( iSendBuf, iStatus ); // Initiate actual write - SetActive(); - - // Request timeout -/* iSendTimer.After( iWriteTimeout ); */ - iSSockState = ESending; -} - -#endif diff --git a/xwords4/symbian/src/symutil.cpp b/xwords4/symbian/src/symutil.cpp deleted file mode 100644 index c3bceb78b..000000000 --- a/xwords4/symbian/src/symutil.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. - * - * 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 -#include -#include -#include -#include -#include -#include "comtypes.h" -#include "mempool.h" - - -void -symReplaceStrIfDiff( MPFORMAL XP_UCHAR** loc, const TDesC16& desc ) -{ - TBuf8<256> tmp; - tmp.Copy( desc ); - - if ( *loc ) { - TPtrC8 forCmp; - forCmp.Set( *loc, XP_STRLEN( *loc ) ); - - if ( tmp == forCmp ) { - return; - } - - XP_FREE( mpool, *loc ); - } - - TInt len = desc.Length(); - XP_UCHAR* newStr = (XP_UCHAR*)XP_MALLOC( mpool, len + 1 ); - XP_MEMCPY( newStr, (void*)tmp.Ptr(), len ); - newStr[len] = '\0'; - *loc = newStr; -} /* symReplaceStr */ - -void -symReplaceStrIfDiff( MPFORMAL XP_UCHAR** loc, const XP_UCHAR* str ) -{ - if ( *loc != NULL ) { - if ( 0 == XP_STRCMP( *loc, str ) ) { - return; /* nothing to do */ - } - /* need to free */ - XP_FREE( mpool, *loc ); - } - - TInt len = XP_STRLEN( str ) + 1; - *loc = (XP_UCHAR*)XP_MALLOC( mpool, len ); - XP_MEMCPY( (void*)*loc, (void*)str, len ); -} /* symReplaceStrIfDiff */ - -#ifdef DEBUG -_LIT( KXWLogdir, "xwords" ); -_LIT( KXWLogfile, "xwdebug.txt" ); -/* The emulator, anyway, doesn't do descs well even with the %S directive. - So convert 'em to desc8s... */ -void -XP_LOGDESC16( const TDesC16* desc ) -{ - TBuf8<256> buf8; - buf8.Copy( *desc ); - buf8.Append( (const unsigned char*)"\0", 1 ); - TBuf8<256> fmtDesc((unsigned char*)"des16: %s"); - - RFileLogger::WriteFormat( KXWLogdir, KXWLogfile, - EFileLoggingModeAppend, - fmtDesc, buf8.Ptr() ); -} -#endif - -extern "C" { - -int -sym_snprintf( XP_UCHAR* aBuf, XP_U16 aLen, const XP_UCHAR* aFmt, ... ) -{ - __e32_va_list ap; - va_start( ap, aFmt ); - - int result = vsprintf( (char*)aBuf, (const char*)aFmt, ap ); - XP_ASSERT( XP_STRLEN(aBuf) < aLen ); // this may not work.... - va_end(ap); - return result; -} - -#ifdef DEBUG -void sym_debugf( char* aFmt, ... ) -{ - VA_LIST ap; - VA_START( ap, aFmt ); - - TBuf8<256> fmtDesc((unsigned char*)aFmt); - - RFileLogger::WriteFormat( KXWLogdir, KXWLogfile, - EFileLoggingModeAppend, - fmtDesc, ap ); - VA_END(ap); -} - -#else - -void p_ignore( char* , ...) {} - -#endif - - -void* -sym_malloc(XP_U32 nbytes ) -{ - return malloc( nbytes ); -} - -void* sym_realloc(void* p, XP_U32 nbytes) -{ - return realloc( p, nbytes ); -} - -void -sym_free( void* p ) -{ - free( p ); -} - -void -sym_assert( XP_Bool b, XP_U32 line, const char* file ) -{ - if ( !b ) { - XP_LOGF( "ASSERTION FAILED: line %d, file %s", - line, file ); - } -} - -void -sym_memcpy( void* dest, const void* src, XP_U32 nbytes ) -{ - memcpy( dest, src, nbytes ); -} - -XP_U32 -sym_strlen( XP_UCHAR* str ) -{ - return strlen( (const char*)str ); -} - -XP_S16 -sym_strncmp( XP_UCHAR* str1, XP_UCHAR* str2, XP_U32 len ) -{ - return (XP_S16)strncmp( (const char*)str1, (const char*)str2, len ); -} - -void -sym_memset( void* dest, XP_UCHAR val, XP_U32 nBytes ) -{ - memset( dest, val, nBytes ); -} - -XP_S16 -sym_strcmp( XP_UCHAR* str1, XP_UCHAR* str2 ) -{ - return (XP_S16)strcmp( (const char*)str1, (const char*)str2 ); -} - -char* -sym_strcat( XP_UCHAR* dest, const XP_UCHAR* src ) -{ - return strcat( (char*)dest, (const char*) src ); -} - -XP_S16 -sym_memcmp( void* m1, void* m2, XP_U32 nbytes ) -{ - return (XP_S16)memcmp( m1, m2, nbytes ); -} - -XP_U32 -sym_flip_long( XP_U32 l ) -{ - XP_U32 result = - ((l & 0x000000FF) << 24) | - ((l & 0x0000FF00) << 8) | - ((l & 0x00FF0000) >> 8) | - ((l & 0xFF000000) >> 24); - return result; -} - -XP_U16 -sym_flip_short(XP_U16 s) -{ - XP_U16 result = - ((s & 0x00FF) << 8) | - ((s & 0xFF00) >> 8); - - return result; -} - -} // extern "C" diff --git a/xwords4/symbian/src/xwapp.cpp b/xwords4/symbian/src/xwapp.cpp deleted file mode 100644 index 3d8da2bff..000000000 --- a/xwords4/symbian/src/xwapp.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 "xwdoc.h" -#include "xwapp.h" -#include "xwords.hrh" - -// UID for the application, this should correspond to the uid defined in the -// mmp file. (This is an official number from Symbian. I've been allocated a -// block of 10 of which this is the first.) -static const TUid KUidXWordsApp = {XW_UID3}; - -CApaDocument* -CXWordsApplication::CreateDocumentL() -{ - // Create an HelloWorldBasic document, and return a pointer to it - CApaDocument* document = CXWordsDocument::NewL(*this); - return document; -} - -TUid -CXWordsApplication::AppDllUid() const -{ - - return KUidXWordsApp; -} diff --git a/xwords4/symbian/src/xwappui.cpp b/xwords4/symbian/src/xwappui.cpp deleted file mode 100644 index 16a75375b..000000000 --- a/xwords4/symbian/src/xwappui.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 -#if defined SERIES_60 -# include -# include -#elif defined SERIES_80 -# include -# include -# include -#endif - -#include "xwords.pan" -#include "xwappui.h" -#include "xwappview.h" -#include "xwords.hrh" -#include "symutil.h" - -// ConstructL is called by the application framework -void CXWordsAppUi::ConstructL() -{ - BaseConstructL(); - - iAppView = CXWordsAppView::NewL( ClientRect(), Application() ); - - AddToStackL(iAppView); -} - -CXWordsAppUi::CXWordsAppUi() -{ -} - -CXWordsAppUi::~CXWordsAppUi() -{ - if ( iAppView ) { - iEikonEnv->RemoveFromStack(iAppView); - delete iAppView; - iAppView = NULL; - } - - /* Somebody on NewLC says this is required to clean up TLS allocated - via use of stdlib calls */ - CloseSTDLIB(); -} - -// handle any menu commands -void CXWordsAppUi::HandleCommandL(TInt aCommand) -{ - switch(aCommand) { - - // built-in commands here - case EEikCmdExit: - iAppView->Exiting(); - CBaActiveScheduler::Exit(); - break; - - // added commands here - default: - if ( iAppView->HandleCommand( aCommand ) == 0 ) { - Panic(EXWordsUi); - } - break; - } -} // HandleCommandL - -TKeyResponse -CXWordsAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, - TEventCode aType ) -{ - if ( aType == EEventKey ) { - XP_LOGF( "got iScanCode: %d (%c)", aKeyEvent.iScanCode, - aKeyEvent.iScanCode ); - if ( iAppView->HandleKeyEvent( aKeyEvent ) ) { - return EKeyWasConsumed; - } - } - - return EKeyWasNotConsumed; -} /* HandleKeyEventL */ diff --git a/xwords4/symbian/src/xwappview.cpp b/xwords4/symbian/src/xwappview.cpp deleted file mode 100644 index f8ce8d46f..000000000 --- a/xwords4/symbian/src/xwappview.cpp +++ /dev/null @@ -1,1375 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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. - */ - -#if defined SERIES_60 -# include -# include -# include "xwords_60.rsg" -#elif defined SERIES_80 -# include -# include -# include -# include -# include "xwords_80.rsg" -#endif - -#include -#include // for srand -#include -#include - -#include "xwappview.h" -#include "xwappui.h" -#include "xwords.hrh" -#include "comtypes.h" -#include "symdraw.h" -#include "symaskdlg.h" -#include "symdict.h" -#include "symgamdl.h" -#include "symblnk.h" -#include "symgmdlg.h" -#include "symutil.h" -#include "symssock.h" - -#include "LocalizedStrIncludes.h" - -// Standard construction sequence -CXWordsAppView* CXWordsAppView::NewL(const TRect& aRect, CEikApplication* aApp ) -{ - CXWordsAppView* self = CXWordsAppView::NewLC( aRect, aApp ); - CleanupStack::Pop(self); - return self; -} - -CXWordsAppView* CXWordsAppView::NewLC(const TRect& aRect, CEikApplication* aApp ) -{ - CXWordsAppView* self = new (ELeave) CXWordsAppView( aApp ); - CleanupStack::PushL(self); - self->ConstructL(aRect); - return self; -} - -CXWordsAppView::CXWordsAppView( CEikApplication* aApp ) - : iApp( aApp ) - , iHeartbeatCB( HeartbeatTimerCallback, this ) - , iHeartbeatDTE(iHeartbeatCB) - , iHBQueued(XP_FALSE) -{ -#ifdef DEBUG - TInt processHandleCount, threadHandleCount; - RThread thread; - thread.HandleCount( processHandleCount, threadHandleCount ); - XP_LOGF( "startup: processHandleCount: %d; threadHandleCount: %d", - processHandleCount, threadHandleCount ); -#endif - - iDraw = NULL; - XP_MEMSET( &iGame, 0, sizeof(iGame) ); - - iCurGameName.Copy( _L("") ); - - /* CBase derivitaves are zero'd out, they say */ - XP_ASSERT( iTimerReasons[0] == 0 && iTimerReasons[1] == 0 ); - -#ifndef XWFEATURE_STANDALONE_ONLY - comms_getInitialAddr( &iCommsAddr ); -#endif -} - -CXWordsAppView::~CXWordsAppView() -{ - DeleteGame(); - - if ( iDraw ) { - draw_destroyCtxt( iDraw ); - } - - XP_FREE( mpool, iUtil.vtable ); - vtmgr_destroy( MPPARM(mpool) iVtMgr ); - - mpool_destroy( mpool ); - - delete iDictList; - delete iRequestTimer; - delete iGamesMgr; -#ifndef XWFEATURE_STANDALONE_ONLY - delete iSendSock; - delete iNewPacketQueue; -#endif - -#ifdef DEBUG - TInt processHandleCount, threadHandleCount; - RThread thread; - thread.HandleCount( processHandleCount, threadHandleCount ); - XP_LOGF( "shutdown: processHandleCount: %d; threadHandleCount: %d", - processHandleCount, threadHandleCount ); -#endif -} - -void CXWordsAppView::ConstructL(const TRect& aRect) -{ - // Create a window for this application view - CreateWindowL(); - - // Set the windows size - SetRect(aRect); - - // Indicate that the control is blank - SetBlank(); - - iRequestTimer = CIdle::NewL( CActive::EPriorityIdle ); - iTimerRunCount = 0; - iDeltaTimer = CDeltaTimer::NewL( CActive::EPriorityStandard ); - - -#ifndef XWFEATURE_STANDALONE_ONLY - iSendSock = CSendSocket::NewL( PacketReceived, (void*)this ); - XP_LOGF( "iSendSock created" ); - iNewPacketQueue = new (ELeave)CDesC8ArrayFlat(2); -#endif - - // Set the control's border -// SetBorder(TGulBorder::EFlatContainer); - - // Set the correct application view (Note: - // ESkinAppViewWithCbaNoToolband is the default) - -#if defined SERIES_80 - //CknEnv::Skin().SetAppViewType(ESkinAppViewWithCbaNoToolband); - CknEnv::Skin().SetAppViewType(ESkinAppViewNoCbaNoToolband); -#endif - - // This doesn't do what I want -// SetExtentToWholeScreen(); - - // Activate the window, which makes it ready to be drawn - ActivateL(); - - // Now the xwords-specific stuff - XP_LOGF( "starting xwords initialization" ); - - iStartTime.HomeTime(); - TDateTime tdtime = iStartTime.DateTime(); - // seed random with current microseconds, or so.... whatever. - TInt seed = (((tdtime.Minute() * 60) + tdtime.Second()) * 1000 ) - + tdtime.MicroSecond(); - XP_LOGF( "seeding srand with %d", seed ); - srand( seed ); - -#ifdef MEM_DEBUG - mpool = mpool_make(); -#endif - - iVtMgr = make_vtablemgr( MPPARM_NOCOMMA(mpool) ); - User::LeaveIfNull( iVtMgr ); - - iUtil.vtable = (UtilVtable*)XP_MALLOC( mpool, sizeof( UtilVtable ) ); - User::LeaveIfNull( iUtil.vtable ); - SetUpUtil(); - - TFileName basePath; - GetXwordsRWDir( &basePath, EGamesLoc ); - iGamesMgr = CXWGamesMgr::NewL( MPPARM(mpool) iCoeEnv, &basePath ); - - iDraw = sym_drawctxt_make( MPPARM(mpool) &SystemGc(), iCoeEnv, - iEikonEnv, iApp ); - User::LeaveIfNull( iDraw ); - - if ( !FindAllDicts() ) { - UserErrorFromID( R_ALERT_NO_DICTS ); - User::Leave( -1 ); - } - - if ( !LoadPrefs() ) { - InitPrefs(); - } - MakeOrLoadGameL(); - - PositionBoard(); - (void)server_do( iGame.server ); // get tiles assigned etc. -} // ConstructL - -// Draw this application's view to the screen -void CXWordsAppView::Draw( const TRect& aRect ) const -{ - // Get the standard graphics context - CWindowGc& gc = SystemGc(); - gc.SetClippingRect( aRect ); - gc.Clear( aRect ); - - if ( iGame.board ) { - XP_Rect rect; - - rect.left = SC( XP_U16, aRect.iTl.iX ); - rect.top = SC( XP_U16, aRect.iTl.iY ); - rect.width = SC( XP_U16, aRect.Width() ); - rect.height = SC( XP_U16, aRect.Height() ); - - board_invalRect( iGame.board, &rect ); - board_draw( iGame.board ); - } - - DrawGameName(); -} // Draw - -/* static */ VTableMgr* -CXWordsAppView::sym_util_getVTManager( XW_UtilCtxt* uc ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - return self->iVtMgr; -} /* sym_util_getVTManager */ - -#ifndef XWFEATURE_STANDALONE_ONLY -/*static*/ XWStreamCtxt* -CXWordsAppView::sym_util_makeStreamFromAddr( XW_UtilCtxt* uc, - XP_U16 channelNo ) -{ - XP_LOGF( "sym_util_makeStreamFromAddr called" ); - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - XP_ASSERT( self->iGame.comms ); - return self->MakeSimpleStream( self->sym_send_on_close, - channelNo ); -} -#endif - -#define EM BONUS_NONE -#define DL BONUS_DOUBLE_LETTER -#define DW BONUS_DOUBLE_WORD -#define TL BONUS_TRIPLE_LETTER -#define TW BONUS_TRIPLE_WORD - -static XWBonusType -sym_util_getSquareBonus( XW_UtilCtxt* /*uc*/, ModelCtxt* /*model*/, - XP_U16 col, XP_U16 row ) -{ - XP_U16 index; - XWBonusType result; - const XP_U16 fourteen = 14; - - const char defaultBoard[8*8] = { - TW,EM,EM,DL,EM,EM,EM,TW, - EM,DW,EM,EM,EM,TL,EM,EM, - - EM,EM,DW,EM,EM,EM,DL,EM, - DL,EM,EM,DW,EM,EM,EM,DL, - - EM,EM,EM,EM,DW,EM,EM,EM, - EM,TL,EM,EM,EM,TL,EM,EM, - - EM,EM,DL,EM,EM,EM,DL,EM, - TW,EM,EM,DL,EM,EM,EM,DW, - }; /* defaultBoard */ - - if ( col > 7 ) col = SC(XP_U16, fourteen - col); - if ( row > 7 ) row = SC(XP_U16, fourteen - row); - index = SC(XP_U16,(row*8) + col); - if ( index >= 8*8 ) { - result = (XWBonusType)EM; - } else { - result = (XWBonusType)defaultBoard[index]; - } - return result; -} // sym_util_getSquareBonus - -/* static */ void -CXWordsAppView::sym_util_userError( XW_UtilCtxt* uc, UtilErrID id ) -{ - TInt resourceId = 0; - - switch( id ) { - case ERR_TILES_NOT_IN_LINE: - resourceId = R_TILES_IN_LINE_ALERT; - break; - case ERR_NO_EMPTIES_IN_TURN: - resourceId = R_NO_EMPTIES_SEP_ALERT; - break; - case ERR_TWO_TILES_FIRST_MOVE: - resourceId = R_TWO_TILES_FIRST_MOVE_ALERT; - break; - case ERR_TILES_MUST_CONTACT: - resourceId = R_PLACED_MUST_CONTACT_ALERT; - break; - case ERR_TOO_FEW_TILES_LEFT_TO_TRADE: - resourceId = R_TOO_FEW_TO_TRADE_ALERT; - break; - case ERR_NOT_YOUR_TURN: - resourceId = R_NOT_YOUR_TURN_ALERT; - break; - case ERR_NO_PEEK_ROBOT_TILES: - resourceId = R_NO_PEEK_ALERT; - break; -#ifndef XWFEATURE_STANDALONE_ONLY - case ERR_SERVER_DICT_WINS: - case ERR_NO_PEEK_REMOTE_TILES: - case ERR_REG_UNEXPECTED_USER: -#endif - case ERR_CANT_TRADE_MID_MOVE: - resourceId = R_REMOVE_FIRST_ALERT; - break; - case ERR_CANT_UNDO_TILEASSIGN: - resourceId = R_NOTHING_TO_UNDO_ALERT; - break; - default: - break; - } - - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - self->UserErrorFromID( resourceId ); -} // sym_util_userError - -static XP_Bool -sym_util_userQuery( XW_UtilCtxt* uc, UtilQueryID aId, - XWStreamCtxt* aStream ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - return self->UserQuery( aId, aStream ); -} /* sym_util_userQuery */ - -static XP_S16 -sym_util_userPickTile( XW_UtilCtxt* /*uc*/, const PickInfo* /*pi*/, - XP_U16 /*playerNum*/, - const XP_UCHAR4* texts, XP_U16 nTiles ) -{ - TInt result = 0; - TRAPD( error, CXWBlankSelDlg::UsePickTileDialogL( texts, nTiles, &result ) ); - XP_ASSERT( result >= 0 && result < nTiles ); - return static_cast(result); -} /* sym_util_userPickTile */ - -static XP_Bool -sym_util_askPassword( XW_UtilCtxt* /*uc*/, const XP_UCHAR* /*name*/, - XP_UCHAR* /*buf*/, XP_U16* /*len*/ ) -{ - return XP_TRUE; -} - -static void -sym_util_trayHiddenChange(XW_UtilCtxt* /*uc*/, XW_TrayVisState /*newState*/, - XP_U16 /*nVisibleRows*/) -{ -} - -static void -sym_util_yOffsetChange(XW_UtilCtxt* /*uc*/, XP_U16 /*oldOffset*/, - XP_U16 /*newOffset*/ ) -{ -} - -/* static */ void -CXWordsAppView::sym_util_notifyGameOverL( XW_UtilCtxt* uc ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - self->DrawNow(); - self->DisplayFinalScoresL(); -} - -static XP_Bool -sym_util_hiliteCell( XW_UtilCtxt* /*uc*/, XP_U16 /*col*/, XP_U16 /*row*/ ) -{ - return XP_TRUE; // don't exit early -} - -static XP_Bool -sym_util_engineProgressCallback( XW_UtilCtxt* /*uc*/ ) -{ -#ifdef SHOW_PROGRESS -#endif - return XP_TRUE; -} - -/*static*/ TInt -CXWordsAppView::HeartbeatTimerCallback( TAny* closure ) -{ -#ifdef BEYOND_IR - CXWordsAppView* self = (CXWordsAppView*)closure; - self->iHBQueued = XP_FALSE; - - TimerProc proc; - void* hbclosure; - self->GetHeartbeatCB( &proc, &hbclosure ); - (*proc)( hbclosure, TIMER_HEARTBEAT ); -#endif - return 0; -} - -/* static */ void -CXWordsAppView::sym_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, - XP_U16 when, - TimerProc proc, void* closure ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - - self->SetHeartbeatCB( proc, closure ); - - if ( self->iHBQueued ) { - self->iDeltaTimer->Remove( self->iHeartbeatDTE ); - self->iHBQueued = XP_FALSE; - } - - self->iDeltaTimer->Queue( when * 1000000, self->iHeartbeatDTE ); - self->iHBQueued = XP_TRUE; -} - -/* static */ void -CXWordsAppView::sym_util_requestTime( XW_UtilCtxt* uc ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - self->StartIdleTimer( EUtilRequest ); -} - -/* static */ XP_U32 -CXWordsAppView::sym_util_getCurSeconds( XW_UtilCtxt* uc ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - TTime currentTime; - currentTime.HomeTime(); - - TTimeIntervalSeconds interval; - (void)currentTime.SecondsFrom( self->iStartTime, interval ); - - return (XP_U32)interval.Int(); -} - -/* static */ DictionaryCtxt* -CXWordsAppView::sym_util_makeEmptyDict( XW_UtilCtxt* uc ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - - DictionaryCtxt* dict = sym_dictionary_makeL( MPPARM(self->mpool) - NULL, NULL ); - return dict; -} - -static XP_UCHAR* -sym_util_getUserString( XW_UtilCtxt* /*uc*/, XP_U16 stringCode ) -{ - // These belong in resources. But I haven't yet figured out how - // to do 8-bit strings in resources. Also, StringLoader does - // allocations when loading strings rather than just returning - // pointers into the resources as palm does. So this method will - // have to provide permanent storage for the strings, probably via - // a string table that's filled in on demand. - - switch( stringCode ) { - case STRD_REMAINING_TILES_ADD: - return (XP_UCHAR*)"+ %d [all remaining tiles]"; - case STRD_UNUSED_TILES_SUB: - return (XP_UCHAR*)"- %d [unused tiles]"; - case STR_BONUS_ALL: - return (XP_UCHAR*)"Bonus for using all tiles: 50" XP_CR; - case STRD_TURN_SCORE: - return (XP_UCHAR*)"Score for turn: %d" XP_CR; - case STR_COMMIT_CONFIRM: - return (XP_UCHAR*)"Commit the current move?" XP_CR; - case STR_LOCAL_NAME: - return (XP_UCHAR*)"%s"; - case STR_NONLOCAL_NAME: - return (XP_UCHAR*)"%s (remote)"; - case STRD_TIME_PENALTY_SUB: - return (XP_UCHAR*)" - %d [time]"; - - case STRD_CUMULATIVE_SCORE: - return (XP_UCHAR*)"Cumulative score: %d" XP_CR; - case STRS_MOVE_ACROSS: - return (XP_UCHAR*)"move (from %s across)" XP_CR; - case STRS_MOVE_DOWN: - return (XP_UCHAR*)"move (from %s down)" XP_CR; - case STRS_TRAY_AT_START: - return (XP_UCHAR*)"Tray at start: %s" XP_CR; - - case STRS_NEW_TILES: - return (XP_UCHAR*)"New tiles: %s" XP_CR; - case STRSS_TRADED_FOR: - return (XP_UCHAR*)"Traded %s for %s."; - case STR_PASS: - return (XP_UCHAR*)"pass" XP_CR; - case STR_PHONY_REJECTED: - return (XP_UCHAR*)"Illegal word in move; turn lost!" XP_CR; - - case STRD_ROBOT_TRADED: - return (XP_UCHAR*)"Robot traded tiles %d this turn."; - case STR_ROBOT_MOVED: - return (XP_UCHAR*)"The robot made this move:" XP_CR; - case STR_REMOTE_MOVED: - return (XP_UCHAR*)"Remote player made this move:" XP_CR; - - case STR_PASSED: - return (XP_UCHAR*)"Passed"; - case STRSD_SUMMARYSCORED: - return (XP_UCHAR*)"%s:%d"; - case STRD_TRADED: - return (XP_UCHAR*)"Traded %d"; - case STR_LOSTTURN: - return (XP_UCHAR*)"Lost turn"; - - case STRS_VALUES_HEADER: - return (XP_UCHAR*)"%s counts/values:" XP_CR; - - default: - XP_LOGF( "stringCode=%d", stringCode ); - return (XP_UCHAR*)"unknown code"; - } -} // sym_util_getUserString - -static XP_Bool -sym_util_warnIllegalWord( XW_UtilCtxt* /*uc*/, BadWordInfo* /*bwi*/, - XP_U16 /*turn*/, XP_Bool /*turnLost*/ ) -{ - return XP_FALSE; -} - -#ifdef BEYOND_IR -/*static*/void -CXWordsAppView::sym_util_listenPortChange( XW_UtilCtxt* uc, XP_U16 aPort ) -{ -/* CXWordsAppView* self = (CXWordsAppView*)uc->closure; */ -// self->iReadSock->SetListenPort( aPort ); -/* self->iSendSock->Listen(); */ -} - -/*static*/void -CXWordsAppView::sym_util_addrChange( XW_UtilCtxt* uc, - const CommsAddrRec* aOld, - const CommsAddrRec* aNew ) -{ - CXWordsAppView* self = (CXWordsAppView*)uc->closure; - XP_LOGF( "util_addrChange: calling connect" ); - self->iSendSock->ConnectL( aNew ); - (void)self->iSendSock->Listen(); -} -#endif - -#ifdef XWFEATURE_SEARCHLIMIT -static XP_Bool -sym_util_getTraySearchLimits(XW_UtilCtxt* /*uc*/, XP_U16* /*min*/, XP_U16* /*max*/ ) -{ - return XP_FALSE; -} -#endif - - -void -CXWordsAppView::SetUpUtil() -{ - UtilVtable* vtable = iUtil.vtable; - iUtil.closure = (void*)this; - iUtil.gameInfo = &iGi; - MPASSIGN( iUtil.mpool, mpool ); - - vtable->m_util_getVTManager = sym_util_getVTManager; -#ifndef XWFEATURE_STANDALONE_ONLY - vtable->m_util_makeStreamFromAddr = sym_util_makeStreamFromAddr; -#endif - vtable->m_util_getSquareBonus = sym_util_getSquareBonus; - vtable->m_util_userError = sym_util_userError; - vtable->m_util_userQuery = sym_util_userQuery; - vtable->m_util_userPickTile = sym_util_userPickTile; - vtable->m_util_askPassword = sym_util_askPassword; - vtable->m_util_trayHiddenChange = sym_util_trayHiddenChange; - vtable->m_util_yOffsetChange = sym_util_yOffsetChange; - vtable->m_util_notifyGameOver = sym_util_notifyGameOverL; - vtable->m_util_hiliteCell = sym_util_hiliteCell; - vtable->m_util_engineProgressCallback = sym_util_engineProgressCallback; - vtable->m_util_setTimer = sym_util_setTimer; - vtable->m_util_requestTime = sym_util_requestTime; - vtable->m_util_getCurSeconds = sym_util_getCurSeconds; - vtable->m_util_makeEmptyDict = sym_util_makeEmptyDict; - vtable->m_util_getUserString = sym_util_getUserString; - vtable->m_util_warnIllegalWord = sym_util_warnIllegalWord; -#ifdef BEYOND_IR - vtable->m_util_addrChange = sym_util_addrChange; -#endif -#ifdef XWFEATURE_SEARCHLIMIT - vtable->m_util_getTraySearchLimits = sym_util_getTraySearchLimits; -#endif -} - -// Load the current game from prefs or else create a new one. -// Eventually this will involve putting up the new game dialog. -void -CXWordsAppView::MakeOrLoadGameL() -{ - if ( iCurGameName.Length() > 0 && iGamesMgr->Exists( &iCurGameName ) ) { - LoadOneGameL( &iCurGameName ); - } else { - - /*************************************************************** - * PENDING The code here duplicates DoNewGame. Unify the two!!!! - ***************************************************************/ - - gi_initPlayerInfo( MPPARM(mpool) &iGi, (XP_UCHAR*)"Player %d" ); - -#ifndef XWFEATURE_STANDALONE_ONLY - CommsAddrRec commsAddr; - if ( iGame.comms != NULL ) { - comms_getAddr( iGame.comms, &commsAddr ); - } else { - commsAddr = iCommsAddr; - } -#endif - - TGameInfoBuf gib( &iGi, -#ifndef XWFEATURE_STANDALONE_ONLY - &commsAddr, -#endif - iDictList ); - if ( !CXWGameInfoDlg::DoGameInfoDlgL( MPPARM(mpool) &gib, ETrue ) ) { - User::Leave(-1); - } - - gib.CopyToL( MPPARM(mpool) &iGi -#ifndef XWFEATURE_STANDALONE_ONLY - , &iCommsAddr -#endif - ); - - TFileName path; - GetXwordsRWDir( &path, EDictsLoc ); - DictionaryCtxt* dict = sym_dictionary_makeL( MPPARM(mpool) - &path, iGi.dictName ); - User::LeaveIfNull( dict ); - - XP_U16 newGameID = SC( XP_U16, sym_util_getCurSeconds( &iUtil ) ); - game_makeNewGame( MPPARM(mpool) &iGame, &iGi, - &iUtil, iDraw, newGameID, &iCp, - SYM_SEND, this ); - model_setDictionary( iGame.model, dict ); - -#ifndef XWFEATURE_STANDALONE_ONLY - if ( iGame.comms ) { - comms_setAddr( iGame.comms, &iCommsAddr ); - if ( iGi.serverRole == SERVER_ISCLIENT ) { - XWStreamCtxt* stream = MakeSimpleStream( sym_send_on_close ); - server_initClientConnection( iGame.server, stream ); - } - } -#endif - - iGamesMgr->MakeDefaultName( &iCurGameName ); - StoreOneGameL( &iCurGameName ); - } -} /* MakeOrLoadGameL */ - -void -CXWordsAppView::DeleteGame() -{ - game_dispose( &iGame ); - gi_disposePlayerInfo( MPPARM(mpool) &iGi ); -} - -void -CXWordsAppView::PositionBoard() -{ - const TRect rect = Rect(); - const XP_U16 boardWidth = 15 * scaleBoardH; - const XP_U16 scoreTop = 25; - const XP_U16 scoreHt = 120; - - board_setPos( iGame.board, 2, 2, XP_FALSE ); - board_setScale( iGame.board, scaleBoardH, scaleBoardV ); - - XP_U16 scoreLeft = 2 + boardWidth + 2 + 3; /* 2 for border, 3 for gap */ - XP_U16 scoreRight = SC(XP_U16, rect.iBr.iX - 2 - 1); /* 2 for border */ - board_setScoreboardLoc( iGame.board, scoreLeft, scoreTop, - SC( XP_U16, scoreRight - scoreLeft - 1), - scoreHt, XP_FALSE ); - board_setYOffset( iGame.board, 0 ); - - board_setTrayLoc( iGame.board, - 2 + (15 * scaleBoardH) + 5, // to right of board - // make tray bottom same as board's - 2 + (15*scaleBoardV) - scaleTrayV, - scaleTrayH, scaleTrayV, // v and h scale - 3 ); // divider width - board_invalAll( iGame.board ); - - iTitleBox.SetRect( scoreLeft, 2, scoreRight, scoreTop - 4 ); -} // PositionBoard - -int -CXWordsAppView::HandleCommand( TInt aCommand ) -{ - XP_Bool draw = XP_FALSE; - XP_Bool notDone; - - switch ( aCommand ) { - - case XW_NEWGAME_COMMAND: - draw = DoNewGame(); - break; - - case XW_SAVEDGAMES_COMMAND: - draw = DoSavedGames(); - (void)server_do( iGame.server ); - break; - case XW_PREFS_COMMAND: - case XW_ABOUT_COMMAND: - NotImpl(); - break; - - case XW_VALUES_COMMAND: - if ( iGame.server != NULL ) { - XWStreamCtxt* stream = MakeSimpleStream( NULL ); - if ( stream != NULL ) { - server_formatDictCounts( iGame.server, stream, 7 ); /* 4: ncols */ - CXWAskDlg::DoInfoDlg(MPPARM(mpool) stream, ETrue); - } - } - break; - - case XW_REMAIN_COMMAND: - if ( iGame.board != NULL ) { - XWStreamCtxt* stream = MakeSimpleStream( NULL ); - if ( stream ) { - board_formatRemainingTiles( iGame.board, stream ); - CXWAskDlg::DoInfoDlg(MPPARM(mpool) stream, ETrue); - } - } - break; - - case XW_CURINFO_COMMAND: { - NotImpl(); -/* TGameInfoBuf gib( &iGi, iDictList ); */ -/* CXWGameInfoDlg::DoGameInfoDlgL( MPPARM(mpool) &gib, EFalse ); */ - } - break; - - case XW_HISTORY_COMMAND: - if ( iGame.server ) { - XP_Bool gameOver = server_getGameIsOver( iGame.server ); - XWStreamCtxt* stream = MakeSimpleStream( NULL ); - - model_writeGameHistory( iGame.model, stream, - iGame.server, gameOver ); - if ( stream_getSize( stream ) > 0 ) { - CXWAskDlg::DoInfoDlg( MPPARM(mpool) stream, ETrue ); - } - } - - break; - - case XW_FINALSCORES_COMMAND: - if ( server_getGameIsOver( iGame.server ) ) { - DisplayFinalScoresL(); - } else if ( AskFromResId( R_CONFIRM_END_GAME ) ) { - server_endGame( iGame.server ); - draw = ETrue; - } - break; - - case XW_HINT_COMMAND: -#ifdef XWFEATURE_SEARCHLIMIT - case XW_LIMHINT_COMMAND: -#endif - break; - case XW_NEXTHINT_COMMAND: - draw = board_requestHint( iGame.board, -#ifdef XWFEATURE_SEARCHLIMIT - XP_FALSE, -#endif - - ¬Done ); - break; - case XW_UNDOCUR_COMMAND: - draw = board_replaceTiles( iGame.board ); - break; - case XW_UNDOLAST_COMMAND: - draw = server_handleUndo( iGame.server ); - break; - case XW_DONE_COMMAND: - draw = board_commitTurn( iGame.board ); - break; - case XW_JUGGLE_COMMAND: - draw = board_juggleTray( iGame.board ); - break; - - case XW_TRADE_COMMAND: - draw = board_beginTrade( iGame.board ); - break; - - case XW_HIDETRAY_COMMAND: - if ( TRAY_REVEALED == board_getTrayVisState( iGame.board ) ) { - draw = board_hideTray( iGame.board ); - } else { - draw = board_showTray( iGame.board ); - } - break; - - case XW_FLIP_COMMAND: - draw = board_flip( iGame.board ); - break; - case XW_TOGGLEVALS_COMMAND: - draw = board_toggle_showValues( iGame.board ); - break; - -#ifndef XWFEATURE_STANDALONE_ONLY - case XW_RESEND_COMMAND: - if ( iGame.comms != NULL ) { - (void)comms_resendAll( iGame.comms ); - } -#endif - - default: - return 0; - } - - if ( draw ) { - DoImmediateDraw(); - } - - return 1; -} // CXWordsAppView::HandleCommand - -void -CXWordsAppView::Exiting() -{ - StoreOneGameL( &iCurGameName ); - WritePrefs(); -} /* Exiting */ - -TBool -CXWordsAppView::HandleKeyEvent( const TKeyEvent& aKeyEvent ) -{ - XP_Bool draw = XP_FALSE; - XP_Key key = XP_KEY_NONE; - TChar chr(aKeyEvent.iCode); - - switch ( chr ) { - - case EKeyTab: // 2 // this is probably for laptop only! :-) - key = XP_FOCUSCHANGE_KEY; - break; - - case EKeyEnter: - key = XP_RETURN_KEY; - break; - case EKeyBackspace: - key = XP_CURSOR_KEY_DEL; - break; - case EKeyLeftArrow: // 14 - key = XP_CURSOR_KEY_LEFT; - break; - case EKeyRightArrow: // 15 - key = XP_CURSOR_KEY_RIGHT; - break; - case EKeyUpArrow: // 16 - key = XP_CURSOR_KEY_UP; - break; - case EKeyDownArrow: // 17 - key = XP_CURSOR_KEY_DOWN; - break; - - default: - key = (XP_Key)aKeyEvent.iScanCode; - if ( key < 0x20 || key > 0x7f ) { - key = XP_KEY_NONE; - } - break; - } - - if ( iGame.board != NULL ) { - if ( key != XP_KEY_NONE ) { - draw = board_handleKey( iGame.board, key ); - } - } - - if ( draw ) { - DoImmediateDraw(); - } - - // handled if it's one we recognize. This is probably too broad!!! - return key != XP_KEY_NONE; -} - -/* static */ TInt -CXWordsAppView::TimerCallback( TAny* aPtr ) -{ - CXWordsAppView* me = (CXWordsAppView*)aPtr; - - if ( 0 ) { - -#ifndef XWFEATURE_STANDALONE_ONLY - /* Only do one per call. Packets are higher priority */ - } else if ( me->iTimerReasons[EProcessPacket] > 0 ) { - --me->iTimerReasons[EProcessPacket]; - XP_ASSERT( me->iTimerReasons[EProcessPacket] == 0 ); - - XP_Bool draw = XP_FALSE; - - XWStreamCtxt* stream = me->MakeSimpleStream( NULL ); - - TPtrC8 packet = (*me->iNewPacketQueue)[0]; - stream_putBytes( stream, (void*)packet.Ptr(), packet.Length() ); - me->iNewPacketQueue->Delete(0); - XP_LOGF( "pulling packet off head of queue; there are %d left", - me->iNewPacketQueue->Count() ); - - CommsAddrRec addr; - addr.conType = COMMS_CONN_RELAY; - if ( comms_checkIncomingStream( me->iGame.comms, stream, &addr ) ) { - draw = server_receiveMessage( me->iGame.server, stream ); - } - stream_destroy( stream ); - sym_util_requestTime( &me->iUtil ); - - if ( draw ) { - me->DoImmediateDraw(); - } -#endif - } else if ( me->iTimerReasons[EUtilRequest] > 0 ) { - --me->iTimerReasons[EUtilRequest]; - if ( server_do( me->iGame.server ) ) { - me->DoImmediateDraw(); - } - } - - return --me->iTimerRunCount > 0; -} - -XWStreamCtxt* -CXWordsAppView::MakeSimpleStream( MemStreamCloseCallback cb, - XP_U16 channelNo ) -{ - return mem_stream_make( MPPARM(mpool) - iVtMgr, (void*)this, - channelNo, cb ); -} /* MakeSimpleStream */ - -void -CXWordsAppView::DisplayFinalScoresL() -{ - XWStreamCtxt* stream = MakeSimpleStream( NULL ); - User::LeaveIfNull( stream ); - - server_writeFinalScores( iGame.server, stream ); - - CXWAskDlg::DoInfoDlg( MPPARM(mpool) stream, ETrue ); -} /* displayFinalScores */ - -TBool -CXWordsAppView::AskFromResId( TInt aResource ) -{ - TBuf16<128> message; - StringLoader::Load( message, aResource ); - - return CXWAskDlg::DoAskDlg( MPPARM(mpool) &message ); -} - -static void -logOneFile( TPtrC name ) -{ - TBuf8<128> tmpb; - tmpb.Copy( name ); - XP_UCHAR buf[128]; - XP_MEMCPY( buf, (void*)(tmpb.Ptr()), tmpb.Length() ); - buf[tmpb.Length()] = '\0'; - XP_LOGF( "found file %s", buf ); -} /* logOneFile */ - -TBool -CXWordsAppView::FindAllDicts() -{ - /* NOTE: CEikFileNameSelector might be the way to do this and the display - * of the list in the game setup dialog. - */ - TBool found = EFalse; - RFs fs = iCoeEnv->FsSession(); - - TFindFile file_finder( fs ); - CDir* file_list; - _LIT( wildName, "*.xwd" ); - - TFileName dir; - GetXwordsRWDir( &dir, EDictsLoc ); - - TInt err = file_finder.FindWildByDir( wildName, dir, file_list ); - if ( err == KErrNone ) { - - CleanupStack::PushL( file_list ); - iDictList = new (ELeave)CDesC16ArrayFlat( file_list->Count() ); - - TInt i; - for ( i = 0; i < file_list->Count(); i++ ) { - TParse fullentry; - fullentry.Set((*file_list)[i].iName,& file_finder.File(),NULL); - logOneFile( fullentry.Name() ); - iDictList->AppendL( fullentry.Name() ); - } - - CleanupStack::PopAndDestroy( file_list ); - found = ETrue; - } - - return found; -} /* FindAllDicts */ - -void -CXWordsAppView::UserErrorFromID( TInt aResource ) -{ - if ( aResource != 0 ) { - _LIT(title,"Oops"); - TBuf16<128> message; - StringLoader::Load( message, aResource ); -#if defined SERIES_60 - CEikInfoDialog::RunDlgLD( title, message ); -#elif defined SERIES_80 - CCknInfoDialog::RunDlgLD( title, message ); -#endif - } -} - -void -CXWordsAppView::NotImpl() -{ - UserErrorFromID( R_ALERT_FEATURE_PENDING ); -} /* NotImpl */ - -void -CXWordsAppView::GetXwordsRWDir( TFileName* aPathRef, TDriveReason aWhy ) -{ - TFileName fn = iApp->BitmapStoreName(); /* isn't the a method to just get - the path? */ - TParse nameParser; - nameParser.Set( fn, NULL, NULL ); - TPtrC path = nameParser.DriveAndPath(); - - switch( aWhy ) { - case EGamesLoc: - case EDictsLoc: - aPathRef->Copy( nameParser.DriveAndPath() ); - break; - case EPrefsLoc: - aPathRef->Copy( nameParser.Path() ); - break; /* don't want a drive */ - } -} /* GetXwordsRWDir */ - -_LIT(filename,"xwdata.dat"); -TBool -CXWordsAppView::LoadPrefs() -{ - RFs fs = iCoeEnv->FsSession(); - - TFileName nameD; - GetXwordsRWDir( &nameD, EPrefsLoc ); - nameD.Append( filename ); - - /* Read in prefs etc. */ - RFileReadStream reader; - CleanupClosePushL(reader); - TInt err = reader.Open( fs, nameD, EFileRead ); - - TBool found = err == KErrNone; - if ( found ) { - iCp.showBoardArrow = reader.ReadInt8L(); - iCp.showRobotScores = reader.ReadInt8L(); - reader >> iCurGameName; - } - CleanupStack::PopAndDestroy( &reader ); // reader - - return found; -} /* LoadPrefs */ - -void -CXWordsAppView::WritePrefs() -{ - RFs fs = iCoeEnv->FsSession(); - - TFileName nameD; - GetXwordsRWDir( &nameD, EPrefsLoc ); - nameD.Append( filename ); - - RFileWriteStream writer; - CleanupClosePushL(writer); - User::LeaveIfError( writer.Replace( fs, nameD, EFileWrite ) ); - - writer.WriteInt8L( iCp.showBoardArrow ); - writer.WriteInt8L( iCp.showRobotScores ); - - writer << iCurGameName; - - CleanupStack::PopAndDestroy( &writer ); // writer -} /* WritePrefs */ - -void -CXWordsAppView::InitPrefs() -{ - iCp.showBoardArrow = XP_TRUE; // default because no pen - iCp.showRobotScores = XP_FALSE; - -#ifndef XWFEATURE_STANDALONE_ONLY - iGi.serverRole = SERVER_STANDALONE; -#endif -} - -TBool -CXWordsAppView::DoNewGame() -{ - TBool draw = EFalse; - - TBool save = AskSaveGame(); - -#ifndef XWFEATURE_STANDALONE_ONLY - CommsAddrRec commsAddr; - if ( iGame.comms != NULL ) { - comms_getAddr( iGame.comms, &commsAddr ); - } else { - commsAddr = iCommsAddr; - } -#endif - - TGameInfoBuf gib( &iGi, -#ifndef XWFEATURE_STANDALONE_ONLY - &commsAddr, -#endif - iDictList ); - if ( CXWGameInfoDlg::DoGameInfoDlgL( MPPARM(mpool) &gib, ETrue ) ) { - - if ( save ) { - StoreOneGameL( &iCurGameName ); - iGamesMgr->MakeDefaultName( &iCurGameName ); - } - - gib.CopyToL( MPPARM(mpool) &iGi -#ifndef XWFEATURE_STANDALONE_ONLY - , &iCommsAddr -#endif - ); - XP_U16 newGameID = SC( XP_U16,sym_util_getCurSeconds( &iUtil ) ); - game_reset( MPPARM(mpool) &iGame, &iGi, &iUtil, newGameID, - &iCp, SYM_SEND, this ); - - DictionaryCtxt* prevDict = model_getDictionary( iGame.model ); - if ( 0 != XP_STRCMP( dict_getName(prevDict), iGi.dictName ) ) { - dict_destroy( prevDict ); - - TFileName path; - GetXwordsRWDir( &path, EDictsLoc ); - DictionaryCtxt* dict = sym_dictionary_makeL( MPPARM(mpool) - &path, iGi.dictName ); - model_setDictionary( iGame.model, dict ); - } -#ifndef XWFEATURE_STANDALONE_ONLY - if ( iGame.comms ) { - comms_setAddr( iGame.comms, &iCommsAddr ); - - if ( iGi.serverRole == SERVER_ISCLIENT ) { - XWStreamCtxt* stream = MakeSimpleStream( sym_send_on_close ); - // server deletes stream - server_initClientConnection( iGame.server, stream ); - } - } -#endif - - board_invalAll( iGame.board ); - (void)server_do( iGame.server ); // get tiles assigned etc. - draw = ETrue; - } - return draw; -} /* DoNewGame */ - -TBool -CXWordsAppView::DoSavedGames() -{ - StoreOneGameL( &iCurGameName ); - - TGameName openName; - TBool confirmed = CXSavedGamesDlg::DoGamesPicker( MPPARM(mpool) - this, - iGamesMgr, - &iCurGameName, - &openName ); - if ( confirmed ) { - if ( 0 != iCurGameName.Compare( openName ) ) { - - iCurGameName = openName; - - game_dispose( &iGame ); - gi_disposePlayerInfo( MPPARM(mpool) &iGi ); - - LoadOneGameL( &iCurGameName ); - Window().Invalidate( iTitleBox ); - } - } - return confirmed; -} /* DoSavedGames */ - -void -CXWordsAppView::LoadOneGameL( TGameName* aGameName ) -{ - XWStreamCtxt* stream = MakeSimpleStream( NULL ); - DictionaryCtxt* dict; - - iGamesMgr->LoadGameL( aGameName, stream ); - - XP_U16 len = stream_getU8( stream ); - XP_UCHAR dictName[32]; - stream_getBytes( stream, dictName, len ); - dictName[len] = '\0'; - - TFileName path; - GetXwordsRWDir( &path, EDictsLoc ); - dict = sym_dictionary_makeL( MPPARM(mpool) &path, dictName ); - XP_ASSERT( !!dict ); - - game_makeFromStream( MPPARM(mpool) stream, &iGame, - &iGi, dict, &iUtil, iDraw, &iCp, - SYM_SEND, this ); - stream_destroy( stream ); - - PositionBoard(); -} - -void -CXWordsAppView::StoreOneGameL( TGameName* aGameName ) -{ - XWStreamCtxt* stream = MakeSimpleStream( NULL ); - - /* save the dict. NOTE: should be possible to do away with this! */ - XP_U32 len = XP_STRLEN(iGi.dictName); - XP_ASSERT( len <= 0xFF ); - stream_putU8( stream, SC(XP_U8, len) ); - stream_putBytes( stream, iGi.dictName, SC(XP_U16, len) ); - - /* Now the game */ - game_saveToStream( &iGame, &iGi, stream ); - - iGamesMgr->StoreGameL( aGameName, stream ); - stream_destroy( stream ); -} - -XP_Bool -CXWordsAppView::UserQuery( UtilQueryID aId, XWStreamCtxt* aStream ) -{ - TInt resID = 0; - - switch ( aId ) { - case QUERY_ROBOT_MOVE: - case QUERY_ROBOT_TRADE: - case QUERY_COMMIT_TURN: - XP_ASSERT( aStream ); - return CXWAskDlg::DoAskDlg( MPPARM(mpool) aStream, EFalse ); - case QUERY_COMMIT_TRADE: - XP_ASSERT( !aStream ); - resID = R_CONFIRM_TRADE; - break; - case SYM_QUERY_CONFIRM_DELGAME: - XP_ASSERT( !aStream ); - resID = R_CONFIRM_DELGAME; - break; - } - if ( resID != 0 ) { - return AskFromResId( resID ); - } - XP_ASSERT( 0 ); - return XP_FALSE; -} /* sym_util_userQuery */ - -void -CXWordsAppView::DoImmediateDraw() -{ - ActivateGc(); - - XP_ASSERT( iGame.board != NULL ); - board_draw( iGame.board ); - - DeactivateGc(); -} /* DoImmediateDraw */ - -void -CXWordsAppView::DrawGameName() const -{ - if ( iGi.dictName != NULL ) { - TBuf16<66> buf; - buf.Copy( TBuf8<32>(iGi.dictName) ); - buf.Insert( 0, _L("::") ); - buf.Insert( 0, iCurGameName ); - - CWindowGc& gc = SystemGc(); - gc.SetPenStyle( CGraphicsContext::ESolidPen ); - gc.SetPenColor( KRgbBlack ); - gc.SetBrushColor( KRgbGray ); - gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); - - gc.UseFont( iCoeEnv->NormalFont() ); - gc.DrawText( buf, iTitleBox, iTitleBox.Height() - 4,/*TInt aBaselineOffset*/ - CGraphicsContext::ECenter ); - gc.DiscardFont(); - } -} - -#ifndef XWFEATURE_STANDALONE_ONLY - -/*static*/ void -CXWordsAppView::PacketReceived( const TDesC8* aBuf, void* aClosure ) -{ - CXWordsAppView* me = (CXWordsAppView*)aClosure; - - TInt count = me->iNewPacketQueue->Count(); - me->iNewPacketQueue->InsertL( count, *aBuf ); - XP_LOGF( "inserted packet: now number %d", count ); - - me->StartIdleTimer( EProcessPacket ); -} /* CXWordsAppView::PacketReceived */ - -/*static*/ XP_S16 -CXWordsAppView::sym_send( XP_U8* aBuf, XP_U16 aLen, const CommsAddrRec* aAddr, - void* aClosure ) -{ - CommsAddrRec addr; - XP_S16 result = -1; - CXWordsAppView* self = (CXWordsAppView*)aClosure; - - if ( aAddr == NULL ) { - comms_getAddr( self->iGame.comms, &addr ); - aAddr = &addr; - } - - if ( self->iSendSock->SendL( aBuf, aLen, aAddr ) ) { - result = aLen; - } - - /* Can't call listen until we've sent something.... */ - self->iSendSock->Listen(); - - return result; -} /* sym_send */ - -/*static*/ void -CXWordsAppView::sym_send_on_close( XWStreamCtxt* aStream, void* aClosure ) -{ - XP_LOGF( "sym_send_on_close called" ); - CXWordsAppView* self = (CXWordsAppView*)aClosure; - - comms_send( self->iGame.comms, aStream ); -} -#endif - -void -CXWordsAppView::StartIdleTimer( XWTimerReason_symb aWhy ) -{ - ++iTimerReasons[aWhy]; - - if ( ++iTimerRunCount == 1 ) { - iRequestTimer->Start( TCallBack( CXWordsAppView::TimerCallback, - (TAny*)this ) ); - } -} diff --git a/xwords4/symbian/src/xwdoc.cpp b/xwords4/symbian/src/xwdoc.cpp deleted file mode 100644 index a0a922936..000000000 --- a/xwords4/symbian/src/xwdoc.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 "xwappui.h" -#include "xwdoc.h" - -// Standard Symbian OS construction sequence -CXWordsDocument* CXWordsDocument::NewL(CEikApplication& aApp) - { - CXWordsDocument* self = NewLC(aApp); - CleanupStack::Pop(self); - return self; - } - -CXWordsDocument* CXWordsDocument::NewLC(CEikApplication& aApp) - { - CXWordsDocument* self = new (ELeave) CXWordsDocument(aApp); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -void CXWordsDocument::ConstructL() - { - // no implementation required - } - -CXWordsDocument::CXWordsDocument(CEikApplication& aApp) : CEikDocument(aApp) - { - // no implementation required - } - -CXWordsDocument::~CXWordsDocument() - { - // no implementation required - } - -CEikAppUi* CXWordsDocument::CreateAppUiL() - { - // Create the application user interface, and return a pointer to it, - // the framework takes ownership of this object - CEikAppUi* appUi = new (ELeave) CXWordsAppUi; - return appUi; - } - diff --git a/xwords4/symbian/src/xwmain.cpp b/xwords4/symbian/src/xwmain.cpp deleted file mode 100644 index dceb06735..000000000 --- a/xwords4/symbian/src/xwmain.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */ -/* - * Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample - * app helloworldbasic "Copyright (c) 2002, Nokia. All rights - * reserved.") - * - * 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 "xwapp.h" - -// DLL entry point, return that everything is ok -GLDEF_C TInt E32Dll(TDllReason /*aReason*/) -{ - return KErrNone; -} - - -// Create an application, and return a pointer to it -EXPORT_C CApaApplication* NewApplication() -{ - return (new CXWordsApplication); -} -