Previous 199869 Revisions Next

r20460 Friday 25th January, 2013 at 04:31:01 UTC by Jonathan Gevaryahu
(MESS) cat.c (Canon cat): Added the 6ms timer and its counter. [Lord Nightmare]
[src/mess/drivers]cat.c

trunk/src/mess/drivers/cat.c
r20459r20460
4141ToDo:
4242* Canon Cat
4343- Find the mirrors for the write-only video control register and figure out
44  what the writes actually do
44  what the writes actually do; hook these up properly to screen timing etc
4545- The 2.40 (bios 0) firmware gets annoyed and thinks it has a phone call at
4646  random.
4747  (hit ctrl a few times to make it shut up for a bit or go into forth mode);
4848  The 1.74 (bios 1) firmware doesn't have this issue.
49  Figure out what causes it and make it stop.
50  (This MIGHT be related to the mysterious HK0NT line connecting gate array 2
51  to a toggle latch connecting to IP2 on the DUART; It may be necessary to
52  actually probe that line with a meter to see what address/bit causes it to
53  toggle, if the call can't be found in the cat source code)
49  Figure out what causes it and make it stop. May be OFFHOOK or more likely
50  the DUART thinks the phone is ringing constantly.
5451- Floppy drive (3.5", Single Sided Double Density MFM, ~400kb)
5552  * Cat has very low level control of data being read or written, much like
5653    the Amiga does
r20459r20460
7168- Centronics port
7269- RS232C port and Modem "port" connected to the DUART's two ports
7370- DTMF generator chip (connected to DUART 'user output' pins OP4,5,6,7)
74- 6ms timer at 0x83xxxx
71- Hook duart IP2 up to the 6ms timer
72- Correctly hook the duart interrupt to the 68k, including autovector using the vector register on the duart
7573- Watchdog timer/powerfail at 0x85xxxx
7674- Canon Cat released versions known: 1.74 (dumped), 2.40 (dumped), 2.42 (NEED DUMP)
75- Known Spellcheck roms: NH7-0684 (US, dumped); NH7-0724 (UK, NEED DUMP);
76  NH7-0813/0814 (Quebec/France, NEED DUMP); NH7-1019/1020/1021 (Germany, NEED DUMP)
77  It is possible the non-US roms were never officially released.
78  Wordlist sources: American Heritage (US and UK), Librarie Larousse (FR), Langenscheidt (DE)
7779
7880* Swyft
7981- Figure out the keyboard (interrupts are involved? or maybe an NMI on a
r20459r20460
8789
8890// Defines
8991
90#undef DEBUG_VIDEO_STATUS_W
92#undef DEBUG_VIDEO_ENABLE_W
9193#undef DEBUG_VIDEO_CONTROL_W
9294
9395#undef DEBUG_FLOPPY_CONTROL_W
r20459r20460
121123   cat_state(const machine_config &mconfig, device_type type, const char *tag)
122124      : driver_device(mconfig, type, tag),
123125      m_maincpu(*this, "maincpu"),
124      //m_nvram(*this, "nvram"), // merge with p_sram?
126      //m_nvram(*this, "nvram"), // merge with svram?
125127      //m_duart(*this, "duart68681"),
126128      //m_speaker(*this, "speaker"),
127      m_p_sram(*this, "p_sram"), // nvram
129      m_svram(*this, "svram"), // nvram
128130      m_p_videoram(*this, "p_videoram"),
129131      m_y0(*this, "Y0"),
130132      m_y1(*this, "Y1"),
r20459r20460
141143   //optional_device<nvram_device> m_nvram;
142144   //required_device<68681_device> m_duart;
143145   //required_device<speaker_sound_device> m_speaker;
144   optional_shared_ptr<UINT16> m_p_sram;
146   optional_shared_ptr<UINT16> m_svram;
145147   required_shared_ptr<UINT16> m_p_videoram;
146148   optional_ioport m_y0;
147149   optional_ioport m_y1;
r20459r20460
153155   optional_ioport m_y7;
154156   optional_ioport m_dipsw;
155157   emu_timer *m_keyboard_timer;
158   emu_timer *m_6ms_timer;
156159
157160   DECLARE_MACHINE_START(cat);
158161   DECLARE_MACHINE_RESET(cat);
r20459r20460
165168   UINT32 screen_update_cat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
166169   UINT32 screen_update_swyft(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
167170
168   DECLARE_WRITE16_MEMBER(cat_video_status_w);
169   DECLARE_WRITE16_MEMBER(cat_test_mode_w);
170   DECLARE_READ16_MEMBER(cat_s35213_r);
171   DECLARE_WRITE16_MEMBER(cat_s35213_w);
172171   DECLARE_READ16_MEMBER(cat_floppy_control_r);
173172   DECLARE_WRITE16_MEMBER(cat_floppy_control_w);
174173   DECLARE_WRITE16_MEMBER(cat_printer_data_w);
r20459r20460
180179   DECLARE_READ16_MEMBER(cat_floppy_status_r);
181180   DECLARE_READ16_MEMBER(cat_battery_r);
182181   DECLARE_WRITE16_MEMBER(cat_printer_control_w);
182   DECLARE_READ16_MEMBER(cat_modem_r);
183   DECLARE_WRITE16_MEMBER(cat_modem_w);
184   DECLARE_READ16_MEMBER(cat_6ms_counter_r);
185   DECLARE_WRITE16_MEMBER(cat_video_enable_w);
186   DECLARE_WRITE16_MEMBER(cat_test_mode_w);
183187   DECLARE_READ16_MEMBER(cat_2e80_r);
184188   DECLARE_READ16_MEMBER(cat_0080_r);
185189   DECLARE_READ16_MEMBER(cat_0000_r);
186190
187191   UINT8 m_duart_inp;// = 0x0e;
192   /* gate array 2 has a 16-bit counter inside which counts at 10mhz and
193      rolls over at FFFF->0000; on rollover (or maybe at FFFF terminal count)
194      it triggers the KTOBF output. It does this every 6.5535ms, which causes
195      a 74LS74 d-latch at IC100 to switch the state of the DUART IP2 line;
196      this causes the DUART to fire an interrupt, which makes the 68000 read
197      the keyboard.
198    */
199   UINT16 m_6ms_counter;
188200   UINT8 m_video_enable;
189201   UINT16 m_pr_cont;
190202   UINT8 m_keyboard_line;
191203
192204   TIMER_CALLBACK_MEMBER(keyboard_callback);
205   TIMER_CALLBACK_MEMBER(counter_6ms_callback);
193206   TIMER_CALLBACK_MEMBER(swyft_reset);
194207};
195208
r20459r20460
211224   }
212225}*/
213226
214WRITE16_MEMBER( cat_state::cat_test_mode_w )
215{
216#ifdef DEBUG_TEST_W
217   fprintf(stderr, "Test mode reg write: offset %06X, data %04X\n", 0x860000+(offset<<1), data);
218#endif
219}
220
221// AMI S35213 300/1200 Single Chip Modem (datasheet found at http://bitsavers.trailing-edge.com/pdf/ami/_dataBooks/1985_AMI_MOS_Products_Catalog.pdf on pdf page 243)
222READ16_MEMBER( cat_state::cat_s35213_r )
223{
224#ifdef DEBUG_MODEM_R
225   fprintf(stderr,"Read from s35213 modem address %06X\n", 0x820000+(offset<<1));
226#endif
227// HACK: return default 'sane' modem state
228   return 0x00;
229}
230
231WRITE16_MEMBER( cat_state::cat_s35213_w )
232{
233#ifdef DEBUG_MODEM_W
234   fprintf(stderr,"Write to s35213 modem address %06X, data %04X\n", 0x820000+(offset<<1), data);
235#endif
236}
237
238227/* 0x600000-0x65ffff Write: Video Generator (AKA NH4-5001 AKA Gate Array #1 @ IC30)
239228 writing to the video generator is done by putting the register number in the high 3 bits
240229 and the data to write in the lower 12 (14?) bits.
r20459r20460
334323#endif
335324}
336325
337
338326// 0x800008-0x800009: Floppy status register (called fd.status in the cat source code)
339327   /* FEDCBA98 (76543210 is ignored)
340328    * |||||||\-- ? always low
r20459r20460
343331    * ||||\----- /WRITE PROTECT: 1 = writable, 0 = protected (verified)
344332    * |||\------ /TRACK0: 0 = on track 0, 1 = not on track 0 (verified)
345333    * ||\------- /INDEX: 0 = index sensor active, 1 = index sensor inactive (verified)
346    * |\-------- ? low on drive 1, high on drive 0?
347    * \--------- ? usually high but occasionally low?
348    stuff that needs to be found here:
349    ready sense
334    * |\-------- ? this bit may indicate which drive is selected, i.e. same as floppy control bit 7; low on drive 1, high on drive 0?
335    * \--------- ? this bit may indicate 'data separator overflow'; it is usually low but becomes high if you manually select the floppy drive
336    ALL of these bits except bit 7 seem to be reset when the selected drive in floppy control is switched
350337    */
351338READ16_MEMBER( cat_state::cat_floppy_status_r )
352339{
r20459r20460
415402   m_pr_cont = data;
416403}
417404
418WRITE16_MEMBER( cat_state::cat_video_status_w )
405// 0x820000: AMI S35213 300/1200 Single Chip Modem (datasheet found at http://bitsavers.trailing-edge.com/pdf/ami/_dataBooks/1985_AMI_MOS_Products_Catalog.pdf on pdf page 243)
406READ16_MEMBER( cat_state::cat_modem_r )
419407{
408#ifdef DEBUG_MODEM_R
409   fprintf(stderr,"Read from s35213 modem address %06X\n", 0x820000+(offset<<1));
410#endif
411// HACK: return default 'sane' modem state
412   return 0x00;
413}
414
415WRITE16_MEMBER( cat_state::cat_modem_w )
416{
417#ifdef DEBUG_MODEM_W
418   fprintf(stderr,"Write to s35213 modem address %06X, data %04X\n", 0x820000+(offset<<1), data);
419#endif
420}
421
422// 0x830000: 6ms counter (used for KTOBF)
423READ16_MEMBER( cat_state::cat_6ms_counter_r )
424{
425   return m_6ms_counter;
426}
427
428// 0x840000: video enable (also controls hsync/vsync?)
429WRITE16_MEMBER( cat_state::cat_video_enable_w )
430{
420431   /*
421432    * 76543210
422433    * |||||||\-- ?
423434    * ||||||\--- ?
424435    * |||||\---- Video enable (1 = video on, 0 = video off/screen black)
425    * ||||\----- ? (always written as 1?)
426    * |||\------ ? (always written as 1?)
436    * ||||\----- ? (always written as 1?) maybe hsync
437    * |||\------ ? (always written as 1?) maybe vsync
427438    * ||\------- ?
428439    * |\-------- ?
429440    * \--------- ?
430441    */
431442
432#ifdef DEBUG_VIDEO_STATUS_W
433   fprintf(stderr, "Video status reg write: offset %06X, data %04X\n", 0x840000+(offset<<1), data);
443#ifdef DEBUG_VIDEO_ENABLE_W
444   fprintf(stderr, "Video enable reg write: offset %06X, data %04X\n", 0x840000+(offset<<1), data);
434445#endif
435446   m_video_enable = BIT( data, 2 );
436447}
437448
449// 0x850000: test mode registers
450WRITE16_MEMBER( cat_state::cat_test_mode_w )
451{
452#ifdef DEBUG_TEST_W
453   fprintf(stderr, "Test mode reg write: offset %06X, data %04X\n", 0x860000+(offset<<1), data);
454#endif
455}
456
438457// open bus etc handlers
439458READ16_MEMBER( cat_state::cat_2e80_r )
440459{
r20459r20460
455474/* Canon cat memory map, based on a 16MB dump of the entire address space of a running unit using forth "1000000 0 do i c@ semit loop"
45647568k address map:
457476a23 a22 a21 a20 a19 a18 a17 a16 a15 a14 a13 a12 a11 a10 a9  a8  a7  a6  a5  a4  a3  a2  a1  (a0 via UDS/LDS)
4580   0   *   x   x   *   *   *   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x       *GATE ARRAY 2 DECODES THESE LINES TO ENABLE THIS AREA*
477*i  *i  *   x   x   *   *   *   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x       *GATE ARRAY 2 DECODES THESE LINES TO ENABLE THIS AREA* (a23 and a22 are indirectly decoded via the /RAMROMCS and /IOCS lines from gate array 1)
4594780   0   0   0   x   0   a   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   b       R   ROM (ab: 00=ic4 01=ic2 10=ic5 11=ic3) (EPROM 27C512 x 4) [controlled via GA2 /ROMCS]
4604790   0   0   0   x   1   0   0   x   x   *   *   *   *   *   *   *   *   *   *   *   *   *   0       RW  SVRAM ic11 d4364 (battery backed) [controlled via GA2 /RAMCS]
4614800   0   0   0   x   1   x   1   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   0       O   OPEN BUS (reads as 0x2e) [may be controlled via GA2 /RAMCS?]
r20459r20460
485504                                                                            1   x   x   x   0       W?  Unknown (reads as 0x00)
4865051   0   0   x   x   0   0   1   x   x   x   x   x   x   x   x   x   x   x   *   *   *   *   1       RW  68681 DUART at ic34 [controlled via GA2 /DUARTCS]
4875061   0   0   x   x   0   1   0   x   x   x   x   x   x   x   x   x   x   *   *   *   *   *   0       RW  Modem Chip AMI S35213 @ IC37 DATA BIT 7 ONLY [controlled via GA2 /SMCS]
4881   0   0   x   x   0   1   1   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       RW  Read: Fixed 16-bit counter. increments once per frame? Write: Modem Chip?
4891   0   0   x   x   1   0   0   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       W?  Video Control register? (screen enable on bit 3?) (reads as 0x2e80)
5071   0   0   x   x   0   1   1   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       R   Read: Fixed 16-bit counter from ga2. increments once another 16-bit counter clocked at 10mhz overflows
5081   0   0   x   x   1   0   0   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       W?  Video/Sync enable register? (screen enable on bit 3?) (reads as 0x2e80)
4905091   0   0   x   x   1   0   1   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       R?  reads as 0x0100 0x0101 or 0x0102, some sort of test register or video status register?
4915101   0   0   x   x   1   1   0   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       W?  Test register? (reads as 0x0000)
4925111   0   0   x   x   1   1   1   x   x   x   x   x   x   x   x   x   x   x   x   x   x   x   *       ?   Unknown (reads as 0x2e80)
r20459r20460
499518static ADDRESS_MAP_START(cat_mem, AS_PROGRAM, 16, cat_state)
500519   ADDRESS_MAP_UNMAP_HIGH
501520   AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_MIRROR(0x080000) // 256 KB ROM
502   AM_RANGE(0x040000, 0x043fff) AM_RAM AM_SHARE("p_sram") AM_MIRROR(0x08C000)// SRAM powered by battery
521   AM_RANGE(0x040000, 0x043fff) AM_RAM AM_SHARE("svram") AM_MIRROR(0x08C000)// SRAM powered by battery
503522   AM_RANGE(0x200000, 0x27ffff) AM_ROM AM_REGION("svrom",0x0000) AM_MIRROR(0x180000) // SV ROM
504523   AM_RANGE(0x400000, 0x47ffff) AM_RAM AM_SHARE("p_videoram") AM_MIRROR(0x180000) // 512 KB RAM
505524   AM_RANGE(0x600000, 0x67ffff) AM_READWRITE(cat_2e80_r,cat_video_control_w) AM_MIRROR(0x180000) // Gate Array #1: Video
r20459r20460
513532   AM_RANGE(0x80000e, 0x80000f) AM_READWRITE(cat_battery_r,cat_printer_control_w) AM_MIRROR(0x18FFE0) // Centronics Printer Control, keyboard led and country code enable
514533   AM_RANGE(0x800010, 0x80001f) AM_READ(cat_0080_r) AM_MIRROR(0x18FFE0) // Open bus?
515534   AM_RANGE(0x810000, 0x81001f) AM_DEVREADWRITE8_LEGACY("duart68681", duart68681_r, duart68681_w, 0xff ) AM_MIRROR(0x18FFE0)
516   AM_RANGE(0x820000, 0x82003f) AM_READWRITE(cat_s35213_r,cat_s35213_w) AM_MIRROR(0x18FFC0) // AMI S35213 Modem Chip, all access is on bit 7
517   //AM_RANGE(0x830000, 0x830001) AM_READ(cat_6ms_counter) AM_MIRROR(0x18FFFE) // 6ms counter?
518   AM_RANGE(0x840000, 0x840001) AM_READWRITE(cat_2e80_r,cat_video_status_w) AM_MIRROR(0x18FFFE) // Video status/Output port register
535   AM_RANGE(0x820000, 0x82003f) AM_READWRITE(cat_modem_r,cat_modem_w) AM_MIRROR(0x18FFC0) // AMI S35213 Modem Chip, all access is on bit 7
536   AM_RANGE(0x830000, 0x830001) AM_READ(cat_6ms_counter_r) AM_MIRROR(0x18FFFE) // 16bit 6ms counter clocked by output of another 16bit counter clocked at 10mhz
537   AM_RANGE(0x840000, 0x840001) AM_READWRITE(cat_2e80_r,cat_video_enable_w) AM_MIRROR(0x18FFFE) // Video status/Output port register
519538   //AM_RANGE(0x850000, 0x850001) AM_READ(cat_video_status) AM_MIRROR(0x18FFFE) // video status read: hblank, vblank or draw?
520539   AM_RANGE(0x860000, 0x860001) AM_READWRITE(cat_0000_r, cat_test_mode_w) AM_MIRROR(0x18FFFE) // Test mode
521540   AM_RANGE(0x870000, 0x870001) AM_READ(cat_2e80_r) AM_MIRROR(0x18FFFE) // Open bus?
r20459r20460
646665   machine().device("maincpu")->execute().set_input_line(M68K_IRQ_1, ASSERT_LINE);
647666}
648667
668// This is effectively also the KTOBF line to the d-latch before the duart
669TIMER_CALLBACK_MEMBER(cat_state::counter_6ms_callback)
670{
671   // TODO: emulate the d-latch here and poke the duart's input ports
672   m_6ms_counter++;
673}
674
649675static IRQ_CALLBACK(cat_int_ack)
650676{
651677   device->machine().device("maincpu")->execute().set_input_line(M68K_IRQ_1,CLEAR_LINE);
r20459r20460
655681MACHINE_START_MEMBER(cat_state,cat)
656682{
657683   m_duart_inp = 0x0e;
684   m_6ms_counter = 0;
658685   m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cat_state::keyboard_callback),this));
659   machine().device<nvram_device>("nvram")->set_base(m_p_sram, 0x4000);
686   m_6ms_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cat_state::counter_6ms_callback),this));
687   machine().device<nvram_device>("nvram")->set_base(m_svram, 0x4000);
660688}
661689
662690MACHINE_RESET_MEMBER(cat_state,cat)
663691{
664692   machine().device("maincpu")->execute().set_irq_acknowledge_callback(cat_int_ack);
693   m_6ms_counter = 0;
665694   m_keyboard_timer->adjust(attotime::zero, 0, attotime::from_hz(120));
695   m_6ms_timer->adjust(attotime::zero, 0, attotime::from_hz((XTAL_19_968MHz/2)/65536));
666696}
667697
668698VIDEO_START_MEMBER(cat_state,cat)
r20459r20460
735765   return 0;
736766}
737767
768/* TODO: the duart is the only thing actually connected to the cpu IRQ pin
769 * The KTOBF output of the gate array 2 (itself the terminal count output
770 * of a 16-bit counter clocked at ~10mhz, hence 6.5536ms period) goes to a
771 * d-latch and inputs on ip2 of the duart, causing the duart to fire an irq;
772 * this is used by the cat to read the keyboard.
773 */
738774static void duart_irq_handler(device_t *device, int state, UINT8 vector)
739775{
740776#ifdef DEBUG_DUART_IRQ_HANDLER
r20459r20460
860896   // since ROM_FILL16BE(0x0, 0x80000, 0x2e80) doesn't exist, the even bytes and latter chunk of the svrom space are filled in in DRIVER_INIT
861897   // Romspace here is a little strange: there are 3 rom sockets on the board:
862898   // svrom-0 maps to 200000-21ffff every ODD byte (d8-d0)
863   ROMX_LOAD( "uv1__nh7-0684__hn62301apc11__7h1.ic6", 0x00000, 0x20000, CRC(229CA210) SHA1(564B57647A34ACDD82159993A3990A412233DA14), ROM_SKIP(1)) // this is a 28pin tc531000 mask rom, 128KB long
899   ROMX_LOAD( "uv1__nh7-0684__hn62301apc11__7h1.ic6", 0x00000, 0x20000, CRC(229ca210) SHA1(564b57647a34acdd82159993a3990a412233da14), ROM_SKIP(1)) // this is a 28pin tc531000 mask rom, 128KB long
864900   // svrom-1 maps to 200000-21ffff every EVEN byte (d15-d7)
865901   // no rom is in the socket; it reads as open bus 0x2E
866902   // svrom-2 maps to 240000-25ffff every ODD byte (d8-d0)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team