Skip to content

Commit

Permalink
apple/macadb.cpp: Updates [R. Belmont]
Browse files Browse the repository at this point in the history
- Added ADB power key callback
- Added "any key down" callback used in PowerBooks
- Removed the last bits of the old adb_vblank() service routine.

apple/pseudovia.cpp: Added support for SCSI IRQs. [R. Belmont]

apple/macprtb.cpp: Support sleep and wake-up for Macintosh Portable and PowerBook 100. [R. Belmont]

apple/macpwrbk030.cpp: Updates [R. Belmont]
- Fixed issues with Shut Down and Restart functionality
- Support sleep and wake-up for all supported models
- Cleanups and save state support

Systems promoted to working
---------------------------
Macintosh PowerBook 140 [R. Belmont]
Macintosh PowerBook 160 [R. Belmont]
Macintosh PowerBook 180c [R. Belmont]

Clones promoted to working
--------------------------
Macintosh PowerBook 145 [R. Belmont]
Macintosh PowerBook 145B [R. Belmont]
Macintosh PowerBook 165	[R. Belmont]
Macintosh PowerBook 165c [R. Belmont]
Macintosh PowerBook 170	[R. Belmont]
Macintosh PowerBook 180	[R. Belmont]
  • Loading branch information
rb6502 committed Dec 2, 2024
1 parent 21488f0 commit b6792dd
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 86 deletions.
14 changes: 0 additions & 14 deletions src/mame/apple/mac128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class mac128_state : public driver_device
void scc_mouse_irq( int x, int y );
void set_via_interrupt(int value);
void field_interrupts();
void vblank_irq();
void mouse_callback();

uint16_t ram_r(offs_t offset);
Expand Down Expand Up @@ -415,14 +414,6 @@ void mac128_state::set_via_interrupt(int value)
field_interrupts();
}

void mac128_state::vblank_irq()
{
if (m_macadb)
{
m_macadb->adb_vblank();
}
}

void mac128_state::update_volume()
{
/* LS161 audio PWM counters TC (SND) -> LS04 inverter (/SND) ->
Expand Down Expand Up @@ -461,11 +452,6 @@ TIMER_CALLBACK_MEMBER(mac128_state::mac_scanline)
{
const int scanline = param;

if (scanline == 0)
{
vblank_irq();
}

/* video beam in display (! VBLANK && ! HBLANK basically) */
if (scanline >= 28)
{
Expand Down
17 changes: 17 additions & 0 deletions src/mame/apple/macadb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define LOG_STATE (1U << 2)
#define LOG_LINESTATE (1U << 3)
#define VERBOSE (0)
#define LOG_OUTPUT_FUNC osd_printf_info

#include "logmacro.h"

Expand Down Expand Up @@ -238,6 +239,8 @@ macadb_device::macadb_device(const machine_config &mconfig, const char *tag, dev
m_keys(*this, "KEY%u", 0),
write_adb_data(*this),
write_adb_irq(*this),
write_adb_power(*this),
write_adb_akd(*this),
m_waiting_cmd(false),
m_datasize(0),
m_command(0),
Expand Down Expand Up @@ -313,6 +316,7 @@ static char const *const adb_statenames[4] = { "NEW", "EVEN", "ODD", "IDLE" };
bool macadb_device::adb_pollkbd(int update)
{
int report, codes[2];
int akd = 0;
bool result;

codes[0] = codes[1] = 0xff; // key up
Expand Down Expand Up @@ -344,6 +348,10 @@ bool macadb_device::adb_pollkbd(int update)
{
codes[report] |= 0x80;
}
else
{
akd = 1;
}

// update modifier state
if (update)
Expand Down Expand Up @@ -426,10 +434,12 @@ bool macadb_device::adb_pollkbd(int update)
if (codes[0] == 0x5d)
{
codes[0] = codes[1] = 0x7f;
write_adb_power(ASSERT_LINE);
}
else if (codes[0] == 0xdd)
{
codes[0] = codes[1] = 0xff;
write_adb_power(CLEAR_LINE);
}

// figure out if there was a change
Expand All @@ -453,9 +463,16 @@ bool macadb_device::adb_pollkbd(int update)
}
}

write_adb_akd(akd);

return result;
}

void macadb_device::portable_update_keyboard()
{
adb_pollkbd(0);
}

bool macadb_device::adb_pollmouse()
{
s32 NewX, NewY, NewButton;
Expand Down
6 changes: 4 additions & 2 deletions src/mame/apple/macadb.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ class macadb_device : public device_t

auto adb_data_callback() { return write_adb_data.bind(); }
auto adb_irq_callback() { return write_adb_irq.bind(); }
auto adb_power_callback() { return write_adb_power.bind(); }
auto adb_akd_callback() { return write_adb_akd.bind(); }

required_ioport m_mouse0, m_mouse1, m_mouse2;
required_ioport_array<8> m_keys;
devcb_write_line write_adb_data, write_adb_irq;
devcb_write_line write_adb_data, write_adb_irq, write_adb_power, write_adb_akd;

void adb_linechange_w(int state);

void adb_vblank() {}
void portable_update_keyboard();

protected:
// device-level overrides
Expand Down
9 changes: 0 additions & 9 deletions src/mame/apple/maciici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,6 @@ class maciici_state : public driver_device
else
m_fdc->write((offset >> 8) & 0xf, data >> 8);
}

void write_6015(int state)
{
if (state)
{
m_macadb->adb_vblank();
}
}
};

void maciici_state::machine_start()
Expand Down Expand Up @@ -607,7 +599,6 @@ void maciici_state::maciixi_base(machine_config &config)

RBV(config, m_rbv, C15M);
m_rbv->via6015_callback().set(m_via1, FUNC(via6522_device::write_ca1));
m_rbv->via6015_callback().append(FUNC(maciici_state::write_6015));
m_rbv->irq_callback().set(FUNC(maciici_state::set_via2_interrupt));

/* internal ram */
Expand Down
80 changes: 59 additions & 21 deletions src/mame/apple/macprtb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// copyright-holders:R. Belmont
/****************************************************************************
drivers/macprtb.cpp
macprtb.cpp
Mac Portable / PowerBook 100 emulation
By R. Belmont
Expand All @@ -21,6 +21,9 @@
(CMDμ G65SC22PE-2, not the "6523" variant normally used in ADB Macs) and an
M50753 microcontroller "PMU" handles power management, ADB, and clock/PRAM.
These machines didn't have a power switch, so you can press any key after
shutting them down and they'll reboot. No other Apple portables did that.
VIA connections:
Port A: 8-bit bidirectional data bus to the PMU
Port B: 0: PMU REQ
Expand Down Expand Up @@ -147,12 +150,14 @@ class macportable_state : public driver_device, public device_nvram_interface
m_last_taken_interrupt(-1),
m_ca1_data(0),
m_overlay(false),
m_pmu_blank_display(true),
m_pmu_to_via(0),
m_pmu_from_via(0),
m_pmu_ack(0),
m_pmu_req(0),
m_pmu_p0(0x80),
m_adb_line(1)
m_adb_line(1),
m_adb_akd(0)
{
}

Expand Down Expand Up @@ -202,6 +207,7 @@ class macportable_state : public driver_device, public device_nvram_interface
u8 pmu_comms_r();
void pmu_comms_w(u8 data);
void set_adb_line(int state);
void set_adb_anykeydown(int state);
u8 pmu_adb_r();
void pmu_adb_w(u8 data);
u8 pmu_in_r();
Expand Down Expand Up @@ -235,10 +241,10 @@ class macportable_state : public driver_device, public device_nvram_interface
s32 m_via_cycles, m_via_interrupt, m_scc_interrupt, m_asc_interrupt, m_last_taken_interrupt;
s32 m_ca1_data;

bool m_overlay;
bool m_overlay, m_pmu_blank_display;

u8 m_pmu_to_via, m_pmu_from_via, m_pmu_ack, m_pmu_req, m_pmu_p0;
s32 m_adb_line;
s32 m_adb_line, m_adb_akd;
};

void macportable_state::nvram_default()
Expand Down Expand Up @@ -369,7 +375,7 @@ void macportable_state::pmu_p0_w(u8 data)

u8 macportable_state::pmu_p1_r()
{
return 0x08; // indicate on charger power
return 0x08 | (m_adb_akd << 1); // indicate on charger power
}

u8 macportable_state::pmu_data_r()
Expand All @@ -389,6 +395,17 @@ u8 macportable_state::pmu_comms_r()

void macportable_state::pmu_comms_w(u8 data)
{
if (!BIT(data, 1))
{
address_space &space = m_maincpu->space(AS_PROGRAM);
const u32 memory_size = std::min((u32)0x3fffff, m_rom_size);
const u32 memory_end = memory_size - 1;
offs_t memory_mirror = memory_end & ~(memory_size - 1);
space.unmap_readwrite(0x00000000, memory_end);
space.install_rom(0x00000000, memory_end & ~memory_mirror, memory_mirror, m_rom_ptr);
m_overlay = true;
}

m_maincpu->set_input_line(INPUT_LINE_RESET, BIT(data, 1) ? CLEAR_LINE : ASSERT_LINE);

m_via1->write_ca2(BIT(data, 4)); // 1 second interrupt
Expand All @@ -401,6 +418,11 @@ void macportable_state::set_adb_line(int state)
m_adb_line = state;
}

void macportable_state::set_adb_anykeydown(int state)
{
m_adb_akd = state;
}

u8 macportable_state::pmu_adb_r()
{
return (m_adb_line << 1);
Expand All @@ -409,6 +431,8 @@ u8 macportable_state::pmu_adb_r()
void macportable_state::pmu_adb_w(u8 data)
{
m_macadb->adb_linechange_w((data & 1) ^ 1);

m_pmu_blank_display = BIT(data, 2) ^ 1;
}

u8 macportable_state::pmu_in_r()
Expand Down Expand Up @@ -463,7 +487,14 @@ void macportable_state::machine_start()
save_item(NAME(m_last_taken_interrupt));
save_item(NAME(m_ca1_data));
save_item(NAME(m_overlay));
save_item(NAME(m_pmu_blank_display));
save_item(NAME(m_pmu_to_via));
save_item(NAME(m_pmu_from_via));
save_item(NAME(m_pmu_ack));
save_item(NAME(m_pmu_req));
save_item(NAME(m_pmu_p0));
save_item(NAME(m_adb_line));
save_item(NAME(m_adb_akd));

m_6015_timer = timer_alloc(FUNC(macportable_state::mac_6015_tick), this);
m_6015_timer->adjust(attotime::never);
Expand All @@ -480,6 +511,8 @@ void macportable_state::machine_reset()

// start 60.15 Hz timer
m_6015_timer->adjust(attotime::from_hz(60.15), 0, attotime::from_hz(60.15));

m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
}

void macportable_state::init_macprtb()
Expand All @@ -488,6 +521,13 @@ void macportable_state::init_macprtb()

u32 macportable_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
// is the display enabled?
if (m_pmu_blank_display)
{
bitmap.fill(0, cliprect);
return 0;
}

u16 const *const video_ram = (const u16 *) m_vram.target();

for (int y = 0; y < 400; y++)
Expand Down Expand Up @@ -542,21 +582,18 @@ void macportable_state::via_irq_w(int state)
u16 macportable_state::rom_switch_r(offs_t offset)
{
// disable the overlay
if (!machine().side_effects_disabled())
if (m_overlay && !machine().side_effects_disabled())
{
if ((m_overlay) && (offset == 0x67f))
{
address_space &space = m_maincpu->space(AS_PROGRAM);
const u32 memory_end = m_ram->size() - 1;
void *memory_data = m_ram->pointer();
offs_t memory_mirror = memory_end & ~memory_end;
address_space &space = m_maincpu->space(AS_PROGRAM);
const u32 memory_end = m_ram->size() - 1;
void *memory_data = m_ram->pointer();
offs_t memory_mirror = memory_end & ~memory_end;

space.install_ram(0x00000000, memory_end & ~memory_mirror, memory_mirror, memory_data);
m_overlay = false;
}
space.install_ram(0x00000000, memory_end & ~memory_mirror, memory_mirror, memory_data);
m_overlay = false;
}

return m_rom_ptr[offset & ((m_rom_size - 1)>>2)];
return m_rom_ptr[offset & ((m_rom_size - 1)>>1)];
}

TIMER_CALLBACK_MEMBER(macportable_state::mac_6015_tick)
Expand All @@ -566,7 +603,7 @@ TIMER_CALLBACK_MEMBER(macportable_state::mac_6015_tick)
m_via1->write_ca1(m_ca1_data);

m_pmu->set_input_line(m50753_device::M50753_INT1_LINE, ASSERT_LINE);
m_macadb->adb_vblank();
m_macadb->portable_update_keyboard();
}

u16 macportable_state::scsi_r(offs_t offset, u16 mem_mask)
Expand All @@ -592,8 +629,7 @@ void macportable_state::scsi_berr_w(u8 data)

void macportable_state::macprtb_map(address_map &map)
{
map(0x000000, 0x1fffff).r(FUNC(macportable_state::rom_switch_r));
map(0x900000, 0x93ffff).rom().region("bootrom", 0).mirror(0x0c0000);
map(0x900000, 0x93ffff).r(FUNC(macportable_state::rom_switch_r)).mirror(0x0c0000);
map(0xf60000, 0xf6ffff).rw(FUNC(macportable_state::iwm_r), FUNC(macportable_state::iwm_w));
map(0xf70000, 0xf7ffff).rw(FUNC(macportable_state::via_r), FUNC(macportable_state::via_w));
map(0xf90000, 0xf9ffff).rw(FUNC(macportable_state::scsi_r), FUNC(macportable_state::scsi_w));
Expand All @@ -612,7 +648,7 @@ u8 macportable_state::via_in_a()

u8 macportable_state::via_in_b()
{
return 0x80 | 0x04 | ((m_pmu_ack & 1)<<1);
return 0x80 | 0x04 | ((m_pmu_ack & 1)<<1) | m_pmu_req;
}

void macportable_state::via_out_a(u8 data)
Expand Down Expand Up @@ -702,6 +738,7 @@ void macportable_state::macprtb(machine_config &config)

MACADB(config, m_macadb, 15.6672_MHz_XTAL);
m_macadb->adb_data_callback().set(FUNC(macportable_state::set_adb_line));
m_macadb->adb_akd_callback().set(FUNC(macportable_state::set_adb_anykeydown));

SWIM1(config, m_swim, 15.6672_MHz_XTAL);
m_swim->phases_cb().set(FUNC(macportable_state::phases_w));
Expand Down Expand Up @@ -759,11 +796,12 @@ void macportable_state::macprtb(machine_config &config)
m_ram->set_default_size("1M");
m_ram->set_extra_options("2M,4M,5M,6M,7M,8M,9M");

SOFTWARE_LIST(config, "hdd_list").set_original("mac_hdd");
SOFTWARE_LIST(config, "cd_list").set_original("mac_cdrom").set_filter("MC68000");
SOFTWARE_LIST(config, "flop_mac35_orig").set_original("mac_flop_orig");
SOFTWARE_LIST(config, "flop_mac35_clean").set_original("mac_flop_clcracked");
SOFTWARE_LIST(config, "flop35_list").set_original("mac_flop");
SOFTWARE_LIST(config, "flop35hd_list").set_original("mac_hdflop");
SOFTWARE_LIST(config, "hdd_list").set_original("mac_hdd");
}

ROM_START(macprtb)
Expand Down
Loading

0 comments on commit b6792dd

Please sign in to comment.