void S1Init() { char str[16]; char name[16]; ScreenBox.g_x = ScreenBox.g_y = 0; ScreenBox.g_w = 320; ScreenBox.g_h = 192; /* initialiser ecrans */ UnTiny(TnyRayoid); MemClear(_Screens[0],32000L); MemClear(_Screens[1],32000L); SwapReset(); Alien.on = 0; Alien.mis.on = 0; Joueur[0].points = 0; S1Bonus = 2000; S1Level = 0; S1AstCreate(); strcpy(str,"~8"); strcpy(name,S1Stats.name); StrRight(name,8); strcat(str,name); _ShowStr(200,192,str,0); CopyZone(192,192,80,8); DrawNumber(272,192,S1Stats.score); S1ShowSpare(4); }
int InitTank() { int ii; /* initialiser cookie */ InitCookie(); /* sauvegarder palette des couleurs */ for ( ii = 0; ii < 16; ii++ ) SavPalette[ii] = Setcolor(ii,-1); /* aller en basse resolution */ SavRez = Getrez(); if ( SavRez > 1 ) return (1); /* mise en place des ecrans de travail */ _SavLogScreen = (char *)Logbase(); _SavPhyScreen = (char *)Physbase(); _Screens[0] = (char *)malloc(32256L); _Screens[1] = (char *)malloc(32256L); if ( _Screens[0] == 0 || _Screens[1] == 0L ) return (2); _Screens[0] = _ShowScreen = (char *)((long)(_Screens[0] + 255) & 0xFFFFFF00L); _Screens[1] = _HideScreen = (char *)((long)(_Screens[1] + 255) & 0xFFFFFF00L); MemClear(_Screens[0],32000L); MemClear(_Screens[1],32000L); Setpalette(BlackPalette); if ( ShipSetUp(0) == 0 ) return (2); if ( MiscSetUp() == 0 ) return (2); if ( StarSetUp() == 0 ) return (2); if ( AstSetUp() == 0 ) return (2); if ( ExplSetUp() == 0 ) return (2); Setscreen(_Screens[0],_Screens[0],0); TTSpl = ((Cookies.snd & 2) != 0); SplOn._proc = _SplOnProc[ TTSpl ]; SplOff._proc = _SplOffProc[ TTSpl ]; NStars = (Cookies.cpu > 10) ? 32 : 16; return (0); }
//----- (0000272C) -------------------------------------------------------- __myevic__ uint32_t hidLDUpdateCmd( CMD_T *pCmd ) { myprintf( "Update LDROM command - Start page: %d\t\tLen: %d\n", pCmd->u32Arg1, pCmd->u32Arg2 ); MemClear( hidData, FMC_FLASH_PAGE_SIZE ); hidDataIndex = 0; pCmd->u32Signature = 0; return 0; }
/* InitDialogStorage(dsp, offset, multiplier) We use a DialogStorage structure to store working values during the dialog. In a Macintosh application, the fields in this structure could be local variables in the main dialog routine. However, in a Windows application, they would have to be globals. By using a structure like this, we are able to avoid using globals. Also, routines that access these fields (such as this one) can be used for both platforms. */ static int InitDialogStorage(DialogStorage* dsp, double* offsetPtr, double* multiplierPtr) { MemClear(dsp, sizeof(DialogStorage)); dsp->offsetPtr = offsetPtr; dsp->multiplierPtr = multiplierPtr; return 0; }
void * GetPoolHunk (MemPool * Pool,bool AutoExtendFlag) { void * Ret; struct MemBlock * CurMemBlock; if ( Pool->NumFreedHunks > 0 ) { Pool->NumFreedHunks--; Ret = Pool->FreedHunks[Pool->NumFreedHunks]; Pool->NumItemsActive++; MemClear(Ret,Pool->HunkLength); return(Ret); } if ( (CurMemBlock = Pool->CurMemBlock) == NULL ) return(NULL); if ( CurMemBlock->MemFree < Pool->HunkLength ) { if ( AutoExtendFlag ) { if ( ! ExtendPool(Pool,Pool->AutoExtendNumItems) ) return(NULL); CurMemBlock = Pool->CurMemBlock; } else { return(NULL); } } Ret = (void *) CurMemBlock->MemPtr; CurMemBlock->MemFree -= Pool->HunkLength; CurMemBlock->MemPtr += Pool->HunkLength; MemClear(Ret,Pool->HunkLength); Pool->NumItemsActive++; return(Ret); }
// PlayerGetPluginITFileSpec // OSStatus PlayerGetPluginITFileSpec (void *appCookie, ITAppProcPtr appProc, ITFileSpec *pluginFileSpec) { PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.getPluginITFileSpecMessage.fileSpec = pluginFileSpec; return ITCallApplication(appCookie, appProc, kPlayerGetPluginITFileSpecMessage, &messageInfo); }
// PlayerSetFullScreen // OSStatus PlayerSetFullScreen (void *appCookie, ITAppProcPtr appProc, Boolean fullScreen) { PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.setFullScreenMessage.fullScreen = fullScreen; return ITCallApplication(appCookie, appProc, kPlayerSetFullScreenMessage, &messageInfo); }
// PlayerSetPluginData // OSStatus PlayerSetPluginData (void *appCookie, ITAppProcPtr appProc, void *dataPtr, UInt32 dataSize) { PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.setPluginDataMessage.dataPtr = dataPtr; messageInfo.u.setPluginDataMessage.dataSize = dataSize; return ITCallApplication(appCookie, appProc, kPlayerSetPluginDataMessage, &messageInfo); }
// PlayerSetFileTrackInfo // OSStatus PlayerSetFileTrackInfo (void *appCookie, ITAppProcPtr appProc, const ITFileSpec *fileSpec, const ITTrackInfo *trackInfo) { PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.setFileTrackInfoMessage.fileSpec = fileSpec; messageInfo.u.setFileTrackInfoMessage.trackInfo = trackInfo; return ITCallApplication(appCookie, appProc, kPlayerSetFileTrackInfoMessage, &messageInfo); }
// PlayerOpenURL // void PlayerOpenURL (void *appCookie, ITAppProcPtr appProc, SInt8 *string, UInt32 length) { PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.openURLMessage.url = string; messageInfo.u.openURLMessage.length = length; ITCallApplication(appCookie, appProc, kPlayerOpenURLMessage, &messageInfo); }
// PlayerGetITTrackInfoSize // OSStatus PlayerGetITTrackInfoSize (void *appCookie, ITAppProcPtr appProc, UInt32 appPluginMajorVersion, UInt32 appPluginMinorVersion, UInt32 *itTrackInfoSize) { PlayerMessageInfo messageInfo; OSStatus status; /* Note: appPluginMajorVersion and appPluginMinorVersion are the versions given to the plugin by iTunes in the plugin's init message. These versions are *not* the version of the API used when the plugin was compiled. */ *itTrackInfoSize = 0; MemClear(&messageInfo, sizeof(messageInfo)); status = ITCallApplication(appCookie, appProc, kPlayerGetITTrackInfoSizeMessage, &messageInfo); if( status == noErr ) { *itTrackInfoSize = messageInfo.u.getITTrackInfoSizeMessage.itTrackInfoSize; } else if( appPluginMajorVersion == 10 && appPluginMinorVersion == 2 ) { // iTunes 2.0.x *itTrackInfoSize = ((UInt32) &((ITTrackInfo *) 0)->composer); status = noErr; } else if( appPluginMajorVersion == 10 && appPluginMinorVersion == 3 ) { // iTunes 3.0.x *itTrackInfoSize = ((UInt32) &((ITTrackInfo *) 0)->beatsPerMinute); status = noErr; } else { // iTunes 4.0 and later implement the kPlayerGetITTrackInfoSizeMessage message. If you got here // then the appPluginMajorVersion or appPluginMinorVersion are incorrect. status = paramErr; } if( status == noErr && (*itTrackInfoSize) > sizeof(ITTrackInfo) ) { // iTunes is using a larger ITTrackInfo than the one when this plugin was compiled. Pin *itTrackInfoSize to the plugin's known size *itTrackInfoSize = sizeof(ITTrackInfo); } return status; }
// PlayerSetFullScreenOptions // OSStatus PlayerSetFullScreenOptions (void *appCookie, ITAppProcPtr appProc, SInt16 minBitDepth, SInt16 maxBitDepth, SInt16 preferredBitDepth, SInt16 desiredWidth, SInt16 desiredHeight) { PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.setFullScreenOptionsMessage.minBitDepth = minBitDepth; messageInfo.u.setFullScreenOptionsMessage.maxBitDepth = maxBitDepth; messageInfo.u.setFullScreenOptionsMessage.preferredBitDepth = preferredBitDepth; messageInfo.u.setFullScreenOptionsMessage.desiredWidth = desiredWidth; messageInfo.u.setFullScreenOptionsMessage.desiredHeight = desiredHeight; return ITCallApplication(appCookie, appProc, kPlayerSetFullScreenOptionsMessage, &messageInfo); }
// PlayerGetCurrentTrackCoverArt // OSStatus PlayerGetCurrentTrackCoverArt (void *appCookie, ITAppProcPtr appProc, Handle *coverArt, OSType *coverArtFormat) { OSStatus status; PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.getCurrentTrackCoverArtMessage.coverArt = nil; status = ITCallApplication(appCookie, appProc, kPlayerGetCurrentTrackCoverArtMessage, &messageInfo); *coverArt = messageInfo.u.getCurrentTrackCoverArtMessage.coverArt; if (coverArtFormat) *coverArtFormat = messageInfo.u.getCurrentTrackCoverArtMessage.coverArtFormat; return status; }
// ITCallApplication // static OSStatus ITCallApplicationInternal (void *appCookie, ITAppProcPtr handler, OSType message, UInt32 messageMajorVersion, UInt32 messageMinorVersion, PlayerMessageInfo *messageInfo) { PlayerMessageInfo localMessageInfo; if (messageInfo == nil) { MemClear(&localMessageInfo, sizeof(localMessageInfo)); messageInfo = &localMessageInfo; } messageInfo->messageMajorVersion = messageMajorVersion; messageInfo->messageMinorVersion = messageMinorVersion; messageInfo->messageInfoSize = sizeof(PlayerMessageInfo); return handler(appCookie, message, messageInfo); }
// PlayerGetPluginData // OSStatus PlayerGetPluginData (void *appCookie, ITAppProcPtr appProc, void *dataPtr, UInt32 dataBufferSize, UInt32 *dataSize) { OSStatus status; PlayerMessageInfo messageInfo; MemClear(&messageInfo, sizeof(messageInfo)); messageInfo.u.getPluginDataMessage.dataPtr = dataPtr; messageInfo.u.getPluginDataMessage.dataBufferSize = dataBufferSize; status = ITCallApplication(appCookie, appProc, kPlayerGetPluginDataMessage, &messageInfo); if (dataSize != nil) *dataSize = messageInfo.u.getPluginDataMessage.dataSize; return status; }
//----- (00002788) -------------------------------------------------------- __myevic__ void hidGetOutReport( uint8_t *pu8Buffer, uint32_t u32BufferLen ) { uint8_t u8Cmd; uint8_t *hidDataPtr; uint32_t u32StartAddr; uint32_t u32DataSize; uint32_t u32ByteCount; uint32_t u32Page; uint32_t sz; uint32_t veo; u8Cmd = hidCmd.u8Cmd; u32StartAddr = hidCmd.u32Arg1; u32DataSize = hidCmd.u32Arg2; u32ByteCount = hidCmd.u32Signature; hidDataPtr = &hidData[hidDataIndex]; switch ( hidCmd.u8Cmd ) { case HID_CMD_SETPARAMS: { USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE ); hidDataIndex += EP3_MAX_PKT_SIZE; if ( hidDataIndex >= u32DataSize ) { u8Cmd = HID_CMD_NONE; if ( u32StartAddr + u32DataSize > FMC_FLASH_PAGE_SIZE ) { sz = FMC_FLASH_PAGE_SIZE - u32StartAddr; } else { sz = u32DataSize; } MemCpy( (uint8_t*)(&hidDFData) + u32StartAddr, hidData, sz ); myprintf( "Set Sys Param complete.\n" ); dfStruct_t * df = (dfStruct_t*)hidDFData; if ( Checksum( (uint8_t*)df->params, FMC_FLASH_PAGE_SIZE - 4 ) == df->Checksum ) { myprintf( "\tCompany ID ............................ [0x%08x]\n", df->i.fmcCID ); myprintf( "\tDevice ID ............................. [0x%08x]\n", df->i.fmcDID ); myprintf( "\tProduct ID ............................ [0x%08x]\n", df->i.fmcPID ); myprintf( "\tu8UpdateAPRom ......................... [0x%08x]\n", df->p.BootFlag ); MemCpy( DataFlash.params, df->params, DATAFLASH_PARAMS_SIZE ); DFCheckValuesValidity(); UpdateDataFlash(); if ( df->i.Year >= 2000 && df->i.Year <= 2099 ) { S_RTC_TIME_DATA_T rtd; rtd.u32Year = df->i.Year; rtd.u32Month = df->i.Month; rtd.u32Day = df->i.Day; rtd.u32DayOfWeek = 0; rtd.u32Hour = df->i.Hour; rtd.u32Minute = df->i.Minute; rtd.u32Second = df->i.Second; rtd.u32TimeScale = RTC_CLOCK_24; SetRTC( &rtd ); } gFlags.refresh_display = 1; } else { myprintf( "Sys Param Receive fail.\n" ); } hidDataIndex = 0; } break; } case HID_CMD_SETLOGO: { USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE ); hidDataIndex += EP3_MAX_PKT_SIZE; if ( hidDataIndex < FMC_FLASH_PAGE_SIZE && hidDataIndex + u32ByteCount < u32DataSize ) { break; } u32Page = u32StartAddr + u32ByteCount; myprintf( "Writing page %d\n", u32Page ); SYS_UnlockReg(); FMC_ENABLE_ISP(); FMC_ENABLE_AP_UPDATE(); if ( FMCEraseWritePage( u32Page, (uint32_t*)hidData ) ) { myprintf( "Data Flash Erase error!\n" ); } veo = FMCVerifyPage( u32Page, (uint32_t*)hidData ); if ( veo ) { myprintf( "Data Flash Verify error! 0x%x\n", 4 * veo - 4 ); } MemClear( hidData, FMC_FLASH_PAGE_SIZE ); u32ByteCount += hidDataIndex; myprintf( "g_u32BytesInPageBuf %d, u32LenCnt 0x%x\n", hidDataIndex, u32ByteCount ); FMC_DISABLE_AP_UPDATE(); FMC_DISABLE_ISP(); SYS_LockReg(); if ( u32ByteCount < u32DataSize ) { hidDataIndex = 0; } else { u8Cmd = HID_CMD_NONE; myprintf( "set boot logo command complete.\n" ); } break; } case HID_CMD_LDUPDATE: { USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE ); hidDataIndex += EP3_MAX_PKT_SIZE; if ( hidDataIndex < FMC_FLASH_PAGE_SIZE && hidDataIndex + u32ByteCount < u32DataSize ) { break; } u32Page = u32StartAddr + u32ByteCount; myprintf( "Writing page 0x%08X\n", u32Page ); SYS_UnlockReg(); FMC_ENABLE_ISP(); FMC_EnableLDUpdate(); if ( FMCEraseWritePage( u32Page, (uint32_t*)hidData ) ) { myprintf( "Data Flash Erase error!\n" ); } veo = FMCVerifyPage( u32Page, (uint32_t*)hidData ); if ( veo ) { myprintf( "Data Flash Verify error! 0x%x\n", 4 * veo - 4 ); } MemClear( hidData, FMC_FLASH_PAGE_SIZE ); u32ByteCount += hidDataIndex; hidDataIndex = 0; myprintf( "g_u32BytesInPageBuf %d, u32LenCnt 0x%x\n", hidDataIndex, u32ByteCount ); FMC_DisableLDUpdate(); FMC_DISABLE_ISP(); SYS_LockReg(); if ( u32ByteCount >= u32DataSize ) { u8Cmd = HID_CMD_NONE; myprintf( "Update LDROM command complete.\n" ); } break; } default: { if ( hidProcessCommand( pu8Buffer, u32BufferLen ) ) { myprintf( "Unknown HID command!\n" ); } return; } } hidCmd.u8Cmd = u8Cmd; hidCmd.u32Signature = u32ByteCount; }
/* XOPSaveFileDialog(prompt, fileFilterStr, fileIndexPtr, initialDir, defaultExtensionStr, filePath) Displays the save file dialog. Returns 0 if the user provides a file name or -1 if the user cancels or another non-zero number in the event of an error. Returns the full path to the file via filePath. filePath is both an input and an output as explained below. In the event of a cancel, filePath is unmodified. filePath is a Macintosh HFS path on Macintosh and a Windows path on Windows. On Windows, prompt sets the dialog caption. On Macintosh, it sets a prompt string in the dialog. fileFilterStr is now used to control the contents of the Format popup menu in the Save File dialog. On Macintosh, if there is only one format in which you can save the file, pass "" for fileFilterStr. This will cause the Format menu to be hidden. If you can save the file in more than one format, pass a string like this: "Plain Text:TEXT:.txt;Igor Text:IGTX:.itx;" This would give you a Format menu like this: Plain Text Igor Text fileFilterStr on Macintosh fileFilterStr consists of sections terminated by a semicolon. For example, here is one section: "Data Files:TEXT:.dat;" Each section consists of three components: a menu item string (e.g., Data Files) to be displayed in the Format popup menu, a Macintosh file type (e.g., TEXT), and an extension (e.g., .dat). At present, only the menu item string and extension are used. The Macintosh file type is currently not used. If there is no meaningful Macintosh file type, leave the file type component empty. If there is no meaningful extension, leave the extension component empty. fileFilterStr on Windows On Windows, fileFilterStr identifies the types of files to display and the types of files that can be created. It is constructed as for the lpstrFilter field of the OPENFILENAME structure for the Windows GetSaveFileName routine. For example, to allow the user to save as a text file or as an Igor Text file, use "Text Files (*.txt)\0*.txt\0Igor Text Files (*.itx)\0*.itx\0\0". Note that the string ends with two null characters (\0\0). If fileFilterStr is "", this behaves the same as "Text Files (*.txt)\0*.txt\0\0". fileIndexPtr it is ignored if it is NULL. If it is not NULL, then *fileIndexPtr is the one-based index of the file type filter to be initially selected. In the example given above, setting *fileIndexPtr to 2 would select the Igor Text file type on entry to the dialog. On exit from the dialog, *fileIndexPtr is set to the index of the file type string that the user last selected. initialDir can be "" or it can point to a full path to a directory. It determines the directory that will be initially displayed in the save file dialog. If "", the directory will be the last directory that was seen in the open or save file dialogs. If initialDir points to a valid path to a directory, then this directory will be initially displayed in the dialog. On Macintosh, initialDir is a Macintosh HFS path. On Windows, it is a Windows path. defaultExtensionStr points to the extension to be added to the file name if the user does not enter an extension. For example, pass "txt" to have ".txt" appended if the user does not enter an extension. If you don't want any extension to be added in this case, pass NULL. Prior to XOP Toolkit 6.00, defaultExtensionStr was ignored on Macintosh. Returns via filePath the full path to the file that the user chose or "" if the user cancelled. The path is a Macintosh HFS path on Macintosh and a Windows path on Windows. filePath must point to a buffer of at least MAX_PATH_LEN+1 bytes. On Windows and Macintosh, the initial value of filePath sets the initial contents of the File Name edit control in the save file dialog. The following values are valid: "" If there is no initial file name a file name a full Mac or Win path to a file In the event of an error other than a cancel, XOPSaveFileDialog displays an error dialog. This should never or rarely happen. WINDOWS NOTES The dialog will appear in the upper left corner of the screen. This is because Windows provides no straight-forward way to set the position of the dialog. Thread Safety: XOPSaveFileDialog is not thread-safe. */ int XOPSaveFileDialog( const char* prompt, const char* fileFilterStr, int* fileIndexPtr, const char* initialDir, const char* defaultExtensionStr, char filePath[MAX_PATH_LEN+1]) { OPENFILENAME ofn; char filePath2[MAX_PATH_LEN+1]; char initialDir2[MAX_PATH_LEN+1]; if (!CheckRunningInMainThread("XOPSaveFileDialog")) return NOT_IN_THREADSAFE; if (*fileFilterStr == 0) fileFilterStr = "Text Files (*.txt)\0*.txt\0\0"; if (*initialDir == 0) { GetStandardFileWinPath(initialDir2); // Get Igor's save file dialog directory. } else { strcpy(initialDir2, initialDir); SetStandardFileWinPath(initialDir); // Sets initial directory for next save file dialog. This will be overridden below, but not if the user cancels. } /* HR, 040928, XOP Toolkit 5.04 Previously this copied filePath to filePath2. This was correct because the filePath parameter was supposed to be either "" or just the proposed file name. However, I incorrectly passed a full path for the filePath parameter in all of the sample XOPs. This mistake undoubtedly leaked into users' XOPs. Therefore I now allow filePath to be either "", just a file name, or a full path. */ // strcpy(filePath2, filePath); // HR, 010815: Previously filePath2 was set to "" which prevented the File Name item in the Windows Open File dialog from being preset as the comment above says it should be. GetLeafName(filePath, filePath2); MemClear(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = IgorClientHWND(); ofn.lpstrFile = filePath2; ofn.nMaxFile = MAX_PATH_LEN+1; ofn.lpstrFilter = fileFilterStr; ofn.nFilterIndex = fileIndexPtr==NULL ? 1 : *fileIndexPtr; ofn.lpstrDefExt = defaultExtensionStr; ofn.lpstrTitle = prompt; ofn.lpstrFileTitle = NULL; ofn.lpstrInitialDir = initialDir2; ofn.lpfnHook = OpenOrSaveFileNameHook; // Needed to set position of the dialog. Otherwise, it is in top/left corner of screen. ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; ofn.Flags |= OFN_EXPLORER; ofn.Flags |= OFN_ENABLEHOOK; // Needed so that hook will be called. ofn.Flags |= OFN_ENABLESIZING; // HR, 090121: Added this to get resizeable dialog. ofn.Flags |= OFN_HIDEREADONLY; ofn.Flags |= OFN_NOCHANGEDIR; // Changing the current directory causes problems. e.g., if set to floppy disk and the floppy is removed, the system slows down. if (GetSaveFileName(&ofn) == 0) { int err; err = CommDlgExtendedError(); // err will be zero if cancel. if (err == 0) return -1; // We got an error other than cancel. *filePath2 = 0; // HR, 021114: Clear possible bad fields *initialDir2 = 0; // and try again. if (GetSaveFileName(&ofn) != 0) { // Succeeded this time? err = 0; } else { if (CommDlgExtendedError() == 0) return -1; // User canceled. // Report the original error. err = WindowsErrorToIgorError(err); IgorError("XOPSaveFileDialog", err); return err; } } if (fileIndexPtr != NULL) *fileIndexPtr = ofn.nFilterIndex; strcpy(filePath, filePath2); SetStandardFileWinPath(filePath); // Update Igor's open file dialog directory. return 0; }
/* Create a two column text wave from two string vectors */ int createAndFillTextWave(DataFolderHandle baseFolderHandle, const StringPairVector& data, DataFolderHandle dataFolderHandle, const char* waveName, int brickletID, std::string& waveNameList) { // create 2D textwave with firstColumn.size() rows and 2 columns if (data.empty()) { HISTPRINT("BUG: list size may not be zero"); return UNKNOWN_ERROR; } CountInt dimensionSizes[MAX_DIMENSIONS + 1]; MemClear(dimensionSizes, sizeof(dimensionSizes)); dimensionSizes[ROWS] = data.size(); dimensionSizes[COLUMNS] = 2; waveHndl waveHandle; int ret = MDMakeWave(&waveHandle, waveName, dataFolderHandle, dimensionSizes, TEXT_WAVE_TYPE, isOverwriteEnabled()); if (ret == NAME_WAV_CONFLICT) { DEBUGPRINT("Wave %s already exists.", waveName); return WAVE_EXIST; } else if (ret != 0) { HISTPRINT("Error %d in creating wave %s.", ret, waveName); return UNKNOWN_ERROR; } // copy the strings of both columns into a new vector // so that they are then 1D // first: first, then: second std::vector<std::string> allColumns; try { allColumns.resize(data.size()*2); } catch (CMemoryException* e) { e->Delete(); HISTPRINT("Out of memory in createAndFillTextWave()"); return UNKNOWN_ERROR; } for (unsigned int i = 0; i < data.size(); i++) { allColumns[i] = data[i].first; allColumns[data.size()+i] = data[i].second; } ret = stringVectorToTextWave(allColumns, waveHandle); if (ret != 0) { HISTPRINT("stringVectorToTextWave returned %d", ret); return ret; } setOtherWaveNote(waveHandle, brickletID); appendToWaveList(baseFolderHandle, waveHandle, waveNameList); return 0; }
//========================================================================= // Additional initialisations //------------------------------------------------------------------------- __myevic__ void CustomStartup() { //------------------------------------------------------------------------- // EADC test if ( 0 ) { uint32_t s1, s2, s3; SetADCState( 0, 1 ); SetADCState( 4, 1 ); do { ClearScreenBuffer(); CLK_SysTickDelay( 10 ); s3 = ADC_Read( 4 ); CLK_SysTickDelay( 10 ); s1 = ADC_Read( 18 ); CLK_SysTickDelay( 10 ); s2 = ADC_Read( 0 ); DrawValue( 8, 0, s1, 0, 0x29, 4 ); DrawValue( 8, 20, s2, 0, 0x29, 4 ); DrawValue( 8, 40, s3, 0, 0x29, 4 ); DisplayRefresh(); WaitOnTMR2( 1000 ); } while ( PD3 ); } //------------------------------------------------------------------------- // Timer test 1 if ( 0 ) { TIMER_Stop( TIMER3 ); TIMER_Close( TIMER3 ); MemClear( gPlayfield.uc, 256 ); CLK_SetModuleClock( TMR3_MODULE, CLK_CLKSEL1_TMR3SEL_LIRC, 0 ); gPlayfield.ul[1] = TIMER_Open( TIMER3, TIMER_PERIODIC_MODE, 10 ); TIMER_EnableInt( TIMER3 ); TIMER_Start( TIMER3 ); } //------------------------------------------------------------------------- // Timer test 2 if ( 0 ) { TIMER_Close( TIMER2 ); TIMER_Close( TIMER3 ); MemClear( gPlayfield.uc, 256 ); CLK_SetModuleClock( TMR2_MODULE, CLK_CLKSEL1_TMR2SEL_HXT, 0 ); CLK_SetModuleClock( TMR3_MODULE, CLK_CLKSEL1_TMR3SEL_LIRC, 0 ); CLK_EnableModuleClock( TMR2_MODULE ); CLK_EnableModuleClock( TMR3_MODULE ); __set_PRIMASK(1); TIMER3->CTL |= TIMER_CTL_RSTCNT_Msk; TIMER2->CTL |= TIMER_CTL_RSTCNT_Msk; TIMER3->CMP = 1000; TIMER3->CTL = TIMER_CTL_CNTEN_Msk | TIMER_ONESHOT_MODE; TIMER2->CTL = TIMER_CTL_CNTEN_Msk | TIMER_CONTINUOUS_MODE; while(!(TIMER3->INTSTS & TIMER_INTSTS_TIF_Msk)); TIMER2->CTL = 0; gPlayfield.ul[0] = TIMER2->CNT; __set_PRIMASK(0); TIMER_Close( TIMER2 ); TIMER_Close( TIMER3 ); CLK_SetModuleClock( TMR2_MODULE, CLK_CLKSEL1_TMR2SEL_HIRC, 0 ); CLK_EnableModuleClock( TMR2_MODULE ); TIMER_Open( TIMER2, TIMER_PERIODIC_MODE, 1000 ); TIMER_EnableInt( TIMER2 ); TIMER_Start( TIMER2 ); CLK_SetModuleClock( TMR3_MODULE, CLK_CLKSEL1_TMR3SEL_HXT, 0 ); CLK_EnableModuleClock( TMR3_MODULE ); TIMER_Open( TIMER3, TIMER_PERIODIC_MODE, 10 ); TIMER_EnableInt( TIMER3 ); TIMER_Start( TIMER3 ); } return; }