Previous 15994 Revisions Next

r807 Thursday 9th August, 2007 at 23:45:09 UTC by Nathan Woods
1. [AMIGA] RTC support, added buffered keyboard support, properly implemented
a fix for the slow-memory detection bug in Kickstart 1.2. [Ernesto Corvi]

2. [CDTV] Added NVRAM support. [Ernesto Corvi]
[docs]messnew.txt
[src/mame/machine]msm6242.c
[src/mess]mess.mak
[src/mess/drivers]amiga.c
[src/mess/machine]amigakbd.c

src/mame/machine/msm6242.c
r806r807
66
77#include "machine/msm6242.h"
88
9static UINT8 msm6264_reg[3] = { 0, 0, 0 };
10static mame_system_time msm6264_hold_time = { 0 };
11
12enum
13{
14   MSM6264_REG_S1      = 0,
15   MSM6264_REG_S10,
16   MSM6264_REG_MI1,
17   MSM6264_REG_MI10,
18   MSM6264_REG_H1,
19   MSM6264_REG_H10,
20   MSM6264_REG_D1,
21   MSM6264_REG_D10,
22   MSM6264_REG_MO1,
23   MSM6264_REG_MO10,
24   MSM6264_REG_Y1,
25   MSM6264_REG_Y10,
26   MSM6264_REG_W,
27   MSM6264_REG_CD,
28   MSM6264_REG_CE,
29   MSM6264_REG_CF
30};
31
932READ8_HANDLER( msm6242_r )
1033{
11   mame_system_time systime;
34   mame_system_time curtime, *systime = &curtime;
35   
36   if ( msm6264_reg[0] & 1 ) /* if HOLD is set, use the hold time */
37   {
38      systime = &msm6264_hold_time;
39   }
40   else /* otherwise, use the current time */
41   {
42      mame_get_current_datetime(Machine, &curtime);
43   }
1244
13   mame_get_current_datetime(Machine, &systime);
14
1545   switch(offset)
1646   {
17      case 0x0:   return systime.local_time.second % 10;
18      case 0x1:   return systime.local_time.second / 10;
19      case 0x2:   return systime.local_time.minute % 10;
20      case 0x3:   return systime.local_time.minute / 10;
21      case 0x4:   return systime.local_time.hour % 10;
22      case 0x5:   return systime.local_time.hour / 10;
23      case 0x6:   return systime.local_time.mday % 10;
24      case 0x7:   return systime.local_time.mday / 10;
25      case 0x8:   return (systime.local_time.month+1) % 10;
26      case 0x9:   return (systime.local_time.month+1) / 10;
27      case 0xa:   return systime.local_time.year % 10;
28      case 0xb:   return (systime.local_time.year % 100) / 10;
29      case 0xc:   return systime.local_time.weekday;
30      case 0xd:   return 1;
31      case 0xe:   return 6;
32      case 0xf:   return 4;
47      case MSM6264_REG_S1: return systime->local_time.second % 10;
48      case MSM6264_REG_S10: return systime->local_time.second / 10;
49      case MSM6264_REG_MI1: return systime->local_time.minute % 10;
50      case MSM6264_REG_MI10: return systime->local_time.minute / 10;
51      case MSM6264_REG_H1:
52      case MSM6264_REG_H10:
53      {
54         /* check for 12/24 hour mode */
55         if ( (msm6264_reg[2] & 0x04) == 0 ) /* 12 hour mode? */
56         {
57            int   hour = systime->local_time.hour;
58            int   pm = (hour >= 12) ? 1 : 0;
59           
60            if ( pm ) hour -= 12;
61            if ( hour == 0 ) hour = 12;
62           
63            if ( offset == MSM6264_REG_H1 )
64               return hour % 10;
65               
66            return (hour / 10) | (pm << 2);
67         }
68         
69         if ( offset == MSM6264_REG_H1 )
70            return systime->local_time.hour % 10;
71               
72         return systime->local_time.hour / 10;
73      }
74     
75      case MSM6264_REG_D1: return systime->local_time.mday % 10;
76      case MSM6264_REG_D10: return systime->local_time.mday / 10;
77      case MSM6264_REG_MO1: return (systime->local_time.month+1) % 10;
78      case MSM6264_REG_MO10: return (systime->local_time.month+1) / 10;
79      case MSM6264_REG_Y1: return (systime->local_time.year - 1900) % 10;
80      case MSM6264_REG_Y10: return (systime->local_time.year - 1900) / 10;
81      case MSM6264_REG_W: return systime->local_time.weekday;
82      case MSM6264_REG_CD: return msm6264_reg[0];
83      case MSM6264_REG_CE: return msm6264_reg[1];
84      case MSM6264_REG_CF: return msm6264_reg[2];
3385   }
3486
3587   logerror("%04x: MSM6242 unmapped offset %02X read\n",activecpu_get_pc(),offset);
r806r807
4092{
4193   switch(offset)
4294   {
43      case 0x0:   return;
44      case 0x1:   return;
45      case 0x2:   return;
46      case 0x3:   return;
47      case 0x4:   return;
48      case 0x5:   return;
49      case 0x6:   return;
50      case 0x7:   return;
51      case 0x8:   return;
52      case 0x9:   return;
53      case 0xa:   return;
54      case 0xb:   return;
55      case 0xc:   return;
56      case 0xd:   return;
57      case 0xe:   return;
58      case 0xf:   return;
95      case MSM6264_REG_CD:
96      {
97          msm6264_reg[0] = data;
98         
99          if ( data & 1 )   /* was Hold set? */
100          {
101             mame_get_current_datetime(Machine, &msm6264_hold_time);
102          }
103         
104          return;
105      }
106     
107      case MSM6264_REG_CE: msm6264_reg[1] = data; return;
108     
109      case MSM6264_REG_CF:
110      {
111         /* the 12/24 mode bit can only be changed while REST is 1 */
112         if ( (data ^ msm6264_reg[2]) & 0x04 )
113         {
114            if ( msm6264_reg[2] & 1 )
115               msm6264_reg[2] = data;
116         }
117         else
118         {
119            msm6264_reg[2] = data;
120         }
121         return;
122      }
59123   }
124   
60125   logerror("%04x: MSM6242 unmapped offset %02X written with %02X\n",activecpu_get_pc(),offset,data);
61126}
62127
src/mess/machine/amigakbd.c
r806r807
1010#include "amigakbd.h"
1111#include "machine/6526cia.h"
1212
13#define KEYBOARD_BUFFER_SIZE   256
14
1315static int   kbd_index[4] = { 0, 1, 2, 3 };
16static UINT8 *key_buf = NULL;
17static int key_buf_pos = 0;
18static int key_cur_pos = 0;
1419
20static void kbd_sendscancode( UINT8 scancode )
21{
22   int j;
23   
24   /* send over to the cia A */
25   for( j = 0; j < 8; j++ )
26   {
27      cia_set_input_cnt( 0, 0 );   /* lower cnt */
28      cia_set_input_sp( 0, ( scancode >> j ) & 1 ); /* set the serial data */
29      cia_set_input_cnt( 0, 1 );   /* raise cnt */
30   }
31}
32
33static TIMER_CALLBACK( kbd_update_callback )
34{
35   UINT8   scancode;
36   
37   (void)param;
38   
39   /* if we don't have pending data, bail */
40   if ( key_buf_pos == key_cur_pos )
41      return;
42   
43   /* fetch the next scan code and send it to the Amiga */
44   scancode = key_buf[key_cur_pos++];
45   key_cur_pos %= KEYBOARD_BUFFER_SIZE;
46   kbd_sendscancode( scancode );
47   
48   /* if we still have more data, schedule another update */
49   if ( key_buf_pos != key_cur_pos )
50      mame_timer_set(scale_down_mame_time(video_screen_get_frame_period(0),2), 0, kbd_update_callback);
51}
52
1553static void kbd_update( void *param, UINT32 oldvalue, UINT32 newvalue )
1654{
1755   int   index = *( (int*)(param) ), i;
r806r807
3674   else
3775#endif
3876   {
77      int      key_buf_was_empty = ( key_buf_pos == key_cur_pos ) ? 1 : 0;
78         
3979      for( i = 0; i < 32; i++ )
4080      {
4181         if ( delta & ( 1 << i ) )
r806r807
4383            int   down = ( newvalue & ( 1 << i ) ) ? 0 : 1;
4484            int   scancode = ( ( (index*32)+i ) << 1 ) | down;
4585            int amigacode = ~scancode;
46            int j;
47         
48            /* send over to the cia A */
49            for( j = 0; j < 8; j++ )
50            {
51               /* lower cnt */
52               cia_set_input_cnt( 0, 0 );
53               
54               /* set the serial data */
55               cia_set_input_sp( 0, ( amigacode >> j ) & 1 );
56               
57               /* raise cnt */
58               cia_set_input_cnt( 0, 1 );
59            }
86     
87            /* add the keycode to the buffer */     
88            key_buf[key_buf_pos++] = amigacode & 0xff;
89            key_buf_pos %= KEYBOARD_BUFFER_SIZE;
6090         }
6191      }
92     
93      /* if the buffer was empty and we have new data, start a timer to send the keystrokes */
94      if ( key_buf_was_empty && ( key_buf_pos != key_cur_pos ) )
95      {
96         mame_timer_set(scale_down_mame_time(video_screen_get_frame_period(0),2), 0, kbd_update_callback);
97      }
6298   }
6399}
64100
r806r807
75111
76112      input_port_set_changed_callback( port_tag_to_index( buf ), 0xFFFFFFFF, kbd_update, &kbd_index[i] );
77113   }
114   
115   /* allocate a keyboard buffer */
116   key_buf = auto_malloc( KEYBOARD_BUFFER_SIZE );
117   key_buf_pos = 0;
118   key_cur_pos = 0;
78119}
79120
80121/*********************************************************************************************/
src/mess/mess.mak
r806r807
563563   $(MAME_AUDIO)/amiga.o         \
564564   $(MESS_MACHINE)/amigafdc.o   \
565565   $(MESS_MACHINE)/amigakbd.o   \
566   $(MAME_MACHINE)/msm6242.o   \
566567   $(MESS_DRIVERS)/amiga.o      \
567568
568569$(MESSOBJ)/cbmshare.a: \
src/mess/drivers/amiga.c
r806r807
44Preliminary driver by:
55
66Ernesto Corvi
7ernesto@imagina.com
87
8Note 1: The 'fast-mem' memory detector in Kickstart 1.2 expects to
9see the custom chips at the end of any present fast memory (mapped
10from $C00000 onwards). I assume this is a bug, given that the routine
11was entirely rewritten for Kickstart 1.3. So the strategy is, for
12any machine that can run Kickstart 1.2 (a500,a1000 and a2000), we
13map a mirror of the custom chips right after any fast-mem we mapped.
14If we didn't map any, then we still put a mirror, but where fast-mem
15would commence ($C00000).
16
17
18TODO:
19- Reverse and add the DMAC DMA/CD-ROM controller for CDTV
20
921***************************************************************************/
1022
1123#include "driver.h"
r806r807
1426#include "includes/amiga.h"
1527#include "machine/amigafdc.h"
1628#include "machine/amigakbd.h"
29#include "machine/msm6242.h"
1730#include "devices/chd_cd.h"
1831#include "inputx.h"
1932
2033/***************************************************************************
34  Battery Backed-Up Clock (MSM6264)
35***************************************************************************/
36static READ16_HANDLER( amiga_clock_r ) { return msm6242_r( offset / 2 ); }
37static WRITE16_HANDLER( amiga_clock_w ) { return msm6242_w( offset / 2, data ); }
38
39/***************************************************************************
2140  Address maps
2241***************************************************************************/
2342
r806r807
2847   AM_RANGE(0x9fc000, 0x9fffff) AM_RAMBANK(2) AM_BASE(&amiga_ar_ram) AM_SIZE(&amiga_ar_ram_size)
2948#endif
3049   AM_RANGE(0xbfd000, 0xbfefff) AM_READWRITE(amiga_cia_r, amiga_cia_w)
31   AM_RANGE(0xc00000, 0xc7ffff) AM_RAM
32   AM_RANGE(0xc80000, 0xdfffff) AM_READWRITE(amiga_custom_r, amiga_custom_w) AM_BASE(&amiga_custom_regs)   /* Custom Chips */
50   AM_RANGE(0xc00000, 0xc7ffff) AM_RAM /* slow-mem */
51   AM_RANGE(0xc80000, 0xcfffff) AM_READWRITE(amiga_custom_r, amiga_custom_w)   /* see Note 1 above */
52   AM_RANGE(0xdc0000, 0xdc003f) AM_READWRITE(amiga_clock_r, amiga_clock_w);
53   AM_RANGE(0xdf0000, 0xdfffff) AM_READWRITE(amiga_custom_r, amiga_custom_w) AM_BASE(&amiga_custom_regs)   /* Custom Chips */
3354   AM_RANGE(0xe80000, 0xe8ffff) AM_READWRITE(amiga_autoconfig_r, amiga_autoconfig_w)
3455#if AMIGA_ACTION_REPLAY_1
3556   AM_RANGE(0xf00000, 0xf7ffff) AM_ROM AM_REGION(REGION_USER2, 0)   /* Cart ROM */
r806r807
6889   AM_RANGE(0x000000, 0x0fffff) AM_RAMBANK(1) AM_BASE(&amiga_chip_ram) AM_SIZE(&amiga_chip_ram_size)
6990   AM_RANGE(0x100000, 0x9fffff) AM_NOP
7091   AM_RANGE(0xbfd000, 0xbfefff) AM_READWRITE(amiga_cia_r, amiga_cia_w)
71   AM_RANGE(0xc00000, 0xdeffff) AM_NOP
92   AM_RANGE(0xdc0000, 0xdc003f) AM_READWRITE(amiga_clock_r, amiga_clock_w);
93   AM_RANGE(0xdc8000, 0xdc87ff) AM_RAM AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
7294   AM_RANGE(0xdf0000, 0xdfffff) AM_READWRITE(amiga_custom_r, amiga_custom_w) AM_BASE(&amiga_custom_regs)   /* Custom Chips */
7395   AM_RANGE(0xe80000, 0xe8ffff) AM_READWRITE(amiga_autoconfig_r, amiga_autoconfig_w)
7496   AM_RANGE(0xf00000, 0xffffff) AM_ROM AM_REGION(REGION_USER1, 0)   /* CDTV & System ROM */
r806r807
78100static ADDRESS_MAP_START(a1000_mem, ADDRESS_SPACE_PROGRAM, 16)
79101   AM_RANGE(0x000000, 0x03ffff) AM_MIRROR(0xc0000) AM_RAMBANK(1) AM_BASE(&amiga_chip_ram) AM_SIZE(&amiga_chip_ram_size)
80102   AM_RANGE(0xbfd000, 0xbfefff) AM_READWRITE(amiga_cia_r, amiga_cia_w)
103   AM_RANGE(0xc00000, 0xc3ffff) AM_READWRITE(amiga_custom_r, amiga_custom_w) /* See Note 1 above */
104   AM_RANGE(0xdc0000, 0xdc003f) AM_READWRITE(amiga_clock_r, amiga_clock_w);
81105   AM_RANGE(0xdf0000, 0xdfffff) AM_READWRITE(amiga_custom_r, amiga_custom_w) AM_BASE(&amiga_custom_regs)   /* Custom Chips */
82106   AM_RANGE(0xe80000, 0xe8ffff) AM_READWRITE(amiga_autoconfig_r, amiga_autoconfig_w)
83107   AM_RANGE(0xf80000, 0xfbffff) AM_ROM AM_REGION(REGION_USER1, 0)   /* Bootstrap ROM */
84   AM_RANGE(0xfc0000, 0xffffff) AM_RAMBANK(2)   /* Kickstart RAM */
108   AM_RANGE(0xfc0000, 0xffffff) AM_RAMBANK(2)   /* Writable Control Store RAM */
85109ADDRESS_MAP_END
86110
87111/***************************************************************************
r806r807
190214   MDRV_IMPORT_FROM(ntsc)
191215   MDRV_CPU_MODIFY("main")
192216   MDRV_CPU_PROGRAM_MAP(cdtv_mem, 0)
217   
218   MDRV_NVRAM_HANDLER(generic_0fill)
193219MACHINE_DRIVER_END
194220
195static MACHINE_DRIVER_START( a1000 )
221static MACHINE_DRIVER_START( a1000n )
196222   MDRV_IMPORT_FROM(ntsc)
197223   MDRV_CPU_MODIFY("main")
198224   MDRV_CPU_PROGRAM_MAP(a1000_mem, 0)
r806r807
211237   MDRV_SCREEN_VISIBLE_AREA((129-8)*2, (449+8-1)*2, 44-8, 300+8-1)
212238MACHINE_DRIVER_END
213239
240static MACHINE_DRIVER_START( a1000p )
241   MDRV_IMPORT_FROM(pal)
242   MDRV_CPU_MODIFY("main")
243   MDRV_CPU_PROGRAM_MAP(a1000_mem, 0)
244MACHINE_DRIVER_END
245
214246/***************************************************************************
215247
216248  Amiga specific stuff
r806r807
385417   ROMX_LOAD("a1000.bin", 0x000000, 0x002000, CRC(62f11c04) SHA1(c87f9fada4ee4e69f3cca0c36193be822b9f5fe6), ROM_GROUPWORD)
386418ROM_END
387419
420ROM_START(a1000p)
421   ROM_REGION16_BE(0x080000, REGION_USER1, 0)
422   ROMX_LOAD("a1000.bin", 0x000000, 0x002000, CRC(62f11c04) SHA1(c87f9fada4ee4e69f3cca0c36193be822b9f5fe6), ROM_GROUPWORD)
423ROM_END
424
388425ROM_START(cdtv)
389426   ROM_REGION16_BE(0x100000, REGION_USER1, 0)
390427   ROM_LOAD16_BYTE("391008.01", 0x000000, 0x020000, CRC(791cb14b) SHA1(277a1778924496353ffe56be68063d2a334360e4))
r806r807
423460***************************************************************************/
424461
425462/*     YEAR  NAME      PARENT   BIOS     COMPAT   MACHINE  INPUT    INIT     CONFIG   COMPANY                             FULLNAME             FLAGS */
426COMP(  1985, a1000n,   0,                0,       a1000,   amiga,   amiga,   amiga,   "Commodore Business Machines Co.",  "Commodore Amiga 1000 (NTSC-OCS)", GAME_COMPUTER | GAME_NOT_WORKING )
463COMP(  1985, a1000n,   0,                0,       a1000n,  amiga,   amiga,   amiga,   "Commodore Business Machines Co.",  "Commodore Amiga 1000 (NTSC-OCS)", GAME_COMPUTER | GAME_IMPERFECT_GRAPHICS )
464COMP(  1985, a1000p,   a1000n,           0,       a1000p,  amiga,   amiga,   amiga,   "Commodore Business Machines Co.",  "Commodore Amiga 1000 (PAL-OCS)", GAME_COMPUTER | GAME_IMPERFECT_GRAPHICS )
427465COMPB( 1987, a500n,    0,       amiga,   0,       ntsc,    amiga,   amiga,   amiga,   "Commodore Business Machines Co.",  "Commodore Amiga 500 (NTSC-OCS)", GAME_COMPUTER | GAME_IMPERFECT_GRAPHICS )
428466COMPB( 1987, a500p,    a500n,   amiga,   0,       pal,     amiga,   amiga,   amiga,   "Commodore Business Machines Co.",  "Commodore Amiga 500 (PAL-OCS)", GAME_COMPUTER | GAME_IMPERFECT_GRAPHICS )
429467COMP(  1991, cdtv,     0,                0,       cdtv,    amiga,   cdtv,    cdtv,    "Commodore Business Machines Co.",  "Commodore Amiga CDTV (NTSC)", GAME_NOT_WORKING )
docs/messnew.txt
r806r807
22
33New System Drivers Supported (in no particular order):
44------------------------------------------------------
5Atari ST (not working) [Curt Coder]
6Atari Mega ST (not working) [Curt Coder]
7Sega Dreamcast (not working)  [R. Belmont]
5- Amiga 1000 PAL-OCS [Ernesto Corvi]
6- Atari ST (not working) [Curt Coder]
7- Atari Mega ST (not working) [Curt Coder]
8- Sega Dreamcast (not working)  [R. Belmont]
89
910
1011
r806r807
3637- [AIM65] Updated the driver to use cartridges instead of hard-coded ROMs.
3738  This means you can now use the Forth and PL/65 ROMs.  [Dirk Best]
3839
40- [AMIGA] RTC support, added buffered keyboard support, properly implemented
41  a fix for the slow-memory detection bug in Kickstart 1.2.  [Ernesto Corvi]
42
43- [CDTV] Added NVRAM support.  [Ernesto Corvi]
44
3945- [COCO] Fixed PIA regression that prevented OS-9 level 1 from working.  (bug
4046  #1314) [Nate Woods]
4147

Previous 15994 Revisions Next


© 1998-2018 The MESS Team