Previous 15994 Revisions Next

r3855 Tuesday 16th December, 2008 at 21:44:39 UTC by Antoine Mine
Using MC6843, MC6846, MC6854, MEA8000 as devices
[src/mess/devices]thomflop.c
[src/mess/drivers]thomson.c
[src/mess/formats]thom_dsk.c
[src/mess/includes]thomson.h
[src/mess/machine]thomson.c
[src/mess/video]thomson.c

src/mess/video/thomson.c
r3854r3855
77**********************************************************************/
88
99#include <math.h>
10#include "driver.h"
1110#include "includes/thomson.h"
12#include "cpu/m6809/m6809.h"
13#include "machine/6821pia.h"
14#include "machine/mc6846.h"
1511
1612
1713#define VERBOSE 0
r3854r3855
9995
10096
10197/* elapsed time from begining of frame, in us */
102INLINE unsigned thom_video_elapsed ( void )
98INLINE unsigned thom_video_elapsed ( running_machine *machine )
10399{
104100   unsigned u;
105101   attotime elapsed = timer_timeelapsed( thom_video_timer );
r3854r3855
111107
112108
113109
114struct thom_vsignal thom_get_vsignal ( void )
110struct thom_vsignal thom_get_vsignal ( running_machine *machine )
115111{
116112   struct thom_vsignal v;
117   int gpl = thom_video_elapsed() - 64 * THOM_BORDER_HEIGHT - 7;
113   int gpl = thom_video_elapsed( machine ) - 64 * THOM_BORDER_HEIGHT - 7;
118114   if ( gpl < 0 )
119115      gpl += 19968;
120116
r3854r3855
296292
297293
298294/* either the border index or its palette entry has changed */
299static void thom_border_changed( void )
295static void thom_border_changed( running_machine *machine )
300296{
301   unsigned l = thom_video_elapsed();
297   unsigned l = thom_video_elapsed( machine );
302298   unsigned y = l >> 6;
303299   unsigned x = l & 63;
304300   unsigned color =  thom_pal[ thom_border_index ];
r3854r3855
335331
336332
337333/* the video mode or page has changed */
338static void thom_gplinfo_changed( void )
334static void thom_gplinfo_changed( running_machine *machine )
339335{
340   unsigned l = thom_video_elapsed() - THOM_BORDER_HEIGHT * 64 - 7;
336   unsigned l = thom_video_elapsed( machine ) - THOM_BORDER_HEIGHT * 64 - 7;
341337   unsigned y = l >> 6;
342338   unsigned x = l & 63;
343339   int modepage = ((int)thom_vmode << 8) | thom_vpage;
r3854r3855
350346
351347
352348
353void thom_set_border_color ( unsigned index )
349void thom_set_border_color ( running_machine *machine, unsigned index )
354350{
355351   assert( index < 16 );
356352   if ( index != thom_border_index )
357353   {
358      LOG (( "thom_set_border_color: %i at line %i col %i\n", index, thom_video_elapsed() / 64, thom_video_elapsed() % 64  ));
354      LOG (( "thom_set_border_color: %i at line %i col %i\n", index, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64  ));
359355      thom_border_index = index;
360      thom_border_changed();
356      thom_border_changed( machine );
361357   }
362358}
363359
364360
365361
366void thom_set_palette ( unsigned index, UINT16 color )
362void thom_set_palette ( running_machine *machine, unsigned index, UINT16 color )
367363{
368364   assert( index < 16 );
369365
r3854r3855
373369   if ( thom_pal[ index ] == color )
374370      return;
375371
376   LOG (( "thom_set_palette: %i to %03x at line %i col %i\n", index, color, thom_video_elapsed() / 64, thom_video_elapsed() % 64  ));
372   LOG (( "thom_set_palette: %i to %03x at line %i col %i\n", index, color, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64  ));
377373
378374   thom_pal[ index ] = color;
379375   if ( index == thom_border_index )
380      thom_border_changed();
376      thom_border_changed( machine );
381377   thom_pal_changed = 1;
382378   thom_vstate_dirty = 1;
383379}
384380
385381
386382
387void thom_set_video_mode ( unsigned mode )
383void thom_set_video_mode ( running_machine *machine, unsigned mode )
388384{
389385   assert( mode < THOM_VMODE_NB );
390386
391387   if ( mode != thom_vmode )
392388   {
393      LOG (( "thom_set_video_mode: %i at line %i, col %i\n", mode, thom_video_elapsed() / 64, thom_video_elapsed() % 64 ));
389      LOG (( "thom_set_video_mode: %i at line %i, col %i\n", mode, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64 ));
394390      thom_vmode = mode;
395      thom_gplinfo_changed();
391      thom_gplinfo_changed( machine );
396392      thom_hires_better |= thom_mode_is_hires( mode );
397393   }
398394}
399395
400396
401397
402void thom_set_video_page ( unsigned page )
398void thom_set_video_page ( running_machine *machine, unsigned page )
403399{
404400   assert( page < THOM_NB_PAGES )
405401      ;
406402   if ( page != thom_vpage ) {
407      LOG (( "thom_set_video_page: %i at line %i col %i\n", page, thom_video_elapsed() / 64, thom_video_elapsed() % 64  ));
403      LOG (( "thom_set_video_page: %i at line %i col %i\n", page, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64  ));
408404      thom_vpage = page;
409      thom_gplinfo_changed();
405      thom_gplinfo_changed( machine );
410406   }
411407}
412408
r3854r3855
416412
417413
418414
419typedef void ( *thom_scandraw ) ( UINT8* vram, UINT16* dst, UINT16* pal,
415typedef void ( *thom_scandraw ) ( running_machine *machine, UINT8* vram, UINT16* dst, UINT16* pal,
420416              int org, int len );
421417
422418
423419
424420#define UPDATE( name, res )                  \
425   static void name##_scandraw_##res ( UINT8* vram, UINT16* dst,   UINT16* pal, \
421   static void name##_scandraw_##res ( running_machine *machine,   \
422                   UINT8* vram, UINT16* dst,   UINT16* pal, \
426423                   int org, int len )      \
427424   {                        \
428425      unsigned gpl;                  \
r3854r3855
810807            xx++;
811808         } while ( xx < 40 && thom_vmodepage[xx] == -1 );
812809         thom_scandraw_funcs[ mode ][ thom_hires ]
813            ( thom_vram + y * 40 + page * 0x4000,
810            ( machine,
811              thom_vram + y * 40 + page * 0x4000,
814812              thom_vbody + y * 320 * (thom_hires+1),
815813              thom_last_pal, x, xx-x );
816814         x = xx;
r3854r3855
873871
874872
875873
876void thom_floppy_active ( int write )
874void thom_floppy_active ( running_machine *machine, int write )
877875{
878876   int fold = FLOP_STATE, fnew;
879877
r3854r3855
10091007
10101008static emu_timer *thom_init_timer;
10111009
1012static void (*thom_init_cb) ( running_machine *machine, int );
1010static void (*thom_init_cb) ( running_machine *machine, int init );
10131011
10141012
10151013
1016void thom_set_init_callback ( void (*cb) ( running_machine *machine, int init ) )
1014void thom_set_init_callback ( running_machine *machine, void (*cb) ( running_machine *machine, int init ) )
10171015{
10181016   thom_init_cb = cb;
10191017}
r3854r3855
10231021static TIMER_CALLBACK( thom_set_init )
10241022{
10251023   int init = param;
1026   LOG (( "%f thom_set_init: %i, at line %i col %i\n", attotime_to_double(timer_get_time(machine)), init, thom_video_elapsed() / 64, thom_video_elapsed() % 64 ));
1024   LOG (( "%f thom_set_init: %i, at line %i col %i\n", attotime_to_double(timer_get_time(machine)), init, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64 ));
10271025
10281026   if ( thom_init_cb )
10291027      thom_init_cb( machine, init );
r3854r3855
11021100   0x0777, /* 8: gray */         0x033a, /* 9: pink */
11031101   0x03a3, /* a: light green */  0x03aa, /* b: light yellow */
11041102   0x0a33, /* c: light blue */   0x0a3a, /* d: redish pink */
1105   0x0ee7, /* e: light cyan */   0x007b, /* f: orange */
1103   0x0ee7, /* e: light cyan */   0x003b, /* f: orange */
11061104};
11071105
11081106
src/mess/includes/thomson.h
r3854r3855
99#ifndef _THOMSON_H_
1010#define _THOMSON_H_
1111
12#include "driver.h"
13#include "cpu/m6809/m6809.h"
14#include "machine/6821pia.h"
15#include "machine/mc6846.h"
16#include "machine/6850acia.h"
17#include "machine/6551.h"
18#include "sound/dac.h"
19#include "audio/mea8000.h"
20#include "devices/cartslot.h"
21#include "machine/centroni.h"
22#include "devices/printer.h"
23#include "includes/serial.h"
24#include "devices/cassette.h"
25#include "machine/wd17xx.h"
26#include "machine/mc6843.h"
27#include "machine/mc6846.h"
28#include "machine/mc6854.h"
29#include "formats/thom_cas.h"
30#include "devices/thomflop.h"
31#include "formats/thom_dsk.h"
1232
33
1334/*----------- defined in machine/thomson.c -----------*/
1435
1536/*************************** common ********************************/
r3854r3855
3758#define THOM_FLOP_BANK  4 /* external floppy controller ROM */
3859#define THOM_BASE_BANK  5 /* system RAM */
3960
40
4161/* serial */
4262extern DEVICE_START( thom_serial );
4363extern DEVICE_IMAGE_LOAD( thom_serial );
4464extern DEVICE_IMAGE_UNLOAD( thom_serial );
4565
46
4766/***************************** TO7 / T9000 *************************/
4867
4968/* cartridge bank-switching */
r3854r3855
6281extern MACHINE_START ( to7 );
6382extern MACHINE_RESET ( to7 );
6483
84/* timer */
85extern mc6846_interface to7_timer;
6586
87/* speech synthesis */
88extern mea8000_interface to7_speech;
89
90/* floppy */
91extern mc6843_interface to7_6843_itf;
92extern mc6854_interface to7_network_iface;
93
94/* modem */
95extern acia6850_interface to7_modem;
96
97
6698/***************************** TO7/70 ******************************/
6799
68100/* gate-array */
r3854r3855
72104extern MACHINE_START ( to770 );
73105extern MACHINE_RESET ( to770 );
74106
107extern mc6846_interface to770_timer;
108
75109/***************************** MO5 ******************************/
76110
77111/* gate-array */
r3854r3855
113147extern MACHINE_START ( to9 );
114148extern MACHINE_RESET ( to9 );
115149
150extern mc6846_interface to9_timer;
116151
152
117153/***************************** TO8 ******************************/
118154
119155/* bank-switching */
r3854r3855
144180extern MACHINE_START ( to8 );
145181extern MACHINE_RESET ( to8 );
146182
183extern mc6846_interface to8_timer;
147184
185
148186/***************************** TO9+ ******************************/
149187
150188extern MACHINE_START ( to9p );
151189extern MACHINE_RESET ( to9p );
152190
191extern mc6846_interface to9p_timer;
153192
193
154194/***************************** MO6 ******************************/
155195
156196extern READ8_HANDLER  ( mo6_cartridge_r );
r3854r3855
240280};
241281
242282/* current video position */
243extern struct thom_vsignal thom_get_vsignal ( void );
283extern struct thom_vsignal thom_get_vsignal ( running_machine *machine );
244284
245285
246286/************************* lightpen ********************************/
r3854r3855
264304extern VIDEO_EOF    ( thom );
265305
266306/* pass video init signal */
267extern void thom_set_init_callback ( void (*cb) ( running_machine *machine, int init ) );
307extern void thom_set_init_callback ( running_machine *machine, void (*cb) ( running_machine *machine, int init ) );
268308
269309/* TO7 TO7/70 MO5 video bank switch */
270310extern void thom_set_mode_point ( running_machine *machine, int point );
271311
272312/* set the palette index for the border color */
273extern void thom_set_border_color ( unsigned color );
313extern void thom_set_border_color ( running_machine *machine, unsigned color );
274314
275315/* set one of 16 palette indices to one of 4096 colors */
276extern void thom_set_palette ( unsigned index, UINT16 color );
316extern void thom_set_palette ( running_machine *machine, unsigned index, UINT16 color );
277317
278318
279319/* video modes */
r3854r3855
292332#define THOM_VMODE_NB         12
293333
294334/* change the current video-mode */
295extern void thom_set_video_mode ( unsigned mode );
335extern void thom_set_video_mode ( running_machine *machine, unsigned mode );
296336
297337/* select which video page shown among the 4 available */
298extern void thom_set_video_page ( unsigned page );
338extern void thom_set_video_page ( running_machine *machine, unsigned page );
299339
300340/* to tell there is some floppy activity, stays up for a few frames */
301extern void thom_floppy_active ( int write );
341extern void thom_floppy_active ( running_machine *machine, int write );
302342
303343
304344/***************************** TO7 / T9000 *************************/
src/mess/machine/thomson.c
r3854r3855
77**********************************************************************/
88
99#include "driver.h"
10#include "deprecat.h"
11#include "includes/thomson.h"
12#include "cpu/m6809/m6809.h"
13#include "machine/6821pia.h"
14#include "machine/mc6846.h"
15#include "machine/6850acia.h"
16#include "machine/6551.h"
17#include "sound/dac.h"
18#include "audio/mea8000.h"
19#include "devices/cartslot.h"
20#include "machine/centroni.h"
21#include "devices/printer.h"
22#include "includes/serial.h"
23#include "devices/cassette.h"
2410#include "devices/thomflop.h"
2511#include "formats/thom_dsk.h"
12#include "includes/thomson.h"
2613
2714#define VERBOSE       0
2815#define VERBOSE_IRQ   0
r3854r3855
10592         /* hack, feed existing bits */
10693         if ( bitpos >= to7_k7_bitsize )
10794            bitpos = to7_k7_bitsize -1;
108//         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n",
109//            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, bitpos,
110//            to7_k7_bits[ bitpos ] ));
95         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n",
96            cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), state, pos, bitpos,
97            to7_k7_bits[ bitpos ] ));
11198         return to7_k7_bits[ bitpos ];
11299      }
113100      else
r3854r3855
126113               chg++;
127114         }
128115         k = ( chg >= 13 ) ? 1 : 0;
129//         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n",
130//            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, bitpos,
131//            k, chg ));
116         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n",
117            cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), state, pos, bitpos,
118            k, chg ));
132119         return k;
133120      }
134121
r3854r3855
150137
151138static WRITE8_HANDLER ( to7_set_cassette_motor )
152139{
153   const device_config* img = thom_cassette_img(space->machine);
140   const device_config* img = thom_cassette_img( space->machine );
154141   cassette_state state = cassette_get_state( img );
155142   double pos = cassette_get_position(img);
156143
157144   LOG (( "$%04x %f to7_set_cassette_motor: cassette motor %s bitpos=%i\n",
158          cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on",
145          cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(img->machine)), data ? "off" : "on",
159146          (int) (pos / TO7_BIT_LENGTH) ));
160147
161148   if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 )
r3854r3855
204191      cassette_get_sample( cass, 0, pos, 0, &hbit );
205192      hbit = hbit >= 0;
206193
207//      VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n",
208//         cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos,
209//         (int) (pos / MO5_HBIT_LENGTH), hbit ));
194      VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n",
195         cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), state, pos,
196         (int) (pos / MO5_HBIT_LENGTH), hbit ));
210197      return hbit;
211198   }
212199   else
r3854r3855
225212
226213static WRITE8_HANDLER ( mo5_set_cassette_motor )
227214{
228   const device_config* img = thom_cassette_img(space->machine);
215   const device_config* img = thom_cassette_img( space->machine );
229216   cassette_state state = cassette_get_state( img );
230217   double pos = cassette_get_position(img);
231218
232219   LOG (( "$%04x %f mo5_set_cassette_motor: cassette motor %s hbitpos=%i\n",
233          cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on",
220          cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on",
234221          (int) (pos / MO5_HBIT_LENGTH) ));
235222
236223   if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED &&  !data && pos > 0.3 )
r3854r3855
293280   if ( old && !thom_firq )
294281      LOG_IRQ(( "%f thom_set_firq: firq line down %i\n", attotime_to_double(timer_get_time(machine)), line ));
295282
296   cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE );
283   cpu_set_input_line( machine->cpu[0], M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE );
297284}
298285
299286
r3854r3855
302289{
303290   thom_irq = 0;
304291   thom_firq = 0;
305   cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, CLEAR_LINE );
306   cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, CLEAR_LINE );
292   cpu_set_input_line( machine->cpu[0], M6809_IRQ_LINE, CLEAR_LINE );
293   cpu_set_input_line( machine->cpu[0], M6809_FIRQ_LINE, CLEAR_LINE );
307294}
308295
309296
310297
311298static void thom_irq_init ( running_machine *machine )
312299{
313   state_save_register_global(machine,  thom_irq );
314   state_save_register_global(machine,  thom_firq );
300   state_save_register_global( machine, thom_irq );
301   state_save_register_global( machine, thom_firq );
315302}
316303
317304
r3854r3855
321308   thom_set_irq  ( machine, 0, state );
322309}
323310
311static void thom_dev_irq_0  ( const device_config *device, int state )
312{
313   thom_irq_0( device->machine, state );
314}
315
316
317
324318static void thom_irq_1  ( running_machine *machine, int state )
325319{
326320   thom_set_irq  ( machine, 1, state );
r3854r3855
365359
366360
367361
368static void thom_set_caps_led ( int led )
362static void thom_set_caps_led ( running_machine *machine, int led )
369363{
370364   output_set_value( "led0", led );
371365}
r3854r3855
512506
513507static void to7_update_cart_bank(running_machine *machine)
514508{
509   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
515510   static int old_bank = -1;
516511   int bank = 0;
517512   if ( thom_cart_nb_banks )
518513   {
519514      bank = thom_cart_bank % thom_cart_nb_banks;
520      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r );
515      memory_install_read8_handler(space, 0x0000, 0x0003, 0, 0, to7_cartridge_r );
521516   }
522517
523518   if ( bank != old_bank )
r3854r3855
564559
565560
566561
567static WRITE8_HANDLER ( to7_timer_port_out )
562static WRITE8_DEVICE_HANDLER ( to7_timer_port_out )
568563{
569   thom_set_mode_point( space->machine, data & 1 );          /* bit 0: video bank switch */
570   thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */
571   thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* bits 4-6: border color */
564   thom_set_mode_point( device->machine, data & 1 );          /* bit 0: video bank switch */
565   thom_set_caps_led( device->machine, (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */
566   thom_set_border_color( device->machine,
567                ((data & 0x10) ? 1 : 0) |           /* bits 4-6: border color */
572568                ((data & 0x20) ? 2 : 0) |
573569                ((data & 0x40) ? 4 : 0) );
574570}
575571
576572
577573
578static WRITE8_HANDLER ( to7_timer_cp2_out )
574static WRITE8_DEVICE_HANDLER ( to7_timer_cp2_out )
579575{
580576   dac_data_w( THOM_SOUND_BUZ, data ? 0x80 : 0); /* 1-bit buzzer */
581577}
582578
583579
584580
585static READ8_HANDLER ( to7_timer_port_in )
581static READ8_DEVICE_HANDLER ( to7_timer_port_in )
586582{
587   int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0;
588   int cass = to7_get_cassette(space->machine) ? 0x80 : 0;
583   int lightpen = (input_port_read(device->machine, "lightpen_button") & 1) ? 2 : 0;
584   int cass = to7_get_cassette(device->machine) ? 0x80 : 0;
589585   return lightpen | cass;
590586}
591587
592588
593589
594static WRITE8_HANDLER ( to7_timer_tco_out )
590static WRITE8_DEVICE_HANDLER ( to7_timer_tco_out )
595591{
596592   /* 1-bit cassette output */
597   to7_set_cassette( space->machine, data );
593   to7_set_cassette( device->machine, data );
598594}
599595
600596
601597
602static const mc6846_interface to7_timer =
598mc6846_interface to7_timer =
603599{
604600   to7_timer_port_out, NULL, to7_timer_cp2_out,
605601   to7_timer_port_in, to7_timer_tco_out,
606   thom_irq_0
602   thom_dev_irq_0
607603};
608604
609605
r3854r3855
756752{
757753   /* acknowledge from centronics printer to PIA */
758754   int ack = (data & CENTRONICS_ACKNOWLEDGE) ? 1 : 0;
759   //LOG (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", attotime_to_double(timer_get_time(machine)), data, ack ));
755   //LOG_IO (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", attotime_to_double(timer_get_time(machine)), data, ack ));
760756   pia_set_input_cb1( THOM_PIA_IO, ack );
761757}
762758
r3854r3855
767763   int tx  = data & 1;
768764   int dtr = ( data & 2 ) ? 1 : 0;
769765
770   LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n",  cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), tx, dtr ));
766   LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n",  cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), tx, dtr ));
771767   if ( dtr )
772768      to7_io_line.State |=  SERIAL_STATE_DTR;
773769   else
r3854r3855
790786   else
791787      cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0;
792788
793   LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to7_io_mode(space->machine), cts, dsr, rd ));
789   LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to7_io_mode(space->machine), cts, dsr, rd ));
794790
795791   return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0);
796792}
r3854r3855
801797{
802798   /* set 8-bit data */
803799
804   LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
800   LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
805801
806802   centronics_write_data( 0, data );
807803}
r3854r3855
812808{
813809   /* send STROBE to printer */
814810
815   LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
811   LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
816812
817813   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE );
818814}
819815
820816
821817
822static void to7_io_in_callback ( int id, unsigned long state )
818static void to7_io_in_cb ( int id, unsigned long state )
823819{
824820   /* our peer's state has changed */
825821   to7_io_line.input_state = state;
r3854r3855
842838
843839
844840
845static void thom_centronics_reset( void )
841static void thom_centronics_reset( running_machine *machine )
846842{
847843   centronics_write_handshake
848844      ( 0,
r3854r3855
858854static void to7_io_reset( running_machine *machine )
859855{
860856   LOG (( "to7_io_reset called\n" ));
861   thom_centronics_reset();
857   thom_centronics_reset(machine);
862858   /* pia_reset() is called in MACHINE_RESET */
863859   pia_set_port_a_z_mask( THOM_PIA_IO, 0x03 );
864860   to7_io_line.input_state = SERIAL_STATE_CTS;
r3854r3855
870866
871867
872868
873static void to7_io_init( void )
869static void to7_io_init( running_machine *machine )
874870{
875871   LOG (( "to7_io_init: CC 90-323 serial / parallel extension\n" ));
876872   pia_config( THOM_PIA_IO, &to7_io );
877873   centronics_config( 0, &to7_centronics );
878874   serial_connection_init( &to7_io_line );
879   serial_connection_set_in_callback( &to7_io_line, to7_io_in_callback );
875   serial_connection_set_in_callback( &to7_io_line, to7_io_in_cb );
880876}
881877
882878
r3854r3855
891887
892888
893889
894static void to7_rf57932_reset( void )
895{
896   LOG (( "to7_rf57932_reset called\n" ));
897}
898
899
900
901890/* ------------  MD 90-120 MODEM extension (not functional) ------------ */
902891
903892/* Features:
r3854r3855
916905
917906
918907
919static void to7_modem_cb(const device_config *device, int state )
908static void to7_modem_cb( const device_config *device, int state )
920909{
921910   LOG(( "to7_modem_cb: called %i\n", state ));
922911}
r3854r3855
932921
933922
934923
935const acia6850_interface to7_acia_modem =
924acia6850_interface to7_modem =
936925{
937926   1200, 1200, /* 1200 bauds, might be divided by 16 */
938927   &to7_modem_rx, &to7_modem_tx,
r3854r3855
942931
943932
944933
945static void to7_modem_reset( void )
934static void to7_modem_reset( running_machine *machine )
946935{
947936   LOG (( "to7_modem_reset called\n" ));
948937   to7_modem_rx = 0;
r3854r3855
957946{
958947   LOG (( "to7_modem_init: MODEM not implemented!\n" ));
959948   pia_config( THOM_PIA_MODEM, &to7_pia_modem );
960   state_save_register_global(machine,  to7_modem_rx );
961   state_save_register_global(machine,  to7_modem_tx );
949   state_save_register_global( machine, to7_modem_rx );
950   state_save_register_global( machine, to7_modem_tx );
962951}
963952
964953
r3854r3855
966955/* ------------  dispatch MODEM / speech extension ------------ */
967956
968957
958mea8000_interface to7_speech = { THOM_SOUND_SPEECH, NULL };
969959
960
970961READ8_HANDLER ( to7_modem_mea8000_r )
971962{
972   if ( input_port_read(space->machine, "mconfig") & 1 )
973      return mea8000_r( space, offset );
974   else
963   if ( input_port_read(space->machine, "mconfig") & 1 )
975964   {
976      switch ( offset ) {
977      case 0: return acia6850_stat_r( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0 );
978      case 1: return acia6850_data_r( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0 );
965      const device_config* device = devtag_get_device(space->machine, MEA8000, "mea8000" );
966      return mea8000_r( device, offset );
967   }
968   else
969   {   
970      const device_config* device = devtag_get_device(space->machine, ACIA6850, "acia6850" );
971      switch (offset) {
972      case 0: return acia6850_stat_r( device, offset );
973      case 1: return acia6850_data_r( device, offset );
979974      default: return 0;
980975      }
981976   }
r3854r3855
986981WRITE8_HANDLER ( to7_modem_mea8000_w )
987982{
988983   if ( input_port_read(space->machine, "mconfig") & 1 )
989      mea8000_w( space, offset, data );
984   {
985      const device_config* device = devtag_get_device(space->machine, MEA8000, "mea8000" );
986      mea8000_w( device, offset, data );
987   }
990988   else
991989   {
992      switch ( offset ) {
993      case 0: acia6850_ctrl_w( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0, data ); break;
994      case 1: acia6850_data_w( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0, data ); break;
990      const device_config* device = devtag_get_device(space->machine, ACIA6850, "acia6850" );     
991      switch (offset) {
992      case 0: acia6850_ctrl_w( device, offset, data );
993      case 1: acia6850_data_w( device, offset, data );
995994      }
996995   }
997996}
r3854r3855
10441043
10451044
10461045
1047static void to7_game_sound_update ( void )
1046static void to7_game_sound_update ( running_machine *machine )
10481047{
10491048   dac_data_w( THOM_SOUND_GAME, to7_game_mute ? 0 : (to7_game_sound << 2) );
10501049}
r3854r3855
11231122{
11241123   /* 6-bit DAC sound */
11251124   to7_game_sound = data & 0x3f;
1126   to7_game_sound_update();
1125   to7_game_sound_update(space->machine);
11271126}
11281127
11291128
r3854r3855
11821181{
11831182   LOG (( "to7_game_init called\n" ));
11841183   pia_config( THOM_PIA_GAME, &to7_game );
1185   to7_game_timer = timer_alloc(machine, to7_game_update_cb , NULL);
1184   to7_game_timer = timer_alloc( machine, to7_game_update_cb , NULL);
11861185   timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD);
1187   state_save_register_global(machine,  to7_game_sound );
1188   state_save_register_global(machine,  to7_game_mute );
1186   state_save_register_global( machine, to7_game_sound );
1187   state_save_register_global( machine, to7_game_mute );
11891188}
11901189
11911190
11921191
1193static void to7_game_reset ( void )
1192static void to7_game_reset ( running_machine *machine )
11941193{
11951194   LOG (( "to7_game_reset called\n" ));
11961195   pia_set_input_ca1( THOM_PIA_GAME, 0 );
11971196   to7_game_sound = 0;
11981197   to7_game_mute = 0;
1199   to7_game_sound_update();
1198   to7_game_sound_update( machine );
12001199}
12011200
12021201
r3854r3855
12381237
12391238
12401239
1241static void to7_midi_update_irq ( void )
1240static void to7_midi_update_irq ( running_machine *machine )
12421241{
12431242   if ( (to7_midi_intr & 4) && (to7_midi_status & ACIA_6850_RDRF) )
12441243      to7_midi_status |= ACIA_6850_irq; /* byte received interrupt */
r3854r3855
12491248   if ( (to7_midi_intr & 3) == 1 && (to7_midi_status & ACIA_6850_TDRE) )
12501249      to7_midi_status |= ACIA_6850_irq; /* ready to transmit interrupt */
12511250
1252   thom_irq_4( Machine, to7_midi_status & ACIA_6850_irq );
1251   thom_irq_4( machine, to7_midi_status & ACIA_6850_irq );
12531252}
12541253
12551254
r3854r3855
12591258   to7_midi_status |= ACIA_6850_RDRF;
12601259   if ( s == CHARDEV_OVERFLOW )
12611260      to7_midi_overrun = 1;
1262   to7_midi_update_irq();
1261   to7_midi_update_irq( machine );
12631262}
12641263
12651264
r3854r3855
12671266static void to7_midi_ready_to_send_cb( running_machine *machine )
12681267{
12691268   to7_midi_status |= ACIA_6850_TDRE;
1270   to7_midi_update_irq();
1269   to7_midi_update_irq( machine );
12711270}
12721271
12731272
r3854r3855
12891288      /* bit 6:     parity error (ignored) */
12901289      /* bit 7:     interrupt */
12911290      LOG_MIDI(( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n",
1292           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to7_midi_status,
1291           cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to7_midi_status,
12931292           (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0,
12941293           (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0,
12951294           (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0,
r3854r3855
13071306         to7_midi_status &= ~ACIA_6850_OVRN;
13081307      to7_midi_overrun = 0;
13091308      LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n",
1310           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
1311      to7_midi_update_irq();
1309           cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
1310      to7_midi_update_irq( space->machine );
13121311      return data;
13131312   }
13141313
13151314
13161315   default:
13171316      logerror( "$%04x to7_midi_r: invalid offset %i\n",
1318           cpu_get_previouspc(space->cpu),  offset );
1317           cpu_get_previouspc( space->machine->cpu[0] ),  offset );
13191318      return 0;
13201319   }
13211320}
r3854r3855
13341333      if ( (data & 3) == 3 )
13351334      {
13361335         /* reset */
1337         LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
1336         LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
13381337         to7_midi_overrun = 0;
13391338         to7_midi_status = 2;
13401339         to7_midi_intr = 0;
r3854r3855
13511350            static const int stop[8] = { 2,2,1,1,2,1,1,1 };
13521351            static const char parity[8] = { 'e','o','e','o','-','-','e','o' };
13531352            LOG_MIDI(( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n",
1354                 cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
1353                 cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
13551354                 data,
13561355                 bits[ (data >> 2) & 7 ],
13571356                 stop[ (data >> 2) & 7 ],
r3854r3855
13601359                 (to7_midi_intr & 3) ? 1 : 0));
13611360         }
13621361      }
1363      to7_midi_update_irq();
1362      to7_midi_update_irq( space->machine );
13641363      break;
13651364
13661365
13671366   case 1: /* output data */
1368      LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
1367      LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
13691368      if ( data == 0x55 )
13701369         /* cable-detect: shortcut */
13711370         chardev_fake_in( to7_midi_chardev, 0x55 );
r3854r3855
13791378
13801379
13811380   default:
1382      logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data );
1381      logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
13831382   }
13841383}
13851384
r3854r3855
13931392
13941393
13951394
1396static void to7_midi_reset( void )
1395static void to7_midi_reset( running_machine *machine )
13971396{
13981397   LOG (( "to7_midi_reset called\n" ));
13991398   to7_midi_overrun = 0;
r3854r3855
14041403
14051404
14061405
1407static void to7_midi_init( void )
1406static void to7_midi_init( running_machine *machine )
14081407{
14091408   LOG (( "to7_midi_init\n" ));
1410   to7_midi_chardev = chardev_open( Machine, "/dev/snd/midiC1D0", "/dev/snd/midiC1D1", &to7_midi_interface );
1411   state_save_register_global(machine,  to7_midi_status );
1412   state_save_register_global(machine,  to7_midi_overrun );
1413   state_save_register_global(machine,  to7_midi_intr );
1409   to7_midi_chardev = chardev_open( machine, "/dev/snd/midiC1D0", "/dev/snd/midiC1D1", &to7_midi_interface );
1410   state_save_register_global( machine, to7_midi_status );
1411   state_save_register_global( machine, to7_midi_overrun );
1412   state_save_register_global( machine, to7_midi_intr );
14141413}
14151414
14161415
r3854r3855
14341433
14351434
14361435
1437static void to7_midi_reset( void )
1436static void to7_midi_reset( running_machine *machine )
14381437{
14391438   logerror( "to7_midi_reset: not implemented\n" );
14401439}
14411440
14421441
14431442
1444static void to7_midi_init( void )
1443static void to7_midi_init( running_machine *machine )
14451444{
14461445   logerror( "to7_midi_init: not implemented\n" );
14471446}
r3854r3855
14631462   /* subsystems */
14641463   thom_irq_reset(machine);
14651464   pia_reset();
1466   mc6846_reset();
1467   to7_game_reset();
1465   to7_game_reset(machine);
14681466   to7_floppy_reset(machine);
14691467   to7_io_reset(machine);
1470   to7_modem_reset();
1471   to7_midi_reset();
1472   to7_rf57932_reset();
1473   mea8000_reset(machine);
1468   to7_modem_reset(machine);
1469   to7_midi_reset(machine);
14741470
14751471   /* video */
1476   thom_set_video_mode( THOM_VMODE_TO770 );
1477   thom_set_init_callback( to7_set_init );
1478   thom_set_lightpen_callback(machine, 3, to7_lightpen_cb );
1472   thom_set_video_mode( machine, THOM_VMODE_TO770 );
1473   thom_set_init_callback( machine, to7_set_init );
1474   thom_set_lightpen_callback( machine, 3, to7_lightpen_cb );
14791475   thom_set_mode_point( machine, 0 );
1480   thom_set_border_color( 0 );
1476   thom_set_border_color( machine, 0 );
14811477   pia_set_input_cb1( THOM_PIA_SYS, 0 );
14821478
14831479   /* memory */
r3854r3855
14921488
14931489MACHINE_START ( to7 )
14941490{
1491   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
14951492   UINT8* mem = memory_region(machine, "main");
14961493
14971494   LOG (( "to7: machine start called\n" ));
r3854r3855
14991496   /* subsystems */
15001497   thom_irq_init(machine);
15011498   pia_config( THOM_PIA_SYS, &to7_sys );
1502   mc6846_config( machine, &to7_timer );
15031499   to7_game_init(machine);
1504   to7_floppy_init( machine, mem + 0x20000 );
1505   to7_io_init();
1500   to7_floppy_init(machine, mem + 0x20000);
1501   to7_io_init(machine);
15061502   to7_modem_init(machine);
1507   to7_midi_init();
1508   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
1503   to7_midi_init(machine);
15091504
15101505   /* memory */
15111506   thom_cart_bank = 0;
r3854r3855
15221517      /* install 16 KB or 16 KB + 8 KB memory extensions */
15231518      /* BASIC instruction to see free memory: ?FRE(0) */
15241519      int extram = mess_ram_size - 24*1024;
1525      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0,
1526                      (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1527      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0,
1528                      (read8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1520      memory_install_write8_handler(space, 0x8000, 0x8000 + extram - 1, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1521      memory_install_read8_handler(space, 0x8000, 0x8000 + extram - 1, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
15291522      memory_configure_bank( machine, THOM_RAM_BANK,  0, 1, mess_ram + 0x6000, extram );
15301523      memory_set_bank( machine, THOM_RAM_BANK, 0 );
15311524   }
r3854r3855
15341527   memset( thom_vram + 0x2000, 0xc0, 0x2000 );
15351528
15361529   /* save-state */
1537   state_save_register_global(machine,  thom_cart_nb_banks );
1538   state_save_register_global(machine,  thom_cart_bank );
1539   state_save_register_global(machine,  to7_lightpen );
1540   state_save_register_global(machine,  to7_lightpen_step );
1541   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
1542   state_save_register_postload(machine,  to7_update_cart_bank_postload, NULL );
1530   state_save_register_global( machine, thom_cart_nb_banks );
1531   state_save_register_global( machine, thom_cart_bank );
1532   state_save_register_global( machine, to7_lightpen );
1533   state_save_register_global( machine, to7_lightpen_step );
1534   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
1535   state_save_register_postload( machine,  to7_update_cart_bank_postload, NULL );
15431536}
15441537
15451538
r3854r3855
15551548static WRITE8_HANDLER ( to770_sys_cb2_out )
15561549{
15571550   /* video overlay: black pixels are transparent and show TV image underneath */
1558   LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", cpu_get_previouspc(space->cpu), data ));
1551   LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", cpu_get_previouspc( space->machine->cpu[0] ), data ));
15591552}
15601553
15611554
r3854r3855
15741567
15751568static void to770_update_ram_bank(running_machine *machine)
15761569{
1570   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
15771571   UINT8 portb = pia_get_port_b_z_mask( THOM_PIA_SYS );
15781572   static int old_bank = -1;
15791573   int bank;
r3854r3855
16041598   if ( mess_ram_size == 128*1024 || bank < 2 )
16051599   {
16061600      memory_set_bank( machine, THOM_RAM_BANK, bank );
1607      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1601      memory_install_write8_handler(space, 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
16081602   }
16091603   else
16101604   {
1611      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_UNMAP );
1605      memory_install_write8_handler(space, 0xa000, 0xdfff, 0, 0, SMH_UNMAP );
16121606   }
16131607
16141608   old_bank = bank;
r3854r3855
16441638
16451639
16461640
1647static WRITE8_HANDLER ( to770_timer_port_out )
1641static WRITE8_DEVICE_HANDLER ( to770_timer_port_out )
16481642{
1649   thom_set_mode_point( space->machine, data & 1 );          /* bit 0: video bank switch */
1650   thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */
1651   thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* 4-bit border color */
1643   thom_set_mode_point( device->machine, data & 1 );          /* bit 0: video bank switch */
1644   thom_set_caps_led( device->machine, (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */
1645   thom_set_border_color( device->machine,
1646                ((data & 0x10) ? 1 : 0) |          /* 4-bit border color */
16521647                ((data & 0x20) ? 2 : 0) |
16531648                ((data & 0x40) ? 4 : 0) |
16541649                ((data & 0x04) ? 0 : 8) );
r3854r3855
16561651
16571652
16581653
1659static const mc6846_interface to770_timer =
1654mc6846_interface to770_timer =
16601655{
16611656   to770_timer_port_out, NULL, to7_timer_cp2_out,
16621657   to7_timer_port_in, to7_timer_tco_out,
1663   thom_irq_0
1658   thom_dev_irq_0
16641659};
16651660
16661661
r3854r3855
16711666
16721667READ8_HANDLER ( to770_gatearray_r )
16731668{
1674   struct thom_vsignal v = thom_get_vsignal();
1669   struct thom_vsignal v = thom_get_vsignal( space->machine );
16751670   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
16761671   int count, inil, init, lt3;
16771672   count = to7_lightpen ? l.count : v.count;
r3854r3855
16861681   case 2: return (lt3 << 7) | (inil << 6);
16871682   case 3: return (init << 7);
16881683   default:
1689      logerror( "$%04x to770_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
1684      logerror( "$%04x to770_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset );
16901685      return 0;
16911686   }
16921687}
r3854r3855
17121707   /* subsystems */
17131708   thom_irq_reset(machine);
17141709   pia_reset();
1715   mc6846_reset();
1716   to7_game_reset();
1710   to7_game_reset(machine);
17171711   to7_floppy_reset(machine);
17181712   to7_io_reset(machine);
1719   to7_modem_reset();
1720   to7_midi_reset();
1721   to7_rf57932_reset();
1722   mea8000_reset(machine);
1713   to7_modem_reset(machine);
1714   to7_midi_reset(machine);
17231715
17241716   /* video */
1725   thom_set_video_mode( THOM_VMODE_TO770 );
1726   thom_set_init_callback( to7_set_init );
1727   thom_set_lightpen_callback(machine, 3, to7_lightpen_cb );
1717   thom_set_video_mode( machine, THOM_VMODE_TO770 );
1718   thom_set_init_callback( machine, to7_set_init );
1719   thom_set_lightpen_callback( machine, 3, to7_lightpen_cb );
17281720   thom_set_mode_point( machine, 0 );
1729   thom_set_border_color( 8 );
1721   thom_set_border_color( machine, 8 );
17301722   pia_set_input_cb1( THOM_PIA_SYS, 0 );
17311723
17321724   /* memory */
r3854r3855
17491741   /* subsystems */
17501742   thom_irq_init(machine);
17511743   pia_config( THOM_PIA_SYS, &to770_sys );
1752   mc6846_config( machine, &to770_timer );
17531744   to7_game_init(machine);
17541745   to7_floppy_init( machine, mem + 0x20000 );
1755   to7_io_init();
1746   to7_io_init(machine);
17561747   to7_modem_init(machine);
1757   to7_midi_init();
1758   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
1748   to7_midi_init(machine);
17591749
17601750   /* memory */
17611751   thom_cart_bank = 0;
r3854r3855
17701760   memory_set_bank( machine, THOM_CART_BANK, 0 );
17711761
17721762   /* save-state */
1773   state_save_register_global(machine,  thom_cart_nb_banks );
1774   state_save_register_global(machine,  thom_cart_bank );
1775   state_save_register_global(machine,  to7_lightpen );
1776   state_save_register_global(machine,  to7_lightpen_step );
1777   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
1778   state_save_register_postload(machine,  to770_update_ram_bank_postload, NULL );
1779   state_save_register_postload(machine,  to7_update_cart_bank_postload, NULL );
1763   state_save_register_global( machine, thom_cart_nb_banks );
1764   state_save_register_global( machine, thom_cart_bank );
1765   state_save_register_global( machine, to7_lightpen );
1766   state_save_register_global( machine, to7_lightpen_step );
1767   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
1768   state_save_register_postload( machine,  to770_update_ram_bank_postload, NULL );
1769   state_save_register_postload( machine,  to7_update_cart_bank_postload, NULL );
17801770}
17811771
17821772
r3854r3855
18221812
18231813
18241814
1825static void mo5_init_timer(void)
1815static void mo5_init_timer(running_machine *machine)
18261816{
18271817   /* time is a little faster than 50 Hz to match video framerate */
18281818   timer_adjust_periodic(mo5_periodic_timer, attotime_zero, 0, ATTOTIME_IN_USEC( 19968 ));
r3854r3855
18361826
18371827static WRITE8_HANDLER ( mo5_sys_porta_out )
18381828{
1839   thom_set_mode_point( space->machine, data & 1 );                  /* bit 0: video bank switch */
1840   thom_set_border_color( (data >> 1) & 15 );            /* bit 1-4: border color */
1841   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
1829   thom_set_mode_point( space->machine, data & 1 );      /* bit 0: video bank switch */
1830   thom_set_border_color( space->machine, (data >> 1) & 15 );   /* bit 1-4: border color */
1831   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );   /* bit 6: cassette output */
18421832}
18431833
18441834
r3854r3855
18931883
18941884READ8_HANDLER ( mo5_gatearray_r )
18951885{
1896   struct thom_vsignal v = thom_get_vsignal();
1886   struct thom_vsignal v = thom_get_vsignal( space->machine );
18971887   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO5_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
18981888   int count, inil, init, lt3;
18991889   count = to7_lightpen ? l.count : v.count;
r3854r3855
19071897   case 2: return (lt3 << 7) | (inil << 6);
19081898   case 3: return (init << 7);
19091899   default:
1910      logerror( "$%04x mo5_gatearray_r: invalid offset %i\n",  cpu_get_previouspc(space->cpu), offset );
1900      logerror( "$%04x mo5_gatearray_r: invalid offset %i\n",  cpu_get_previouspc( space->machine->cpu[0] ), offset );
19111901      return 0;
19121902   }
19131903}
r3854r3855
19781968
19791969static void mo5_update_cart_bank(running_machine *machine)
19801970{
1971   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
19811972   static int old_bank = -1;
19821973   int rom_is_ram = mo5_reg_cart & 4;
19831974   int bank = 0;
19841975
1985   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0,
1986                  (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
1976   memory_install_read8_handler( space, 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
19871977
19881978   if ( rom_is_ram && thom_cart_nb_banks == 4 )
19891979   {
19901980      /* 64 KB ROM from "JANE" cartridge */
1991      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP );
1981      memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, SMH_NOP );
19921982      bank = mo5_reg_cart & 3;
19931983      if ( bank != old_bank )
19941984         LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank ));
r3854r3855
19981988      /* 64 KB RAM from network extension */
19991989      int write_enable = mo5_reg_cart & 8;
20001990      bank = 4 + ( mo5_reg_cart & 3 );
2001      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ?
2002                      (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
1991      memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, write_enable ? (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
20031992      if ( bank != old_bank )
20041993         LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 ));
20051994   }
20061995   else
20071996   {
20081997      /* regular cartridge bank switch */
2009      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo5_cartridge_w );
1998      memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, mo5_cartridge_w );
20101999      if ( thom_cart_nb_banks )
20112000      {
20122001         bank = thom_cart_bank % thom_cart_nb_banks;
2013         memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r );
2002         memory_install_read8_handler( space, 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r );
20142003      }
20152004      if ( bank != old_bank )
20162005         LOG_BANK(( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank ));
r3854r3855
20732062   thom_irq_reset(machine);
20742063   pia_reset();
20752064   pia_set_port_a_z_mask( THOM_PIA_SYS, 0x5f );
2076   to7_game_reset();
2065   to7_game_reset(machine);
20772066   to7_floppy_reset(machine);
20782067   to7_io_reset(machine);
2079   to7_modem_reset();
2080   to7_midi_reset();
2081   to7_rf57932_reset();
2082   mo5_init_timer();
2083   mea8000_reset(machine);
2068   to7_modem_reset(machine);
2069   to7_midi_reset(machine);
2070   mo5_init_timer(machine);
20842071
20852072   /* video */
2086   thom_set_video_mode( THOM_VMODE_MO5 );
2087   thom_set_lightpen_callback(machine, 3, mo5_lightpen_cb );
2073   thom_set_video_mode( machine, THOM_VMODE_MO5 );
2074   thom_set_lightpen_callback( machine, 3, mo5_lightpen_cb );
20882075   thom_set_mode_point( machine, 0 );
2089   thom_set_border_color( 0 );
2076   thom_set_border_color( machine, 0 );
20902077   pia_set_input_ca1( THOM_PIA_SYS, 0 );
20912078
20922079   /* memory */
r3854r3855
21112098   pia_config( THOM_PIA_SYS, &mo5_sys );
21122099   to7_game_init(machine);
21132100   to7_floppy_init( machine, mem + 0x20000 );
2114   to7_io_init();
2101   to7_io_init(machine);
21152102   to7_modem_init(machine);
2116   to7_midi_init();
2117   mo5_periodic_timer = timer_alloc(machine,  mo5_periodic_cb , NULL);
2118   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
2103   to7_midi_init(machine);
2104   mo5_periodic_timer = timer_alloc( machine, mo5_periodic_cb , NULL);
21192105
21202106   /* memory */
21212107   thom_cart_bank = 0;
r3854r3855
21302116   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
21312117
21322118   /* save-state */
2133   state_save_register_global(machine,  thom_cart_nb_banks );
2134   state_save_register_global(machine,  thom_cart_bank );
2135   state_save_register_global(machine,  to7_lightpen );
2136   state_save_register_global(machine,  to7_lightpen_step );
2137   state_save_register_global(machine,  mo5_reg_cart );
2138   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
2139   state_save_register_postload(machine,  mo5_update_cart_bank_postload, NULL );
2119   state_save_register_global( machine, thom_cart_nb_banks );
2120   state_save_register_global( machine, thom_cart_bank );
2121   state_save_register_global( machine, to7_lightpen );
2122   state_save_register_global( machine, to7_lightpen_step );
2123   state_save_register_global( machine, mo5_reg_cart );
2124   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
2125   state_save_register_postload( machine,  mo5_update_cart_bank_postload, NULL );
21402126}
21412127
21422128
r3854r3855
21552141
21562142WRITE8_HANDLER ( to9_ieee_w )
21572143{
2158   logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, offset );
2144   logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data, offset );
21592145}
21602146
21612147
21622148
21632149READ8_HANDLER  ( to9_ieee_r )
21642150{
2165   logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset );
2151   logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset );
21662152   return 0;
21672153}
21682154
r3854r3855
21782164
21792165READ8_HANDLER ( to9_gatearray_r )
21802166{
2181   struct thom_vsignal v = thom_get_vsignal();
2167   struct thom_vsignal v = thom_get_vsignal( space->machine );
21822168   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO9_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
21832169   int count, inil, init, lt3;
21842170   count = to7_lightpen ? l.count : v.count;
r3854r3855
21932179   case 2: return (lt3 << 7) | (inil << 6);
21942180   case 3: return (v.init << 7) | (init << 6); /* != TO7/70 */
21952181   default:
2196      logerror( "$%04x to9_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
2182      logerror( "$%04x to9_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset );
21972183      return 0;
21982184   }
21992185}
r3854r3855
22182204
22192205
22202206/* style: 0 => TO9, 1 => TO8/TO9, 2 => MO6 */
2221static void to9_set_video_mode( UINT8 data, int style )
2207static void to9_set_video_mode( running_machine *machine, UINT8 data, int style )
22222208{
22232209   switch ( data & 0x7f )
22242210   {
22252211   case 0x00:
22262212      if ( style == 2 )
2227         thom_set_video_mode( THOM_VMODE_MO5 );
2213         thom_set_video_mode( machine, THOM_VMODE_MO5 );
22282214      else if ( style == 1 )
2229         thom_set_video_mode( THOM_VMODE_TO770 );
2215         thom_set_video_mode( machine, THOM_VMODE_TO770 );
22302216      else
2231         thom_set_video_mode( THOM_VMODE_TO9 );
2217         thom_set_video_mode( machine, THOM_VMODE_TO9 );
22322218      break;
22332219
2234   case 0x21: thom_set_video_mode( THOM_VMODE_BITMAP4 );     break;
2220   case 0x21: thom_set_video_mode( machine, THOM_VMODE_BITMAP4 );     break;
22352221
2236   case 0x41: thom_set_video_mode( THOM_VMODE_BITMAP4_ALT ); break;
2222   case 0x41: thom_set_video_mode( machine, THOM_VMODE_BITMAP4_ALT ); break;
22372223
22382224   case 0x2a:
22392225      if ( style==0 )
2240         thom_set_video_mode( THOM_VMODE_80_TO9 );
2226         thom_set_video_mode( machine, THOM_VMODE_80_TO9 );
22412227      else
2242         thom_set_video_mode( THOM_VMODE_80 );
2228         thom_set_video_mode( machine, THOM_VMODE_80 );
22432229      break;
22442230
2245   case 0x7b: thom_set_video_mode( THOM_VMODE_BITMAP16 );    break;
2231   case 0x7b: thom_set_video_mode( machine, THOM_VMODE_BITMAP16 );    break;
22462232
2247   case 0x24: thom_set_video_mode( THOM_VMODE_PAGE1 );       break;
2233   case 0x24: thom_set_video_mode( machine, THOM_VMODE_PAGE1 );       break;
22482234
2249   case 0x25: thom_set_video_mode( THOM_VMODE_PAGE2 );       break;
2235   case 0x25: thom_set_video_mode( machine, THOM_VMODE_PAGE2 );       break;
22502236
2251   case 0x26: thom_set_video_mode( THOM_VMODE_OVERLAY );     break;
2237   case 0x26: thom_set_video_mode( machine, THOM_VMODE_OVERLAY );     break;
22522238
2253   case 0x3f: thom_set_video_mode( THOM_VMODE_OVERLAY3 );    break;
2239   case 0x3f: thom_set_video_mode( machine, THOM_VMODE_OVERLAY3 );    break;
22542240
22552241   default:
22562242      logerror( "to9_set_video_mode: unknown mode $%02X tr=%i phi=%i mod=%i\n", data, (data >> 5) & 3, (data >> 3) & 2, data & 7 );
r3854r3855
22882274
22892275WRITE8_HANDLER ( to9_vreg_w )
22902276{
2291   LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset, 0xe7da + offset, data ));
2277   LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset, 0xe7da + offset, data ));
22922278
22932279   switch ( offset )
22942280   {
r3854r3855
23002286      idx = to9_palette_idx / 2;
23012287      color = to9_palette_data[ 2 * idx + 1 ];
23022288      color = to9_palette_data[ 2 * idx ] | (color << 8);
2303      thom_set_palette( idx ^ 8, color & 0x1fff );
2289      thom_set_palette( space->machine, idx ^ 8, color & 0x1fff );
23042290
23052291      to9_palette_idx = ( to9_palette_idx + 1 ) & 31;
23062292   }
r3854r3855
23112297      break;
23122298
23132299   case 2: /* video mode */
2314      to9_set_video_mode( data, 0 );
2300      to9_set_video_mode( space->machine, data, 0 );
23152301      break;
23162302
23172303   case 3: /* border color */
2318      thom_set_border_color( data & 15 );
2304      thom_set_border_color( space->machine, data & 15 );
23192305      break;
23202306
23212307   default:
r3854r3855
23292315{
23302316   to9_palette_idx = 0;
23312317   memset( to9_palette_data, 0, sizeof( to9_palette_data ) );
2332   state_save_register_global(machine,  to9_palette_idx );
2333   state_save_register_global_array(machine,  to9_palette_data );
2318   state_save_register_global( machine, to9_palette_idx );
2319   state_save_register_global_array( machine, to9_palette_data );
23342320}
23352321
23362322
r3854r3855
23432329
23442330static void to9_update_cart_bank(running_machine *machine)
23452331{
2332   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
23462333   static int old_bank = -1;
23472334   int bank = 0;
2348   int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */
2335   int slot = ( mc6846_get_output_port(devtag_get_device(machine, MC6846, "mc6846")) >> 4 ) & 3; /* bits 4-5: ROM bank */
23492336
23502337   /* reset cartridge read handler */
2351   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
2338   memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
23522339
23532340   switch ( slot )
23542341   {
r3854r3855
23752362      if ( thom_cart_nb_banks )
23762363      {
23772364         bank = thom_cart_bank % thom_cart_nb_banks;
2378         memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r );
2365         memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, to7_cartridge_r );
23792366      }
23802367      if ( bank != old_bank )
23812368         LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n",  thom_cart_bank ));
r3854r3855
23982385/* write signal to 0000-1fff generates a bank switch */
23992386WRITE8_HANDLER ( to9_cartridge_w )
24002387{
2401   int slot = ( mc6846_get_output_port(space->machine) >> 4 ) & 3; /* bits 4-5: ROM bank */
2388   int slot = ( mc6846_get_output_port(devtag_get_device(space->machine, MC6846, "mc6846")) >> 4 ) & 3; /* bits 4-5: ROM bank */
24022389
24032390   if ( offset >= 0x2000 )
24042391      return;
r3854r3855
24262413
24272414static void to9_update_ram_bank (running_machine *machine)
24282415{
2416   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
24292417   static int old_bank = -1;
2430   UINT8 port = mc6846_get_output_port(machine);
2418   UINT8 port = mc6846_get_output_port(devtag_get_device(machine, MC6846, "mc6846"));
24312419   UINT8 portb = pia_get_port_b_z_mask( THOM_PIA_SYS );
24322420   UINT8 disk = ((port >> 2) & 1) | ((port >> 5) & 2); /* bits 6,2: RAM bank */
24332421   int bank;
r3854r3855
24592447   if ( mess_ram_size == 192*1024 || bank < 6 )
24602448   {
24612449      memory_set_bank( machine, THOM_RAM_BANK, bank );
2462      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
2450      memory_install_write8_handler( space, 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
24632451   }
24642452   else
24652453   {
2466      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_NOP );
2454      memory_install_write8_handler( space, 0xa000, 0xdfff, 0, 0, SMH_NOP );
24672455   }
24682456
24692457   old_bank = bank;
r3854r3855
25832571      /* bit 7:     interrupt */
25842572
25852573      LOG_KBD(( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n",
2586           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to9_kbd_status,
2574           cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to9_kbd_status,
25872575           (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0,
25882576           (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0,
25892577           (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0,
r3854r3855
25982586      else
25992587         to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF);
26002588      to9_kbd_overrun = 0;
2601      LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to9_kbd_in ));
2589      LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to9_kbd_in ));
26022590      to9_kbd_update_irq(space->machine);
26032591      return to9_kbd_in;
26042592
26052593   default:
2606      logerror( "$%04x to9_kbd_r: invalid offset %i\n", cpu_get_previouspc(space->cpu),  offset );
2594      logerror( "$%04x to9_kbd_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ),  offset );
26072595      return 0;
26082596   }
26092597}
r3854r3855
26252613         to9_kbd_overrun = 0;
26262614         to9_kbd_status = ACIA_6850_TDRE;
26272615         to9_kbd_intr = 0;
2628         LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
2616         LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
26292617      }
26302618      else
26312619      {
r3854r3855
26392627         to9_kbd_intr = data >> 5;
26402628
26412629         LOG_KBD(( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n",
2642              cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
2630              cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
26432631              data, to9_kbd_parity, to9_kbd_intr >> 2,
26442632              (to9_kbd_intr & 3) ? 1 : 0 ));
26452633      }
r3854r3855
26702658      case 0xFE: to9_kbd_periph = 0; break;
26712659
26722660      default:
2673         logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data );
2661         logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data );
26742662      }
26752663
2676      thom_set_caps_led( ! to9_kbd_caps );
2664      thom_set_caps_led( space->machine, !to9_kbd_caps );
26772665
26782666      LOG(( "$%04x %f to9_kbd_w: kbd command %02X (caps=%i, pad=%i, periph=%i)\n",
2679            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data,
2667            cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data,
26802668            to9_kbd_caps, to9_kbd_pad, to9_kbd_periph ));
26812669
26822670      break;
26832671
26842672   default:
2685      logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data );
2673      logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
26862674   }
26872675}
26882676
r3854r3855
27562744
27572745
27582746/* returns the ASCII code for the key, or 0 for no key */
2759static int to9_kbd_get_key( void )
2747static int to9_kbd_get_key( running_machine *machine )
27602748{
2761   int control = ! (input_port_read(Machine, "keyboard_7") & 1);
2762   int shift   = ! (input_port_read(Machine, "keyboard_9") & 1);
2749   int control = ! (input_port_read(machine, "keyboard_7") & 1);
2750   int shift   = ! (input_port_read(machine, "keyboard_9") & 1);
27632751   int key = -1, line, bit;
27642752   UINT8 port;
27652753   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
r3854r3855
27672755
27682756   for ( line = 0; line < 10; line++ )
27692757   {
2770      port = input_port_read(Machine, keynames[line]);
2758      port = input_port_read(machine, keynames[line]);
27712759
27722760      if ( line == 7 || line == 9 )
27732761         port |= 1; /* shift & control */
r3854r3855
27962784
27972785      to9_kbd_last_key = key;
27982786      to9_kbd_caps = !to9_kbd_caps;
2799      thom_set_caps_led( ! to9_kbd_caps );
2787      thom_set_caps_led( machine, !to9_kbd_caps );
28002788      return 0;
28012789   }
28022790   else
r3854r3855
28532841      {
28542842
28552843      case 0: /* key */
2856         to9_kbd_send( machine, to9_kbd_get_key(), 0 );
2844         to9_kbd_send( machine, to9_kbd_get_key(machine), 0 );
28572845         break;
28582846
28592847      case 1: /* x axis */
r3854r3855
28912879   }
28922880   else
28932881   {
2894      int key = to9_kbd_get_key();
2882      int key = to9_kbd_get_key(machine);
28952883      /* keyboard mode: send a byte only if a key is down */
28962884      if ( key )
28972885         to9_kbd_send( machine, key, 0 );
r3854r3855
29112899   to9_kbd_periph = 0;
29122900   to9_kbd_pad = 0;
29132901   to9_kbd_byte_count = 0;
2914   thom_set_caps_led( ! to9_kbd_caps );
2902   thom_set_caps_led( machine, !to9_kbd_caps );
29152903   to9_kbd_key_count = 0;
29162904   to9_kbd_last_key = 0xff;
29172905   to9_kbd_update_irq(machine);
r3854r3855
29232911static void to9_kbd_init ( running_machine *machine )
29242912{
29252913   LOG(( "to9_kbd_init called\n" ));
2926   to9_kbd_timer = timer_alloc(machine,  to9_kbd_timer_cb , NULL);
2927   state_save_register_global(machine,  to9_kbd_parity );
2928   state_save_register_global(machine,  to9_kbd_intr );
2929   state_save_register_global(machine,  to9_kbd_in );
2930   state_save_register_global(machine,  to9_kbd_status );
2931   state_save_register_global(machine,  to9_kbd_overrun );
2932   state_save_register_global(machine,  to9_kbd_last_key );
2933   state_save_register_global(machine,  to9_kbd_key_count );
2934   state_save_register_global(machine,  to9_kbd_caps );
2935   state_save_register_global(machine,  to9_kbd_periph );
2936   state_save_register_global(machine,  to9_kbd_pad );
2937   state_save_register_global(machine,  to9_kbd_byte_count );
2938   state_save_register_global(machine,  to9_mouse_x );
2939   state_save_register_global(machine,  to9_mouse_y );
2914   to9_kbd_timer = timer_alloc( machine, to9_kbd_timer_cb , NULL);
2915   state_save_register_global( machine, to9_kbd_parity );
2916   state_save_register_global( machine, to9_kbd_intr );
2917   state_save_register_global( machine, to9_kbd_in );
2918   state_save_register_global( machine, to9_kbd_status );
2919   state_save_register_global( machine, to9_kbd_overrun );
2920   state_save_register_global( machine, to9_kbd_last_key );
2921   state_save_register_global( machine, to9_kbd_key_count );
2922   state_save_register_global( machine, to9_kbd_caps );
2923   state_save_register_global( machine, to9_kbd_periph );
2924   state_save_register_global( machine, to9_kbd_pad );
2925   state_save_register_global( machine, to9_kbd_byte_count );
2926   state_save_register_global( machine, to9_mouse_x );
2927   state_save_register_global( machine, to9_mouse_y );
29402928}
29412929
29422930
r3854r3855
29542942   centronics_write_data( 0, data );
29552943   centronics_write_handshake( 0, (b & 2) ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE );
29562944
2957//   LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n",
2958//        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data,
2959//        (b & 2) ? 1 : 0 ));
2945   LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n",
2946        cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), data,
2947        (b & 2) ? 1 : 0 ));
29602948}
29612949
29622950
r3854r3855
30072995
30082996
30092997
3010static WRITE8_HANDLER ( to9_timer_port_out )
2998static WRITE8_DEVICE_HANDLER ( to9_timer_port_out )
30112999{
3012   thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank */
3013   to9_update_ram_bank(space->machine);
3014   to9_update_cart_bank(space->machine);
3000   thom_set_mode_point( device->machine, data & 1 ); /* bit 0: video bank */
3001   to9_update_ram_bank( device->machine );
3002   to9_update_cart_bank( device->machine );
30153003}
30163004
30173005
30183006
3019static const mc6846_interface to9_timer =
3007mc6846_interface to9_timer =
30203008{
30213009   to9_timer_port_out, NULL, to7_timer_cp2_out,
30223010   to7_timer_port_in, to7_timer_tco_out,
3023   thom_irq_0
3011   thom_dev_irq_0
30243012};
30253013
30263014
r3854r3855
30373025   thom_irq_reset(machine);
30383026   pia_reset();
30393027   pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe );
3040   mc6846_reset();
3041   to7_game_reset();
3028   to7_game_reset(machine);
30423029   to9_floppy_reset(machine);
30433030   to9_kbd_reset(machine);
3044   thom_centronics_reset();
3045   to7_modem_reset();
3046   to7_midi_reset();
3047   to7_rf57932_reset();
3048   mea8000_reset(machine);
3031   thom_centronics_reset(machine);
3032   to7_modem_reset(machine);
3033   to7_midi_reset(machine);
30493034
30503035   /* video */
3051   thom_set_video_mode( THOM_VMODE_TO9 );
3052   thom_set_lightpen_callback(machine, 3, to7_lightpen_cb );
3053   thom_set_border_color( 8 );
3036   thom_set_video_mode( machine, THOM_VMODE_TO9 );
3037   thom_set_lightpen_callback( machine, 3, to7_lightpen_cb );
3038   thom_set_border_color( machine, 8 );
30543039   thom_set_mode_point( machine, 0 );
30553040   pia_set_input_cb1( THOM_PIA_SYS, 0 );
30563041
r3854r3855
30763061   thom_irq_init(machine);
30773062   pia_config( THOM_PIA_SYS, &to9_sys );
30783063   centronics_config( 0, &to9_centronics );
3079   mc6846_config( machine, &to9_timer );
30803064   to7_game_init(machine);
30813065   to9_floppy_init( machine, mem + 0xe000, mem + 0x40000 );
30823066   to9_kbd_init(machine);
30833067   to9_palette_init(machine);
30843068   to7_modem_init(machine);
3085   to7_midi_init();
3086   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
3069   to7_midi_init(machine);
30873070
30883071   /* memory */
30893072   thom_vram = mess_ram;
r3854r3855
30983081   memory_set_bank( machine, THOM_RAM_BANK,  0 );
30993082
31003083   /* save-state */
3101   state_save_register_global(machine,  thom_cart_nb_banks );
3102   state_save_register_global(machine,  thom_cart_bank );
3103   state_save_register_global(machine,  to7_lightpen );
3104   state_save_register_global(machine,  to7_lightpen_step );
3105   state_save_register_global(machine,  to9_soft_bank );
3106   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
3107   state_save_register_postload(machine,  to9_update_ram_bank_postload, NULL );
3108   state_save_register_postload(machine,  to9_update_cart_bank_postload, NULL );
3084   state_save_register_global( machine, thom_cart_nb_banks );
3085   state_save_register_global( machine, thom_cart_bank );
3086   state_save_register_global( machine, to7_lightpen );
3087   state_save_register_global( machine, to7_lightpen_step );
3088   state_save_register_global( machine, to9_soft_bank );
3089   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
3090   state_save_register_postload( machine,  to9_update_ram_bank_postload, NULL );
3091   state_save_register_postload( machine,  to9_update_cart_bank_postload, NULL );
31093092}
31103093
31113094
r3854r3855
32403223      to8_kbd_caps = !to8_kbd_caps;
32413224      if ( to8_kbd_caps )
32423225         key |= 0x080; /* auto-shift */
3243      thom_set_caps_led( ! to8_kbd_caps );
3226      thom_set_caps_led( machine, !to8_kbd_caps );
32443227      return key;
32453228   }
32463229   else if ( key == to8_kbd_last_key )
r3854r3855
32833266         (helps avoiding CPU lock)
32843267      */
32853268      if ( ! to8_kbd_ack )
3286         mc6846_set_input_cp1( machine, 0 );
3287      mc6846_set_input_cp1( machine, 1 );
3269         mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 );
3270      mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 1 );
32883271
32893272      if ( k == -1 )
32903273         d = TO8_KBD_POLL_PERIOD;
r3854r3855
33033286      to8_kbd_last_key = 0xff;
33043287      to8_kbd_key_count = 0;
33053288      to8_kbd_step = 0;
3306      mc6846_set_input_cp1( machine, 1 );
3289      mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 1 );
33073290      d = TO8_KBD_POLL_PERIOD;
33083291   }
33093292   else if ( to8_kbd_step == 1 )
33103293   {
33113294      /* schedule timeout waiting for ack to go down */
3312      mc6846_set_input_cp1( machine, 0 );
3295      mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 );
33133296      to8_kbd_step = 255;
33143297      d = TO8_KBD_TIMEOUT;
33153298   }
33163299   else if ( to8_kbd_step == 117 )
33173300   {
33183301      /* schedule timeout  waiting for ack to go up */
3319      mc6846_set_input_cp1( machine, 0 );
3302      mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 );
33203303      to8_kbd_step = 255;
33213304      d = TO8_KBD_TIMEOUT;
33223305   }
33233306   else if ( to8_kbd_step & 1 )
33243307   {
33253308      /* send silence between bits */
3326      mc6846_set_input_cp1( machine, 0 );
3309      mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 );
33273310      d = ATTOTIME_IN_USEC( 100 );
33283311      to8_kbd_step++;
33293312   }
r3854r3855
33323315      /* send bit */
33333316      int bpos = 8 - ( (to8_kbd_step - 100) / 2);
33343317      int bit = (to8_kbd_data >> bpos) & 1;
3335      mc6846_set_input_cp1( machine, 1 );
3318      mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 1 );
33363319      d = ATTOTIME_IN_USEC( bit ? 56 : 38 );
33373320      to8_kbd_step++;
33383321   }
r3854r3855
33883371               to8_kbd_caps = 0;
33893372            }
33903373         }
3391         thom_set_caps_led( ! to8_kbd_caps );
3374         thom_set_caps_led( machine, !to8_kbd_caps );
33923375      }
33933376      else
33943377      {
r3854r3855
34283411   to8_kbd_data = 0;
34293412   to8_kbd_ack = 1;
34303413   to8_kbd_caps = 1;
3431   thom_set_caps_led( ! to8_kbd_caps );
3414   thom_set_caps_led( machine, !to8_kbd_caps );
34323415   to8_kbd_timer_func(machine);
34333416}
34343417
r3854r3855
34363419
34373420static void to8_kbd_init ( running_machine *machine )
34383421{
3439   to8_kbd_timer = timer_alloc(machine,  to8_kbd_timer_cb , NULL);
3440   to8_kbd_signal = timer_alloc(machine,  NULL , NULL);
3441   state_save_register_global(machine,  to8_kbd_ack );
3442   state_save_register_global(machine,  to8_kbd_data );
3443   state_save_register_global(machine,  to8_kbd_step );
3444   state_save_register_global(machine,  to8_kbd_last_key );
3445   state_save_register_global(machine,  to8_kbd_key_count );
3446   state_save_register_global(machine,  to8_kbd_caps );
3422   to8_kbd_timer = timer_alloc( machine, to8_kbd_timer_cb , NULL);
3423   to8_kbd_signal = timer_alloc( machine, NULL , NULL);
3424   state_save_register_global( machine, to8_kbd_ack );
3425   state_save_register_global( machine, to8_kbd_data );
3426   state_save_register_global( machine, to8_kbd_step );
3427   state_save_register_global( machine, to8_kbd_last_key );
3428   state_save_register_global( machine, to8_kbd_key_count );
3429   state_save_register_global( machine, to8_kbd_caps );
34473430}
34483431
34493432
r3854r3855
34613444
34623445
34633446
3464static void to8_update_floppy_bank(running_machine *machine)
3447static void to8_update_floppy_bank( running_machine *machine )
34653448{
34663449   static int old_bank = -1;
34673450   int bank = (to8_reg_sys1 & 0x80) ? to7_floppy_bank : (to8_bios_bank + TO7_NB_FLOP_BANK);
r3854r3855
34853468
34863469static void to8_update_ram_bank (running_machine *machine)
34873470{
3471   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
34883472   UINT8 bank = 0;
34893473
34903474   if ( to8_reg_sys1 & 0x10 )
r3854r3855
35273511   {
35283512      memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage );
35293513      memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage );
3530      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_LO - 1) );
3531      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_HI - 1) );
3514      memory_install_write8_handler( space, 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_LO - 1) );
3515      memory_install_write8_handler( space, 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_HI - 1) );
35323516   }
35333517   else
35343518   {
3535      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, SMH_NOP );
3536      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, SMH_NOP );
3519      memory_install_write8_handler( space, 0xa000, 0xbfff, 0, 0, SMH_NOP );
3520      memory_install_write8_handler( space, 0xc000, 0xdfff, 0, 0, SMH_NOP );
35373521   }
35383522}
35393523
r3854r3855
35483532
35493533static void to8_update_cart_bank (running_machine *machine)
35503534{
3535   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
35513536   static int old_bank = -1;
35523537   int bank = 0;
35533538
35543539   /* reset bank switch */
3555   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
3540   memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
35563541
35573542   if ( to8_reg_cart & 0x20 )
35583543   {
35593544      /* RAM space */
35603545      to8_cart_vpage = to8_reg_cart & 31;
35613546      bank = 8 + to8_cart_vpage;
3562      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0,
3547      memory_install_write8_handler( space, 0x0000, 0x3fff, 0, 0,
35633548                      ((to8_cart_vpage < 8 || mess_ram_size == 512*1024) && (to8_reg_cart & 0x40)) ?
35643549                      (to8_cart_vpage <= 4) ? to8_vcart_w :
35653550                      (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :
r3854r3855
35693554   }
35703555   else
35713556   {
3572      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, to8_cartridge_w );
3557      memory_install_write8_handler( space, 0x0000, 0x3fff, 0, 0, to8_cartridge_w );
35733558      if ( to8_soft_select )
35743559      {
35753560         /* internal software ROM space */
r3854r3855
35843569         if ( thom_cart_nb_banks )
35853570         {
35863571            bank = thom_cart_bank % thom_cart_nb_banks;
3587            memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to8_cartridge_r );
3572            memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, to8_cartridge_r );
35883573
35893574         }
35903575
r3854r3855
36973682
36983683READ8_HANDLER ( to8_gatearray_r )
36993684{
3700   struct thom_vsignal v = thom_get_vsignal();
3685   struct thom_vsignal v = thom_get_vsignal( space->machine );
37013686   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO8_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 );
37023687   int count, inil, init, lt3;
37033688   UINT8 res;
r3854r3855
37393724      break;
37403725
37413726   default:
3742      logerror( "$%04x to8_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
3727      logerror( "$%04x to8_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset );
37433728      res = 0;
37443729   }
37453730
37463731   LOG_VIDEO(( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n",
3747        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
3732        cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
37483733        offset, 0xe7e4 + offset, res, to7_lightpen ));
37493734
37503735   return res;
r3854r3855
37553740WRITE8_HANDLER ( to8_gatearray_w )
37563741{
37573742   LOG_VIDEO(( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n",
3758        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
3743        cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
37593744        offset, 0xe7e4 + offset, data ));
37603745
37613746   switch ( offset )
r3854r3855
37873772
37883773   default:
37893774      logerror( "$%04x to8_gatearray_w: invalid offset %i (data=$%02X)\n",
3790           cpu_get_previouspc(space->cpu), offset, data );
3775           cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
37913776   }
37923777}
37933778
r3854r3855
38363821WRITE8_HANDLER ( to8_vreg_w )
38373822{
38383823   LOG_VIDEO(( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n",
3839        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
3824        cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
38403825        offset, 0xe7da + offset, data ));
38413826
38423827   switch ( offset )
r3854r3855
38493834      idx = to9_palette_idx / 2;
38503835      color = to9_palette_data[ 2 * idx + 1 ];
38513836      color = to9_palette_data[ 2 * idx ] | (color << 8);
3852      thom_set_palette( idx, color & 0x1fff );
3837      thom_set_palette( space->machine, idx, color & 0x1fff );
38533838      to9_palette_idx = ( to9_palette_idx + 1 ) & 31;
38543839   }
38553840   break;
r3854r3855
38593844      break;
38603845
38613846   case 2: /* display register */
3862      to9_set_video_mode( data, 1 );
3847      to9_set_video_mode( space->machine, data, 1 );
38633848      break;
38643849
38653850   case 3: /* system register 2 */
r3854r3855
38723857      else
38733858      {
38743859         to8_reg_sys2 = data;
3875         thom_set_video_page( data >> 6 );
3876         thom_set_border_color( data & 15 );
3860         thom_set_video_page( space->machine, data >> 6 );
3861         thom_set_border_color( space->machine, data & 15 );
38773862      }
38783863      break;
38793864
r3854r3855
38923877{
38933878   int ktest = to8_kbd_ktest (space->machine);
38943879
3895   LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), ktest ));
3880   LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), ktest ));
38963881
38973882   return ktest;
38983883}
r3854r3855
39243909
39253910
39263911
3927static READ8_HANDLER ( to8_timer_port_in )
3912static READ8_DEVICE_HANDLER ( to8_timer_port_in )
39283913{
3929   int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0;
3930   int cass = to7_get_cassette(space->machine) ? 0x80 : 0;
3914   int lightpen = (input_port_read(device->machine, "lightpen_button") & 1) ? 2 : 0;
3915   int cass = to7_get_cassette(device->machine) ? 0x80 : 0;
39313916   int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40;
39323917   int lock = to8_kbd_caps ? 0 : 8; /* undocumented! */
39333918   return lightpen | cass | dtr | lock;
r3854r3855
39353920
39363921
39373922
3938static WRITE8_HANDLER ( to8_timer_port_out )
3923static WRITE8_DEVICE_HANDLER ( to8_timer_port_out )
39393924{
39403925   int ack = (data & 0x20) ? 1 : 0;       /* bit 5: keyboard ACK */
39413926   to8_bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank*/
3942   thom_set_mode_point( space->machine, data & 1 );       /* bit 0: video bank switch */
3943   memory_set_bank( space->machine, TO8_BIOS_BANK, to8_bios_bank );
3927   thom_set_mode_point( device->machine, data & 1 );       /* bit 0: video bank switch */
3928   memory_set_bank( device->machine, TO8_BIOS_BANK, to8_bios_bank );
39443929   to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */
3945   to8_update_floppy_bank(space->machine);
3946   to8_update_cart_bank(space->machine);
3947   to8_kbd_set_ack( space->machine, ack );
3930   to8_update_floppy_bank(device->machine);
3931   to8_update_cart_bank(device->machine);
3932   to8_kbd_set_ack(device->machine, ack);
39483933}
39493934
39503935
39513936
3952static WRITE8_HANDLER ( to8_timer_cp2_out )
3937static WRITE8_DEVICE_HANDLER ( to8_timer_cp2_out )
39533938{
39543939   /* mute */
39553940   to7_game_mute = data;
3956   to7_game_sound_update();
3941   to7_game_sound_update(device->machine);
39573942}
39583943
39593944
39603945
3961static const mc6846_interface to8_timer =
3946mc6846_interface to8_timer =
39623947{
39633948   to8_timer_port_out, NULL, to8_timer_cp2_out,
39643949   to8_timer_port_in, to7_timer_tco_out,
3965   thom_irq_0
3950   thom_dev_irq_0
39663951};
39673952
39683953
r3854r3855
39963981   thom_irq_reset(machine);
39973982   pia_reset();
39983983   pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe );
3999   mc6846_reset();
4000   to7_game_reset();
3984   to7_game_reset(machine);
40013985   to8_floppy_reset(machine);
40023986   to8_kbd_reset(machine);
4003   thom_centronics_reset();
4004   to7_modem_reset();
4005   to7_midi_reset();
4006   to7_rf57932_reset();
4007   mea8000_reset(machine);
3987   thom_centronics_reset(machine);
3988   to7_modem_reset(machine);
3989   to7_midi_reset(machine);
40083990
40093991   /* gate-array */
40103992   to7_lightpen = 0;
r3854r3855
40163998   to8_soft_select = 0;
40173999
40184000   /* video */
4019   thom_set_video_mode( THOM_VMODE_TO770 );
4020   thom_set_lightpen_callback(machine, 4, to8_lightpen_cb );
4021   thom_set_border_color( 0 );
4001   thom_set_video_mode( machine, THOM_VMODE_TO770 );
4002   thom_set_lightpen_callback( machine, 4, to8_lightpen_cb );
4003   thom_set_border_color( machine, 0 );
40224004   thom_set_mode_point( machine, 0 );
40234005   pia_set_input_cb1( THOM_PIA_SYS, 0 );
40244006
r3854r3855
40464028   thom_irq_init(machine);
40474029   pia_config( THOM_PIA_SYS, &to8_sys );
40484030   centronics_config( 0, &to9_centronics );
4049   mc6846_config( machine, &to8_timer );
40504031   to7_game_init(machine);
4051   to8_floppy_init( machine );
4032   to8_floppy_init(machine);
40524033   to8_kbd_init(machine);
40534034   to9_palette_init(machine);
40544035   to7_modem_init(machine);
4055   to7_midi_init();
4056   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
4036   to7_midi_init(machine);
40574037
40584038   /* memory */
40594039   thom_cart_bank = 0;
r3854r3855
40754055   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
40764056
40774057   /* save-state */
4078   state_save_register_global(machine,  thom_cart_nb_banks );
4079   state_save_register_global(machine,  thom_cart_bank );
4080   state_save_register_global(machine,  to7_lightpen );
4081   state_save_register_global(machine,  to7_lightpen_step );
4082   state_save_register_global(machine,  to8_reg_ram );
4083   state_save_register_global(machine,  to8_reg_cart );
4084   state_save_register_global(machine,  to8_reg_sys1 );
4085   state_save_register_global(machine,  to8_reg_sys2 );
4086   state_save_register_global(machine,  to8_soft_select );
4087   state_save_register_global(machine,  to8_soft_bank );
4088   state_save_register_global(machine,  to8_bios_bank );
4089   state_save_register_global(machine,  to8_lightpen_intr );
4090   state_save_register_global(machine,  to8_data_vpage );
4091   state_save_register_global(machine,  to8_cart_vpage );
4092   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
4093   state_save_register_postload(machine,  to8_update_ram_bank_postload, NULL );
4094   state_save_register_postload(machine,  to8_update_cart_bank_postload, NULL );
4095   state_save_register_postload(machine,  to8_update_floppy_bank_postload, NULL );
4058   state_save_register_global( machine, thom_cart_nb_banks );
4059   state_save_register_global( machine, thom_cart_bank );
4060   state_save_register_global( machine, to7_lightpen );
4061   state_save_register_global( machine, to7_lightpen_step );
4062   state_save_register_global( machine, to8_reg_ram );
4063   state_save_register_global( machine, to8_reg_cart );
4064   state_save_register_global( machine, to8_reg_sys1 );
4065   state_save_register_global( machine, to8_reg_sys2 );
4066   state_save_register_global( machine, to8_soft_select );
4067   state_save_register_global( machine, to8_soft_bank );
4068   state_save_register_global( machine, to8_bios_bank );
4069   state_save_register_global( machine, to8_lightpen_intr );
4070   state_save_register_global( machine, to8_data_vpage );
4071   state_save_register_global( machine, to8_cart_vpage );
4072   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
4073   state_save_register_postload( machine,  to8_update_ram_bank_postload, NULL );
4074   state_save_register_postload( machine,  to8_update_cart_bank_postload, NULL );
4075   state_save_register_postload( machine,  to8_update_floppy_bank_postload, NULL );
40964076}
40974077
40984078
r3854r3855
41194099
41204100
41214101
4122static READ8_HANDLER ( to9p_timer_port_in )
4102static READ8_DEVICE_HANDLER ( to9p_timer_port_in )
41234103{
4124   int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0;
4125   int cass = to7_get_cassette(space->machine) ? 0x80 : 0;
4104   int lightpen = (input_port_read(device->machine, "lightpen_button") & 1) ? 2 : 0;
4105   int cass = to7_get_cassette(device->machine) ? 0x80 : 0;
41264106   int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40;
41274107   return lightpen | cass | dtr;
41284108}
41294109
41304110
41314111
4132static WRITE8_HANDLER ( to9p_timer_port_out )
4112static WRITE8_DEVICE_HANDLER ( to9p_timer_port_out )
41334113{
41344114   int bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank */
4135   thom_set_mode_point( space->machine, data & 1 );       /* bit 0: video bank switch */
4136   memory_set_bank( space->machine, TO8_BIOS_BANK, bios_bank );
4115   thom_set_mode_point( device->machine, data & 1 );       /* bit 0: video bank switch */
4116   memory_set_bank( device->machine, TO8_BIOS_BANK, bios_bank );
41374117   to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */
4138   to8_update_floppy_bank(space->machine);
4139   to8_update_cart_bank(space->machine);
4118   to8_update_floppy_bank(device->machine);
4119   to8_update_cart_bank(device->machine);
41404120}
41414121
41424122
41434123
4144static const mc6846_interface to9p_timer =
4124mc6846_interface to9p_timer =
41454125{
41464126   to9p_timer_port_out, NULL, to8_timer_cp2_out,
41474127   to9p_timer_port_in, to7_timer_tco_out,
4148   thom_irq_0
4128   thom_dev_irq_0
41494129};
41504130
41514131
r3854r3855
41624142   thom_irq_reset(machine);
41634143   pia_reset();
41644144   pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe );
4165   mc6846_reset();
4166   to7_game_reset();
4145   to7_game_reset(machine);
41674146   to8_floppy_reset(machine);
41684147   to9_kbd_reset(machine);
4169   thom_centronics_reset();
4170   to7_modem_reset();
4171   to7_midi_reset();
4172   to7_rf57932_reset();
4173   mea8000_reset(machine);
4148   thom_centronics_reset(machine);
4149   to7_modem_reset(machine);
4150   to7_midi_reset(machine);
41744151
41754152   /* gate-array */
41764153   to7_lightpen = 0;
r3854r3855
41824159   to8_soft_select = 0;
41834160
41844161   /* video */
4185   thom_set_video_mode( THOM_VMODE_TO770 );
4186   thom_set_lightpen_callback(machine, 4, to8_lightpen_cb );
4187   thom_set_border_color( 0 );
4162   thom_set_video_mode( machine, THOM_VMODE_TO770 );
4163   thom_set_lightpen_callback( machine, 4, to8_lightpen_cb );
4164   thom_set_border_color( machine, 0 );
41884165   thom_set_mode_point( machine, 0 );
41894166   pia_set_input_cb1( THOM_PIA_SYS, 0 );
41904167
r3854r3855
42124189   thom_irq_init(machine);
42134190   pia_config( THOM_PIA_SYS, &to9p_sys );
42144191   centronics_config( 0, &to9_centronics );
4215   mc6846_config( machine, &to9p_timer );
42164192   to7_game_init(machine);
42174193   to8_floppy_init( machine );
42184194   to9_kbd_init(machine);
42194195   to9_palette_init(machine);
42204196   to7_modem_init(machine);
4221   to7_midi_init();
4222   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
4197   to7_midi_init(machine);
42234198
42244199   /* memory */
42254200   thom_cart_bank = 0;
r3854r3855
42414216   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
42424217
42434218   /* save-state */
4244   state_save_register_global(machine,  thom_cart_nb_banks );
4245   state_save_register_global(machine,  thom_cart_bank );
4246   state_save_register_global(machine,  to7_lightpen );
4247   state_save_register_global(machine,  to7_lightpen_step );
4248   state_save_register_global(machine,  to8_reg_ram );
4249   state_save_register_global(machine,  to8_reg_cart );
4250   state_save_register_global(machine,  to8_reg_sys1 );
4251   state_save_register_global(machine,  to8_reg_sys2 );
4252   state_save_register_global(machine,  to8_soft_select );
4253   state_save_register_global(machine,  to8_soft_bank );
4254   state_save_register_global(machine,  to8_bios_bank );
4255   state_save_register_global(machine,  to8_lightpen_intr );
4256   state_save_register_global(machine,  to8_data_vpage );
4257   state_save_register_global(machine,  to8_cart_vpage );
4258   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
4259   state_save_register_postload(machine,  to8_update_ram_bank_postload, NULL );
4260   state_save_register_postload(machine,  to8_update_cart_bank_postload, NULL );
4261   state_save_register_postload(machine,  to8_update_floppy_bank_postload, NULL );
4219   state_save_register_global( machine, thom_cart_nb_banks );
4220   state_save_register_global( machine, thom_cart_bank );
4221   state_save_register_global( machine, to7_lightpen );
4222   state_save_register_global( machine, to7_lightpen_step );
4223   state_save_register_global( machine, to8_reg_ram );
4224   state_save_register_global( machine, to8_reg_cart );
4225   state_save_register_global( machine, to8_reg_sys1 );
4226   state_save_register_global( machine, to8_reg_sys2 );
4227   state_save_register_global( machine, to8_soft_select );
4228   state_save_register_global( machine, to8_soft_bank );
4229   state_save_register_global( machine, to8_bios_bank );
4230   state_save_register_global( machine, to8_lightpen_intr );
4231   state_save_register_global( machine, to8_data_vpage );
4232   state_save_register_global( machine, to8_cart_vpage );
4233   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
4234   state_save_register_postload( machine,  to8_update_ram_bank_postload, NULL );
4235   state_save_register_postload( machine,  to8_update_cart_bank_postload, NULL );
4236   state_save_register_postload( machine,  to8_update_floppy_bank_postload, NULL );
42624237}
42634238
42644239
r3854r3855
42714246
42724247
42734248
4274static void mo6_update_ram_bank (running_machine *machine)
4249static void mo6_update_ram_bank ( running_machine *machine )
42754250{
42764251   UINT8 bank = 0;
42774252
r3854r3855
42974272
42984273static void mo6_update_cart_bank (running_machine *machine)
42994274{
4275   const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
43004276   int b = (pia_get_output_a( THOM_PIA_SYS ) >> 5) & 1;
43014277   static int old_bank = -1;
43024278   int bank = 0;
43034279
4304   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
4280   memory_install_read8_handler( space, 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
43054281
43064282   if ( ( ( to8_reg_sys1 & 0x40 ) && ( to8_reg_cart & 0x20 ) ) || ( ! ( to8_reg_sys1 & 0x40 ) && ( mo5_reg_cart & 4 ) ) )
43074283   {
r3854r3855
43114287         /* use a7e6 */
43124288         to8_cart_vpage = to8_reg_cart & 7; /* 128 KB RAM only = 8 pages */
43134289         bank = 8 + to8_cart_vpage;
4314         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0,
4290         memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0,
43154291                         (to8_reg_cart & 0x40) ? (to8_cart_vpage <= 4) ? to8_vcart_w :
43164292                         (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP );
43174293         if ( bank != old_bank )
r3854r3855
43204296      else if ( thom_cart_nb_banks == 4 )
43214297      {
43224298         /* "JANE"-style cartridge bank switching */
4323         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP );
4299         memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, SMH_NOP );
43244300         bank = mo5_reg_cart & 3;
43254301         if ( bank != old_bank )
43264302            LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank ));
r3854r3855
43314307         int write_enable = mo5_reg_cart & 8;
43324308         to8_cart_vpage = (mo5_reg_cart & 3) | 4;
43334309         bank = 8 + to8_cart_vpage;
4334         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ?
4310         memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, write_enable ?
43354311                         (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
43364312         if ( bank != old_bank )
43374313            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 ));
r3854r3855
43404316   else
43414317   {
43424318      /* ROM space */
4343      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP );
4319      memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, SMH_NOP );
43444320      if ( to8_reg_sys2 & 0x20 )
43454321      {
43464322         /* internal ROM */
r3854r3855
43544330      else
43554331      {
43564332         /* cartridge */
4357         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo6_cartridge_w );
4333         memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, mo6_cartridge_w );
43584334         if ( thom_cart_nb_banks )
43594335         {
43604336            bank = thom_cart_bank % thom_cart_nb_banks;
4361            memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r );
4337            memory_install_read8_handler( space, 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r );
43624338         }
43634339         if ( bank != old_bank )
43644340            LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank ));
r3854r3855
44214397static WRITE8_HANDLER ( mo6_game_porta_out )
44224398{
44234399   /* centronics data */
4424   LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
4400   LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
44254401   centronics_write_data( 0, data );
44264402}
44274403
r3854r3855
44314407{
44324408   int dtr = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 0 : 1;
44334409   /* note: printer busy signal replaces button */
4434   LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), dtr ));
4410   LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), dtr ));
44354411   return dtr;
44364412}
44374413
r3854r3855
44404416static WRITE8_HANDLER ( mo6_game_cb2_out )
44414417{
44424418   /* centronics strobe */
4443   LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ));
4444   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0,
4445                CENTRONICS_STROBE );
4419   LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ));
4420   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE );
44464421}
44474422
44484423
r3854r3855
44814456{
44824457   LOG (( "mo6_game_init called\n" ));
44834458   pia_config( THOM_PIA_GAME, &mo6_game );
4484   to7_game_timer = timer_alloc(machine, mo6_game_update_cb , NULL);
4459   to7_game_timer = timer_alloc( machine, mo6_game_update_cb , NULL);
44854460   timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD);
4486   state_save_register_global(machine,  to7_game_sound );
4487   state_save_register_global(machine,  to7_game_mute );
4461   state_save_register_global( machine, to7_game_sound );
4462   state_save_register_global( machine, to7_game_mute );
44884463}
44894464
44904465
44914466
4492static void mo6_game_reset ( void )
4467static void mo6_game_reset ( running_machine *machine )
44934468{
44944469   LOG (( "mo6_game_reset called\n" ));
44954470   pia_set_input_ca1( THOM_PIA_GAME, 0 );
44964471   to7_game_sound = 0;
44974472   to7_game_mute = 0;
4498   to7_game_sound_update();
4473   to7_game_sound_update(machine);
44994474}
45004475
45014476
r3854r3855
45374512
45384513static WRITE8_HANDLER ( mo6_sys_porta_out )
45394514{
4540   thom_set_mode_point( space->machine, data & 1 );                  /* bit 0: video bank switch */
4541   to7_game_mute = data & 4;                        /* bit 2: sound mute */
4542   thom_set_caps_led( (data & 16) ? 0 : 1 ) ;            /* bit 4: keyboard led */
4543   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
4544   mo6_update_cart_bank(space->machine);                     /* bit 5: rom bank */
4545   to7_game_sound_update();
4515   thom_set_mode_point( space->machine,data & 1 );            /* bit 0: video bank switch */
4516   to7_game_mute = data & 4;                  /* bit 2: sound mute */
4517   thom_set_caps_led( space->machine,(data & 16) ? 0 : 1 ) ;      /* bit 4: keyboard led */
4518   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );       /* bit 6: cassette output */
4519   mo6_update_cart_bank(space->machine);               /* bit 5: rom bank */
4520   to7_game_sound_update(space->machine);
45464521}
45474522
45484523
r3854r3855
45804555
45814556READ8_HANDLER ( mo6_gatearray_r )
45824557{
4583   struct thom_vsignal v = thom_get_vsignal();
4558   struct thom_vsignal v = thom_get_vsignal( space->machine );
45844559   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO6_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 );
45854560   int count, inil, init, lt3;
45864561   UINT8 res;
r3854r3855
46224597      break;
46234598
46244599   default:
4625      logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
4600      logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset );
46264601      res = 0;
46274602   }
46284603
46294604   LOG_VIDEO(( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n",
4630        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
4605        cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
46314606        offset, 0xa7e4 + offset, res, to7_lightpen ));
46324607
46334608   return res;
r3854r3855
46384613WRITE8_HANDLER ( mo6_gatearray_w )
46394614{
46404615   LOG_VIDEO(( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n",
4641        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
4616        cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
46424617        offset, 0xa7e4 + offset, data ));
46434618
46444619   switch ( offset )
r3854r3855
46684643      break;
46694644
46704645   default:
4671      logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), offset, data );
4646      logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
46724647   }
46734648}
46744649
r3854r3855
47054680WRITE8_HANDLER ( mo6_vreg_w )
47064681{
47074682   LOG_VIDEO(( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n",
4708        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)),
4683        cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)),
47094684        offset, 0xa7da + offset, data ));
47104685
47114686   switch ( offset )
r3854r3855
47204695      if ( ( to8_reg_sys1 & 0x80 ) && ( to8_reg_ram & 0x80 ) )
47214696         to7_floppy_w( space, 0xc, data );
47224697      else
4723         to9_set_video_mode( data, 2 );
4698         to9_set_video_mode( space->machine, data, 2 );
47244699      break;
47254700
47264701   case 3: /* system register 2 */
r3854r3855
47304705      else
47314706      {
47324707         to8_reg_sys2 = data;
4733         thom_set_video_page( data >> 6 );
4734         thom_set_border_color( data & 15 );
4735         mo6_update_cart_bank(space->machine);
4708         thom_set_video_page( space->machine, data >> 6 );
4709         thom_set_border_color( space->machine, data & 15 );
4710         mo6_update_cart_bank( space->machine );
47364711      }
47374712      break;
47384713
r3854r3855
47554730   thom_irq_reset(machine);
47564731   pia_reset();
47574732   pia_set_port_a_z_mask( THOM_PIA_SYS, 0x75 );
4758   mo6_game_reset();
4733   mo6_game_reset(machine);
47594734   to7_floppy_reset(machine);
4760   thom_centronics_reset();
4761   to7_modem_reset();
4762   to7_midi_reset();
4763   to7_rf57932_reset();
4764   mo5_init_timer();
4765   mea8000_reset(machine);
4735   thom_centronics_reset(machine);
4736   to7_modem_reset(machine);
4737   to7_midi_reset(machine);
4738   mo5_init_timer(machine);
47664739
47674740   /* gate-array */
47684741   to7_lightpen = 0;
r3854r3855
47734746   to8_lightpen_intr = 0;
47744747
47754748   /* video */
4776   thom_set_video_mode( THOM_VMODE_MO5 );
4777   thom_set_lightpen_callback(machine, 3, to8_lightpen_cb );
4778   thom_set_border_color( 0 );
4749   thom_set_video_mode( machine, THOM_VMODE_MO5 );
4750   thom_set_lightpen_callback( machine, 3, to8_lightpen_cb );
4751   thom_set_border_color( machine, 0 );
47794752   thom_set_mode_point( machine, 0 );
47804753   pia_set_input_ca1( THOM_PIA_SYS, 0 );
47814754
r3854r3855
48044777   to7_floppy_init( machine, mem + 0x30000 );
48054778   to9_palette_init(machine);
48064779   to7_modem_init(machine);
4807   to7_midi_init();
4808   mo5_periodic_timer = timer_alloc(machine,  mo5_periodic_cb , NULL);
4809   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
4780   to7_midi_init(machine);
4781   mo5_periodic_timer = timer_alloc( machine, mo5_periodic_cb , NULL);
48104782
48114783   /* memory */
48124784   thom_cart_bank = 0;
r3854r3855
48314803   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
48324804
48334805   /* save-state */
4834   state_save_register_global(machine,  thom_cart_nb_banks );
4835   state_save_register_global(machine,  thom_cart_bank );
4836   state_save_register_global(machine,  to7_lightpen );
4837   state_save_register_global(machine,  to7_lightpen_step );
4838   state_save_register_global(machine,  to8_reg_ram );
4839   state_save_register_global(machine,  to8_reg_cart );
4840   state_save_register_global(machine,  to8_reg_sys1 );
4841   state_save_register_global(machine,  to8_reg_sys2 );
4842   state_save_register_global(machine,  to8_lightpen_intr );
4843   state_save_register_global(machine,  to8_data_vpage );
4844   state_save_register_global(machine,  to8_cart_vpage );
4845   state_save_register_global(machine,  mo5_reg_cart );
4846   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
4847   state_save_register_postload(machine,  mo6_update_ram_bank_postload, NULL );
4848   state_save_register_postload(machine,  mo6_update_cart_bank_postload, NULL );
4806   state_save_register_global( machine, thom_cart_nb_banks );
4807   state_save_register_global( machine, thom_cart_bank );
4808   state_save_register_global( machine, to7_lightpen );
4809   state_save_register_global( machine, to7_lightpen_step );
4810   state_save_register_global( machine, to8_reg_ram );
4811   state_save_register_global( machine, to8_reg_cart );
4812   state_save_register_global( machine, to8_reg_sys1 );
4813   state_save_register_global( machine, to8_reg_sys2 );
4814   state_save_register_global( machine, to8_lightpen_intr );
4815   state_save_register_global( machine, to8_data_vpage );
4816   state_save_register_global( machine, to8_cart_vpage );
4817   state_save_register_global( machine, mo5_reg_cart );
4818   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
4819   state_save_register_postload( machine,  mo6_update_ram_bank_postload, NULL );
4820   state_save_register_postload( machine,  mo6_update_cart_bank_postload, NULL );
48494821}
48504822
48514823
r3854r3855
48634835   if ( to7_controller_type )
48644836      return to7_floppy_r ( space, offset );
48654837
4866   logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset );
4838   logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset );
48674839
4868   if ( to7_controller_type )
4869      return to7_floppy_r ( space, offset );
4870
48714840   return 0;
48724841}
48734842
r3854r3855
48794848      to7_floppy_w ( space, offset, data );
48804849   else
48814850      logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n",
4882           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, offset );
4851           cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data, offset );
48834852}
48844853
48854854
r3854r3855
49074876         return 0x80;
49084877
49094878   default:
4910      logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset );
4879      logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset );
49114880      return 0;
49124881   }
49134882}
r3854r3855
49294898      break;
49304899
49314900   default:
4932      logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset, data );
4901      logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset, data );
49334902   }
49344903}
49354904
r3854r3855
49574926static WRITE8_HANDLER ( mo5nr_sys_porta_out )
49584927{
49594928   /* no keyboard LED */
4960   thom_set_mode_point( space->machine, data & 1 );                  /* bit 0: video bank switch */
4961   to7_game_mute = data & 4;                        /* bit 2: sound mute */
4929   thom_set_mode_point( space->machine, data & 1 );         /* bit 0: video bank switch */
4930   to7_game_mute = data & 4;                  /* bit 2: sound mute */
49624931   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
4963   mo6_update_cart_bank(space->machine);                     /* bit 5: rom bank */
4964   to7_game_sound_update();
4932   mo6_update_cart_bank(space->machine);               /* bit 5: rom bank */
4933   to7_game_sound_update(space->machine);
49654934}
49664935
49674936
r3854r3855
49934962
49944963
49954964
4996static void mo5nr_game_init ( running_machine *machine )
4965static void mo5nr_game_init ( running_machine* machine )
49974966{
49984967   LOG (( "mo5nr_game_init called\n" ));
49994968   pia_config( THOM_PIA_GAME, &mo5nr_game );
5000   to7_game_timer = timer_alloc(machine,  mo6_game_update_cb , NULL);
5001   timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD);
5002   state_save_register_global(machine,  to7_game_sound );
5003   state_save_register_global(machine,  to7_game_mute );
4969   to7_game_timer = timer_alloc( machine, mo6_game_update_cb , NULL);
4970   timer_adjust_periodic( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
4971   state_save_register_global( machine, to7_game_sound );
4972   state_save_register_global( machine, to7_game_mute );
50044973}
50054974
50064975
50074976
5008static void mo5nr_game_reset ( void )
4977static void mo5nr_game_reset ( running_machine* machine )
50094978{
50104979   LOG (( "mo5nr_game_reset called\n" ));
50114980   pia_set_input_ca1( THOM_PIA_GAME, 0 );
50124981   to7_game_sound = 0;
50134982   to7_game_mute = 0;
5014   to7_game_sound_update();
4983   to7_game_sound_update(machine);
50154984}
50164985
50174986
r3854r3855
50284997   thom_irq_reset(machine);
50294998   pia_reset();
50304999   pia_set_port_a_z_mask( THOM_PIA_SYS, 0x65 );
5031   mo5nr_game_reset();
5000   mo5nr_game_reset(machine);
50325001   to7_floppy_reset(machine);
5033   thom_centronics_reset();
5034   to7_modem_reset();
5035   to7_midi_reset();
5036   to7_rf57932_reset();
5037   mo5_init_timer();
5038   mea8000_reset(machine);
5002   thom_centronics_reset(machine);
5003   to7_modem_reset(machine);
5004   to7_midi_reset(machine);
5005   mo5_init_timer(machine);
50395006
50405007   /* gate-array */
50415008   to7_lightpen = 0;
r3854r3855
50465013   to8_lightpen_intr = 0;
50475014
50485015   /* video */
5049   thom_set_video_mode( THOM_VMODE_MO5 );
5050   thom_set_lightpen_callback(machine, 3, to8_lightpen_cb );
5051   thom_set_border_color( 0 );
5016   thom_set_video_mode( machine, THOM_VMODE_MO5 );
5017   thom_set_lightpen_callback( machine, 3, to8_lightpen_cb );
5018   thom_set_border_color( machine, 0 );
50525019   thom_set_mode_point( machine, 0 );
50535020   pia_set_input_ca1( THOM_PIA_SYS, 0 );
50545021
r3854r3855
50735040   thom_irq_init(machine);
50745041   pia_config( THOM_PIA_SYS, &mo5nr_sys );
50755042   centronics_config( 0, &to9_centronics );
5076   mo5nr_game_init( machine );
5043   mo5nr_game_init(machine);
50775044   to7_floppy_init( machine, mem + 0x30000 );
50785045   to9_palette_init(machine);
50795046   to7_modem_init(machine);
5080   to7_midi_init();
5081   mo5_periodic_timer = timer_alloc(machine,  mo5_periodic_cb , NULL);
5082   mea8000_config( machine, THOM_SOUND_SPEECH, NULL );
5047   to7_midi_init(machine);
5048   mo5_periodic_timer = timer_alloc( machine, mo5_periodic_cb , NULL);
50835049
50845050   /* memory */
50855051   thom_cart_bank = 0;
r3854r3855
51045070   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
51055071
51065072   /* save-state */
5107   state_save_register_global(machine,  thom_cart_nb_banks );
5108   state_save_register_global(machine,  thom_cart_bank );
5109   state_save_register_global(machine,  to7_lightpen );
5110   state_save_register_global(machine,  to7_lightpen_step );
5111   state_save_register_global(machine,  to8_reg_ram );
5112   state_save_register_global(machine,  to8_reg_cart );
5113   state_save_register_global(machine,  to8_reg_sys1 );
5114   state_save_register_global(machine,  to8_reg_sys2 );
5115   state_save_register_global(machine,  to8_lightpen_intr );
5116   state_save_register_global(machine,  to8_data_vpage );
5117   state_save_register_global(machine,  to8_cart_vpage );
5118   state_save_register_global(machine,  mo5_reg_cart );
5119   state_save_register_global_pointer(machine,  (mem + 0x10000), 0x10000 );
5120   state_save_register_postload(machine,  mo6_update_ram_bank_postload, NULL );
5121   state_save_register_postload(machine,  mo6_update_cart_bank_postload, NULL );
5073   state_save_register_global( machine, thom_cart_nb_banks );
5074   state_save_register_global( machine, thom_cart_bank );
5075   state_save_register_global( machine, to7_lightpen );
5076   state_save_register_global( machine, to7_lightpen_step );
5077   state_save_register_global( machine, to8_reg_ram );
5078   state_save_register_global( machine, to8_reg_cart );
5079   state_save_register_global( machine, to8_reg_sys1 );
5080   state_save_register_global( machine, to8_reg_sys2 );
5081   state_save_register_global( machine, to8_lightpen_intr );
5082   state_save_register_global( machine, to8_data_vpage );
5083   state_save_register_global( machine, to8_cart_vpage );
5084   state_save_register_global( machine, mo5_reg_cart );
5085   state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 );
5086   state_save_register_postload( machine,  mo6_update_ram_bank_postload, NULL );
5087   state_save_register_postload( machine,  mo6_update_cart_bank_postload, NULL );
51225088}
src/mess/devices/thomflop.c
r3854r3855
66
77**********************************************************************/
88
9#include "driver.h"
109#include "includes/thomson.h"
11#include "machine/wd17xx.h"
12#include "devices/flopdrv.h"
13#include "devices/thomflop.h"
14#include "formats/thom_dsk.h"
15#include "machine/mc6854.h"
16#include "machine/mc6843.h"
1710
1811
1912#define VERBOSE 0 /* 0, 1 or 2 */
r3854r3855
282275   else if ( offset == 8 )
283276      return to7_5p14_select;
284277   else
285      logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset );
278      logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset );
286279   return 0;
287280}
288281
r3854r3855
306299      case 4: drive = 2; side = 0; break;
307300      case 5: drive = 3; side = 1; break;
308301      default:
309         logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data );
302         logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data );
310303      }
311304
312305      dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO;
r3854r3855
317310
318311      if ( drive != -1 )
319312      {
320         thom_floppy_active( 0 );
313         thom_floppy_active( space->machine, 0 );
321314         wd17xx_set_drive( drive );
322315         wd17xx_set_side( side );
323316         LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n",
324               attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu),
317               attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ),
325318               data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" ));
326319      }
327320   }
328321   else
329322      logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n",
330            attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data );
323            attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
331324}
332325
333326
r3854r3855
353346{
354347   LOG(( "to7_5p14_init: CD 90-640 controller\n" ));
355348   wd17xx_init( machine, WD_TYPE_2793, NULL, NULL );
356   state_save_register_global(machine, to7_5p14_select );
349   state_save_register_global( machine, to7_5p14_select );
357350}
358351
359352
r3854r3855
375368static READ8_HANDLER ( to7_5p14sd_r )
376369{
377370   if ( offset < 8 )
378      return mc6843_r( space, offset );
371      return mc6843_r( devtag_get_device(space->machine, MC6843, "mc6843"), offset );
379372   else if ( offset >= 8 && offset <= 9 )
380373      return to7_5p14sd_select;
381374   else
382      logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n",  attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset );
375      logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n",  attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset );
383376   return 0;
384377}
385378
r3854r3855
388381static WRITE8_HANDLER( to7_5p14sd_w )
389382{
390383   if ( offset < 8 )
391      mc6843_w( space, offset, data );
384      mc6843_w( devtag_get_device(space->machine, MC6843, "mc6843"), offset, data );
392385   else if ( offset >= 8 && offset <= 9 )
393386   {
394387      /* drive select */
r3854r3855
419412
420413      if ( drive != -1 )
421414      {
422         thom_floppy_active( 0 );
423         mc6843_set_drive( drive );
424         mc6843_set_side( side );
415         thom_floppy_active( space->machine, 0 );
416         mc6843_set_drive( devtag_get_device(space->machine, MC6843, "mc6843"), drive );
417         mc6843_set_side( devtag_get_device(space->machine, MC6843, "mc6843"), side );
425418         LOG(( "%f $%04x to7_5p14sd_w: $%02X set drive=%i side=%i\n",
426               attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, drive, side ));
419               attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, drive, side ));
427420      }
428421   }
429422   else
430423      logerror ( "%f $%04x to7_5p14sd_w: invalid write offset %i (data=$%02X)\n",
431            attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data );
424            attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
432425}
433426
427static void to7_5p14_index_pulse_callback( const device_config *device, int index_pulse )
428{
429   mc6843_set_index_pulse( devtag_get_device(device->machine, MC6843, "mc6843"), index_pulse );
430}
434431
435
436432static void to7_5p14sd_reset( running_machine *machine )
437433{
438434   int i;
439435   LOG(( "to7_5p14sd_reset: CD 90-015 controller\n" ));
440436   thom_floppy_set_density( DEN_FM_LO );
441   mc6843_reset(machine);
442437   for ( i = 0; i < device_count( machine, IO_FLOPPY ); i++ )
443438   {
444439      const device_config * img = image_from_devtype_and_index( IO_FLOPPY, i );
445440      floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 );
446441      floppy_drive_set_rpm( img, 300. );
447442      floppy_drive_seek( img, - floppy_drive_get_current_track( img ) );
443      floppy_drive_set_index_pulse_callback( img, to7_5p14_index_pulse_callback );
444
448445   }
449446}
450447
451448
452449
453static mc6843_interface to7_6843_itf = { NULL };
450mc6843_interface to7_6843_itf = { NULL };
454451
455452
456453
457454static void to7_5p14sd_init( running_machine *machine )
458455{
459456   LOG(( "to7_5p14sd_init: CD 90-015 controller\n" ));
460   mc6843_config( machine, &to7_6843_itf );
461   state_save_register_global(machine,  to7_5p14sd_select );
457   state_save_register_global( machine, to7_5p14sd_select );
462458}
463459
464460
r3854r3855
541537      to7qdd->data_size = 0;
542538   }
543539
544   //VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state ));
540   VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(img->machine)), state ));
545541}
546542
547543
r3854r3855
588584
589585
590586
591static UINT8 to7_qdd_read_byte( void )
587static UINT8 to7_qdd_read_byte( running_machine *machine )
592588{
593589   UINT8 data;
594590
r3854r3855
604600   else
605601      data = to7qdd->data[ to7qdd->data_idx ];
606602
607//   VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n",
608//          attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu),
609//          to7qdd->data_idx, to7qdd->data_size, data ));
603   VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n",
604          attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ),
605          to7qdd->data_idx, to7qdd->data_size, data ));
610606
611607   to7qdd->data_idx++;
612608   to7qdd->start_idx = to7qdd->data_idx;
r3854r3855
621617   * CPU write id field and data field => format
622618   * CPU write data field after it has read an id field => sector write
623619   */
624static void to7_qdd_write_byte( UINT8 data )
620static void to7_qdd_write_byte( running_machine *machine, UINT8 data )
625621{
626622   int i;
627623
r3854r3855
645641      to7qdd->data[ to7qdd->data_idx ] = data;
646642      to7qdd->data_idx++;
647643
648//      VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n",
649//         attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data,
650//         to7qdd->start_idx, to7qdd->data_idx ));
644      VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n",
645         attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data,
646         to7qdd->start_idx, to7qdd->data_idx ));
651647
652648      /* end of tentative id field */
653649      if ( to7qdd->data_idx == to7qdd->start_idx + 4 &&
r3854r3855
659655         int sector = (int) to7qdd->data[ to7qdd->start_idx + 1 ] * 256 + (int) to7qdd->data[ to7qdd->start_idx + 2 ];
660656         UINT8 filler = 0xff;
661657
662//         LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n",
663//               attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector ));
658         LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n",
659               attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector ));
664660
665661         floppy_drive_format_sector( to7_qdd_image(),
666662                      0, sector, 0, 0, sector, 128, filler );
r3854r3855
688684            /* got an id & a data field => write */
689685            int sector = (int) to7qdd->data[ i + 1 ] * 256 + (int) to7qdd->data[ i + 2 ];
690686
691//            LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n",
692//                  attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector ));
687            LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n",
688                  attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector ));
693689
694690            floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 );
695691         }
r3854r3855
711707   case 0: /* MC6852 status */
712708      to7_qdd_stat_update();
713709      VLOG(( "%f $%04x to7_qdd_r: STAT=$%02X irq=%i pe=%i ovr=%i und=%i tr=%i rd=%i ncts=%i\n",
714             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), to7qdd->status,
710             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), to7qdd->status,
715711             to7qdd->status & QDD_S_IRQ  ? 1 : 0,
716712             to7qdd->status & QDD_S_PE   ? 1 : 0,
717713             to7qdd->status & QDD_S_OVR  ? 1 : 0,
r3854r3855
724720   case 1: /* MC6852 data input => read byte from disk */
725721      to7qdd->status &= ~(QDD_S_RDA | QDD_S_PE | QDD_S_OVR);
726722      to7_qdd_stat_update();
727      return to7_qdd_read_byte();
723      return to7_qdd_read_byte( space->machine );
728724
729725   case 8: /* floppy status */
730726   {
r3854r3855
734730         data |= 0x40; /* disk present */
735731      if ( to7qdd->index_pulse )
736732         data |= 0x80; /* disk start */
737      VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
733      VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
738734      return data;
739735   }
740736
741737   default:
742      logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset );
738      logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset );
743739      return 0;
744740   }
745741}
r3854r3855
761757      to7qdd->ctrl1 = ( data & ~(QDD_C1_RRESET | QDD_C1_TRESET) ) |( data &  (QDD_C1_RRESET | QDD_C1_TRESET) & to7qdd->ctrl1 );
762758      to7_qdd_stat_update();
763759      VLOG(( "%f $%04x to7_qdd_w: CTRL1=$%02X reset=%c%c %s%sirq=%c%c\n",
764             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
760             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
765761             data & QDD_C1_RRESET ? 'r' : '-', data & QDD_C1_TRESET ? 't' : '-',
766762             data & QDD_C1_STRIPSYNC ? "strip-sync " : "",
767763             data & QDD_C1_CLRSYNC ? "clear-sync " : "",
r3854r3855
785781         parity = par[ (data >> 3) & 7 ];
786782         to7_qdd_stat_update();
787783         VLOG(( "%f $%04x to7_qdd_w: CTRL2=$%02X bits=%i par=%s blen=%i under=%s%s\n",
788                attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data,
784                attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
789785                bits, parname[ parity ], data & QDD_C2_BLEN ? 1 : 2,
790786                data & QDD_C2_TSYNC ? "sync" : "ff",
791787                data & QDD_C2_EIE ? "irq-err" : "" ));
r3854r3855
803799            to7qdd->status &= ~QDD_S_NCTS;
804800         to7_qdd_stat_update();
805801         VLOG(( "%f $%04x to7_qdd_w: CTRL3=$%02X %s%ssync-len=%i sync-mode=%s\n",
806                attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
802                attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
807803                data & QDD_C3_CLRTUF ? "clr-tuf " : "",
808804                data & QDD_C3_CLRCTS ? "clr-cts " : "",
809805                data & QDD_C3_SYNCLEN ? 1 : 2,
r3854r3855
811807         break;
812808
813809      case 2: /* MC6852 sync code => write byte to disk */
814         to7_qdd_write_byte( data );
810         to7_qdd_write_byte( space->machine, data );
815811         break;
816812
817813      case 3: /* MC6852 data out => does not seem to be used */
818         VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
814         VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
819815         break;
820816
821817      }
r3854r3855
823819
824820   case 8: /* set drive */
825821      to7qdd->drive = data;
826      VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
822      VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
827823      break;
828824
829825   case 12: /* motor pulse ? */
830      thom_floppy_active( 0 );
831      VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
826      thom_floppy_active( space->machine, 0 );
827      VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
832828      break;
833829
834830   default:
835      logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data );
831      logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
836832   }
837833}
838834
r3854r3855
872868   to7qdd = auto_malloc( sizeof( *to7qdd ) );
873869   assert( to7qdd );
874870
875   state_save_register_global(machine,  to7qdd->status );
876   state_save_register_global(machine,  to7qdd->ctrl1 );
877   state_save_register_global(machine,  to7qdd->ctrl2 );
878   state_save_register_global(machine,  to7qdd->ctrl3 );
879   state_save_register_global(machine,  to7qdd->drive );
880   state_save_register_global(machine,  to7qdd->data_idx );
881   state_save_register_global(machine,  to7qdd->start_idx );
882   state_save_register_global(machine,  to7qdd->data_size );
883   state_save_register_global(machine,  to7qdd->data_crc );
884   state_save_register_global(machine,  to7qdd->index_pulse );
885   state_save_register_global_array(machine,  to7qdd->data );
871   state_save_register_global( machine, to7qdd->status );
872   state_save_register_global( machine, to7qdd->ctrl1 );
873   state_save_register_global( machine, to7qdd->ctrl2 );
874   state_save_register_global( machine, to7qdd->ctrl3 );
875   state_save_register_global( machine, to7qdd->drive );
876   state_save_register_global( machine, to7qdd->data_idx );
877   state_save_register_global( machine, to7qdd->start_idx );
878   state_save_register_global( machine, to7qdd->data_size );
879   state_save_register_global( machine, to7qdd->data_crc );
880   state_save_register_global( machine, to7qdd->index_pulse );
881   state_save_register_global_array( machine, to7qdd->data );
886882}
887883
888884
r3854r3855
983979         thmfc1->data_raw_idx = 0;
984980   }
985981
986   //VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state ));
982   VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(img->machine)), state ));
987983}
988984
989985
r3854r3855
10251021
10261022
10271023/* complete command (by read, write, or timeout) */
1028static void thmfc_floppy_cmd_complete(running_machine *machine)
1024static void thmfc_floppy_cmd_complete( running_machine *machine )
10291025{
10301026   LOG (( "%f thmfc_floppy_cmd_complete_cb: cmd=%i off=%i/%i/%i\n",
10311027          attotime_to_double(timer_get_time(machine)), thmfc1->op, thmfc1->data_idx,
r3854r3855
10481044
10491045static TIMER_CALLBACK( thmfc_floppy_cmd_complete_cb )
10501046{
1051   thmfc_floppy_cmd_complete(machine);
1047   thmfc_floppy_cmd_complete( machine );
10521048}
10531049
10541050
r3854r3855
10581054{
10591055   UINT8 data = thmfc1->data[ thmfc1->data_idx ];
10601056
1061//   VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n",
1062//          attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu),
1063//          thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1,
1064//          data ));
1057   VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n",
1058          attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ),
1059          thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1,
1060          data ));
10651061
10661062   if ( thmfc1->data_idx >= thmfc1->data_size - 1 )
1067      thmfc_floppy_cmd_complete(machine);
1063      thmfc_floppy_cmd_complete( machine );
10681064   else
10691065      thmfc1->data_idx++;
10701066
r3854r3855
10771073
10781074
10791075/* dumb read: show whole track with field headers and gaps  */
1080static UINT8 thmfc_floppy_raw_read_byte ( void )
1076static UINT8 thmfc_floppy_raw_read_byte ( running_machine *machine )
10811077{
10821078   UINT8 data;
10831079
r3854r3855
11011097   else
11021098      data = thmfc1->data[ thmfc1->data_raw_idx ];
11031099
1104//   VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n",
1105//          attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu),
1106//          thmfc1->data_raw_idx, thmfc1->data_raw_size, data ));
1100   VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n",
1101          attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ),
1102          thmfc1->data_raw_idx, thmfc1->data_raw_size, data ));
11071103
11081104   thmfc1->data_raw_idx++;
11091105
r3854r3855
11131109
11141110
11151111/* QDD writing / formating */
1116static void thmfc_floppy_qdd_write_byte ( UINT8 data )
1112static void thmfc_floppy_qdd_write_byte ( running_machine *machine, UINT8 data )
11171113{
11181114   int i;
11191115
r3854r3855
11391135         thmfc1->data_idx = thmfc1->data_raw_idx;
11401136      }
11411137
1142//      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n",
1143//         attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data,
1144//         thmfc1->data_idx,thmfc1->data_raw_idx ));
1138      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n",
1139         attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data,
1140         thmfc1->data_idx,thmfc1->data_raw_idx ));
11451141
11461142      if ( thmfc1->data_raw_idx == thmfc1->data_idx + 3 &&
11471143           thmfc1->data[ thmfc1->data_idx - 1 ] == 0xA5 &&
r3854r3855
11521148         int sector = (int) thmfc1->data[ thmfc1->data_idx ] * 256 + (int) thmfc1->data[ thmfc1->data_idx + 1 ];
11531149         UINT8 filler = 0xff;
11541150
1155//         LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector ));
1151         LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector ));
11561152
11571153         floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler );
11581154         thmfc1->data_idx = 0;
r3854r3855
11801176            int sector = (int) thmfc1->data[ i + 1 ] * 256 +
11811177               (int) thmfc1->data[ i + 2 ];
11821178
1183//            LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n",
1184//                  attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector ));
1179            LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n",
1180                  attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector ));
11851181
11861182            floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 );
11871183         }
r3854r3855
11951191   else
11961192   {
11971193      thmfc1->data_raw_idx++;
1198//      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data ));
1194      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data ));
11991195   }
12001196
12011197}
r3854r3855
12051201/* intelligent writing */
12061202static void thmfc_floppy_write_byte ( running_machine *machine, UINT8 data )
12071203{
1208//   VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n",
1209//      attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu),
1210//      thmfc1->data_idx, thmfc1->data_size - 1, data ));
1204   VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n",
1205      attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ),
1206      thmfc1->data_idx, thmfc1->data_size - 1, data ));
12111207
12121208   thmfc1->data_raw_size = 0;
12131209   thmfc1->data[ thmfc1->data_idx ] = data;
12141210   if ( thmfc1->data_idx >= thmfc1->data_size - 1 )
1215      thmfc_floppy_cmd_complete(machine);
1211      thmfc_floppy_cmd_complete( machine );
12161212   else
12171213      thmfc1->data_idx++;
12181214}
12191215
12201216/* intelligent formatting */
1221static void thmfc_floppy_format_byte ( UINT8 data )
1217static void thmfc_floppy_format_byte ( running_machine *machine, UINT8 data )
12221218{
1223//   VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data ));
1219   VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data ));
12241220
12251221   thmfc1->data_raw_size = 0;
12261222
r3854r3855
12601256
12611257   case 0: /* STAT0 */
12621258      thmfc1->stat0 ^= THMFC1_STAT0_SYNCHRO | THMFC1_STAT0_BYTE_READY_POL;
1263      VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), thmfc1->stat0 ));
1259      VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), thmfc1->stat0 ));
12641260      return thmfc1->stat0;
12651261
12661262   case 1: /* STAT1 */
r3854r3855
12911287         data |= 0x10;
12921288      if ( flags & FLOPPY_DRIVE_DISK_WRITE_PROTECTED )
12931289         data |= 0x04;
1294      VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
1290      VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
12951291      return data;
12961292   }
12971293
12981294   case 3: /* RDATA */
12991295
13001296      if ( thmfc1->op == THMFC1_OP_READ_SECT || thmfc1->op == THMFC1_OP_READ_ADDR )
1301         return thmfc_floppy_read_byte(space->machine);
1297         return thmfc_floppy_read_byte( space->machine );
13021298      else
1303         return thmfc_floppy_raw_read_byte();
1299         return thmfc_floppy_raw_read_byte( space->machine );
13041300
13051301   case 6:
13061302      return 0;
r3854r3855
13091305   {
13101306      /* undocumented => emulate TO7 QDD controller ? */
13111307      UINT8 data = thmfc1->ipl << 7;
1312      VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
1308      VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
13131309      return data;
13141310   }
13151311
13161312   default:
1317      logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset );
1313      logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset );
13181314      return 0;
13191315   }
13201316}
r3854r3855
13341330      thom_floppy_set_density( dens );
13351331      thmfc1->formatting = (data >> 2) & 1;
13361332      LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n",
1337             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
1333             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
13381334             (dens == DEN_FM_LO) ? "MF" : "MFM",
13391335             wsync, (data >> 3) & 1,
13401336             thmfc1->formatting, data & 3 ));
r3854r3855
14191415      if ( thmfc1->sector_size > 256 )
14201416      {
14211417         logerror( "$%04x thmfc_floppy_w: sector size %i > 256 not handled\n",
1422              cpu_get_previouspc(space->cpu), thmfc1->sector_size );
1418              cpu_get_previouspc( space->machine->cpu[0] ), thmfc1->sector_size );
14231419         thmfc1->sector_size = 256;
14241420      }
14251421
14261422      LOG (( "%f $%04x thmfc_floppy_w: CMD1=$%02X sect-size=%i comp=%i head=%i\n",
1427             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
1423             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
14281424             thmfc1->sector_size, (data >> 1) & 7, thmfc1->side ));
14291425      break;
14301426
r3854r3855
14491445      }
14501446
14511447      img = thmfc_floppy_image();
1452      thom_floppy_active( 0 );
1448      thom_floppy_active( space->machine, 0 );
14531449
14541450      LOG (( "%f $%04x thmfc_floppy_w: CMD2=$%02X drv=%i step=%i motor=%i\n",
1455             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
1451             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
14561452             thmfc1->drive, seek, motor ));
14571453
14581454      if ( seek )
r3854r3855
14731469   case 3: /* WDATA */
14741470      thmfc1->wsync = data;
14751471      if ( thmfc_floppy_is_qdd() )
1476         thmfc_floppy_qdd_write_byte( data );
1472         thmfc_floppy_qdd_write_byte( space->machine, data );
14771473      else if ( thmfc1->op==THMFC1_OP_WRITE_SECT )
14781474         thmfc_floppy_write_byte( space->machine, data );
14791475      else if ( thmfc1->formatting )
1480         thmfc_floppy_format_byte( data );
1476         thmfc_floppy_format_byte( space->machine, data );
14811477      else
14821478      {
14831479         /* TODO: implement other forms of raw track writing */
14841480         LOG (( "%f $%04x thmfc_floppy_w: ignored raw WDATA $%02X\n",
1485                attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
1481                attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
14861482      }
14871483      break;
14881484
r3854r3855
14901486   case 4: /* WCLK (unemulated) */
14911487      /* clock configuration: FF for data, 0A for synchro */
14921488      LOG (( "%f $%04x thmfc_floppy_w: WCLK=$%02X (%s)\n",
1493             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
1489             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
14941490             (data == 0xff) ? "data" : (data == 0x0A) ? "synchro" : "?" ));
14951491      break;
14961492
14971493   case 5: /* WSECT */
14981494      thmfc1->sector = data;
14991495      LOG (( "%f $%04x thmfc_floppy_w: WSECT=%i\n",
1500             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
1496             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
15011497      break;
15021498
15031499   case 6: /* WTRCK */
15041500      thmfc1->track = data;
15051501      LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n",
1506             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data,
1502             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data,
15071503             floppy_drive_get_current_track( thmfc_floppy_image() ) ));
15081504      break;
15091505
15101506   case 7: /* WCELL */
15111507      /* precompensation (unemulated) */
15121508      LOG (( "%f $%04x thmfc_floppy_w: WCELL=$%02X\n",
1513             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ));
1509             attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ));
15141510      break;
15151511
15161512   default:
15171513      logerror ( "%f $%04x thmfc_floppy_w: invalid write offset %i (data=$%02X)\n",
1518            attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data );
1514            attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
15191515   }
15201516}
15211517
r3854r3855
15611557   thmfc1 = auto_malloc( sizeof( *thmfc1 ) );
15621558   assert( thmfc1 );
15631559
1564   thmfc_floppy_cmd = timer_alloc(machine, thmfc_floppy_cmd_complete_cb, NULL );
1560   thmfc_floppy_cmd = timer_alloc( machine, thmfc_floppy_cmd_complete_cb, NULL );
15651561
1566   state_save_register_global(machine,  thmfc1->op );
1567   state_save_register_global(machine,  thmfc1->sector );
1568   state_save_register_global(machine,  thmfc1->track );
1569   state_save_register_global(machine,  thmfc1->side );
1570   state_save_register_global(machine,  thmfc1->drive );
1571   state_save_register_global(machine,  thmfc1->sector_size );
1572   state_save_register_global(machine,  thmfc1->formatting );
1573   state_save_register_global(machine,  thmfc1->ipl );
1574   state_save_register_global(machine,  thmfc1->data_idx );
1575   state_save_register_global(machine,  thmfc1->data_size );
1576   state_save_register_global(machine,  thmfc1->data_finish );
1577   state_save_register_global(machine,  thmfc1->stat0 );
1578   state_save_register_global(machine,  thmfc1->data_raw_idx );
1579   state_save_register_global(machine,  thmfc1->data_raw_size );
1580   state_save_register_global(machine,  thmfc1->data_crc );
1581   state_save_register_global(machine,  thmfc1->wsync );
1582   state_save_register_global_array(machine,  thmfc1->data );
1562   state_save_register_global( machine, thmfc1->op );
1563   state_save_register_global( machine, thmfc1->sector );
1564   state_save_register_global( machine, thmfc1->track );
1565   state_save_register_global( machine, thmfc1->side );
1566   state_save_register_global( machine, thmfc1->drive );
1567   state_save_register_global( machine, thmfc1->sector_size );
1568   state_save_register_global( machine, thmfc1->formatting );
1569   state_save_register_global( machine, thmfc1->ipl );
1570   state_save_register_global( machine, thmfc1->data_idx );
1571   state_save_register_global( machine, thmfc1->data_size );
1572   state_save_register_global( machine, thmfc1->data_finish );
1573   state_save_register_global( machine, thmfc1->stat0 );
1574   state_save_register_global( machine, thmfc1->data_raw_idx );
1575   state_save_register_global( machine, thmfc1->data_raw_size );
1576   state_save_register_global( machine, thmfc1->data_crc );
1577   state_save_register_global( machine, thmfc1->wsync );
1578   state_save_register_global_array( machine, thmfc1->data );
15831579}
15841580
15851581
r3854r3855
16001596static TIMER_CALLBACK( ans4 )
16011597{
16021598   LOG(( "%f ans4\n", attotime_to_double(timer_get_time(machine)) ));
1603   mc6854_set_cts( 0 );
1599   mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 0 );
16041600}
16051601
16061602static TIMER_CALLBACK( ans3 )
16071603{
16081604   LOG(( "%f ans3\n", attotime_to_double(timer_get_time(machine)) ));
1609   mc6854_set_cts( 1 );
1610   timer_set(machine,   ATTOTIME_IN_USEC( 100 ), NULL, 0, ans4 );
1605   mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 1 );
1606   timer_set( machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans4 );
16111607}
16121608
16131609static TIMER_CALLBACK( ans2 )
16141610{
16151611   LOG(( "%f ans2\n", attotime_to_double(timer_get_time(machine)) ));
1616   mc6854_set_cts( 0 );
1617   timer_set(machine,   ATTOTIME_IN_USEC( 100 ), NULL, 0, ans3 );
1612   mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 0 );
1613   timer_set( machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans3 );
16181614}
16191615
16201616static TIMER_CALLBACK( ans )
16211617{
16221618   LOG(( "%f ans\n", attotime_to_double(timer_get_time(machine)) ));
1623   mc6854_set_cts( 1 );
1624   timer_set(machine,   ATTOTIME_IN_USEC( 100 ), NULL, 0, ans2 );
1619   mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 1 );
1620   timer_set( machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans2 );
16251621}
16261622/* consigne DKBOOT
16271623
r3854r3855
16521648
16531649*/
16541650
1655static void to7_network_got_frame( running_machine *machine, UINT8* data, int length )
1651static void to7_network_got_frame( const device_config *device, UINT8* data, int length )
16561652{
16571653   int i;
1658   LOG(( "%f to7_network_got_frame:", attotime_to_double(timer_get_time(machine)) ));
1654   LOG(( "%f to7_network_got_frame:", attotime_to_double(timer_get_time(device->machine)) ));
16591655   for ( i = 0; i < length; i++ )
16601656      LOG(( " $%02X", data[i] ));
16611657   LOG(( "\n" ));
r3854r3855
16631659   if ( data[1] == 0xff )
16641660   {
16651661      LOG(( "to7_network_got_frame: %i phones %i\n", data[2], data[0] ));
1666      timer_set(machine,   ATTOTIME_IN_USEC( 100 ), NULL, 0, ans  );
1667      mc6854_set_cts( 0 );
1662      timer_set( device->machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans  );
1663      mc6854_set_cts( device, 0 );
16681664   }
16691665   else if ( ! data[1] )
16701666   {
r3854r3855
16861682
16871683
16881684
1689static const mc6854_interface network_iface = { NULL, to7_network_got_frame, NULL, NULL };
1685mc6854_interface to7_network_iface = { NULL, to7_network_got_frame, NULL, NULL };
16901686
16911687
16921688
r3854r3855
16941690{
16951691   LOG(( "to7_network_init: NR 07-005 network extension\n" ));
16961692   logerror( "to7_network_init: network not handled!\n" );
1697   mc6854_config( machine, &network_iface  );
16981693}
16991694
17001695
17011696
1702static void to7_network_reset( void )
1697static void to7_network_reset( running_machine *machine )
17031698{
17041699   LOG(( "to7_network_reset: NR 07-005 network extension\n" ));
1705   mc6854_reset();
1706   mc6854_set_cts( 1 );
1700   mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 0 );
1701   mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 1 );
17071702}
17081703
17091704
r3854r3855
17111706static READ8_HANDLER ( to7_network_r )
17121707{
17131708   if ( offset >= 0 && offset < 4 )
1714      return mc6854_r( space, offset );
1709      return mc6854_r( devtag_get_device(space->machine, MC6854, "mc6854"), offset );
17151710
17161711   if ( offset == 8 )
17171712   {
17181713      /* network ID of the computer */
17191714      UINT8 id = input_port_read(space->machine, "fconfig") >> 3;
1720      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), id ));
1715      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), id ));
17211716      return id;
17221717   }
17231718
1724   logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset );
1719   logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset );
17251720   return 0;
17261721}
17271722
r3854r3855
17301725static WRITE8_HANDLER ( to7_network_w )
17311726{
17321727   if ( offset >= 0 && offset < 4 )
1733      mc6854_w( space, offset, data );
1728      mc6854_w( devtag_get_device(space->machine, MC6854, "mc6854"), offset, data );
17341729   else
17351730   {
17361731      logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n",
1737           attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data );
1732           attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data );
17381733   }
17391734}
17401735
r3854r3855
17611756void to7_floppy_init ( running_machine *machine, void* base )
17621757{
17631758   memory_configure_bank( machine, THOM_FLOP_BANK, 0, TO7_NB_FLOP_BANK, base, 0x800 );
1764   state_save_register_global(machine,  to7_controller_type );
1765   state_save_register_global(machine,  to7_floppy_bank );
1759   state_save_register_global( machine, to7_controller_type );
1760   state_save_register_global( machine, to7_floppy_bank );
17661761   to7_5p14sd_init(machine);
17671762   to7_5p14_init(machine);
17681763   to7_qdd_init(machine);
r3854r3855
18011796
18021797   case 5:
18031798      to7_floppy_bank = 8;
1804      to7_network_reset();
1799      to7_network_reset(machine);
18051800      break;
18061801
18071802   default:
src/mess/formats/thom_dsk.c
r3854r3855
210210static void thom_floppy_seek ( const device_config *image, int physical_track )
211211{
212212   thom_floppy_drive* d = thom_floppy_drive_of_image( image );
213   thom_floppy_active( 0 );
213   thom_floppy_active( image->machine, 0 );
214214   if ( physical_track < 0 )
215215      physical_track = 0;
216216   if ( physical_track >= 80 )
r3854r3855
243243          (int)(FPTR)(d - thom_floppy_drives), trk, id_index, physical_side,
244244          (thom_density == DEN_FM_LO) ? "FM" : "MFM",
245245          (d->density == DEN_FM_LO) ? "FM" : "MFM" ));
246   thom_floppy_active( 0 );
246   thom_floppy_active( image->machine, 0 );
247247   if ( thom_floppy_sector_ptr( d, id_index+1, trk, 0 ) &&
248248#if 0
249249        /* fails with bobwinter */
r3854r3855
282282{
283283   thom_floppy_drive* d = thom_floppy_drive_of_image( image );
284284   UINT8* src = thom_floppy_sector_ptr( d, index1, d->cur_track, 0 );
285   thom_floppy_active( 0 );
285   thom_floppy_active( image->machine, 0 );
286286   LOG(( "thom_floppy_read_sector_data_into_buffer: dev=%d track=%i idx=%i side=%i len=%i\n", (int)(FPTR)(d - thom_floppy_drives), d->cur_track, index1, side, length ));
287287   if ( length > d->sector_size )
288288   {
r3854r3855
299299{
300300   thom_floppy_drive* d = thom_floppy_drive_of_image( image );
301301   UINT8* dst = thom_floppy_sector_ptr( d, data_id, d->cur_track, 0 );
302   thom_floppy_active( 1 );
302   thom_floppy_active( image->machine, 1 );
303303   LOG(( "thom_floppy_write_sector_data_into_buffer: dev=%d track=%i idx=%i side=%i ddam=%i len=%i\n", (int)(FPTR)(d - thom_floppy_drives), d->cur_track, data_id, side, ddam, length ));
304304   if ( length > d->sector_size )
305305   {
r3854r3855
320320   thom_floppy_drive* d = thom_floppy_drive_of_image( image );
321321   int sector_size = 128 << n;
322322   UINT8* dst;
323   thom_floppy_active( 1 );
323   thom_floppy_active( image->machine, 1 );
324324   LOG(( "thom_floppy_format_sector: dev=%d track=%i/%i side=%i/%i idx=%i/%i c=%i h=%i r=%i n=%i filler=$%02X\n",
325325         (int)(FPTR)(d - thom_floppy_drives),
326326         d->cur_track, d->tracks, side, d->sides, sector_index, d->sectors,
src/mess/drivers/thomson.c
r3854r3855
7272
7373*/
7474
75#include "driver.h"
7675#include "includes/thomson.h"
77#include "machine/6821pia.h"
78#include "machine/mc6846.h"
79#include "machine/6850acia.h"
80#include "machine/6551.h"
81#include "audio/mea8000.h"
82#include "devices/cartslot.h"
83#include "devices/printer.h"
84#include "devices/cassette.h"
85#include "formats/thom_cas.h"
86#include "devices/thomflop.h"
87#include "formats/thom_dsk.h"
88#include "includes/serial.h"
8976
9077
9178/**************************** common *******************************/
r3854r3855
351338  - AZERTY keyboard, 58-keys, French with accents
352339  - cartridge 16 KB (up to 64 KB using bank-switching),
353340    the MESS cartridge device is named -cart
354  - cassette 900 bauds (frequency signals: 0=4.5kHz, 1=6.3kHz)
341  - cassette 900 bauds (frequency signals: 0=4.5Khz, 1=6.3KHz)
355342    the MESS cassette device is named -cass
356343  - 1-bit internal buzzer
357344  - lightpen, with 8-pixel horizontal resolution, 1-pixel vertical
r3854r3855
421408     AM_RANGE ( 0x8000, 0xbfff ) AM_NOP       /* 16 KB (for extension) */
422409     AM_RANGE ( 0xc000, 0xdfff ) AM_NOP       /*  8 KB (for extension) */
423410     AM_RANGE ( 0xe000, 0xe7bf ) AM_ROMBANK   ( THOM_FLOP_BANK )
424     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_READWRITE ( mc6846_r, mc6846_w )
411     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_DEVREADWRITE(MC6846, "mc6846", mc6846_r, mc6846_w)
425412     AM_RANGE ( 0xe7c8, 0xe7cb ) AM_READWRITE ( pia_0_alt_r,  pia_0_alt_w )
426413     AM_RANGE ( 0xe7cc, 0xe7cf ) AM_READWRITE ( pia_1_alt_r,  pia_1_alt_w )
427414     AM_RANGE ( 0xe7d0, 0xe7df ) AM_READWRITE ( to7_floppy_r, to7_floppy_w )
r3854r3855
713700     CONFIG_IMPORT_FROM ( to7 )
714701SYSTEM_CONFIG_END
715702
716extern const acia6850_interface to7_acia_modem;
717703
718704/* ------------ driver ------------ */
719705
r3854r3855
727713     MDRV_CPU_PROGRAM_MAP ( to7, 0 )
728714
729715/* video */
730/* Finally, I figured it out. The video hardware overclocks the SECAM
731   framerate from 50 Hz to 1/0.019968 Hz to get 312 64us lines per frame,
732   i.e., 19.968 ms per frame, not 20 ms
733*/
734716     MDRV_SCREEN_ADD("main", RASTER)
735717     MDRV_SCREEN_REFRESH_RATE ( /*50*/ 1./0.019968 )
736718     MDRV_INTERLEAVE ( 0 )
r3854r3855
754736     MDRV_SOUND_ADD ( "speech", DAC, 0 )
755737     MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.) /* speech synthesis */
756738
757   /* printer */
758   MDRV_DEVICE_ADD("printer", PRINTER)
739/* printer */
740     MDRV_DEVICE_ADD("printer", PRINTER)
759741
760   /* cassette */
761   MDRV_CASSETTE_ADD( "cassette", to7_cassette_config )
742/* cassette */
743     MDRV_CASSETTE_ADD( "cassette", to7_cassette_config )
762744
763   /* acia */
764   MDRV_DEVICE_ADD("acia", ACIA6551)
765   MDRV_DEVICE_ADD("acia_1", ACIA6850)
766   MDRV_DEVICE_CONFIG(to7_acia_modem)   
745/* timer */
746     MDRV_MC6846_ADD( "mc6846", to7_timer )
747
748/* speech synthesis */
749     MDRV_MEA8000_ADD( "mea8000", to7_speech )
750
751/* floppy */
752     MDRV_MC6843_ADD( "mc6843", to7_6843_itf )
753
754/* network */
755     MDRV_MC6854_ADD( "mc6854", to7_network_iface )
756
757/* acia */
758     MDRV_DEVICE_ADD( "acia", ACIA6551 )
759
760/* modem */
761     MDRV_DEVICE_ADD( "acia6850", ACIA6850 )
762     MDRV_DEVICE_CONFIG( to7_modem )
763
767764MACHINE_DRIVER_END
768765
769766static MACHINE_DRIVER_START ( t9000 )
r3854r3855
832829     AM_RANGE ( 0x6000, 0x9fff ) AM_RAMBANK   ( THOM_BASE_BANK ) /* 16 KB */
833830     AM_RANGE ( 0xa000, 0xdfff ) AM_RAMBANK   ( THOM_RAM_BANK )  /* 6 * 16 KB */
834831     AM_RANGE ( 0xe000, 0xe7bf ) AM_ROMBANK   ( THOM_FLOP_BANK )
835     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_READWRITE ( mc6846_r, mc6846_w )
832     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_DEVREADWRITE(MC6846, "mc6846", mc6846_r, mc6846_w)
836833     AM_RANGE ( 0xe7c8, 0xe7cb ) AM_READWRITE ( pia_0_alt_r,  pia_0_alt_w )
837834     AM_RANGE ( 0xe7cc, 0xe7cf ) AM_READWRITE ( pia_1_alt_r,  pia_1_alt_w )
838835     AM_RANGE ( 0xe7d0, 0xe7df ) AM_READWRITE ( to7_floppy_r, to7_floppy_w )
r3854r3855
950947     MDRV_IMPORT_FROM ( to7 )
951948     MDRV_MACHINE_START ( to770 )
952949     MDRV_MACHINE_RESET ( to770 )
950
953951     MDRV_CPU_MODIFY( "main" )
954952     MDRV_CPU_PROGRAM_MAP ( to770, 0 )
953
954     MDRV_MC6846_MODIFY( "mc6846", to770_timer )
955955MACHINE_DRIVER_END
956956
957957static MACHINE_DRIVER_START ( to770a )
r3854r3855
10001000    . the right SHIFT key has been replaced with a BASIC key
10011001    . no caps-lock led
10021002  - the famous lightpen is optional
1003  - cassette 1200 bauds (frequency signals: 0=4.5kHz, 1=6.3kHz),
1003  - cassette 1200 bauds (frequency signals: 0=4.5Khz, 1=6.3KHz),
10041004    TO7-incompatible
10051005  - optional cartridge, up to 64 KB, incompatible with TO7,
10061006    masks the integrated BASIC ROM
r3854r3855
10361036                  mo5_gatearray_w )
10371037     AM_RANGE ( 0xa7e8, 0xa7eb ) AM_DEVREADWRITE(ACIA6551, "acia",  acia_6551_r, acia_6551_w )
10381038     AM_RANGE ( 0xa7f2, 0xa7f3 ) AM_READWRITE ( to7_midi_r, to7_midi_w )
1039     AM_RANGE ( 0xa7fe, 0xa7ff ) AM_READWRITE ( mea8000_r, mea8000_w )
1039     AM_RANGE ( 0xa7fe, 0xa7ff ) AM_DEVREADWRITE(MEA8000, "mea8000", mea8000_r, mea8000_w)
10401040     AM_RANGE ( 0xb000, 0xefff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), mo5_cartridge_w )
10411041     AM_RANGE ( 0xf000, 0xffff ) AM_ROM       /* system bios */
10421042
r3854r3855
11451145     MDRV_IMPORT_FROM ( to7 )
11461146     MDRV_MACHINE_START ( mo5 )
11471147     MDRV_MACHINE_RESET ( mo5 )
1148
11481149     MDRV_CPU_MODIFY( "main" )
11491150     MDRV_CPU_PROGRAM_MAP ( mo5, 0 )
11501151
1151   MDRV_CASSETTE_MODIFY( "cassette", mo5_cassette_config )
1152     MDRV_CASSETTE_MODIFY( "cassette", mo5_cassette_config )
1153
1154     MDRV_MC6846_REMOVE( "mc6846" )
11521155MACHINE_DRIVER_END
11531156
11541157static MACHINE_DRIVER_START ( mo5e )
r3854r3855
12251228  - IEEE extension ? (unemulated)
12261229  - floppy:
12271230    . integrated floppy controller, based on WD2793
1228    . integrated one-sided double-density 3"1/2
1229    . external two-sided double-density 3"1/2, 5"1/4 or QDD (extension)
1231    . integrated one-sided double-density 3''1/2
1232    . external two-sided double-density 3''1/2, 5''1/4 or QDD (extension)
12301233    . floppies are TO7 and MO5 compatible
12311234  - speech synthesis extension: identical to TO7
12321235  - MIDIPAK MIDI extension: identical to TO7
r3854r3855
12351238
12361239static ADDRESS_MAP_START ( to9, ADDRESS_SPACE_PROGRAM, 8 )
12371240
1238     AM_RANGE ( 0x0000, 0x3fff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), to9_cartridge_w )/* 12 * 16 KB */
1241     AM_RANGE ( 0x0000, 0x3fff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), to9_cartridge_w )/* 4 * 16 KB */
12391242     AM_RANGE ( 0x4000, 0x5fff ) AM_READWRITE ( SMH_BANK(THOM_VRAM_BANK), to770_vram_w )
12401243     AM_RANGE ( 0x6000, 0x9fff ) AM_RAMBANK   ( THOM_BASE_BANK ) /* 16 KB */
12411244     AM_RANGE ( 0xa000, 0xdfff ) AM_RAMBANK   ( THOM_RAM_BANK )  /* 10 * 16 KB */
12421245     AM_RANGE ( 0xe000, 0xe7bf ) AM_ROMBANK   ( THOM_FLOP_BANK )
1243     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_READWRITE ( mc6846_r, mc6846_w )
1246     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_DEVREADWRITE(MC6846, "mc6846", mc6846_r, mc6846_w)
12441247     AM_RANGE ( 0xe7c8, 0xe7cb ) AM_READWRITE ( pia_0_alt_r,  pia_0_alt_w )
12451248     AM_RANGE ( 0xe7cc, 0xe7cf ) AM_READWRITE ( pia_1_alt_r,  pia_1_alt_w )
12461249     AM_RANGE ( 0xe7d0, 0xe7d9 ) AM_READWRITE ( to9_floppy_r, to9_floppy_w )
r3854r3855
14921495     MDRV_IMPORT_FROM ( to7 )
14931496     MDRV_MACHINE_START ( to9 )
14941497     MDRV_MACHINE_RESET ( to9 )
1498
14951499     MDRV_CPU_MODIFY( "main" )
14961500     MDRV_CPU_PROGRAM_MAP ( to9, 0 )
1501
1502     MDRV_MC6846_MODIFY( "mc6846", to9_timer )
14971503MACHINE_DRIVER_END
14981504
14991505
r3854r3855
15651571
15661572static ADDRESS_MAP_START ( to8, ADDRESS_SPACE_PROGRAM, 8 )
15671573
1568     AM_RANGE ( 0x0000, 0x3fff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), to8_cartridge_w ) /* 8 * 16 KB */
1574     AM_RANGE ( 0x0000, 0x3fff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), to8_cartridge_w ) /* 4 * 16 KB */
15691575     AM_RANGE ( 0x4000, 0x5fff ) AM_READWRITE ( SMH_BANK(THOM_VRAM_BANK), to770_vram_w )
15701576     AM_RANGE ( 0x6000, 0x7fff ) AM_READWRITE ( SMH_BANK(TO8_SYS_LO), to8_sys_lo_w )
15711577     AM_RANGE ( 0x8000, 0x9fff ) AM_READWRITE ( SMH_BANK(TO8_SYS_HI), to8_sys_hi_w )
15721578     AM_RANGE ( 0xa000, 0xbfff ) AM_READWRITE ( SMH_BANK(TO8_DATA_LO), to8_data_lo_w )
15731579     AM_RANGE ( 0xc000, 0xdfff ) AM_READWRITE ( SMH_BANK(TO8_DATA_HI), to8_data_hi_w )
15741580     AM_RANGE ( 0xe000, 0xe7bf ) AM_ROMBANK   ( THOM_FLOP_BANK ) /* 2 * 2 KB */
1575     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_READWRITE ( mc6846_r, mc6846_w )
1581     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_DEVREADWRITE(MC6846, "mc6846", mc6846_r, mc6846_w)
15761582     AM_RANGE ( 0xe7c8, 0xe7cb ) AM_READWRITE ( pia_0_alt_r,  pia_0_alt_w )
15771583     AM_RANGE ( 0xe7cc, 0xe7cf ) AM_READWRITE ( pia_1_alt_r,  pia_1_alt_w )
15781584     AM_RANGE ( 0xe7d0, 0xe7d9 ) AM_READWRITE ( to8_floppy_r, to8_floppy_w )
r3854r3855
17231729     MDRV_IMPORT_FROM ( to7 )
17241730     MDRV_MACHINE_START ( to8 )
17251731     MDRV_MACHINE_RESET ( to8 )
1732
17261733     MDRV_CPU_MODIFY( "main" )
17271734     MDRV_CPU_PROGRAM_MAP ( to8, 0 )
1735
1736     MDRV_MC6846_MODIFY( "mc6846", to8_timer )
17281737MACHINE_DRIVER_END
17291738
17301739static MACHINE_DRIVER_START ( to8d )
r3854r3855
17681777  - RF 57-932: RS232 (identical to the TO7) sometimes integrated
17691778  - MD 90-120: MODEM (identical to the TO7?) sometimes integrated
17701779  - IEEE extension ?
1771  - floppy: one two-sided double-density 3"1/2 floppy drive is integrated
1780  - floppy: one two-sided double-density 3''1/2 floppy drive is integrated
17721781  - RS 52-932 RS232 extension ?
17731782  - digitisation extension
17741783
r3854r3855
17761785
17771786static ADDRESS_MAP_START ( to9p, ADDRESS_SPACE_PROGRAM, 8 )
17781787
1779     AM_RANGE ( 0x0000, 0x3fff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), to8_cartridge_w ) /* 8 * 16 KB */
1788     AM_RANGE ( 0x0000, 0x3fff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), to8_cartridge_w ) /* 4 * 16 KB */
17801789     AM_RANGE ( 0x4000, 0x5fff ) AM_READWRITE ( SMH_BANK(THOM_VRAM_BANK), to770_vram_w )
17811790     AM_RANGE ( 0x6000, 0x7fff ) AM_READWRITE ( SMH_BANK(TO8_SYS_LO), to8_sys_lo_w )
17821791     AM_RANGE ( 0x8000, 0x9fff ) AM_READWRITE ( SMH_BANK(TO8_SYS_HI), to8_sys_hi_w )
17831792     AM_RANGE ( 0xa000, 0xbfff ) AM_READWRITE ( SMH_BANK(TO8_DATA_LO), to8_data_lo_w )
17841793     AM_RANGE ( 0xc000, 0xdfff ) AM_READWRITE ( SMH_BANK(TO8_DATA_HI), to8_data_hi_w )
17851794     AM_RANGE ( 0xe000, 0xe7bf ) AM_ROMBANK   ( THOM_FLOP_BANK ) /* 2 * 2 KB */
1786     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_READWRITE ( mc6846_r, mc6846_w )
1795     AM_RANGE ( 0xe7c0, 0xe7c7 ) AM_DEVREADWRITE(MC6846, "mc6846", mc6846_r, mc6846_w)
17871796     AM_RANGE ( 0xe7c8, 0xe7cb ) AM_READWRITE ( pia_0_alt_r,  pia_0_alt_w )
17881797     AM_RANGE ( 0xe7cc, 0xe7cf ) AM_READWRITE ( pia_1_alt_r,  pia_1_alt_w )
17891798     AM_RANGE ( 0xe7d0, 0xe7d9 ) AM_READWRITE ( to8_floppy_r, to8_floppy_w )
r3854r3855
18751884     MDRV_IMPORT_FROM ( to7 )
18761885     MDRV_MACHINE_START ( to9p )
18771886     MDRV_MACHINE_RESET ( to9p )
1887
18781888     MDRV_CPU_MODIFY( "main" )
18791889     MDRV_CPU_PROGRAM_MAP ( to9p, 0 )
1890
1891     MDRV_MC6846_MODIFY( "mc6846", to9p_timer )
18801892MACHINE_DRIVER_END
18811893
18821894COMP ( 1986, to9p, 0, 0, to9p, to9p, 0, to9p, "Thomson", "TO9+", 0 )
r3854r3855
19591971     AM_RANGE ( 0xa7e8, 0xa7eb ) AM_DEVREADWRITE(ACIA6551, "acia",  acia_6551_r, acia_6551_w )
19601972/*   AM_RANGE ( 0xa7f0, 0xa7f7 ) AM_READWRITE ( to9_ieee_r, to9_ieee_w )*/
19611973     AM_RANGE ( 0xa7f2, 0xa7f3 ) AM_READWRITE ( to7_midi_r, to7_midi_w )
1962     AM_RANGE ( 0xa7fe, 0xa7ff ) AM_READWRITE ( mea8000_r, mea8000_w )
1974     AM_RANGE ( 0xa7fe, 0xa7ff ) AM_DEVREADWRITE(MEA8000, "mea8000", mea8000_r, mea8000_w)
19631975     AM_RANGE ( 0xb000, 0xefff ) AM_ROMBANK   ( THOM_CART_BANK )
19641976                                 AM_WRITE     ( mo6_cartridge_w )
19651977     AM_RANGE ( 0xf000, 0xffff ) AM_ROMBANK   ( TO8_BIOS_BANK )
r3854r3855
22182230     MDRV_IMPORT_FROM ( to7 )
22192231     MDRV_MACHINE_START ( mo6 )
22202232     MDRV_MACHINE_RESET ( mo6 )
2233
22212234     MDRV_CPU_MODIFY( "main" )
22222235     MDRV_CPU_PROGRAM_MAP ( mo6, 0 )
2236
2237     MDRV_MC6846_REMOVE( "mc6846" )
22232238MACHINE_DRIVER_END
22242239
22252240static MACHINE_DRIVER_START ( pro128 )
r3854r3855
22812296/*   AM_RANGE ( 0xa7f0, 0xa7f7 ) AM_READWRITE ( to9_ieee_r, to9_ieee_w ) */
22822297     AM_RANGE ( 0xa7f2, 0xa7f3 ) AM_READWRITE ( to7_midi_r, to7_midi_w )
22832298     AM_RANGE ( 0xa7f8, 0xa7fb ) AM_READWRITE ( pia_3_alt_r, pia_3_alt_w )
2284     AM_RANGE ( 0xa7fe, 0xa7ff ) AM_READWRITE ( mea8000_r, mea8000_w )
2285     AM_RANGE ( 0xb000, 0xefff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), mo6_cartridge_w ) /* 8 * 16 KB */
2299     AM_RANGE ( 0xa7fe, 0xa7ff ) AM_DEVREADWRITE(MEA8000, "mea8000", mea8000_r, mea8000_w)
2300     AM_RANGE ( 0xb000, 0xefff ) AM_READWRITE ( SMH_BANK(THOM_CART_BANK), mo6_cartridge_w ) /* 4 * 16 KB */
22862301     AM_RANGE ( 0xf000, 0xffff ) AM_ROMBANK   ( TO8_BIOS_BANK )
22872302
22882303/* 0x10000 - 0x1ffff: 64 KB external ROM cartridge */
r3854r3855
24412456     MDRV_IMPORT_FROM ( to7 )
24422457     MDRV_MACHINE_START ( mo5nr )
24432458     MDRV_MACHINE_RESET ( mo5nr )
2459
24442460     MDRV_CPU_MODIFY( "main" )
24452461     MDRV_CPU_PROGRAM_MAP ( mo5nr, 0 )
2462
2463     MDRV_MC6846_REMOVE( "mc6846" )
24462464MACHINE_DRIVER_END
24472465
24482466COMP ( 1986, mo5nr, 0, 0, mo5nr, mo5nr, 0, mo5nr, "Thomson", "MO5 NR", 0 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team