static address_space tms_space;
mscreen *m_screen;
-#define OVERLAY_WIDTH 512
+#define OVERLAY_WIDTH 1024
+static int fullrefresh;
+static int request_fullrefresh;
static uae_u8 *program_ram;
static int a2410_palette_index;
static uae_u8 a2410_palette[4 * (256 + 4)];
static uae_u32 a2410_palette_32[256 + 4];
+static uae_u8 a2410_palette_temp[4];
static uae_u8 a2410_palette_control[4];
static uae_u16 a2410_control;
static bool a2410_modified[1024];
return addr;
}
+UINT32 total_cycles(void)
+{
+ return get_cycles() / CYCLE_UNIT;
+}
+
void m_to_shiftreg_cb(address_space space, offs_t offset, UINT16 *shiftreg)
{
memcpy(shiftreg, &gfxmem_bank.baseaddr[TOWORD(offset)], 256 * sizeof(UINT16));
if (!a2410_isactive)
return;
addr &= 0x1ffff;
- addr /= OVERLAY_WIDTH / 4;
+ addr /= OVERLAY_WIDTH / 8;
a2410_modified[addr] = true;
}
static void a2410_create_palette32(int offset)
{
int idx = a2410_palette_index / 4 + offset;
+ if (a2410_palette[idx * 4 + 0] != a2410_palette_temp[0] ||
+ a2410_palette[idx * 4 + 1] != a2410_palette_temp[1] ||
+ a2410_palette[idx * 4 + 2] != a2410_palette_temp[2]) {
+ request_fullrefresh = 1;
+ }
+ a2410_palette[idx * 4 + 0] = a2410_palette_temp[0];
+ a2410_palette[idx * 4 + 1] = a2410_palette_temp[1];
+ a2410_palette[idx * 4 + 2] = a2410_palette_temp[2];
a2410_palette_32[idx] =
- (a2410_palette[idx * 4 + 0] << 16) |
- (a2410_palette[idx * 4 + 1] << 8) |
- (a2410_palette[idx * 4 + 2] << 0);
+ (a2410_palette_temp[0] << 16) |
+ (a2410_palette_temp[1] << 8) |
+ (a2410_palette_temp[2] << 0);
+#if 0
+ write_log(_T("PAL %d: %02x %02x %02x = %08x\n"),
+ idx,
+ a2410_palette_temp[0],
+ a2410_palette_temp[1],
+ a2410_palette_temp[2],
+ a2410_palette_32[idx]);
+#endif
}
static void write_ramdac(int addr, uae_u8 v)
{
+ int coloridx = a2410_palette_index & 3;
switch (addr)
{
case 0:
a2410_palette_index = v * 4;
break;
case 1:
- a2410_palette[a2410_palette_index] = v;
- a2410_create_palette32(0);
+ a2410_palette_temp[coloridx] = v;
a2410_palette_index++;
- if ((a2410_palette_index & 3) == 3)
+ if ((a2410_palette_index & 3) == 3) {
+ a2410_create_palette32(0);
a2410_palette_index++;
+ }
if (a2410_palette_index >= 256 * 4)
a2410_palette_index = 0;
break;
break;
case 3:
if (a2410_palette_index < 4 * 4) {
- a2410_palette[a2410_palette_index + 256 * 4] = v;
- a2410_create_palette32(256);
+ a2410_palette_temp[coloridx] = v;
a2410_palette_index++;
- if ((a2410_palette_index & 3) == 3)
+ if ((a2410_palette_index & 3) == 3) {
+ a2410_create_palette32(256);
a2410_palette_index++;
+ }
if (a2410_palette_index >= 4 * 4)
a2410_palette_index = 0;
}
uae_u8 v = 0;
UINT32 aa = a << 3;
uaecptr addr = makeaddr(a, &bank);
+
+ addr ^= 1;
switch (bank)
{
case A2410_BANK_PROGRAM:
break;
case A2410_BANK_FRAMEBUFFER:
v = gfxmem_bank.baseaddr[addr];
- write_log(_T("TMS byte read framebuffer %08x (%08x) = %02x PC=%08x\n"), aa, addr, v, M68K_GETPC);
+ //write_log(_T("TMS byte read framebuffer %08x (%08x) = %02x PC=%08x\n"), aa, addr, v, M68K_GETPC);
break;
case A2410_BANK_RAMDAC:
v = read_ramdac(addr);
- write_log(_T("RAMDAC READ %08x = %02x PC=%08x\n"), aa, v, M68K_GETPC);
+ //write_log(_T("RAMDAC READ %08x = %02x PC=%08x\n"), aa, v, M68K_GETPC);
break;
case A2410_BANK_CONTROL:
v = get_a2410_control();
uae_u16 v = 0;
UINT32 aa = a << 3;
uaecptr addr = makeaddr(a, &bank);
+
switch (bank)
{
case A2410_BANK_TMSIO:
v = tms_device.io_register_r(*this, addr);
- write_log(_T("TMS IO word read %08x (%08x) = %04x PC=%08x PC=%08x\n"), aa, addr, v, M68K_GETPC);
+ //write_log(_T("TMS IO word read %08x (%08x) = %04x PC=%08x PC=%08x\n"), aa, addr, v, M68K_GETPC);
break;
case A2410_BANK_PROGRAM:
v = program_ram[addr] << 8;
break;
case A2410_BANK_RAMDAC:
v = read_ramdac(addr);
- write_log(_T("RAMDAC READ %08x = %02x PC=%08x\n"), aa, v, M68K_GETPC);
+ //write_log(_T("RAMDAC READ %08x = %02x PC=%08x\n"), aa, v, M68K_GETPC);
break;
case A2410_BANK_CONTROL:
v = get_a2410_control();
}
return v;
}
+
void address_space::write_byte(UINT32 a, UINT8 b)
{
int bank;
UINT32 aa = a << 3;
uaecptr addr = makeaddr(a, &bank);
+ addr ^= 1;
switch (bank)
{
case A2410_BANK_PROGRAM:
break;
case A2410_BANK_FRAMEBUFFER:
gfxmem_bank.baseaddr[addr] = b;
- write_log(_T("TMS gfx byte write %08x (%08x) = %02x PC=%08x\n"), aa, addr, b, M68K_GETPC);
+ //write_log(_T("TMS gfx byte write %08x (%08x) = %02x PC=%08x\n"), aa, addr, b, M68K_GETPC);
break;
case A2410_BANK_RAMDAC:
//write_log(_T("RAMDAC WRITE %08x = %02x PC=%08x\n"), aa, b, M68K_GETPC);
break;
}
}
+
void address_space::write_word(UINT32 a, UINT16 b)
{
int bank;
{
case A2410_BANK_TMSIO:
tms_device.io_register_w(*this, addr, b);
- write_log(_T("TMS IO word write %08x (%08x) = %04x PC=%08x\n"), aa, addr, b, M68K_GETPC);
+ //write_log(_T("TMS IO word write %08x (%08x) = %04x PC=%08x\n"), aa, addr, b, M68K_GETPC);
break;
case A2410_BANK_PROGRAM:
program_ram[addr] = b >> 8;
//write_log(_T("TMS gfx word write %08x (%08x) = %04x PC=%08x\n"), aa, addr, b, M68K_GETPC);
break;
case A2410_BANK_RAMDAC:
- //write_log(_T("RAMDAC WRITE %08x = %04x PC=%08x\n"), aa, b, M68K_GETPC);
+ //write_log(_T("RAMDAC WRITE %08x = %04x IDX=%d/%d PC=%08x\n"), aa, b, a2410_palette_index / 4, a2410_palette_index & 3, M68K_GETPC);
write_ramdac(addr, b);
break;
case A2410_BANK_CONTROL:
}
return;
}
+// write_log(_T("tms_bput %08x=%02x\n"), addr, b);
tms_device.host_w(tms_space, addr >> 1, (b << 8) | b);
tms_execute_single();
}
tms_lget, tms_wget, ABFLAG_IO
};
+static bool a2410_modechanged;
+static int a2410_gotmode;
+static int a2410_width, a2410_height;
+static int a2410_vram_start_offset;
+static uae_u8 *a2410_surface;
+static int a2410_interlace;
+static int a2410_interrupt;
+
void tms_reset(void)
{
- tms_device.device_reset();
+ if (a2410_surface)
+ gfx_unlock_picasso(true);
+ a2410_surface = NULL;
+
+ a2410_modechanged = false;
+ a2410_gotmode = 0;
+ a2410_interlace = 0;
+ a2410_interrupt = 0;
+
+ if (program_ram)
+ tms_device.device_reset();
tms_configured = 0;
}
void tms_free(void)
{
+ if (a2410_surface)
+ gfx_unlock_picasso(true);
+ a2410_surface = NULL;
mapped_free(&gfxmem_bank);
xfree(program_ram);
+ program_ram = NULL;
}
addrbank *tms_init(int devnum)
mapped_free(&gfxmem_bank);
xfree(program_ram);
- gfxmem_bank.label = _T("x_a0");
+ gfxmem_bank.label = _T("ram_a8");
gfxmem_bank.allocated = 1 * 1024 * 1024;
mapped_malloc(&gfxmem_bank);
picasso_allocatewritewatch(gfxmem_bank.allocated);
- gfxmem_bank.start = 0xa00000;
+ gfxmem_bank.start = 0xa80000;
program_ram = xcalloc(uae_u8, 1 * 1024 * 1024);
return &tms_bank;
}
-static bool a2410_modechanged;
-static int a2410_gotmode;
-static int a2410_width, a2410_height;
-static int fullrefresh;
-static int a2410_vram_start_offset;
-static uae_u8 *a2410_surface;
-static int a2410_interlace;
-
void mscreen::configure(int width, int height, rectangle vis)
{
a2410_width = vis.max_x - vis.min_x + 1;
return false;
}
-void tms_vsync_handler(void)
+static void tms_vsync_handler2(bool internalsync)
{
if (!tms_configured)
return;
if (currprefs.leds_on_screen & STATUSLINE_RTG) {
get_a2410_surface();
}
- if (fullrefresh > 0)
- fullrefresh--;
+ if (internalsync) {
+ if (fullrefresh > 0)
+ fullrefresh--;
+ if (request_fullrefresh) {
+ fullrefresh = 1;
+ request_fullrefresh = 0;
+ }
+ }
}
if (a2410_surface)
}
}
+
+static void a2410_rethink(void)
+{
+ if (a2410_interrupt)
+ INTREQ_0(0x8000 | 0x0008);
+}
+
+void tms_vsync_handler(void)
+{
+ if (!a2410_isactive)
+ tms_vsync_handler2(false);
+
+ if (a2410_surface)
+ gfx_unlock_picasso(false);
+ a2410_surface = NULL;
+}
+
void tms_hsync_handler(void)
{
- int a2410_vpos = tms_vp;
if (!tms_configured)
return;
- if (a2410_vpos == 0 && a2410_isactive) {
- picasso_getwritewatch(a2410_vram_start_offset);
- }
-
tms_device.m_icount = 50;
tms_device.execute_run();
- tms_vp = tms_device.scanline_callback(NULL, tms_vp);
+ int a2410_vpos = tms_vp;
+ tms_vp = tms_device.scanline_callback(NULL, tms_vp, a2410_interlace < 0);
+
+ a2410_rethink();
if (!a2410_isactive)
return;
+ if (a2410_vpos == 0) {
+ tms_vsync_handler2(true);
+ picasso_getwritewatch(a2410_vram_start_offset);
+ }
+
+ if (a2410_modechanged)
+ return;
+
tms34010_display_params parms;
tms_device.get_display_params(&parms);
- if (a2410_interlace) {
- a2410_vpos = tms_vp * 2;
- if (a2410_interlace < 0)
- a2410_vpos++;
- }
-
a2410_displaywidth = parms.hsblnk - parms.heblnk;
a2410_displayend = parms.heblnk;
a2410_vertical_start = parms.veblnk;
- if (a2410_vpos >= a2410_height || a2410_vpos >= picasso_vidinfo.height)
- return;
-
int overlay_yoffset = a2410_vpos - a2410_vertical_start;
int coladdr = parms.coladdr;
uae_u16 *vram = (uae_u16*)gfxmem_bank.baseaddr + vramoffset;
int overlayoffset = a2410_vpos - parms.veblnk;
- uae_u8 *overlay0 = program_ram + overlayoffset * OVERLAY_WIDTH / 4;
- uae_u8 *overlay1 = overlay0 + 0x20000;
- if (!fullrefresh && (overlay_yoffset < 0 || !a2410_modified[overlay_yoffset])) {
+ if (overlay_yoffset < 0)
+ return;
+
+ if (a2410_interlace) {
+ overlay_yoffset *= 2;
+ if (a2410_interlace < 0)
+ overlay_yoffset++;
+ }
+
+ if (overlay_yoffset >= a2410_height || overlay_yoffset >= picasso_vidinfo.height)
+ return;
+
+
+ if (!fullrefresh && !a2410_modified[overlay_yoffset]) {
if (!picasso_is_vram_dirty(gfxmem_bank.start + (vramoffset << 1), a2410_displaywidth)) {
if (!picasso_is_vram_dirty(gfxmem_bank.start + ((vramoffset + 0x200) << 1), a2410_displaywidth)) {
return;
}
}
}
- if (overlay_yoffset >= 0)
- a2410_modified[overlay_yoffset] = false;
+
+ a2410_modified[overlay_yoffset] = false;
get_a2410_surface();
uae_u8 *dst = a2410_surface;
if (!dst)
return;
- dst += a2410_vpos * picasso_vidinfo.rowbytes;
+ dst += overlay_yoffset * picasso_vidinfo.rowbytes;
+ uae_u32 *dst32 = (uae_u32*)dst;
+
+ uae_u8 *overlay0 = program_ram + overlayoffset * OVERLAY_WIDTH / 8;
+ uae_u8 *overlay1 = overlay0 + 0x20000;
bool overlay0color = !(a2410_palette_control[6 - 4] & 0x40);
uae_u16 bitmap_mask = a2410_palette_control[4 - 4];
overlay_mask[0] = 0;
if (a2410_palette_control[6 - 4] & 8)
overlay_mask[1] = 0;
- uae_u16 blink_mask = a2410_palette_control[5 - 4];
- blink_mask |= blink_mask << 8;
- bitmap_mask &= ~blink_mask;
+ bitmap_mask &= ~a2410_palette_control[5 - 4];
}
int xx = 0;
uae_u8 opix0 = 0, opix1 = 0;
for (int x = parms.heblnk; x < parms.hsblnk && xx < picasso_vidinfo.width; x += 2, xx += 2) {
- uae_u16 pix;
- if (!overlay_bitcount && overlayoffset >= 0) {
- opix0 = overlay0[overlay_offset ^ 1] & a2410_overlay_mask[0];
- opix1 = overlay1[overlay_offset ^ 1] & a2410_overlay_mask[1];
- overlay_offset++;
- }
+ if (a2410_vpos >= parms.veblnk && a2410_vpos < parms.vsblnk) {
- if (overlay0color || opix0 || opix1) {
+ if (!overlay_bitcount && overlayoffset >= 0) {
+ opix0 = overlay0[overlay_offset ^ 1] & a2410_overlay_mask[0];
+ opix1 = overlay1[overlay_offset ^ 1] & a2410_overlay_mask[1];
+ overlay_offset++;
+ }
- int pal;
- uae_u8 ov;
+ uae_u16 pix = vram[coladdr & 0x1ff];
+ coladdr++;
- pix = vram[coladdr & 0x1ff];
+ if (overlay0color || opix0 || opix1) {
- pal = (pix >> 8) & bitmap_mask;
- ov = opix0 & 1;
- ov |= (opix1 & 1) << 1;
- if (ov || overlay0color)
- pal = 256 + ov;
- ((uae_u32*)dst)[0] = a2410_palette_32[pal];
- opix0 >>= 1;
- opix1 >>= 1;
+ int pal;
+ uae_u8 ov;
- pal = pix & bitmap_mask;
- ov = opix0 & 1;
- ov |= (opix1 & 1) << 1;
- if (ov || overlay0color)
- pal = 256 + ov;
- ((uae_u32*)dst)[1] = a2410_palette_32[pal];
- opix0 >>= 1;
- opix1 >>= 1;
+ pal = (pix >> 8) & bitmap_mask;
+ ov = opix0 & 1;
+ ov |= (opix1 & 1) << 1;
+ if (ov || overlay0color)
+ pal = 256 + ov;
+ *dst32++ = a2410_palette_32[pal];
+ opix0 >>= 1;
+ opix1 >>= 1;
- dst += 8;
- coladdr++;
+ pal = pix & bitmap_mask;
+ ov = opix0 & 1;
+ ov |= (opix1 & 1) << 1;
+ if (ov || overlay0color)
+ pal = 256 + ov;
+ *dst32++ = a2410_palette_32[pal];
+ opix0 >>= 1;
+ opix1 >>= 1;
- } else {
- pix = vram[coladdr & 0x1ff];
+ } else {
- ((uae_u32*)dst)[0] = a2410_palette_32[pix >> 8];
- ((uae_u32*)dst)[1] = a2410_palette_32[pix & 0xff];
+ *dst32++ = a2410_palette_32[pix >> 8];
+ *dst32++ = a2410_palette_32[pix & 0xff];
- dst += 8;
- coladdr++;
+ opix0 >>= 2;
+ opix1 >>= 2;
- opix0 >>= 2;
- opix1 >>= 2;
+ }
+ overlay_bitcount += 2;
+ overlay_bitcount &= 7;
}
-
- overlay_bitcount += 2;
- overlay_bitcount &= 7;
}
+
while (xx < picasso_vidinfo.width) {
- ((uae_u32*)dst)[0] = 0;
- dst += 4;
+ *dst32++ = 0;
xx++;
}
}
-void standard_irq_callback(int v)
+void standard_irq_callback(int level)
{
- INTREQ_0(0x8000 | 0x0008);
+ a2410_interrupt = level;
+ a2410_rethink();
}