-
Notifications
You must be signed in to change notification settings - Fork 2.2k
sinclair/tsconf.cpp: Added FPGA 100K variant; implemented Copper for it. #14008
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
Open
holub
wants to merge
4
commits into
mamedev:master
Choose a base branch
from
holub:tsconf2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42925,6 +42925,7 @@ uk2086 | |
|
||
@source:sinclair/tsconf.cpp | ||
tsconf | ||
tsconf2 | ||
|
||
@source:sinclair/zx.cpp | ||
lambda | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
// license:BSD-3-Clause | ||
// copyright-holders:Andrei I. Holub | ||
/********************************************************************** | ||
TS-Configuration Copper | ||
**********************************************************************/ | ||
|
||
#include "emu.h" | ||
#include "tsconf_copper.h" | ||
|
||
|
||
#define LOG_CTRL (1U << 1) | ||
#define LOG_DATA (1U << 2) | ||
|
||
//#define VERBOSE ( LOG_GENERAL /*| LOG_CTRL | LOG_DATA*/ ) | ||
#include "logmacro.h" | ||
|
||
#define LOGCTRL(...) LOGMASKED(LOG_CTRL, __VA_ARGS__) | ||
#define LOGDATA(...) LOGMASKED(LOG_DATA, __VA_ARGS__) | ||
|
||
|
||
// device type definition | ||
DEFINE_DEVICE_TYPE(TSCONF_COPPER, tsconf_copper_device, "tsconf_copper", "TS-Configuration Copper") | ||
|
||
|
||
tsconf_copper_device::tsconf_copper_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) | ||
: device_t(mconfig, TSCONF_COPPER, tag, owner, clock) | ||
, m_timer(nullptr) | ||
, m_cl_data(*this, "cl_data", 0x100, ENDIANNESS_LITTLE) | ||
, m_out_wreg_cb(*this) | ||
, m_in_dma_ready_cb(*this, 0) | ||
, m_in_until_pos_cb(*this) | ||
{ | ||
} | ||
|
||
void tsconf_copper_device::copper_en_w(u8 data) | ||
{ | ||
m_en = data != 0xff; | ||
m_pc = data; | ||
|
||
if (m_en) | ||
{ | ||
LOGCTRL("START\n"); | ||
m_timer->adjust(attotime::zero); | ||
} | ||
else | ||
{ | ||
LOGCTRL("STOP\n"); | ||
m_timer->reset(); | ||
} | ||
} | ||
|
||
void tsconf_copper_device::cl_data_w(u16 addr, u8 data) | ||
{ | ||
addr &= 0x1ff; | ||
LOGDATA("data(W) %02x %04x\n", addr, data); | ||
m_cl_data[addr >> 1] = (addr & 1) | ||
? (m_cl_data[addr >> 1] & 0x00ff) | (data << 8) | ||
: (m_cl_data[addr >> 1] & 0xff00) | data; | ||
} | ||
|
||
void tsconf_copper_device::dma_ready_w(int status) | ||
{ | ||
if(m_en && (status & 1) && (m_cl_data[m_pc] & 0xffff) == 0b1111'1011'1111'0001) | ||
{ | ||
++m_pc; | ||
m_timer->adjust(attotime::from_hz(clock()), 0); | ||
} | ||
} | ||
|
||
TIMER_CALLBACK_MEMBER(tsconf_copper_device::timer_callback) | ||
{ | ||
const u16 data = m_cl_data[m_pc]; | ||
if (BIT(data, 12, 4) == 0b1111) // all instructions except WREG | ||
{ | ||
switch (BIT(data, 8, 4)) | ||
{ | ||
case 0b0110: //SETA | ||
m_a = data & 0xff; | ||
++m_pc; | ||
break; | ||
|
||
case 0b1000: //SETB | ||
case 0b1001: | ||
m_b = data & 0x1ff; | ||
++m_pc; | ||
break; | ||
|
||
case 0b0111: // WAITX | ||
if (param == 0b1111'0111) | ||
++m_pc; | ||
else | ||
{ | ||
const u8 x = data & 0xff; | ||
if (x < 224) | ||
m_timer->adjust(m_in_until_pos_cb(0x8000 | x), 0b1111'0111); | ||
else | ||
m_timer->reset(); | ||
return; | ||
} | ||
break; | ||
|
||
case 0b1011: // WAITY | ||
if (BIT(data, 4, 4) == 0b1111) // WAIT event | ||
{ | ||
const u8 event = data & 0x0f; | ||
if (event == param) | ||
++m_pc; | ||
else | ||
{ | ||
switch (event) | ||
{ | ||
case 1: // DMA | ||
m_timer->reset(); | ||
return; | ||
break; | ||
case 2: // frame | ||
m_timer->adjust(m_in_until_pos_cb(0b00 << 14), 2); | ||
return; | ||
break; | ||
case 3: // line start | ||
m_timer->adjust(m_in_until_pos_cb(0b11 << 14), 3); | ||
return; | ||
break; | ||
default: | ||
++m_pc; | ||
break; | ||
|
||
} | ||
} | ||
break; | ||
} | ||
[[fallthrough]]; | ||
case 0b1010: | ||
if (param == 0b1111'1010) | ||
++m_pc; | ||
else | ||
{ | ||
const u16 y = data & 0x1ff; | ||
if (y < 320) | ||
m_timer->adjust(m_in_until_pos_cb(0x4000 | y), 0b1111'1010); | ||
else | ||
m_timer->reset(); | ||
return; | ||
} | ||
break; | ||
|
||
case 0b1100: // DJNZA | ||
--m_a; | ||
m_pc = m_a ? data & 0xff : (m_pc + 1); | ||
break; | ||
|
||
case 0b1101: // DJNZB | ||
--m_b; | ||
m_pc = m_b ? data & 0xff : (m_pc + 1); | ||
break; | ||
|
||
case 0b1110: // CALL | ||
m_ret_pc = m_pc + 1; | ||
m_pc = data & 0xff; | ||
break; | ||
|
||
case 0b1111: // JUMP | ||
{ | ||
const u8 to = data & 0xff; | ||
if (to == m_pc) // HALT | ||
{ | ||
m_en = false; | ||
m_timer->reset(); | ||
return; | ||
} | ||
|
||
m_pc = (to == 0xff) ? m_ret_pc : to; | ||
} | ||
break; | ||
|
||
case 0b0101: // SIGNAL | ||
++m_pc; // TODO signal logic | ||
break; | ||
|
||
default: // reserved instructions | ||
++m_pc; | ||
break; | ||
} | ||
} | ||
else | ||
{ | ||
m_out_wreg_cb((data & 0xff00) | 0xaf, data & 0x00ff); | ||
++m_pc; | ||
} | ||
|
||
m_timer->adjust(attotime::from_hz(clock()), 0); | ||
} | ||
|
||
|
||
void tsconf_copper_device::device_start() | ||
{ | ||
m_timer = timer_alloc(FUNC(tsconf_copper_device::timer_callback), this); | ||
|
||
m_in_until_pos_cb.resolve_safe(attotime::zero); | ||
|
||
save_item(NAME(m_en)); | ||
save_item(NAME(m_pc)); | ||
save_item(NAME(m_ret_pc)); | ||
save_item(NAME(m_a)); | ||
save_item(NAME(m_b)); | ||
} | ||
|
||
void tsconf_copper_device::device_reset() | ||
{ | ||
m_timer->reset(); | ||
|
||
m_en = false; | ||
m_pc = 0; | ||
m_ret_pc = 0; | ||
m_a = 0; | ||
m_b = 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// license:BSD-3-Clause | ||
// copyright-holders:Andrei I. Holub | ||
#ifndef MAME_SINCLAIR_TSCONF_COPPER_H | ||
#define MAME_SINCLAIR_TSCONF_COPPER_H | ||
|
||
#pragma once | ||
|
||
class tsconf_copper_device : public device_t | ||
{ | ||
|
||
public: | ||
tsconf_copper_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); | ||
|
||
auto out_wreg_cb() { return m_out_wreg_cb.bind(); } | ||
template <typename... T> void set_in_until_pos_cb(T &&... args) { return m_in_until_pos_cb.set(std::forward<T>(args)...); } | ||
|
||
void copper_en_w(u8 data); | ||
void cl_data_w(u16 addr, u8 data); | ||
void dma_ready_w(int status); | ||
|
||
protected: | ||
virtual void device_start() override ATTR_COLD; | ||
virtual void device_reset() override ATTR_COLD; | ||
|
||
TIMER_CALLBACK_MEMBER(timer_callback); | ||
|
||
emu_timer *m_timer; | ||
|
||
private: | ||
memory_share_creator<u16> m_cl_data; | ||
|
||
devcb_write8 m_out_wreg_cb; | ||
devcb_read_line m_in_dma_ready_cb; | ||
device_delegate<attotime (u16)> m_in_until_pos_cb; | ||
|
||
bool m_en; | ||
u8 m_pc; | ||
u8 m_ret_pc; | ||
u8 m_a; | ||
u16 m_b; // u9 | ||
}; | ||
|
||
|
||
DECLARE_DEVICE_TYPE(TSCONF_COPPER, tsconf_copper_device) | ||
|
||
#endif // MAME_SINCLAIR_TSCONF_COPPER_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't return and break at same time going to throw a compiler error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither clang nor gcc failed the compilation. I was thinking having break everywhere is more consistent.