EXPORT BOOL WINAPI mhsp_SWFBitmap_buf(HSPEXINFO *hei, int p2, int p3, int p4) { unsigned char *buf, *buf2; int size, size2; SWFInput input; SWFBitmap *p1; lstrcpy(funcname, "SWFBitmap_buf"); p1 = (SWFBitmap *)hei->HspFunc_prm_getv(); buf = (unsigned char *)hei->HspFunc_prm_getv(); size = hei->HspFunc_prm_geti(); buf2 = (unsigned char *)hei->HspFunc_prm_getv(); size2 = hei->HspFunc_prm_getdi(0); input = newSWFInput_allocedBuffer(buf, size); if (size2 && isJPEG(input)) { SWFInput_seek(input, 0, SEEK_SET); *p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input, newSWFInput_allocedBuffer(buf2, size2)); } #ifdef JAMING else if (isDBL(input) || isJPEG(input)) #else else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input)) #endif { SWFInput_seek(input, 0, SEEK_SET); *p1 = newSWFBitmap_fromInput(newSWFInput_allocedBuffer(buf, size)); } else { return -1; } if (!mhsp_bitmap) { mhsp_bitmap = *p1; } return 0; }
EXPORT BOOL WINAPI mhsp_SWFBitmap(HSPEXINFO *hei, int p2, int p3, int p4) { FILE *fp1, *fp2; char filename[MHSP_STRMAX], alpha[MHSP_STRMAX]; SWFInput input; SWFBitmap *p1; lstrcpy(funcname, "SWFBitmap"); p1 = (SWFBitmap *)hei->HspFunc_prm_getv(); lstrcpyn(filename, hei->HspFunc_prm_gets(), MHSP_STRMAX); lstrcpyn(alpha, hei->HspFunc_prm_getds(""), MHSP_STRMAX); fp1 = fopen(filename, "rb"); if (!fp1) { return 1; } input = newSWFInput_file(fp1); fp2 = fopen(alpha, "rb"); if (fp2 && isJPEG(input)) { SWFInput_seek(input, 0, SEEK_SET); *p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input, newSWFInput_file(fp2)); } #ifdef JAMING else if (isDBL(input) || isJPEG(input)) #else else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input)) #endif { SWFInput_seek(input, 0, SEEK_SET); *p1 = newSWFBitmap_fromInput(input); } else { return -1; /* 非対応フォーマット */ } if (!mhsp_bitmap) { mhsp_bitmap = *p1; } return 0; }
/* * Main loop */ int main(int argc, char *argv[]) { int c, n = 0; int warm = 0; xeq_init_contexts(); load_statefile(); if (argc > 1) { if (argc == 2) { if (strcmp(argv[1], "commands") == 0) { dump_commands(0); return 0; } if (strcmp(argv[1], "reg") == 0) { dump_registers(); return 0; } if (strcmp(argv[1], "wake") == 0) { warm = 1; goto skipargs; } if (strcmp(argv[1], "opcodes") == 0) { dump_opcodes(stdout, 0); return 0; } if (strcmp(argv[1], "xref") == 0) { dump_opcodes(stdout, 1); return 0; } if (strcmp(argv[1], "constants") == 0) { dump_constants(); return 0; } dump_menu("statistics", "", CATALOGUE_STATS); dump_menu("probability", "", CATALOGUE_PROB); dump_menu("clear", "", CATALOGUE_CLEAR); dump_menu("displ", "", CATALOGUE_DISPL); dump_menu("more", "", CATALOGUE_MORE); dump_menu("modes", "", CATALOGUE_MODE); dump_menu("conversions", "", CATALOGUE_CONV); dump_menu("constants", "# ", CATALOGUE_CONST); } for (c=0; c<65536; c++) { if (isDBL(c) && (c & 0xff)) /* Don't show all multi-word instructions */ continue; n += dumpop(c, argc > 2); } printf("total number of opcodes %d\n", n); printf("\tniladic commands %d\n", NUM_NILADIC); for (n=c=0; c<NUM_MONADIC; c++) { if (monfuncs[c].mondreal != NULL) n++; if (monfuncs[c].mondcmplx != NULL) n++; if (monfuncs[c].monint != NULL) n++; } printf("\tmonadic commands %d with %d functions\n", NUM_MONADIC, n); for (n=c=0; c<NUM_DYADIC; c++) { if (dyfuncs[c].dydreal != NULL) n++; if (dyfuncs[c].dydcmplx != NULL) n++; if (dyfuncs[c].dydint != NULL) n++; } printf("\tdyadic commands %d with %d functions\n", NUM_DYADIC, n); for (n=c=0; c<NUM_TRIADIC; c++) { if (trifuncs[c].trireal != NULL) n++; if (trifuncs[c].triint != NULL) n++; } printf("\ttriadic commands %d with %d functions\n", NUM_TRIADIC, n); printf("\targument commands %d\n", NUM_RARG); printf("\tmultiword commands %d\n", NUM_MULTI); printf("\tspecial commands %d\n", NUM_SPECIAL); printf("\ttotal commands %u\n", dump_commands(1)); return 0; } skipargs: if (!warm) init_34s(); State2.flags = 1; if (setuptty(0) == 0) { display(); JustDisplayed = 0; while ((c = GETCHAR()) != GETCHAR_ERR && c != CH_QUIT) { #ifdef USECURSES if (c == CH_TRACE) { State2.trace = 1 - State2.trace; display(); } else if (c == CH_FLAGS) { State2.flags = 1 - State2.flags; display(); } else if (c == CH_REFRESH) { clear(); display(); } else if (c == CH_ICOUNT) { instruction_count = 0; view_instruction_counter = 1 - view_instruction_counter; display(); } else if (c == CH_PASTE) { paste_raw_x("123.14159265358979323846264338327950"); c = K_UNKNOWN; clear(); display(); } else if (c == CH_COPY) { char buffer[66]; const char *p = fill_buffer_from_raw_x(buffer); printf("%s\n", p); fflush(NULL); sleep(1); c = K_UNKNOWN; } else #endif c=remap(c); if(c != K_UNKNOWN) { process_keycode(c); process_keycode(K_RELEASE); } } setuptty(1); } shutdown(); return 0; }
void dump_opcodes(FILE *f) { int c, d; char cmdname[16]; char cmdpretty[500]; const char *p; for (c=0; c<65536; c++) { if (isDBL(c)) { const unsigned int cmd = opDBL(c); if ((c & 0xff) != 0) continue; if (cmd >= num_multicmds) continue; #ifdef INCLUDE_MULTI_DELETE if (cmd == DBL_DELPROG) continue; #endif xset(cmdname, '\0', 16); xcopy(cmdname, multicmds[cmd].cmd, NAME_LEN); prettify(cmdname, cmdpretty); fprintf(f, "0x%04x\tmult\t%s\n", c, cmdpretty); } else if (isRARG(c)) { const unsigned int cmd = RARG_CMD(c); unsigned int limit; if (cmd >= NUM_RARG) continue; #ifdef INCLUDE_MULTI_DELETE if (cmd == RARG_DELPROG) continue; #endif limit = argcmds[cmd].lim; if (cmd != RARG_ALPHA && (c & RARG_IND) != 0) continue; p = catcmd(c, cmdname); if (strcmp(p, "???") == 0) continue; prettify(p, cmdpretty); if (cmd == RARG_ALPHA) { if ((c & 0xff) == 0) continue; if ((c & 0xff) == ' ') fprintf(f, "0x%04x\tcmd\t[alpha] [space]\n", c); else fprintf(f, "0x%04x\tcmd\t[alpha] %s\n", c, cmdpretty); continue; } else if (cmd == RARG_CONST || cmd == RARG_CONST_CMPLX) { fprintf(f, "0x%04x\tcmd\t%s# %s\n", c, cmd == RARG_CONST_CMPLX?"[cmplx]":"", cmdpretty); continue; } else if (cmd == RARG_CONV) { fprintf(f, "0x%04x\tcmd\t%s\n", c, cmdpretty); continue; } else if (cmd == RARG_CONST_INT) { p = prt(c, cmdname); if (strcmp(p, "???") != 0) fprintf(f, "0x%04x\tcmd\t%s\n", c, p); if ((c & 0xff) != 0) continue; limit = 0; } if ((c & 0xff) != 0) continue; fprintf(f, "0x%04x\targ\t%s\tmax=%u", c, cmdpretty, limit); if (argcmds[cmd].indirectokay) fprintf(f, ",indirect"); if (argcmds[cmd].stos) fprintf(f, ",stostack"); else if (argcmds[cmd].stckreg) fprintf(f, ",stack"); if (argcmds[cmd].cmplx) fprintf(f, ",complex"); fprintf(f, "\n"); } else { p = catcmd(c, cmdname); if (strcmp(p, "???") == 0) continue; prettify(p, cmdpretty); d = argKIND(c); switch (opKIND(c)) { default: break; case KIND_MON: if (d < num_monfuncs && (! isNULL(monfuncs[d].mondreal) || ! isNULL(monfuncs[d].monint))) break; continue; case KIND_DYA: if (d < num_dyfuncs && (! isNULL(dyfuncs[d].dydreal) || ! isNULL(dyfuncs[d].dydint))) break; continue; case KIND_CMON: if (d < num_monfuncs && ! isNULL(monfuncs[d].mondcmplx)) { if (cmdname[0] == COMPLEX_PREFIX) break; fprintf(f, "0x%04x\tcmd\t[cmplx]%s\n", c, cmdpretty); } continue; case KIND_CDYA: if (d < num_dyfuncs && ! isNULL(dyfuncs[d].dydcmplx)) { if (cmdname[0] == COMPLEX_PREFIX) break; fprintf(f, "0x%04x\tcmd\t[cmplx]%s\n", c, cmdpretty); } continue; case KIND_NIL: d = c & 0xff; if (d == OP_CLALL || d == OP_RESET) { continue; } } fprintf(f, "0x%04x\tcmd\t%s\n", c, cmdpretty); } } }