Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tk10 keyboard device for apple ii clones #13004

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

goldnchild
Copy link
Contributor

I found a schematic of the TK10 keyboard and made a device for it.

The rom can be found as part of the am64 apple II clone in apple2.cpp.

@rb6502
Copy link
Contributor

rb6502 commented Nov 21, 2024

If it's part of the AM64 machine, then you should just hook it up to the AM64. Also, unless the keyboard was also used on non-Apple machines you can just put it in src/mame/apple.

Copy link
Member

@cuavas cuavas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn’t much use if it isn’t actually attached to anything. The device won’t be linked since there’s nothing referenced in the translation unit, so it won’t appear in -listxml or detect things with -romident, etc.

Also it should be in src/mame/apple.

Comment on lines 92 to 101
m_tk10cpu->p1_in_cb().set([this] () -> u8
{
for (int i = 0; i < 8; i++)
{
if (!BIT(m_tk10cpu->p2_r(), i)) return m_keyboard[i]->read();
// read key matrix:
// a low value in p2 bit will drive bit of p1 low when switch contact made
}
return 0xff;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should lift the p2_r out of the loop.

Comment on lines 145 to 156
PORT_START("P21")
PORT_BIT(0x001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) // _ SHIFT=^
PORT_BIT(0x002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_PGUP) // ]
PORT_BIT(0x004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) // [
PORT_BIT(0x008, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_PGDN) // @ SHIFT=^
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH_PAD) // /
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_PLUS_PAD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ASTERISK)

PORT_START("P22")
PORT_BIT(0x001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) // BACKSLASH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these keys really have blank key caps? It’s bad to have inputs that lack either PORT_NAME or PORT_CHAR.

Comment on lines 4 to 5
#ifndef MAME_TK10_KEYBOARD_H
#define MAME_TK10_KEYBOARD_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t match the path.

Comment on lines 24 to 28
INPUT_CHANGED_MEMBER( tk10_func );
INPUT_CHANGED_MEMBER( tk10_reset );

auto reset_write_cb() { return m_reset_write.bind(); }
auto data_write_cb() { return m_data_write.bind(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conventionally, configuration members come before other stuff.

Comment on lines 31 to 35
// device-level overrides
virtual void device_start() override;
virtual void device_add_mconfig(machine_config &config) override;
virtual ioport_constructor device_input_ports() const override;
virtual const tiny_rom_entry *device_rom_region() const override;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don’t copy/paste this meaningless comment. Also, please add ATTR_COLD for typical cold lifecycle member functions as @holub has done for most existing devices.

@goldnchild
Copy link
Contributor Author

If it's part of the AM64 machine, then you should just hook it up to the AM64. Also, unless the keyboard was also used on non-Apple machines you can just put it in src/mame/apple.

I wanted to check with you on changes to apple2.cpp.

adding a member variable to hold the value of tk10 reset line.

void apple2_state::tk10_data_write(u8 data)
{
if (m_maincpu->total_cycles() < 25000)
{
return;
}

	if (data & 0x80)
	{
		m_transchar = data & 0x7f;
		m_strobe = 0x80;
	}

}

void apple2_state::tk10_reset_write(u8 data)
{
m_tk10_reset_data = data;
}

TIMER_DEVICE_CALLBACK_MEMBER(apple2_state::apple2_interrupt_tk10)
{
basically the same as the regular function, only this time using the tk10 reset line
}

void apple2_state::am64(machine_config &config)
{
apple2p(config);
m_scantimer->configure_scanline(FUNC(apple2_state::apple2_interrupt_tk10), "screen", 0, 1);

tk10_keyboard_device &tk10(TK10_KEYBOARD(config, "tk10", 0));
tk10.data_write_cb().set(FUNC(apple2_state::tk10_data_write));
tk10.reset_write_cb().set(FUNC(apple2_state::tk10_reset_write));

}

I didn't want to touch any of the existing code, like removing the normal keyboard.
// config.device_remove(A2_KBDC_TAG);

When you switch the keyboard selection under the Input Menu, the normal keyboard can be deactivated and the tk10 can be activated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants