Skip to content

Commit

Permalink
update, NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
toxieainc committed Dec 7, 2024
1 parent 7358171 commit 349eff5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions release/whatsnew.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Fixed regression/crashes for Elvis and Monopoly (introduced in 3.1)
Improved emulation robustness when running multiple machines from the same generation (e.g. System11) one after another (e.g. from within VPX)
or when resetting certain machines
Clean-up Metallica Coffin Magnet processor board to cleanly report its mode of operation (see https://missionpinball.org/mechs/magnets/stern_magnet_pcb/ for detailed operations)
Rewrite SAM nodeboard emulation (ACDC LE, MTL Premium, ST LE, Mustang LE, TWD LE)
Fixed AT91 USART emulation
Fixed reset and slam-tilt problems of Baby Pac-Man
Fixed PPS4 emulation: ADCSK and ADSK instructions did both respect the carry-in flag because of one wrong byte in the Gottlieb System 1 spider chip reads! Also, regular instructions only increase the six lowest PC bits.
Improved WPC emulation: implementing FIRQ and the highres timer
Expand Down
14 changes: 7 additions & 7 deletions src/cpu/at91/at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,15 @@ void at91_adjust_serial_baud_rate(int usartno)
{
if (at91usart[usartno].US_BRGR)
{
data32_t USCLKS = (at91usart[usartno].US_MR >> 4) & 0x3; // USCLKS: Clock Selection (Baud Rate Generator Input Clock)
data32_t CHRL = (at91usart[usartno].US_MR >> 6) & 0x3; // CHRL: Character Length
data32_t SYNC = (at91usart[usartno].US_MR >> 8) & 0x1; // SYNC: Synchronous Mode Select (Code Label US_SYNC)
data32_t USCLKS = (at91usart[usartno].US_MR >> 4) & 0x3; // USCLKS: Clock Selection (Baud Rate Generator Input Clock)
data32_t CHRL = (at91usart[usartno].US_MR >> 6) & 0x3; // CHRL: Character Length
data32_t SYNC = (at91usart[usartno].US_MR >> 8) & 0x1; // SYNC: Synchronous Mode Select (Code Label US_SYNC)
data32_t NBSTOP = (at91usart[usartno].US_MR >> 12) & 0x3; // NBSTOP: Number of Stop Bits
data32_t MODE9 = (at91usart[usartno].US_MR >> 17) & 0x1; // MODE9: 9-bit Character Length (Code Label US_MODE9)
int divider = SYNC == 0 ? (16 * at91usart[usartno].US_BRGR) : at91usart[usartno].US_BRGR;
data32_t MODE9 = (at91usart[usartno].US_MR >> 17) & 0x1; // MODE9: 9-bit Character Length (Code Label US_MODE9)
unsigned int divider = SYNC == 0 ? (16 * at91usart[usartno].US_BRGR) : at91usart[usartno].US_BRGR;
double uartClock = USCLKS == 0 ? (at91rs.cpu_freq / divider) // MCK
: USCLKS == 1 ? (at91rs.cpu_freq / (8 * divider)) // MCK / 8
: 9600; // SCK (external clock, not implemented)
: USCLKS == 1 ? (at91rs.cpu_freq / (8 * divider)) // MCK / 8
: 9600; // SCK (external clock, not implemented)
double bitPerByte = (MODE9 ? 9 : (CHRL + 5)) + (NBSTOP / 2.0);
LOG(("%08x: AT91-USART%d BYTE RATE = %8.1f bytes per second\n", activecpu_get_pc(), usartno + 1, uartClock / bitPerByte));
timer_adjust(at91_serial_timer[usartno], TIME_IN_HZ(uartClock / bitPerByte), usartno, TIME_IN_HZ(uartClock / bitPerByte));
Expand Down
18 changes: 9 additions & 9 deletions src/wpc/sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,13 +1627,13 @@ static SWITCH_UPDATE(sam) {
// This is built from reading main gamecode, as well as nodeboard firmware and schematics
//
// The 5 first games using these boards were more or less beta version from ACDC & Metallica which have a very basic
// protocol to TWD and Miustang which implement most of it and are very similar to Spike nodeboards.
// protocol, to TWD and Mustang which implement most of it and are very similar to Spike nodeboards.
//
// - ACDC LE (2012) tested with acd_170h
// - Metallica Premium Monsters (2013) tested with mtl_180h
// Board 520-5331-00: Grinder Multi-Color LED driver
// Single board with the bridge and the single child node into the same little controller (ATtiny4313-SU), driving 4 GI outputs and
// some LED drivers. DOes not implement the full communication protocol (see below)
// some LED drivers. Does not implement the full communication protocol (see below)
//
// - Star Trek LE (2013) tested with st_162h
// Board 520-6812-00: top board, bridge and child board 5
Expand All @@ -1644,22 +1644,22 @@ static SWITCH_UPDATE(sam) {
//
// - Mustang LE (2014) tested with mt_145h
// Board 520-6822-00 Board 5: Bridge (ATtiny2313A-SU) and child (LPC1112FHN33/xxx) on the same board
// Gamecode runs a little startyp sequence to validate bridge communication and setup nodeboards then simply send Led states
// Gamecode runs a little startup sequence to validate bridge communication and setup nodeboards then simply send Led states
//
// - The Walking Dead LE (2014) tested with twd_160h
// Board 520-6937-00: bridge & child Board 3 (10 onboard LEDs, 14 driven outputs)
// Board 520-5322-00: 32 LEDs, 32 switch, child board 8
// TWD gamecode runs a startup sequence with bridge setup (03/05 broadcasts), then nodeboards setup (F1/FE/FF/FB messages),
// then send LED data at a 16ms pace (no fading, 2 messages per board)
// then sends LED data at a 16ms pace (no fading, 2 messages per board)
//
// The architecture is designed around the Main CPU, a very simple 'Bridge node' and several 'Child nodes'.
// The bridge node is often located on a board that also have a child node. Bridge is a very basic function
// The bridge node is often located on a board that also has a child node. Bridge is a very basic function
// built with an ATtiny2313A controller which makes the bridge between CPU (simple point to point communication)
// and child nodes (RS485 multi drop communication that support addressing messages).
//
// Child Nodeboard firmwares are partially available in main CPU ROM likely used to update the nodeboards.
// But when updating the nodeboard firmware, the CPU only write to the flash ROM after the first 0x1000 bytes
// These 4Kb of memory contains static informations which are likely flashed in factory and never changed.
// But when updating the nodeboard firmware, the CPU only writes to the flash ROM after the first 0x1000 bytes.
// These 4Kb of memory contains static information which is likely flashed in factory and never changed.
// Therefore values for these are guessed by reverse engineering what the CPU expects when reading. These
// could also be obtained from real boards, or exploiting the 0xF5 GetChecksum command but noone has done
// that yet.
Expand Down Expand Up @@ -1900,7 +1900,7 @@ static void sam_nodebus_msg_received()
}
// Nodeboard addressed command
// These commands are still processed by the bridge that will broadcast them using RS485 multi drop
// addressing mode, and will buffer the response untl the requested size is reached.
// addressing mode, and will buffer the response until the requested size is reached.
else
{
#if LOG_NODEBOARD
Expand Down Expand Up @@ -2066,7 +2066,7 @@ static void sam_nodebus_transmit(int usartno, data8_t *data, int size)
nblocals.rcvMsg[nblocals.rcvMsgPos] = rcvByte;
int msgLength;
if (nblocals.bridge == SAM_NB_ACDC_METALLICA)
// Metallica has a very simple protocol: either one of the GI output (address + state), or the 48 LED string (address + command + states)
// Metallica has a very simple protocol: either one of the GI outputs (address + state), or the 48 LED string (address + command + states)
msgLength = (nblocals.rcvMsg[0] == 0x80) ? (2 + 48) : 2;
else
// Broadcasted messages have an additional expected response length byte which is not included in the payload length
Expand Down

0 comments on commit 349eff5

Please sign in to comment.