trunk/src/emu/machine/mcf5206e.c
| r22656 | r22657 | |
| 5 | 5 | #include "emu.h" |
| 6 | 6 | #include "mcf5206e.h" |
| 7 | 7 | |
| 8 | void CLIB_DECL nolog(const char *format, ...) {} |
| 9 | |
| 8 | 10 | //#define debuglog printf |
| 9 | 11 | #define debuglog logerror |
| 10 | 12 | |
| 11 | 13 | #define invalidlog printf |
| 12 | 14 | //#define invalidlog logerror |
| 13 | 15 | |
| 16 | //#define debuglogtimer printf |
| 17 | //#define debuglogtimer logerror |
| 18 | #define debuglogtimer nolog |
| 14 | 19 | |
| 15 | 20 | static ADDRESS_MAP_START( coldfire_regs_map, AS_0, 32, mcf5206e_peripheral_device ) |
| 16 | 21 | |
| r22656 | r22657 | |
| 652 | 657 | debuglog("(Unused bits) : %01x\n", (ICR&0x60)>>5); |
| 653 | 658 | } |
| 654 | 659 | |
| 655 | | /* The timer module seems practically the same as the 68307 one, possibly make into a common device once the code isn't a hardcoded piece of junk ;-) */ |
| 656 | 660 | |
| 661 | |
| 657 | 662 | TIMER_CALLBACK_MEMBER(mcf5206e_peripheral_device::timer1_callback) |
| 658 | 663 | { |
| 659 | 664 | UINT8 ICR = m_ICR[ICR9]; |
| r22656 | r22657 | |
| 664 | 669 | if (!(m_IMR & 0x0200)) m_cpu->set_input_line((ICR&0x1c)>>2, HOLD_LINE); |
| 665 | 670 | } |
| 666 | 671 | |
| 667 | | debuglog("timer1_callback\n"); |
| 672 | debuglogtimer("timer1_callback\n"); |
| 673 | m_TER1 |= 0x02; |
| 668 | 674 | |
| 669 | 675 | timer1->adjust(attotime::from_msec(10)); // completely made up value just to fire our timers for now |
| 670 | 676 | } |
| r22656 | r22657 | |
| 675 | 681 | switch (offset) |
| 676 | 682 | { |
| 677 | 683 | case 0: |
| 678 | | debuglog("%s: TMR1_r %04x\n", this->machine().describe_context(), mem_mask); |
| 684 | debuglogtimer("%s: TMR1_r %04x\n", this->machine().describe_context(), mem_mask); |
| 679 | 685 | return m_TMR1; |
| 680 | 686 | case 1: |
| 681 | 687 | invalidlog("%s: invalid TMR1_r %d %04x\n", this->machine().describe_context(), offset, mem_mask); |
| r22656 | r22657 | |
| 691 | 697 | { |
| 692 | 698 | case 0: |
| 693 | 699 | COMBINE_DATA(&m_TMR1); |
| 694 | | debuglog("%s: TMR1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask); |
| 700 | debuglogtimer("%s: TMR1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask); |
| 695 | 701 | |
| 696 | | debuglog(" (Prescale) PS : %02x (Capture Edge/Interrupt) CE : %01x (Output Mode) OM : %01x (Output Reference Interrupt En) ORI : %01x Free Run (FRR) : %01x Input Clock Source (ICLK) : %01x (Reset Timer) RST : %01x \n", (m_TMR1 & 0xff00)>>8, (m_TMR1 & 0x00c0)>>6, (m_TMR1 & 0x0020)>>5, (m_TMR1 & 0x0010)>>4, (m_TMR1 & 0x0008)>>3, (m_TMR1 & 0x0006)>>1, (m_TMR1 & 0x0001)>>0); |
| 702 | debuglogtimer(" (Prescale) PS : %02x (Capture Edge/Interrupt) CE : %01x (Output Mode) OM : %01x (Output Reference Interrupt En) ORI : %01x Free Run (FRR) : %01x Input Clock Source (ICLK) : %01x (Reset Timer) RST : %01x \n", (m_TMR1 & 0xff00)>>8, (m_TMR1 & 0x00c0)>>6, (m_TMR1 & 0x0020)>>5, (m_TMR1 & 0x0010)>>4, (m_TMR1 & 0x0008)>>3, (m_TMR1 & 0x0006)>>1, (m_TMR1 & 0x0001)>>0); |
| 697 | 703 | |
| 698 | 704 | if (m_TMR1 & 0x0001) |
| 699 | 705 | { |
| r22656 | r22657 | |
| 718 | 724 | switch (offset) |
| 719 | 725 | { |
| 720 | 726 | case 0: |
| 721 | | debuglog("%s: TRR1_r %04x\n", this->machine().describe_context(), mem_mask); |
| 727 | debuglogtimer("%s: TRR1_r %04x\n", this->machine().describe_context(), mem_mask); |
| 722 | 728 | return m_TRR1; |
| 723 | 729 | case 1: |
| 724 | 730 | invalidlog("%s: invalid TRR1_r %d %04x\n", this->machine().describe_context(), offset, mem_mask); |
| r22656 | r22657 | |
| 734 | 740 | { |
| 735 | 741 | case 0: |
| 736 | 742 | COMBINE_DATA(&m_TRR1); |
| 737 | | debuglog("%s: TRR1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask); |
| 743 | debuglogtimer("%s: TRR1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask); |
| 738 | 744 | break; |
| 739 | 745 | case 1: |
| 740 | 746 | debuglog("%s: invalid TRR1_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask); |
| r22656 | r22657 | |
| 750 | 756 | switch (offset) |
| 751 | 757 | { |
| 752 | 758 | case 1: |
| 753 | | debuglog("%s: TER1_r\n", this->machine().describe_context()); |
| 754 | | return 2; // hack, timer events should set bits, this just stops the code going crazy for now |
| 759 | debuglogtimer("%s: TER1_r\n", this->machine().describe_context()); |
| 760 | return m_TER1; // set on timer events, cleared by writing below |
| 755 | 761 | case 0: |
| 756 | 762 | case 2: |
| 757 | 763 | case 3: |
| r22656 | r22657 | |
| 767 | 773 | switch (offset) |
| 768 | 774 | { |
| 769 | 775 | case 1: |
| 770 | | m_TER1 = data; // writes should clear the bits.. |
| 771 | | debuglog("%s: TER1_w %02x\n", this->machine().describe_context(), data); |
| 776 | m_TER1 &= ~data; // writes should clear the bits.. |
| 777 | debuglogtimer("%s: TER1_w %02x\n", this->machine().describe_context(), data); |
| 772 | 778 | break; |
| 773 | 779 | case 0: |
| 774 | 780 | case 2: |
| r22656 | r22657 | |
| 784 | 790 | switch (offset) |
| 785 | 791 | { |
| 786 | 792 | case 0: |
| 787 | | debuglog("%s: TCN1_r %04x\n", this->machine().describe_context(), mem_mask); |
| 788 | | return machine().rand(); // 0x8ca0 -1;// m_TCN1; // this should be the counter, code has a hardcoded >= check against 8ca0. |
| 793 | debuglogtimer("%s: TCN1_r %04x\n", this->machine().describe_context(), mem_mask); |
| 794 | // return 0x9c40; |
| 795 | return 0x8ca0 -1;// m_TCN1; // this should be the counter, code has a hardcoded >= check against 8ca0. |
| 789 | 796 | case 1: |
| 790 | 797 | invalidlog("%s: invalid TCN1_r %d %04x\n", this->machine().describe_context(), offset, mem_mask); |
| 791 | 798 | return 0; |
| r22656 | r22657 | |
| 800 | 807 | { |
| 801 | 808 | case 0: |
| 802 | 809 | COMBINE_DATA(&m_TCN1); |
| 803 | | debuglog("%s: TCN1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask); |
| 810 | debuglogtimer("%s: TCN1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask); |
| 804 | 811 | break; |
| 805 | 812 | case 1: |
| 806 | 813 | invalidlog("%s: invalid TCN1_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask); |