Skip to content

Commit 3ab7451

Browse files
committed
TLCS900: reduce usage of preprocessor macros.
1 parent 1f06e6b commit 3ab7451

File tree

3 files changed

+135
-136
lines changed

3 files changed

+135
-136
lines changed

src/devices/cpu/tlcs900/tlcs900.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ std::unique_ptr<util::disasm_interface> tlcs900_device::create_disassembler()
7070
}
7171

7272

73-
/* Flag defines */
74-
#define FLAG_CF 0x01
75-
#define FLAG_NF 0x02
76-
#define FLAG_VF 0x04
77-
#define FLAG_HF 0x10
78-
#define FLAG_ZF 0x40
79-
#define FLAG_SF 0x80
73+
static constexpr u8 FLAG_CF = 0x01;
74+
static constexpr u8 FLAG_NF = 0x02;
75+
static constexpr u8 FLAG_VF = 0x04;
76+
static constexpr u8 FLAG_HF = 0x10;
77+
static constexpr u8 FLAG_ZF = 0x40;
78+
static constexpr u8 FLAG_SF = 0x80;
8079

8180

8281
inline uint8_t tlcs900_device::RDOP()

src/devices/cpu/tlcs900/tmp95c061.cpp

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -257,50 +257,51 @@ void tmp95c061_device::device_reset()
257257
}
258258
}
259259

260+
enum {
261+
INTE0AD,
262+
INTE45,
263+
INTE67,
264+
INTET10,
265+
INTET32,
266+
INTET54,
267+
INTET76,
268+
INTES0,
269+
INTES1,
270+
INTETC10,
271+
INTETC32
272+
};
260273

261-
#define TMP95C061_INTE0AD 0x0
262-
#define TMP95C061_INTE45 0x1
263-
#define TMP95C061_INTE67 0x2
264-
#define TMP95C061_INTET10 0x3
265-
#define TMP95C061_INTET32 0x4
266-
#define TMP95C061_INTET54 0x5
267-
#define TMP95C061_INTET76 0x6
268-
#define TMP95C061_INTES0 0x7
269-
#define TMP95C061_INTES1 0x8
270-
#define TMP95C061_INTETC10 0x9
271-
#define TMP95C061_INTETC32 0xa
272-
273-
#define TMP95C061_NUM_MASKABLE_IRQS 22
274274
static const struct {
275275
uint8_t reg;
276276
uint8_t iff;
277277
uint8_t vector;
278-
} tmp95c061_irq_vector_map[TMP95C061_NUM_MASKABLE_IRQS] =
279-
{
280-
{ TMP95C061_INTETC32, 0x80, 0x80 }, /* INTTC3 */
281-
{ TMP95C061_INTETC32, 0x08, 0x7c }, /* INTTC2 */
282-
{ TMP95C061_INTETC10, 0x80, 0x78 }, /* INTTC1 */
283-
{ TMP95C061_INTETC10, 0x08, 0x74 }, /* INTTC0 */
284-
{ TMP95C061_INTE0AD, 0x80, 0x70 }, /* INTAD */
285-
{ TMP95C061_INTES1, 0x80, 0x6c }, /* INTTX1 */
286-
{ TMP95C061_INTES1, 0x08, 0x68 }, /* INTRX1 */
287-
{ TMP95C061_INTES0, 0x80, 0x64 }, /* INTTX0 */
288-
{ TMP95C061_INTES0, 0x08, 0x60 }, /* INTRX0 */
289-
{ TMP95C061_INTET76, 0x80, 0x5c }, /* INTTR7 */
290-
{ TMP95C061_INTET76, 0x08, 0x58 }, /* INTTR6 */
291-
{ TMP95C061_INTET54, 0x80, 0x54 }, /* INTTR5 */
292-
{ TMP95C061_INTET54, 0x08, 0x50 }, /* INTTR4 */
293-
{ TMP95C061_INTET32, 0x80, 0x4c }, /* INTT3 */
294-
{ TMP95C061_INTET32, 0x08, 0x48 }, /* INTT2 */
295-
{ TMP95C061_INTET10, 0x80, 0x44 }, /* INTT1 */
296-
{ TMP95C061_INTET10, 0x08, 0x40 }, /* INTT0 */
278+
} tmp95c061_irq_vector_map[] =
279+
{
280+
{ INTETC32, 0x80, 0x80 }, /* INTTC3 */
281+
{ INTETC32, 0x08, 0x7c }, /* INTTC2 */
282+
{ INTETC10, 0x80, 0x78 }, /* INTTC1 */
283+
{ INTETC10, 0x08, 0x74 }, /* INTTC0 */
284+
{ INTE0AD, 0x80, 0x70 }, /* INTAD */
285+
{ INTES1, 0x80, 0x6c }, /* INTTX1 */
286+
{ INTES1, 0x08, 0x68 }, /* INTRX1 */
287+
{ INTES0, 0x80, 0x64 }, /* INTTX0 */
288+
{ INTES0, 0x08, 0x60 }, /* INTRX0 */
289+
{ INTET76, 0x80, 0x5c }, /* INTTR7 */
290+
{ INTET76, 0x08, 0x58 }, /* INTTR6 */
291+
{ INTET54, 0x80, 0x54 }, /* INTTR5 */
292+
{ INTET54, 0x08, 0x50 }, /* INTTR4 */
293+
{ INTET32, 0x80, 0x4c }, /* INTT3 */
294+
{ INTET32, 0x08, 0x48 }, /* INTT2 */
295+
{ INTET10, 0x80, 0x44 }, /* INTT1 */
296+
{ INTET10, 0x08, 0x40 }, /* INTT0 */
297297
/* 0x3c - reserved */
298-
{ TMP95C061_INTE67, 0x80, 0x38 }, /* INT7 */
299-
{ TMP95C061_INTE67, 0x08, 0x34 }, /* INT6 */
300-
{ TMP95C061_INTE45, 0x80, 0x30 }, /* INT5 */
301-
{ TMP95C061_INTE45, 0x08, 0x2c }, /* INT4 */
302-
{ TMP95C061_INTE0AD, 0x08, 0x28 } /* INT0 */
298+
{ INTE67, 0x80, 0x38 }, /* INT7 */
299+
{ INTE67, 0x08, 0x34 }, /* INT6 */
300+
{ INTE45, 0x80, 0x30 }, /* INT5 */
301+
{ INTE45, 0x08, 0x2c }, /* INT4 */
302+
{ INTE0AD, 0x08, 0x28 } /* INT0 */
303303
};
304+
static constexpr u8 NUM_MASKABLE_IRQS = sizeof(tmp95c061_irq_vector_map) / 3;
304305

