Previous 15994 Revisions Next

r3131 Sunday 31st August, 2008 at 20:43:16 UTC by Fabio Priuli
[C64] added partial support for tape emulation (only loading and only .wav) [Fabio Priuli, Roberto Zandona']
[C64] fixed border color during tape loading [Roberto Zandona']
[C64] partial cleanup of memory bankswitch, based on docs [Fabio Priuli]
[COMMODORE] removed a few useless inclusions of vc20tape.h [Fabio Priuli]
[docs]messnew.txt
[src/mess/drivers]c64.c cbmb.c
[src/mess/includes]c64.h
[src/mess/machine]c128.c c64.c cbmb.c pet.c
[src/mess/video]ted7360.c vic6560.c vic6567.c

src/mess/video/vic6560.c
r3130r3131
1818#include "includes/vc20.h"
1919#include "includes/cbmserb.h"
2020#include "includes/vc1541.h"
21#include "includes/vc20tape.h"
2221
2322
2423/* usage of GFX system for lightpenpointer drawing,
src/mess/video/vic6567.c
r3130r3131
11441144   if (!SCREENON)
11451145   {
11461146      for (line = first; (line < last) && (line < vic2.bitmap->height); line++)
1147         memset16 (BITMAP_ADDR16(vic2.bitmap, line, 0), 0, vic2.bitmap->width);
1147         memset16 (BITMAP_ADDR16(vic2.bitmap, line, 0), FRAMECOLOR, vic2.bitmap->width);
11481148      return;
11491149   }
11501150
src/mess/video/ted7360.c
r3130r3131
361361#define VERBOSE_DBG 0
362362#include "includes/cbm.h"
363363#include "includes/c16.h"
364#include "includes/vc20tape.h"
365364#include "includes/cbmserb.h"
366365#include "includes/vc1541.h"
367366
src/mess/includes/c64.h
r3130r3131
5555
5656WRITE8_HANDLER ( c64_write_io );
5757READ8_HANDLER ( c64_read_io );
58WRITE8_HANDLER ( c64_tape_read );
5958int c64_paddle_read (int which);
6059void c64_vic_interrupt (int level);
6160
src/mess/machine/cbmb.c
r3130r3131
1515#include "machine/tpi6525.h"
1616#include "includes/cbmserb.h"
1717#include "includes/vc1541.h"
18#include "includes/vc20tape.h"
1918#include "includes/cbmieeeb.h"
2019#include "video/vic6567.h"
2120
src/mess/machine/c128.c
r3130r3131
1414#include "cpu/m6502/m6502.h"
1515#include "sound/sid6581.h"
1616#include "machine/6526cia.h"
17#include "deprecat.h"
1718
1819#define VERBOSE_DBG 1
1920#include "includes/cbm.h"
r3130r3131
5859static int c128_ram_bottom, c128_ram_top;
5960static UINT8 *c128_ram;
6061
62static UINT8 c64_port_data;
63
6164static void c128_set_m8502_read_handler(running_machine *machine, UINT16 start, UINT16 end, read8_machine_func rh)
6265{
6366   int cpunum;
r3130r3131
793796      return c64_colorram[(offset & 0x3ff)|((c64_port6510&0x3)<<10)] & 0xf;
794797}
795798
799/* 2008-08-31
800   We need here the old m6510 port handlers from c64, until we update this driver
801   to the new tape code */
802
803static WRITE8_HANDLER(c64_tape_read)
804{
805   cia_issue_index(machine, 0);
806}
807
808static void c128_m6510_port_write(UINT8 direction, UINT8 data)
809{
810   /* if line is marked as input then keep current value */
811   data = ( c64_port_data & ~direction ) | ( data & direction );
812
813   /* resistor makes cassette sense go high when P4 changes to input */
814   if ( ! ( direction & 0x10 ) ) {
815      data |= 0x10;
816   }
817   /* resistors make P0,P1,P2 go high when respective line is changed to input */
818   if ( ! ( direction & 0x04 ) ) {
819      data |= 0x04;
820   }
821   if ( ! ( direction & 0x02 ) ) {
822      data |= 0x02;
823   }
824   if ( ! ( direction & 0x01 ) ) {
825      data |= 0x01;
826   }
827   c64_port_data = data;
828
829   if (c64_tape_on)
830   {
831      if ( direction & 0x08 ) {
832         vc20_tape_write (!(data & 8));
833      }
834      if ( direction & 0x20 ) {
835         vc20_tape_motor (data & 0x20);
836      }
837   }
838
839   c128_bankswitch_64 (Machine, 0);
840
841   c64_memory[0x000] = program_read_byte( 0 );
842   c64_memory[0x001] = program_read_byte( 1 );
843}
844
845static UINT8 c128_m6510_port_read(UINT8 direction)
846{
847   running_machine *machine = Machine;
848   UINT8 data = c64_port_data;
849
850   if (c64_tape_on && !vc20_tape_switch())
851      data &= ~0x10;
852   /* WP: motor is always marked as on??? */
853   data &= ~0x20;
854
855   if (input_port_read(machine, "SPECIAL") & 0x20)      /* Check Caps Lock */
856   {
857      data &= ~0x40;
858   } else {
859      data |=  0x40;
860   }
861
862   return data;
863}
864
796865static void c128_common_driver_init(running_machine *machine)
797866{
798867   UINT8 *gfx=memory_region(machine, "gfx1");
r3130r3131
800869   int i;
801870
802871   /* configure the M6510 port */
803   cpunum_set_info_fct(1, CPUINFO_PTR_M6510_PORTREAD, (genf *) c64_m6510_port_read);
804   cpunum_set_info_fct(1, CPUINFO_PTR_M6510_PORTWRITE, (genf *) c64_m6510_port_write);
872   cpunum_set_info_fct(1, CPUINFO_PTR_M6510_PORTREAD, (genf *) c128_m6510_port_read);
873   cpunum_set_info_fct(1, CPUINFO_PTR_M6510_PORTWRITE, (genf *) c128_m6510_port_write);
805874
806875   c64_memory = ram;
807876
src/mess/machine/pet.c
r3130r3131
1010
1111#define VERBOSE_DBG 1
1212#include "includes/cbm.h"
13#include "includes/vc20tape.h"
1413#include "machine/6821pia.h"
1514#include "machine/6522via.h"
1615#include "includes/cbmserb.h"
src/mess/machine/c64.c
r3130r3131
1212    (program write some short test code into the vic sprite register)
1313 */
1414
15/*
16   2008-08-31: Tape status [FP & RZ]
17   - tape loading works
18   
19   TODO:
20   * write to tape
21   * FFW & REW
22   * support for .tap files
23   * fix implementation for other CBM machines
24*/
25
1526#include "driver.h"
1627
1728#include "cpu/m6502/m6502.h"
r3130r3131
2839#include "video/vic6567.h"
2940#include "video/vdc8563.h"
3041
31#include "includes/c128.h"   /* we need c128_bankswitch_64 in c64_m6510_port_write */
3242#include "includes/c64.h"
43#include "includes/c128.h"      /* we need c128_bankswitch_64 in MACHINE_START */
3344
34static void c64_driver_shutdown (running_machine *machine);
45#include "devices/cassette.h"
3546
3647unsigned char c65_keyline = { 0xff };
3748UINT8 c65_6511_port=0xff;
r3130r3131
4758
4859/* expansion port lines input */
4960int c64_pal = 0;
50UINT8 c64_game=1, c64_exrom=1;
61UINT8 c64_game = 1, c64_exrom = 1;
5162
5263/* cpu port */
5364int c128_va1617;
r3130r3131
323334   }
324335}
325336
326WRITE8_HANDLER(c64_tape_read)
327{
328   cia_issue_index(machine, 0);
329}
330
331337static void c64_cia0_interrupt (running_machine *machine, int level)
332338{
333339   c64_irq (machine, level || vicirq);
r3130r3131
421427   }
422428};
423429
430
431static UINT8 *c64_io_ram_w_ptr;
432static UINT8 *c64_io_ram_r_ptr;
433
424434WRITE8_HANDLER( c64_write_io )
425435{
426436   c64_io_mirror[ offset ] = data;
r3130r3131
451461   }
452462}
453463
454static UINT8 *c64_io_ram_w_ptr;
455static UINT8 *c64_io_ram_r_ptr;
456
457464WRITE8_HANDLER(c64_ioarea_w)
458465{
459   if ( c64_io_enabled ) {
460      c64_write_io( machine, offset, data );
461   } else {
462      c64_io_ram_w_ptr[ offset ] = data;
466   if (c64_io_enabled)
467   {
468      c64_write_io(machine, offset, data);
469   }
470   else
471   {
472      c64_io_ram_w_ptr[offset] = data;
463473   }
464474}
465475
r3130r3131
491501
492502READ8_HANDLER(c64_ioarea_r)
493503{
494   if ( c64_io_enabled ) {
495      return c64_read_io( machine, offset );
496   }
497   return c64_io_ram_r_ptr[ offset ];
504   return c64_io_enabled ? c64_read_io(machine, offset) : c64_io_ram_r_ptr[offset];
498505}
499506
507
508/* Info from http://unusedino.de/ec64/technical/misc/c64/64doc.html */
500509/*
501 * two devices access bus, cpu and vic
502 *
503 * romh, roml chip select lines on expansion bus
504 * loram, hiram, charen bankswitching select by cpu
505 * exrom, game bankswitching select by cartridge
506 * va15, va14 bank select by cpu for vic
507 *
508 * exrom, game: normal c64 mode
509 * exrom, !game: ultimax mode
510 *
511 * romh: 8k rom at 0xa000 (hiram && !game && exrom)
512 * or 8k ram at 0xe000 (!game exrom)
513 * roml: 8k rom at 0x8000 (loram hiram !exrom)
514 * or 8k ram at 0x8000 (!game exrom)
515 * roml vic: upper 4k rom at 0x3000, 0x7000, 0xb000, 0xd000 (!game exrom)
516 *
517 * basic rom: 8k rom at 0xa000 (loram hiram game)
518 * kernal rom: 8k rom at 0xe000 (hiram !exrom, hiram game)
519 * char rom: 4k rom at 0xd000 (!exrom charen hiram
520 * game charen !hiram loram
521 * game charen hiram)
522 * cpu
523 *
524 * (write colorram)
525 * gr_w = !read&&!cas&&((address&0xf000)==0xd000)
526 *
527 * i_o = !game exrom !read ((address&0xf000)==0xd000)
528 * !game exrom ((address&0xf000)==0xd000)
529 * charen !hiram loram !read ((address&0xf000)==0xd000)
530 * charen !hiram loram ((address&0xf000)==0xd000)
531 * charen hiram !read ((address&0xf000)==0xd000)
532 * charen hiram ((address&0xf000)==0xd000)
533 *
534 * vic
535 * char rom: x101 (game, !exrom)
536 * romh: 0011 (!game, exrom)
537 *
538 * exrom !game (ultimax mode)
539 * addr    CPU     VIC-II
540 * ----    ---     ------
541 * 0000    RAM     RAM
542 * 1000    -       RAM
543 * 2000    -       RAM
544 * 3000    -       ROMH (upper half)
545 * 4000    -       RAM
546 * 5000    -       RAM
547 * 6000    -       RAM
548 * 7000    -       ROMH
549 * 8000    ROML    RAM
550 * 9000    ROML    RAM
551 * A000    -       RAM
552 * B000    -       ROMH
553 * C000    -       RAM
554 * D000    I/O     RAM
555 * E000    ROMH    RAM
556 * F000    ROMH    ROMH
557 */
510
511  The leftmost column of the table contains addresses in hexadecimal
512notation. The columns aside it introduce all possible memory
513configurations. The default mode is on the left, and the absolutely
514most rarely used Ultimax game console configuration is on the right.
515(Has anybody ever seen any Ultimax games?) Each memory configuration
516column has one or more four-digit binary numbers as a title. The bits,
517from left to right, represent the state of the -LORAM, -HIRAM, -GAME
518and -EXROM lines, respectively. The bits whose state does not matter
519are marked with "x". For instance, when the Ultimax video game
520configuration is active (the -GAME line is shorted to ground), the
521-LORAM and -HIRAM lines have no effect.
522
523      default                      001x                       Ultimax
524       1111   101x   1000   011x   00x0   1110   0100   1100   xx01
52510000
526----------------------------------------------------------------------
527 F000
528       Kernal RAM    RAM    Kernal RAM    Kernal Kernal Kernal ROMH(*
529 E000
530----------------------------------------------------------------------
531 D000  IO/C   IO/C   IO/RAM IO/C   RAM    IO/C   IO/C   IO/C   I/O
532----------------------------------------------------------------------
533 C000  RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM     -
534----------------------------------------------------------------------
535 B000                                             
536       BASIC  RAM    RAM    RAM    RAM    BASIC  ROMH   ROMH    -
537 A000                                             
538----------------------------------------------------------------------
539 9000                                             
540       RAM    RAM    RAM    RAM    RAM    ROML   RAM    ROML   ROML(*
541 8000                                             
542----------------------------------------------------------------------
543 7000                                             
544                                             
545 6000                                             
546       RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM     -
547 5000                                             
548                                             
549 4000                                             
550----------------------------------------------------------------------
551 3000                                             
552                                             
553 2000  RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM     -
554                                             
555 1000                                             
556----------------------------------------------------------------------
557 0000  RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM
558----------------------------------------------------------------------
559
560   *) Internal memory does not respond to write accesses to these
561       areas.
562
563
564    Legend: Kernal      E000-FFFF       Kernal ROM.
565
566            IO/C        D000-DFFF       I/O address space or Character
567                                        generator ROM, selected by
568                                        -CHAREN. If the CHAREN bit is
569                                        clear, the character generator
570                                        ROM will be selected. If it is
571                                        set, the I/O chips are
572                                        accessible.
573
574            IO/RAM      D000-DFFF       I/O address space or RAM,
575                                        selected by -CHAREN. If the
576                                        CHAREN bit is clear, the
577                                        character generator ROM will
578                                        be selected. If it is set, the
579                                        internal RAM is accessible.
580
581            I/O         D000-DFFF       I/O address space.
582                                        The -CHAREN line has no effect.
583
584            BASIC       A000-BFFF       BASIC ROM.
585
586            ROMH        A000-BFFF or    External ROM with the -ROMH line
587                        E000-FFFF       connected to its -CS line.
588
589            ROML        8000-9FFF       External ROM with the -ROML line
590                                        connected to its -CS line.
591
592            RAM         various ranges  Commodore 64's internal RAM.
593
594            -           1000-7FFF and   Open address space.
595                        A000-CFFF       The Commodore 64's memory chips
596                                        do not detect any memory accesses
597                                        to this area except the VIC-II's
598                                        DMA and memory refreshes.
599
600    NOTE:   Whenever the processor tries to write to any ROM area
601            (Kernal, BASIC, CHAROM, ROML, ROMH), the data will get
602            "through the ROM" to the C64's internal RAM.
603
604            For this reason, you can easily copy data from ROM to RAM,
605            without any bank switching. But implementing external
606            memory expansions without DMA is very hard, as you have to
607            use a 256 byte window on the I/O1 or I/O2 area, like
608            GEORAM, or the Ultimax memory configuration, if you do not
609            want the data to be written both to internal and external
610            RAM.
611
612            However, this is not true for the Ultimax video game
613            configuration. In that mode, the internal RAM ignores all
614            memory accesses outside the area $0000-$0FFF, unless they
615            are performed by the VIC, and you can write to external
616            memory at $1000-$CFFF and $E000-$FFFF, if any, without
617            changing the contents of the internal RAM.
618
619*/
620
558621static void c64_bankswitch(running_machine *machine, int reset)
559622{
560623   static int old = -1, exrom, game;
561   int data, loram, hiram, charen;
624   int loram, hiram, charen;
625   int ultimax_mode = 0;
626   int data = (UINT8) cpunum_get_info_int(0, CPUINFO_INT_M6510_PORT) & 0x07;
562627
563   data = (UINT8) cpunum_get_info_int(0, CPUINFO_INT_M6510_PORT) & 7;
564   if ((data == old)&&(exrom==c64_exrom)&&(game==c64_game)&&!reset) return;
628   /* If nothing has changed or reset = 0, don't do anything */
629   if ((data == old) && (exrom == c64_exrom) && (game == c64_game) && !reset)
630      return;
565631
632   /* Are we in Ultimax mode? */
633   if (!c64_game && c64_exrom)
634      ultimax_mode = 1;
635
566636   DBG_LOG (1, "bankswitch", ("%d\n", data & 7));
567   loram = (data & 1) ? 1 : 0;
568   hiram = (data & 2) ? 1 : 0;
637   loram  = (data & 1) ? 1 : 0;
638   hiram  = (data & 2) ? 1 : 0;
569639   charen = (data & 4) ? 1 : 0;
570640
571   if ((!c64_game && c64_exrom)
572       || (loram && !c64_exrom)) // for omega race cartridge
573//       || (loram && hiram && !c64_exrom))
641   if (ultimax_mode)
574642   {
575      memory_set_bankptr (1, roml);
576      memory_set_bankptr (2, c64_memory + 0x8000);
577   }
578   else
579   {
580      memory_set_bankptr (1, c64_memory + 0x8000);
581      memory_set_bankptr (2, c64_memory + 0x8000);
582   }
643         c64_io_enabled = 1;      // charen has no effect in ultimax_mode
583644
584#if 1
585   if ((!c64_game && !c64_exrom && hiram)
586       /*|| (!c64_exrom)*/) // must be disabled for 8kb c64 cartridges! like space action, super expander, ...
587#else
588   if ((!c64_game && c64_exrom && hiram)
589       || (!c64_exrom) )
590#endif
591   {
592      memory_set_bankptr (3, romh);
645         memory_set_bankptr (1, roml);
646         memory_set_bankptr (2, c64_memory + 0x8000);
647         memory_set_bankptr (3, c64_memory + 0xa000);
648         memory_set_bankptr (4, romh);
649         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, SMH_NOP);
593650   }
594   else if (loram && hiram &&c64_game)
595   {
596      memory_set_bankptr (3, c64_basic);
597   }
598651   else
599652   {
600      memory_set_bankptr (3, c64_memory + 0xa000);
601   }
653      /* 0x8000-0x9000 */
654      if (loram && hiram && !c64_exrom)
655      {
656         memory_set_bankptr (1, roml);
657         memory_set_bankptr (2, c64_memory + 0x8000);
658      }
659      else
660      {
661         memory_set_bankptr (1, c64_memory + 0x8000);
662         memory_set_bankptr (2, c64_memory + 0x8000);
663      }
602664
603   if ((!c64_game && c64_exrom)
604      || (charen && (loram || hiram)))
605   {
606      c64_io_enabled = 1;
607//      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xd000, 0xdfff, 0, 0, c64_read_io);
608//      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xd000, 0xdfff, 0, 0, c64_write_io);
609//      if ( cpu_getactivecpu() >= 0 )
610//         memory_set_opbase(activecpu_get_physical_pc_byte());
611   }
612   else
613   {
614      c64_io_enabled = 0;
615      c64_io_ram_w_ptr = c64_memory + 0xd000;
616      if ( !charen && (loram || hiram)) {
617         c64_io_ram_r_ptr = c64_chargen;
618      } else {
665      /* 0xa000 */
666      if (hiram && !c64_game && !c64_exrom)
667         memory_set_bankptr (3, romh);
668
669      else if (loram && hiram && c64_game)
670         memory_set_bankptr (3, c64_basic);
671
672      else
673         memory_set_bankptr (3, c64_memory + 0xa000);
674
675      /* 0xd000 */
676      // RAM
677      if (!loram && !hiram && (c64_game || !c64_exrom))
678      {
679         c64_io_enabled = 0;
619680         c64_io_ram_r_ptr = c64_memory + 0xd000;
681         c64_io_ram_w_ptr = c64_memory + 0xd000;
620682      }
621//      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xd000, 0xdfff, 0, 0, SMH_BANK5);
622//      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xd000, 0xdfff, 0, 0, SMH_BANK6);
623//      memory_set_bankptr (6, c64_memory + 0xd000);
624//      if (!charen && (loram || hiram))
625//      {
626//         memory_set_bankptr (5, c64_chargen);
627//      }
628//      else
629//      {
630//         memory_set_bankptr (5, c64_memory + 0xd000);
631//      }
683      // IO/RAM
684      else if (loram && !hiram && !c64_game)   // remember we cannot be in ultimax_mode, no need of !c64_exrom
685      {
686         c64_io_enabled = 0;
687         c64_io_ram_w_ptr = c64_memory + 0xd000;
688         c64_io_ram_r_ptr = (!charen) ? c64_chargen : c64_memory + 0xd000;
689      }
690      // IO/C
691      else
692      {
693         c64_io_enabled = charen ? 1 : 0;
694
695         if (!charen)
696         {
697         c64_io_ram_w_ptr = c64_memory + 0xd000;
698         c64_io_ram_r_ptr = c64_chargen;
699         }
700      }
701
702      /* 0xe000-0xf000 */
703      memory_set_bankptr (4, hiram ? c64_kernal : c64_memory + 0xe000);
704      memory_set_bankptr (5, c64_memory + 0xe000);
632705   }
633706
634   if (!c64_game && c64_exrom)
635   {
636      memory_set_bankptr (7, romh);
637      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, SMH_NOP);
638   }
639   else
640   {
641      if (hiram)
642         memory_set_bankptr (7, c64_kernal);
643      else
644         memory_set_bankptr (7, c64_memory + 0xe000);
645      memory_set_bankptr (8, c64_memory + 0xe000);
646   }
647707   /* make sure the opbase function gets called each time */
648708   /* NPW 15-May-2008 - Another hack in the C64 drivers broken! */
649709   /* opbase->mem_max = 0xcfff; */
710
650711   game = c64_game;
651712   exrom = c64_exrom;
652713   old = data;
r3130r3131
664725  p5 output cassette motor
665726  p6,7 not available on M6510
666727 */
728
729static emu_timer *datasette_timer;
730
667731void c64_m6510_port_write(UINT8 direction, UINT8 data)
668732{
669733   /* if line is marked as input then keep current value */
670   data = ( c64_port_data & ~direction ) | ( data & direction );
734   data = (c64_port_data & ~direction) | (data & direction);
671735
672   /* resistor makes cassette sense go high when P4 changes to input */
673   if ( ! ( direction & 0x10 ) ) {
674      data |= 0x10;
675   }
676736   /* resistors make P0,P1,P2 go high when respective line is changed to input */
677   if ( ! ( direction & 0x04 ) ) {
737   if (!(direction & 0x04))
678738      data |= 0x04;
679   }
680   if ( ! ( direction & 0x02 ) ) {
739
740   if (!(direction & 0x02))
681741      data |= 0x02;
682   }
683   if ( ! ( direction & 0x01 ) ) {
742
743   if (!(direction & 0x01))
684744      data |= 0x01;
685   }
745
686746   c64_port_data = data;
687747
688748   if (c64_tape_on)
689749   {
690      if ( direction & 0x08 ) {
691         vc20_tape_write (!(data & 8));
750      if (direction & 0x08)
751      {
752      /* CASSETTE_RECORD is not implemented yet */
692753      }
693      if ( direction & 0x20 ) {
694         vc20_tape_motor (data & 0x20);
754
755      if (direction & 0x20)
756      {
757         if(!(data & 0x20))
758         {
759            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR);
760            timer_adjust_periodic(datasette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100));
761         }
762         else
763         {
764            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR);
765            timer_reset(datasette_timer, attotime_never);
766         }
695767      }
696768   }
697   if (is_c128(Machine))
698      c128_bankswitch_64 (Machine, 0);
699   else if (is_c65(Machine))
769
770   if (is_c65(Machine))
700771   {
701772      // NPW 8-Feb-2004 - Don't know why I have to do this
702773      //c65_bankswitch(Machine);
703774   }
775
704776   else if (!ultimax)
705777      c64_bankswitch(Machine, 0);
778
706779   c64_memory[0x000] = program_read_byte( 0 );
707780   c64_memory[0x001] = program_read_byte( 1 );
708781}
r3130r3131
712785   running_machine *machine = Machine;
713786   UINT8 data = c64_port_data;
714787
715   if (c64_tape_on && !vc20_tape_switch())
788   if ((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 0)) & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)
716789      data &= ~0x10;
717   /* WP: motor is always marked as on??? */
718   data &= ~0x20;
719   if (is_c128(machine)) {
790   else
791      data |=  0x10;
792
793   if (is_c65(machine))
794   {
720795      if (input_port_read(machine, "SPECIAL") & 0x20)      /* Check Caps Lock */
721      {
722796         data &= ~0x40;
723      } else {
797
798      else
724799         data |=  0x40;
725      }
726800   }
727   if (is_c65(machine)) {
728      if (input_port_read(machine, "SPECIAL") & 0x20)      /* Check Caps Lock */
729      {
730         data &= ~0x40;
731      } else {
732         data |=  0x40;
733      }
734   }
801
735802   return data;
736803}
737804
805
738806int c64_paddle_read (int which)
739807{
740808   int pot1=0xff, pot2=0xff, pot3=0xff, pot4=0xff, temp;
r3130r3131
835903   return c64_colorram[offset & 0x3ff] & 0xf;
836904}
837905
906double last = 0;
907
908static TIMER_CALLBACK( c64_tape_timer )
909{
910   double tmp = cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0));
911
912   if((last > +0.0) && (tmp < +0.0))
913      cia_issue_index(machine, 0);
914
915   last = tmp;
916}
917
838918static void c64_common_driver_init (running_machine *machine)
839919{
920   cia6526_interface cia_intf[2];
921
840922   /* configure the M6510 port */
841923   cpunum_set_info_fct(0, CPUINFO_PTR_M6510_PORTREAD, (genf *) c64_m6510_port_read);
842924   cpunum_set_info_fct(0, CPUINFO_PTR_M6510_PORTWRITE, (genf *) c64_m6510_port_write);
843925
844   /*    memset(c64_memory, 0, 0xfd00); */
845   if (!ultimax) {
926   if (!ultimax)
927   {
846928      UINT8 *mem = memory_region(machine, "main");
847      c64_basic=mem+0x10000;
848      c64_kernal=mem+0x12000;
849      c64_chargen=mem+0x14000;
850      c64_colorram=mem+0x15000;
851      c64_roml=mem+0x15400;
852      c64_romh=mem+0x17400;
853#if 0
854   {0x10000, 0x11fff, SMH_ROM, &c64_basic},   /* basic at 0xa000 */
855   {0x12000, 0x13fff, SMH_ROM, &c64_kernal},   /* kernal at 0xe000 */
856   {0x14000, 0x14fff, SMH_ROM, &c64_chargen},   /* charrom at 0xd000 */
857   {0x15000, 0x153ff, SMH_RAM, &c64_colorram},      /* colorram at 0xd800 */
858   {0x15400, 0x173ff, SMH_ROM, &c64_roml},   /* basic at 0xa000 */
859   {0x17400, 0x193ff, SMH_ROM, &c64_romh},   /* kernal at 0xe000 */
860#endif
929      c64_basic    = mem + 0x10000;
930      c64_kernal   = mem + 0x12000;
931      c64_chargen  = mem + 0x14000;
932      c64_colorram = mem + 0x15000;
933      c64_roml     = mem + 0x15400;
934      c64_romh     = mem + 0x17400;
861935   }
936
862937   if (c64_tape_on)
863      vc20_tape_open (c64_tape_read);
938      datasette_timer = timer_alloc(c64_tape_timer, NULL);
864939
940   /* CIA initialization */
941   cia_intf[0] = c64_cia0;
942   cia_intf[0].tod_clock = c64_pal ? 50 : 60;
943   cia_config(machine, 0, &cia_intf[0]);
944   
945   if (c64_cia1_on)
865946   {
866      cia6526_interface cia_intf[2];
867
868      cia_intf[0] = c64_cia0;
869      cia_intf[0].tod_clock = c64_pal ? 50 : 60;
870      cia_config(machine, 0, &cia_intf[0]);
871
872      if (c64_cia1_on)
873      {
874         cia_intf[1] = c64_cia1;
875         cia_intf[1].tod_clock = c64_pal ? 50 : 60;
876         cia_config(machine, 1, &cia_intf[1]);
877      }
947      cia_intf[1] = c64_cia1;
948      cia_intf[1].tod_clock = c64_pal ? 50 : 60;
949      cia_config(machine, 1, &cia_intf[1]);
878950   }
879
951   
952   
880953   if (ultimax)
881   {
882      vic6567_init (0, c64_pal, c64_dma_read_ultimax, c64_dma_read_color,
883                 c64_vic_interrupt);
884   }
954      vic6567_init (0, c64_pal, c64_dma_read_ultimax, c64_dma_read_color, c64_vic_interrupt);
885955   else
886   {
887      vic6567_init (0, c64_pal, c64_dma_read, c64_dma_read_color,
888                 c64_vic_interrupt);
889   }
956      vic6567_init (0, c64_pal, c64_dma_read, c64_dma_read_color, c64_vic_interrupt);
957
890958   cia_reset();
891   add_exit_callback(machine, c64_driver_shutdown);
892959}
893960
894961DRIVER_INIT( c64 )
r3130r3131
926993   vc1541_config (0, 0, &vc1541);
927994}
928995
929static void c64_driver_shutdown (running_machine *machine)
930{
931   if (c64_tape_on)
932      vc20_tape_close ();
933}
934
935996void c64_common_init_machine (running_machine *machine)
936997{
937998#ifdef VC1541
r3130r3131
9491010   vicirq = 0;
9501011}
9511012
952static OPBASE_HANDLER( c64_opbase ) {
953   if ( ( address & 0xf000 ) == 0xd000 ) {
954      if ( c64_io_enabled ) {
1013static OPBASE_HANDLER( c64_opbase )
1014{
1015   if ((address & 0xf000) == 0xd000)
1016   {
1017      if (c64_io_enabled)
1018      {
9551019         opbase->mask = 0x0fff;
9561020         opbase->ram = c64_io_mirror;
9571021         opbase->rom = c64_io_mirror;
9581022         opbase->mem_min = 0x0000;
9591023         opbase->mem_max = 0xcfff;
9601024         c64_io_mirror[address & 0x0fff] = c64_read_io( machine, address & 0x0fff );
961      } else {
1025      }
1026      else
1027      {
9621028         opbase->mask = 0x0fff;
9631029         opbase->ram = c64_io_ram_r_ptr;
9641030         opbase->rom = c64_io_ram_r_ptr;
r3130r3131
12101276      c65_keyline = value;
12111277   }
12121278
1213
12141279   vic2_frame_interrupt (machine, cpunum);
12151280
1216   if (c64_tape_on)
1217   {
1218      vc20_tape_config (input_port_read(machine, "CFG") & 0x4000, input_port_read(machine, "DSW0") & 0x2000);      /* DATASSETTE, DATASSETTE_TONE */
1219      vc20_tape_buttons (input_port_read(machine, "CFG") & 0x1000, input_port_read(machine, "DSW0") & 0x0800, input_port_read(machine, "DSW0") & 0x0400);   /* DATASETTE_PLAY, DATASETTE_RECORD, DATASETTE_STOP */
1220   }
1221
12221281   set_led_status (1, input_port_read(machine, "SPECIAL") & 0x40 ? 1 : 0);      /*KB_CAPSLOCK_FLAG */
12231282   set_led_status (0, input_port_read(machine, "DSW0") & 0x0100 ? 1 : 0);      /*KB_NUMLOCK_FLAG */
12241283}
src/mess/drivers/cbmb.c
r3130r3131
170170#include "video/mc6845.h"
171171#include "includes/cbmserb.h"
172172#include "includes/vc1541.h"
173#include "includes/vc20tape.h"
174173
175174#include "includes/cbmb.h"
176175
src/mess/drivers/c64.c
r3130r3131
193193#include "driver.h"
194194#include "sound/sid6581.h"
195195#include "machine/6526cia.h"
196#include "devices/cassette.h"
196197
197198#define VERBOSE_DBG 0
198199#include "includes/cbm.h"
r3130r3131
200201#include "video/vic6567.h"
201202#include "includes/cbmserb.h"
202203#include "includes/vc1541.h"
203#include "includes/vc20tape.h"
204204
205205#include "includes/c64.h"
206206
207
207208static ADDRESS_MAP_START(ultimax_mem , ADDRESS_SPACE_PROGRAM, 8)
208209   AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE(&c64_memory)
209210   AM_RANGE(0x8000, 0x9fff) AM_ROM AM_BASE(&c64_roml)
r3130r3131
211212   AM_RANGE(0xd400, 0xd7ff) AM_READWRITE(sid6581_0_port_r, sid6581_0_port_w)
212213   AM_RANGE(0xd800, 0xdbff) AM_READWRITE(SMH_RAM, c64_colorram_write) AM_BASE(&c64_colorram) /* colorram  */
213214   AM_RANGE(0xdc00, 0xdcff) AM_READWRITE(cia_0_r, cia_0_w)
214   AM_RANGE(0xe000, 0xffff) AM_ROM AM_BASE( &c64_romh)      /* ram or kernel rom */
215   AM_RANGE(0xe000, 0xffff) AM_ROM AM_BASE(&c64_romh)      /* ram or kernel rom */
215216ADDRESS_MAP_END
216217
217218static ADDRESS_MAP_START(c64_mem, ADDRESS_SPACE_PROGRAM, 8)
218219   AM_RANGE(0x0000, 0x7fff) AM_RAM AM_BASE(&c64_memory)
219   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(SMH_BANK1, SMH_BANK2)      /* ram or external roml */
220   AM_RANGE(0xa000, 0xbfff) AM_READWRITE(SMH_BANK3, SMH_RAM)      /* ram or basic rom or external romh */
220   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(SMH_BANK1, SMH_BANK2)      /* ram or external roml */
221   AM_RANGE(0xa000, 0xbfff) AM_ROMBANK(3) AM_WRITEONLY            /* ram or basic rom or external romh */
221222   AM_RANGE(0xc000, 0xcfff) AM_RAM
222223   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(c64_ioarea_r, c64_ioarea_w)
223//#if 1
224//  AM_RANGE(0xd000, 0xdfff) AM_READWRITE(SMH_BANK5, SMH_BANK6)
225//#else
226///* dram */
227///* or character rom */
228//  AM_RANGE(0xd000, 0xd3ff) AM_READWRITE(SMH_BANK9, vic2_port_w)
229//  AM_RANGE(0xd400, 0xd7ff) AM_READWRITE(SMH_BANK10, sid6581_0_port_w)
230//  AM_RANGE(0xd800, 0xdbff) AM_READWRITE(SMH_BANK11, c64_colorram_write)         /* colorram  */
231//  AM_RANGE(0xdc00, 0xdcff) AM_READWRITE(SMH_BANK12, cia_0_w)
232//  AM_RANGE(0xdd00, 0xddff) AM_READWRITE(SMH_BANK13, cia_1_w)
233//  AM_RANGE(0xde00, 0xdeff) AM_READ(SMH_BANK14)          /* csline expansion port */
234//  AM_RANGE(0xdf00, 0xdfff) AM_READ(SMH_BANK15)          /* csline expansion port */
235//#endif
236   AM_RANGE(0xe000, 0xffff) AM_READWRITE(SMH_BANK7, SMH_BANK8)      /* ram or kernel rom or external romh */
224   AM_RANGE(0xe000, 0xffff) AM_READWRITE(SMH_BANK4, SMH_BANK5)      /* ram or kernel rom or external romh */
237225ADDRESS_MAP_END
238226
239227
r3130r3131
593581   }
594582}
595583
596static SYSTEM_CONFIG_START(c64)
597   CONFIG_DEVICE(c64_cbmcartslot_getinfo)
598   CONFIG_DEVICE(cbmfloppy_device_getinfo)
599   CONFIG_DEVICE(vc20tape_device_getinfo)
600SYSTEM_CONFIG_END
601
602static SYSTEM_CONFIG_START(sx64)
603   CONFIG_DEVICE(c64_cbmcartslot_getinfo)
604   CONFIG_DEVICE(vc1541_device_getinfo)
605SYSTEM_CONFIG_END
606
607584static void ultimax_cbmcartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
608585{
609586   switch(state)
r3130r3131
618595   }
619596}
620597
598static void datasette_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
599{
600   /* cassette */
601   switch(state)
602   {
603   case MESS_DEVINFO_INT_COUNT:               info->i = 1; break;
604
605   case MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE:   info->i = CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED; break;
606
607   default:                              cassette_device_getinfo( devclass, state, info ); break;
608   }
609}
610
611static SYSTEM_CONFIG_START(c64)
612   CONFIG_DEVICE(c64_cbmcartslot_getinfo)
613   CONFIG_DEVICE(cbmfloppy_device_getinfo)
614   CONFIG_DEVICE(datasette_device_getinfo)
615SYSTEM_CONFIG_END
616
617static SYSTEM_CONFIG_START(sx64)
618   CONFIG_DEVICE(c64_cbmcartslot_getinfo)
619   CONFIG_DEVICE(vc1541_device_getinfo)
620SYSTEM_CONFIG_END
621
621622static SYSTEM_CONFIG_START(ultimax)
622623   CONFIG_DEVICE(ultimax_cbmcartslot_getinfo)
623   CONFIG_DEVICE(vc20tape_device_getinfo)
624   CONFIG_DEVICE(datasette_device_getinfo)
624625SYSTEM_CONFIG_END
625626
626627static SYSTEM_CONFIG_START(c64gs)
r3130r3131
634635***************************************************************************/
635636
636637/*   YEAR  NAME     PARENT  COMPAT  MACHINE         INPUT   INIT    CONFIG      COMPANY                            FULLNAME */
637COMP(1982, max,      0,      0,      ultimax,      ultimax,ultimax,ultimax,   "Commodore Business Machines Co.", "Commodore Max (Ultimax/VC10)", 0)
638638COMP(1982, c64,      0,      0,      c64,         c64,   c64,   c64,      "Commodore Business Machines Co.", "Commodore 64 (NTSC)", 0)
639COMP(1982, c64pal,    c64,   0,      c64pal,       c64,   c64pal, c64,      "Commodore Business Machines Co.", "Commodore 64/VC64/VIC64 (PAL)", 0)
639640COMP(1982, cbm4064,   c64,   0,      pet64,         c64,   c64,   c64,      "Commodore Business Machines Co.", "CBM4064/PET64/Educator64 (NTSC)", 0)
640COMP(1982, c64pal,    c64,   0,      c64pal,       c64,   c64pal, c64,      "Commodore Business Machines Co.", "Commodore 64/VC64/VIC64 (PAL)", 0)
641641COMP(1982, vic64s,    c64,   0,      c64pal,       vic64s,   c64pal, c64,      "Commodore Business Machines Co.", "Commodore 64 Swedish (PAL)", 0)
642COMP(1982, max,      0,      0,      ultimax,      ultimax,ultimax,ultimax,   "Commodore Business Machines Co.", "Commodore Max (Ultimax/VC10)", 0)
642643CONS(1987, c64gs,   c64,   0,      c64gs,         c64gs,   c64gs,   c64gs,      "Commodore Business Machines Co.", "C64GS (PAL)", 0)
643644
644645/* testdrivers */
docs/messnew.txt
r3130r3131
10.127.1
10.127.1
22
33New System Drivers Supported (in no particular order):
44------------------------------------------------------
r3130r3131
88
99System Driver Changes:
1010----------------------
11
12- [C64] added partial support to tape emulation (only loading and only .wav) [Fabio Priuli, Roberto Zandona']
13
14- [C64] fixed border color during tape loading [Roberto Zandona']
15
16- [C64] partial cleanup of memory bankswitch, based on docs [Fabio Priuli]
17
1118- [OSCNANO] Implemented RUN/MONITOR keys properly, changed video to
1219  black and white, and fixed quickloading. System is now fully
1320  working, including the "Säkkijärven polkka" program. [Curt Coder]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team