platform_palmos.c
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:18k
源码类别:

Windows CE

开发平台:

C/C++

  1. /*****************************************************************************
  2.  *
  3.  * This program is free software ; you can redistribute it and/or modify
  4.  * it under the terms of the GNU General Public License as published by
  5.  * the Free Software Foundation; either version 2 of the License, or
  6.  * (at your option) any later version.
  7.  *
  8.  * This program is distributed in the hope that it will be useful,
  9.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11.  * GNU General Public License for more details.
  12.  *
  13.  * You should have received a copy of the GNU General Public License
  14.  * along with this program; if not, write to the Free Software
  15.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  16.  *
  17.  * $Id: platform_palmos.c 615 2006-01-26 16:57:51Z picard $
  18.  *
  19.  * The Core Pocket Media Player
  20.  * Copyright (c) 2004-2005 Gabor Kovacs
  21.  *
  22.  ****************************************************************************/
  23. #include "../common.h"
  24. #if defined(TARGET_PALMOS)
  25. #include "pace.h"
  26. #include "dia.h"
  27. #ifdef HAVE_PALMONE_SDK
  28. #define NO_HSEXT_TRAPS
  29. #include <68K/System/HardwareUtils68K.h>
  30. #include <Common/System/HsNavCommon.h>
  31. #include <68K/System/HsExt.h>
  32. #include <68K/System/PmPalmOSNVFS.h>
  33. static UInt16 HWU = sysInvalidRefNum;
  34. static bool_t HSExt54 = 0;
  35. static bool_t HWUDisplayPower = 1;
  36. static bool_t HALTreo650 = 0;
  37. #endif
  38. static int KeyboardBacklight = 0;
  39. static bool_t HighDens = 0;
  40. static bool_t SleepDisable = 0;
  41. static bool_t SleepCatch = 0;
  42. static UInt16 SleepSave = 0;
  43. static bool_t DisplayPowerSupport = 0;
  44. static bool_t OEMSleep = 0;
  45. //static uint16_t KeyInitDelay, KeyPeriod, KeyDoubleTapDelay;  
  46. //static Boolean KeyQueueAhead; 
  47. void File_Init();
  48. void File_Done();
  49. void FileDb_Init();
  50. void FileDb_Done();
  51. void VFS_Init();
  52. void VFS_Done();
  53. int DefaultLang()
  54. {
  55. return LANG_DEFAULT;
  56. }
  57. rgb* Palette = NULL;
  58. void QueryDesktop(video* p)
  59. {
  60. UInt32 v;
  61.     Coord Width;
  62.     Coord Height;
  63. UInt16 OldCoord = 0;
  64. memset(p,0,sizeof(video));
  65. // we need the display window extent and not the physical screen size 
  66. // (WinScreenGetAttribute(winScreenWidth|winScreenHeight) would return always 320x320 on Sony devices)
  67. if (HighDens)
  68. OldCoord = WinSetCoordinateSystem(kCoordinatesNative);
  69. WinGetDisplayExtent(&Width, &Height);
  70. if (HighDens)
  71. WinSetCoordinateSystem(OldCoord);
  72. p->Width = Width;
  73. p->Height = Height;
  74. if (!WinScreenGetAttribute(winScreenDepth,&v)) p->Pixel.BitCount = (UInt16)v;
  75. if (!WinScreenGetAttribute(winScreenRowBytes,&v)) p->Pitch = (UInt16)v;
  76. if (WinScreenGetAttribute(winScreenPixelFormat,&v))
  77. {
  78. if (p->Pixel.BitCount == 16)
  79. v = pixelFormat565LE;
  80. if (p->Pixel.BitCount <= 8)
  81. v = pixelFormatIndexedLE;
  82. }
  83. if (v==pixelFormat565LE || v==pixelFormat565) 
  84. DefaultRGB(&p->Pixel,16,5,6,5,0,0,0);
  85. free(Palette);
  86. Palette = NULL;
  87. if (v==pixelFormatIndexed || v==pixelFormatIndexedLE)
  88. {
  89. int i,n = 1 << p->Pixel.BitCount;
  90. p->Pixel.Flags = PF_PALETTE;
  91. Palette = malloc(sizeof(rgb)*n);
  92. WinPalette(winPaletteGet,0,(UInt16)n,(RGBColorType*)Palette);
  93. for (i=0;i<n;++i)
  94. {
  95. RGBColorType c = *(RGBColorType*)(Palette+i);
  96. Palette[i].c.r = c.r;
  97. Palette[i].c.g = c.g;
  98. Palette[i].c.b = c.b;
  99. }
  100. p->Pixel.Palette = Palette;
  101. }
  102. p->Aspect = ASPECT_ONE;
  103. p->Direction = 0;
  104. }
  105. bool_t HaveDPad()
  106. {
  107. UInt32 CompanyID;
  108. FtrGet(sysFtrCreator, sysFtrNumOEMCompanyID, &CompanyID);
  109. return CompanyID != 'sony';
  110. }
  111. typedef struct companyname
  112. {
  113. uint32_t CompanyID;
  114. const char* Name;
  115. } companyname;
  116. typedef struct devicename
  117. {
  118. uint32_t CompanyID;
  119. uint32_t DeviceID;
  120. const char* Name;
  121. int Model;
  122. } devicename;
  123. static const companyname CompanyName[] = {
  124. {'PITC',T("PiTech")},
  125. {'SONY',T("Sony")},
  126. {'TPWV',T("Tapwave")},
  127. {'PALM',T("palmOne")},
  128. {'HSPR',T("Handspring")},
  129. {'GRMN',T("Gramin")},
  130. {0},
  131. };
  132. static const devicename DeviceName[] = {
  133. {'PITC','W300',T(" Qool Labs QDA700"),MODEL_QDA700},
  134. {'TPWV','Rdog',T(" Zodiac 1/2"),MODEL_ZODIAC},
  135. {'PSYS',0,T("PalmOS 5 Simulator"),MODEL_PALM_SIMULATOR},
  136. {'PALM','TunX',T(" LifeDrive"),MODEL_LIFEDRIVE},
  137. {'PALM','Zi22',T(" Zire 31"),MODEL_ZIRE_31},
  138. {'PALM','Zpth',T(" Zire 71"),MODEL_ZIRE_71},
  139. {'PALM','Zi72',T(" Zire 72"),MODEL_ZIRE_72},
  140. {'PALM','Cct1',T(" Tungsten E"),MODEL_TUNGSTEN_E},
  141. {'PALM','Zir4',T(" Tungsten E2"),MODEL_TUNGSTEN_E2},
  142. {'PALM','Frg1',T(" Tungsten T"),MODEL_TUNGSTEN_T},
  143. {'PALM','Frg2',T(" Tungsten T2"),MODEL_TUNGSTEN_T2},
  144. {'PALM','Arz1',T(" Tungsten T3"),MODEL_TUNGSTEN_T3},
  145. {'PALM','TnT5',T(" Tungsten T5"),MODEL_TUNGSTEN_T5},
  146. {'PALM','MT64',T(" Tungsten C"),MODEL_TUNGSTEN_C},
  147. {'PALM','D050',T(" TX"),MODEL_PALM_TX},
  148. {'PALM','D051',T(" Z22"),MODEL_PALM_Z22},
  149. {'HSPR','H101',T(" Treo 600"),MODEL_TREO_600},
  150. {'HSPR','H102',T(" Treo 650"),MODEL_TREO_650},
  151. {'HSPR','H202',T(" Treo 650 Simulator"),MODEL_TREO_650},
  152. {'GRMN','3600',T(" iQue 3600"),MODEL_IQUE_3600},
  153. {'SONY','atom',T(" TH55"),MODEL_SONY_TH55},
  154. {'SONY','amno',T(" UX40"),MODEL_SONY_UX40},
  155. {'SONY','prmr',T(" UX50"),MODEL_SONY_UX50},
  156. {'SONY','ancy',T(" VZ90"),MODEL_SONY_VZ90},
  157. {0},
  158. };
  159. void PlatformDetect(platform* p)
  160. {
  161. UInt32 DeviceID;
  162. UInt32 CompanyID;
  163. UInt32 Version;
  164. const companyname* CName;
  165. const devicename* DName;
  166. FtrGet(sysFtrCreator, sysFtrNumROMVersion, &Version);
  167. p->Ver = Version;
  168. stprintf_s(p->Version,TSIZEOF(p->Version),T("%d.%d.%d"),
  169. sysGetROMVerMajor(Version),
  170. sysGetROMVerMinor(Version),
  171. sysGetROMVerFix(Version));
  172. p->Type = TYPE_PALMOS;
  173. p->Model = MODEL_UNKNOWN;
  174. p->OemInfo[0] = 0;
  175. FtrGet(sysFtrCreator, sysFtrNumOEMCompanyID, &CompanyID);
  176. FtrGet(sysFtrCreator, sysFtrNumOEMDeviceID, &DeviceID);
  177. CompanyID = UpperFourCC(CompanyID);
  178. for (CName=CompanyName;CName->CompanyID;++CName)
  179. if (CName->CompanyID == CompanyID)
  180. {
  181. tcscpy_s(p->OemInfo,TSIZEOF(p->OemInfo),CName->Name);
  182. break;
  183. }
  184. if (CompanyID == 'SONY')
  185. p->Caps |= CAPS_SONY;
  186. for (DName=DeviceName;DName->CompanyID;++DName)
  187. if (DName->CompanyID == CompanyID && DName->DeviceID == DeviceID)
  188. {
  189. tcscat_s(p->OemInfo,TSIZEOF(p->OemInfo),DName->Name);
  190. p->Model = DName->Model;
  191. break;
  192. }
  193. if (p->Model == MODEL_ZIRE_31 || p->Model == MODEL_PALM_Z22)
  194. p->Caps |= CAPS_ONLY12BITRGB;
  195. }
  196. void Platform_Init()
  197. {
  198. UInt32 Version;
  199. UInt32 Depth;
  200. UInt16 card;
  201. LocalID db;
  202. int Model;
  203. // UInt16 InitDelay,Period,DoubleTapDelay;
  204. // Boolean QueueAhead;
  205. NodeRegisterClass(&Platform);
  206. Context()->Platform = NodeEnumObject(NULL,PLATFORM_ID);
  207. Model = QueryPlatform(PLATFORM_MODEL);
  208. if (SysCurAppDatabase(&card, &db)==errNone)
  209. {
  210. SysNotifyRegister(card, db, sysNotifyVolumeMountedEvent, NULL, sysNotifyNormalPriority, 0);
  211. SysNotifyRegister(card, db, sysNotifySleepRequestEvent, NULL, sysNotifyNormalPriority, 0);
  212. SysNotifyRegister(card, db, sysNotifySleepNotifyEvent, NULL, sysNotifyNormalPriority, 0);
  213. SysNotifyRegister(card, db, sysNotifyLateWakeupEvent, NULL, sysNotifyNormalPriority, 0);
  214. }
  215. #ifdef HAVE_PALMONE_SDK
  216. if (SysLibFind(kHWUtilsName, &HWU) == sysErrLibNotFound)
  217. SysLibLoad(kHWUtilsType, kHWUtilsCreator, &HWU);
  218. if (HWU != sysInvalidRefNum && SysLibOpen(HWU)!=errNone)
  219. HWU = sysInvalidRefNum;
  220. if (HWU != sysInvalidRefNum)
  221. DisplayPowerSupport = 1;
  222. HSExt54 = FtrGet( hsFtrCreator, hsFtrIDVersion, &Version)==errNone && Version>=0x05400000;
  223. #if 0
  224. // for some reason the player crashes during program exit on Treo650
  225. if (HSExt54 && Model==MODEL_TREO_650 && !DisplayPowerSupport)
  226. {
  227. HALTreo650 = 1;
  228. DisplayPowerSupport = 1;
  229. }
  230. #endif
  231. #endif
  232. if (Model==MODEL_ZODIAC)
  233. {
  234. OEMSleep = 1;
  235. DisplayPowerSupport = 1;
  236. }
  237. DIA_Init();
  238. Depth = 16; // set screen mode to 16bit if possible
  239. WinScreenMode(winScreenModeSet, NULL, NULL, &Depth, NULL);
  240. HighDens = FtrGet(sysFtrCreator, sysFtrNumWinVersion, &Version)==errNone && Version>=4;
  241. // KeyRates(0,&KeyInitDelay,&KeyPeriod,&KeyDoubleTapDelay,&KeyQueueAhead);
  242. // InitDelay = 100; 
  243. // Period = 50;
  244. // DoubleTapDelay = 100;
  245. // QueueAhead = 0;
  246. // KeyRates(1,&InitDelay,&Period,&DoubleTapDelay,&QueueAhead);
  247. File_Init();
  248. FileDb_Init();
  249. VFS_Init();
  250. }
  251. void Log_Done()
  252. {
  253. }
  254. void Platform_Done()
  255. {
  256. UInt16 card;
  257. LocalID db;
  258. // KeyRates(1,&KeyInitDelay,&KeyPeriod,&KeyDoubleTapDelay,&KeyQueueAhead);
  259. File_Done();
  260. FileDb_Done();
  261. VFS_Done();
  262. NodeUnRegisterClass(PLATFORM_ID);
  263. SetDisplayPower(1,0);
  264. SetKeyboardBacklight(1);
  265. SleepTimeout(0,0);
  266.     WinScreenMode(winScreenModeSetToDefaults, NULL, NULL, NULL, NULL);
  267. DIA_Done();
  268. #ifdef HAVE_PALMONE_SDK
  269. if (HWU != sysInvalidRefNum)
  270. {
  271. SysLibClose(HWU);
  272. HWU = sysInvalidRefNum;
  273. }
  274. #endif
  275. if (SysCurAppDatabase(&card, &db)==errNone)
  276. {
  277. SysNotifyUnregister(card, db, sysNotifyVolumeMountedEvent, sysNotifyNormalPriority);
  278. SysNotifyUnregister(card, db, sysNotifySleepRequestEvent, sysNotifyNormalPriority);
  279. SysNotifyUnregister(card, db, sysNotifySleepNotifyEvent, sysNotifyNormalPriority);
  280. SysNotifyUnregister(card, db, sysNotifyLateWakeupEvent, sysNotifyNormalPriority);
  281. }
  282. free(Palette);
  283. Palette = NULL;
  284. }
  285. int ThreadPriority(void* Thread,int Priority) { return 0; }
  286. void* ThreadCreate(int(*Start)(void*),void* Parameter,int Quantum) { return NULL; }
  287. void WaitDisable(bool_t v) {}
  288. bool_t WaitBegin() { return 0; }
  289. void WaitEnd() {}
  290. bool_t GetKeyboardBacklight()
  291. {
  292. #ifdef HAVE_PALMONE_SDK
  293. if (HSExt54)
  294. return (HsCurrentLightCircumstance() & hsLightCircumstanceKeylightOffFlagBit)==0;
  295. #endif
  296. return 0;
  297. }
  298. static int _SetKeyboardBacklight(bool_t State)
  299. {
  300. #ifdef HAVE_PALMONE_SDK
  301. if (HSExt54 && HsLightCircumstance((Boolean)(State==0),hsLightCircumstanceKeylightOff)==errNone)
  302. return ERR_NONE;
  303. #endif
  304. return ERR_NOT_SUPPORTED;
  305. }
  306. int SetKeyboardBacklight(bool_t State)
  307. {
  308. int Result = ERR_NONE;
  309. if (!State)
  310. {
  311. if (GetKeyboardBacklight())
  312. {
  313. Result = _SetKeyboardBacklight(0);
  314. ++KeyboardBacklight;
  315. }
  316. }
  317. else
  318. {
  319. for (;KeyboardBacklight>0;--KeyboardBacklight)
  320. Result = _SetKeyboardBacklight(1);
  321. }
  322. return Result;
  323. }
  324. bool_t GetDisplayPower()
  325. {
  326. #ifdef HAVE_PALMONE_SDK
  327. if (HWU != sysInvalidRefNum)
  328. {
  329. static UInt16 HWU2 = sysInvalidRefNum;
  330. Boolean b = HWUGetDisplayState(HWU);
  331. // some graffiti utlitize can unload HWUtils 
  332. // (example Graffiti Anywhere on T|T: power off, action,action to turn on)
  333. if (b!=1 && SysLibFind(kHWUtilsName, &HWU2) == sysErrLibNotFound)
  334. {
  335. SysLibLoad(kHWUtilsType, kHWUtilsCreator, &HWU2);
  336. b = HWUGetDisplayState(HWU);
  337. }
  338. if (b && !HWUDisplayPower)
  339. {
  340. EvtEnableGraffiti(true);
  341. HWUBlinkLED(HWU,0);
  342. }
  343. HWUDisplayPower = b!=0;
  344. return HWUDisplayPower;
  345. }
  346. if (HALTreo650)
  347. {
  348. UInt32 n = 1;
  349. HsAttrGet(hsAttrDisplayOn,0,&n);
  350. return n != 0;
  351. }
  352. #endif
  353. if (OEMSleep)
  354. return (GetOEMSleepMode() & 2) == 0;
  355. return 1;
  356. }
  357. int SetDisplayPower(bool_t State,bool_t Force)
  358. {
  359. if (OEMSleep)
  360. {
  361. int OldMode = GetOEMSleepMode();
  362. int NewMode = State?(SleepCatch?1:0):2;
  363. if ((OldMode & 2) != (NewMode & 2))
  364. {
  365. if ((OldMode & 3) && !NewMode)
  366. EvtResetAutoOffTimer();
  367. SetOEMSleepMode(NewMode);
  368. }
  369. return ERR_NONE;
  370. }
  371. if (!Force && State == GetDisplayPower())
  372. return ERR_NONE;
  373. #ifdef HAVE_PALMONE_SDK
  374. if (HWU != sysInvalidRefNum && HWUEnableDisplay(HWU,(Boolean)State)==errNone)
  375. {
  376. if (!State)
  377. HWUSetBlinkRate(HWU,1000);
  378. else
  379. EvtResetAutoOffTimer();
  380. EvtEnableGraffiti((Boolean)State);
  381. if (State || QueryAdvanced(ADVANCED_BLINKLED))
  382. HWUBlinkLED(HWU,(Boolean)(!State));
  383. HWUDisplayPower = State;
  384. return ERR_NONE;
  385. }
  386. if (HALTreo650)
  387. {
  388. if (!State)
  389. HALDisplayOff_TREO650();
  390. else
  391. HALDisplayWake();
  392. return ERR_NONE;
  393. }
  394. #endif
  395. return ERR_NOT_SUPPORTED;
  396. }
  397. void LaunchNotify(SysNotifyParamType* Params,bool_t HasFocus)
  398. {
  399. DIAResizedNotify(Params);
  400. if (Params->notifyType == sysNotifyLateWakeupEvent)
  401. {
  402. bool_t b = 0;
  403. node* Player = Context()->Player;
  404. if (Player)
  405. Player->Set(Player,PLAYER_POWEROFF,&b,sizeof(b));
  406. }
  407. if (Params->notifyType == sysNotifySleepNotifyEvent && !(SleepCatch && OEMSleep))
  408. {
  409. bool_t b = 1;
  410. node* Player = Context()->Player;
  411. if (Player)
  412. Player->Set(Player,PLAYER_POWEROFF,&b,sizeof(b));
  413. }
  414. /*
  415. if (Params->notifyType == sysNotifySleepRequestEvent && !OEMSleep && HasFocus &&
  416. ((SleepEventParamType*)Params->notifyDetailsP)->reason == sysSleepPowerButton && !GetDisplayPower())
  417. {
  418. ((SleepEventParamType*)Params->notifyDetailsP)->deferSleep++;
  419. Params->handled = 1;
  420. SetDisplayPower(1,0);
  421. SetKeyboardBacklight(1);
  422. }
  423. */
  424. if (Params->notifyType == sysNotifySleepRequestEvent && SleepCatch && !OEMSleep && HasFocus &&
  425. ((SleepEventParamType*)Params->notifyDetailsP)->reason == sysSleepAutoOff)
  426. {
  427. ((SleepEventParamType*)Params->notifyDetailsP)->deferSleep++;
  428. Params->handled = 1;
  429. SetDisplayPower(0,0);
  430. SetKeyboardBacklight(0);
  431. }
  432. if (Params->notifyType == sysNotifyVolumeMountedEvent)
  433. {
  434. Params->handled |= vfsHandledStartPrc|vfsHandledUIAppSwitch;
  435. //todo: switch to this volume in open dialog...
  436. }
  437. }
  438. void SleepTimerReset()
  439. {
  440. }
  441. void SleepTimeout(bool_t KeepProcess,bool_t KeepDisplay)
  442. {
  443. bool_t Disable;
  444. if (!DisplayPowerSupport || !KeepProcess)
  445. KeepDisplay = KeepProcess;
  446. Disable = KeepProcess && KeepDisplay;
  447. SleepCatch = KeepProcess && !KeepDisplay;
  448. if (SleepDisable != Disable)
  449. {
  450. SleepDisable = Disable;
  451. if (Disable)
  452. {
  453. SetDisplayPower(1,0);
  454. SleepSave = SysSetAutoOffTime(0);
  455. }
  456. else
  457. {
  458. if (!SleepCatch) 
  459. {
  460. EvtResetAutoOffTimer();
  461. GetDisplayPower(); // update
  462. }
  463. SysSetAutoOffTime(SleepSave);
  464. }
  465. }
  466. if (OEMSleep)
  467. {
  468. int OldMode = GetOEMSleepMode();
  469. if (((OldMode & 3)!=0) != SleepCatch)
  470. {
  471. if ((OldMode & 3) && !SleepCatch)
  472. EvtResetAutoOffTimer();
  473. SetOEMSleepMode(SleepCatch?1:0);
  474. }
  475. }
  476. }
  477. void _Assert(const char* Exp,const char* File,int Line)
  478. {
  479. tchar_t TExp[MAXPATH];
  480. tchar_t TFile[MAXPATH];
  481. AsciiToTcs(TExp,TSIZEOF(TExp),File);
  482. stprintf_s(TFile,TSIZEOF(TFile),T("n%s:%d"),TExp,Line);
  483. AsciiToTcs(TExp,TSIZEOF(TExp),Exp);
  484. FrmCustomAlert(WarningOKAlert,TExp,TFile," ");
  485. }
  486. void ShowMessage(const tchar_t* Title,const tchar_t* Msg,...)
  487. {
  488. tchar_t s[512];
  489. va_list Args;
  490. va_start(Args,Msg);
  491. if (Title)
  492. {
  493. tcscpy_s(s,TSIZEOF(s),Title);
  494. tcscat_s(s,TSIZEOF(s),T(":n"));
  495. }
  496. else
  497. s[0] = 0;
  498. vstprintf_s(s+tcslen(s),TSIZEOF(s)-tcslen(s), Msg, Args);
  499. va_end(Args);
  500. DIASet(DIA_TASKBAR,DIA_TASKBAR);
  501. FrmCustomAlert(WarningOKAlert, s, " ", " ");
  502. }
  503. void HotKeyToString(tchar_t* Out, size_t OutLen, int HotKey)
  504. {
  505. Out[0] = 0;
  506. if (HotKey)
  507. {
  508. bool_t Keep = (HotKey & HOTKEY_KEEP) != 0;
  509. HotKey &= HOTKEY_MASK;
  510. stprintf_s(Out,OutLen,T("#%02X"),HotKey);
  511. if (Keep) tcscat_s(Out,OutLen,T("*")); 
  512. }
  513. }
  514. void ThreadSleep(int Time) 
  515. SysTaskDelay(Time);
  516. }
  517. int GetTimeFreq() 
  518. return SysTicksPerSecond();
  519. }
  520. int GetTimeTick()
  521. {
  522. return TimGetTicks();
  523. }
  524. void GetTimeCycle(int* p)
  525. {
  526. int n=1;
  527. int j;
  528. int i = TimGetTicks();
  529. while ((j = TimGetTicks())==i)
  530. ++n;
  531. p[0] = j;
  532. p[1] = n;
  533. }
  534. #ifdef _WIN32
  535. #include <windows.h>
  536. static FILE* Debug = NULL;
  537. #endif
  538. void DebugMessage(const tchar_t* Msg, ...)
  539. {
  540. va_list Args;
  541.     RectangleType r;
  542. tchar_t s[512];
  543. va_start(Args,Msg);
  544. vstprintf_s(s,TSIZEOF(s), Msg, Args);
  545. va_end(Args);
  546.     r.topLeft.x = 0;
  547.     r.topLeft.y = 0;
  548.     r.extent.x = 160;
  549.     r.extent.y = 15; 
  550.     WinEraseRectangle(&r, 0);
  551.     WinDrawChars(s, (Int16)strlen(s), 1, 1);
  552. #ifdef _WIN32
  553. if (!Debug) Debug = fopen("\debug.txt","w+");
  554. tcscat_s(s,TSIZEOF(s),"n");
  555. OutputDebugString(s);
  556. fprintf(Debug,"%s",s);
  557. fflush(Debug);
  558. #endif
  559. }
  560. void* BrushCreate(rgbval_t Color) { return (void*)Color; }
  561. void BrushDelete(void* Handle) {}
  562. void WinFill(void* DC,rect* Rect,rect* Exclude,void* Brush)
  563. {
  564. uint32_t Color = (uint32_t)Brush;
  565. RGBColorType c,c0;
  566. RectangleType r;
  567. UInt16 OldCoord = 0;
  568. WinHandle Old = NULL;
  569. if (DC)
  570. Old = WinSetDrawWindow(FrmGetWindowHandle((FormType*)DC));
  571. if (HighDens)
  572. OldCoord = WinSetCoordinateSystem(kCoordinatesNative);
  573. c.index = 0;
  574. c.r = ((rgb*)&Color)->c.r;
  575. c.g = ((rgb*)&Color)->c.g;
  576. c.b = ((rgb*)&Color)->c.b;
  577. WinSetBackColorRGB(&c,&c0);
  578. r.topLeft.x = (Coord)Rect->x;
  579. r.topLeft.y = (Coord)Rect->y;
  580. r.extent.x = (Coord)Rect->Width;
  581. r.extent.y = (Coord)Rect->Height;
  582. if (Exclude)
  583. {
  584. r.extent.y = (Coord)(Exclude->y - Rect->y);
  585. if (r.extent.y > 0 && r.extent.x > 0)
  586. WinEraseRectangle(&r,0);
  587. r.extent.y = (Coord)(Rect->y + Rect->Height - Exclude->y - Exclude->Height);
  588. r.topLeft.y = (Coord)(Exclude->y + Exclude->Height);
  589. if (r.extent.y > 0 && r.extent.x > 0)
  590. WinEraseRectangle(&r,0);
  591. r.extent.y = (Coord)Rect->Height;
  592. r.topLeft.y = (Coord)Rect->y; 
  593. r.extent.x = (Coord)(Exclude->x - Rect->x);
  594. if (r.extent.x > 0 && r.extent.y > 0)
  595. WinEraseRectangle(&r,0);
  596. r.extent.x = (Coord)(Rect->x + Rect->Width - Exclude->x - Exclude->Width);
  597. r.topLeft.x = (Coord)(Exclude->x + Exclude->Width);
  598. if (r.extent.x > 0 && r.extent.y > 0)
  599. WinEraseRectangle(&r,0);
  600. }
  601. else
  602. if (r.extent.x > 0 && r.extent.y > 0)
  603. WinEraseRectangle(&r,0);
  604. WinSetBackColorRGB(&c0,&c);
  605. if (HighDens)
  606. WinSetCoordinateSystem(OldCoord);
  607. if (Old)
  608. WinSetDrawWindow(Old);
  609. }
  610. void WinUpdate()
  611. {
  612. }
  613. void WinValidate(const rect* Rect)
  614. {
  615. }
  616. void WinInvalidate(const rect* Rect, bool_t Local)
  617. {
  618. }
  619. void ReleaseModule(void** Module)
  620. {
  621. if (*Module)
  622. *Module = NULL;
  623. }
  624. int64_t GetTimeDate()
  625. {
  626. DateTimeType Date;
  627. TimSecondsToDateTime(TimGetSeconds(),&Date);
  628. return (((Date.hour*100)+Date.minute)*100+Date.second)*1000 +
  629. (int64_t)(((Date.year*100)+Date.month)*100+Date.day) * 1000000000;
  630. }
  631. bool_t SaveDocument(const tchar_t* Name, const tchar_t* Text,tchar_t* URL,int URLLen)
  632. {
  633. //todo...
  634. return 0;
  635. }
  636. void GetDebugPath(tchar_t* Path, int PathLen, const tchar_t* FileName)
  637. {
  638. stprintf_s(Path,PathLen,T("slot1:\%s"),FileName);
  639. }
  640. void GetSystemPath(tchar_t* Path, int PathLen, const tchar_t* FileName)
  641. {
  642. if (PathLen>0)
  643. *Path = 0;
  644. }
  645. double compability_with_old_aac(int i) { return i; } // needed for defining __floatsidf()
  646. #endif