ハイハイスクールアドベンチャー_palmos版
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン | |||
| ハイハイスクールアドベンチャー_palmos版 [2025/11/20 04:19] – araki | ハイハイスクールアドベンチャー_palmos版 [2025/11/20 04:22] (現在) – [NDKのこと] araki | ||
|---|---|---|---|
| 行 219: | 行 219: | ||
| </ | </ | ||
| <file c high.c> | <file c high.c> | ||
| + | /* | ||
| + | * High-High School Adventure | ||
| + | | ||
| + | | ||
| + | */ | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #ifdef USE_GRAPH2 | ||
| + | #include " | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | #include " | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | #include " | ||
| + | #include " | ||
| + | |||
| + | typedef struct { | ||
| + | ZamaMapType | ||
| + | ZamaUserDataType user; | ||
| + | UInt8 object[0x200]; | ||
| + | ZamaPrefsType | ||
| + | |||
| + | Char | ||
| + | Char | ||
| + | |||
| + | RectangleType | ||
| + | UInt16 | ||
| + | UInt32 | ||
| + | Boolean | ||
| + | Boolean | ||
| + | |||
| + | UInt32 | ||
| + | Boolean | ||
| + | |||
| + | /* tsPatch support */ | ||
| + | Boolean | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | UInt32 | ||
| + | } ZamaGlobalVarType; | ||
| + | |||
| + | static | ||
| + | ZamaGlobalVarType * | ||
| + | CreateGlobalVariables() | ||
| + | { | ||
| + | ZamaGlobalVarType *ptr = NULL; | ||
| + | Err err; | ||
| + | if ((err = FtrPtrNew(ZAMA_CREATOR_ID, | ||
| + | { | ||
| + | return NULL; | ||
| + | } | ||
| + | return ptr; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | DeleteGlobalVariables() | ||
| + | { | ||
| + | FtrPtrFree(ZAMA_CREATOR_ID, | ||
| + | } | ||
| + | |||
| + | static | ||
| + | ZamaGlobalVarType * | ||
| + | GetGlobalVariables() | ||
| + | { | ||
| + | ZamaGlobalVarType *ptr = NULL; | ||
| + | Err err; | ||
| + | if ((err = FtrGet(ZAMA_CREATOR_ID, | ||
| + | { | ||
| + | return NULL; | ||
| + | } | ||
| + | return ptr; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | MemPtr | ||
| + | GetObjectPtr(UInt16 id) | ||
| + | { | ||
| + | FormPtr form; | ||
| + | form = FrmGetActiveForm(); | ||
| + | return FrmGetObjectPtr(form, | ||
| + | } | ||
| + | |||
| + | static | ||
| + | DmOpenRef | ||
| + | OpenDatabase(Char *name_) | ||
| + | { | ||
| + | LocalID | ||
| + | DmOpenRef | ||
| + | Err err; | ||
| + | UInt16 | ||
| + | |||
| + | if ((err = SysCurAppDatabase(& | ||
| + | cardNo = 0; | ||
| + | } | ||
| + | if ((dbID = DmFindDatabase(cardNo, | ||
| + | /* error */ | ||
| + | return NULL; | ||
| + | } | ||
| + | if ((dbP = DmOpenDatabase(cardNo, | ||
| + | /* error */ | ||
| + | return NULL; | ||
| + | } | ||
| + | return dbP; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | SaveGame(UInt16 fileno_) | ||
| + | { | ||
| + | LocalID | ||
| + | DmOpenRef | ||
| + | MemHandle | ||
| + | UInt16 | ||
| + | MemPtr | ||
| + | Boolean | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((err = SysCurAppDatabase(& | ||
| + | cardNo = 0; | ||
| + | } | ||
| + | while ((dbID = DmFindDatabase(cardNo, | ||
| + | /* create database */ | ||
| + | err = DmCreateDatabase(cardNo, | ||
| + | if (err) { | ||
| + | FrmAlert(ZAMA_SAVE_ALERT); | ||
| + | return false; | ||
| + | } | ||
| + | } | ||
| + | DmDatabaseInfo(cardNo, | ||
| + | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
| + | attr |= dmHdrAttrBackup; | ||
| + | version = 0x100; /* version 1.00 */ | ||
| + | DmSetDatabaseInfo(cardNo, | ||
| + | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
| + | if ((dbP = DmOpenDatabase(cardNo, | ||
| + | /* error */ | ||
| + | FrmAlert(ZAMA_SAVE_ALERT); | ||
| + | return false; | ||
| + | } | ||
| + | for (i = 0 ; i < 4 ; i++) { | ||
| + | if (DmQueryRecord(dbP, | ||
| + | if ((rec = DmNewHandle(dbP, | ||
| + | FrmAlert(ZAMA_SAVE_ALERT); | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | index = i; | ||
| + | if (DmAttachRecord(dbP, | ||
| + | FrmAlert(ZAMA_SAVE_ALERT); | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if ((rec = DmGetRecord(dbP, | ||
| + | FrmAlert(ZAMA_SAVE_ALERT); | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = MemHandleLock(rec); | ||
| + | |||
| + | DmWrite(p, 0, & | ||
| + | |||
| + | MemHandleUnlock(rec); | ||
| + | DmReleaseRecord(dbP, | ||
| + | if (fileno_ != 0) { | ||
| + | z-> | ||
| + | } | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return res; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | LoadGame(UInt16 fileno_) | ||
| + | { | ||
| + | DmOpenRef | ||
| + | MemHandle | ||
| + | Char sid[16]; | ||
| + | MemPtr | ||
| + | Boolean | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((dbP = OpenDatabase(" | ||
| + | FrmCustomAlert(ZAMA_NODATA_ALERT, | ||
| + | return false; | ||
| + | } | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_NODATA_ALERT, | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = MemHandleLock(rec); | ||
| + | |||
| + | MemMove((MemPtr)& | ||
| + | |||
| + | MemHandleUnlock(rec); | ||
| + | z-> | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return res; | ||
| + | } | ||
| + | |||
| + | #ifdef USE_GRAPH2 | ||
| + | static | ||
| + | FontID | ||
| + | ZamaFontSelect(FontID curFont_) | ||
| + | { | ||
| + | FormPtr | ||
| + | UInt16 | ||
| + | Coord x, y; | ||
| + | WinHandle | ||
| + | RectangleType bounds; | ||
| + | FontID | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | formP = FrmInitForm(ZAMA_FONT_FORM); | ||
| + | GGetDisplayExtent(& | ||
| + | if (y > 160) { | ||
| + | /* silk turned off */ | ||
| + | hWin = FrmGetWindowHandle(formP); | ||
| + | WinGetBounds(hWin, | ||
| + | bounds.topLeft.y += stdSilkHeight; | ||
| + | if (bounds.topLeft.y + bounds.extent.y >= y) { | ||
| + | bounds.topLeft.y = y - bounds.extent.y; | ||
| + | } | ||
| + | WinSetBounds(hWin, | ||
| + | } | ||
| + | small = FrmGetObjectIndex(formP, | ||
| + | font = curFont_; | ||
| + | if (font & fntAppFontCustomBase) { | ||
| + | font -= fntAppFontCustomBase; | ||
| + | CtlSetValue(FrmGetObjectPtr(formP, | ||
| + | } | ||
| + | switch (font) { | ||
| + | case stdFont: | ||
| + | case boldFont: | ||
| + | case largeFont: | ||
| + | case largeBoldFont: | ||
| + | default: | ||
| + | CtlSetValue(FrmGetObjectPtr(formP, | ||
| + | if (font == z-> | ||
| + | fnt = ZAMA_STD_FONT; | ||
| + | } else if (font == z-> | ||
| + | fnt = ZAMA_BOLD_FONT; | ||
| + | } else if (font == z-> | ||
| + | fnt = ZAMA_LARGE_FONT; | ||
| + | } else if (font == z-> | ||
| + | fnt = ZAMA_LARGE_BOLD_FONT; | ||
| + | } else { | ||
| + | fnt = ZAMA_STD_FONT; | ||
| + | } | ||
| + | break; | ||
| + | } | ||
| + | fnt = FrmGetObjectIndex(formP, | ||
| + | CtlSetValue(FrmGetObjectPtr(formP, | ||
| + | FrmUpdateForm(ZAMA_FONT_FORM, | ||
| + | ret = FrmDoDialog(formP); | ||
| + | fnt = FrmGetControlGroupSelection(formP, | ||
| + | if (fnt == frmNoSelectedControl) { | ||
| + | ret = ZAMA_BUTTON_CANCEL; | ||
| + | } | ||
| + | if (fnt == FrmGetObjectIndex(formP, | ||
| + | fnt = stdFont; | ||
| + | } else if (fnt == FrmGetObjectIndex(formP, | ||
| + | fnt = boldFont; | ||
| + | } else if (fnt == FrmGetObjectIndex(formP, | ||
| + | fnt = largeFont; | ||
| + | } else if (fnt == FrmGetObjectIndex(formP, | ||
| + | fnt = largeBoldFont; | ||
| + | } else { | ||
| + | ret = ZAMA_BUTTON_CANCEL; | ||
| + | } | ||
| + | if (CtlGetValue(FrmGetObjectPtr(formP, | ||
| + | if (z-> | ||
| + | switch (fnt) { | ||
| + | case stdFont: | ||
| + | case boldFont: | ||
| + | case largeFont: | ||
| + | case largeBoldFont: | ||
| + | } | ||
| + | } else { | ||
| + | fnt += fntAppFontCustomBase; | ||
| + | } | ||
| + | } | ||
| + | FrmDeleteForm(formP); | ||
| + | return (ret == ZAMA_BUTTON_OK) ? fnt : curFont_; | ||
| + | } | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | ZamaSndPlay(UInt16 id) | ||
| + | { | ||
| + | UInt16 | ||
| + | Err err; | ||
| + | Char *pathFmt = = "/ | ||
| + | Char pathName[1024]; | ||
| + | FileRef dbFileRef; | ||
| + | UInt32 | ||
| + | SndPtr | ||
| + | UInt32 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | if (z-> | ||
| + | /* play sound */ | ||
| + | StrPrintF(pathName, | ||
| + | vIterator = vfsIteratorStart; | ||
| + | err = VFSVokumeEnumerate(& | ||
| + | if (err != errNone) { | ||
| + | return false; | ||
| + | } | ||
| + | if (VFSFileOpen(volRefNum, | ||
| + | return false; | ||
| + | } | ||
| + | VFSFileSize(dbFileRef, | ||
| + | } | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | VOSplit(Char *srcP_) | ||
| + | { | ||
| + | Char *p; | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | StrCopy(z-> | ||
| + | StrCopy(z-> | ||
| + | for (p = srcP_ ; *p && *p == ' ' ; p++); /* skip heading space */ | ||
| + | for (i = 0 ; *p && *p != ' ' && i < 4 ; i++) { | ||
| + | z-> | ||
| + | } | ||
| + | for ( ; *p && *p != ' ' ; p++); /* skip until space */ | ||
| + | for ( ; *p && *p == ' ' ; p++); /* skip space */ | ||
| + | for (i = 0 ; *p && *p != ' ' && i < 4 ; i++) { | ||
| + | z-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static | ||
| + | UInt16 | ||
| + | SearchWord(Char *word_, Boolean verb_) | ||
| + | { | ||
| + | DmOpenRef | ||
| + | MemHandle | ||
| + | ZamaWordPtr p; | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | |||
| + | if (word_ == NULL || StrCompare(" | ||
| + | return 0; | ||
| + | } | ||
| + | if ((dbP = OpenDatabase(" | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | return 0; | ||
| + | } | ||
| + | index = (verb_) ? 0 : 1; | ||
| + | n = 0; | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | goto _done; | ||
| + | } | ||
| + | p = (ZamaWordPtr)MemHandleLock(rec); | ||
| + | for (i = 0 ; p[i].word[0] ; i++) { | ||
| + | if (StrNCaselessCompare(word_, | ||
| + | n = p[i].number; | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | MemHandleUnlock(rec); | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return n; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | MemHandle | ||
| + | SearchFixedMessage(UInt16 mesgId_) | ||
| + | { | ||
| + | ZamaMesgPtr | ||
| + | UInt16 | ||
| + | DmOpenRef | ||
| + | MemHandle | ||
| + | ZamaMesgPtr | ||
| + | |||
| + | if ((dbP = OpenDatabase(" | ||
| + | /* error */ | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | return 0; | ||
| + | } | ||
| + | mesg = 0; | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | goto _done; | ||
| + | } | ||
| + | mesgId_ &= 0x7f; | ||
| + | p = (ZamaMesgPtr)MemHandleLock(rec); | ||
| + | for (i = 0 ; p->len > 0 && i < mesgId_ - 1 ; i++) { | ||
| + | p = (ZamaMesgPtr)(p-> | ||
| + | } | ||
| + | if (p && p->len) { | ||
| + | mesg = MemHandleNew(sizeof(ZamaMesgType) + p->len - 1); | ||
| + | mesgP = (ZamaMesgPtr)MemHandleLock(mesg); | ||
| + | MemMove(mesgP, | ||
| + | MemHandleUnlock(mesg); | ||
| + | } | ||
| + | |||
| + | MemHandleUnlock(rec); | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return mesg; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | MemHandle | ||
| + | SearchMapMessage(UInt16 cmdN_, UInt16 objN_) | ||
| + | { | ||
| + | ZamaMesgPtr | ||
| + | int i; | ||
| + | int n = 0; | ||
| + | ZamaReactionType mp; | ||
| + | UInt8 *rp = map.reaction; | ||
| + | MemHandle | ||
| + | ZamaMesgPtr | ||
| + | |||
| + | cmdN_ = (cmdN_ << 8) | objN_; | ||
| + | for (i = 0 ; *rp ; i++) { | ||
| + | mp.action = (rp[0] << 8) | rp[1]; | ||
| + | mp.number = rp[2]; | ||
| + | if (cmdN_ == mp.action) { | ||
| + | p = (ZamaMesgPtr)map.mesg; | ||
| + | for (n = 0 ; p->len > 0 && n < mp.number - 1 ; n++) { | ||
| + | p = (ZamaMesgPtr)(p-> | ||
| + | } | ||
| + | break; | ||
| + | } | ||
| + | rp += 3; | ||
| + | } | ||
| + | mesg = 0; | ||
| + | if (p && p->len) { | ||
| + | mesg = MemHandleNew(sizeof(ZamaMesgType) + p->len - 1); | ||
| + | mesgP = (ZamaMesgPtr)MemHandleLock(mesg); | ||
| + | MemMove(mesgP, | ||
| + | MemHandleUnlock(mesg); | ||
| + | } else { | ||
| + | cmdN_ >>= 8; /* restore Command ID */ | ||
| + | i = 0; | ||
| + | if (cmdN_ <= 0x0e && cmdN_ >= 0x0b) { | ||
| + | i = cmdN_ - 8; | ||
| + | } else if (cmdN_ == 7 || cmdN_ == 8) { | ||
| + | i = cmdN_ - 6; | ||
| + | } else if (cmdN_ >= 0x11 && cmdN_ <= 0x18) { | ||
| + | i = cmdN_ - 9; | ||
| + | } else if (cmdN_ == 0x1c || cmdN_ == 0x1d) { | ||
| + | i = cmdN_ - 12; | ||
| + | } else if (cmdN_ == 0x20 || cmdN_ == 0x21) { | ||
| + | i = cmdN_ - 14; | ||
| + | } else if (cmdN_ == 0x26) { | ||
| + | i = 0x14; | ||
| + | } else if (cmdN_ == 0x28 || cmdN_ == 0x2f) { | ||
| + | i = 0x15; | ||
| + | } else if (cmdN_ == 0x29) { | ||
| + | i = 7; | ||
| + | } else if (objN_ == 0) { | ||
| + | i = 0x30 + (SysRandom(0) % 4); | ||
| + | } | ||
| + | if (i) { | ||
| + | mesg = SearchFixedMessage(i); | ||
| + | } | ||
| + | } | ||
| + | return mesg; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | ScrollMessageField(void) | ||
| + | { | ||
| + | Int16 lines, pos, min, max, page; | ||
| + | UInt16 | ||
| + | FieldPtr | ||
| + | ScrollBarPtr scrP; | ||
| + | fldP = GetObjectPtr(ZAMA_MESSAGE_FIELD); | ||
| + | scrP = GetObjectPtr(ZAMA_SCROLL_BAR); | ||
| + | SclGetScrollBar(scrP, | ||
| + | FldGetScrollValues(fldP, | ||
| + | lines = (pos - scrollPos) /** GScale()*/; | ||
| + | if (lines > 0) { | ||
| + | FldScrollField(fldP, | ||
| + | } else if (lines < 0) { | ||
| + | FldScrollField(fldP, | ||
| + | } | ||
| + | FldSetDirty(fldP, | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (tsPatch) { | ||
| + | FldDrawField(fldP); | ||
| + | } else { | ||
| + | GFldDrawField(fldP); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(fldP); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | UpdateMessageFieldScrollbar(void) | ||
| + | { | ||
| + | UInt16 | ||
| + | Int16 maxValue; | ||
| + | FieldPtr | ||
| + | ScrollBarPtr scrP; | ||
| + | |||
| + | fldP = GetObjectPtr(ZAMA_MESSAGE_FIELD); | ||
| + | scrP = GetObjectPtr(ZAMA_SCROLL_BAR); | ||
| + | maxValue = 0; | ||
| + | FldGetScrollValues(fldP,& | ||
| + | /* fieldHeight *= GScale(); */ | ||
| + | if (textHeight > fieldHeight) { | ||
| + | maxValue = (textHeight - fieldHeight) + FldGetNumberOfBlankLines(fldP); | ||
| + | } else if (scrollPos) { | ||
| + | maxValue = scrollPos; | ||
| + | } | ||
| + | SclSetScrollBar(scrP, | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | CleanMessageField(void) | ||
| + | { | ||
| + | FieldPtr | ||
| + | MemHandle hText; | ||
| + | |||
| + | fldP = GetObjectPtr(ZAMA_MESSAGE_FIELD); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (tsPatch) { | ||
| + | FldEraseField(fldP); | ||
| + | } else { | ||
| + | GFldEraseField(fldP); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldEraseField(fldP); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | if ((hText = FldGetTextHandle(fldP)) != NULL) { | ||
| + | FldSetTextHandle(fldP, | ||
| + | MemHandleFree(hText); | ||
| + | FldSetDirty(fldP, | ||
| + | } | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (tsPatch) { | ||
| + | FldDrawField(fldP); | ||
| + | } else { | ||
| + | GFldDrawField(fldP); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(fldP); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | PutMessageToField(Char *strP_, UInt16 len_) | ||
| + | { | ||
| + | FieldPtr | ||
| + | MemHandle | ||
| + | Char *textP; | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | fldP = GetObjectPtr(ZAMA_MESSAGE_FIELD); | ||
| + | max = FldGetTextLength(fldP); | ||
| + | hText = FldGetTextHandle(fldP); | ||
| + | FldSetTextHandle(fldP, | ||
| + | if (hText == NULL) { | ||
| + | hText = MemHandleNew(len_ + 1); | ||
| + | textP = MemHandleLock(hText); | ||
| + | } else { | ||
| + | MemHandleResize(hText, | ||
| + | textP = MemHandleLock(hText); | ||
| + | textP[max++] = ' | ||
| + | textP[max] | ||
| + | } | ||
| + | MemMove(& | ||
| + | textP[max + len_] = 0; | ||
| + | MemHandleUnlock(hText); | ||
| + | |||
| + | FldSetTextHandle(fldP, | ||
| + | FldSetDirty(fldP, | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (z-> | ||
| + | FldDrawField(fldP); | ||
| + | } else { | ||
| + | GFldDrawField(fldP); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(fldP); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | DrawMessage(UInt16 mesgId_, UInt16 cmdN_, UInt16 objN_) | ||
| + | { | ||
| + | Char *strP; | ||
| + | UInt16 | ||
| + | MemHandle | ||
| + | ZamaMesgPtr | ||
| + | |||
| + | if (mesgId_ & 0x80) { | ||
| + | mesg = SearchFixedMessage(mesgId_ & 0x7f); | ||
| + | } else { | ||
| + | if (mesgId_ == 1) { | ||
| + | mesgP = (ZamaMesgPtr)map.mesg; | ||
| + | mesg = MemHandleNew(sizeof(ZamaMesgType) + mesgP-> | ||
| + | MemMove(MemHandleLock(mesg), | ||
| + | MemHandleUnlock(mesg); | ||
| + | } else { | ||
| + | mesg = SearchMapMessage(cmdN_, | ||
| + | } | ||
| + | } | ||
| + | strP = " | ||
| + | len = StrLen(strP); | ||
| + | if (mesg) { | ||
| + | mesgP = (ZamaMesgPtr)MemHandleLock(mesg); | ||
| + | strP = mesgP-> | ||
| + | len = mesgP-> | ||
| + | } | ||
| + | PutMessageToField(strP, | ||
| + | if (mesg) { | ||
| + | MemHandleUnlock(mesg); | ||
| + | MemHandleFree(mesg); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | LoadInitData(void) | ||
| + | { | ||
| + | DmOpenRef dbP; | ||
| + | MemHandle rec; | ||
| + | MemPtr | ||
| + | Boolean | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((dbP = OpenDatabase(" | ||
| + | /* error */ | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | return false; | ||
| + | } | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = (MemPtr)MemHandleLock(rec); | ||
| + | MemMove(& | ||
| + | MemHandleUnlock(rec); | ||
| + | |||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = (MemPtr)MemHandleLock(rec); | ||
| + | MemMove(& | ||
| + | MemHandleUnlock(rec); | ||
| + | |||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = (MemPtr)MemHandleLock(rec); | ||
| + | MemMove(& | ||
| + | MemHandleUnlock(rec); | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return res; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | LoadMapData(UInt16 id) | ||
| + | { | ||
| + | DmOpenRef dbP; | ||
| + | MemHandle rec; | ||
| + | MemPtr | ||
| + | Boolean | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((dbP = OpenDatabase(" | ||
| + | /* error */ | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | return false; | ||
| + | } | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = (MemPtr)MemHandleLock(rec); | ||
| + | MemMove(& | ||
| + | MemHandleUnlock(rec); | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | LoadObjectData(UInt16 id) | ||
| + | { | ||
| + | DmOpenRef dbP; | ||
| + | MemHandle rec; | ||
| + | MemPtr | ||
| + | Boolean | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((dbP = OpenDatabase(" | ||
| + | /* error */ | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | return false; | ||
| + | } | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | res = false; | ||
| + | goto _done; | ||
| + | } | ||
| + | p = (MemPtr)MemHandleLock(rec); | ||
| + | MemMove(z-> | ||
| + | MemHandleUnlock(rec); | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | UInt16 | ||
| + | WinDrawOutline(RectanglePtr bP, UInt8 *data, | ||
| + | #ifdef USE_GRAPH2 | ||
| + | | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | ) | ||
| + | { | ||
| + | Coord x0, y0, x1, y1; | ||
| + | UInt16 i = 0; | ||
| + | |||
| + | x0 = data[i++]; | ||
| + | y0 = data[i++]; | ||
| + | for (;;) { | ||
| + | x1 = data[i++]; | ||
| + | y1 = data[i++]; | ||
| + | if (y1 == 0xff) { | ||
| + | if (x1 == 0xff) { | ||
| + | /* end of line data */ | ||
| + | break; | ||
| + | } | ||
| + | /* reset line */ | ||
| + | x0 = data[i++]; | ||
| + | y0 = data[i++]; | ||
| + | continue; | ||
| + | } | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | bP-> | ||
| + | bP-> | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(bP-> | ||
| + | | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | x0 = x1; y0 = y1; | ||
| + | } | ||
| + | return i; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | DrawObject(Boolean pre, UInt8 *data) | ||
| + | { | ||
| + | UInt16 | ||
| + | Coord xs, ys; | ||
| + | UInt8 b, c; | ||
| + | RectangleType | ||
| + | |||
| + | b = data[o++]; | ||
| + | xs = (data[o++] / 2) + 32; | ||
| + | ys = data[o++] + 32; | ||
| + | RctSetRectangle(& | ||
| + | WinPushDrawState(); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | o += WinDrawOutline(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | o += WinDrawOutline(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | xs = data[o++]; | ||
| + | ys = data[o++]; | ||
| + | while (xs != 0xff || ys != 0xff) { | ||
| + | c = data[o++]; | ||
| + | /* in order to avoid paint loss */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaint(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaint(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | xs = data[o++]; | ||
| + | ys = data[o++]; | ||
| + | } | ||
| + | WinPopDrawState(); | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | ObjectCheck(UInt16 mapID, Boolean msgOut) | ||
| + | { | ||
| + | int i; | ||
| + | int o = 0; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | for (i = 0 ; i < 12 ; i++) { | ||
| + | if (z-> | ||
| + | /* draw object bitmap */ | ||
| + | o = 0; | ||
| + | if (i == 1 /* Uniform */) { | ||
| + | o = (z-> | ||
| + | } | ||
| + | DrawObject(true, | ||
| + | DrawObject(false, | ||
| + | if (msgOut) DrawMessage(0x96 + i, 0, 0); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | DrawTeacher(void) | ||
| + | { | ||
| + | Coord x0, y0, x1, y1, oy; | ||
| + | UInt16 | ||
| + | UInt8 c = 0; | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | RectangleType | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | oy = 32; | ||
| + | if (LoadObjectData(15)) { | ||
| + | RctSetRectangle(& | ||
| + | y0 = 63; | ||
| + | for (i = 0 ; i <= 172 ; i += 2) { | ||
| + | x0 = z-> | ||
| + | x1 = z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(x0, | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | ++y0; | ||
| + | } | ||
| + | for (j = 0 ; rep[j] != 0xffff ; j++) { | ||
| + | #ifdef USE_GRAPH2 | ||
| + | c = z-> | ||
| + | if (c == gColorRed) { | ||
| + | c = gColorDarkRed; | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | c = z-> | ||
| + | if (c == Red) { | ||
| + | c = DarkRed; | ||
| + | } | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | x0 = z-> | ||
| + | y0 = z-> | ||
| + | for (k = 0 ; k <= rep[j] + 1 ; k++) { | ||
| + | x1 = z-> | ||
| + | y1 = z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(x0, | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | x0 = x1; | ||
| + | y0 = y1; | ||
| + | } | ||
| + | x0 = z-> | ||
| + | y0 = z-> | ||
| + | WinPushDrawState(); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaint(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaint(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | WinPopDrawState(); | ||
| + | } | ||
| + | x0 = z-> | ||
| + | y0 = z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaint(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaint(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | for (j = 120 ; j < 124 ; j++) { | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(j, | ||
| + | ZamaDrawLine(j + 9, oy + 110, j + 11, oy + 126, White); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | GPaint(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(125, | ||
| + | ZamaDrawLine(133, | ||
| + | ZamaDrawLine(134, | ||
| + | ZamaDrawLine(125, | ||
| + | ZamaDrawLine(120, | ||
| + | ZamaDrawLine(123, | ||
| + | ZamaDrawLine(121, | ||
| + | ZamaPaint(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | for (k = 0 ; rep2[k + 1] != 0 ; k += 2) { | ||
| + | for (j = 0, x0 = rep2[k] ; j < rep2[k + 1] ; j += 2) { | ||
| + | y0 = z-> | ||
| + | y1 = z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | GDrawLine(NULL, | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(x0, | ||
| + | ZamaDrawLine(x0, | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | y0 = z-> | ||
| + | y1 = z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(x0, | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | #ifdef USE_GRAPH2 | ||
| + | RctSetRectangle(& | ||
| + | GDrawRectangle(& | ||
| + | RctSetRectangle(& | ||
| + | GDrawRectangle(& | ||
| + | RctSetRectangle(& | ||
| + | GDrawRectangle(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | RctSetRectangle(& | ||
| + | ZamaDrawRectangle(& | ||
| + | RctSetRectangle(& | ||
| + | ZamaDrawRectangle(& | ||
| + | RctSetRectangle(& | ||
| + | ZamaDrawRectangle(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | |||
| + | for (;;) { | ||
| + | x1 = z-> | ||
| + | y1 = z-> | ||
| + | if (y1 == 0xff) { | ||
| + | if (x1 == 0xff) { | ||
| + | break; | ||
| + | } | ||
| + | x0 = z-> | ||
| + | y0 = z-> | ||
| + | continue; | ||
| + | } | ||
| + | |||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawLine(NULL, | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawLine(x0, | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | x0 = x1; | ||
| + | y0 = y1; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | CleanMap( | ||
| + | #ifdef USE_GRAPH2 | ||
| + | | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | ) | ||
| + | { | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GDrawRectangle(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaDrawRectangle(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | DrawMap(Boolean putMesg_) | ||
| + | { | ||
| + | UInt16 | ||
| + | Coord x0, y0; | ||
| + | UInt8 c; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | WinPushDrawState(); | ||
| + | i += z-> | ||
| + | |||
| + | if (z-> | ||
| + | if (z-> | ||
| + | /* never draw */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | CleanMap(gColorBlack); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | CleanMap(Black); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | DrawMessage(0xcc, | ||
| + | goto _done; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | #ifdef USE_GRAPH2 | ||
| + | CleanMap(gColorBlue); | ||
| + | /* draw outline */ | ||
| + | i += WinDrawOutline(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | CleanMap(Blue); | ||
| + | /* draw outline */ | ||
| + | i += WinDrawOutline(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | /* paint */ | ||
| + | x0 = z-> | ||
| + | y0 = z-> | ||
| + | while (x0 != 0xff || y0 != 0xff) { | ||
| + | c = z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaint(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaint(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | x0 = z-> | ||
| + | y0 = z-> | ||
| + | } | ||
| + | if (z-> | ||
| + | i += 2; | ||
| + | } else { | ||
| + | #ifdef USE_GRAPH2 | ||
| + | i += WinDrawOutline(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | i += WinDrawOutline(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | if (z-> | ||
| + | i += 2; | ||
| + | } else { | ||
| + | #ifdef USE_GRAPH2 | ||
| + | i += WinDrawOutline(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | i += WinDrawOutline(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | if (z-> | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GChromakeyPaint(& | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaChromakeyPaint(& | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | /* put message #0 */ | ||
| + | if (putMesg_) DrawMessage(1, | ||
| + | | ||
| + | WinPopDrawState(); | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | GameInit(void) | ||
| + | { | ||
| + | FormPtr | ||
| + | ControlPtr btnP, chkP; | ||
| + | FieldPtr | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | z-> | ||
| + | switch (z-> | ||
| + | case ZAMA_CODE_ISAKO: | ||
| + | default: break; | ||
| + | } | ||
| + | |||
| + | formP = FrmGetActiveForm(); | ||
| + | btnP = GetObjectPtr(ZAMA_BUTTON_START); | ||
| + | fldP = GetObjectPtr(ZAMA_COMMAND_FIELD); | ||
| + | chkP = GetObjectPtr(ZAMA_CONTINUE); | ||
| + | |||
| + | FldEraseField(fldP); | ||
| + | FldSetUsable(fldP, | ||
| + | CtlSetUsable(btnP, | ||
| + | CtlShowControl(btnP); | ||
| + | CtlSetUsable(chkP, | ||
| + | CtlSetValue(chkP, | ||
| + | if (z-> | ||
| + | CtlShowControl(chkP); | ||
| + | } | ||
| + | |||
| + | FrmDrawForm(formP); | ||
| + | CleanMessageField(); | ||
| + | LoadMapData(z-> | ||
| + | DrawMap(false); | ||
| + | PutMessageToField(" | ||
| + | PutMessageToField(" | ||
| + | PutMessageToField(" | ||
| + | z-> | ||
| + | z->_over = true; /* not yet started */ | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | GameOver(void) | ||
| + | { | ||
| + | FormPtr | ||
| + | ControlPtr btnP, chkP; | ||
| + | FieldPtr | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | formP = FrmGetActiveForm(); | ||
| + | btnP = GetObjectPtr(ZAMA_BUTTON_START); | ||
| + | fldP = GetObjectPtr(ZAMA_COMMAND_FIELD); | ||
| + | chkP = GetObjectPtr(ZAMA_CONTINUE); | ||
| + | |||
| + | z-> | ||
| + | |||
| + | FldEraseField(fldP); | ||
| + | FldSetUsable(fldP, | ||
| + | CtlSetUsable(btnP, | ||
| + | CtlShowControl(btnP); | ||
| + | CtlSetUsable(chkP, | ||
| + | CtlSetValue(chkP, | ||
| + | |||
| + | z->_over = true; | ||
| + | } | ||
| + | |||
| + | inline UInt8 | ||
| + | getCond(UInt16 type_, UInt16 id_, UInt16 offset_) | ||
| + | { | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | UInt8 value; | ||
| + | switch (type_) { | ||
| + | case 0: value = 0; break; | ||
| + | case 1: value = z-> | ||
| + | case 2: value = z-> | ||
| + | case 3: value = z-> | ||
| + | case 4: value = z-> | ||
| + | case 5: | ||
| + | case 6: | ||
| + | case 7: | ||
| + | default: value = 0; break; | ||
| + | } | ||
| + | return value; | ||
| + | } | ||
| + | |||
| + | inline void | ||
| + | setStat(UInt16 type_, UInt16 id_, UInt16 offset_, UInt8 value_) | ||
| + | { | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | switch (type_) { | ||
| + | case 0: break; | ||
| + | case 1: z-> | ||
| + | case 2: z-> | ||
| + | case 3: z-> | ||
| + | case 4: z-> | ||
| + | case 5: | ||
| + | case 6: | ||
| + | case 7: | ||
| + | default: break; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static Boolean SexHandleEvent(EventPtr); | ||
| + | static Boolean FileHandleEvent(EventPtr); | ||
| + | static Boolean InvHandleEvent(EventPtr); | ||
| + | static Boolean CutHandleEvent(EventPtr); | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | DialogHandler(UInt16 id_) | ||
| + | { | ||
| + | FormPtr | ||
| + | UInt16 | ||
| + | Boolean | ||
| + | ControlPtr | ||
| + | Coord x, y; | ||
| + | RectangleType bounds; | ||
| + | WinHandle | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | do { | ||
| + | formP = FrmInitForm(id_); | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | SilkLibDisableResize(z-> | ||
| + | } else { | ||
| + | VskSetState(z-> | ||
| + | } | ||
| + | WinGetDisplayExtent(& | ||
| + | if (y > 160) { | ||
| + | hWin = FrmGetWindowHandle(formP); | ||
| + | WinGetBounds(hWin, | ||
| + | bounds.topLeft.y += stdSilkHeight; | ||
| + | WinSetBounds(hWin, | ||
| + | } | ||
| + | } | ||
| + | switch(id_) { | ||
| + | case ZAMA_SEX_FORM: | ||
| + | | ||
| + | break; | ||
| + | case ZAMA_FILE_FORM: | ||
| + | FrmSetEventHandler(formP, | ||
| + | if (z-> | ||
| + | ret = FrmGetObjectIndex(formP, | ||
| + | chkP = FrmGetObjectPtr(formP, | ||
| + | CtlSetValue(chkP, | ||
| + | } | ||
| + | FrmDrawForm(formP); | ||
| + | break; | ||
| + | case ZAMA_INV_FORM: | ||
| + | FrmSetEventHandler(formP, | ||
| + | FrmEraseForm(formP); | ||
| + | for (ret = 0 ; ret < ZAMA_ITEM_NUMBERS ; ret++) { | ||
| + | if (z-> | ||
| + | FrmShowObject(formP, | ||
| + | } else { | ||
| + | FrmHideObject(formP, | ||
| + | } | ||
| + | } | ||
| + | FrmDrawForm(formP); | ||
| + | break; | ||
| + | case ZAMA_CUT_FORM: | ||
| + | FrmSetEventHandler(formP, | ||
| + | break; | ||
| + | } | ||
| + | z-> | ||
| + | z-> | ||
| + | ret = FrmDoDialog(formP); | ||
| + | if (z-> | ||
| + | CleanMessageField(); | ||
| + | DrawMessage(user.sys.n.dmesg, | ||
| + | } | ||
| + | FrmDeleteForm(formP); | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | SilkLibEnableResize(z-> | ||
| + | } else { | ||
| + | VskSetState(z-> | ||
| + | } | ||
| + | } | ||
| + | } while (!z-> | ||
| + | if (z-> | ||
| + | CleanMessageField(); | ||
| + | } | ||
| + | switch (id_) { | ||
| + | case ZAMA_SEX_FORM: | ||
| + | z-> | ||
| + | redraw = true; | ||
| + | break; | ||
| + | case ZAMA_FILE_FORM: | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | SaveGame(z-> | ||
| + | } else { | ||
| + | redraw = LoadGame(z-> | ||
| + | if (redraw) { | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorInvalid); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(InvalidColor); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | break; | ||
| + | case ZAMA_INV_FORM: | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (z-> | ||
| + | FldDrawField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | } else { | ||
| + | GFldDrawField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | break; | ||
| + | case ZAMA_CUT_FORM: | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | DrawMessage(0xe0, | ||
| + | } | ||
| + | /* color change to red */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorRed); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(Red); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | DrawMessage(0xc7, | ||
| + | GameOver(); | ||
| + | } else { | ||
| + | /* correctly choosen */ | ||
| + | z-> | ||
| + | z-> | ||
| + | ZamaSndPlay(3); | ||
| + | redraw = true; | ||
| + | } | ||
| + | break; | ||
| + | } | ||
| + | return redraw; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | DarknessCheck(void) | ||
| + | { | ||
| + | Boolean redraw = false; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | if (z-> | ||
| + | if ((z-> | ||
| + | (z-> | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | /* semi-blue out */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorBlue); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(Blue); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | } else { | ||
| + | z-> | ||
| + | z-> | ||
| + | redraw = true; | ||
| + | } | ||
| + | } else { | ||
| + | if (z-> | ||
| + | /* normal state */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorInvalid); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(InvalidColor); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | return redraw; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | RuleInterpreter(UInt16 cmdN_, UInt16 objN_) | ||
| + | { | ||
| + | Boolean | ||
| + | UInt16 | ||
| + | RulePtr | ||
| + | CmdBlkPtr | ||
| + | UInt16 | ||
| + | DmOpenRef | ||
| + | MemHandle | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | res = false; | ||
| + | if ((dbP = OpenDatabase(" | ||
| + | /* error */ | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | return false; | ||
| + | } | ||
| + | if ((rec = DmQueryRecord(dbP, | ||
| + | FrmCustomAlert(ZAMA_FATAL_ALERT, | ||
| + | goto _done; | ||
| + | } | ||
| + | rule = (RulePtr)MemHandleLock(rec); | ||
| + | |||
| + | for (i = 0 ; rule[i]._mapId != EndOfRule ; i++) { | ||
| + | if (rule[i]._mapId && rule[i]._mapId != z-> | ||
| + | if (rule[i]._cmdN | ||
| + | if (rule[i]._objN | ||
| + | /* check condition block */ | ||
| + | ok = true; | ||
| + | for (blk = (CmdBlkPtr)rule[i]._args ; blk-> | ||
| + | v1 = getCond(blk-> | ||
| + | | ||
| + | if (blk-> | ||
| + | z-> | ||
| + | } | ||
| + | v2 = blk-> | ||
| + | if (blk-> | ||
| + | v2 = getCond(blk-> | ||
| + | if (blk-> | ||
| + | z-> | ||
| + | } | ||
| + | } | ||
| + | switch (blk-> | ||
| + | case CMP_EQ: ok = ok && (v1 == v2); break; | ||
| + | case CMP_NE: ok = ok && (v1 != v2); break; | ||
| + | case CMP_GT: ok = ok && (v1 > v2); break; | ||
| + | case CMP_GE: ok = ok && (v1 >= v2); break; | ||
| + | case CMP_LT: ok = ok && (v1 < v2); break; | ||
| + | case CMP_LE: ok = ok && (v1 <= v2); break; | ||
| + | default: | ||
| + | ok = false; /* no defalut operation is defined */ | ||
| + | } | ||
| + | if (!ok) break; /* short circuit */ | ||
| + | } | ||
| + | if (ok) break; | ||
| + | } | ||
| + | if (ok) { | ||
| + | /* do action */ | ||
| + | redraw = false; | ||
| + | ok = false; | ||
| + | for ( ; blk-> | ||
| + | switch (blk-> | ||
| + | case ACT_MOVE: | ||
| + | if (z-> | ||
| + | /* moveable */ | ||
| + | z-> | ||
| + | z-> | ||
| + | redraw = true; | ||
| + | res = true; | ||
| + | } else { | ||
| + | /* teacher check */ | ||
| + | if (z-> | ||
| + | /* teacher catches you */ | ||
| + | DrawMessage(0xb5, | ||
| + | /* game over */ | ||
| + | z-> | ||
| + | GameOver(); | ||
| + | res = true; | ||
| + | } else { | ||
| + | /* you cannot move */ | ||
| + | DrawMessage(0xb6, | ||
| + | } | ||
| + | z-> | ||
| + | res = true; | ||
| + | } | ||
| + | break; | ||
| + | case ACT_ASGN: | ||
| + | v1 = (blk-> | ||
| + | v2 = blk-> | ||
| + | if (blk-> | ||
| + | v2 = getCond(blk-> | ||
| + | } | ||
| + | setStat(blk-> | ||
| + | if (blk-> | ||
| + | if (blk-> | ||
| + | if (v2 == 0xff) { | ||
| + | redraw = true; | ||
| + | } else { | ||
| + | ObjectCheck(z-> | ||
| + | } | ||
| + | } | ||
| + | ok = true; | ||
| + | } else if(blk-> | ||
| + | if (blk-> | ||
| + | redraw = true; | ||
| + | } else if (blk-> | ||
| + | z-> | ||
| + | } | ||
| + | } | ||
| + | res = true; | ||
| + | break; | ||
| + | case ACT_MESG: | ||
| + | DrawMessage(blk-> | ||
| + | res = true; | ||
| + | break; | ||
| + | case ACT_DLOG: | ||
| + | redraw = DialogHandler(ZAMA_DIALOG_BASE + blk-> | ||
| + | res = true; | ||
| + | break; | ||
| + | case ACT_LOOK: | ||
| + | if (blk-> | ||
| + | z-> | ||
| + | z-> | ||
| + | } else { | ||
| + | z-> | ||
| + | z-> | ||
| + | } | ||
| + | redraw = true; | ||
| + | res = true; | ||
| + | break; | ||
| + | case ACT_SND: | ||
| + | ZamaSndPlay(blk-> | ||
| + | break; | ||
| + | case ACT_OVER: | ||
| + | ok = false; | ||
| + | switch(blk-> | ||
| + | case 0: /* simply put dialog */ | ||
| + | z-> | ||
| + | PutMessageToField(" | ||
| + | break; | ||
| + | case 1: /* screen to red */ | ||
| + | PutMessageToField(" | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorRed); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(Red); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | break; | ||
| + | case 2: /* game clear */ | ||
| + | PutMessageToField(" | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorInvalid); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(InvalidColor); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | FrmHelp(ZAMA_CREDIT_STR); | ||
| + | break; | ||
| + | } | ||
| + | GameOver(); | ||
| + | res = true; | ||
| + | break; | ||
| + | default: | ||
| + | /* error */ | ||
| + | res = false; | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | if (ok) { | ||
| + | PutMessageToField(" | ||
| + | } | ||
| + | if (z-> | ||
| + | switch (++z-> | ||
| + | case 4: | ||
| + | case 6: | ||
| + | case 10: DrawMessage(0xe4, | ||
| + | default: | ||
| + | } | ||
| + | } | ||
| + | redraw = DarknessCheck() || redraw; | ||
| + | if (redraw) { | ||
| + | LoadMapData(z-> | ||
| + | DrawMap(true); | ||
| + | ObjectCheck(z-> | ||
| + | } | ||
| + | } | ||
| + | MemHandleUnlock(rec); | ||
| + | | ||
| + | DmCloseDatabase(dbP); | ||
| + | return res; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | CommandLoop(void) | ||
| + | { | ||
| + | MemHandle | ||
| + | Char | ||
| + | UInt16 | ||
| + | FieldPtr | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((hStr = FldGetTextHandle(GetObjectPtr(ZAMA_COMMAND_FIELD))) == NULL) { | ||
| + | /* fail to get string */ | ||
| + | return false; | ||
| + | } | ||
| + | strP = (Char*)MemHandleLock(hStr); | ||
| + | end = StrLen(strP); | ||
| + | VOSplit(strP); | ||
| + | CleanMessageField(); | ||
| + | |||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | |||
| + | /* status check */ | ||
| + | if (z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | } | ||
| + | if (z-> | ||
| + | --z-> | ||
| + | if (z-> | ||
| + | z-> | ||
| + | DrawMessage(0xd9, | ||
| + | } | ||
| + | if (z-> | ||
| + | z-> | ||
| + | DrawMessage(0xc0, | ||
| + | } | ||
| + | } | ||
| + | if (z-> | ||
| + | --z-> | ||
| + | if (z-> | ||
| + | ZamaSndPlay(2); | ||
| + | DrawMessage(0xd8, | ||
| + | if (z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | DrawMessage(0xda, | ||
| + | } | ||
| + | if (z-> | ||
| + | /* explosion within the room where you are */ | ||
| + | /* change screen to red */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorRed); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(Red); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | DrawMessage(0xcf, | ||
| + | DrawMessage(0xcb, | ||
| + | /* game over */ | ||
| + | GameOver(); | ||
| + | goto _done; | ||
| + | } else { | ||
| + | z-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | if (z-> | ||
| + | DrawMessage(0xaf + z-> | ||
| + | goto _done; | ||
| + | } | ||
| + | if (! RuleInterpreter(z-> | ||
| + | DrawMessage(0, | ||
| + | } | ||
| + | |||
| + | /* teacher check */ | ||
| + | if (!z-> | ||
| + | rd = 100 + z-> | ||
| + | if (rd < SysRandom(0) % 3000) { | ||
| + | if (z-> | ||
| + | DrawMap(false); | ||
| + | } | ||
| + | z-> | ||
| + | } else { | ||
| + | z-> | ||
| + | } | ||
| + | } | ||
| + | if ((z-> | ||
| + | (z-> | ||
| + | | ||
| + | | ||
| + | | ||
| + | z-> | ||
| + | } | ||
| + | if (z-> | ||
| + | DrawTeacher(); | ||
| + | ZamaSndPlay(6); | ||
| + | DrawMessage(0xb4, | ||
| + | } | ||
| + | | ||
| + | MemHandleUnlock(hStr); | ||
| + | fldP = GetObjectPtr(ZAMA_COMMAND_FIELD); | ||
| + | FldDelete(fldP, | ||
| + | FldDrawField(fldP); | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | MainMenuEvent(EventPtr eventP) | ||
| + | { | ||
| + | Boolean | ||
| + | FormPtr | ||
| + | FontID | ||
| + | UInt16 | ||
| + | Coord x, y; | ||
| + | FieldPtr | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | fldP = GetObjectPtr(ZAMA_COMMAND_FIELD); | ||
| + | switch (eventP-> | ||
| + | case ZAMA_FONT_MENU: | ||
| + | /* menu select */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | id = ZamaFontSelect(prefs._curFont); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | id = ZamaFontSelect(prefs._curFont); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | if (z-> | ||
| + | z-> | ||
| + | fldP = GetObjectPtr(ZAMA_MESSAGE_FIELD); | ||
| + | FldSetFont(fldP, | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (tsPatch) { | ||
| + | FldDrawField(fldP); | ||
| + | } else { | ||
| + | GFldDrawField(fldP); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(fldP); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | } | ||
| + | handled = true; | ||
| + | break; | ||
| + | case ZAMA_PREF_MENU: | ||
| + | /* pop-up prefs dialog */ | ||
| + | dlogP = FrmInitForm(ZAMA_PREF_FORM); | ||
| + | lines = FrmGetObjectIndex(dlogP, | ||
| + | plane = FrmGetObjectIndex(dlogP, | ||
| + | /* sound */ | ||
| + | sound = FrmGetObjectIndex(dlogP, | ||
| + | if (z-> | ||
| + | WinGetDisplayExtent(& | ||
| + | if (y > 160) { | ||
| + | RectangleType bounds; | ||
| + | WinHandle | ||
| + | hWin = FrmGetWindowHandle(dlogP); | ||
| + | WinGetBounds(hWin, | ||
| + | bounds.topLeft.y += stdSilkHeight; | ||
| + | WinSetBounds(hWin, | ||
| + | } | ||
| + | } | ||
| + | #ifndef USE_GRAPH2 | ||
| + | if (!ZamaHR()) { | ||
| + | /* not support line draw mode */ | ||
| + | CtlSetUsable(FrmGetObjectPtr(dlogP, | ||
| + | z-> | ||
| + | } | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | CtlSetValue(FrmGetObjectPtr(dlogP, | ||
| + | CtlSetValue(FrmGetObjectPtr(dlogP, | ||
| + | CtlSetValue(FrmGetObjectPtr(dlogP, | ||
| + | if (FrmDoDialog(dlogP) == ZAMA_BUTTON_OK) { | ||
| + | /* change status */ | ||
| + | #ifndef USE_GRAPH2 | ||
| + | if (ZamaHR()) { | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | z-> | ||
| + | (FrmGetControlGroupSelection(dlogP, | ||
| + | #ifndef USE_GRAPH2 | ||
| + | } | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | z-> | ||
| + | } | ||
| + | FrmDeleteForm(dlogP); | ||
| + | handled = true; | ||
| + | break; | ||
| + | case ZAMA_HELP_CMD: | ||
| + | FrmHelp(ZAMA_HELP_STR); | ||
| + | break; | ||
| + | case ZAMA_ABOUT_CMD: | ||
| + | dlogP = FrmInitForm(ZAMA_FRM_ABOUT); | ||
| + | FrmDoDialog(dlogP); | ||
| + | FrmDeleteForm(dlogP); | ||
| + | break; | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | MainHeightChanged(EventPtr eventP) | ||
| + | { | ||
| + | RectangleType bounds; | ||
| + | FormPtr | ||
| + | WinHandle | ||
| + | Int16 dy; | ||
| + | Coord nx, ny; | ||
| + | UInt16 | ||
| + | FieldPtr | ||
| + | Boolean | ||
| + | UInt16 | ||
| + | ZAMA_COMMAND_LABEL, | ||
| + | ZAMA_BUTTON_START, | ||
| + | ZAMA_CONTINUE, | ||
| + | 0 | ||
| + | }; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | formP = FrmGetActiveForm(); | ||
| + | hWin = FrmGetWindowHandle(formP); | ||
| + | WinGetBounds(hWin, | ||
| + | WinGetDisplayExtent(& | ||
| + | if (ny == bounds.topLeft.y + bounds.extent.y) { | ||
| + | /* size has not changed */ | ||
| + | return res; | ||
| + | } | ||
| + | bounds.extent.y = ny - bounds.topLeft.y; | ||
| + | bounds.extent.x = nx - bounds.topLeft.x; | ||
| + | FrmEraseForm(formP); | ||
| + | WinSetBounds(hWin, | ||
| + | /* relocate object */ | ||
| + | dy = (ny == 160) ? -stdSilkHeight : stdSilkHeight; | ||
| + | /* GSI */ | ||
| + | for (i = 0 ; i < FrmGetNumberOfObjects(formP) ; i++) { | ||
| + | if (FrmGetObjectType(formP, | ||
| + | /* found GSI */ | ||
| + | FrmGetObjectPosition(formP, | ||
| + | ny += dy; | ||
| + | FrmSetObjectPosition(formP, | ||
| + | break; /* needless to search any more */ | ||
| + | } | ||
| + | } | ||
| + | for (i = 0 ; objs[i] ; i++) { | ||
| + | idx = FrmGetObjectIndex(formP, | ||
| + | FrmGetObjectBounds(formP, | ||
| + | bounds.topLeft.y += dy; | ||
| + | FrmSetObjectBounds(formP, | ||
| + | } | ||
| + | /* move command field */ | ||
| + | fldP = FrmGetObjectPtr(formP, | ||
| + | FldGetBounds(fldP, | ||
| + | bounds.topLeft.y += dy; | ||
| + | FldSetBounds(fldP, | ||
| + | FrmSetFocus(formP, | ||
| + | FldDrawField(fldP); | ||
| + | /* extent message field */ | ||
| + | fldP = FrmGetObjectPtr(formP, | ||
| + | FldGetBounds(fldP, | ||
| + | bounds.extent.y += dy * 2; | ||
| + | FldSetBounds(fldP, | ||
| + | /* update scrollbar */ | ||
| + | idx = FrmGetObjectIndex(formP, | ||
| + | FrmGetObjectBounds(formP, | ||
| + | bounds.extent.y += dy; | ||
| + | FrmSetObjectBounds(formP, | ||
| + | /* update */ | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | FrmDrawForm(formP); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (tsPatch) { | ||
| + | FldDrawField(fldP); | ||
| + | } else { | ||
| + | GFldDrawField(fldP); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(fldP); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | DrawMap(false); | ||
| + | ObjectCheck(z-> | ||
| + | |||
| + | return res; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | MainHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | Boolean | ||
| + | FormPtr | ||
| + | FieldPtr | ||
| + | ControlPtr | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | formP = FrmGetActiveForm(); | ||
| + | /* resize check */ | ||
| + | if (z-> | ||
| + | z-> | ||
| + | } | ||
| + | if (eventP-> | ||
| + | GameInit(); | ||
| + | handled = true; | ||
| + | } else if (eventP-> | ||
| + | FrmDrawForm(formP); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (z-> | ||
| + | FldDrawField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | } else { | ||
| + | GFldDrawField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldDrawField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | DrawMap(false); | ||
| + | ObjectCheck(z-> | ||
| + | FrmSetFocus(formP, | ||
| + | handled = true; | ||
| + | } else if (eventP-> | ||
| + | switch (eventP-> | ||
| + | case ZAMA_BUTTON_START: | ||
| + | /* enable command field and disable start button */ | ||
| + | btnP = GetObjectPtr(ZAMA_BUTTON_START); | ||
| + | fldP = GetObjectPtr(ZAMA_COMMAND_FIELD); | ||
| + | chkP = GetObjectPtr(ZAMA_CONTINUE); | ||
| + | FrmEraseForm(formP); | ||
| + | CleanMessageField(); | ||
| + | CtlSetUsable(btnP, | ||
| + | CtlSetUsable(chkP, | ||
| + | FldSetUsable(fldP, | ||
| + | /* init game */ | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GPaletteChange(gColorInvalid); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaPaletteChange(InvalidColor); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | if (CtlGetValue(chkP)) { /* load */ | ||
| + | LoadGame(0); | ||
| + | DarknessCheck(); | ||
| + | } else { | ||
| + | LoadInitData(); | ||
| + | z-> | ||
| + | SaveGame(0); | ||
| + | } | ||
| + | z->_over = false; /* start game */ | ||
| + | FldDrawField(fldP); | ||
| + | FrmDrawForm(formP); | ||
| + | FrmSetFocus(formP, | ||
| + | CleanMessageField(); | ||
| + | LoadMapData(z-> | ||
| + | DrawMap(true); | ||
| + | ObjectCheck(z-> | ||
| + | if (z-> | ||
| + | DrawTeacher(); | ||
| + | DrawMessage(0xb4, | ||
| + | } | ||
| + | z-> | ||
| + | handled = true; | ||
| + | break; | ||
| + | } | ||
| + | } else if (eventP-> | ||
| + | fldP = GetObjectPtr(ZAMA_MESSAGE_FIELD); | ||
| + | lines = FldGetVisibleLines(fldP) - 1; | ||
| + | switch (eventP-> | ||
| + | case pageUpChr: | ||
| + | if (FldScrollable(fldP, | ||
| + | FldScrollField(fldP, | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | } | ||
| + | handled = true; | ||
| + | break; | ||
| + | case pageDownChr: | ||
| + | if (FldScrollable(fldP, | ||
| + | FldScrollField(fldP, | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | } | ||
| + | handled = true; | ||
| + | break; | ||
| + | } | ||
| + | } else if (eventP-> | ||
| + | /* update scrollbar */ | ||
| + | if (eventP-> | ||
| + | UpdateMessageFieldScrollbar(); | ||
| + | handled = true; | ||
| + | } | ||
| + | } else if (eventP-> | ||
| + | ScrollMessageField(); | ||
| + | handled = true; | ||
| + | } else if (eventP-> | ||
| + | handled = true; | ||
| + | } else if (eventP-> | ||
| + | handled = MainMenuEvent(eventP); | ||
| + | } else if (eventP-> | ||
| + | FrmEraseForm(formP); | ||
| + | FrmDeleteForm(formP); | ||
| + | handled = true; | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | SexHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | UInt16 | ||
| + | Boolean handled = false; | ||
| + | FormPtr formP = FrmGetActiveForm(); | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if (eventP-> | ||
| + | switch (eventP-> | ||
| + | case ZAMA_BUTTON_OK: | ||
| + | sid = FrmGetControlGroupSelection(formP, | ||
| + | if (sid == FrmGetObjectIndex(formP, | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | } else if (sid == FrmGetObjectIndex(formP, | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | } else { | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | } | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | FileHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | Boolean handled = false; | ||
| + | UInt16 | ||
| + | FormPtr formP = FrmGetActiveForm(); | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if (eventP-> | ||
| + | switch (eventP-> | ||
| + | case ZAMA_BUTTON_OK: | ||
| + | fid = FrmGetControlGroupSelection(formP, | ||
| + | if (fid == FrmGetObjectIndex(formP, | ||
| + | z-> | ||
| + | } else if (fid == FrmGetObjectIndex(formP, | ||
| + | z-> | ||
| + | } else if (fid == FrmGetObjectIndex(formP, | ||
| + | z-> | ||
| + | } else { | ||
| + | z-> | ||
| + | } | ||
| + | z-> | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | InvHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | Boolean handled = false; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if (eventP-> | ||
| + | switch (eventP-> | ||
| + | case ZAMA_BUTTON_OK: | ||
| + | z-> | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | CutHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | UInt16 | ||
| + | Boolean handled = false; | ||
| + | FormPtr formP = FrmGetActiveForm(); | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if (eventP-> | ||
| + | switch (eventP-> | ||
| + | case ZAMA_BUTTON_OK: | ||
| + | z-> | ||
| + | color = FrmGetControlGroupSelection(formP, | ||
| + | if (color == FrmGetObjectIndex(formP, | ||
| + | z-> | ||
| + | } else { | ||
| + | z-> | ||
| + | } | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | MainKeyHandleEvent(EventPtr eventP, UInt32 keys) | ||
| + | { | ||
| + | Boolean handled = false; | ||
| + | EventType event; | ||
| + | |||
| + | if (FrmGetWindowHandle(FrmGetActiveForm()) != WinGetActiveWindow()) { | ||
| + | /* maybe menu or another widget popping up */ | ||
| + | return false; | ||
| + | } | ||
| + | |||
| + | if (eventP-> | ||
| + | if (keys & (keyBitPageUp | keyBitPageDown | keyBitHard1 | keyBitHard2)) { | ||
| + | /* move direction */ | ||
| + | char *dir = NULL; | ||
| + | if (keys & keyBitPageUp) { | ||
| + | dir = " | ||
| + | } else if (keys & keyBitPageDown) { | ||
| + | dir = " | ||
| + | } else if (keys & keyBitHard1) { | ||
| + | dir = " | ||
| + | } else if (keys & keyBitHard2) { | ||
| + | dir = " | ||
| + | } | ||
| + | if (dir) { | ||
| + | FldInsert(GetObjectPtr(ZAMA_COMMAND_FIELD), | ||
| + | event.eType = keyDownEvent; | ||
| + | event.data.keyDown.chr = chrLineFeed; | ||
| + | EvtAddEventToQueue(& | ||
| + | handled = true; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | KeyHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | UInt32 | ||
| + | Boolean | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((keys = KeyCurrentState()) == 0) { /* no key has been pressed */ | ||
| + | return false; | ||
| + | } | ||
| + | switch (FrmGetActiveFormID()) { | ||
| + | case ZAMA_MAIN_FORM: | ||
| + | handled = MainKeyHandleEvent(eventP, | ||
| + | break; | ||
| + | default: | ||
| + | handled = false; | ||
| + | break; | ||
| + | } | ||
| + | if (!handled) { | ||
| + | EventType event; | ||
| + | MemSet(& | ||
| + | if (eventP-> | ||
| + | event.eType = keyDownEvent; | ||
| + | event.data.keyDown.chr =(keys & keyBitHard3) ? vchrJogPush : vchrJogBack; | ||
| + | EvtAddEventToQueue(& | ||
| + | handled = true; | ||
| + | } else if (eventP-> | ||
| + | keys & (keyBitPageUp | keyBitPageDown)) { | ||
| + | event.eType = keyDownEvent; | ||
| + | event.data.keyDown.chr = (keys & keyBitPageUp) ? vchrJogUp : vchrJogDown; | ||
| + | EvtAddEventToQueue(& | ||
| + | handled = true; | ||
| + | } | ||
| + | } | ||
| + | z-> | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | AppHandleEvent(EventPtr eventP) | ||
| + | { | ||
| + | UInt16 | ||
| + | FormPtr formP; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | Boolean handled = false; | ||
| + | if (eventP-> | ||
| + | formId = eventP-> | ||
| + | formP = FrmInitForm(formId); | ||
| + | FrmSetActiveForm(formP); | ||
| + | FldSetFont(GetObjectPtr(ZAMA_MESSAGE_FIELD), | ||
| + | switch (formId) { | ||
| + | case ZAMA_MAIN_FORM: | ||
| + | FrmSetEventHandler(formP, | ||
| + | #ifdef USE_GRAPH2 | ||
| + | if (!tsPatch) { | ||
| + | GFldModifyField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaFldModifyField(GetObjectPtr(ZAMA_MESSAGE_FIELD)); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | handled = true; | ||
| + | break; | ||
| + | default: | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | return handled; | ||
| + | } | ||
| + | |||
| + | void | ||
| + | EventLoop(void) | ||
| + | { | ||
| + | EventType event; | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | z-> | ||
| + | do { | ||
| + | formID = FrmGetActiveFormID(); | ||
| + | EvtGetEvent(& | ||
| + | if (!z-> | ||
| + | continue; | ||
| + | } | ||
| + | z-> | ||
| + | if (event.eType == keyDownEvent && event.data.keyDown.chr == chrLineFeed) { | ||
| + | /* accept command */ | ||
| + | if (formID == ZAMA_MAIN_FORM) { | ||
| + | CommandLoop(); | ||
| + | continue; | ||
| + | } | ||
| + | } | ||
| + | // if (_silkr && event.eType == menuEvent) SilkLibDisableResize(_silkr); | ||
| + | if (!SysHandleEvent(& | ||
| + | if (!MenuHandleEvent(NULL, | ||
| + | #if 0 | ||
| + | if (event.eType == menuCmdBarOpenEvent) { | ||
| + | /* command stroke */ | ||
| + | event.data.menuCmdBarOpen.preventFieldButtons = true; | ||
| + | } | ||
| + | #endif | ||
| + | if(!AppHandleEvent(& | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | SilkLibDisableResize(z-> | ||
| + | } else { | ||
| + | VskSetState(z-> | ||
| + | } | ||
| + | } | ||
| + | FrmDispatchEvent(& | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | SilkLibEnableResize(z-> | ||
| + | } else { | ||
| + | VskSetState(z-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | // if (_silkr) SilkLibEnableResize(_silkr); | ||
| + | } while (event.eType != appStopEvent); | ||
| + | } | ||
| + | /* notification & silk */ | ||
| + | static | ||
| + | Err | ||
| + | SilkHeightChange(SysNotifyParamType *paramP_) | ||
| + | { | ||
| + | FormPtr | ||
| + | Coord nx, ny; | ||
| + | RectangleType bounds; | ||
| + | Boolean | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | afrmP = FrmGetActiveForm(); | ||
| + | formP = FrmGetFormPtr(ZAMA_MAIN_FORM); | ||
| + | WinGetBounds(FrmGetWindowHandle(formP), | ||
| + | WinGetDisplayExtent(& | ||
| + | if (afrmP != formP || ny == bounds.topLeft.y + bounds.extent.y) { | ||
| + | /* works only for display hight change */ | ||
| + | if (paramP_) paramP_-> | ||
| + | return errNone; | ||
| + | } | ||
| + | z-> | ||
| + | GrfCleanState(); | ||
| + | GrfInitState(); | ||
| + | GsiInitialize(); | ||
| + | GsiSetShiftState(0, | ||
| + | if (paramP_) { | ||
| + | resized = paramP_-> | ||
| + | if (resized) *resized = true; | ||
| + | } | ||
| + | if (paramP_) paramP_-> | ||
| + | return errNone; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | SilkStart(void) | ||
| + | { | ||
| + | Err err; | ||
| + | LocalID | ||
| + | SonySysFtrSysInfoP sonySysFtrSysInfoP; | ||
| + | UInt16 | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | z-> | ||
| + | if ((err = FtrGet(sonySysFtrCreator, | ||
| + | sonySysFtrNumSysInfoP, | ||
| + | (UInt32*)& | ||
| + | return false; | ||
| + | } | ||
| + | if ((sonySysFtrSysInfoP-> | ||
| + | (sonySysFtrSysInfoP-> | ||
| + | if ((err = SysLibFind(sonySysLibNameSilk, | ||
| + | if (err == sysErrLibNotFound) { | ||
| + | err = SysLibLoad(' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | z-> | ||
| + | if (err || z-> | ||
| + | z-> | ||
| + | return false; | ||
| + | } | ||
| + | if (SilkLibOpen(z-> | ||
| + | if ((z-> | ||
| + | SilkLibEnableResize(z-> | ||
| + | } else { | ||
| + | VskSetState(z-> | ||
| + | VskSetState(z-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | if ((err = SysCurAppDatabase(& | ||
| + | return false; | ||
| + | } | ||
| + | err = SysNotifyRegister(cardNo, | ||
| + | SilkHeightChange, | ||
| + | sysNotifyNormalPriority, | ||
| + | & | ||
| + | return err == errNone; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | SilkStop(void) | ||
| + | { | ||
| + | Err err; | ||
| + | LocalID codeResId; | ||
| + | UInt16 | ||
| + | Boolean res = true; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | if ((err = SysCurAppDatabase(& | ||
| + | res = false; | ||
| + | } | ||
| + | if (res) { | ||
| + | err = SysNotifyUnregister(cardNo, | ||
| + | sysNotifyNormalPriority); | ||
| + | } | ||
| + | if (z-> | ||
| + | if (z-> | ||
| + | SilkLibResizeDispWin(z-> | ||
| + | SilkLibDisableResize(z-> | ||
| + | } else { | ||
| + | VskSetState(z-> | ||
| + | VskSetState(z-> | ||
| + | } | ||
| + | SilkLibClose(z-> | ||
| + | } | ||
| + | return res && err == errNone; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | ZamaMapInit(void) | ||
| + | { | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | MemSet(z-> | ||
| + | MemSet(z-> | ||
| + | MemSet(z-> | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | InitTsPatch(void) | ||
| + | { | ||
| + | UInt32 | ||
| + | Boolean ok = false; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | z-> | ||
| + | |||
| + | if (FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | FtrGet(SmallFontAppCreator, | ||
| + | ok = true; | ||
| + | } | ||
| + | return ok; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | StartApplication(void) | ||
| + | { | ||
| + | UInt16 | ||
| + | Boolean res = false; | ||
| + | ZamaGlobalVarType *z = CreateGlobalVariables(); | ||
| + | |||
| + | #ifdef USE_GRAPH2 | ||
| + | if (!GInit()) { | ||
| + | return false; | ||
| + | } | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | if (!ZamaGraphInit()) { | ||
| + | return false; | ||
| + | } | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | res = true; | ||
| + | RctSetRectangle(& | ||
| + | LoadInitData(); | ||
| + | size = sizeof(ZamaPrefsType); | ||
| + | MemSet(& | ||
| + | z-> | ||
| + | FtrGet(sysFtrCreator, | ||
| + | #ifndef USE_GRAPH2 | ||
| + | if (ZamaHR()) { | ||
| + | z-> | ||
| + | } | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | ZamaMapInit(); | ||
| + | ver = PrefGetAppPreferences(ZAMA_CREATOR_ID, | ||
| + | ZAMA_PREFS_ID, | ||
| + | & | ||
| + | if (ver != ZAMA_PREFS_VER) { | ||
| + | /* upgrade ? */ | ||
| + | } | ||
| + | SilkStart(); | ||
| + | z-> | ||
| + | return res; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | Boolean | ||
| + | StopApplication(void) | ||
| + | { | ||
| + | ZamaGlobalVarType *z = GetGlobalVariables(); | ||
| + | #ifdef USE_GRAPH2 | ||
| + | GFinalize(); | ||
| + | #else /* USE_GRAPH2 */ | ||
| + | ZamaGraphClean(); | ||
| + | #endif /* USE_GRAPH2 */ | ||
| + | if (z-> | ||
| + | SaveGame(0); | ||
| + | } | ||
| + | PrefSetAppPreferences(ZAMA_CREATOR_ID, | ||
| + | ZAMA_PREFS_ID, | ||
| + | ZAMA_PREFS_VER, | ||
| + | & | ||
| + | sizeof(ZamaPrefsType), | ||
| + | SilkStop(); | ||
| + | DeleteGlobalVariables(); | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | static void | ||
| + | ZamaSearchDrawName(const Char *strP_, Coord x_, Coord y_, UInt16 width_) | ||
| + | { | ||
| + | Char *ptr = StrChr(strP_, | ||
| + | UInt16 titleLen = (ptr == NULL) ? StrLen(strP_) : (UInt16)(ptr - strP_); | ||
| + | if (FntWidthToOffset(strP_, | ||
| + | WinDrawChars(strP_, | ||
| + | } else { | ||
| + | Int16 titleWidth; | ||
| + | titleLen = FntWidthToOffset(strP_, | ||
| + | width_ - FntCharWidth(chrEllipsis), | ||
| + | NULL, & | ||
| + | WinDrawChars(strP_, | ||
| + | WinDrawChar (chrEllipsis, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static void | ||
| + | ZamaSearch(FindParamsPtr findParams) | ||
| + | { | ||
| + | MemHandle | ||
| + | Char *headerP; | ||
| + | Boolean | ||
| + | RectangleType r; | ||
| + | UInt16 | ||
| + | UInt32 | ||
| + | |||
| + | recH = DmGetResource(strRsc, | ||
| + | headerP = MemHandleLock(recH); | ||
| + | done = FindDrawHeader(findParams, | ||
| + | MemHandleUnlock(recH); | ||
| + | DmReleaseResource(recH); | ||
| + | if (done) return; | ||
| + | findParams-> | ||
| + | if (findParams-> | ||
| + | findParams-> | ||
| + | return; | ||
| + | } | ||
| + | match = TxtFindString(" | ||
| + | findParams-> | ||
| + | & | ||
| + | pos = longPos; | ||
| + | if (match) { | ||
| + | done = FindSaveMatch(findParams, | ||
| + | pos, 0, matchLength, | ||
| + | if (!done) { | ||
| + | FindGetLineBounds(findParams, | ||
| + | ZamaSearchDrawName(" | ||
| + | | ||
| + | ++findParams-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | UInt32 | ||
| + | PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags) | ||
| + | { | ||
| + | if (cmd == sysAppLaunchCmdNormalLaunch || cmd == sysAppLaunchCmdGoTo) { | ||
| + | _startup = 0; | ||
| + | if (cmd == sysAppLaunchCmdGoTo) { | ||
| + | _startup = ((GoToParamsPtr)cmdPBP)-> | ||
| + | } | ||
| + | if (StartApplication()) { | ||
| + | FrmGotoForm(ZAMA_MAIN_FORM); | ||
| + | EventLoop(); | ||
| + | FrmCloseAllForms(); | ||
| + | StopApplication(); | ||
| + | } | ||
| + | } else if (cmd == sysAppLaunchCmdFind) { | ||
| + | ZamaSearch((FindParamsPtr)cmdPBP); | ||
| + | } else if (cmd == sysAppLaunchCmdNotify) { | ||
| + | SilkHeightChange(cmdPBP); | ||
| + | } | ||
| + | return 0; | ||
| + | } | ||
| </ | </ | ||
| <file c graph2.c> | <file c graph2.c> | ||
| + | /* | ||
| + | * Graphics routine for High-High-School Adventure. | ||
| + | | ||
| + | */ | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include " | ||
| + | #include " | ||
| + | #include " | ||
| + | |||
| + | #define MAX_QUEUE_SIZE (1024) | ||
| + | typedef struct { | ||
| + | int | ||
| + | PointType _Queue[MAX_QUEUE_SIZE]; | ||
| + | } GPointQueueType; | ||
| + | typedef GPointQueueType *GPointQueuePtr; | ||
| + | |||
| + | /* global variables */ | ||
| + | |||
| + | typedef struct { | ||
| + | GPointQueueType | ||
| + | Boolean | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | IndexedColorType _colors[gColorNameCandidate]; | ||
| + | RGBColorType | ||
| + | WinHandle | ||
| + | BitmapPtr | ||
| + | UInt8 *_baseP; | ||
| + | UInt16 | ||
| + | RectangleType | ||
| + | UInt32 | ||
| + | FontID | ||
| + | } GraphGlobalVarType; | ||
| + | |||
| + | static | ||
| + | GraphGlobalVarType * | ||
| + | CreateGlobalVariables() | ||
| + | { | ||
| + | GraphGlobalVarType *ptr = NULL; | ||
| + | Err err; | ||
| + | if ((err = FtrPtrNew(ZAMA_CREATOR_ID, | ||
| + | { | ||
| + | return NULL; | ||
| + | } | ||
| + | return ptr; | ||
| + | } | ||
| + | |||
| + | static | ||
| + | void | ||
| + | DeleteGlobalVariables() | ||
| + | { | ||
| + | FtrPtrFree(ZAMA_CREATOR_ID, | ||
| + | } | ||
| + | |||
| + | static | ||
| + | GraphGlobalVarType * | ||
| + | GetGlobalVariables() | ||
| + | { | ||
| + | GraphGlobalVarType *ptr; | ||
| + | Err err; | ||
| + | if ((err = FtrGet(ZAMA_CREATOR_ID, | ||
| + | { | ||
| + | return NULL; | ||
| + | } | ||
| + | return ptr; | ||
| + | } | ||
| + | |||
| + | static void | ||
| + | HDWinDrawChars(Char *strP_, UInt16 len_, Coord x_, Coord y_) | ||
| + | { | ||
| + | WinHandle | ||
| + | BitmapPtr | ||
| + | BitmapPtrV3 | ||
| + | RectangleType r; | ||
| + | Coord w, h; | ||
| + | Err err; | ||
| + | UInt16 | ||
| + | |||
| + | curH = WinGetDrawWindow(); | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | w = FntCharsWidth(strP_, | ||
| + | h = FntCharHeight(); | ||
| + | bmpP = BmpCreate(w, | ||
| + | bmp3P = BmpCreateBitmapV3(bmpP, | ||
| + | BmpGetBits(bmpP), | ||
| + | offH = WinCreateBitmapWindow((BitmapPtr)bmp3P, | ||
| + | |||
| + | WinSetDrawWindow(offH); | ||
| + | WinDrawChars(strP_, | ||
| + | WinDeleteWindow(offH, | ||
| + | BmpSetDensity((BitmapPtr)bmp3P, | ||
| + | offH = WinCreateBitmapWindow((BitmapPtr)bmp3P, | ||
| + | RctSetRectangle(& | ||
| + | WinCopyRectangle(offH, | ||
| + | WinDeleteWindow(offH, | ||
| + | BmpDelete((BitmapPtr)bmp3P); | ||
| + | BmpDelete(bmpP); | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | |||
| + | static inline UInt16 | ||
| + | GCoord2Offset(Coord x_, Coord y_) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | if (g-> | ||
| + | return y_ * g-> | ||
| + | } else { | ||
| + | return y_ * g-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static inline void | ||
| + | GSetPixel(Coord x_, Coord y_, IndexedColorType c_) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | UInt16 o = GCoord2Offset(x_, | ||
| + | if (g-> | ||
| + | #if 0 | ||
| + | WinHandle draw = WinGetDrawWindow(); | ||
| + | WinSetDrawWindow(_canvas); | ||
| + | WinDrawPixel(x_, | ||
| + | WinSetDrawWindow(draw); | ||
| + | #else | ||
| + | g-> | ||
| + | #endif | ||
| + | } else if (_hrLib) { | ||
| + | g-> | ||
| + | } else { | ||
| + | if (x_ % 2) { | ||
| + | g-> | ||
| + | g-> | ||
| + | } else { | ||
| + | g-> | ||
| + | g-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static inline IndexedColorType | ||
| + | GFetchPixel(Coord x_, Coord y_) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | UInt16 o = GCoord2Offset(x_, | ||
| + | if (g-> | ||
| + | #if 0 | ||
| + | IndexedColorType c; | ||
| + | WinHandle | ||
| + | WinSetDrawWindow(_canvas); | ||
| + | c = WinGetPixel(x_, | ||
| + | WinSetDrawWindow(draw); | ||
| + | return c; | ||
| + | #else | ||
| + | return g-> | ||
| + | #endif | ||
| + | } else if (g-> | ||
| + | return g-> | ||
| + | } else { | ||
| + | if (x_ % 2) { | ||
| + | return g-> | ||
| + | } else { | ||
| + | return (g-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | #define isSjis(k_) (((k_) >= 0x80 && (k_) < 0xa0)||((k_) >= 0xe0)) | ||
| + | |||
| + | static inline void | ||
| + | GInitQueue(void) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | g-> | ||
| + | } | ||
| + | |||
| + | static inline void | ||
| + | GShiftPoint(Coord x_, Coord y_) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | g-> | ||
| + | g-> | ||
| + | if (++g-> | ||
| + | g-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static inline PointType* | ||
| + | GUnshiftPoint(void) | ||
| + | { | ||
| + | PointType *p; | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | if (g-> | ||
| + | p = & | ||
| + | if (g-> | ||
| + | g-> | ||
| + | } | ||
| + | return p; | ||
| + | } | ||
| + | |||
| + | static void | ||
| + | GInitColors(void) | ||
| + | { | ||
| + | UInt16 i; | ||
| + | RGBColorType rgb[] = { | ||
| + | { 0, 0x00, 0x00, 0x00}, | ||
| + | { 0, 0x00, 0x00, 0xff}, | ||
| + | { 0, 0xff, 0x00, 0x00}, | ||
| + | { 0, 0xff, 0x00, 0xff}, | ||
| + | { 0, 0x00, 0xff, 0x00}, | ||
| + | { 0, 0x00, 0xff, 0xff}, | ||
| + | { 0, 0xff, 0xff, 0x00}, | ||
| + | { 0, 0xff, 0xff, 0xff}, | ||
| + | { 0, 0x55, 0x55, 0x55}, | ||
| + | { 0, 0x00, 0x00, 0x80}, | ||
| + | { 0, 0x80, 0x00, 0x00}, | ||
| + | { 0, 0x80, 0x00, 0x80}, | ||
| + | { 0, 0x00, 0x80, 0x00}, | ||
| + | { 0, 0x00, 0x80, 0x80}, | ||
| + | { 0, 0x80, 0x80, 0x00}, | ||
| + | { 0, 0xaa, 0xaa, 0xaa}, | ||
| + | }; | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | for (i = 0 ; i < gColorNameCandidate ; i++) { | ||
| + | g-> | ||
| + | WinIndexToRGB(g-> | ||
| + | if (g-> | ||
| + | g-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /* API */ | ||
| + | |||
| + | Boolean | ||
| + | GInit(void) | ||
| + | { | ||
| + | SonySysFtrSysInfoP sonySysFtrSysInfoP; | ||
| + | UInt32 | ||
| + | Err err = 0; | ||
| + | Boolean | ||
| + | Boolean | ||
| + | UInt16 | ||
| + | FontID | ||
| + | hrTinyFont, hrTinyBoldFont, | ||
| + | hrStdFont, hrBoldFont, hrLargeFont, | ||
| + | }; | ||
| + | GraphGlobalVarType *g = CreateGlobalVariables(); | ||
| + | /* OS5 High Density Check */ | ||
| + | g-> | ||
| + | if (FtrGet(sysFtrCreator, | ||
| + | if (wmVer >= 4) { /* hd interface existing */ | ||
| + | WinScreenGetAttribute(winScreenDensity, | ||
| + | if (wmAttr == kDensityDouble) { | ||
| + | _hDensity = true; | ||
| + | WinSetCoordinateSystem(kCoordinatesStandard); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | /* CLIe High Resolution Check */ | ||
| + | if ((err = FtrGet(sonySysFtrCreator, | ||
| + | sonySysFtrNumSysInfoP, | ||
| + | (UInt32*)& | ||
| + | if (sonySysFtrSysInfoP-> | ||
| + | /* High-resolution library available */ | ||
| + | if ((err = SysLibFind(sonySysLibNameHR, | ||
| + | if (err == sysErrLibNotFound) { | ||
| + | err = SysLibLoad(' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if (!g-> | ||
| + | g-> | ||
| + | g-> | ||
| + | g-> | ||
| + | WinScreenMode(winScreenModeSet, | ||
| + | res = true; | ||
| + | } else { | ||
| + | g-> | ||
| + | g-> | ||
| + | res = true; /* only High-resolution CLIE/OS5 high density device support */ | ||
| + | if (g-> | ||
| + | WinScreenMode(winScreenModeSet, | ||
| + | } else { | ||
| + | HROpen(g-> | ||
| + | HRGetAPIVersion(g-> | ||
| + | HRWinScreenMode(g-> | ||
| + | winScreenModeSet, | ||
| + | for (i = 0 ; i < 8 ; i++) { | ||
| + | g-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | WinScreenMode(winScreenModeGet, | ||
| + | if (!col) { | ||
| + | if (g-> | ||
| + | HRClose(g-> | ||
| + | } | ||
| + | return false; /* mono-chrome mode */ | ||
| + | } | ||
| + | GInitColors(); | ||
| + | RctSetRectangle(& | ||
| + | if (g-> | ||
| + | UInt16 coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | g-> | ||
| + | | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } else if (g-> | ||
| + | g-> | ||
| + | | ||
| + | | ||
| + | } | ||
| + | if (g-> | ||
| + | res = false; | ||
| + | } else { | ||
| + | _bmpP = WinGetBitmap(g-> | ||
| + | _baseP = BmpGetBits(g-> | ||
| + | GlueBmpGetDimensions(g-> | ||
| + | } | ||
| + | return res; | ||
| + | } | ||
| + | |||
| + | Boolean | ||
| + | GFinalize(void) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | if (g-> | ||
| + | HRClose(g-> | ||
| + | } | ||
| + | if (g-> | ||
| + | WinDeleteWindow(g-> | ||
| + | } | ||
| + | DeleteGlobalVariables(); | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GChromakeyPaint(RectanglePtr clipP_, UInt8 *patP_, Boolean line_) | ||
| + | { | ||
| + | IndexedColorType c; | ||
| + | WinHandle | ||
| + | UInt8 r, g, b, off; | ||
| + | Coord x, y, dx, lx, ox; | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | RectangleType | ||
| + | UInt8 pattern[][3] = { | ||
| + | { 0x00, 0x00, 0x00 }, | ||
| + | { 0xff, 0x00, 0x00 }, | ||
| + | { 0x00, 0xff, 0x00 }, | ||
| + | { 0xff, 0xff, 0x00 }, | ||
| + | { 0x00, 0x00, 0xff }, | ||
| + | { 0xff, 0x00, 0xff }, | ||
| + | { 0x00, 0xff, 0xff }, | ||
| + | { 0xff, 0xff, 0xff }, | ||
| + | }; | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | i = 0; | ||
| + | n = patP_[i++]; | ||
| + | for (j = 0 ; j < n ; j++) { | ||
| + | pattern[j + 1][0] = patP_[i + j * 3 + 0]; | ||
| + | pattern[j + 1][1] = patP_[i + j * 3 + 1]; | ||
| + | pattern[j + 1][2] = patP_[i + j * 3 + 2]; | ||
| + | } | ||
| + | |||
| + | bl = clipP_-> | ||
| + | bu = clipP_-> | ||
| + | br = bl + clipP_-> | ||
| + | bd = bu + clipP_-> | ||
| + | cur = WinGetDrawWindow(); | ||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | for (y = bu; y < bd ; y++) { | ||
| + | for (x = bl ; x < br ; x += 8) { | ||
| + | lx = (br - x < 8) ? br - x : 8; | ||
| + | for (dx = 0, ox = 7 ; dx < lx ; dx++, ox--) { | ||
| + | c = GFetchPixel(x + dx, y); | ||
| + | off = 1 << ox; | ||
| + | for (j = 1 ; j <= n ; j++) { | ||
| + | if (_colors[j] == c) { | ||
| + | b = (pattern[j][0] & off) >> ox; | ||
| + | r = (pattern[j][1] & off) >> ox; | ||
| + | g = (pattern[j][2] & off) >> ox; | ||
| + | GSetPixel(x + dx, y, _colors[(r << 1) | (g << 2) | b]); | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if (line_) { | ||
| + | RctSetRectangle(& | ||
| + | if (g-> | ||
| + | HRWinCopyRectangle(g-> | ||
| + | } else { | ||
| + | WinCopyRectangle(g-> | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if (!line_) { | ||
| + | if (g-> | ||
| + | HRWinCopyRectangle(g-> | ||
| + | } else { | ||
| + | WinCopyRectangle(g-> | ||
| + | } | ||
| + | } | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | static inline Boolean | ||
| + | _chk(Coord x_, Coord y_, IndexedColorType c_, IndexedColorType b_) | ||
| + | { | ||
| + | IndexedColorType c = GFetchPixel(x_, | ||
| + | return c != c_ && c != b_; | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GPaintSpec(GPaintSpecPtr specP_) | ||
| + | { | ||
| + | PointType | ||
| + | Coord bl, bu, br, bd; | ||
| + | Coord l, r, x, y; | ||
| + | Coord wx, wy; | ||
| + | WinHandle | ||
| + | Coord ltx, lty, lbx, lby; | ||
| + | Boolean | ||
| + | UInt16 | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | bl = specP_-> | ||
| + | bu = specP_-> | ||
| + | br = bl + specP_-> | ||
| + | bd = bu + specP_-> | ||
| + | x = specP_-> | ||
| + | y = specP_-> | ||
| + | |||
| + | ltx = lty = lbx = lby = -1; | ||
| + | |||
| + | cur = WinGetDrawWindow(); | ||
| + | if (!_chk(x, y, g-> | ||
| + | /* needless to paint */ | ||
| + | return; | ||
| + | } | ||
| + | GInitQueue(); | ||
| + | |||
| + | GShiftPoint(x, | ||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | WinSetForeColor(g-> | ||
| + | while ((pP = GUnshiftPoint()) != NULL) { | ||
| + | if (!_chk(pP-> | ||
| + | /* needless to paint */ | ||
| + | continue; | ||
| + | } | ||
| + | for (l = pP->x ; l >= bl ; l--) { | ||
| + | if (!_chk(l, pP->y, g-> | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | ++l; | ||
| + | for (r = pP->x ; r < br ; r++) { | ||
| + | if (!_chk(r, pP->y, g-> | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | --r; | ||
| + | /* draw current line */ | ||
| + | if (g-> | ||
| + | WinSetDrawWindow(g-> | ||
| + | HRWinDrawLine(g-> | ||
| + | WinSetDrawWindow(cur); | ||
| + | HRWinDrawLine(g-> | ||
| + | } else { | ||
| + | WinSetDrawWindow(g-> | ||
| + | WinDrawLine(l, | ||
| + | WinSetDrawWindow(cur); | ||
| + | WinDrawLine(l, | ||
| + | } | ||
| + | for (wx = l ; wx <= r ; wx++) { | ||
| + | uf = df = false; | ||
| + | /* scan upper line */ | ||
| + | wy = pP->y - 1; | ||
| + | if (wy >= bu) { | ||
| + | uf = _chk(wx, wy, g-> | ||
| + | if (uf) { | ||
| + | if (wx + 1 <= r && !_chk(wx + 1, wy, | ||
| + | | ||
| + | | ||
| + | /* found right edge */ | ||
| + | GShiftPoint(wx, | ||
| + | uf = false; | ||
| + | } else if (wx == r) { | ||
| + | GShiftPoint(wx, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | /* scan lower line */ | ||
| + | wy = pP->y + 1; | ||
| + | if (wy < bd) { | ||
| + | df = _chk(wx, wy, g-> | ||
| + | if (df) { | ||
| + | if (wx + 1 <= r && !_chk(wx + 1, wy, | ||
| + | | ||
| + | | ||
| + | /* found right edge */ | ||
| + | GShiftPoint(wx, | ||
| + | df = false; | ||
| + | } else if (wx == r) { | ||
| + | GShiftPoint(wx, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if (_hDensity) { | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GPaint(RectanglePtr clipP_, Coord x_, Coord y_, GColorName f_, GColorName b_) | ||
| + | { | ||
| + | GPaintSpecType spec; | ||
| + | spec._clipP | ||
| + | spec._x | ||
| + | spec._y | ||
| + | spec._fg | ||
| + | spec._bg | ||
| + | spec._bgBmpP = NULL; | ||
| + | GPaintSpec(& | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GDrawLine(RectanglePtr clipP_, | ||
| + | Coord x0_, Coord y0_, Coord x1_, Coord y1_, GColorName c_) | ||
| + | { | ||
| + | RectangleType cur; | ||
| + | WinHandle | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | draw = WinGetDrawWindow(); | ||
| + | WinSetForeColor(g-> | ||
| + | windows[0] = g-> | ||
| + | windows[1] = draw; | ||
| + | for (i = 0 ; i < 2; i++) { | ||
| + | WinSetDrawWindow(windows[i]); | ||
| + | if (g-> | ||
| + | if (clipP_) { | ||
| + | HRWinGetClip(g-> | ||
| + | HRWinSetClip(g-> | ||
| + | } | ||
| + | HRWinDrawLine(g-> | ||
| + | if (clipP_) { | ||
| + | HRWinSetClip(g-> | ||
| + | } | ||
| + | } else { | ||
| + | if (clipP_) { | ||
| + | WinGetClip(& | ||
| + | WinSetClip(clipP_); | ||
| + | } | ||
| + | WinDrawLine(x0_, | ||
| + | if (clipP_) { | ||
| + | WinSetClip(& | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | GColorName | ||
| + | GGetPixel(Coord x0_, Coord y0_) | ||
| + | { | ||
| + | UInt16 | ||
| + | IndexedColorType c; | ||
| + | GColorName | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | c = GFetchPixel(x0_, | ||
| + | for (i = 0 ; i < gColorNameCandidate ; i++) { | ||
| + | if (g-> | ||
| + | r = i; | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | return r; | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GDrawPixel(RectanglePtr clipP_, Coord x0_, Coord y0_, GColorName c_) | ||
| + | { | ||
| + | UInt16 coordSys; | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | WinSetForeColor(g-> | ||
| + | GSetPixel(x0_, | ||
| + | if (g-> | ||
| + | HRWinDrawPixel(g-> | ||
| + | } else { | ||
| + | WinDrawPixel(x0_, | ||
| + | } | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GDrawRectangle(RectanglePtr rP_, GColorName c_) | ||
| + | { | ||
| + | UInt16 | ||
| + | WinHandle | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | WinSetForeColor(g-> | ||
| + | if (g-> | ||
| + | WinSetDrawWindow(g-> | ||
| + | HRWinDrawRectangle(g-> | ||
| + | WinSetDrawWindow(draw); | ||
| + | HRWinDrawRectangle(g-> | ||
| + | } else { | ||
| + | WinSetDrawWindow(g-> | ||
| + | WinDrawRectangle(rP_, | ||
| + | WinSetDrawWindow(draw); | ||
| + | WinDrawRectangle(rP_, | ||
| + | } | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GDrawChars(Boolean small_, | ||
| + | Char *strP_, UInt16 len_, Coord x_, Coord y_, GColorName c_) | ||
| + | { | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | WinHandle windows[2]; | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | if (g-> | ||
| + | coordSys = WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | WinSetTextColor(g-> | ||
| + | |||
| + | windows[0] = g-> | ||
| + | windows[1] = WinGetDrawWindow(); | ||
| + | if (strP_[len_ - 1] < ' ') { | ||
| + | --len_; | ||
| + | } | ||
| + | for(i = 0 ; i < 2 ; i++) { | ||
| + | WinSetDrawWindow(windows[i]); | ||
| + | if (g-> | ||
| + | if (small_){ | ||
| + | HDWinDrawChars(strP_, | ||
| + | } else { | ||
| + | WinDrawChars(strP_, | ||
| + | } | ||
| + | } else { | ||
| + | HRWinDrawChars(g-> | ||
| + | } | ||
| + | } | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(coordSys); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GPaletteChange(GColorName c_) | ||
| + | { | ||
| + | UInt16 | ||
| + | RGBColorType *mapP, rgb; | ||
| + | MemHandle | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | hRGB = MemHandleNew(sizeof(RGBColorType) * 256); | ||
| + | mapP = (RGBColorType*)MemHandleLock(hRGB); | ||
| + | WinPalette(winPaletteGet, | ||
| + | if (c_ != gColorInvalid) { | ||
| + | WinIndexToRGB(g-> | ||
| + | } | ||
| + | for (i = gColorBlue ; i < gColorWhite ; i++) { | ||
| + | mapP[g-> | ||
| + | } | ||
| + | WinPalette(winPaletteSet, | ||
| + | MemHandleUnlock(hRGB); | ||
| + | MemHandleFree(hRGB); | ||
| + | } | ||
| + | |||
| + | FontID | ||
| + | GGetFont(void) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | return (!g-> | ||
| + | } | ||
| + | |||
| + | FontID | ||
| + | GSetFont(FontID id_) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | return (!g-> | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GFldModifyField(FieldPtr fldP) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | if (g-> | ||
| + | FldSetUsable(fldP, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GFldDrawField(FieldPtr fldP) | ||
| + | { | ||
| + | UInt16 | ||
| + | UInt16 | ||
| + | FontID | ||
| + | Char *textP; | ||
| + | RectangleType b; | ||
| + | Boolean | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | |||
| + | if (!g-> | ||
| + | FldDrawField(fldP); | ||
| + | return; | ||
| + | } | ||
| + | WinPushDrawState(); | ||
| + | if (g-> | ||
| + | WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | } | ||
| + | FldGetBounds(fldP, | ||
| + | if (_hDensity || _hrLib) { | ||
| + | b.topLeft.x <<= 1; | ||
| + | b.topLeft.y <<= 1; | ||
| + | b.extent.x <<= 1; | ||
| + | b.extent.y <<= 1; | ||
| + | } | ||
| + | fldFont = FldGetFont(fldP); | ||
| + | textP = FldGetTextPtr(fldP); | ||
| + | maxLength = FldGetTextLength(fldP); | ||
| + | if (textP) { | ||
| + | GFldEraseField(fldP); | ||
| + | if (g-> | ||
| + | if (fldFont & fntAppFontCustomBase) { | ||
| + | fldFont -= fntAppFontCustomBase; | ||
| + | small = true; | ||
| + | } | ||
| + | curFont = FntSetFont(fldFont); | ||
| + | } else if (g-> | ||
| + | FontID hrFont; | ||
| + | if (fldFont & fntAppFontCustomBase) { | ||
| + | /* use small font */ | ||
| + | fldFont -= fntAppFontCustomBase; | ||
| + | small = true; | ||
| + | } | ||
| + | hrFont = g-> | ||
| + | if (fldFont == largeBoldFont) { | ||
| + | hrFont = g-> | ||
| + | } | ||
| + | curFont = HRFntSetFont(g-> | ||
| + | } | ||
| + | h = FntLineHeight(); | ||
| + | w = b.extent.x; | ||
| + | if (small) { | ||
| + | if (g-> | ||
| + | h /= 2; | ||
| + | w *= 2; | ||
| + | } | ||
| + | } | ||
| + | if (!g-> | ||
| + | h = HRFntLineHeight(g-> | ||
| + | } | ||
| + | lines = FldGetVisibleLines(fldP); | ||
| + | if (g-> | ||
| + | lines = b.extent.y / h; | ||
| + | } | ||
| + | offset = FldGetScrollPosition(fldP); | ||
| + | for (pos = 0 ; pos < lines ; pos++) { | ||
| + | l = FldWordWrap(& | ||
| + | GDrawChars(small, | ||
| + | l, b.topLeft.x, | ||
| + | offset += l; | ||
| + | if (offset >= maxLength) { | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | if (g-> | ||
| + | FntSetFont(curFont); | ||
| + | } else if (g-> | ||
| + | HRFntSetFont(g-> | ||
| + | } | ||
| + | } | ||
| + | WinPopDrawState(); | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GFldEraseField(FieldPtr fldP) | ||
| + | { | ||
| + | RectangleType b; | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | if (!g-> | ||
| + | FldEraseField(fldP); | ||
| + | return; | ||
| + | } | ||
| + | FldGetBounds(fldP, | ||
| + | b.topLeft.x <<= 1; | ||
| + | b.topLeft.y <<= 1; | ||
| + | b.extent.x <<= 1; | ||
| + | b.extent.y <<= 1; | ||
| + | if (g-> | ||
| + | WinPushDrawState(); | ||
| + | WinSetCoordinateSystem(kCoordinatesDouble); | ||
| + | WinEraseRectangle(& | ||
| + | WinPopDrawState(); | ||
| + | } else if (g-> | ||
| + | HRWinEraseRectangle(g-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void | ||
| + | GGetDisplayExtent(Coord *xP, Coord *yP, Boolean hd) | ||
| + | { | ||
| + | WinPushDrawState(); | ||
| + | if (_hDensity) { | ||
| + | WinSetCoordinateSystem((hd) ? kCoordinatesDouble : kCoordinatesStandard); | ||
| + | } | ||
| + | WinGetDisplayExtent(xP, | ||
| + | WinPopDrawState(); | ||
| + | } | ||
| + | |||
| + | UInt16 | ||
| + | GScale(void) | ||
| + | { | ||
| + | GraphGlobalVarType *g = GetGlobalVariables(); | ||
| + | return (g-> | ||
| + | } | ||
| </ | </ | ||
ハイハイスクールアドベンチャー_palmos版.1763612393.txt.gz · 最終更新: by araki
