printf("Writing garbege datas.\n");
for (uint32_t i = 0; i < 512 * 1024; i++) {
- garbege_datas[i] = (uint8_t)(rand() % 0xFF);
+ while(garbege_datas[i] == 0x00)
+ garbege_datas[i] = (uint8_t)(rand() % 0xFF);
write8(i, (uint32_t)garbege_datas[i]);
}
+
printf("Reading back garbege datas, read8()...\n");
for (uint32_t i = 0; i < 512 * 1024; i++) {
uint32_t c = read8(i);
printf("read8 errors total: %d.\n", errors);
errors = 0;
sleep (1);
+
printf("Reading back garbege datas, read16(), even addresses...\n");
for (uint32_t i = 0; i < (512 * 1024) - 2; i += 2) {
uint32_t c = be16toh(read16(i));
printf("read16 even errors total: %d.\n", errors);
errors = 0;
sleep (1);
- for (int x = 0; x < 20; x++) {
- printf("Reading back garbege datas, read16(), odd addresses...\n");
- for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
- uint32_t c = be16toh((read8(i) << 8) | read8(i + 1));
- if (c != *((uint16_t *)&garbege_datas[i])) {
- if (errors < 512)
- printf("READ16_ODD: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
- errors++;
- }
+
+ printf("Reading back garbege datas, read16(), odd addresses...\n");
+ for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
+ uint32_t c = be16toh((read8(i) << 8) | read8(i + 1));
+ if (c != *((uint16_t *)&garbege_datas[i])) {
+ if (errors < 512)
+ printf("READ16_ODD: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
+ errors++;
}
- printf("read16 odd loop %d errors total: %d.\n", x+1, errors);
- errors = 0;
}
+ printf("read16 odd errors total: %d.\n", errors);
+ errors = 0;
sleep (1);
+
printf("Reading back garbege datas, read32(), even addresses...\n");
for (uint32_t i = 0; i < (512 * 1024) - 4; i += 2) {
uint32_t c = be32toh(read32(i));
printf("read32 even errors total: %d.\n", errors);
errors = 0;
sleep (1);
- for (int x = 0; x < 20; x++) {
- printf("Reading back garbege datas, read32(), odd addresses...\n");
- for (uint32_t i = 1; i < (512 * 1024) - 4; i += 2) {
- uint32_t c = be32toh(read32(i));
- c = (c >> 8) | (read8(i + 3) << 24);
- if (c != *((uint32_t *)&garbege_datas[i])) {
- if (errors < 512)
- printf("READ32_ODD: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
- errors++;
- }
+
+ printf("Reading back garbege datas, read32(), odd addresses...\n");
+ for (uint32_t i = 1; i < (512 * 1024) - 4; i += 2) {
+ uint32_t c = read8(i);
+ c |= (be16toh(read16(i + 1)) << 8);
+ c |= (read8(i + 3) << 24);
+ //c = be32toh(c);
+ if (c != *((uint32_t *)&garbege_datas[i])) {
+ if (errors < 512)
+ printf("READ32_ODD: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
+ errors++;
+ }
+ }
+ printf("read32 odd errors total: %d.\n", errors);
+ errors = 0;
+ sleep (1);
+
+ printf("Clearing 512KB of Chip again\n");
+ for (uint32_t i = 0; i < 512 * 1024; i++) {
+ write8(i, (uint32_t)0x0);
+ }
+
+ printf("[WORD] Writing garbege datas to Chip, unaligned...\n");
+ for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
+ uint16_t v = *((uint16_t *)&garbege_datas[i]);
+ write8(i, (v & 0x00FF));
+ write8(i + 1, (v >> 8));
+ //write16(i, *((uint16_t *)&garbege_datas[i]));
+ }
+
+ sleep (1);
+ printf("Reading back garbege datas, read16(), odd addresses...\n");
+ for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
+ //uint32_t c = be16toh(read16(i));
+ uint32_t c = be16toh((read8(i) << 8) | read8(i + 1));
+ if (c != *((uint16_t *)&garbege_datas[i])) {
+ if (errors < 512)
+ printf("READ16_EVEN: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
+ errors++;
}
- printf("read32 odd loop %d errors total: %d.\n", x+1, errors);
- errors = 0;
}
+ printf("read16 even errors total: %d.\n", errors);
+ errors = 0;
+
+ printf("Clearing 512KB of Chip again\n");
+ for (uint32_t i = 0; i < 512 * 1024; i++) {
+ write8(i, (uint32_t)0x0);
+ }
+
+ printf("[LONG] Writing garbege datas to Chip, unaligned...\n");
+ for (uint32_t i = 1; i < (512 * 1024) - 4; i += 4) {
+ uint32_t v = *((uint32_t *)&garbege_datas[i]);
+ write8(i , v & 0x0000FF);
+ write16(i + 1, htobe16(((v & 0x00FFFF00) >> 8)));
+ write8(i + 3 , (v & 0xFF000000) >> 24);
+ //write32(i, v);
+ }
+
sleep (1);
+ printf("Reading back garbege datas, read32(), even addresses...\n");
+ for (uint32_t i = 1; i < (512 * 1024) - 4; i += 4) {
+ uint32_t c = read8(i);
+ c |= (be16toh(read16(i + 1)) << 8);
+ c |= (read8(i + 3) << 24);
+ //uint32_t c = be32toh(read32(i));
+ if (c != *((uint32_t *)&garbege_datas[i])) {
+ if (errors < 512)
+ printf("READ32_EVEN: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
+ errors++;
+ }
+ }
+ printf("read32 even errors total: %d.\n", errors);
+ errors = 0;
return 0;
}
static unsigned int target = 0;
static uint8_t send_keypress = 0;
+uint8_t cdtv_dmac_reg_idx_read();
+void cdtv_dmac_reg_idx_write(uint8_t value);
+uint32_t cdtv_dmac_read(uint32_t address, uint8_t type);
+void cdtv_dmac_write(uint32_t address, uint32_t value, uint8_t type);
+
#define PLATFORM_CHECK_READ(a) \
if (address >= cfg->custom_low && address < cfg->custom_high) { \
unsigned int target = 0; \
unsigned int m68k_read_memory_8(unsigned int address) {
PLATFORM_CHECK_READ(OP_TYPE_BYTE);
+ if (address >= 0xE90000 && address < 0xF00000) {
+ printf("BYTE read from DMAC @%.8X:", address);
+ uint32_t v = cdtv_dmac_read(address & 0xFFFF, OP_TYPE_BYTE);
+ printf("%.2X\n", v);
+ m68k_end_timeslice();
+ cpu_emulation_running = 0;
+ return v;
+ }
+
if (mouse_hook_enabled) {
if (address == CIAAPRA) {
unsigned char result = (unsigned int)read8((uint32_t)address);
unsigned int m68k_read_memory_16(unsigned int address) {
PLATFORM_CHECK_READ(OP_TYPE_WORD);
+ if (address >= 0xE90000 && address < 0xF00000) {
+ printf("WORD read from DMAC @%.8X:", address);
+ uint32_t v = cdtv_dmac_read(address & 0xFFFF, OP_TYPE_WORD);
+ printf("%.2X\n", v);
+ m68k_end_timeslice();
+ cpu_emulation_running = 0;
+ return v;
+ }
+
if (mouse_hook_enabled) {
if (address == JOY0DAT) {
// Forward mouse valueses to Amyga.
unsigned int m68k_read_memory_32(unsigned int address) {
PLATFORM_CHECK_READ(OP_TYPE_LONGWORD);
+ if (address >= 0xE90000 && address < 0xF00000) {
+ printf("LONGWORD read from DMAC @%.8X:", address);
+ uint32_t v = cdtv_dmac_read(address & 0xFFFF, OP_TYPE_LONGWORD);
+ printf("%.2X\n", v);
+ m68k_end_timeslice();
+ cpu_emulation_running = 0;
+ return v;
+ }
+
if (address & 0xFF000000)
return 0;
void m68k_write_memory_8(unsigned int address, unsigned int value) {
PLATFORM_CHECK_WRITE(OP_TYPE_BYTE);
+ if (address >= 0xE90000 && address < 0xF00000) {
+ printf("BYTE write to DMAC @%.8X: %.2X\n", address, value);
+ cdtv_dmac_write(address & 0xFFFF, value, OP_TYPE_BYTE);
+ m68k_end_timeslice();
+ cpu_emulation_running = 0;
+ return;
+ }
+
if (address == 0xbfe001) {
if (ovl != (value & (1 << 0))) {
ovl = (value & (1 << 0));
void m68k_write_memory_16(unsigned int address, unsigned int value) {
PLATFORM_CHECK_WRITE(OP_TYPE_WORD);
+ if (address >= 0xE90000 && address < 0xF00000) {
+ printf("WORD write to DMAC @%.8X: %.4X\n", address, value);
+ cdtv_dmac_write(address & 0xFFFF, value, OP_TYPE_WORD);
+ m68k_end_timeslice();
+ cpu_emulation_running = 0;
+ return;
+ }
+
if (address & 0xFF000000)
return;
+ if (address & 0x01)
+ printf("Unaligned WORD write!\n");
+
write16((uint32_t)address, value);
return;
}
void m68k_write_memory_32(unsigned int address, unsigned int value) {
PLATFORM_CHECK_WRITE(OP_TYPE_LONGWORD);
+ if (address >= 0xE90000 && address < 0xF00000) {
+ printf("LONGWORD write to DMAC @%.8X: %.8X\n", address, value);
+ cdtv_dmac_write(address & 0xFFFF, value, OP_TYPE_LONGWORD);
+ m68k_end_timeslice();
+ cpu_emulation_running = 0;
+ return;
+ }
+
if (address & 0xFF000000)
return;
-
+
+ if (address & 0x01)
+ printf("Unaligned LONGWORD write!\n");
+
write16(address, value >> 16);
write16(address + 2, value);
return;