-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit for Foenix F256K retro-computer. #14029
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
dtremblay
wants to merge
13
commits into
mamedev:master
Choose a base branch
from
dtremblay:f256k
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
13 commits
Select commit
Hold shift + click to select a range
f697291
Commit for Foenix F256K retro-computer.
dtremblay 263cfc3
Fixed the header constant to match guard.
dtremblay 28e69a1
Added SPDX license and my handle.
dtremblay a6ef931
Removed the harddriv.old file.
dtremblay 8e5147c
Merge branch 'mamedev:master' into f256k
dtremblay 2bf708d
Addressed comments by ajrhacker.
dtremblay 52cfd24
Merge branch 'f256k' of https://github.com/dtremblay/mame into f256k
dtremblay 451cb91
Fixed the issue with "-validate" reporting a duplicate name.
dtremblay 22cac54
Converted the iopages to an array.
dtremblay ebc5f47
Used a DEFINED variable instead of magic string.
dtremblay a4964ed
Converted other devices to arrays.
dtremblay 39ae79c
Addressing comments from reviewers.
dtremblay cca1b72
Updated code to address comments from reviewers.
dtremblay 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 |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
#include "logmacro.h" | ||
|
||
// device type definition | ||
DEFINE_DEVICE_TYPE(BQ4802, bq4802_device, "bq4802", "Benchmarq BQ4802 RTC") | ||
DEFINE_DEVICE_TYPE(BQ4845, bq4845_device, "bq4845", "Benchmarq BQ4845 RTC") | ||
DEFINE_DEVICE_TYPE(BQ4847, bq4847_device, "bq4847", "Benchmarq BQ4847 RTC") | ||
|
||
|
@@ -51,7 +52,7 @@ enum | |
reg_interrupts, // 0 0 0 0 AIE PIE PWRIE ABE 0x00 on powerup | ||
reg_flags, // 0 0 0 0 AF PF PWRF BVF 0x00 after reading | ||
reg_control, // 0 0 0 0 UTI STOP* 24/12* DSE | ||
reg_unused // 0x00 | ||
reg_century, // 0x00-0x99 | ||
}; | ||
|
||
enum | ||
|
@@ -74,7 +75,7 @@ enum | |
// Constructors for basetype | ||
//------------------------------------------------- | ||
|
||
bq4847_device::bq4847_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock) | ||
bq4847_device::bq4847_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) | ||
: device_t(mconfig, type, tag, owner, clock), | ||
device_nvram_interface(mconfig, *this), | ||
device_rtc_interface(mconfig, *this), | ||
|
@@ -88,20 +89,26 @@ bq4847_device::bq4847_device(const machine_config& mconfig, device_type type, co | |
m_int_state(1), | ||
m_rst_state(1), | ||
m_wdi_state(-1), | ||
m_writing(false) | ||
m_writing(false), | ||
m_century(false) | ||
{ | ||
} | ||
|
||
bq4847_device::bq4847_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock) | ||
bq4847_device::bq4847_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) | ||
: bq4847_device(mconfig, BQ4847, tag, owner, clock) | ||
{ | ||
} | ||
|
||
bq4845_device::bq4845_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock) | ||
bq4845_device::bq4845_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) | ||
: bq4847_device(mconfig, BQ4845, tag, owner, clock) | ||
{ | ||
} | ||
|
||
bq4802_device::bq4802_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) | ||
: bq4847_device(mconfig, BQ4802, tag, owner, clock) | ||
{ | ||
set_century(true); | ||
} | ||
// device_rtc_interface | ||
|
||
void bq4847_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) | ||
|
@@ -112,10 +119,15 @@ void bq4847_device::rtc_clock_updated(int year, int month, int day, int day_of_w | |
(((hour % 24) >= 12) ? 0x80 : 0x00) | convert_to_bcd((hour % 12) ? (hour % 12) : 12); | ||
m_register[reg_minutes] = convert_to_bcd(minute); | ||
m_register[reg_seconds] = convert_to_bcd(second); | ||
m_register[reg_year] = convert_to_bcd(year); | ||
m_register[reg_year] = convert_to_bcd(year % 100); | ||
m_register[reg_month] = convert_to_bcd(month); | ||
m_register[reg_date] = convert_to_bcd(day); | ||
m_register[reg_days] = convert_to_bcd(day_of_week); | ||
if (m_century) | ||
{ | ||
m_register[reg_century] = convert_to_bcd(year / 100); | ||
} | ||
|
||
} | ||
|
||
// Clear the saved flags (TODO: check that flags set before power down, or during battery backup are lost) | ||
|
@@ -132,7 +144,7 @@ void bq4847_device::rtc_clock_updated(int year, int month, int day, int day_of_w | |
// What about the DSE flag? | ||
} | ||
|
||
bool bq4847_device::increment_bcd(uint8_t& bcdnumber, uint8_t limit, uint8_t min) | ||
bool bq4847_device::increment_bcd(uint8_t &bcdnumber, uint8_t limit, uint8_t min) | ||
{ | ||
if (bcdnumber >= limit) | ||
{ | ||
|
@@ -183,16 +195,26 @@ TIMER_CALLBACK_MEMBER(bq4847_device::update_callback) | |
if (carry) | ||
advance_days_bcd(); | ||
|
||
LOGMASKED(LOG_CLOCK, "%s 20%02x-%02x-%02x %02x:%02x:%02x\n", | ||
dow[m_register[reg_days] - 1], m_register[reg_year], m_register[reg_month], m_register[reg_date], | ||
m_register[reg_hours], m_register[reg_minutes], m_register[reg_seconds]); | ||
if (!m_century) | ||
{ | ||
LOGMASKED(LOG_CLOCK, "%s 20%02x-%02x-%02x %02x:%02x:%02x\n", | ||
dow[m_register[reg_days] - 1], m_register[reg_year], m_register[reg_month], m_register[reg_date], | ||
m_register[reg_hours], m_register[reg_minutes], m_register[reg_seconds]); | ||
} | ||
else | ||
{ | ||
LOGMASKED(LOG_CLOCK, "%s %02x%02x-%02x-%02x %02x:%02x:%02x\n", | ||
dow[m_register[reg_days] - 1], m_register[reg_century], m_register[reg_year], m_register[reg_month], m_register[reg_date], | ||
m_register[reg_hours], m_register[reg_minutes], m_register[reg_seconds]); | ||
} | ||
|
||
|
||
if (newsec) | ||
{ | ||
if ((m_register[reg_control] & CONTROL_UTI) == 0) | ||
{ | ||
LOGMASKED(LOG_TRANSFER, "Transfer to external regs\n"); | ||
for (int i = reg_seconds; i < reg_unused; i++) | ||
for (int i = reg_seconds; i < reg_century + 1; i++) | ||
{ | ||
if (is_clock_register(i)) m_userbuffer[i] = m_register[i]; | ||
} | ||
|
@@ -289,9 +311,13 @@ void bq4847_device::advance_days_bcd() | |
if (m_register[reg_month] == 0x13) | ||
{ | ||
m_register[reg_month] = 0x01; | ||
increment_bcd(m_register[reg_year], 0xff, 0); | ||
carry = increment_bcd(m_register[reg_year], 0xff, 0); | ||
} | ||
} | ||
if (m_century && carry) | ||
{ | ||
increment_bcd(m_register[reg_century], 0xff, 1); | ||
} | ||
} | ||
|
||
bool bq4847_device::check_alarm(int now, int alarm) | ||
|
@@ -313,8 +339,8 @@ uint8_t bq4847_device::read(offs_t address) | |
} | ||
else if (regnum >= reg_interrupts && regnum <= reg_control) | ||
value &= 0xf; | ||
else if (regnum == reg_unused) | ||
value = 0; // Reg 15 is locked to 0 in BQ4847 | ||
else if (regnum == reg_century) | ||
value = m_century? m_register[reg_century]: 0; // Reg 15 is locked to 0 in BQ4847 | ||
|
||
LOGMASKED(LOG_REG, "Reg %d -> %02x\n", regnum, value); | ||
|
||
|
@@ -358,7 +384,7 @@ void bq4847_device::write(offs_t address, uint8_t data) | |
if (uti_set && !uti_set_now && m_writing) | ||
{ | ||
LOGMASKED(LOG_TRANSFER, "Transfer to internal regs\n"); | ||
for (int i = reg_seconds; i < reg_unused; i++) | ||
for (int i = reg_seconds; i < reg_century + 1; i++) | ||
{ | ||
if (is_clock_register(i)) m_register[i] = m_userbuffer[i]; | ||
} | ||
|
@@ -372,7 +398,7 @@ bool bq4847_device::is_clock_register(int regnum) | |
{ | ||
return (regnum == reg_seconds || regnum == reg_minutes || regnum == reg_hours || | ||
regnum == reg_date || regnum == reg_days || regnum == reg_month | ||
|| regnum == reg_year); | ||
|| regnum == reg_year || regnum == reg_century); | ||
} | ||
Comment on lines
399
to
402
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, combined with the change to |
||
|
||
void bq4847_device::set_periodic_timer() | ||
|
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
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.
In general, adding device type flags that need to be checked all over the place is an ugly way of doing things. Can you think of a way of doing this without needing intrusive checks inserted throughout the code?