Skip to content

Commit 3f3f38a

Browse files
committed
simplify invocations of change_timer_flipflop method
by passing it directly the operation values instead of explicitly interpreting their meaning on the calling end. (Addressing "it feels like it's always used with constant parameters" comment from mamedev#13220 (comment))
1 parent f997297 commit 3f3f38a

File tree

1 file changed

+18
-134
lines changed

1 file changed

+18
-134
lines changed

src/devices/cpu/tlcs900/tmp94c241.cpp

Lines changed: 18 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -711,31 +711,8 @@ void tmp94c241_device::change_timer_flipflop(uint8_t flipflop, uint8_t operation
711711

712712
void tmp94c241_device::t02ffcr_w(uint8_t data)
713713
{
714-
switch( data & 0x0c )
715-
{
716-
case 0x00:
717-
change_timer_flipflop( 1, FF_INVERT );
718-
break;
719-
case 0x04:
720-
change_timer_flipflop( 1, FF_SET );
721-
break;
722-
case 0x08:
723-
change_timer_flipflop( 1, FF_CLEAR );
724-
break;
725-
}
726-
switch( data & 0xc0 )
727-
{
728-
case 0x00:
729-
change_timer_flipflop( 3, FF_INVERT );
730-
break;
731-
case 0x40:
732-
change_timer_flipflop( 3, FF_SET );
733-
break;
734-
case 0x80:
735-
change_timer_flipflop( 3, FF_CLEAR );
736-
break;
737-
}
738-
714+
change_timer_flipflop( 1, (data >> 2) & 3 );
715+
change_timer_flipflop( 3, (data >> 6) & 3 );
739716
SFR_T02FFCR = data | 0xcc;
740717
}
741718

@@ -854,103 +831,33 @@ uint8_t tmp94c241_device::t4ffcr_r()
854831

855832
void tmp94c241_device::t4ffcr_w(uint8_t data)
856833
{
857-
switch( data & 0x03 )
858-
{
859-
case 0x00:
860-
change_timer_flipflop( 4, FF_INVERT );
861-
break;
862-
case 0x01:
863-
change_timer_flipflop( 4, FF_SET );
864-
break;
865-
case 0x02:
866-
change_timer_flipflop( 4, FF_CLEAR );
867-
break;
868-
}
869-
switch( data & 0xc0 )
870-
{
871-
case 0x00:
872-
change_timer_flipflop( 5, FF_INVERT );
873-
break;
874-
case 0x40:
875-
change_timer_flipflop( 5, FF_SET );
876-
break;
877-
case 0x80:
878-
change_timer_flipflop( 5, FF_CLEAR );
879-
break;
880-
}
881-
834+
change_timer_flipflop( 4, data & 3 );
835+
change_timer_flipflop( 5, (data >> 6) & 3 );
882836
SFR_T4FFCR = data | 0xc3;
883837
}
884838

885-
uint8_t tmp94c241_device::t8ffcr_r()
839+
uint8_t tmp94c241_device::t6ffcr_r()
886840
{
887-
return SFR_T8FFCR;
841+
return SFR_T6FFCR;
888842
}
889843

890-
void tmp94c241_device::t8ffcr_w(uint8_t data)
844+
void tmp94c241_device::t6ffcr_w(uint8_t data)
891845
{
892-
switch( data & 0x03 )
893-
{
894-
case 0x00:
895-
change_timer_flipflop( 8, FF_INVERT );
896-
break;
897-
case 0x01:
898-
change_timer_flipflop( 8, FF_SET );
899-
break;
900-
case 0x02:
901-
change_timer_flipflop( 8, FF_CLEAR );
902-
break;
903-
}
904-
switch( data & 0xc0 )
905-
{
906-
case 0x00:
907-
change_timer_flipflop( 9, FF_INVERT );
908-
break;
909-
case 0x40:
910-
change_timer_flipflop( 9, FF_SET );
911-
break;
912-
case 0x80:
913-
change_timer_flipflop( 9, FF_CLEAR );
914-
break;
915-
}
916-
917-
SFR_T8FFCR = data | 0xc3;
846+
change_timer_flipflop( 6, data & 3 );
847+
change_timer_flipflop( 7, (data >> 6) & 3 );
848+
SFR_T6FFCR = data | 0xc3;
918849
}
919850

920-
921-
uint8_t tmp94c241_device::t6ffcr_r()
851+
uint8_t tmp94c241_device::t8ffcr_r()
922852
{
923-
return SFR_T6FFCR;
853+
return SFR_T8FFCR;
924854
}
925855

926-
void tmp94c241_device::t6ffcr_w(uint8_t data)
856+
void tmp94c241_device::t8ffcr_w(uint8_t data)
927857
{
928-
switch( data & 0x03 )
929-
{
930-
case 0x00:
931-
change_timer_flipflop( 6, FF_INVERT );
932-
break;
933-
case 0x01:
934-
change_timer_flipflop( 6, FF_SET );
935-
break;
936-
case 0x02:
937-
change_timer_flipflop( 6, FF_CLEAR );
938-
break;
939-
}
940-
switch( data & 0xc0 )
941-
{
942-
case 0x00:
943-
change_timer_flipflop( 7, FF_INVERT );
944-
break;
945-
case 0x40:
946-
change_timer_flipflop( 7, FF_SET );
947-
break;
948-
case 0x80:
949-
change_timer_flipflop( 7, FF_CLEAR );
950-
break;
951-
}
952-
953-
SFR_T6FFCR = data | 0xc3;
858+
change_timer_flipflop( 8, data & 3 );
859+
change_timer_flipflop( 9, (data >> 6) & 3 );
860+
SFR_T8FFCR = data | 0xc3;
954861
}
955862

956863
uint8_t tmp94c241_device::taffcr_r()
@@ -960,31 +867,8 @@ uint8_t tmp94c241_device::taffcr_r()
960867

961868
void tmp94c241_device::taffcr_w(uint8_t data)
962869
{
963-
switch( data & 0x03 )
964-
{
965-
case 0x00:
966-
change_timer_flipflop( 0xa, FF_INVERT );
967-
break;
968-
case 0x01:
969-
change_timer_flipflop( 0xa, FF_SET );
970-
break;
971-
case 0x02:
972-
change_timer_flipflop( 0xa, FF_CLEAR );
973-
break;
974-
}
975-
switch( data & 0xc0 )
976-
{
977-
case 0x00:
978-
change_timer_flipflop( 0xb, FF_INVERT );
979-
break;
980-
case 0x40:
981-
change_timer_flipflop( 0xb, FF_SET );
982-
break;
983-
case 0x80:
984-
change_timer_flipflop( 0xb, FF_CLEAR );
985-
break;
986-
}
987-
870+
change_timer_flipflop( 0xa, data & 3 );
871+
change_timer_flipflop( 0xb, (data >> 6) & 3 );
988872
SFR_TAFFCR = data | 0xc3;
989873
}
990874

0 commit comments

Comments
 (0)