Previous 15994 Revisions Next

r6856 Saturday 2nd January, 2010 at 09:01:22 UTC by Wilbert Pol
uPD7801 core changes:
- Fixed incorrect disassembly of some instructions.
- Updated the handling of interrupts to match the documentation.
[src/emu/cpu/upd7810]7810dasm.c 7810tbl.c upd7810.c upd7810.h

src/emu/cpu/upd7810/7810tbl.c
r6855r6856
35493549   {illegal2,      2, 8, 8,L0|L1},   {illegal2,      2, 8, 8,L0|L1},
35503550   {SK_CY,       2, 8, 8,L0|L1},   {illegal2,      2, 8, 8,L0|L1},
35513551   {SK_Z,         2, 8, 8,L0|L1},   {illegal2,      2, 8, 8,L0|L1},
3552   {PUSH_VA,      2,15,15,L0|L1},   {POP_VA,      2,15,15,L0|L1},
3552   {PUSH_VA,      2,17,17,L0|L1},   {POP_VA,      2,15,15,L0|L1},
35533553
35543554   {SKNIT_F0,      2, 8, 8,L0|L1},   {SKNIT_FT0,      2, 8, 8,L0|L1},
35553555   {SKNIT_F1,      2, 8, 8,L0|L1},   {SKNIT_F2,      2, 8, 8,L0|L1},
r6855r6856
35753575   {SLL_A,         2, 8, 8,L0|L1},   {SLR_A,       2, 8, 8,L0|L1},
35763576   {SLL_C,       2, 8, 8,L0|L1},   {SLR_C,       2, 8, 8,L0|L1},
35773577   {RLD,         2,17,17,L0|L1},   {RRD,         2,17,17,L0|L1},
3578   {illegal2,      2, 8, 8,L0|L1},   {illegal2,      2,12,12,L0|L1},
3578   {illegal2,      2, 8, 8,L0|L1},   {illegal2,      2, 8, 8,L0|L1},
35793579   {PER,         2,11,11,L0|L1},   {illegal2,      2, 8, 8,L0|L1},
35803580   {PUSH_HL,      2,17,17,L0|L1},   {POP_HL,      2,15,15,L0|L1},
35813581
src/emu/cpu/upd7810/7810dasm.c
r6855r6856
41154115
41164116   /* 0xC0 - 0xFF */
41174117   { MOV, "A,PA" },   { MOV, "A,PB" },   { MOV, "A,PC" },   { MOV, "A,MK" },
4118   { MOV, "A,MB" },   { MOV, "A,MC" },   { MOV, "A,TM0" },   { MOV, "A,TM1" },
4118   { illegal, 0 },      { illegal, 0 },      { illegal, 0 },      { illegal, 0 },
41194119   { MOV, "A,S" },      { illegal, 0 },      { illegal, 0 },      { illegal, 0 },
41204120   { illegal, 0 },      { illegal, 0 },      { illegal, 0 },      { illegal, 0 },
41214121
r6855r6856
43794379
43804380   { ACI, "PA,%b" }, { ACI, "PB,%b" }, { ACI, "PC,%b" }, { ACI, "MK,%b" },
43814381   { illegal, 0 }, { illegal, 0 }, { illegal, 0 }, { illegal, 0 },
4382   { OFFI, "PA,%b" }, { OFFI, "PB,%b" }, { OFFI, "PC,%b" }, { OFFI, "MK,%b" },
4383   { illegal, 0 }, { illegal, 0 }, { illegal, 0 }, { illegal, 0 },
4384
43824385   { SUI, "PA,%b" }, { SUI, "PB,%b" }, { SUI, "PC,%b" }, { SUI, "MK,%b" },
43834386   { illegal, 0 }, { illegal, 0 }, { illegal, 0 }, { illegal, 0 },
4384
43854387   { NEI, "PA,%b" }, { NEI, "PB,%b" }, { NEI, "PC,%b" }, { NEI, "MK,%b" },
43864388   { illegal, 0 }, { illegal, 0 }, { illegal, 0 }, { illegal, 0 },
4387   { SBI, "PA,%b" }, { SBI, "PB,%b" }, { SBI, "PC,%b" }, { SBI, "MK,%b" },
4388   { illegal, 0 }, { illegal, 0 }, { illegal, 0 }, { illegal, 0 },
43894389
43904390   { SBI, "PA,%b" }, { SBI, "PB,%b" }, { SBI, "PC,%b" }, { SBI, "MK,%b" },
43914391   { illegal, 0 }, { illegal, 0 }, { illegal, 0 }, { illegal, 0 },
r6855r6856
46004600
46014601   { 0, dasm60_7801 },   { DAA, 0 },         { RETI, 0 },      { CALB, 0 },
46024602   { 0, dasm64_7801 },   { NEIW, "%a,%b" },   { SUI, "A,%b" },   { NEI, "A,%b" },
4603   { MVI, "V,%b?" },   { MVI, "A,%b" },   { MVI, "B,%b" },   { MVI, "C,%b" },
4603   { MVI, "V,%b" },   { MVI, "A,%b" },   { MVI, "B,%b" },   { MVI, "C,%b" },
46044604   { MVI, "D,%b" },   { MVI, "E,%b" },   { MVI, "H,%b" },   { MVI, "L,%b" },
46054605
46064606   { 0, dasm70_7801 },   { MVIW, "%a,%b" },   { SOFTI, 0 },      { JB, 0 },
src/emu/cpu/upd7810/upd7810.c
r6855r6856
472472   UINT8   co1;
473473   UINT16   irr;   /* interrupt request register */
474474   UINT16   itf;   /* interrupt test flag register */
475   int      int1;   /* keep track of current int1 state. Needed for 7801 irq checking. */
476   int      int2;   /* keep track to current int2 state. Needed for 7801 irq checking. */
475477
476478/* internal helper variables */
477479   UINT16   txs;   /* transmitter shift register */
r6855r6856
538540#define INTFST   0x0400
539541#define INTER   0x0800
540542#define INTOV   0x1000
543#define INTF0   0x2000
541544
542545/* ITF flags */
543546#define INTAN4   0x0001
r6855r6856
843846   if (0 == IFF)
844847      return;
845848
846   /* check the interrupts in priority sequence */
847   if ((IRR & INTFT0)   && 0 == (MKL & 0x02))
849   switch ( cpustate->config.type )
848850   {
849       switch (cpustate->config.type)
851   case TYPE_7801:
852      /* 1 - SOFTI - vector at 0x0060 */
853      /* 2 - INT0 - Masked by MK0 bit */
854      if ( IRR & INTF0 && 0 == (MKL & 0x01 ) )
850855      {
851         case TYPE_7810_GAMEMASTER:
852            vector = 0xff2a;
853            break;
854         default:
855            vector = 0x0008;
856         irqline = UPD7810_INTF0;
857         vector = 0x0004;
858         IRR &= ~INTF0;
856859      }
857       if (!((IRR & INTFT1)   && 0 == (MKL & 0x04)))
858      IRR&=~INTFT0;
859   }
860   else
861   if ((IRR & INTFT1)   && 0 == (MKL & 0x04))
862   {
863       switch (cpustate->config.type)
860      /* 3 - INTT - Masked by MKT bit */
861      if ( IRR & INTFT0 && 0 == ( MKL & 0x02 ) )
864862      {
865         case TYPE_7810_GAMEMASTER:
866            vector = 0xff2a;
867            break;
868         default:
869            vector = 0x0008;
863         vector = 0x0008;
864         IRR &= ~INTFT0;
870865      }
871       IRR&=~INTFT1;
872   }
873   else
874   if ((IRR & INTF1)   && 0 == (MKL & 0x08))
875   {
876      irqline = UPD7810_INTF1;
877      vector = 0x0010;
878      if (!((IRR & INTF2)   && 0 == (MKL & 0x10)))
879          IRR&=~INTF1;
880   }
881   else
882   if ((IRR & INTF2)   && 0 == (MKL & 0x10))
883   {
884      irqline = UPD7810_INTF2;
885      vector = 0x0010;
886      IRR&=~INTF2;
887   }
888   else
889   if ((IRR & INTFE0)   && 0 == (MKL & 0x20))
890   {
891       switch (cpustate->config.type)
866      /* 4 - INT1 - Masked by MK1 bit */
867      if ( IRR & INTF1 && 0 == ( MKL & 0x04 ) )
892868      {
893         case TYPE_7810_GAMEMASTER:
894            vector = 0xff2d;
895            break;
896         default:
897            vector = 0x0018;
869         irqline = UPD7810_INTF1;
870         vector = 0x0010;
871         IRR &= ~INTF1;
898872      }
899       if (!((IRR & INTFE1)   && 0 == (MKL & 0x40)))
900      IRR&=~INTFE0;
901   }
902   else
903   if ((IRR & INTFE1)   && 0 == (MKL & 0x40))
904   {
905       switch (cpustate->config.type)
873      /* 5 - INT2 - Masked by MK2 bit */
874      if ( IRR & INTF2 && 0 == ( MKL & 0x08 ) )
906875      {
907          case TYPE_7810_GAMEMASTER:
908            vector = 0xff2d;
909            break;
910          default:
911            vector = 0x0018;
876         irqline = UPD7810_INTF2;
877         vector = 0x0020;
878         IRR &= ~INTF2;
912879      }
913       IRR&=~INTFE1;
880      /* 6 - INTS - Masked by MKS bit */
881      if ( IRR & INTFST && 0 == ( MKL & 0x10 ) )
882      {
883         vector = 0x0040;
884         IRR &= ~INTFST;
885      }
886      break;
887
888   default:
889      /* check the interrupts in priority sequence */
890      if ((IRR & INTFT0)   && 0 == (MKL & 0x02))
891      {
892          switch (cpustate->config.type)
893         {
894            case TYPE_7810_GAMEMASTER:
895               vector = 0xff2a;
896               break;
897            default:
898               vector = 0x0008;
899         }
900          if (!((IRR & INTFT1)   && 0 == (MKL & 0x04)))
901         IRR&=~INTFT0;
902      }
903      else
904      if ((IRR & INTFT1)   && 0 == (MKL & 0x04))
905      {
906          switch (cpustate->config.type)
907         {
908            case TYPE_7810_GAMEMASTER:
909               vector = 0xff2a;
910               break;
911            default:
912               vector = 0x0008;
913         }
914          IRR&=~INTFT1;
915      }
916      else
917      if ((IRR & INTF1)   && 0 == (MKL & 0x08))
918      {
919         irqline = UPD7810_INTF1;
920         vector = 0x0010;
921         if (!((IRR & INTF2)   && 0 == (MKL & 0x10)))
922             IRR&=~INTF1;
923      }
924      else
925      if ((IRR & INTF2)   && 0 == (MKL & 0x10))
926      {
927         irqline = UPD7810_INTF2;
928         vector = 0x0010;
929         IRR&=~INTF2;
930      }
931      else
932      if ((IRR & INTFE0)   && 0 == (MKL & 0x20))
933      {
934          switch (cpustate->config.type)
935         {
936            case TYPE_7810_GAMEMASTER:
937               vector = 0xff2d;
938               break;
939            default:
940               vector = 0x0018;
941         }
942          if (!((IRR & INTFE1)   && 0 == (MKL & 0x40)))
943         IRR&=~INTFE0;
944      }
945      else
946      if ((IRR & INTFE1)   && 0 == (MKL & 0x40))
947      {
948          switch (cpustate->config.type)
949         {
950             case TYPE_7810_GAMEMASTER:
951               vector = 0xff2d;
952               break;
953             default:
954               vector = 0x0018;
955         }
956          IRR&=~INTFE1;
957      }
958      else
959      if ((IRR & INTFEIN) && 0 == (MKL & 0x80))
960      {
961         vector = 0x0020;
962      }
963      else
964      if ((IRR & INTFAD)   && 0 == (MKH & 0x01))
965      {
966         vector = 0x0020;
967      }
968      else
969      if ((IRR & INTFSR)   && 0 == (MKH & 0x02))
970      {
971         vector = 0x0028;
972          IRR&=~INTFSR;
973      }
974      else
975      if ((IRR & INTFST)   && 0 == (MKH & 0x04))
976      {
977         vector = 0x0028;
978          IRR&=~INTFST;
979      }
980      break;
914981   }
915   else
916   if ((IRR & INTFEIN) && 0 == (MKL & 0x80))
917   {
918      vector = 0x0020;
919   }
920   else
921   if ((IRR & INTFAD)   && 0 == (MKH & 0x01))
922   {
923      vector = 0x0020;
924   }
925   else
926   if ((IRR & INTFSR)   && 0 == (MKH & 0x02))
927   {
928      vector = 0x0028;
929       IRR&=~INTFSR;
930   }
931   else
932   if ((IRR & INTFST)   && 0 == (MKH & 0x04))
933   {
934      vector = 0x0028;
935       IRR&=~INTFST;
936   }
982
937983   if (vector)
938984   {
939985      /* acknowledge external IRQ */
r6855r6856
17041750   state_save_register_device_item(device, 0, cpustate->ovcf);
17051751   state_save_register_device_item(device, 0, cpustate->ovcs);
17061752   state_save_register_device_item(device, 0, cpustate->edges);
1753   state_save_register_device_item(device, 0, cpustate->int1);
1754   state_save_register_device_item(device, 0, cpustate->int2);
17071755}
17081756
17091757#include "7810tbl.c"
r6855r6856
18981946
18991947static void set_irq_line(upd7810_state *cpustate, int irqline, int state)
19001948{
1901   if (state != CLEAR_LINE)
1949   /* The uPD7801 can check for falling and rising edges changes on the INT2 input */
1950   switch ( cpustate->config.type )
19021951   {
1903      if (irqline == INPUT_LINE_NMI)
1952   case TYPE_7801:
1953      switch ( irqline )
19041954      {
1905         /* no nested NMIs ? */
1906//          if (0 == (IRR & INTNMI))
1955      case UPD7810_INTF0:
1956         /* INT0 is level sensitive */
1957         if ( state == ASSERT_LINE )
1958            IRR |= INTF0;
1959         else
1960            IRR &= INTF0;
1961         break;
1962
1963      case UPD7810_INTF1:
1964         /* INT1 is rising edge sensitive */
1965         if ( cpustate->int1 == CLEAR_LINE && state == ASSERT_LINE )
1966            IRR |= INTF1;
1967
1968         cpustate->int1 = state;
1969         break;
1970
1971      case UPD7810_INTF2:
1972         /* INT2 is rising or falling edge sensitive */
1973         /* Check if the ES bit is set then check for rising edge, otherwise falling edge */
1974         if ( MKL & 0x20 )
19071975         {
1908               IRR |= INTNMI;
1909            SP--;
1910            WM( SP, PSW );
1911            SP--;
1912            WM( SP, PCH );
1913            SP--;
1914            WM( SP, PCL );
1915            IFF = 0;
1916            PSW &= ~(SK|L0|L1);
1917            PC = 0x0004;
1976            if ( cpustate->int2 == CLEAR_LINE && state == ASSERT_LINE )
1977            {
1978               IRR |= INTF2;
1979            }
19181980         }
1981         else
1982         {
1983            if ( cpustate->int2 == ASSERT_LINE && state == CLEAR_LINE )
1984            {
1985               IRR |= INTF2;
1986            }
1987         }
1988         cpustate->int2 = state;
1989         break;
19191990      }
1920      else
1921      if (irqline == UPD7810_INTF1)
1922         IRR |= INTF1;
1923      else
1924      if (irqline == UPD7810_INTF2)
1925         IRR |= INTF2;
1926      // gamemaster hack
1927      else
1928      if (irqline == UPD7810_INTFE1)
1929         IRR |= INTFE1;
1930      else
1931         logerror("upd7810_set_irq_line invalid irq line #%d\n", irqline);
1991      break;
1992
1993   default:
1994      if (state != CLEAR_LINE)
1995      {
1996         if (irqline == INPUT_LINE_NMI)
1997         {
1998            /* no nested NMIs ? */
1999//              if (0 == (IRR & INTNMI))
2000            {
2001               IRR |= INTNMI;
2002               SP--;
2003               WM( SP, PSW );
2004               SP--;
2005               WM( SP, PCH );
2006               SP--;
2007               WM( SP, PCL );
2008               IFF = 0;
2009               PSW &= ~(SK|L0|L1);
2010               PC = 0x0004;
2011            }
2012         }
2013         else
2014         if (irqline == UPD7810_INTF1)
2015            IRR |= INTF1;
2016         else
2017         if ( irqline == UPD7810_INTF2 && ( MKL & 0x20 ) )
2018            IRR |= INTF2;
2019         // gamemaster hack
2020         else
2021         if (irqline == UPD7810_INTFE1)
2022            IRR |= INTFE1;
2023         else
2024            logerror("upd7810_set_irq_line invalid irq line #%d\n", irqline);
2025      }
2026      /* resetting interrupt requests is done with the SKIT/SKNIT opcodes only! */
19322027   }
1933   /* resetting interrupt requests is done with the SKIT/SKNIT opcodes only! */
19342028}
19352029
19362030
src/emu/cpu/upd7810/upd7810.h
r6855r6856
6969/* IRQ lines */
7070#define UPD7810_INTF1      0
7171#define UPD7810_INTF2      1
72#define UPD7810_INTF0      2
7273#define UPD7810_INTFE1      4
7374
7475CPU_GET_INFO( upd7810 );

Previous 15994 Revisions Next


© 1998-2018 The MESS Team