~ubuntu-branches/ubuntu/lucid/sdlmame/lucid

« back to all changes in this revision

Viewing changes to src/emu/cpu/dsp56k/dsp56pcu.c

  • Committer: Bazaar Package Importer
  • Author(s): Cesare Falco
  • Date: 2009-11-03 17:10:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091103171015-6hop4ory5lxnumpn
Tags: 0.135-0ubuntu1
* New upstream release - Closes (LP: #403212)
* debian/watch: unstable releases are no longer detected
* mame.ini: added the cheat subdirectories to cheatpath so zipped
  cheatfiles will be searched too
* renamed crsshair subdirectory to crosshair to reflect upstream change
* mame.ini: renamed references to crosshair subdirectory (see above)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Status Register */
 
1
/* ************************************************************************* */
 
2
/*                            Status Register                                */
 
3
/* ************************************************************************* */
 
4
/*                   MR                                  CCR                 */
 
5
/* |-------------------------------------| |-------------------------------| */
 
6
/* | LF | FV | * | * | S1 | S0 | I1 | I0 | | S | L | E | U | N | Z | V | C | */
 
7
/* |-------------------------------------| |-------------------------------| */
 
8
/*                                                                           */
 
9
/* ************************************************************************* */
2
10
static UINT8 LF_bit(dsp56k_core* cpustate) { return (SR & 0x8000) >> 15; }
3
11
static UINT8 FV_bit(dsp56k_core* cpustate) { return (SR & 0x4000) >> 14; }
4
 
//static UINT8 S_bits(dsp56k_core* cpustate); #define s1BIT ((SR & 0x0800) != 0) #define s0BIT ((SR & 0x0400) != 0)
5
 
static UINT8 I_bits(dsp56k_core* cpustate) { return (SR & 0x0300) >> 8; }
6
 
static UINT8 S_bit(dsp56k_core* cpustate)  { return (SR & 0x0080) >> 7; }
7
 
static UINT8 L_bit(dsp56k_core* cpustate)  { return (SR & 0x0040) >> 6; }
8
 
static UINT8 E_bit(dsp56k_core* cpustate)  { return (SR & 0x0020) >> 5; }
9
 
static UINT8 U_bit(dsp56k_core* cpustate)  { return (SR & 0x0010) >> 4; }
10
 
static UINT8 N_bit(dsp56k_core* cpustate)  { return (SR & 0x0008) >> 3; }
11
 
static UINT8 Z_bit(dsp56k_core* cpustate)  { return (SR & 0x0004) >> 2; }
12
 
static UINT8 V_bit(dsp56k_core* cpustate)  { return (SR & 0x0002) >> 1; }
13
 
static UINT8 C_bit(dsp56k_core* cpustate)  { return (SR & 0x0001) >> 0; }
14
 
 
15
 
static void LF_bit_set(dsp56k_core* cpustate, UINT8 value)
16
 
{
17
 
        value = value & 0x01;
18
 
        SR &= ~(0x8000);
19
 
        SR |=  (value << 15);
20
 
}
21
 
static void FV_bit_set(dsp56k_core* cpustate, UINT8 value)
22
 
{
23
 
        value = value & 0x01;
24
 
        SR &= ~(0x4000);
25
 
        SR |=  (value << 14);
26
 
}
27
 
static void S_bits_set(dsp56k_core* cpustate, UINT8 value)
28
 
{
29
 
        value = value & 0x03;
30
 
        SR &= ~(0x0c00);
31
 
        SR |=  (value << 10);
32
 
}
33
 
static void I_bits_set(dsp56k_core* cpustate, UINT8 value)
34
 
{
35
 
        value = value & 0x03;
36
 
        SR &= ~(0x0300);
37
 
        SR |=  (value << 8);
38
 
}
39
 
static void S_bit_set(dsp56k_core* cpustate, UINT8 value)
40
 
{
41
 
        value = value & 0x01;
42
 
        SR &= ~(0x0080);
43
 
        SR |=  (value << 7);
44
 
}
45
 
static void L_bit_set(dsp56k_core* cpustate, UINT8 value)
46
 
{
47
 
        value = value & 0x01;
48
 
        SR &= ~(0x0040);
49
 
        SR |=  (value << 6);
50
 
}
51
 
static void E_bit_set(dsp56k_core* cpustate, UINT8 value)
52
 
{
53
 
        value = value & 0x01;
54
 
        SR &= ~(0x0020);
55
 
        SR |=  (value << 5);
56
 
}
57
 
static void U_bit_set(dsp56k_core* cpustate, UINT8 value)
58
 
{
59
 
        value = value & 0x01;
60
 
        SR &= ~(0x0010);
61
 
        SR |=  (value << 4);
62
 
}
63
 
static void N_bit_set(dsp56k_core* cpustate, UINT8 value)
64
 
{
65
 
        value = value & 0x01;
66
 
        SR &= ~(0x0008);
67
 
        SR |=  (value << 3);
68
 
}
69
 
static void Z_bit_set(dsp56k_core* cpustate, UINT8 value)
70
 
{
71
 
        value = value & 0x01;
72
 
        SR &= ~(0x0004);
73
 
        SR |=  (value << 2);
74
 
}
75
 
static void V_bit_set(dsp56k_core* cpustate, UINT8 value)
76
 
{
77
 
        value = value & 0x01;
78
 
        SR &= ~(0x0002);
79
 
        SR |=  (value << 1);
80
 
}
81
 
static void C_bit_set(dsp56k_core* cpustate, UINT8 value)
82
 
{
83
 
        value = value & 0x01;
84
 
        SR &= ~(0x0001);
85
 
        SR |=  (value << 0);
86
 
}
87
 
 
88
 
/* Operating Mode Register */
89
 
// static UINT8 MC_bit(dsp56k_core* cpustate) { return ((OMR & 0x0004) != 0); } // #define mcBIT ((OMR & 0x0004) != 0)
90
 
static UINT8 MB_bit(dsp56k_core* cpustate) { return ((OMR & 0x0002) != 0); } // #define mbBIT ((OMR & 0x0002) != 0)
91
 
static UINT8 MA_bit(dsp56k_core* cpustate) { return ((OMR & 0x0001) != 0); } // #define maBIT ((OMR & 0x0001) != 0)
 
12
// static UINT8 S_bits(dsp56k_core* cpustate) { return (SR & 0x0c00) >> 10; }
 
13
static UINT8 I_bits(dsp56k_core* cpustate) { return (SR & 0x0300) >> 8;  }
 
14
static UINT8 S_bit (dsp56k_core* cpustate) { return (SR & 0x0080) >> 7;  }
 
15
static UINT8 L_bit (dsp56k_core* cpustate) { return (SR & 0x0040) >> 6;  }
 
16
static UINT8 E_bit (dsp56k_core* cpustate) { return (SR & 0x0020) >> 5;  }
 
17
static UINT8 U_bit (dsp56k_core* cpustate) { return (SR & 0x0010) >> 4;  }
 
18
static UINT8 N_bit (dsp56k_core* cpustate) { return (SR & 0x0008) >> 3;  }
 
19
static UINT8 Z_bit (dsp56k_core* cpustate) { return (SR & 0x0004) >> 2;  }
 
20
static UINT8 V_bit (dsp56k_core* cpustate) { return (SR & 0x0002) >> 1;  }
 
21
static UINT8 C_bit (dsp56k_core* cpustate) { return (SR & 0x0001) >> 0;  }
 
22
 
 
23
/* MR setters */
 
24
static void LF_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x8000); else (SR &= (~0x8000)); }
 
