diff --git a/src/mess/drivers/mac.c b/src/mess/drivers/mac.c index 0226274d105..2090339e4de 100644 --- a/src/mess/drivers/mac.c +++ b/src/mess/drivers/mac.c @@ -33,7 +33,13 @@ SCC: PB_EXT from mouse Y circuitry PA_EXT from mouse X circuitry - + + NOTES: + - pmac6100: with recent PPC fixes now gets into the 68000 emulator and executes part of the 680x0 startup code. + 'g 6802c73c' to get to the interesting part (wait past the boot chime). PPC register r24 is the 68000 PC. + when the PC hits GetCPUID, the move.l (a2), d0 at PC = 0x10000 will cause an MMU fault (jump to 0xFFF00300). why? + a2 = 0x5ffffffc (the CPU ID register). MMU is unable to resolve this; defect in the MMU emulation probable. + ****************************************************************************/ @@ -182,7 +188,7 @@ READ8_MEMBER( mac_state::mac_sonora_vctl_r ) if (offset == 2) { // printf("Sonora: read monitor ID at PC=%x\n", m_maincpu->pc()); - return (6 << 4); // 640x480 RGB monitor + return (space.machine().root_device().ioport("MONTYPE")->read_safe(6)<<4); } return m_sonora_vctl[offset]; @@ -1120,7 +1126,8 @@ static MACHINE_CONFIG_DERIVED( maclc, macii ) MCFG_SCREEN_RAW_PARAMS(25175000, 800, 0, 640, 525, 0, 480) MCFG_SCREEN_SIZE(1024,768) MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) - MCFG_SCREEN_UPDATE_DRIVER(mac_state, screen_update_macrbvvram) + MCFG_SCREEN_UPDATE_DRIVER(mac_state, screen_update_macv8) + MCFG_DEFAULT_LAYOUT(layout_mac) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("2M") @@ -1156,7 +1163,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( maccclas, maclc2 ) MCFG_EGRET_REMOVE() - MCFG_CUDA_ADD(CUDA_341S0788, mac_cuda_interface) // should be 341s0417, but only the color classic used that rev and those are "collectable" ($$$$) + MCFG_CUDA_ADD(CUDA_341S0788, mac_cuda_interface) // should be 0417, but that version won't sync up properly with the '030 right now MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( maclc3, maclc ) @@ -1169,11 +1176,11 @@ static MACHINE_CONFIG_DERIVED( maclc3, maclc ) MCFG_VIDEO_RESET_OVERRIDE(mac_state,macsonora) MCFG_SCREEN_MODIFY(MAC_SCREEN_NAME) - MCFG_SCREEN_UPDATE_DRIVER(mac_state, screen_update_macrbvvram) + MCFG_SCREEN_UPDATE_DRIVER(mac_state, screen_update_macsonora) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4M") - MCFG_RAM_EXTRA_OPTIONS("8M,12M,16M,20M,24M,28M,32M,36M") + MCFG_RAM_EXTRA_OPTIONS("8M,16M,32M,48M,64M,80M") MCFG_ASC_REPLACE("asc", C15M, ASC_TYPE_SONORA, mac_asc_irq) MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) @@ -1458,9 +1465,9 @@ static MACHINE_CONFIG_DERIVED( macpd210, macpb160 ) MACHINE_CONFIG_END #endif static MACHINE_CONFIG_DERIVED( macclas2, maclc ) - MCFG_CPU_REPLACE("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(maclc_map) + MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) MCFG_VIDEO_START_OVERRIDE(mac_state,macv8) MCFG_VIDEO_RESET_OVERRIDE(mac_state,maceagle) @@ -1534,6 +1541,7 @@ static MACHINE_CONFIG_DERIVED( maciisi, macii ) MCFG_SCREEN_SIZE(640, 870) MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) MCFG_SCREEN_UPDATE_DRIVER(mac_state, screen_update_macrbv) + MCFG_DEFAULT_LAYOUT(layout_mac) /* internal ram */ MCFG_RAM_MODIFY(RAM_TAG) @@ -2139,14 +2147,14 @@ COMP( 1989, maciicx, mac2fdhd, 0, maciicx, macadb, mac_state, maciicx, "Ap COMP( 1989, maciici, 0, 0, maciici, maciici, mac_state, maciici, "Apple Computer", "Macintosh IIci", 0 ) COMP( 1990, maciifx, 0, 0, maciifx, macadb, mac_state, maciifx, "Apple Computer", "Macintosh IIfx", GAME_NOT_WORKING ) COMP( 1990, macclasc, 0, 0, macse, macadb, mac_state, macclassic, "Apple Computer", "Macintosh Classic", 0 ) -COMP( 1990, maclc, 0, 0, maclc, maciici, mac_state, maclc, "Apple Computer", "Macintosh LC", GAME_NOT_WORKING ) -COMP( 1990, maciisi, 0, 0, maciisi, maciici, mac_state, maciisi, "Apple Computer", "Macintosh IIsi", GAME_NOT_WORKING ) +COMP( 1990, maclc, 0, 0, maclc, maciici, mac_state, maclc, "Apple Computer", "Macintosh LC", GAME_IMPERFECT_SOUND ) +COMP( 1990, maciisi, 0, 0, maciisi, maciici, mac_state, maciisi, "Apple Computer", "Macintosh IIsi", 0 ) COMP( 1991, macpb100, 0, 0, macprtb, macadb, mac_state, macprtb, "Apple Computer", "Macintosh PowerBook 100", GAME_NOT_WORKING ) COMP( 1991, macpb140, 0, 0, macpb140, macadb, mac_state, macpb140, "Apple Computer", "Macintosh PowerBook 140", GAME_NOT_WORKING ) COMP( 1991, macpb170, macpb140, 0, macpb170, macadb, mac_state, macpb140, "Apple Computer", "Macintosh PowerBook 170", GAME_NOT_WORKING ) COMP( 1991, macqd700, macpb140, 0, macqd700, macadb, mac_state, macquadra700, "Apple Computer", "Macintosh Quadra 700", GAME_NOT_WORKING ) -COMP( 1991, macclas2, 0, 0, macclas2, macadb, mac_state, macclassic2, "Apple Computer", "Macintosh Classic II", GAME_NOT_WORKING ) -COMP( 1991, maclc2, 0, 0, maclc2, maciici, mac_state, maclc2, "Apple Computer", "Macintosh LC II", GAME_NOT_WORKING ) +COMP( 1991, macclas2, 0, 0, macclas2, macadb, mac_state, macclassic2, "Apple Computer", "Macintosh Classic II", GAME_IMPERFECT_SOUND ) +COMP( 1991, maclc2, 0, 0, maclc2, maciici, mac_state, maclc2, "Apple Computer", "Macintosh LC II", GAME_IMPERFECT_SOUND ) COMP( 1992, macpb145, macpb140, 0, macpb145, macadb, mac_state, macpb140, "Apple Computer", "Macintosh PowerBook 145", GAME_NOT_WORKING ) COMP( 1992, macpb160, 0, 0, macpb160, macadb, mac_state, macpb160, "Apple Computer", "Macintosh PowerBook 160", GAME_NOT_WORKING ) COMP( 1992, macpb180, macpb160, 0, macpb180, macadb, mac_state, macpb160, "Apple Computer", "Macintosh PowerBook 180", GAME_NOT_WORKING ) @@ -2154,8 +2162,8 @@ COMP( 1992, macpb180c,macpb160, 0, macpb180c,macadb, mac_state, macpb160, //COMP( 1992, macpd210, 0, 0, macpd210, macadb, mac_state, macpd210, "Apple Computer", "Macintosh PowerBook Duo 210", GAME_NOT_WORKING ) COMP( 1993, maccclas, 0, 0, maccclas, macadb, mac_state, maclrcclassic,"Apple Computer", "Macintosh Color Classic", GAME_NOT_WORKING ) COMP( 1992, macpb145b,macpb140, 0, macpb170, macadb, mac_state, macpb140, "Apple Computer", "Macintosh PowerBook 145B", GAME_NOT_WORKING ) -COMP( 1993, maclc3, 0, 0, maclc3, maciici, mac_state, maclc3, "Apple Computer", "Macintosh LC III", GAME_NOT_WORKING ) -COMP( 1993, maciivx, 0, 0, maciivx, maciici, mac_state, maciivx, "Apple Computer", "Macintosh IIvx", GAME_NOT_WORKING ) -COMP( 1993, maciivi, maciivx, 0, maciivi, maciici, mac_state, maciivx, "Apple Computer", "Macintosh IIvi", GAME_NOT_WORKING ) +COMP( 1993, maclc3, 0, 0, maclc3, maciici, mac_state, maclc3, "Apple Computer", "Macintosh LC III", GAME_IMPERFECT_SOUND ) +COMP( 1993, maciivx, 0, 0, maciivx, maciici, mac_state, maciivx, "Apple Computer", "Macintosh IIvx", GAME_IMPERFECT_SOUND ) +COMP( 1993, maciivi, maciivx, 0, maciivi, maciici, mac_state, maciivx, "Apple Computer", "Macintosh IIvi", GAME_IMPERFECT_SOUND ) COMP( 1993, maclc520, 0, 0, maclc520, maciici, mac_state, maclc520, "Apple Computer", "Macintosh LC 520", GAME_NOT_WORKING ) COMP( 1994, pmac6100, 0, 0, pwrmac, macadb, mac_state, macpm6100, "Apple Computer", "Power Macintosh 6100/60", GAME_NOT_WORKING | GAME_NO_SOUND ) diff --git a/src/mess/includes/mac.h b/src/mess/includes/mac.h index 175d83481aa..81a865bcaae 100644 --- a/src/mess/includes/mac.h +++ b/src/mess/includes/mac.h @@ -29,7 +29,9 @@ #define ADB_IS_BITBANG ((mac->m_model == MODEL_MAC_SE || mac->m_model == MODEL_MAC_CLASSIC) || (mac->m_model >= MODEL_MAC_II && mac->m_model <= MODEL_MAC_IICI) || (mac->m_model == MODEL_MAC_SE30) || (mac->m_model == MODEL_MAC_QUADRA_700)) #define ADB_IS_BITBANG_CLASS ((m_model == MODEL_MAC_SE || m_model == MODEL_MAC_CLASSIC) || (m_model >= MODEL_MAC_II && m_model <= MODEL_MAC_IICI) || (m_model == MODEL_MAC_SE30) || (m_model == MODEL_MAC_QUADRA_700)) #define ADB_IS_EGRET (m_model >= MODEL_MAC_LC && m_model <= MODEL_MAC_CLASSIC_II) || ((m_model >= MODEL_MAC_IISI) && (m_model <= MODEL_MAC_IIVI)) +#define ADB_IS_EGRET_NONCLASS (mac->m_model >= MODEL_MAC_LC && mac->m_model <= MODEL_MAC_CLASSIC_II) || ((mac->m_model >= MODEL_MAC_IISI) && (mac->m_model <= MODEL_MAC_IIVI)) #define ADB_IS_CUDA ((m_model >= MODEL_MAC_COLOR_CLASSIC && m_model <= MODEL_MAC_LC_580) || ((m_model >= MODEL_MAC_QUADRA_660AV) && (m_model <= MODEL_MAC_QUADRA_630)) || (m_model >= MODEL_MAC_POWERMAC_6100)) +#define ADB_IS_CUDA_NONCLASS ((mac->m_model >= MODEL_MAC_COLOR_CLASSIC && mac->m_model <= MODEL_MAC_LC_580) || ((mac->m_model >= MODEL_MAC_QUADRA_660AV) && (mac->m_model <= MODEL_MAC_QUADRA_630)) || (mac->m_model >= MODEL_MAC_POWERMAC_6100)) #define ADB_IS_PM_VIA1 (m_model >= MODEL_MAC_PORTABLE && m_model <= MODEL_MAC_PB100) #define ADB_IS_PM_VIA2 (m_model >= MODEL_MAC_PB140 && m_model <= MODEL_MAC_PBDUO_270c) #define ADB_IS_PM_VIA1_CLASS (m_model >= MODEL_MAC_PORTABLE && m_model <= MODEL_MAC_PB100) @@ -258,6 +260,8 @@ public: UINT32 m_se30_vbl_enable; UINT8 m_nubus_irq_state; + void adb_linechange(int state, int dtime); + /* used to store the reply to most keyboard commands */ int m_keyboard_reply; @@ -318,6 +322,8 @@ public: INT32 m_adb_state, m_adb_command, m_adb_send, m_adb_timer_ticks, m_adb_extclock, m_adb_direction; INT32 m_adb_listenreg, m_adb_listenaddr, m_adb_last_talk, m_adb_srq_switch; INT32 m_adb_streaming, m_adb_stream_ptr; + INT32 m_adb_linestate; + bool m_adb_srqflag; // Portable/PB100 Power Manager IC comms (chapter 4, "Guide to the Macintosh Family Hardware", second edition) UINT8 m_pm_data_send, m_pm_data_recv, m_pm_ack, m_pm_req, m_pm_cmd[32], m_pm_out[32], m_pm_dptr, m_pm_sptr, m_pm_slen, m_pm_state; @@ -364,6 +370,7 @@ public: void rbv_recalc_irqs(); void pmu_exec(); void mac_adb_newaction(int state); + void set_adb_line(int linestate); DECLARE_READ16_MEMBER ( mac_via_r ); DECLARE_WRITE16_MEMBER ( mac_via_w ); @@ -521,6 +528,8 @@ public: UINT32 screen_update_macrbv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); UINT32 screen_update_macdafb(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); UINT32 screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + UINT32 screen_update_macv8(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + UINT32 screen_update_macsonora(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); UINT32 screen_update_macpbwd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(mac_rbv_vbl); TIMER_CALLBACK_MEMBER(kbd_clock); diff --git a/src/mess/machine/cuda.c b/src/mess/machine/cuda.c index 1086a1b3a85..475a2f4479d 100644 --- a/src/mess/machine/cuda.c +++ b/src/mess/machine/cuda.c @@ -41,6 +41,7 @@ #include "cpu/m6805/m6805.h" #include "machine/6522via.h" #include "sound/asc.h" +#include "includes/mac.h" //************************************************************************** // MACROS / CONSTANTS @@ -122,14 +123,20 @@ void cuda_device::send_port(address_space &space, UINT8 offset, UINT8 data) { /* if (data & 0x80) { - printf("CU ADB: 1->0 time %lld\n", m_maincpu->total_cycles()-last_adb_time); + printf("CU ADB: 1->0 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); } else { - printf("CU ADB: 0->1 time %lld\n", m_maincpu->total_cycles()-last_adb_time); - } */ + printf("CU ADB: 0->1 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); + }*/ + + adb_in = (data & 0x80) ? true : false; + + mac_state *mac = machine().driver_data(); + mac->adb_linechange(((data & 0x80) >> 7) ^ 1, (int)(machine().time().as_ticks(1000000) - last_adb_time)); + last_adb = data & 0x80; - last_adb_time = m_maincpu->total_cycles(); + last_adb_time = machine().time().as_ticks(1000000); } break; @@ -207,8 +214,6 @@ READ8_MEMBER( cuda_device::ports_r ) switch (offset) { case 0: // port A -// incoming |= adb_in ? 0x40 : 0; - if (cuda_controls_power) { incoming = 0x20; // pull up + chassis switch (which is 0 = on) @@ -217,6 +222,11 @@ READ8_MEMBER( cuda_device::ports_r ) { incoming = 0x02 | 0x01; // pull-up + PFW } + + if (adb_in) + { + incoming |= 0x40; + } break; case 1: // port B diff --git a/src/mess/machine/cuda.h b/src/mess/machine/cuda.h index 04438e51771..b9f72258f1c 100644 --- a/src/mess/machine/cuda.h +++ b/src/mess/machine/cuda.h @@ -84,6 +84,7 @@ public: UINT8 get_via_data() { return via_data; } void set_via_data(UINT8 dat) { via_data = dat; } UINT8 get_via_clock() { return via_clock; } + void set_adb_line(int linestate) { adb_in = (linestate == ASSERT_LINE) ? true : false; } int rom_offset; diff --git a/src/mess/machine/egret.c b/src/mess/machine/egret.c index 8d8afe65ec8..429b4e7dc26 100644 --- a/src/mess/machine/egret.c +++ b/src/mess/machine/egret.c @@ -120,15 +120,21 @@ void egret_device::send_port(address_space &space, UINT8 offset, UINT8 data) { /* if (data & 0x80) { - printf("EG ADB: 1->0 time %lld\n", m_maincpu->total_cycles()-last_adb_time); + printf("EG ADB: 1->0 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); } else { - printf("EG ADB: 0->1 time %lld\n", m_maincpu->total_cycles()-last_adb_time); + printf("EG ADB: 0->1 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); }*/ - last_adb = data & 0x80; - last_adb_time = m_maincpu->total_cycles(); + + // allow the linechange handler to override us adb_in = (data & 0x80) ? true : false; + + mac_state *mac = machine().driver_data(); + mac->adb_linechange(((data & 0x80) >> 7) ^ 1, (int)(machine().time().as_ticks(1000000) - last_adb_time)); + + last_adb = data & 0x80; + last_adb_time = machine().time().as_ticks(1000000); } break; @@ -212,7 +218,7 @@ READ8_MEMBER( egret_device::ports_r ) switch (offset) { case 0: // port A - incoming |= adb_in ? 0x40 : 0; + incoming |= adb_in ? 0x40 : 0; if (egret_controls_power) { diff --git a/src/mess/machine/egret.h b/src/mess/machine/egret.h index 0d5581e32db..afaad798c40 100644 --- a/src/mess/machine/egret.h +++ b/src/mess/machine/egret.h @@ -77,6 +77,7 @@ public: UINT8 get_via_data() { return via_data; } void set_via_data(UINT8 dat) { via_data = dat; } UINT8 get_via_clock() { return via_clock; } + void set_adb_line(int linestate) { adb_in = (linestate == ASSERT_LINE) ? true : false; } int rom_offset; diff --git a/src/mess/machine/mac.c b/src/mess/machine/mac.c index daa8fb2e21b..75c3354bcf2 100644 --- a/src/mess/machine/mac.c +++ b/src/mess/machine/mac.c @@ -1886,7 +1886,7 @@ void mac_state::machine_reset() } m_scsi_interrupt = 0; - if (machine().device("maincpu")->debug()) + if ((machine().device("maincpu")->debug()) && (m_model < MODEL_MAC_POWERMAC_6100)) { machine().device("maincpu")->debug()->set_dasm_override(mac_dasm_override); } diff --git a/src/mess/machine/macadb.c b/src/mess/machine/macadb.c index fc29b71384e..b5e72dd86ba 100644 --- a/src/mess/machine/macadb.c +++ b/src/mess/machine/macadb.c @@ -1,7 +1,7 @@ /*************************************************************************** macadb.c - handles various aspects of ADB on the Mac. - + ***************************************************************************/ #include "emu.h" @@ -22,8 +22,51 @@ #define ADB_CMD_RESET (0) #define ADB_CMD_FLUSH (1) +// ADB line states +enum +{ + // receive states + LST_IDLE = 0, + LST_ATTENTION, + LST_BIT0, + LST_BIT1, + LST_BIT2, + LST_BIT3, + LST_BIT4, + LST_BIT5, + LST_BIT6, + LST_BIT7, + LST_TSTOP, + LST_WAITT1T, + LST_RCVSTARTBIT, + LST_SRQNODATA, + + // send states + LST_TSTOPSTART, + LST_TSTOPSTARTa, + LST_STARTBIT, + LST_SENDBIT0, + LST_SENDBIT0a, + LST_SENDBIT1, + LST_SENDBIT1a, + LST_SENDBIT2, + LST_SENDBIT2a, + LST_SENDBIT3, + LST_SENDBIT3a, + LST_SENDBIT4, + LST_SENDBIT4a, + LST_SENDBIT5, + LST_SENDBIT5a, + LST_SENDBIT6, + LST_SENDBIT6a, + LST_SENDBIT7, + LST_SENDBIT7a, + LST_SENDSTOP, + LST_SENDSTOPa +}; + /* ************************************************************************* - * ADB (Mac II-style) + * High-level ADB primitives used by all lower-level implementations * *************************************************************************/ #if LOG_ADB @@ -264,19 +307,34 @@ void mac_state::adb_talk() break; case 2: // listen - #if LOG_ADB || LOG_ADB_TALK_LISTEN - printf("ADB LISTEN: reg %x address %x\n", reg, addr); - #endif - - m_adb_direction = 1; // input from Mac - m_adb_listenreg = reg; - m_adb_listenaddr = addr; - m_adb_command = 0; + m_adb_datasize = 0; + if ((addr == m_adb_keybaddr) || (addr == m_adb_mouseaddr)) + { + #if LOG_ADB || LOG_ADB_TALK_LISTEN + printf("ADB LISTEN: reg %x address %x\n", reg, addr); + #endif + m_adb_direction = 1; // input from Mac + m_adb_command = 0; + m_adb_listenreg = reg; + m_adb_listenaddr = addr; + if ((ADB_IS_EGRET) || (ADB_IS_CUDA)) + { + m_adb_stream_ptr = 0; + memset(m_adb_buffer, 0, sizeof(m_adb_buffer)); + } + } + else + { + #if LOG_ADB || LOG_ADB_TALK_LISTEN + printf("ADB LISTEN to unknown device, timing out\n"); + #endif + m_adb_direction = 0; + } break; case 3: // talk #if LOG_ADB || LOG_ADB_TALK_LISTEN - printf("ADB TALK: reg %x address %x\n", reg, addr); + printf("ADB TALK: reg %x address %x (K %x M %x)\n", reg, addr, m_adb_keybaddr, m_adb_mouseaddr); #endif // keep track of what device the Mac last TALKed to @@ -312,7 +370,7 @@ void mac_state::adb_talk() // get ID/handler case 3: - m_adb_buffer[0] = 0x60 | ((m_adb_mouseaddr<<8)&0xf); // SRQ enable, no exceptional event + m_adb_buffer[0] = 0x60 | (m_adb_mouseaddr&0xf); // SRQ enable, no exceptional event m_adb_buffer[1] = 0x01; // handler 1 m_adb_datasize = 2; @@ -322,6 +380,11 @@ void mac_state::adb_talk() default: break; } + + if (adb_pollkbd(0)) + { + m_adb_srqflag = true; + } } else if (addr == m_adb_keybaddr) { @@ -341,23 +404,34 @@ void mac_state::adb_talk() { this->adb_pollkbd(1); } -// printf("keyboard = %02x %02x\n", m_adb_currentkeys[0], m_adb_currentkeys[1]); + +/* if (m_adb_currentkeys[0] != 0xff) + { + printf("Keys[0] = %02x\n", m_adb_currentkeys[0]); + } + if (m_adb_currentkeys[1] != 0xff) + { + printf("Keys[1] = %02x\n", m_adb_currentkeys[1]); + }*/ + m_adb_buffer[0] = m_adb_currentkeys[1]; m_adb_buffer[1] = m_adb_currentkeys[0]; m_adb_datasize = 2; break; // read modifier keys - case 2: - this->adb_pollkbd(1); - m_adb_buffer[0] = m_adb_modifiers; // nothing pressed - m_adb_buffer[1] = 0; - m_adb_datasize = 2; + case 2: + { + this->adb_pollkbd(1); + m_adb_buffer[0] = m_adb_modifiers; + m_adb_buffer[1] = 0xff; + m_adb_datasize = 2; + } break; // get ID/handler case 3: - m_adb_buffer[0] = 0x60 | ((m_adb_keybaddr<<8)&0xf); // SRQ enable, no exceptional event + m_adb_buffer[0] = 0x60 | (m_adb_keybaddr&0xf); // SRQ enable, no exceptional event m_adb_buffer[1] = 0x01; // handler 1 m_adb_datasize = 2; @@ -367,6 +441,11 @@ void mac_state::adb_talk() default: break; } + + if (adb_pollmouse()) + { + m_adb_srqflag = true; + } } else { @@ -375,6 +454,11 @@ void mac_state::adb_talk() #endif m_adb_buffer[0] = m_adb_buffer[1] = 0; m_adb_datasize = 0; + + if ((adb_pollkbd(0)) || (adb_pollmouse())) + { + m_adb_srqflag = true; + } } break; } @@ -384,9 +468,11 @@ void mac_state::adb_talk() else { #if LOG_ADB || LOG_ADB_TALK_LISTEN - printf("Got LISTEN data %x for device %x reg %x\n", m_adb_command, m_adb_listenaddr, m_adb_listenreg); + printf("Got LISTEN data %02x %02x for device %x reg %x\n", m_adb_command, m_adb_buffer[1], m_adb_listenaddr, m_adb_listenreg); #endif + m_adb_direction = 0; + if (m_adb_listenaddr == m_adb_mouseaddr) { if ((m_adb_listenreg == 3) && (m_adb_command > 0) && (m_adb_command < 16)) @@ -414,26 +500,135 @@ TIMER_CALLBACK(mac_adb_tick) { mac_state *mac = machine.driver_data(); - // do one clock transition on CB1 to advance the VIA shifter - mac->m_adb_extclock ^= 1; - mac->m_via1->write_cb1(mac->m_adb_extclock); - mac->m_adb_extclock ^= 1; - mac->m_via1->write_cb1(mac->m_adb_extclock); + if ((ADB_IS_EGRET_NONCLASS) || (ADB_IS_CUDA_NONCLASS)) + { + switch (mac->m_adb_linestate) + { + case LST_SRQNODATA: + mac->set_adb_line(ASSERT_LINE); + mac->m_adb_linestate = LST_IDLE; + break; - mac->m_adb_timer_ticks--; - if (!mac->m_adb_timer_ticks) - { - mac->m_adb_timer->adjust(attotime::never); + case LST_TSTOPSTART: + mac->set_adb_line(ASSERT_LINE); + mac->m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + mac->m_adb_linestate++; + break; - if ((mac->m_adb_direction) && (ADB_IS_BITBANG)) - { - mac->adb_talk(); - } - } - else - { - mac->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); - } + case LST_TSTOPSTARTa: + mac->set_adb_line(CLEAR_LINE); + mac->m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + mac->m_adb_linestate++; + break; + + case LST_STARTBIT: + mac->set_adb_line(ASSERT_LINE); + mac->m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + mac->m_adb_linestate++; + break; + + case LST_SENDBIT0: + case LST_SENDBIT1: + case LST_SENDBIT2: + case LST_SENDBIT3: + case LST_SENDBIT4: + case LST_SENDBIT5: + case LST_SENDBIT6: + case LST_SENDBIT7: + mac->set_adb_line(CLEAR_LINE); + if (mac->m_adb_buffer[mac->m_adb_stream_ptr] & 0x80) + { +// printf("1 "); + mac->m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + } + else + { +// printf("0 "); + mac->m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + } + mac->m_adb_linestate++; + break; + + case LST_SENDBIT0a: + case LST_SENDBIT1a: + case LST_SENDBIT2a: + case LST_SENDBIT3a: + case LST_SENDBIT4a: + case LST_SENDBIT5a: + case LST_SENDBIT6a: + mac->set_adb_line(ASSERT_LINE); + if (mac->m_adb_buffer[mac->m_adb_stream_ptr] & 0x80) + { + mac->m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + } + else + { + mac->m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + } + mac->m_adb_buffer[mac->m_adb_stream_ptr] <<= 1; + mac->m_adb_linestate++; + break; + + case LST_SENDBIT7a: + mac->set_adb_line(ASSERT_LINE); + if (mac->m_adb_buffer[mac->m_adb_stream_ptr] & 0x80) + { +// printf(" "); + mac->m_adb_timer->adjust(attotime::from_ticks(105, 1000000)); + } + else + { +// printf(" "); + mac->m_adb_timer->adjust(attotime::from_ticks(57, 1000000)); + } + + mac->m_adb_stream_ptr++; + if (mac->m_adb_stream_ptr == mac->m_adb_datasize) + { + mac->m_adb_linestate++; + } + else + { + mac->m_adb_linestate = LST_SENDBIT0; + } + break; + + case LST_SENDSTOP: + mac->set_adb_line(CLEAR_LINE); + mac->m_adb_timer->adjust(attotime::from_ticks((57*2), 1000000)); + mac->m_adb_linestate++; + break; + + case LST_SENDSTOPa: + mac->set_adb_line(ASSERT_LINE); + mac->m_adb_timer->adjust(attotime::never); + mac->m_adb_linestate = LST_IDLE; + break; + } + } + else + { + // do one clock transition on CB1 to advance the VIA shifter + mac->m_adb_extclock ^= 1; + mac->m_via1->write_cb1(mac->m_adb_extclock); + mac->m_adb_extclock ^= 1; + mac->m_via1->write_cb1(mac->m_adb_extclock); + + mac->m_adb_timer_ticks--; + if (!mac->m_adb_timer_ticks) + { + mac->m_adb_timer->adjust(attotime::never); + + if ((mac->m_adb_direction) && (ADB_IS_BITBANG)) + { + mac->adb_talk(); + } + } + else + { + mac->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); + } + } } void mac_state::mac_adb_newaction(int state) @@ -960,6 +1155,7 @@ void mac_state::adb_reset() m_adb_waiting_cmd = 0; m_adb_streaming = MCU_STREAMING_NONE; m_adb_state = 0; + m_adb_srqflag = false; m_pmu_poll = 0; if (ADB_IS_BITBANG_CLASS) { @@ -969,6 +1165,8 @@ void mac_state::adb_reset() m_adb_datasize = 0; m_adb_last_talk = -1; + m_adb_linestate = 0; + // mouse m_adb_mouseaddr = 3; m_adb_lastmousex = m_adb_lastmousey = m_adb_lastbutton = 0; @@ -978,10 +1176,198 @@ void mac_state::adb_reset() m_adb_keybaddr = 2; m_adb_keybinitialized = 0; m_adb_currentkeys[0] = m_adb_currentkeys[1] = 0xff; - m_adb_modifiers = 0; + m_adb_modifiers = 0xff; for (i=0; i<7; i++) { m_key_matrix[i] = 0; } } +void mac_state::adb_linechange(int state, int dtime) +{ +/* static const char *states[] = + { + "idle", + "attention", + "bit0", + "bit1", + "bit2", + "bit3", + "bit4", + "bit5", + "bit6", + "bit7", + "tstop", + "waitt1t", + "rcvstartbit", + "srqnodata" + };*/ + +/* if (m_adb_linestate <= 12) + { + printf("linechange: %d -> %d, time %d (state %d = %s)\n", state^1, state, dtime, m_adb_linestate, states[m_adb_linestate]); + } + else + { + printf("linechange: %d -> %d, time %d (state %d)\n", state^1, state, dtime, m_adb_linestate); + }*/ + + if ((m_adb_direction) && (m_adb_linestate == LST_TSTOP)) + { + if (m_adb_stream_ptr & 1) // odd byte, can't end here + { +// printf("critical linechange: odd, cont\n"); + m_adb_linestate = LST_BIT0; + } + else + { + if (dtime < 90) + { +// printf("critical linechange: even, and it's another bit\n"); + m_adb_linestate = LST_BIT0; + } + } + } + + switch (m_adb_linestate) + { + case LST_IDLE: + if ((state) && (dtime >= 4500)) // reset + { +// printf("ADB RESET\n"); + } + else if ((state) && (dtime >= 1200)) // attention + { +// printf("ADB ATTENTION\n"); + m_adb_waiting_cmd = 1; + m_adb_direction = 0; + m_adb_linestate++; + } + break; + + case LST_ATTENTION: + if ((!state) && (dtime >= 90)) // Tsync + { +// printf("ADB Tsync\n"); + m_adb_command = 0; + m_adb_linestate++; + } + break; + + case LST_BIT0: + case LST_BIT1: + case LST_BIT2: + case LST_BIT3: + case LST_BIT4: + case LST_BIT5: + case LST_BIT6: + case LST_BIT7: + if (!state) + { + if (dtime >= 90) // "1" bit + { + m_adb_command |= 1; + } +// printf("ADB bit %d\n", m_adb_command & 1); + + if (m_adb_linestate != LST_BIT7) + { + m_adb_command <<= 1; + } + else + { + if (m_adb_direction) + { +// printf("listen byte[%d] = %02x\n", m_adb_stream_ptr, m_adb_command); + m_adb_buffer[m_adb_stream_ptr++] = m_adb_command; + m_adb_command = 0; + } + } + + m_adb_linestate++; + } + break; + + case LST_TSTOP: + if (state) + { +// printf("ADB TSTOP, command byte %02x\n", m_adb_command); + + if (m_adb_direction) + { + m_adb_command = m_adb_buffer[0]; + } + + m_adb_srqflag = false; + adb_talk(); + + if (!m_adb_srqflag) + { + set_adb_line(ASSERT_LINE); + } + else + { + set_adb_line(CLEAR_LINE); + } + + if (m_adb_datasize > 0) + { +/* printf("Device has %d bytes of data: ", m_adb_datasize); + for (int i = 0; i < m_adb_datasize; i++) + { + printf("%02x ", m_adb_buffer[i]); + }*/ + m_adb_linestate = LST_TSTOPSTART; // T1t + m_adb_timer->adjust(attotime::from_ticks(324/4, 1000000)); + m_adb_stream_ptr = 0; + } + else if (m_adb_direction) // if direction is set, we LISTENed to a valid device + { + m_adb_linestate = LST_WAITT1T; + } + else // no valid device targetted, time out + { + if (m_adb_srqflag) + { + m_adb_linestate = LST_SRQNODATA; + m_adb_timer->adjust(attotime::from_ticks(486, 1000000)); // SRQ time + } + else + { + m_adb_linestate = LST_IDLE; + } + } + } + break; + + case LST_WAITT1T: + if ((!state) && (dtime >= 300)) // T1t + { +// printf("ADB T1t\n"); + m_adb_linestate++; + } + break; + + case LST_RCVSTARTBIT: + if ((!state) && (dtime >= 90)) // start + { +// printf("ADB start\n"); + m_adb_linestate = LST_BIT0; + m_adb_command = 0; + } + break; + } +} + +void mac_state::set_adb_line(int linestate) +{ + if (ADB_IS_EGRET) + { + m_egret->set_adb_line(linestate); + } + else if (ADB_IS_CUDA) + { + m_cuda->set_adb_line(linestate); + } +} + diff --git a/src/mess/video/mac.c b/src/mess/video/mac.c index 0a85303f8b6..0d416f4e547 100644 --- a/src/mess/video/mac.c +++ b/src/mess/video/mac.c @@ -9,7 +9,7 @@ Classic) Also emulates on-board video for systems with the - RBV, V8, Sonora, and DAFB chips. + RBV, V8, Eagle, Sonora, and DAFB chips. ---------------------------------------------------------------------- Monitor sense codes @@ -197,8 +197,6 @@ UINT32 mac_state::screen_update_macpb160(screen_device &screen, bitmap_ind16 &bi { pixels = vram8[(y * 160) + (BYTE4_XOR_BE(x))]; -// *line++ = (pixels>>4)&0xf; -// *line++ = pixels&0xf; *line++ = ((pixels>>6)&3); *line++ = ((pixels>>4)&3); *line++ = ((pixels>>2)&3); @@ -273,7 +271,7 @@ VIDEO_RESET_MEMBER(mac_state,macrbv) break; } -// printf("RBV reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate); +// printf("RBV reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate); machine().primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS(framerate)); render_target *target = machine().render().first_target(); target->set_view(view); @@ -284,6 +282,7 @@ VIDEO_RESET_MEMBER(mac_state,macsonora) rectangle visarea; int htotal, vtotal; double framerate; + int view = 0; memset(m_rbv_regs, 0, sizeof(m_rbv_regs)); @@ -308,6 +307,7 @@ VIDEO_RESET_MEMBER(mac_state,macsonora) htotal = 832; vtotal = 918; framerate = 75.0; + view = 1; break; case 2: // 12" RGB @@ -328,8 +328,10 @@ VIDEO_RESET_MEMBER(mac_state,macsonora) break; } -// printf("RBV reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate); +// printf("Sonora reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate); machine().primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS(framerate)); + render_target *target = machine().render().first_target(); + target->set_view(view); } VIDEO_START_MEMBER(mac_state,macsonora) @@ -488,74 +490,51 @@ UINT32 mac_state::screen_update_macrbv(screen_device &screen, bitmap_rgb32 &bitm UINT32 mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { UINT32 *scanline; - int x, y; - UINT8 mode = 0; + int x, y, hres, vres; - switch (m_rbv_type) + switch (m_rbv_montype) { - case RBV_TYPE_RBV: - case RBV_TYPE_V8: - mode = m_rbv_regs[0x10] & 7; + case 1: // 15" portrait display + hres = 640; + vres = 870; break; - case RBV_TYPE_SONORA: - mode = m_sonora_vctl[1] & 7; + case 2: // 12" RGB + hres = 512; + vres = 384; + break; - // forced blank? - if (m_sonora_vctl[0] & 0x80) - { - return 0; - } + case 6: // 13" RGB + default: + hres = 640; + vres = 480; break; } - switch (mode) + switch (m_rbv_regs[0x10] & 7) { case 0: // 1bpp { UINT8 *vram8 = (UINT8 *)m_vram.target(); UINT8 pixels; - if (m_rbv_type == RBV_TYPE_SONORA) - { - for (y = 0; y < 480; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < 640; x+=8) - { - pixels = vram8[(y * 80) + ((x/8)^3)]; + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < hres; x+=8) + { + pixels = vram8[(y * 0x400) + ((x/8)^3)]; - *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; - } - } - } - else - { - for (y = 0; y < 480; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < 640; x+=8) - { - pixels = vram8[(y * 0x400) + ((x/8)^3)]; - - *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; - } - } - } + *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; + } + } } break; @@ -564,12 +543,12 @@ UINT32 mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 & UINT8 *vram8 = (UINT8 *)m_vram.target(); UINT8 pixels; - for (y = 0; y < 480; y++) + for (y = 0; y < vres; y++) { scanline = &bitmap.pix32(y); - for (x = 0; x < 640/4; x++) + for (x = 0; x < hres/4; x++) { - pixels = vram8[(y * 160) + (BYTE4_XOR_BE(x))]; + pixels = vram8[(y * (hres/4)) + (BYTE4_XOR_BE(x))]; *scanline++ = m_rbv_palette[0xfc|((pixels>>6)&3)]; *scanline++ = m_rbv_palette[0xfc|((pixels>>4)&3)]; @@ -585,13 +564,13 @@ UINT32 mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 & UINT8 *vram8 = (UINT8 *)m_vram.target(); UINT8 pixels; - for (y = 0; y < 480; y++) + for (y = 0; y < vres; y++) { scanline = &bitmap.pix32(y); - for (x = 0; x < 640/2; x++) + for (x = 0; x < hres/2; x++) { - pixels = vram8[(y * 320) + (BYTE4_XOR_BE(x))]; + pixels = vram8[(y * (hres/2)) + (BYTE4_XOR_BE(x))]; *scanline++ = m_rbv_palette[0xf0|(pixels>>4)]; *scanline++ = m_rbv_palette[0xf0|(pixels&0xf)]; @@ -605,33 +584,269 @@ UINT32 mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 & UINT8 *vram8 = (UINT8 *)m_vram.target(); UINT8 pixels; - if (m_rbv_type == RBV_TYPE_SONORA) - { - for (y = 0; y < 480; y++) - { - scanline = &bitmap.pix32(y); + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); - for (x = 0; x < 640; x++) - { - pixels = vram8[(y * 0x280) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - } - else - { - for (y = 0; y < 480; y++) - { - scanline = &bitmap.pix32(y); + for (x = 0; x < hres; x++) + { + pixels = vram8[(y * 2048) + (BYTE4_XOR_BE(x))]; + *scanline++ = m_rbv_palette[pixels]; + } + } + } + } - for (x = 0; x < 640; x++) - { - pixels = vram8[(y * 2048) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } + return 0; +} + +UINT32 mac_state::screen_update_macv8(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + UINT32 *scanline; + int x, y, hres, vres; + + switch (m_rbv_montype) + { + case 1: // 15" portrait display + hres = 640; + vres = 870; + break; + + case 2: // 12" RGB + hres = 512; + vres = 384; + break; + + case 6: // 13" RGB + default: + hres = 640; + vres = 480; + break; + } + + switch (m_rbv_regs[0x10] & 7) + { + case 0: // 1bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < hres; x+=8) + { + pixels = vram8[(y * 1024) + ((x/8)^3)]; + + *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; + } + } + } + break; + + case 1: // 2bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < hres/4; x++) + { + pixels = vram8[(y * 1024) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_rbv_palette[0x3f|(pixels&0xc0)]; + *scanline++ = m_rbv_palette[0x3f|((pixels<<2)&0xc0)]; + *scanline++ = m_rbv_palette[0x3f|((pixels<<4)&0xc0)]; + *scanline++ = m_rbv_palette[0x3f|((pixels<<6)&0xc0)]; } } } + break; + + case 2: // 4bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < hres/2; x++) + { + pixels = vram8[(y * 1024) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_rbv_palette[(pixels&0xf0) | 0xf]; + *scanline++ = m_rbv_palette[((pixels&0x0f)<<4) | 0xf]; + } + } + } + break; + + case 3: // 8bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < hres; x++) + { + pixels = vram8[(y * 1024) + (BYTE4_XOR_BE(x))]; + *scanline++ = m_rbv_palette[pixels]; + } + } + } + break; + } + + return 0; +} + +UINT32 mac_state::screen_update_macsonora(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + UINT32 *scanline; + int x, y, hres, vres, stride; + + switch (m_rbv_montype) + { + case 1: // 15" portrait display + stride = hres = 640; + vres = 870; + break; + + case 2: // 12" RGB + stride = hres = 512; + vres = 384; + break; + + case 6: // 13" RGB + default: + stride = hres = 640; + vres = 480; + break; + } + + // forced blank? + if (m_sonora_vctl[0] & 0x80) + { + return 0; + } + + switch (m_sonora_vctl[1] & 7) + { + case 0: // 1bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < hres; x+=8) + { + pixels = vram8[(y * (stride/8)) + ((x/8)^3)]; + + *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; + *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; + } + } + } + break; + + case 1: // 2bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < hres/4; x++) + { + pixels = vram8[(y * (stride/4)) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_rbv_palette[0x3f|(pixels&0xc0)]; + *scanline++ = m_rbv_palette[0x3f|((pixels<<2)&0xc0)]; + *scanline++ = m_rbv_palette[0x3f|((pixels<<4)&0xc0)]; + *scanline++ = m_rbv_palette[0x3f|((pixels<<6)&0xc0)]; + } + } + } + break; + + case 2: // 4bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < hres/2; x++) + { + pixels = vram8[(y * (stride/2)) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_rbv_palette[(pixels&0xf0) | 0xf]; + *scanline++ = m_rbv_palette[((pixels&0x0f)<<4) | 0xf]; + } + } + } + break; + + case 3: // 8bpp + { + UINT8 *vram8 = (UINT8 *)m_vram.target(); + UINT8 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < hres; x++) + { + pixels = vram8[(y * stride) + (BYTE4_XOR_BE(x))]; + *scanline++ = m_rbv_palette[pixels]; + } + } + } + break; + + case 4: // 16bpp + { + UINT16 *vram16 = (UINT16 *)m_vram.target(); + UINT16 pixels; + + for (y = 0; y < vres; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < hres; x++) + { + pixels = vram16[(y * stride) + (x^1)]; + *scanline++ = MAKE_RGB(((pixels>>10) & 0x1f)<<3, ((pixels>>5) & 0x1f)<<3, (pixels & 0x1f)<<3); + } + } + } + break; } return 0;