if (r == -1) {
DEBUG("[GRAB_AMIGA_STRING] No mapped range found for address $%.8X. Grabbing string data over the bus.\n", addr);
do {
- dest[index] = read8(addr + index);
+ dest[index] = (unsigned char)m68k_read_memory_8(addr + index);
index++;
} while (dest[index - 1] != 0x00 && index < str_max_len);
}
for (uint32_t i = 0; i < filesize; i++) {
tmp_read = (uint8_t)fgetc(in);
- write8(addr + i, tmp_read);
+ m68k_write_memory_8(addr + i, tmp_read);
}
} else {
uint8_t *dst = cfg->map_data[r] + (addr - cfg->map_offset[r]);
printf("!!! doing manual memcpy\n");
uint8_t tmp = 0;
for (uint32_t i = 0; i < val; i++) {
- if (src == -1) tmp = read8(pi_ptr[0] + i);
+ if (src == -1) tmp = (unsigned char)m68k_read_memory_8(pi_ptr[0] + i);
else tmp = cfg->map_data[src][pi_ptr[0] - cfg->map_offset[src] + i];
- if (dst == -1) write8(pi_ptr[1] + i, tmp);
+ if (dst == -1) m68k_write_memory_8(pi_ptr[1] + i, tmp);
else cfg->map_data[dst][pi_ptr[1] - cfg->map_offset[dst] + i] = tmp;
}
}
//DEBUG("[PISTORM-DEV] Copied %d bytes from $%.8X to $%.8X\n", val, pi_ptr[0], pi_ptr[1]);
}
break;
+ case PI_CMD_MEMSET:
+ //DEBUG("[PISTORM-DEV} Write to MEMSET: %d (%.8X)\n", val, val);
+ if (pi_ptr[0] == 0) {
+ printf("[PISTORM-DEV] MEMSET with null pointer not allowed. Aborting.\n");
+ pi_cmd_result = PI_RES_INVALIDVALUE;
+ } else if (val == 0) {
+ printf("[PISTORM-DEV] MEMSET called with size 0. Aborting.\n");
+ pi_cmd_result = PI_RES_INVALIDVALUE;
+ } else {
+ int32_t dst = get_mapped_item_by_address(cfg, pi_ptr[0]);
+ if (dst != -1) {
+ uint8_t *dst_ptr = &cfg->map_data[dst][(pi_ptr[0] - cfg->map_offset[dst])];
+ memset(dst_ptr, pi_byte[0], val);
+ } else {
+ for (uint32_t i = 0; i < val; i++) {
+ m68k_write_memory_8(pi_ptr[0] + i, val);
+ }
+ }
+ }
+ break;
case PI_CMD_COPYRECT:
case PI_CMD_COPYRECT_EX:
if (pi_ptr[0] == 0 || pi_ptr[1] == 0) {
for (uint32_t y = 0; y < pi_word[3]; y++) {
for (uint32_t x = 0; x < pi_word[2]; x++) {
- if (src == -1) tmp = read8(pi_ptr[0] + src_offset + x);
+ if (src == -1) tmp = (unsigned char)m68k_read_memory_8(pi_ptr[0] + src_offset + x);
else tmp = cfg->map_data[src][(pi_ptr[0] + src_offset + x) - cfg->map_offset[src]];
- if (dst == -1) write8(pi_ptr[1] + dst_offset + x, tmp);
+ if (dst == -1) m68k_write_memory_8(pi_ptr[1] + dst_offset + x, tmp);
else cfg->map_data[dst][(pi_ptr[1] + dst_offset + x) - cfg->map_offset[dst]] = tmp;
}
src_offset += pi_word[0];