25
static void FV_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x4000); else (SR &= (~0x4000)); }
 
26
static void S_bits_set(dsp56k_core* cpustate, UINT8 value) { value = value & 0x03;  SR &= ~(0x0c00);  SR |= (value << 10); }
 
27
static void I_bits_set(dsp56k_core* cpustate, UINT8 value) { value = value & 0x03;  SR &= ~(0x0300);  SR |= (value <<  8); }
 
28
 
 
29
/* CCR setters */
 
30
static void S_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0080); else (SR &= (~0x0080)); }
 
31
static void L_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0040); else (SR &= (~0x0040)); }
 
32
static void E_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0020); else (SR &= (~0x0020)); }
 
33
static void U_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0010); else (SR &= (~0x0010)); }
 
34
static void N_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0008); else (SR &= (~0x0008)); }
 
35
static void Z_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0004); else (SR &= (~0x0004)); }
 
36
static void V_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0002); else (SR &= (~0x0002)); }
 
37
static void C_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (SR |= 0x0001); else (SR &= (~0x0001)); }
 
38
 
 
39
 
 
40
 
 
41
/* ************************************************************************* */
 
42
/*                        Operating Mode Register                            */
 
43
/* ************************************************************************* */
 
44
/*                                                                           */
 
45
/*  |---------------------------------------------------------------------|  */
 
