/*********************** ** DoEmFloatIteration ** ************************ ** Perform an iteration of the emulated floating-point ** benchmark. Note that "an iteration" can involve multiple ** loops through the benchmark. */ ulong DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, ulong arraysize, ulong loops, double *wat_time) { ulong elapsed; /* For the stopwatch */ static uchar jtable[16] = {0,0,0,0,1,1,1,1,2,2,2,2,2,3,3,3}; ulong i; /* ** Begin timing */ elapsed=StartStopwatch(); TimerOn(); /* ** Each pass through the array performs operations in ** the followingratios: ** 4 adds, 4 subtracts, 5 multiplies, 3 divides ** (adds and subtracts being nearly the same operation) */ while(loops--) { for(i=0;i<arraysize;i++) switch(jtable[i % 16]) { case 0: /* Add */ AddSubInternalFPF(0,abase+i, bbase+i, cbase+i); break; case 1: /* Subtract */ AddSubInternalFPF(1,abase+i, bbase+i, cbase+i); break; case 2: /* Multiply */ MultiplyInternalFPF(abase+i, bbase+i, cbase+i); break; case 3: /* Divide */ DivideInternalFPF(abase+i, bbase+i, cbase+i); break; } } TimerOff(); elapsed = StopStopwatch(elapsed); if( wat_time ) { *wat_time = TimerElapsed(); } return(elapsed); }
/*********************** ** DoEmFloatIteration ** ************************ ** Perform an iteration of the emulated floating-point ** benchmark. Note that "an iteration" can involve multiple ** loops through the benchmark. */ ulong DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, ulong arraysize, ulong loops) { ulong elapsed; /* For the stopwatch */ static uchar jtable[16] = {0,0,0,0,1,1,1,1,2,2,2,2,2,3,3,3}; ulong i; #ifdef DEBUG int number_of_loops; #endif /* ** Begin timing */ elapsed=StartStopwatch(); #ifdef DEBUG number_of_loops=loops-1; /* the index of the first loop we run */ #endif /* ** Each pass through the array performs operations in ** the followingratios: ** 4 adds, 4 subtracts, 5 multiplies, 3 divides ** (adds and subtracts being nearly the same operation) */ while(loops--) { for(i=0;i<arraysize;i++) switch(jtable[i % 16]) { case 0: /* Add */ AddSubInternalFPF(0,abase+i, bbase+i, cbase+i); break; case 1: /* Subtract */ AddSubInternalFPF(1,abase+i, bbase+i, cbase+i); break; case 2: /* Multiply */ MultiplyInternalFPF(abase+i, bbase+i, cbase+i); break; case 3: /* Divide */ DivideInternalFPF(abase+i, bbase+i, cbase+i); break; } #ifdef DEBUG { ulong j[8]; /* we test 8 entries */ int k; ulong i; char buffer[1024]; if (number_of_loops==loops) /* the first loop */ { j[0]=(ulong)2; j[1]=(ulong)6; j[2]=(ulong)10; j[3]=(ulong)14; j[4]=(ulong)(arraysize-14); j[5]=(ulong)(arraysize-10); j[6]=(ulong)(arraysize-6); j[7]=(ulong)(arraysize-2); for(k=0;k<8;k++){ i=j[k]; InternalFPFToString(buffer,abase+i); printf("%6ld: (%s) ",i,buffer); switch(jtable[i % 16]) { case 0: strcpy(buffer,"+"); break; case 1: strcpy(buffer,"-"); break; case 2: strcpy(buffer,"*"); break; case 3: strcpy(buffer,"/"); break; } printf("%s ",buffer); InternalFPFToString(buffer,bbase+i); printf("(%s) = ",buffer); InternalFPFToString(buffer,cbase+i); printf("%s\n",buffer); } } } #endif } return(StopStopwatch(elapsed)); }
//--------------------------------------------------------------------------- int am_cbk_ZoneList(app_menu_t *pMenu, menu_item_t *pItem, int event, int param ) // Callback function, invoked from the "app menu" framework for the 'ZONES' list. // (lists ALL ZONES, not THE CHANNELS in a zone) { scroll_list_control_t *pSL = &pMenu->scroll_list; // what happened, why did the menu framework call us ? if( event==APPMENU_EVT_ENTER ) // pressed ENTER (to enter the 'Zone List') ? { ZoneList_OnEnter(pMenu, pItem); return AM_RESULT_OCCUPY_SCREEN; // occupy the entire screen (not just a single line) } else if(event==APPMENU_EVT_PAINT) // someone wants us to paint into the framebuffer { // To minimize QRM from the display cable, only redraw when necessary (no "dynamic" content here): if( pMenu->visible == APPMENU_USERSCREEN_VISIBLE ) // only if HexMon already 'occupied' the screen ! { if( pMenu->redraw ) { pMenu->redraw = FALSE; // don't modify this sequence ZoneList_Draw(pMenu, pItem); // <- may decide to draw AGAIN (scroll) } return AM_RESULT_OCCUPY_SCREEN; // keep the screen 'occupied' } } else if( event==APPMENU_EVT_KEY ) // some other key pressed while focused.. { switch( (char)param ) // here: message parameter = keyboard code (ASCII) { case 'M' : // green "Menu" key : kind of ENTER. But here, "apply & return" . if( pSL->focused_item>=0 ) { ZoneList_SetZoneByIndex( pSL->focused_item ); // The above command switched to the new zone, and probably set // channel_num = 0 to 'politely ask' the original firmware to // reload whever is necessary from the codeplug (SPI-Flash). // It's unknown when exactly that happens (possibly in another task). // To update the CHANNEL NAME from the *new* zone in our menu, // let a few hundred milliseconds pass before redrawing the screen: StartStopwatch( &pMenu->stopwatch_late_redraw ); } return AM_RESULT_EXIT_AND_RELEASE_SCREEN; case 'B' : // red "Back"-key : return from this screen, discard changes. return AM_RESULT_EXIT_AND_RELEASE_SCREEN; case 'U' : // cursor UP if( pSL->focused_item > 0 ) { --pSL->focused_item; } else // Wrap around top { pSL->focused_item = (pSL->num_items-1); } # if( CONFIG_MORSE_OUTPUT ) // autonomously report the first item in Morse code: pMenu->morse_request = AMENU_MORSE_REQUEST_ITEM_TEXT | AMENU_MORSE_REQUEST_ITEM_VALUE; # endif break; case 'D' : // cursor DOWN if( pSL->focused_item < (pSL->num_items-1) ) { ++pSL->focused_item; } else // Wrap around bottom { pSL->focused_item = 0; } # if( CONFIG_MORSE_OUTPUT ) // autonomously report the first item in Morse code: pMenu->morse_request = AMENU_MORSE_REQUEST_ITEM_TEXT | AMENU_MORSE_REQUEST_ITEM_VALUE; # endif break; default: // Other keys .. editing or treat as a hotkey ? break; } // end switch < key > pMenu->redraw = TRUE; } // end if < keyboard event > if( pMenu->visible == APPMENU_USERSCREEN_VISIBLE ) // only if HexMon already 'occupied' the screen ! { return AM_RESULT_OCCUPY_SCREEN; // keep the screen 'occupied' } else { return AM_RESULT_NONE; // "proceed as if there was NO callback function" } } // end am_cbk_ZoneList()