GameData_Init1 (PGameInitData GameInitData) { ClearMem ( GameInitData, 8 ); GameInitData->GameRunning = 1; GameInitData->LogFileName = "APP.LOG"; }
static Bool CheckSerial(void) // call this routine AFTER resources have been initialized { Char data[SERIAL_SIZE], sn[SERIAL_SIZE]; if (!ReadPluginInfo(MYPLUGIN_ID, data, SERIAL_SIZE)) goto error; if (data[0] != 'O' || data[1] != 'K' || !Validate(data + 4)) goto error; // check your data here return true; error: // serial number could not be authenticated ClearMem(sn, SERIAL_SIZE); if (!OpenSerialDialog(sn)) return false; data[0] = 'O'; // write the serial number here data[1] = 'K'; CopyMem(sn, data + 4, SERIAL_SIZE - 4); return WritePluginInfo(MYPLUGIN_ID, data, SERIAL_SIZE); }
void scHandleArray::GrowSlots( long newItems ) { long oldSize = fElemSlots; raise_if( fItems == NULL, scERRmem ); fItems = MEMResizeHnd( (scMemHandle)fItems, fElemSize * ( fElemSlots + newItems ) ); fElemSlots += newItems; ClearMem( oldSize ); }
scHandleArray::scHandleArray( size_t elemSize, unsigned clearmem ) : scAbstractArray( elemSize, clearmem ) { fItems = (scMemHandle)MEMAllocHnd( fElemSize * fBlockSize ); fElemSlots = fBlockSize; ClearMem( 0 ); }
void scMemArray::GrowSlots( long newItems ) { long oldSize = fElemSlots; raise_if( fItems == NULL, scERRmem ); MEMResizePtr( &fItems, fElemSize * ( fElemSlots + newItems ) ); fElemSlots += newItems; ClearMem( oldSize ); }
scMemArray::scMemArray( size_t elemSize, unsigned clearmem ) : scAbstractArray( elemSize, clearmem ) { fItems = MEMAllocPtr( fElemSize * fBlockSize ); fElemSlots = fBlockSize; ClearMem( 0 ); }
StackInit (PVOID Stack, PGameData GameData) { PUCHAR StackBase; ClearMem ( 0xAC30, Stack ); StackBase = (Stack + 0x1000) & ~0xFFF; GameData->StackBase = StackBase; }
void scHandleArray::SizeSlots( long numItems ) { // do not shrink if we are retaining memory or if no resizing is // necessary // if ( ( numItems < fElemSlots && fRetainMem ) || fElemSlots == numItems ) return; long oldSize = fElemSlots; raise_if( fItems == NULL, scERRmem ); fItems = MEMResizeHnd( (scMemHandle)fItems, fElemSize * numItems ); fElemSlots = numItems; ClearMem( oldSize ); }
// Allocates the memory void GenericImageMemBase::CreateMem(size_t nBytes) { if (nBytes> m_byteSize) { ClearMem(); #ifndef INDI // NOTE we use malloc/free as this is used when transfering mem to wxImage :-( m_pByteMem= reinterpret_cast<unsigned char*>(::malloc(nBytes)); #else m_pByteMem= new unsigned char[nBytes]; #endif } if (m_pByteMem) { m_byteSize=nBytes; m_memOK=true; } }
GenericImageMemBase::~GenericImageMemBase() { ClearMem(); }
void gui_create_form_select_menu(struct gui_window *g, struct form_control *control) { struct Library *PopupMenuBase = NULL; struct PopupMenuIFace *IPopupMenu = NULL; struct Hook selectmenuhook; Object *selectmenuobj; Object *smenu = NULL; Object *currentmenu; Object *submenu = NULL; char *selectmenu_item[AMI_SELECTMENU_MAX]; char *more_label; struct form_option *opt = form_select_get_option(control, 0); int i = 0; int n = 0; if(ami_selectmenu_is_safe() == FALSE) return; if((PopupMenuBase = OpenLibrary("popupmenu.class", 0))) { IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase, "main", 1, NULL); } if(IPopupMenu == NULL) return; ClearMem(selectmenu_item, AMI_SELECTMENU_MAX * 4); more_label = ami_utf8_easy(messages_get("More")); selectmenuhook.h_Entry = ami_popup_hook; selectmenuhook.h_SubEntry = NULL; selectmenuhook.h_Data = g; g->shared->control = control; selectmenuobj = PMMENU(form_control_get_name(control)), PMA_MenuHandler, &selectmenuhook, End; currentmenu = selectmenuobj; while(opt) { selectmenu_item[i] = ami_utf8_easy(opt->text); IDoMethod(currentmenu, PM_INSERT, NewObject(POPUPMENU_GetItemClass(), NULL, PMIA_Title, (ULONG)selectmenu_item[i], PMIA_ID, i, PMIA_CheckIt, TRUE, PMIA_Checked, opt->selected, TAG_DONE), ~0); opt = opt->next; i++; n++; if(n == AMI_SELECTMENU_PAGE_MAX) { if(submenu != NULL) { /* attach the previous submenu */ IDoMethod(smenu, PM_INSERT, NewObject(NULL, "popupmenuitem.class", PMIA_Title, more_label, PMIA_CheckIt, TRUE, PMIA_SubMenu, submenu, TAG_DONE), ~0); } submenu = NewObject(NULL, "popupmenu.class", TAG_DONE); smenu = currentmenu; currentmenu = submenu; n = 0; } if(i >= AMI_SELECTMENU_MAX) break; } if((submenu != NULL) && (n != 0)) { /* attach the previous submenu */ IDoMethod(smenu, PM_INSERT, NewObject(NULL, "popupmenuitem.class", PMIA_Title, more_label, PMIA_CheckIt, TRUE, PMIA_SubMenu, submenu, TAG_DONE), ~0); } ami_set_pointer(g->shared, GUI_POINTER_DEFAULT, false); // Clear the menu-style pointer IDoMethod(selectmenuobj, PM_OPEN, g->shared->win); /* PM_OPEN is blocking, so dispose menu immediately... */ if(selectmenuobj) DisposeObject(selectmenuobj); /* ...and get rid of popupmenu.class ASAP */ if(IPopupMenu) DropInterface((struct Interface *)IPopupMenu); if(PopupMenuBase) CloseLibrary(PopupMenuBase); /* Free the menu labels */ if(more_label) ami_utf8_free(more_label); for(i = 0; i < AMI_SELECTMENU_MAX; i++) { if(selectmenu_item[i] != NULL) { ami_utf8_free(selectmenu_item[i]); selectmenu_item[i] = NULL; } } }
// // MAIN // // Main program loop, I/O polling and timing // void main () { // init ADCON1 = 0x7; // disable analog inputs TRISA = MASKPA; // set i/o config. TRISB = MASKPB; TRISC = MASKPC; PORTA = 0; // init all outputs PORTB = 0; PORTC = 0; OPTION = 0x8f; // prescaler assigned to WDT, // TMR0 clock/4, no pull ups CTLearn = 0; // Learn debounce CLearn = 0; // Learn timer COut = 0; // output timer CFlash = 0; // flash counter CTFlash = 0; // flash timer FLearn = FALSE; // start in normal mode F2Chance = FALSE; // no resynchronization required InitReceiver(); // enable and init the receiver state machine // main loop while ( TRUE) { if ( RFFull) // buffer contains a message Remote(); // loop waiting 512* period = 72ms if ( XTMR < 512) continue; // main loop // once every 72ms XTMR=0; // re-init fundamental registers ADCON1 = 0x7; // disable analog inputs TRISA = MASKPA; // set i/o config. TRISB = MASKPB; TRISC = MASKPC; OPTION = 0x0f; // prescaler assigned to WDT, TMR0 clock/4, pull up T0IE = 1; GIE = 1; // poll learn if ( !Learn) // low -> button pressed { CLearn++; // pressing Learn button for more than 10s -> ERASE ALL if (CLearn == 128) // 128 * 72 ms = 10s { Led = OFF; // switch off Learn Led while( !Learn); // wait for button release Led = ON; // signal Led on ClearMem(); // erase all comand! COut = TOUT; // single lomg flash pulse time // timer will switch off Led CLearn = 0; // reset learn debounce FLearn = FALSE; // exit learn mode } // normal Learn button debounce if (CLearn == 4) // 250ms debounce { FLearn = TRUE; // enter learn mode comand! CTLearn = TLEARN; // load timout value Led = ON; // turn Led on } } else CLearn=0; // reset counter // outputs timing if ( COut > 0) // if timer running { COut--; if ( COut == 0) // when it reach 0 { Led = OFF; // all outputs off Out0 = OFF; Out1 = OFF; Out2 = OFF; Out3 = OFF; Vlow = OFF; } } // Learn Mode timout after 18s (TLEARN * 72ms) if ( CTLearn > 0) { CTLearn--; // count down if ( CTLearn == 0) // if timed out { Led = OFF; // exit Learn mode FLearn = FALSE; } } // Led Flashing if ( CFlash > 0) { CTFlash--; // count down if ( CTFlash == 0) // if timed out { CTFlash = TFLASH; // reload timer CFlash--; // count one flash Led = OFF; // toggle Led if ( CFlash & 1) Led = ON; } } } // main loop } // main