305306

306307
int tmp95c061_device::tlcs900_process_hdma( int channel )
@@ -312,11 +313,11 @@ int tmp95c061_device::tlcs900_process_hdma( int channel )
312313
{
313314
int irq = 0;
314315

315-
while( irq < TMP95C061_NUM_MASKABLE_IRQS && tmp95c061_irq_vector_map[irq].vector != vector )
316+
while( irq < NUM_MASKABLE_IRQS && tmp95c061_irq_vector_map[irq].vector != vector )
316317
irq++;
317318

318319
/* Check if our interrupt flip-flop is set */
319-
if ( irq < TMP95C061_NUM_MASKABLE_IRQS && m_int_reg[tmp95c061_irq_vector_map[irq].reg] & tmp95c061_irq_vector_map[irq].iff )
320+
if ( irq < NUM_MASKABLE_IRQS && m_int_reg[tmp95c061_irq_vector_map[irq].reg] & tmp95c061_irq_vector_map[irq].iff )
320321
{
321322
switch( m_dmam[channel].b.l & 0x1f )
322323
{
@@ -406,16 +407,16 @@ int tmp95c061_device::tlcs900_process_hdma( int channel )
406407
switch( channel )
407408
{
408409
case 0:
409-
m_int_reg[TMP95C061_INTETC10] |= 0x08;
410+
m_int_reg[INTETC10] |= 0x08;
410411
break;
411412
case 1:
412-
m_int_reg[TMP95C061_INTETC10] |= 0x80;
413+
m_int_reg[INTETC10] |= 0x80;
413414
break;
414415
case 2:
415-
m_int_reg[TMP95C061_INTETC32] |= 0x08;
416+
m_int_reg[INTETC32] |= 0x08;
416417
break;
417418
case 3:
418-
m_int_reg[TMP95C061_INTETC32] |= 0x80;
419+
m_int_reg[INTETC32] |= 0x80;
419420
break;
420421
}
421422
}
@@ -475,7 +476,7 @@ void tmp95c061_device::tlcs900_check_irqs()
475476
}
476477

477478
/* Check regular irqs */
478-
for( i = 0; i < TMP95C061_NUM_MASKABLE_IRQS; i++ )
479+
for( i = 0; i < NUM_MASKABLE_IRQS; i++ )
479480
{
480481
if ( m_int_reg[tmp95c061_irq_vector_map[i].reg] & tmp95c061_irq_vector_map[i].iff )
481482
{
@@ -563,7 +564,7 @@ void tmp95c061_device::tlcs900_handle_ad()
563564
m_ad_mode &= ~ 0x40;
564565
m_ad_mode |= 0x80;
565566

566-
m_int_reg[TMP95C061_INTE0AD] |= 0x80;
567+
m_int_reg[INTE0AD] |= 0x80;
567568
m_check_irqs = 1;
568569

569570
/* AD repeat mode */
@@ -661,7 +662,7 @@ void tmp95c061_device::tlcs900_handle_timers()
661662
if ( ( m_t8_mode[0] & 0xc0 ) != 0x40 )
662663
{
663664
m_timer[0] = 0;
664-
m_int_reg[TMP95C061_INTET10] |= 0x08;
665+
m_int_reg[INTET10] |= 0x08;
665666
}
666667
}
667668
}
@@ -691,7 +692,7 @@ void tmp95c061_device::tlcs900_handle_timers()
691692
if ( m_timer[1] == m_t8_reg[1] )
692693
{
693694
m_timer[1] = 0;
694-
m_int_reg[TMP95C061_INTET10] |= 0x80;
695+
m_int_reg[INTET10] |= 0x80;
695696

696697
if ( m_t8_invert & 0x02 )
697698
{
@@ -738,7 +739,7 @@ void tmp95c061_device::tlcs900_handle_timers()
738739
if ( ( m_t8_mode[1] & 0xc0 ) != 0x40 )
739740
{
740741
m_timer[2] = 0;
741-
m_int_reg[TMP95C061_INTET32] |= 0x08;
742+
m_int_reg[INTET32] |= 0x08;
742743
}
743744
}
744745
}
@@ -768,7 +769,7 @@ void tmp95c061_device::tlcs900_handle_timers()
768769
if ( m_timer[3] == m_t8_reg[3] )
769770
{
770771
m_timer[3] = 0;
771-
m_int_reg[TMP95C061_INTET32] |= 0x80;
772+
m_int_reg[INTET32] |= 0x80;
772773

773774
if ( m_t8_invert & 0x20 )
774775
{
@@ -815,16 +816,16 @@ void tmp95c061_device::execute_set_input(int input, int level)
815816
{
816817
/* Leave HALT state */
817818
m_halted = 0;
818-
m_int_reg[TMP95C061_INTE0AD] |= 0x08;
819+
m_int_reg[INTE0AD] |= 0x08;
819820
}
820821
}
821822
else
822823
{
823824
/* Level detect */
824825
if ( level == ASSERT_LINE )
825-
m_int_reg[TMP95C061_INTE0AD] |= 0x08;
826+
m_int_reg[INTE0AD] |= 0x08;
826827
else
827-
m_int_reg[TMP95C061_INTE0AD] &= ~ 0x08;
828+
m_int_reg[INTE0AD] &= ~ 0x08;
828829
}
829830
}
830831
m_level[TLCS900_INT0] = level;
@@ -835,7 +836,7 @@ void tmp95c061_device::execute_set_input(int input, int level)
835836
{
836837
if ( m_level[TLCS900_INT4] == CLEAR_LINE && level == ASSERT_LINE )
837838
{
838-
m_int_reg[TMP95C061_INTE45] |= 0x08;
839+
m_int_reg[INTE45] |= 0x08;
839840
}
840841
}
841842
m_level[TLCS900_INT4] = level;
@@ -846,7 +847,7 @@ void tmp95c061_device::execute_set_input(int input, int level)
846847
{
847848
if ( m_level[TLCS900_INT5] == CLEAR_LINE && level == ASSERT_LINE )
848849
{
849-
m_int_reg[TMP95C061_INTE45] |= 0x80;
850+
m_int_reg[INTE45] |= 0x80;
850851
}
851852
}
852853
m_level[TLCS900_INT5] = level;
@@ -1262,7 +1263,7 @@ uint8_t tmp95c061_device::sc0buf_r()
12621263
void tmp95c061_device::sc0buf_w(uint8_t data)
12631264
{
12641265
// Fake finish sending data
1265-
m_int_reg[TMP95C061_INTES0] |= 0x80;
1266+
m_int_reg[INTES0] |= 0x80;
12661267
m_check_irqs = 1;
12671268
}
12681269

@@ -1307,7 +1308,7 @@ uint8_t tmp95c061_device::sc1buf_r()
13071308
void tmp95c061_device::sc1buf_w(uint8_t data)
13081309
{
13091310
// Fake finish sending data
1310-
m_int_reg[TMP95C061_INTES1] |= 0x80;
1311+
m_int_reg[INTES1] |= 0x80;
13111312
m_check_irqs = 1;
13121313
}
13131314

@@ -1364,7 +1365,7 @@ uint8_t tmp95c061_device::adreg_r(offs_t offset)
13641365
return m_ad_result[offset >> 1] >> 2;
13651366

13661367
// Reading data from the upper 8 bits clears INTE0AD IADC
1367-
m_int_reg[TMP95C061_INTE0AD] &= ~0x80;
1368+
m_int_reg[INTE0AD] &= ~0x80;
13681369
return m_ad_result[offset >> 1] << 6 | 0x3f;
13691370
}
13701371

0 commit comments

Comments
 (0)