Skip to content

Commit

Permalink
m6800: fix OCF status clearing as outlined in the manual (m6801u4.pdf…
Browse files Browse the repository at this point in the history
…) - this is needed for kicknrun mcu to function properly [dink]
  • Loading branch information
dinkc64 committed Apr 30, 2020
1 parent c94f733 commit 5a5dbc0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/cpu/m6800/m6800.cpp
Expand Up @@ -1008,18 +1008,8 @@ unsigned char m6803_internal_registers_r(unsigned short offset)
case 0x0a:
return m6800.counter.b.l;
case 0x0b:
if(!(m6800.pending_tcsr&TCSR_OCF))
{
m6800.tcsr &= ~TCSR_OCF;
MODIFIED_tcsr;
}
return m6800.output_compare.b.h;
case 0x0c:
if(!(m6800.pending_tcsr&TCSR_OCF))
{
m6800.tcsr &= ~TCSR_OCF;
MODIFIED_tcsr;
}
return m6800.output_compare.b.l;
case 0x0d:
if(!(m6800.pending_tcsr&TCSR_ICF))
Expand Down Expand Up @@ -1161,13 +1151,25 @@ void m6803_internal_registers_w(unsigned short offset, unsigned char data)
MODIFIED_counters;
break;
case 0x0b:
// M6801U4.pdf pg.25 bottom-left "OCFI is cleared by reading the TCSR or the TSR (with OCFI set) and then writing to output compare register 1 ($OB or $OC); or during reset..." -dink [April 30, 2020]
if(!(m6800.pending_tcsr&TCSR_OCF))
{
m6800.tcsr &= ~TCSR_OCF;
MODIFIED_tcsr;
}
if( m6800.output_compare.b.h != data)
{
m6800.output_compare.b.h = data;
MODIFIED_counters;
}
break;
case 0x0c:
// M6801U4.pdf pg.25 bottom-left "OCFI is cleared by reading the TCSR or the TSR (with OCFI set) and then writing to output compare register 1 ($OB or $OC); or during reset..." -dink [April 30, 2020]
if(!(m6800.pending_tcsr&TCSR_OCF))
{
m6800.tcsr &= ~TCSR_OCF;
MODIFIED_tcsr;
}
if( m6800.output_compare.b.l != data)
{
m6800.output_compare.b.l = data;
Expand Down

1 comment on commit 5a5dbc0

@dinkc64
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same fix for current MAME, devices/cpu/m6800/m6801.cpp: diff attached
m6801_diff.zip

M6801U4 manual, pg.25 bottom-left text states
"OCFI is cleared by reading the TCSR or the TSR (with OCFI set) and then writing to output compare register 1 ($OB or $OC); or during reset"
Manual link: https://lrak.net/secret/data_sheets/microprocessor/MC6801U4.pdf

Please sign in to comment.