static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur) { int cnt; int i; cursor_t *cur; cursor_t *list = NULL; cursor_header_t *ch = (cursor_header_t *)rd->data; int swap = 0; if(ch->type == 2) swap = 0; else if(BYTESWAP_WORD(ch->type) == 2) swap = 1; else yyerror("Cursor resource data has invalid type id %d", ch->type); cnt = swap ? BYTESWAP_WORD(ch->count) : ch->count; for(i = 0; i < cnt; i++) { cursor_dir_entry_t cde; BITMAPINFOHEADER info; memcpy(&cde, rd->data + sizeof(cursor_header_t) + i*sizeof(cursor_dir_entry_t), sizeof(cde)); cur = new_cursor(); cur->id = alloc_cursor_id(curg->lvc.language); cur->lvc = curg->lvc; if(swap) { cde.offset = BYTESWAP_DWORD(cde.offset); cde.ressize= BYTESWAP_DWORD(cde.ressize); } if(cde.offset > rd->size || cde.offset + cde.ressize > rd->size) yyerror("Cursor resource data corrupt"); cur->width = cde.width; cur->height = cde.height; cur->nclr = cde.nclr; memcpy(&info, rd->data + cde.offset, sizeof(info)); convert_bitmap((char *)&info, 0); memcpy(rd->data + cde.offset, &info, sizeof(info)); /* The bitmap is in destination byteorder. We want native for our structures */ switch(byteorder) { #ifdef WORDS_BIGENDIAN case WRC_BO_LITTLE: #else case WRC_BO_BIG: #endif cur->planes = BYTESWAP_WORD(info.biPlanes); cur->bits = BYTESWAP_WORD(info.biBitCount); break; default: cur->planes = info.biPlanes; cur->bits = info.biBitCount; } if(!win32 && (cur->planes != 1 || cur->bits != 1)) yywarning("Win16 cursor contains colors"); cur->xhot = swap ? BYTESWAP_WORD(cde.xhot) : cde.xhot; cur->yhot = swap ? BYTESWAP_WORD(cde.yhot) : cde.yhot; cur->data = new_raw_data(); copy_raw_data(cur->data, rd, cde.offset, cde.ressize); if(!list) { list = cur; } else { cur->next = list; list->prev = cur; list = cur; } } curg->cursorlist = list; *ncur = cnt; }
int main(void) { uint8_t token = 0U; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); PSO_PeripheralEnable(); PSO_GPIOConfig(); PSO_UART0Config(); IntMasterEnable(); /* Timer initialization */ PSO_Timers(); while(1){ if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x00) { switch (token) { case 0: PSO_LEDRedOn(); break; case 1: PSO_LEDGreenOn(); break; case 2: PSO_LEDBlueOn(); break; case 3: PSO_LEDCyanOn(); break; case 4: PSO_LEDPurpleOn(); break; case 5: PSO_LEDYellowOn(); break; case 6: PSO_LEDWhiteOn(); break; default: PSO_LEDAllOff(); } /* switch */ SysCtlDelay(100000); SysCtlDelay(100000); token++; if (token > 6) { token = 0; } } /* if */ if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0x00) { PSO_LEDAllOff(); } SysCtlDelay(100000); read_raw_data (&g_uart0_data); copy_raw_data (&g_tx_buffer_uart, &g_uart0_data); uart_write(); uartBatchWrite (UART0_BASE, uart_tx_buffer, 10); } }
static void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico) { int cnt; int i; icon_t *ico; icon_t *list = NULL; icon_header_t *ih = (icon_header_t *)rd->data; int swap = 0; if(ih->type == 1) swap = 0; else if(BYTESWAP_WORD(ih->type) == 1) swap = 1; else yyerror("Icon resource data has invalid type id %d", ih->type); cnt = swap ? BYTESWAP_WORD(ih->count) : ih->count; for(i = 0; i < cnt; i++) { icon_dir_entry_t ide; BITMAPINFOHEADER info; memcpy(&ide, rd->data + sizeof(icon_header_t) + i*sizeof(icon_dir_entry_t), sizeof(ide)); ico = new_icon(); ico->id = alloc_icon_id(icog->lvc.language); ico->lvc = icog->lvc; if(swap) { ide.offset = BYTESWAP_DWORD(ide.offset); ide.ressize= BYTESWAP_DWORD(ide.ressize); } if(ide.offset > rd->size || ide.offset + ide.ressize > rd->size) yyerror("Icon resource data corrupt"); ico->width = ide.width; ico->height = ide.height; ico->nclr = ide.nclr; ico->planes = swap ? BYTESWAP_WORD(ide.planes) : ide.planes; ico->bits = swap ? BYTESWAP_WORD(ide.bits) : ide.bits; memcpy(&info, rd->data + ide.offset, sizeof(info)); convert_bitmap((char *) &info, 0); memcpy(rd->data + ide.offset, &info, sizeof(info)); if(!ico->planes) { /* Argh! They did not fill out the resdir structure */ /* The bitmap is in destination byteorder. We want native for our structures */ switch(byteorder) { #ifdef WORDS_BIGENDIAN case WRC_BO_LITTLE: #else case WRC_BO_BIG: #endif ico->planes = BYTESWAP_WORD(info.biPlanes); break; default: ico->planes = info.biPlanes; } } if(!ico->bits) { /* Argh! They did not fill out the resdir structure */ /* The bitmap is in destination byteorder. We want native for our structures */ switch(byteorder) { #ifdef WORDS_BIGENDIAN case WRC_BO_LITTLE: #else case WRC_BO_BIG: #endif ico->bits = BYTESWAP_WORD(info.biBitCount); break; default: ico->bits = info.biBitCount; } } ico->data = new_raw_data(); copy_raw_data(ico->data, rd, ide.offset, ide.ressize); if(!list) { list = ico; } else { ico->next = list; list->prev = ico; list = ico; } } icog->iconlist = list; *nico = cnt; }