static void intra_predict_vert_8x8_msa(const uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t row; uint32_t src_data1, src_data2; src_data1 = LW(src); src_data2 = LW(src + 4); for (row = 8; row--;) { SW(src_data1, dst); SW(src_data2, (dst + 4)); dst += dst_stride; } }
static void intra_predict_tm_4x4_msa(const uint8_t *src_top_ptr, const uint8_t *src_left, uint8_t *dst, int32_t dst_stride) { uint32_t val; uint8_t top_left = src_top_ptr[-1]; v16i8 src_left0, src_left1, src_left2, src_left3, tmp0, tmp1, src_top = { 0 }; v16u8 src0, src1, src2, src3; v8u16 src_top_left, vec0, vec1, vec2, vec3; src_top_left = (v8u16)__msa_fill_h(top_left); val = LW(src_top_ptr); src_top = (v16i8)__msa_insert_w((v4i32)src_top, 0, val); src_left0 = __msa_fill_b(src_left[0]); src_left1 = __msa_fill_b(src_left[1]); src_left2 = __msa_fill_b(src_left[2]); src_left3 = __msa_fill_b(src_left[3]); ILVR_B4_UB(src_left0, src_top, src_left1, src_top, src_left2, src_top, src_left3, src_top, src0, src1, src2, src3); HADD_UB4_UH(src0, src1, src2, src3, vec0, vec1, vec2, vec3); IPRED_SUBS_UH2_UH(src_top_left, src_top_left, vec0, vec1); IPRED_SUBS_UH2_UH(src_top_left, src_top_left, vec2, vec3); SAT_UH4_UH(vec0, vec1, vec2, vec3, 7); PCKEV_B2_SB(vec1, vec0, vec3, vec2, tmp0, tmp1); ST4x4_UB(tmp0, tmp1, 0, 2, 0, 2, dst, dst_stride); }
VOID spol_gblk(VOID) { BYTE handle; #if GEMDOS handle = Fopen( (const char *)spol_path, 0x0000 ); #else handle = dos_open( spol_path, 0x0000 ); #endif if (handle) { #if GEMDOS Fseek( spol_fcnt, handle, 0x0000 ); spol_cntr = (WORD)Fread( handle, SPLSIZE, (VOID *)spol_pbuf ); #else dos_lseek( handle, 0x0000, spol_fcnt ); spol_cntr = dos_read( handle, SPLSIZE, spol_pbuf ); #endif if ( spol_cntr != SPLSIZE ) spol_sts = TRUE; spol_fcnt += LW( spol_cntr ); #if GEMDOS Fclose( handle ); #else dos_close( handle ); #endif spol_ptr = spol_bufr; } else { spol_sts = TRUE; spol_cntr = 0; } }
/* Output the program header */ void output_ph(unsigned char *data) { Elf32_Phdr *phdr; struct PspModuleInfo *pModinfo; int mod_flags; phdr = (Elf32_Phdr*) data; pModinfo = (struct PspModuleInfo *) (g_modinfo->pData); mod_flags = LW(pModinfo->flags); SW(&phdr->p_type, 1); /* Starts after the program header */ SW(&phdr->p_offset, g_allocbase); SW(&phdr->p_vaddr, 0); /* Check if this is a kernel module */ if(mod_flags & 0x1000) { SW(&phdr->p_paddr, 0x80000000 | (g_modinfo->iAddr + g_allocbase)); } else { SW(&phdr->p_paddr, (g_modinfo->iAddr + g_allocbase)); } SW(&phdr->p_filesz, g_alloc_size); SW(&phdr->p_memsz, g_mem_size); SW(&phdr->p_flags, 5); SW(&phdr->p_align, 0x10); }
/* Output relocations */ void output_relocs(unsigned char *data) { int i; unsigned char *pReloc; pReloc = data; for(i = 0; i < g_elfhead.iShnum; i++) { if((g_elfsections[i].blOutput) && ((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC))) { Elf32_Rel *rel; int j, count; memcpy(pReloc, g_elfsections[i].pData, g_elfsections[i].iSize); rel = (Elf32_Rel*) pReloc; count = g_elfsections[i].iSize / sizeof(Elf32_Rel); for(j = 0; j < count; j++) { unsigned int sym; /* Clear the top 24bits of the info */ /* Kind of a dirty trick but hey :P */ sym = LW(rel->r_info); sym &= 0xFF; SW(&rel->r_info, sym); rel++; } pReloc += g_elfsections[i].iSize; } } }
int sub_01B8(int flag, int enable) { int oldIntr = sceKernelCpuSuspendIntr(); int reg = LW(0xBC10004C); *(int*)(0xBC10004C) = enable ? (reg | flag) : (reg ^ (reg & flag)); sceKernelCpuResumeIntr(intr); return (reg & flag) != 0; }
static void intra_predict_vert_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t src_data; src_data = LW(src); SW4(src_data, src_data, src_data, src_data, dst, dst_stride); }
/* * Wait for the mouse buttons to reach the state where: * ((bmask & (bstate ^ button)) == 0) != bflag * Clicks is how many times to wait for it to reach the state, but * the routine should return how many times it actually reached the * state before some time interval. * * High bit of bflgclks determines whether to return when * state is entered or left. This is called bflag. * The default case is flag = 0 and we are waiting to ENTER the * indicated state. If bflag = 1 then we are waiting to LEAVE * the state. */ UWORD ev_button(WORD bflgclks, UWORD bmask, UWORD bstate, WORD rets[]) { WORD ret; LONG parm; parm = HW(bflgclks) | LW((bmask << 8) | bstate); ret = ev_block(MU_BUTTON, parm); ev_rets(&rets[0]); return(ret); }
static void intra_predict_dc_4x4_msa(const uint8_t *src_top, const uint8_t *src_left, uint8_t *dst, int32_t dst_stride) { uint32_t val0, val1; v16i8 store, src = { 0 }; v8u16 sum_h; v4u32 sum_w; v2u64 sum_d; val0 = LW(src_top); val1 = LW(src_left); INSERT_W2_SB(val0, val1, src); sum_h = __msa_hadd_u_h((v16u8)src, (v16u8)src); sum_w = __msa_hadd_u_w(sum_h, sum_h); sum_d = __msa_hadd_u_d(sum_w, sum_w); sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 3); store = __msa_splati_b((v16i8)sum_w, 0); val0 = __msa_copy_u_w((v4i32)store, 0); SW4(val0, val0, val0, val0, dst, dst_stride); }
LONG get_obmem(VOID) { UWORD foo; foo = (UWORD) (rcs_free - ( head + LW( LWGET(RSH_OBJECT(head)) ))); foo %= (UWORD) sizeof(OBJECT); /* synchronize to even OBJECT */ /* boundary w.r.t. first OBJECT */ if (foo) rcs_free += (UWORD) sizeof(OBJECT) - foo; return get_mem((UWORD) sizeof(OBJECT)); }
static void intra_predict_dc_tl_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t val0; v16i8 store, data = { 0 }; v8u16 sum_h; v4u32 sum_w; val0 = LW(src); data = (v16i8)__msa_insert_w((v4i32)data, 0, val0); sum_h = __msa_hadd_u_h((v16u8)data, (v16u8)data); sum_w = __msa_hadd_u_w(sum_h, sum_h); sum_w = (v4u32)__msa_srari_w((v4i32)sum_w, 2); store = __msa_splati_b((v16i8)sum_w, 0); val0 = __msa_copy_u_w((v4i32)store, 0); SW4(val0, val0, val0, val0, dst, dst_stride); }
void deltmpfiles() { int ti; const char *path; int rcode; int fd; for( fd = 3; fd < 256; fd++ ) if( closetmpf1(fd) == 0 ) LW("exit: close(%d) = 0",fd); for( ti = 0; ti < MAXFD_SETSIZE; ti++ ){ if( path = tmpfiles[ti] ){ if( *path == ' ' ){ continue; } errno = 0; rcode = unlink(path); LV("unlink(%s) = %d, errno=%d",path,rcode,errno); } } }
void render_layer(int clayer, float alpha) { char *s = layer[clayer].index; char *e = layer[clayer].index + layer[clayer].size; float G = NAN, X = NAN, Y = NAN, E = NAN, Z = NAN, lastX = NAN, lastY = NAN, lastE = NAN; uint32_t seen = 0; for (X = 0; X < 201.0; X += 10.0) { gline(X, 0, X, 200, ((((int) X) % 50) == 0)?1:0.2, 0, 0, 0, 16); gline(0, X, 200, X, ((((int) X) % 50) == 0)?1:0.2, 0, 0, 0, 16); } //printf("render layer %d (%g)\n", clayer + 1, alpha); lastX = layer[clayer].startX; lastY = layer[clayer].startY; Z = layer[clayer].height; lastE = layer[clayer].startE; while (s < e) { seen = scanline(s, e - s, linewords, &s, LMASK('G') | LMASK('X') | LMASK('Y') | LMASK('Z') | LMASK('E')); if (SEEN('G') && (LW('G') == 0.0 || LW('G') == 1.0)) { G = LW('G'); if (SEEN('X')) X = LW('X'); if (SEEN('Y')) Y = LW('Y'); if (SEEN('Z')) Z = LW('Z'); if (SEEN('E')) E = LW('E'); //if (clayer == 2) // printf("SEEN %c%c%c%c X%g Y%g Z%g E%g\n", SEEN('X')?'X':' ', SEEN('Y')?'Y':' ', SEEN('Z')?'Z':' ', SEEN('E')?'E':' ', X, Y, Z, E); if (SEEN('X') || SEEN('Y')) { // draw uint8_t r = 0, g = 0, b = 0, a = 160; if (SEEN('E')) { r = 0; g = 0; b = 0; a = 224; } else if (Z > layer[clayer].height) { r = 224; g = 64; b = 64; a = 160; } else if (Z < layer[clayer].height) { r = 128; g = 0; b = 128; a = 160; } else { r = 0; g = 128; b = 64; a = 160; } if ((lastX != X || lastY != Y) && !isnan(X) && !isnan(Y) && lastX <= 200.0) gline(lastX, lastY, X, Y, extrusionWidth, r, g, b, a * alpha); } if (SEEN('X')) lastX = X; if (SEEN('Y')) lastY = Y; if (SEEN('E')) lastE = E; } } }
void scanLine() { static char* l = NULL; static float lastX = 0.0, lastY = 0.0, lastE = 0.0; if (l == NULL) l = gcodefile; char* end; uint32_t seen; if (l < gcodefile_end) { //printf("\t-\n"); seen = scanline(l, gcodefile_end - l, linewords, &end, LMASK('G') | LMASK('X') | LMASK('Y') | LMASK('Z') | LMASK('E')); if (SEEN('G')) { if (LW('G') == 0.0 || LW('G') == 1.0) { if (layer[layerCount].index == NULL) { layer[layerCount].index = l; layer[layerCount].startX = lastX; layer[layerCount].startY = lastY; layer[layerCount].startE = lastE; } if (SEEN('Z')) { //dumpZstack(); //printf("%d: Z%g\n", l - gcodefile, LW('Z')); if (layer[layerCount].height == NAN) layer[layerCount].height = LW('Z'); else { int i; //dumpZstack(); for (i = 0; i < ZstackIndex; i++) { //printf("Check %d: got %g vs found %g\n", i, Zstack[i].Z, LW('Z')); if (Zstack[i].Z == LW('Z')) { //printf("found end of hop\n"); // end of hop ZstackIndex = i + 1; break; } } //printf("ZS %d i %d\n", ZstackIndex, i); if (i >= ZstackIndex || ZstackIndex == 0) { //printf("found start of hop\n"); // start of hop or new layer Zstack[ZstackIndex].start = l; Zstack[ZstackIndex].X = lastX; Zstack[ZstackIndex].Y = lastY; Zstack[ZstackIndex].Z = LW('Z'); Zstack[ZstackIndex].E = lastE; ZstackIndex++; if (ZstackIndex >= 8) die("Zstack overflow!",""); } } } if (SEEN('E')) { // extrusion, collapse Z stack int i = ZstackIndex - 1; if (Zstack[i].Z != layer[layerCount].height) { //printf("E word at Z=%g\n", LW('Z')); //dumpZstack(); //printf("new layer!\n"); // finish previous layer layer[layerCount].size = Zstack[i].start - layer[layerCount].index; layer[layerCount].flags = 0; layer[layerCount].glList = 0; layer[layerCount].endX = Zstack[i].X; layer[layerCount].endY = Zstack[i].Y; layer[layerCount].endE = Zstack[i].E; // start new layer layerCount++; //printf("NEW LAYER: %d\n", layerCount); if (layerCount * sizeof(layerData) >= layerSize) { layerSize += sizeof(layerData) * 128; layer = realloc(layer, layerSize); if (layer == NULL) die("Scan: realloc layer",""); } //printf("START LAYER %d\n", layerCount); // initialise layer[layerCount].index = Zstack[i].start; layer[layerCount].startX = Zstack[i].X; layer[layerCount].startY = Zstack[i].Y; layer[layerCount].height = Zstack[i].Z; layer[layerCount].startE = Zstack[i].E; // flush Z stack memcpy(Zstack, &Zstack[i], sizeof(ZstackItem)); ZstackIndex = 1; //dumpZstack(); } } } if (SEEN('X')) lastX = LW('X'); if (SEEN('Y')) lastY = LW('Y'); if (SEEN('E')) lastE = LW('E'); } l = end; } if (l >= gcodefile_end) { layer[layerCount].size = l - layer[layerCount].index; layer[layerCount].flags = 0; layer[layerCount].glList = 0; layer[layerCount].endX = lastX; layer[layerCount].endY = lastY; layer[layerCount].endE = lastE; layerCount++; printf("Found %d layers\n", layerCount); if (0) for (int i = 0; i < layerCount; i++) { printf("Layer %d at %d+%d=%d\n", i, layer[i].index - gcodefile, layer[i].size, layer[i].index - gcodefile + layer[i].size); printf("\tHeight: %g\n", layer[i].height); printf("\tStarts at [%g,%g:%g]\n", layer[i].startX, layer[i].startY, layer[i].startE); printf("\tEnds at [%g,%g:%g]\n", layer[i].endX, layer[i].endY, layer[i].endE); } busy &= ~BUSY_SCANFILE; } }
int remove_weak_relocs(struct ElfSection *pReloc, struct ElfSection *pSymbol, struct ElfSection *pString) { int iCount; int iMaxSymbol; void *pNewRel = NULL; Elf32_Rel *pInRel; Elf32_Rel *pOutRel; Elf32_Sym *pSymData = (Elf32_Sym *) pSymbol->pData; char *pStrData = NULL; int iOutput; int i; if(pString != NULL) { pStrData = (char *) pString->pData; } iMaxSymbol = pSymbol->iSize / sizeof(Elf32_Sym); iCount = pReloc->iSize / sizeof(Elf32_Rel); pNewRel = malloc(pReloc->iSize); if(pNewRel == NULL) { return 0; } pOutRel = (Elf32_Rel *) pNewRel; pInRel = (Elf32_Rel *) pReloc->pData; iOutput = 0; if(g_verbose) { fprintf(stderr, "[%s] Processing %d relocations, %d symbols\n", pReloc->szName, iCount, iMaxSymbol); } for(i = 0; i < iCount; i++) { int iSymbol; iSymbol = ELF32_R_SYM(LW(pInRel->r_info)); if(g_verbose) { fprintf(stderr, "Relocation %d - Symbol %x\n", iOutput, iSymbol); } if(iSymbol >= iMaxSymbol) { fprintf(stderr, "Warning: Ignoring relocation as cannot find matching symbol\n"); } else { if(g_verbose) { if(pStrData != NULL) { fprintf(stderr, "Symbol %d - Name %s info %x ndx %x\n", iSymbol, &pStrData[pSymData[iSymbol].st_name], pSymData[iSymbol].st_info, pSymData[iSymbol].st_shndx); } else { fprintf(stderr, "Symbol %d - Name %d info %x ndx %x\n", iSymbol, pSymData[iSymbol].st_name, pSymData[iSymbol].st_info, pSymData[iSymbol].st_shndx); } } /* Remove PC16 relocations (unsupported by PSP, and useless) */ if(LH(pSymData[iSymbol].st_shndx) == 0 || ELF32_R_TYPE(LW(pInRel->r_info)) == R_MIPS_PC16) { if(g_verbose) { fprintf(stderr, "Deleting relocation\n"); } } else { /* We are keeping this relocation, copy it across */ *pOutRel = *pInRel; pOutRel++; iOutput++; } } pInRel++; } /* If we deleted some relocations */ if(iOutput < iCount) { int iSize; iSize = iOutput * sizeof(Elf32_Rel); if(g_verbose) { fprintf(stderr, "Old relocation size %d, new %d\n", pReloc->iSize, iSize); } pReloc->iSize = iSize; /* If size is zero then delete this section */ if(iSize == 0) { pReloc->blOutput = 0; } else { /* Copy across the new relocation data */ memcpy(pReloc->pData, pNewRel, pReloc->iSize); } } free(pNewRel); return 1; }
int fixup_imports(void) { unsigned int *pText; unsigned int *pNid; struct PspModuleImport *pLastImport = NULL; int count; /* First let's check the sizes are correct */ if(g_stubtext->iSize != (g_nid->iSize * 2)) { fprintf(stderr, "Error, size of text section and nid section do not match\n"); return 0; } count = g_nid->iSize / 4; pText = (unsigned int *) g_stubtext->pData; pNid = (unsigned int *) g_nid->pData; if(g_verbose) { fprintf(stderr, "Import count %d\n", count); } while(count > 0) { unsigned int stub_addr; unsigned int stub_nid; unsigned int sect_nid; stub_addr = LW(pText[0]); stub_nid = LW(pText[1]); sect_nid = LW(pNid[0]); /* Check if this is an original format NID */ if((stub_addr != MIPS_JR_31) || (stub_nid != MIPS_NOP)) { struct PspModuleImport *pImport; u16 func_count; if(g_verbose) { fprintf(stderr, "Found import to fixup. pStub %08X, Nid %08X, NidInSect %08X\n", stub_addr, stub_nid, sect_nid); } if(stub_nid != sect_nid) { fprintf(stderr, "Error, unmatched NIDs\n"); return 0; } if((stub_addr < g_libstub->iAddr) || (stub_addr > (g_libstub->iAddr + g_libstub->iSize)) || (stub_addr & 3)) { fprintf(stderr, "Error, invalid stub address\n"); return 0; } pImport = (struct PspModuleImport *) (g_libstub->pData + (stub_addr - g_libstub->iAddr)); if(g_verbose) { fprintf(stderr, "Import Stub %p, %08X, %08X, %02X, %02X, %04X, %08X, %08X\n", pImport, LW(pImport->name), LW(pImport->flags), pImport->entry_size, pImport->var_count, LH(pImport->func_count), LW(pImport->nids), LW(pImport->funcs)); } func_count = LH(pImport->func_count); if(func_count == 0) { /* Setup the stub */ SW(&pImport->nids, ((unsigned char *) pNid - g_nid->pData) + g_nid->iAddr); SW(&pImport->funcs, ((unsigned char *) pText - g_stubtext->pData) + g_stubtext->iAddr); } else { if((pLastImport) && (pImport != pLastImport)) { fprintf(stderr, "Error, could not fixup imports, stubs out of order.\n"); fprintf(stderr, "Ensure the SDK libraries are linked in last to correct this error\n"); return 0; } } pLastImport = pImport; func_count++; SH(&pImport->func_count, func_count); SW(&pText[0], MIPS_JR_31); SW(&pText[1], MIPS_NOP); } else { /* Set last import to some value so we know if we have out of order stubs over a fixed stub table */ pLastImport = (struct PspModuleImport *) pText; } pText += 2; pNid++; count--; } /* Should indicate no error occurred */ if(count == 0) { if(g_verbose) { fprintf(stderr, "No libraries to fixup\n"); } } return 1; }
/* Validate the ELF header */ int validate_header(unsigned char *data) { Elf32_Ehdr *head; int ret = 0; head = (Elf32_Ehdr*) data; do { /* Read in the header structure */ g_elfhead.iMagic = LW(head->e_magic); g_elfhead.iClass = head->e_class; g_elfhead.iData = head->e_data; g_elfhead.iIdver = head->e_idver; g_elfhead.iType = LH(head->e_type); g_elfhead.iMachine = LH(head->e_machine); g_elfhead.iVersion = LW(head->e_version); g_elfhead.iEntry = LW(head->e_entry); g_elfhead.iPhoff = LW(head->e_phoff); g_elfhead.iShoff = LW(head->e_shoff); g_elfhead.iFlags = LW(head->e_flags); g_elfhead.iEhsize = LH(head->e_ehsize); g_elfhead.iPhentsize = LH(head->e_phentsize); g_elfhead.iPhnum = LH(head->e_phnum); g_elfhead.iShentsize = LH(head->e_shentsize); g_elfhead.iShnum = LH(head->e_shnum); g_elfhead.iShstrndx = LH(head->e_shstrndx); if(g_verbose) { fprintf(stderr, "Magic %08X, Class %02X, Data %02X, Idver %02X\n", g_elfhead.iMagic, g_elfhead.iClass, g_elfhead.iData, g_elfhead.iIdver); fprintf(stderr, "Type %04X, Machine %04X, Version %08X, Entry %08X\n", g_elfhead.iType, g_elfhead.iMachine, g_elfhead.iVersion, g_elfhead.iEntry); fprintf(stderr, "Phoff %08X, Shoff %08X, Flags %08X, Ehsize %08X\n", g_elfhead.iPhoff, g_elfhead.iShoff, g_elfhead.iFlags, g_elfhead.iEhsize); fprintf(stderr, "Phentsize %04X, Phnum %04X\n", g_elfhead.iPhentsize, g_elfhead.iPhnum); fprintf(stderr, "Shentsize %04X, Shnum %08X, Shstrndx %04X\n", g_elfhead.iShentsize, g_elfhead.iShnum, g_elfhead.iShstrndx); } if(g_elfhead.iMagic != ELF_MAGIC) { fprintf(stderr, "Error, invalid magic in the header\n"); break; } if((g_elfhead.iType != ELF_EXEC_TYPE) && (g_elfhead.iType != ELF_PRX_TYPE)) { fprintf(stderr, "Error, not EXEC type elf\n"); break; } if(g_elfhead.iMachine != ELF_MACHINE_MIPS) { fprintf(stderr, "Error, not MIPS type ELF\n"); break; } if(g_elfhead.iShnum < g_elfhead.iShstrndx) { fprintf(stderr, "Error, number of headers is less than section string index\n"); break; } ret = 1; } while(0); return ret; }
/* Load sections into ram */ int load_sections(unsigned char *data) { int ret = 0; int found_rel = 0; unsigned int load_addr = 0xFFFFFFFF; if(g_elfhead.iShnum > 0) { do { Elf32_Shdr *sect; int i; g_elfsections = (struct ElfSection *) malloc(sizeof(struct ElfSection) * g_elfhead.iShnum); if(g_elfsections == NULL) { fprintf(stderr, "Error, could not allocate memory for sections\n"); break; } memset(g_elfsections, 0, sizeof(struct ElfSection) * g_elfhead.iShnum); for(i = 0; i < g_elfhead.iShnum; i++) { sect = (Elf32_Shdr *) (g_elfdata + g_elfhead.iShoff + (i * g_elfhead.iShentsize)); g_elfsections[i].iName = LW(sect->sh_name); g_elfsections[i].iType = LW(sect->sh_type); g_elfsections[i].iAddr = LW(sect->sh_addr); g_elfsections[i].iFlags = LW(sect->sh_flags); g_elfsections[i].iOffset = LW(sect->sh_offset); g_elfsections[i].iSize = LW(sect->sh_size); g_elfsections[i].iLink = LW(sect->sh_link); g_elfsections[i].iInfo = LW(sect->sh_info); g_elfsections[i].iAddralign = LW(sect->sh_addralign); g_elfsections[i].iEntsize = LW(sect->sh_entsize); g_elfsections[i].iIndex = i; if(g_elfsections[i].iOffset != 0) { g_elfsections[i].pData = g_elfdata + g_elfsections[i].iOffset; } if(g_elfsections[i].iFlags & SHF_ALLOC) { g_elfsections[i].blOutput = 1; if(g_elfsections[i].iAddr < load_addr) { load_addr = g_elfsections[i].iAddr; } } if(((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC)) && (g_elfsections[g_elfsections[i].iInfo].iFlags & SHF_ALLOC)) { g_elfsections[i].pRef = &g_elfsections[g_elfsections[i].iInfo]; found_rel = 1; g_elfsections[i].blOutput = 1; } } /* Okay so we have loaded all the sections, lets fix up the names */ for(i = 0; i < g_elfhead.iShnum; i++) { strcpy(g_elfsections[i].szName, (char *) (g_elfsections[g_elfhead.iShstrndx].pData + g_elfsections[i].iName)); if(strcmp(g_elfsections[i].szName, PSP_MODULE_INFO_NAME) == 0) { g_modinfo = &g_elfsections[i]; } else if(strcmp(g_elfsections[i].szName, PSP_MODULE_REMOVE_REL) == 0) { /* Don't output .rel.lib.stub relocations */ g_elfsections[i].blOutput = 0; } } if(g_verbose) { for(i = 0; i < g_elfhead.iShnum; i++) { fprintf(stderr, "\nSection %d: %s\n", i, g_elfsections[i].szName); fprintf(stderr, "Name %08X, Type %08X, Flags %08X, Addr %08X\n", g_elfsections[i].iName, g_elfsections[i].iType, g_elfsections[i].iFlags, g_elfsections[i].iAddr); fprintf(stderr, "Offset %08X, Size %08X, Link %08X, Info %08X\n", g_elfsections[i].iOffset, g_elfsections[i].iSize, g_elfsections[i].iLink, g_elfsections[i].iInfo); fprintf(stderr, "Addralign %08X, Entsize %08X pData %p\n", g_elfsections[i].iAddralign, g_elfsections[i].iEntsize, g_elfsections[i].pData); } fprintf(stderr, "ELF Load Base address %08X\n", load_addr); } if(g_modinfo == NULL) { fprintf(stderr, "Error, no sceModuleInfo section found\n"); break; } if(!found_rel) { fprintf(stderr, "Error, found no relocation sections\n"); break; } if(load_addr != 0) { fprintf(stderr, "Error, ELF not loaded to address 0 (%08X)\n", load_addr); break; } ret = 1; } while(0); } else { fprintf(stderr, "Error, no sections in the ELF\n"); } return ret; }
static void hevc_idct_8x32_column_msa(int16_t *coeffs, uint8_t buf_pitch, uint8_t round) { uint8_t i; const int16_t *filter_ptr0 = >32x32_cnst0[0]; const int16_t *filter_ptr1 = >32x32_cnst1[0]; const int16_t *filter_ptr2 = >32x32_cnst2[0]; const int16_t *filter_ptr3 = >8x8_cnst[0]; int16_t *src0 = (coeffs + buf_pitch); int16_t *src1 = (coeffs + 2 * buf_pitch); int16_t *src2 = (coeffs + 4 * buf_pitch); int16_t *src3 = (coeffs); int32_t cnst0, cnst1; int32_t tmp_buf[8 * 32 + 15]; int32_t *tmp_buf_ptr = tmp_buf + 15; v8i16 in0, in1, in2, in3, in4, in5, in6, in7; v8i16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r; v8i16 src0_l, src1_l, src2_l, src3_l, src4_l, src5_l, src6_l, src7_l; v8i16 filt0, filter0, filter1, filter2, filter3; v4i32 sum0_r, sum0_l, sum1_r, sum1_l, tmp0_r, tmp0_l, tmp1_r, tmp1_l; /* Align pointer to 64 byte boundary */ tmp_buf_ptr = (int32_t *)(((uintptr_t) tmp_buf_ptr) & ~(uintptr_t) 63); /* process coeff 4, 12, 20, 28 */ LD_SH4(src2, 8 * buf_pitch, in0, in1, in2, in3); ILVR_H2_SH(in1, in0, in3, in2, src0_r, src1_r); ILVL_H2_SH(in1, in0, in3, in2, src0_l, src1_l); LD_SH2(src3, 16 * buf_pitch, in4, in6); LD_SH2((src3 + 8 * buf_pitch), 16 * buf_pitch, in5, in7); ILVR_H2_SH(in6, in4, in7, in5, src2_r, src3_r); ILVL_H2_SH(in6, in4, in7, in5, src2_l, src3_l); /* loop for all columns of constants */ for (i = 0; i < 2; i++) { /* processing single column of constants */ cnst0 = LW(filter_ptr2); cnst1 = LW(filter_ptr2 + 2); filter0 = (v8i16) __msa_fill_w(cnst0); filter1 = (v8i16) __msa_fill_w(cnst1); DOTP_SH2_SW(src0_r, src0_l, filter0, filter0, sum0_r, sum0_l); DPADD_SH2_SW(src1_r, src1_l, filter1, filter1, sum0_r, sum0_l); ST_SW2(sum0_r, sum0_l, (tmp_buf_ptr + 2 * i * 8), 4); /* processing single column of constants */ cnst0 = LW(filter_ptr2 + 4); cnst1 = LW(filter_ptr2 + 6); filter0 = (v8i16) __msa_fill_w(cnst0); filter1 = (v8i16) __msa_fill_w(cnst1); DOTP_SH2_SW(src0_r, src0_l, filter0, filter0, sum0_r, sum0_l); DPADD_SH2_SW(src1_r, src1_l, filter1, filter1, sum0_r, sum0_l); ST_SW2(sum0_r, sum0_l, (tmp_buf_ptr + (2 * i + 1) * 8), 4); filter_ptr2 += 8; } /* process coeff 0, 8, 16, 24 */ /* loop for all columns of constants */ for (i = 0; i < 2; i++) { /* processing first column of filter constants */ cnst0 = LW(filter_ptr3); cnst1 = LW(filter_ptr3 + 2); filter0 = (v8i16) __msa_fill_w(cnst0); filter1 = (v8i16) __msa_fill_w(cnst1); DOTP_SH4_SW(src2_r, src2_l, src3_r, src3_l, filter0, filter0, filter1, filter1, sum0_r, sum0_l, tmp1_r, tmp1_l); sum1_r = sum0_r - tmp1_r; sum1_l = sum0_l - tmp1_l; sum0_r = sum0_r + tmp1_r; sum0_l = sum0_l + tmp1_l; HEVC_EVEN16_CALC(tmp_buf_ptr, sum0_r, sum0_l, i, (7 - i)); HEVC_EVEN16_CALC(tmp_buf_ptr, sum1_r, sum1_l, (3 - i), (4 + i)); filter_ptr3 += 8; } /* process coeff 2 6 10 14 18 22 26 30 */ LD_SH8(src1, 4 * buf_pitch, in0, in1, in2, in3, in4, in5, in6, in7); ILVR_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, src0_r, src1_r, src2_r, src3_r); ILVL_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, src0_l, src1_l, src2_l, src3_l); /* loop for all columns of constants */ for (i = 0; i < 8; i++) { /* processing single column of constants */ filt0 = LD_SH(filter_ptr1); SPLATI_W4_SH(filt0, filter0, filter1, filter2, filter3); DOTP_SH2_SW(src0_r, src0_l, filter0, filter0, sum0_r, sum0_l); DPADD_SH4_SW(src1_r, src1_l, src2_r, src2_l, filter1, filter1, filter2, filter2, sum0_r, sum0_l, sum0_r, sum0_l); DPADD_SH2_SW(src3_r, src3_l, filter3, filter3, sum0_r, sum0_l); LD_SW2(tmp_buf_ptr + i * 8, 4, tmp0_r, tmp0_l); tmp1_r = tmp0_r; tmp1_l = tmp0_l; tmp0_r += sum0_r; tmp0_l += sum0_l; ST_SW2(tmp0_r, tmp0_l, (tmp_buf_ptr + i * 8), 4); tmp1_r -= sum0_r; tmp1_l -= sum0_l; ST_SW2(tmp1_r, tmp1_l, (tmp_buf_ptr + (15 - i) * 8), 4); filter_ptr1 += 8; } /* process coeff 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 */ LD_SH8(src0, 2 * buf_pitch, in0, in1, in2, in3, in4, in5, in6, in7); src0 += 16 * buf_pitch; ILVR_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, src0_r, src1_r, src2_r, src3_r); ILVL_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, src0_l, src1_l, src2_l, src3_l); LD_SH8(src0, 2 * buf_pitch, in0, in1, in2, in3, in4, in5, in6, in7); ILVR_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, src4_r, src5_r, src6_r, src7_r); ILVL_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, src4_l, src5_l, src6_l, src7_l); /* loop for all columns of filter constants */ for (i = 0; i < 16; i++) { /* processing single column of constants */ filt0 = LD_SH(filter_ptr0); SPLATI_W4_SH(filt0, filter0, filter1, filter2, filter3); DOTP_SH2_SW(src0_r, src0_l, filter0, filter0, sum0_r, sum0_l); DPADD_SH4_SW(src1_r, src1_l, src2_r, src2_l, filter1, filter1, filter2, filter2, sum0_r, sum0_l, sum0_r, sum0_l); DPADD_SH2_SW(src3_r, src3_l, filter3, filter3, sum0_r, sum0_l); tmp1_r = sum0_r; tmp1_l = sum0_l; filt0 = LD_SH(filter_ptr0 + 8); SPLATI_W4_SH(filt0, filter0, filter1, filter2, filter3); DOTP_SH2_SW(src4_r, src4_l, filter0, filter0, sum0_r, sum0_l); DPADD_SH4_SW(src5_r, src5_l, src6_r, src6_l, filter1, filter1, filter2, filter2, sum0_r, sum0_l, sum0_r, sum0_l); DPADD_SH2_SW(src7_r, src7_l, filter3, filter3, sum0_r, sum0_l); sum0_r += tmp1_r; sum0_l += tmp1_l; LD_SW2(tmp_buf_ptr + i * 8, 4, tmp0_r, tmp0_l); tmp1_r = tmp0_r; tmp1_l = tmp0_l; tmp0_r += sum0_r; tmp0_l += sum0_l; sum1_r = __msa_fill_w(round); SRAR_W2_SW(tmp0_r, tmp0_l, sum1_r); SAT_SW2_SW(tmp0_r, tmp0_l, 15); in0 = __msa_pckev_h((v8i16) tmp0_l, (v8i16) tmp0_r); ST_SH(in0, (coeffs + i * buf_pitch)); tmp1_r -= sum0_r; tmp1_l -= sum0_l; SRAR_W2_SW(tmp1_r, tmp1_l, sum1_r); SAT_SW2_SW(tmp1_r, tmp1_l, 15); in0 = __msa_pckev_h((v8i16) tmp1_l, (v8i16) tmp1_r); ST_SH(in0, (coeffs + (31 - i) * buf_pitch)); filter_ptr0 += 16; } }
int fixup_nidmap(void) { struct PspModuleImport *pImport; int size; pImport = (struct PspModuleImport *) g_libstub->pData; size = g_libstub->iSize; while(size >= sizeof(struct PspModuleImport)) { const char *str; str = (const char*) find_data(LW(pImport->name)); if(str) { struct ImportMap *pMap; pMap = find_map_by_name(str); if(pMap) { int count; unsigned int *pNid; pNid = (unsigned int*) find_data(LW(pImport->nids)); count = LH(pImport->func_count) + pImport->var_count; if(pNid && (count > 0)) { if(g_verbose) { fprintf(stderr, "Mapping library %s\n", str); } while(count > 0) { int i; for(i = 0; i < pMap->count; i++) { unsigned oldnid, newnid; if(g_reversemap) { oldnid = pMap->nids[i].newnid; newnid = pMap->nids[i].oldnid; } else { newnid = pMap->nids[i].newnid; oldnid = pMap->nids[i].oldnid; } if(oldnid == *pNid) { if(g_verbose) { fprintf(stderr, "Mapping 0x%08X to 0x%08X\n", oldnid, newnid); } *pNid = newnid; break; } } pNid++; count--; } } } } pImport++; size -= sizeof(struct PspModuleImport); } return 1; }
LONG img_ptr(WORD n) { return (head + LW( LWGET(RSH_FRIMG(head)) ) + (LONG) (n * sizeof(LONG))); }
LONG str_ptr(WORD n) { return (head + LW( LWGET(RSH_FRSTR(head)) ) + (LONG) (n * sizeof(LONG))); }
LONG tree_ptr(WORD n) { return (head + LW( LWGET(RSH_TRINDEX(head)) ) + (LONG) (n * sizeof(LONG))); }
void simulation(aveq *A, function *G, function *S, int k, int method) { //l'intero method serve a designare il metodo di integrazione // 0 = FTCS // 1 = LeapFrog // 2 = LaxWendroff // 3 = LaxFriedrichs int i, t, it; char filename[50]; FILE *pt; for(A->cf = 0.5; A->cf <= 1; A->cf += 0.5) { //ciclo su due diversi fattori di Courant for(A->time = 10; A->time <= 20; A->time += 10) { //ciclo su due diversi tempi di esecuzione A->xstep = 1e-1; //step di partenza for(it = 1; it <= 3; it++) { //ciclo sulle dimensioni dello step (e conseguentemente dell'array) A->tstep = A->cf * A->xstep; //definizione dello step temporale //-----------------------------definizione degli array A->dim = (int)(XMAX/A->xstep+1); //dimensione degli array //malloc non perchè grandi ma per evitare problemi di allocamento di memoria inutile nei cicli double *solution = (double *)malloc((A->dim) * sizeof(double)); //soluzione double *tsol = (double *)malloc((A->dim) * sizeof(double)); //tmp soluzione double *tsol_1 = (double *)malloc((A->dim) * sizeof(double)); //tmp soluzione3 //associa agli elementi della struct A->solution = solution; A->tsol = tsol; A->tsol_1 = tsol_1; //----------------------------- printf("\t-> Simulating: cf = %g, execution time = %d, spatial step = %g\n", A->cf, A->time, A->xstep); //genera i file nelle cartelle che vengono create ed esegui in base al valore di method switch(method) { case 0: if(k == 1) snprintf(filename, sizeof(filename), "FTCS_G/ftcs_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); else snprintf(filename, sizeof(filename), "FTCS_S/ftcs_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); pt = fopen(filename,"w"); FTCS(A, G, S, k); //FTCS break; case 1: if(k == 1) snprintf(filename, sizeof(filename), "LEAPFROG_G/lpfr_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); else snprintf(filename, sizeof(filename), "LEAPFROG_S/lpfr_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); pt = fopen(filename,"w"); LeFr(A, G, S, k); //Leapfrog break; case 2: if( k== 1) snprintf(filename, sizeof(filename), "LAXWENDROFF_G/lw_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); else snprintf(filename, sizeof(filename), "LAXWENDROFF_S/lw_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); pt = fopen(filename,"w"); LW(A, G, S, k); //Lax Wendroff break; case 3: if( k== 1) snprintf(filename, sizeof(filename), "LAXFRIEDRICHS_G/lf_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); else snprintf(filename, sizeof(filename), "LAXFRIEDRICHS_S/lf_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); pt = fopen(filename,"w"); LF(A, G, S, k); //Lax Friedrichs break; case 4: if( k== 1) snprintf(filename, sizeof(filename), "LEAPFROG-WAVE/lefr_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); else { printf("\t-> L'equazione delle onde può essere risolta solo con condizioni gaussiane.\n"); exit(0); } pt = fopen(filename,"w"); LF_WAVE(A, G, S, k); //Leapfrog per l'equazione delle onde break; case 5: if( k == 1) snprintf(filename, sizeof(filename), "LAXWENDROFF-WAVE/lw_cf%g_xstep%g_T%d_k%d", A->cf, A->xstep, A->time,k); else { printf("\t-> L'equazione delle onde può essere risolta solo con condizioni gaussiane.\n"); exit(0); } pt = fopen(filename,"w"); LW_WAVE(A, G, S, k); //Lax-Wendroff per l'equazione delle onde break; } //stampa finalmente i valori di solution su file for(i = 0; i < A->dim; i++) fprintf(pt, "%g \t %g\n", i*A->xstep, A->solution[i]); //libera tutto fclose(pt); free(solution); free(tsol); free(tsol_1); A->xstep /= 10.; //dividi per 10 lo step ogni volta che it viene incrementato di uno } } } }
static UWORD crysbind(WORD opcode, LONG pglobal, WORD control[], WORD int_in[], WORD int_out[], LONG addr_in[]) { LONG maddr; LONG tree; WORD mouse, ret; WORD unsupported = FALSE; maddr = 0; ret = TRUE; switch(opcode) { /* Application Manager */ case APPL_INIT: #if DBG_GEMSUPER aestrace("appl_init()"); #endif LWSET(pglobal, AES_VERSION); /* version number */ LWSET(pglobal+2, 0x0001); /* num of concurrent procs*/ /* LLSET(pglobal, 0x00010200L); */ LWSET(pglobal+4, rlr->p_pid); sh_deskf(0, pglobal+6); LWSET(pglobal+20, gl_nplanes); LLSET(pglobal+22, ADDR(&D)); /* reset dispatcher */ /* count to let the app*/ /* run a while. */ dspcnt = 0; ret = ap_init(); break; case APPL_READ: case APPL_WRITE: ap_rdwr(opcode == APPL_READ ? MU_MESAG : MU_SDMSG, fpdnm(NULLPTR, AP_RWID), AP_LENGTH, AP_PBUFF); break; case APPL_FIND: ret = ap_find( AP_PNAME ); break; case APPL_TPLAY: ap_tplay(AP_TBUFFER, AP_TLENGTH, AP_TSCALE); break; case APPL_TRECORD: ret = ap_trecd(AP_TBUFFER, AP_TLENGTH); break; #if CONF_WITH_PCGEM case APPL_YIELD: dsptch(); break; #endif case APPL_EXIT: #if DBG_GEMSUPER aestrace("appl_exit()"); #endif ap_exit(); break; /* Event Manager */ case EVNT_KEYBD: ret = ev_block(MU_KEYBD, 0x0L); break; case EVNT_BUTTON: ret = ev_button(B_CLICKS, B_MASK, B_STATE, &EV_MX); break; case EVNT_MOUSE: ret = ev_mouse((MOBLK *)&MO_FLAGS, &EV_MX); break; case EVNT_MESAG: #if DBG_GEMSUPER aestrace("evnt_mesag()"); #endif ap_rdwr(MU_MESAG, rlr, 16, ME_PBUFF); break; case EVNT_TIMER: ev_timer( HW(T_HICOUNT) + LW(T_LOCOUNT) ); break; case EVNT_MULTI: #if DBG_GEMSUPER aestrace("evnt_multi()"); #endif if (MU_FLAGS & MU_TIMER) maddr = HW(MT_HICOUNT) + LW(MT_LOCOUNT); tree = HW(MB_CLICKS) | LW((MB_MASK << 8) | MB_STATE); ret = ev_multi(MU_FLAGS, (MOBLK *)&MMO1_FLAGS, (MOBLK *)&MMO2_FLAGS, maddr, tree, MME_PBUFF, &EV_MX); break; case EVNT_DCLICK: ret = ev_dclick(EV_DCRATE, EV_DCSETIT); break; /* Menu Manager */ case MENU_BAR: if (gl_mnppd == rlr || gl_mnppd == NULL) mn_bar(MM_ITREE, SHOW_IT, rlr->p_pid); else menu_tree[rlr->p_pid] = (SHOW_IT) ? MM_ITREE : 0x0L; break; case MENU_ICHECK: do_chg(MM_ITREE, ITEM_NUM, CHECKED, CHECK_IT, FALSE, FALSE); break; case MENU_IENABLE: do_chg(MM_ITREE, (ITEM_NUM & 0x7fff), DISABLED, !ENABLE_IT, ((ITEM_NUM & 0x8000) != 0x0), FALSE); break; case MENU_TNORMAL: if (gl_mntree == menu_tree[rlr->p_pid]) do_chg(MM_ITREE, TITLE_NUM, SELECTED, !NORMAL_IT, TRUE, TRUE); break; case MENU_TEXT: tree = MM_ITREE; strcpy((char *)LLGET(OB_SPEC(ITEM_NUM)), (char *)MM_PTEXT); break; case MENU_REGISTER: ret = mn_register(MM_PID, MM_PSTR); break; case MENU_UNREGISTER: #if CONF_WITH_PCGEM /* distinguish between menu_unregister() and menu_popup() */ if (IN_LEN == 1) mn_unregister( MM_MID ); else #endif unsupported = TRUE; break; case MENU_CLICK: /* distinguish between menu_click() and menu_attach() */ /* * although menu_click() is PC-GEM only, it's always * enabled because the desktop uses it. */ if (IN_LEN == 2) { if (MN_SETIT) gl_mnclick = MN_CLICK; ret = gl_mnclick; } else unsupported = TRUE; break; /* Object Manager */ case OBJC_ADD: ob_add(OB_TREE, OB_PARENT, OB_CHILD); break; case OBJC_DELETE: ob_delete(OB_TREE, OB_DELOB); break; case OBJC_DRAW: gsx_sclip((GRECT *)&OB_XCLIP); ob_draw(OB_TREE, OB_DRAWOB, OB_DEPTH); break; case OBJC_FIND: ret = ob_find(OB_TREE, OB_STARTOB, OB_DEPTH, OB_MX, OB_MY); break; case OBJC_OFFSET: ob_offset(OB_TREE, OB_OBJ, &OB_XOFF, &OB_YOFF); break; case OBJC_ORDER: ob_order(OB_TREE, OB_OBJ, OB_NEWPOS); break; case OBJC_EDIT: gsx_sclip(&gl_rfull); OB_ODX = OB_IDX; ret = ob_edit(OB_TREE, OB_OBJ, OB_CHAR, &OB_ODX, OB_KIND); break; case OBJC_CHANGE: gsx_sclip((GRECT *)&OB_XCLIP); ob_change(OB_TREE, OB_DRAWOB, OB_NEWSTATE, OB_REDRAW); break; /* Form Manager */ case FORM_DO: ret = fm_do(FM_FORM, FM_START); break; case FORM_DIAL: ret = fm_dial(FM_TYPE, (GRECT *)&FM_X); break; case FORM_ALERT: ret = fm_alert(FM_DEFBUT, FM_ASTRING); break; case FORM_ERROR: ret = fm_error(FM_ERRNUM); break; case FORM_CENTER: ob_center(FM_FORM, (GRECT *)&FM_XC); break; case FORM_KEYBD: gsx_sclip(&gl_rfull); FM_OCHAR = FM_ICHAR; FM_ONXTOB = FM_INXTOB; ret = fm_keybd(FM_FORM, FM_OBJ, &FM_OCHAR, &FM_ONXTOB); break; case FORM_BUTTON: gsx_sclip(&gl_rfull); ret = fm_button(FM_FORM, FM_OBJ, FM_CLKS, &FM_ONXTOB); break; /* Graphics Manager */ case GRAF_RUBBOX: gr_rubbox(GR_I1, GR_I2, GR_I3, GR_I4, &GR_O1, &GR_O2); break; case GRAF_DRAGBOX: gr_dragbox(GR_I1, GR_I2, GR_I3, GR_I4, (GRECT *)&GR_I5, &GR_O1, &GR_O2); break; case GRAF_MBOX: gr_movebox(GR_I1, GR_I2, GR_I3, GR_I4, GR_I5, GR_I6); break; case GRAF_GROWBOX: gr_growbox((GRECT *)&GR_I1, (GRECT *)&GR_I5); break; case GRAF_SHRINKBOX: gr_shrinkbox((GRECT *)&GR_I1, (GRECT *)&GR_I5); break; case GRAF_WATCHBOX: ret = gr_watchbox(GR_TREE, GR_OBJ, GR_INSTATE, GR_OUTSTATE); break; case GRAF_SLIDEBOX: ret = gr_slidebox(GR_TREE, GR_PARENT, GR_OBJ, GR_ISVERT); break; case GRAF_HANDLE: GR_WCHAR = gl_wchar; GR_HCHAR = gl_hchar; GR_WBOX = gl_wbox; GR_HBOX = gl_hbox; ret = gl_handle; break; case GRAF_MOUSE: if (GR_MNUMBER > 255) { if (GR_MNUMBER == M_OFF) gsx_moff(); if (GR_MNUMBER == M_ON) gsx_mon(); } else { if (GR_MNUMBER != 255) { switch(GR_MNUMBER) { case 1: mouse = MICE01; break; case 2: mouse = MICE02; break; case 3: mouse = MICE03; break; case 4: mouse = MICE04; break; case 5: mouse = MICE05; break; case 6: mouse = MICE06; break; case 7: mouse = MICE07; break; default: mouse = MICE00; break; } maddr = *(LONG *) &rs_bitblk[mouse]; } else maddr = GR_MADDR; gsx_mfset(maddr); } break; case GRAF_MKSTATE: gr_mkstate(&GR_MX, &GR_MY, &GR_MSTATE, &GR_KSTATE); break; /* Scrap Manager */ case SCRP_READ: ret = sc_read((BYTE*)SC_PATH); break; case SCRP_WRITE: ret = sc_write((const BYTE*)SC_PATH); break; #if CONF_WITH_PCGEM case SCRP_CLEAR: ret = sc_clear(); break; #endif /* File Selector Manager */ case FSEL_INPUT: ret = fs_input((BYTE*)FS_IPATH, (BYTE*)FS_ISEL, &FS_BUTTON, NULL); break; case FSEL_EXINPUT: ret = fs_input((BYTE*)FS_IPATH, (BYTE*)FS_ISEL, &FS_BUTTON, (BYTE *)FS_ILABEL); break; /* Window Manager */ case WIND_CREATE: ret = wm_create(WM_KIND, (GRECT *)&WM_WX); break; case WIND_OPEN: wm_open(WM_HANDLE, (GRECT *)&WM_WX); break; case WIND_CLOSE: wm_close(WM_HANDLE); break; case WIND_DELETE: wm_delete(WM_HANDLE); break; case WIND_GET: wm_get(WM_HANDLE, WM_WFIELD, &WM_OX); break; case WIND_SET: wm_set(WM_HANDLE, WM_WFIELD, &WM_IX); break; case WIND_FIND: ret = wm_find(WM_MX, WM_MY); break; case WIND_UPDATE: wm_update(WM_BEGUP); break; case WIND_CALC: wm_calc(WM_WCTYPE, WM_WCKIND, WM_WCIX, WM_WCIY, WM_WCIW, WM_WCIH, &WM_WCOX, &WM_WCOY, &WM_WCOW, &WM_WCOH); break; case WIND_NEW: wm_new(); break; /* Resource Manager */ case RSRC_LOAD: ret = rs_load(pglobal, RS_PFNAME); break; case RSRC_FREE: ret = rs_free(pglobal); break; case RSRC_GADDR: ret = rs_gaddr(pglobal, RS_TYPE, RS_INDEX, &ad_rso); break; case RSRC_SADDR: ret = rs_saddr(pglobal, RS_TYPE, RS_INDEX, RS_INADDR); break; case RSRC_OBFIX: rs_obfix(RS_TREE, RS_OBJ); break; /* Shell Manager */ case SHEL_READ: sh_read((BYTE*)SH_PCMD, (BYTE*)SH_PTAIL); break; case SHEL_WRITE: ret = sh_write(SH_DOEX, SH_ISGR, SH_ISCR, (const BYTE*)SH_PCMD, (const BYTE*)SH_PTAIL); break; case SHEL_GET: sh_get((void*)SH_PBUFFER, SH_LEN); break; case SHEL_PUT: sh_put((const void *)SH_PDATA, SH_LEN); break; case SHEL_FIND: ret = sh_find((BYTE*)SH_PATH); break; case SHEL_ENVRN: sh_envrn((BYTE**)SH_PATH, (const BYTE*)SH_SRCH); break; #if CONF_WITH_PCGEM case SHEL_RDEF: sh_rdef((BYTE*)SH_LPCMD, (BYTE*)SH_LPDIR); break; case SHEL_WDEF: sh_wdef((const BYTE*)SH_LPCMD, (const BYTE*)SH_LPDIR); break; #endif default: unsupported = TRUE; break; } if (unsupported) { kprintf("Bad AES function %d\n", opcode); if (opcode != 0) /* Ignore the 0 since some PRGs are this call */ fm_show(ALNOFUNC, &opcode, 1); ret = -1; } return(ret); }