46
/*  | * | * | * | * | * | * | * | * | CD | SD | R | SA | * | MC | MB | MA |  */
 
47
/*  |---------------------------------------------------------------------|  */
 
48
/*                                                                           */
 
49
/* ************************************************************************* */
 
50
// static UINT8 CD_bit(dsp56k_core* cpustate) { return ((OMR & 0x0080) != 0); }
 
51
// static UINT8 SD_bit(dsp56k_core* cpustate) { return ((OMR & 0x0040) != 0); }
 
52
// static UINT8  R_bit(dsp56k_core* cpustate) { return ((OMR & 0x0020) != 0); }
 
53
// static UINT8 SA_bit(dsp56k_core* cpustate) { return ((OMR & 0x0010) != 0); }
 
54
// static UINT8 MC_bit(dsp56k_core* cpustate) { return ((OMR & 0x0004) != 0); }
 
55
static UINT8 MB_bit(dsp56k_core* cpustate) { return ((OMR & 0x0002) != 0); }
 
56
static UINT8 MA_bit(dsp56k_core* cpustate) { return ((OMR & 0x0001) != 0); }
92
57
 
93
58
static void CD_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0080); else (OMR &= (~0x0080)); }
94
59
static void SD_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0040); else (OMR &= (~0x0040)); }
95
 
static void R_bit_set(dsp56k_core* cpustate, UINT8 value)  { if (value) (OMR |= 0x0020); else (OMR &= (~0x0020)); }
 
60
static void  R_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0020); else (OMR &= (~0x0020)); }
96
61
static void SA_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0010); else (OMR &= (~0x0010)); }
97
62
static void MC_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0004); else (OMR &= (~0x0004)); }
98
63
static void MB_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0002); else (OMR &= (~0x0002)); }
99
64
static void MA_bit_set(dsp56k_core* cpustate, UINT8 value) { if (value) (OMR |= 0x0001); else (OMR &= (~0x0001)); }
100
65
 
101
 
 
102
 
/* Stack Pointer */
103
 
static UINT8 UF_bit(dsp56k_core* cpustate) { return (SP & 0x0020) >> 5; }
104
 
static UINT8 SE_bit(dsp56k_core* cpustate) { return (SP & 0x0010) >> 4; }
 
66
static UINT8 dsp56k_operating_mode(dsp56k_core* cpustate)
 
67
{
 
68
        return ((MB_bit(cpustate) << 1) | MA_bit(cpustate));
 
69
}
 
70
 
 
71
 
 
72
 
 
73
/* ************************************************************************* */
 
74
/*                             Stack Pointer                                 */
 
75
/* ************************************************************************* */
 
76
/*                                                                           */
 
77
/*  |---------------------------------------------------------------------|  */
 
78
/*  | * | * | * | * | * | * | * | * | * | * | UF | SE | P3 | P2 | P1 | P0 |  */
 
79
/*  |---------------------------------------------------------------------|  */
 
80
/*                                                                           */
 
81
/* ************************************************************************* */
 
82
static UINT8 UF_bit(dsp56k_core* cpustate) { return ((SP & 0x0020) != 0); }
 
83
static UINT8 SE_bit(dsp56k_core* cpustate) { return ((SP & 0x0010) != 0); }
105
84
 
