Previous 15994 Revisions Next

r3838 Tuesday 16th December, 2008 at 11:07:05 UTC by Curt Coder
All callbacks from a device must include the device object as the first parameter.
[src/mess/drivers]tm990189.c
[src/mess/machine]geneve.c ti99_4x.c tms9901.c tms9901.h

src/mess/machine/tms9901.c
r3837r3838
324324         answer = ((~ tms->int_state) & tms->supported_int_mask) & 0xFF;
325325
326326         if (tms->intf->read_handlers[0])
327            answer |= (* tms->intf->read_handlers[0])(space, 0);
327            answer |= (* tms->intf->read_handlers[0])(device, 0);
328328
329329         answer &= ~ tms->pio_direction_mirror;
330330         answer |= (tms->pio_output_mirror & tms->pio_direction_mirror) & 0xFF;
r3837r3838
342342         answer = ((~ tms->int_state) & tms->supported_int_mask) >> 8;
343343
344344         if (tms->intf->read_handlers[1])
345            answer |= (* tms->intf->read_handlers[1])(space, 1);
345            answer |= (* tms->intf->read_handlers[1])(device, 1);
346346
347347         answer &= ~ (tms->pio_direction_mirror >> 8);
348348         answer |= (tms->pio_output_mirror & tms->pio_direction_mirror) >> 8;
r3837r3838
352352      /* exit timer mode */
353353      tms->mode9901 = 0;
354354
355      answer = (tms->intf->read_handlers[2]) ? (* tms->intf->read_handlers[2])(space, 2) : 0;
355      answer = (tms->intf->read_handlers[2]) ? (* tms->intf->read_handlers[2])(device, 2) : 0;
356356
357357      answer &= ~ tms->pio_direction;
358358      answer |= (tms->pio_output & tms->pio_direction) & 0xFF;
r3837r3838
362362      /* exit timer mode */
363363      tms->mode9901 = 0;
364364
365      answer = (tms->intf->read_handlers[3]) ? (* tms->intf->read_handlers[3])(space, 3) : 0;
365      answer = (tms->intf->read_handlers[3]) ? (* tms->intf->read_handlers[3])(device, 3) : 0;
366366
367367      answer &= ~ (tms->pio_direction >> 8);
368368      answer |= (tms->pio_output & tms->pio_direction) >> 8;
r3837r3838
530530         }
531531
532532         if (tms->intf->write_handlers[pin] != NULL)
533            (* tms->intf->write_handlers[pin])(space, pin, data);
533            (* tms->intf->write_handlers[pin])(device, pin, data);
534534      }
535535
536536      break;
src/mess/machine/tms9901.h
r3837r3838
4040struct _tms9901_interface
4141{
4242   int supported_int_mask;   /* a bit for each input pin whose state is always notified to the TMS9901 core */
43   read8_space_func  read_handlers[4];     /* 4*8 bits */
44   write8_space_func write_handlers[16]; /* 16 Pn outputs */
43   read8_device_func  read_handlers[4];     /* 4*8 bits */
44   write8_device_func write_handlers[16]; /* 16 Pn outputs */
4545   tms9901_int_callback_func interrupt_callback; /* called when interrupt bus state changes */
4646   double clock_rate;
4747};
src/mess/machine/geneve.c
r3837r3838
13011301    (bit 2: INT2 status)
13021302    bit 3-7: joystick status
13031303*/
1304static READ8_HANDLER( R9901_0 )
1304static READ8_DEVICE_HANDLER( R9901_0 )
13051305{
13061306   int answer;
13071307
1308   answer = input_port_read(space->machine, "JOY") >> (JoySel * 8);
1308   answer = input_port_read(device->machine, "JOY") >> (JoySel * 8);
13091309
13101310   return (answer);
13111311}
r3837r3838
13221322    bit 5 & 7: used as output
13231323    bit 6: unused
13241324*/
1325static READ8_HANDLER( R9901_1 )
1325static READ8_DEVICE_HANDLER( R9901_1 )
13261326{
13271327   int answer;
13281328
1329   answer = (input_port_read(space->machine, "MOUSE0") & 4) ^ 4;
1329   answer = (input_port_read(device->machine, "MOUSE0") & 4) ^ 4;
13301330
13311331   return answer;
13321332}
r3837r3838
13341334/*
13351335   Read pins P0-P7 of Geneve 9901.
13361336*/
1337static READ8_HANDLER( R9901_2 )
1337static READ8_DEVICE_HANDLER( R9901_2 )
13381338{
13391339   return 0;
13401340}
r3837r3838
13431343   Read pins P8-P15 of Geneve 9901.
13441344   bit 4: mouse right button
13451345*/
1346static READ8_HANDLER( R9901_3 )
1346static READ8_DEVICE_HANDLER( R9901_3 )
13471347{
13481348   int answer = 0;
13491349
1350   if (! (input_port_read(space->machine, "MOUSE0") & 4))
1350   if (! (input_port_read(device->machine, "MOUSE0") & 4))
13511351      answer |= 0x10;
13521352
13531353   return answer;
r3837r3838
13571357/*
13581358   Write PE bus reset line
13591359*/
1360static WRITE8_HANDLER( W9901_PE_bus_reset )
1360static WRITE8_DEVICE_HANDLER( W9901_PE_bus_reset )
13611361{
13621362}
13631363
13641364/*
13651365   Write VDP reset line
13661366*/
1367static WRITE8_HANDLER( W9901_VDP_reset )
1367static WRITE8_DEVICE_HANDLER( W9901_VDP_reset )
13681368{
13691369}
13701370
13711371/*
13721372   Write joystick select line
13731373*/
1374static WRITE8_HANDLER( W9901_JoySel )
1374static WRITE8_DEVICE_HANDLER( W9901_JoySel )
13751375{
13761376   JoySel = data;
13771377}
13781378
1379static WRITE8_HANDLER( W9901_KeyboardReset )
1379static WRITE8_DEVICE_HANDLER( W9901_KeyboardReset )
13801380{
13811381   KeyReset = ! data;
13821382   if (KeyReset)
r3837r3838
13991399/*
14001400   Write external mem cycles (0=long, 1=short)
14011401*/
1402static WRITE8_HANDLER( W9901_ext_mem_wait_states )
1402static WRITE8_DEVICE_HANDLER( W9901_ext_mem_wait_states )
14031403{
14041404}
14051405
14061406/*
14071407   Write vdp wait cycles (1=add 15 cycles, 0=add none)
14081408*/
1409static WRITE8_HANDLER( W9901_VDP_wait_states )
1409static WRITE8_DEVICE_HANDLER( W9901_VDP_wait_states )
14101410{
14111411}
14121412
src/mess/machine/ti99_4x.c
r3837r3838
17091709
17101710   Handler for tms9901 P0 pin (handset data acknowledge)
17111711*/
1712WRITE8_HANDLER( ti99_handset_set_ack )
1712WRITE8_DEVICE_HANDLER( ti99_handset_set_ack )
17131713{
17141714   if (has_handset && handset_buflen && (data != handset_ack))
17151715   {
17161716      handset_ack = data;
17171717      if (data == handset_clock)
17181718         /* I don't know what the real delay is, but 30us apears to be enough */
1719         timer_set(space->machine, ATTOTIME_IN_USEC(30), NULL, 0, ti99_handset_ack_callback);
1719         timer_set(device->machine, ATTOTIME_IN_USEC(30), NULL, 0, ti99_handset_ack_callback);
17201720   }
17211721}
17221722
r3837r3838
21542154    (bit 2: INT2 status)
21552155    bit 3-7: keyboard status bits 0 to 4
21562156*/
2157static READ8_HANDLER( ti99_R9901_0 )
2157static READ8_DEVICE_HANDLER( ti99_R9901_0 )
21582158{
21592159   int answer;
21602160   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" };
r3837r3838
21632163      answer = (ti99_handset_poll_bus() << 3) | 0x80;
21642164   else if (has_mecmouse && (KeyCol == ((ti99_model == model_99_4) ? 6 : 7)))
21652165   {
2166      int buttons = input_port_read(space->machine, "MOUSE0") & 3;
2166      int buttons = input_port_read(device->machine, "MOUSE0") & 3;
21672167
21682168      answer = (mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 4;
21692169
r3837r3838
21762176   }
21772177   else
21782178   {
2179      answer = ((input_port_read(space->machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) << 3) & 0xF8;
2179      answer = ((input_port_read(device->machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) << 3) & 0xF8;
21802180   }
21812181   
21822182   if ((ti99_model == model_99_4a) || (ti99_model == model_99_4p))
21832183   {
21842184      if (! AlphaLockLine)
2185         answer &= ~ (input_port_read(space->machine, "ALPHA") << 3);
2185         answer &= ~ (input_port_read(device->machine, "ALPHA") << 3);
21862186   }
21872187
21882188   return answer;
r3837r3838
21972197    (bit 4: IR remote handset interrupt)
21982198    bit 5-7: weird, not emulated
21992199*/
2200static READ8_HANDLER( ti99_R9901_1 )
2200static READ8_DEVICE_HANDLER( ti99_R9901_1 )
22012201{
22022202   int answer;
22032203   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" };
r3837r3838
22062206      answer = 0x07;
22072207   else
22082208   {
2209      answer = ((input_port_read(space->machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) >> 5) & 0x07;
2209      answer = ((input_port_read(device->machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) >> 5) & 0x07;
22102210   }
22112211   
22122212   /* we don't take CS2 into account, as CS2 is a write-only unit */
2213   /*if (cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette1" )) > 0)
2213   /*if (cassette_input(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette1" )) > 0)
22142214      answer |= 8;*/
22152215
22162216   return answer;
r3837r3838
22212221
22222222    bit 1: handset data clock pin
22232223*/
2224static READ8_HANDLER( ti99_R9901_2 )
2224static READ8_DEVICE_HANDLER( ti99_R9901_2 )
22252225{
22262226   return (has_handset && handset_clock) ? 2 : 0;
22272227}
r3837r3838
22322232    bit 26: IR handset interrupt
22332233    bit 27: tape input
22342234*/
2235static READ8_HANDLER( ti99_R9901_3 )
2235static READ8_DEVICE_HANDLER( ti99_R9901_3 )
22362236{
22372237   int answer;
22382238
r3837r3838
22442244   /* we don't take CS2 into account, as CS2 is a write-only unit */
22452245   if ( ti99_model != model_99_8 )
22462246   {
2247      if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette1" )) > 0)
2247      if (cassette_input(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette1" )) > 0)
22482248         answer |= 8;
22492249   }
22502250   else
22512251   {
2252      if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) > 0)
2252      if (cassette_input(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette" )) > 0)
22532253         answer |= 8;
22542254   }
22552255
r3837r3838
22602260/*
22612261   WRITE key column select (P2-P4)
22622262*/
2263static WRITE8_HANDLER( ti99_KeyC )
2263static WRITE8_DEVICE_HANDLER( ti99_KeyC )
22642264{
22652265   if (data)
22662266      KeyCol |= 1 << (offset-2);
r3837r3838
22752275/*
22762276   WRITE alpha lock line - TI99/4a only (P5)
22772277*/
2278static WRITE8_HANDLER( ti99_AlphaW )
2278static WRITE8_DEVICE_HANDLER( ti99_AlphaW )
22792279{
22802280   if ((ti99_model == model_99_4a) || (ti99_model == model_99_4p))
22812281      AlphaLockLine = data;
r3837r3838
22912291    bit 5: ???
22922292    bit 6-7: keyboard status bits 0 through 1
22932293*/
2294static READ8_HANDLER( ti99_8_R9901_0 )
2294static READ8_DEVICE_HANDLER( ti99_8_R9901_0 )
22952295{
22962296   int answer;
22972297   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
r3837r3838
22992299
23002300   if (has_mecmouse && (KeyCol == 15))
23012301   {
2302      int buttons = input_port_read(space->machine, "MOUSE0") & 3;
2302      int buttons = input_port_read(device->machine, "MOUSE0") & 3;
23032303
23042304      answer = ((mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 7) & 0x80;
23052305
r3837r3838
23092309   }
23102310   else
23112311   {
2312      answer = (input_port_read(space->machine, keynames[KeyCol]) << 6) & 0xC0;
2312      answer = (input_port_read(device->machine, keynames[KeyCol]) << 6) & 0xC0;
23132313   }
23142314   
23152315   return answer;
r3837r3838
23242324    (bit 4: IR remote handset interrupt)
23252325    bit 5-7: weird, not emulated
23262326*/
2327static READ8_HANDLER( ti99_8_R9901_1 )
2327static READ8_DEVICE_HANDLER( ti99_8_R9901_1 )
23282328{
23292329   int answer;
23302330   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
r3837r3838
23322332
23332333   if (has_mecmouse && (KeyCol == 15))
23342334   {
2335      int buttons = input_port_read(space->machine, "MOUSE0") & 3;
2335      int buttons = input_port_read(device->machine, "MOUSE0") & 3;
23362336
23372337      answer = ((mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 1) & 0x03;
23382338
r3837r3838
23422342   }
23432343   else
23442344   {
2345      answer = (input_port_read(space->machine, keynames[KeyCol]) >> 2) & 0x07;
2345      answer = (input_port_read(device->machine, keynames[KeyCol]) >> 2) & 0x07;
23462346   }
23472347   
23482348   /* we don't take CS2 into account, as CS2 is a write-only unit */
r3837r3838
23552355/*
23562356   WRITE key column select (P0-P3)
23572357*/
2358static WRITE8_HANDLER( ti99_8_KeyC )
2358static WRITE8_DEVICE_HANDLER( ti99_8_KeyC )
23592359{
23602360   if (data)
23612361      KeyCol |= 1 << offset;
r3837r3838
23662366      mecmouse_select(KeyCol, 14, 15);
23672367}
23682368
2369static WRITE8_HANDLER( ti99_8_WCRUS )
2369static WRITE8_DEVICE_HANDLER( ti99_8_WCRUS )
23702370{
23712371   ti99_8_CRUS = data;
23722372}
23732373
2374static WRITE8_HANDLER( ti99_8_PTGEN )
2374static WRITE8_DEVICE_HANDLER( ti99_8_PTGEN )
23752375{
23762376   /* ... */
23772377}
r3837r3838
23792379/*
23802380   command CS1/CS2 tape unit motor (P6-P7)
23812381*/
2382static WRITE8_HANDLER( ti99_CS_motor )
2382static WRITE8_DEVICE_HANDLER( ti99_CS_motor )
23832383{
23842384   const device_config *img;
23852385
23862386   if ( ti99_model != model_99_8 )
23872387   {
2388      img = device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, ( offset-6 ) ? "cassette2" :  "cassette1" );
2388      img = device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, ( offset-6 ) ? "cassette2" :  "cassette1" );
23892389   }
23902390   else
23912391   {
2392      img = device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" );
2392      img = device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette" );
23932393   }
23942394   cassette_change_state(img, data ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
23952395}
r3837r3838
24032403   We do not really need to emulate this as the tape recorder generates sound
24042404   on its own.
24052405*/
2406static WRITE8_HANDLER( ti99_audio_gate )
2406static WRITE8_DEVICE_HANDLER( ti99_audio_gate )
24072407{
24082408}
24092409
r3837r3838
24112411   tape output (P9)
24122412   I think polarity is correct, but don't take my word for it.
24132413*/
2414static WRITE8_HANDLER( ti99_CS_output )
2414static WRITE8_DEVICE_HANDLER( ti99_CS_output )
24152415{
24162416   if (ti99_model != model_99_8)   /* 99/8 only has one tape port!!! */
24172417   {
2418      cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette1" ), data ? +1 : -1);
2419      cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette2" ), data ? +1 : -1);
2418      cassette_output(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette1" ), data ? +1 : -1);
2419      cassette_output(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette2" ), data ? +1 : -1);
24202420   }
24212421   else
24222422   {
2423      cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ), data ? +1 : -1);
2423      cassette_output(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette" ), data ? +1 : -1);
24242424   }
24252425}
24262426
src/mess/drivers/tm990189.c
r3837r3838
271271      field_interrupts(device->machine);
272272}
273273
274static WRITE8_HANDLER( usr9901_led_w )
274static WRITE8_DEVICE_HANDLER( usr9901_led_w )
275275{
276276   if (data)
277277      LED_state |= (1 << offset);
r3837r3838
286286   tms9901_set_single_int(device_list_find_by_tag(device->machine->config->devicelist, TMS9901, "tms9901_0"), 5, intreq);
287287}
288288
289static READ8_HANDLER( sys9901_r0 )
289static READ8_DEVICE_HANDLER( sys9901_r0 )
290290{
291291   int reply = 0x00;
292292   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", "LINE8" };
293293
294294   /* keyboard read */
295295   if (digitsel < 9)
296      reply |= input_port_read(space->machine, keynames[digitsel]) << 1;
296      reply |= input_port_read(device->machine, keynames[digitsel]) << 1;
297297
298298   /* tape input */
299   if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) > 0.0)
299   if (cassette_input(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette" )) > 0.0)
300300      reply |= 0x40;
301301
302302   return reply;
303303}
304304
305static WRITE8_HANDLER( sys9901_digitsel_w )
305static WRITE8_DEVICE_HANDLER( sys9901_digitsel_w )
306306{
307307   if (data)
308308      digitsel |= 1 << offset;
r3837r3838
310310      digitsel &= ~ (1 << offset);
311311}
312312
313static WRITE8_HANDLER( sys9901_segment_w )
313static WRITE8_DEVICE_HANDLER( sys9901_segment_w )
314314{
315315   if (data)
316316      segment |= 1 << (offset-4);
r3837r3838
322322   }
323323}
324324
325static WRITE8_HANDLER( sys9901_dsplytrgr_w )
325static WRITE8_DEVICE_HANDLER( sys9901_dsplytrgr_w )
326326{
327327   if ((!data) && (digitsel < 10))
328328   {
r3837r3838
331331   }
332332}
333333
334static WRITE8_HANDLER( sys9901_shiftlight_w )
334static WRITE8_DEVICE_HANDLER( sys9901_shiftlight_w )
335335{
336336   if (data)
337337      LED_state |= 0x10;
r3837r3838
339339      LED_state &= ~0x10;
340340}
341341
342static WRITE8_HANDLER( sys9901_spkrdrive_w )
342static WRITE8_DEVICE_HANDLER( sys9901_spkrdrive_w )
343343{
344344   speaker_level_w(0, data);
345345}
346346
347static WRITE8_HANDLER( sys9901_tapewdata_w )
347static WRITE8_DEVICE_HANDLER( sys9901_tapewdata_w )
348348{
349   cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ), data ? +1.0 : -1.0);
349   cassette_output(device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, "cassette" ), data ? +1.0 : -1.0);
350350}
351351
352352/*

Previous 15994 Revisions Next


© 1998-2018 The MESS Team