uaecptr consolehook_beginio(TrapContext *ctx, uaecptr request) { uae_u32 io_data = trap_get_long(ctx, request + 40); // 0x28 uae_u32 io_length = trap_get_long(ctx, request + 36); // 0x24 uae_u32 io_actual = trap_get_long(ctx, request + 32); // 0x20 uae_u32 io_offset = trap_get_long(ctx, request + 44); // 0x2c uae_u16 cmd = trap_get_word(ctx, request + 28); if (cmd == CMD_WRITE) { int len = io_length; char *dbuf; TCHAR *buf; if (len == -1) { dbuf = xmalloc(char, MAX_DPATH); trap_get_string(ctx, dbuf, io_data, MAX_DPATH); len = strlen(dbuf); } else {
void trap_multi(TrapContext *ctx, struct trapmd *data, int items) { if (trap_is_indirect_null(ctx)) { uae_u8 *p = ctx->host_trap_data + RTAREA_TRAP_DATA_EXTRA; for (int i = 0; i < items; i++) { struct trapmd *md = &data[i]; put_word_host(p + 0, md->cmd); put_byte_host(p + 2, md->trapmd_index); put_byte_host(p + 3, md->parm_num); put_long_host(p + 4, md->params[0]); put_long_host(p + 8, md->params[1]); put_long_host(p + 12, md->params[2]); put_long_host(p + 16, md->params[3]); p += 5 * 4; } call_hardware_trap_back(ctx, TRAPCMD_MULTI, ctx->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, items, 0, 0); p = ctx->host_trap_data + RTAREA_TRAP_DATA_EXTRA; for (int i = 0; i < items; i++) { struct trapmd *md = &data[i]; md->params[0] = get_long_host(p + 4); p += 5 * 4; } } else { uae_u32 v = 0; for (int i = 0; i < items; i++) { struct trapmd *md = &data[i]; switch (md->cmd) { case TRAPCMD_PUT_LONG: trap_put_long(ctx, md->params[0], md->params[1]); break; case TRAPCMD_PUT_WORD: trap_put_word(ctx, md->params[0], md->params[1]); break; case TRAPCMD_PUT_BYTE: trap_put_byte(ctx, md->params[0], md->params[1]); break; case TRAPCMD_GET_LONG: v = md->params[0] = trap_get_long(ctx, md->params[0]); break; case TRAPCMD_GET_WORD: v = md->params[0] = trap_get_word(ctx, md->params[0]); break; case TRAPCMD_GET_BYTE: v = md->params[0] = trap_get_byte(ctx, md->params[0]); break; case TRAPCMD_PUT_BYTES: trap_put_bytes(ctx, md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_GET_BYTES: trap_get_bytes(ctx, md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_PUT_WORDS: trap_put_words(ctx, (uae_u16*)md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_GET_WORDS: trap_get_words(ctx, (uae_u16*)md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_PUT_LONGS: trap_put_longs(ctx, (uae_u32*)md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_GET_LONGS: trap_get_longs(ctx, (uae_u32*)md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_PUT_STRING: trap_put_string(ctx, md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_GET_STRING: trap_get_string(ctx, md->haddr, md->params[0], md->params[1]); break; case TRAPCMD_SET_LONGS: trap_set_longs(ctx, md->params[0], md->params[1], md->params[2]); break; case TRAPCMD_SET_WORDS: trap_set_words(ctx, md->params[0], md->params[1], md->params[2]); break; case TRAPCMD_SET_BYTES: trap_set_bytes(ctx, md->params[0], md->params[1], md->params[2]); break; case TRAPCMD_NOP: break; } if (md->trapmd_index) { data[md->trapmd_index].params[md->parm_num] = v; } } } }
uae_char *trap_get_alloc_string(TrapContext *ctx, uaecptr addr, int maxlen) { uae_char *buf = xmalloc(uae_char, maxlen); trap_get_string(ctx, buf, addr, maxlen); return buf; }