Previous 199869 Revisions Next

r17630 Tuesday 4th September, 2012 at 09:20:01 UTC by Curt Coder
m6502: Fixed CPU peripheral port behavior by introducing pull-up and pull-down masks to the CPU interface. [Curt Coder]
(MESS) c64: Fixed CPU port, tsuit215 CPUPORT test passes now. [Curt Coder]
[src/emu/cpu/m6502]m6502.c m6502.h
[src/mess/drivers]c64.c

trunk/src/emu/cpu/m6502/m6502.c
r17629r17630
8080   write8_space_func wrmem_id;               /* writemem callback for indexed instructions */
8181
8282   UINT8    ddr;
83   UINT8    port;
83   UINT8    port;
84   UINT8    mask;
85   UINT8    pullup;
86   UINT8    pulldown;
8487
8588   devcb_resolved_read8   in_port_func;
8689   devcb_resolved_write8   out_port_func;
r17629r17630
154157
155158      cpustate->in_port_func.resolve(intf->in_port_func, *device);
156159      cpustate->out_port_func.resolve(intf->out_port_func, *device);
160      cpustate->pullup = intf->external_port_pullup;
161      cpustate->pulldown = intf->external_port_pulldown;
157162   }
158163   else
159164   {
160165      devcb_write8 nullcb = DEVCB_NULL;
161166      cpustate->out_port_func.resolve(nullcb, *device);
167      cpustate->pullup = 0;
168      cpustate->pulldown = 0;
162169   }
163170
164171   device->save_item(NAME(cpustate->pc.w.l));
r17629r17630
176183   if (subtype == SUBTYPE_6510)
177184   {
178185      device->save_item(NAME(cpustate->port));
186      device->save_item(NAME(cpustate->mask));
179187      device->save_item(NAME(cpustate->ddr));
188      device->save_item(NAME(cpustate->pullup));
189      device->save_item(NAME(cpustate->pulldown));
180190   }
181191}
182192
r17629r17630
355365
356366   CPU_RESET_CALL(m6502);
357367   cpustate->port = 0xff;
368   cpustate->mask = 0xff;
358369   cpustate->ddr = 0x00;
359370}
360371
r17629r17630
374385      case 0x0000:   /* DDR */
375386         result = cpustate->ddr;
376387         break;
388
377389      case 0x0001:   /* Data Port */
378         result = cpustate->in_port_func(cpustate->ddr);
379         result = (cpustate->ddr & cpustate->port) | (~cpustate->ddr & result);
390         {
391            UINT8 input = cpustate->in_port_func(0) & ~cpustate->ddr;
392            UINT8 mask = cpustate->mask & ~cpustate->ddr;
393            UINT8 output = cpustate->port & cpustate->ddr;
394            UINT8 pulldown = ~(cpustate->pulldown & ~cpustate->ddr);
395
396            result = (input | mask | output) & pulldown;
397         }
380398         break;
381399   }
400
382401   return result;
383402}
384403
r17629r17630
389408   switch(offset)
390409   {
391410      case 0x0000:   /* DDR */
392         cpustate->ddr = data;
411         if (cpustate->ddr != data)
412         {
413            cpustate->ddr = data;
414            cpustate->mask = cpustate->port;
415         }
393416         break;
417
394418      case 0x0001:   /* Data Port */
395419         cpustate->port = data;
396420         break;
397421   }
398422
399   cpustate->out_port_func(cpustate->ddr, cpustate->port & cpustate->ddr);
423   UINT8 output = (cpustate->port & cpustate->ddr) | (cpustate->pullup & ~cpustate->ddr);
424
425   cpustate->out_port_func(0, output);
426
427   // TODO assert write with floating data lines
428   //WRMEM(offset, 0xff);
400429}
401430
402431static ADDRESS_MAP_START(m6510_mem, AS_PROGRAM, 8, legacy_cpu_device)
trunk/src/emu/cpu/m6502/m6502.h
r17629r17630
5353
5454
5555/* Optional interface to set callbacks */
56#define M6510_INTERFACE(name) \
57      const m6502_interface (name) =
58
5659typedef struct _m6502_interface m6502_interface;
5760struct _m6502_interface
5861{
r17629r17630
6063   write8_space_func      write_indexed_func;
6164   devcb_read8            in_port_func;
6265   devcb_write8         out_port_func;
66   UINT8               external_port_pullup;
67   UINT8               external_port_pulldown;
6368};
6469
6570DECLARE_LEGACY_CPU_DEVICE(M6502, m6502);
trunk/src/mess/drivers/c64.c
r17629r17630
22
33    TODO:
44
5   - floating bus writes to peripheral registers in m6502.c
56   - sort out kernals between PAL/NTSC
67    - tsuit215 test failures
7
8        - CPUPORT (0=FF 1=FF 0=00 1=FF 1=FF 1=FF, AFTER 00 17, RIGHT 00 DF)
98        - IRQ (WRONG $DC0D)
109        - NMI (WRONG $DD0D)
1110        - all CIA tests
r17629r17630
188187
189188   bankswitch(offset, va, rw, aec, ba, cas, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh);
190189
190   if (offset < 0x0002)
191   {
192      // write to internal CPU register
193      data = m_vic->bus_r();
194   }
195
191196   if (!casram)
192197   {
193198      m_ram->pointer()[offset] = data;
r17629r17630
658663        P0      1
659664        P1      1
660665        P2      1
661        P3
666        P3     
662667        P4      CASS SENS
663        P5
668        P5      0
664669
665670    */
666671
r17629r17630
686691
687692    */
688693
689   // HACK apply pull-up resistors
690   data |= (offset ^ 0x07) & 0x07;
691
694    // memory banking
692695   m_loram = BIT(data, 0);
693696   m_hiram = BIT(data, 1);
694697   m_charen = BIT(data, 2);
r17629r17630
700703   m_cassette->motor_w(BIT(data, 5));
701704}
702705
703static const m6502_interface cpu_intf =
706static M6510_INTERFACE( cpu_intf )
704707{
705708   NULL,
706709   NULL,
707710   DEVCB_DRIVER_MEMBER(c64_state, cpu_r),
708   DEVCB_DRIVER_MEMBER(c64_state, cpu_w)
711   DEVCB_DRIVER_MEMBER(c64_state, cpu_w),
712   0x17,
713   0x20
709714};
710715
711716
r17629r17630
722727        P0      1
723728        P1      1
724729        P2      1
725        P3      1
726        P4      1
727        P5      1
730        P3     
731        P4     
732        P5     
728733
729734    */
730735
731   return 0x3f;
736   return 0x07;
732737}
733738
734739WRITE8_MEMBER( sx64_state::cpu_w )
r17629r17630
746751
747752    */
748753
749   // HACK apply pull-up resistors
750   data |= (offset ^ 0x07) & 0x07;
751
754    // memory banking
752755   m_loram = BIT(data, 0);
753756   m_hiram = BIT(data, 1);
754757   m_charen = BIT(data, 2);
755758}
756759
757static const m6502_interface sx64_cpu_intf =
760static M6510_INTERFACE( sx64_cpu_intf )
758761{
759762   NULL,
760763   NULL,
761764   DEVCB_DRIVER_MEMBER(sx64_state, cpu_r),
762   DEVCB_DRIVER_MEMBER(sx64_state, cpu_w)
765   DEVCB_DRIVER_MEMBER(sx64_state, cpu_w),
766   0x07,
767   0x00
763768};
764769
765770
r17629r17630
776781        P0      1
777782        P1      1
778783        P2      1
779        P3      1
780        P4      1
781        P5      1
784        P3     
785        P4     
786        P5     
782787
783788    */
784789
785   return 0x3f;
790   return 0x07;
786791}
787792
788793WRITE8_MEMBER( c64gs_state::cpu_w )
r17629r17630
800805
801806    */
802807
803   // HACK apply pull-up resistors
804   data |= (offset ^ 0x07) & 0x07;
805
808    // memory banking
806809   m_loram = BIT(data, 0);
807810   m_hiram = BIT(data, 1);
808811   m_charen = BIT(data, 2);
r17629r17630
813816   NULL,
814817   NULL,
815818   DEVCB_DRIVER_MEMBER(c64gs_state, cpu_r),
816   DEVCB_DRIVER_MEMBER(c64gs_state, cpu_w)
819   DEVCB_DRIVER_MEMBER(c64gs_state, cpu_w),
820   0x07,
821   0x00
817822};
818823
819824

Previous 199869 Revisions Next


© 1997-2024 The MAME Team