106
85
//static void UF_bit_set(dsp56k_core* cpustate, UINT8 value) {};
107
86
//static void SE_bit_set(dsp56k_core* cpustate, UINT8 value) {};
108
87
 
109
88
 
110
 
static UINT8 dsp56k_operating_mode(dsp56k_core* cpustate)
111
 
{
112
 
        return ((MB_bit(cpustate) << 1) | MA_bit(cpustate));
113
 
}
114
 
 
115
 
 
 
89
 
 
90
/***************************************************************************
 
91
    INITIALIZATION AND RESET
 
92
***************************************************************************/
116
93
static void pcu_init(dsp56k_core* cpustate)
117
94
{
118
95
        // Init the irq table
276
253
                // 1-12 Make sure you're not masked out against the Interrupt Mask Bits (disabled is handled for free here)
277
254
                if (priority >= I_bits(cpustate))
278
255
                {
 
256
                        // TODO: Implement long interrupts & fast interrupts correctly!
 
257
                        //       Right now they are handled in the JSR & BSR ops.  SupahLame.
 
258
                        cpustate->ppc = PC;
 
259
 
279
260
                        // Are you anything but the Host Command interrupt?
280
261
                        if (interrupt_index != 22)
281
262
                        {
287
268
                                // The host command input has a floating vector.
288
269
                                const UINT16 irq_vector = HV_bits(cpustate) << 1;
289
270
 
290
 
                                cpustate->ppc = PC;
291
271
                                PC = irq_vector;
292
272
 
293
273
                                // TODO: 5-9 5-11 Gotta' Clear HC (HCP gets it too) when taking this exception!
299
279
        dsp56k_clear_pending_interrupts(cpustate);
300
280
}
301
281
 
302
 
//
303
 
// The function the CPU core will call to add an interrupt to the list
304
 
// (The API as it were)
305
 
//
 
282
 
 
283
/* Register an interrupt  */
306
284
static void dsp56k_add_pending_interrupt(dsp56k_core* cpustate, const char* name)
307
285
{
308
286
        int i;
318
296
        }
319
297
}
320
298
 
 
299
/* Utility function to construct IRQ table */
321
300
static void dsp56k_set_irq_source(UINT8 irq_num, UINT16 iv, const char* source)
322
301
{
323
302
        dsp56k_interrupt_sources[irq_num].irq_vector = iv;
324
303
        strcpy(dsp56k_interrupt_sources[irq_num].irq_source, source);
325
304
}
326
305
 
327
 
// 1-14 + 1-18
 
306
/* Construct a table containing pertient IRQ information */
328
307
static void dsp56k_irq_table_init(void)
329
308
{
 
309
        // 1-14 + 1-18
330
310
        // TODO: Cull host command stuff appropriately
331
311
        /* array index . vector . token */
332
312
        dsp56k_set_irq_source(0,  0x0000, "Hardware RESET");
363
343
        dsp56k_set_irq_source(31, 0x003e, "Host Command 8");
364
344
}
365
345
 
 
346
/* Clear all entries from the pending table */
366
347
static void dsp56k_clear_pending_interrupts(dsp56k_core* cpustate)
367
348
{
368
349
        int i;
372
353
        }
373
354
}
374
355
 
 
356
/* Recover number of pending irqs */
375
357
static int dsp56k_count_pending_interrupts(dsp56k_core* cpustate)
376
358
{
377
359
        int numI = 0;
383
365
        return numI;
384
366
}
385
367
 
 
368
/* Sort the pending irqs by priority */
386
369
static void dsp56k_sort_pending_interrupts(dsp56k_core* cpustate, int num)
387
370
{
388
371
        int i, j;
419
402
        // TODO: 1-17 Now sort each of the priority levels within their categories.
420
403
}
421
404
 
 
405
/* Given an index into the irq table, return the interrupt's current priority */
422
406
static INT8 dsp56k_get_irq_priority(dsp56k_core* cpustate, int index)
423
407
{
424
408
        // 1-12
466
450
        return -1;
467
451
}
468
452
 
 
453
/* Given an IRQ name, return its index in the irq table */
469
454
static int dsp56k_get_irq_index_by_tag(const char* tag)
470
455
{
471
456
        int i;