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 cpu device PIC16x8x - Add PIC16F84 to magicle into misc/magicard.cpp #12092

Merged
merged 8 commits into from
Jun 3, 2024

Conversation

grullosgo
Copy link
Contributor

Add cpu device PIC16x8x
Add PIC16F84 to magicle game into misc/magicard.cpp

Comment on lines 115 to 117
, m_data_config("data", ENDIANNESS_LITTLE, 8, 8, 0,
((pic_model == 0x83) ? address_map_constructor(FUNC(pic16x8x_device::ram_6), this) :
address_map_constructor(FUNC(pic16x8x_device::ram_7), this)))
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably better just to pass the address map constructor here and eliminate the artificial pic_model constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Deleted pic_model and and use program_width as selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Second revision. Fixed.
Added new base classes and instances for 16x83 and 16x84 to define properly the address maps.

Comment on lines +200 to +205
// Get default NVRAM data from memory region
memcpy(m_buff, m_region->base() + eeprom_dump, m_internal_eeprom_size * 2);

// Data width conversion
for (u8 i=0; i < m_internal_eeprom_size; i++)
m_eeprom_data[i] = m_buff[i] & 0x00ff;
Copy link
Contributor

Choose a reason for hiding this comment

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

This code doesn't seem endian-safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the rom load of this region is (and "must be") "ROM_REGION16_LE( 0x4280, "pic16f84", 0 )", I understand that the proposed code is correct.
The origin and destination data have been duly verified.
The memcpy() function loads u16 type data into m_buff from m_region, which in turn
have been read from the source in little_endian mode, therefore the conversion loop and its corresponding mask are correct.
Even so, if you consider that the code requires some change, I am completely willing to make it.

Comment on lines 264 to 277
#define RBPU_FLAG 0x80 // RBPU PORTB Pull-up Enable bit
#define INTEDG_FLAG 0x40 // INTEDG Interrupt Edge Select bit
// 1 = Interrupt on rising edge of RB0/INT pin
// 0 = Interrupt on falling edge of RB0/INT pin
#define T0CS_FLAG 0x20 // T0CS Timer 0 clock source select
// 1 = Transition on RA4/T0CKI pin
// 0 = Internal instruction cycle clock (CLKOUT)
#define T0SE_FLAG 0x10 // T0SE Timer 0 clock source edge select
// 1 = Increment on high-to-low transition on RA4/T0CKI pin
// 0 = Increment on low-to-high transition on RA4/T0CKI pin
#define PSA_FLAG 0x08 // PSA Prescaler Assignment bit
// 1 = Prescaler is assigned to the WDT
// 0 = Prescaler is assigned to the Timer0 module
#define PS_REG 0x07 // PS Prescaler Rate select
Copy link
Contributor

Choose a reason for hiding this comment

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

It's generally recommended to use constexpr instead of #define for constants in new code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

working on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 689 to 690
if(ADDR == 0x0b)
logerror("ANDWF -> INTCON - data:%x\n", m_ALU);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a leftover from debugging. If you're running MAME with -debug, you can use wpdset 0x0b, 1, w to catch writes to this register.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Will delete this and other two following logerrors calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Deleted all leftovers.

Comment on lines 416 to 417
m_STACK[m_stack_pointer] = data & m_program_mask;
m_stack_pointer++;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to check for stack overflow here. (I haven't double-checked the datasheet for this microcontroller, but PIC17 does recognize stack overflows, though it doesn't handle them very gracefully.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will check the datasheet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Added some datasheet notes and add stack overflow check.

Unify EEPROM size. Delete  model selector.
Unify EEPROM size.
Deleted pic model selector.
Deleted all logerror() leftover
Changed #defines by constexpr
Fixed and add datashhet notes about stack overflow control
Added new base classes and instances for 16x83 and 16x84 to define properly the address maps.
Added new base classes and instances for 16x83 and 16x84 to define properly the address maps.
@grullosgo grullosgo requested a review from ajrhacker April 2, 2024 13:31
@grullosgo
Copy link
Contributor Author

grullosgo commented Apr 28, 2024

Hi @ajrhacker.
I have completed all the items mentioned. Have I missed something for a second review? Should I click the "Resolve Conversation" button on each resolved comment? (There are small details about the PR's that I still don't know how to handle).
Thanks.

Copy link
Member

@angelosa angelosa left a comment

Choose a reason for hiding this comment

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

Have seen this PR a couple times and have no direct feedback against it. Approving out of a later merging if there's no further feedback.

@galibert galibert merged commit 1efb9a8 into mamedev:master Jun 3, 2024
5 checks passed
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.

None yet

4 participants