Previous 15994 Revisions Next

r8223 Saturday 5th June, 2010 at 05:33:37 UTC by Fabio Priuli
[X07] Added printer text support [Sandro Ronco]
[src/mess/drivers]x07.c
[src/mess/includes]x07.h

src/mess/includes/x07.h
r8222r8223
2323   ""
2424};
2525
26static const UINT8 printer_charcode[256] = {
27   0xff, 0x7f, 0xbf, 0x3f, 0xdf, 0x5f, 0x9f, 0x1f,
28   0xef, 0x6f, 0xaf, 0x2f, 0xcf, 0x4f, 0x8f, 0x0f,
29   0xf7, 0x77, 0xb7, 0x37, 0xd7, 0x57, 0x97, 0x17,
30   0xe7, 0x67, 0xa7, 0x27, 0xc7, 0x47, 0x87, 0x07,
31   0xfb, 0x7b, 0xbb, 0x3b, 0xdb, 0x5b, 0x9b, 0x1b,
32   0xeb, 0x6b, 0xab, 0x2b, 0xcb, 0x4b, 0x8b, 0x0b,
33   0xf3, 0x73, 0xb3, 0x33, 0xd3, 0x53, 0x93, 0x13,
34   0xe3, 0x63, 0xa3, 0x23, 0xc3, 0x43, 0x83, 0x03,
35   0xfd, 0x7d, 0xbd, 0x3d, 0xdd, 0x5d, 0x9d, 0x1d,
36   0xed, 0x6d, 0xad, 0x2d, 0xcd, 0x4d, 0x8d, 0x0d,
37   0xf5, 0x75, 0xb5, 0x35, 0xd5, 0x55, 0x95, 0x15,
38   0xe5, 0x65, 0xa5, 0x25, 0xc5, 0x45, 0x85, 0x05,
39   0xf9, 0x79, 0xb9, 0x39, 0xd9, 0x59, 0x99, 0x19,
40   0xe9, 0x69, 0xa9, 0x29, 0xc9, 0x49, 0x89, 0x09,
41   0xf1, 0x71, 0xb1, 0x31, 0xd1, 0x51, 0x91, 0x11,
42   0xe1, 0x61, 0xa1, 0x21, 0xc1, 0x41, 0x81, 0x01,
43   0xfe, 0x7e, 0xbe, 0x3e, 0xde, 0x5e, 0x9e, 0x1e,
44   0xee, 0x6e, 0xae, 0x2e, 0xce, 0x4e, 0x8e, 0x0e,
45   0xf6, 0x76, 0xb6, 0x36, 0xd6, 0x56, 0x96, 0x16,
46   0xe6, 0x66, 0xa6, 0x26, 0xc6, 0x46, 0x86, 0x06,
47   0xfa, 0x7a, 0xba, 0x3a, 0xda, 0x5a, 0x9a, 0x1a,
48   0xea, 0x6a, 0xaa, 0x2a, 0xca, 0x4a, 0x8a, 0x0a,
49   0xf2, 0x72, 0xb2, 0x32, 0xd2, 0x52, 0x92, 0x12,
50   0xe2, 0x62, 0xa2, 0x22, 0xc2, 0x42, 0x82, 0x02,
51   0xfc, 0x7c, 0xbc, 0x3c, 0xdc, 0x5c, 0x9c, 0x1c,
52   0xec, 0x6c, 0xac, 0x2c, 0xcc, 0x4c, 0x8c, 0x0c,
53   0xf4, 0x74, 0xb4, 0x34, 0xd4, 0x54, 0x94, 0x14,
54   0xe4, 0x64, 0xa4, 0x24, 0xc4, 0x44, 0x84, 0x04,
55   0xf8, 0x78, 0xb8, 0x38, 0xd8, 0x58, 0x98, 0x18,
56   0xe8, 0x68, 0xa8, 0x28, 0xc8, 0x48, 0x88, 0x08,
57   0xf0, 0x70, 0xb0, 0x30, 0xd0, 0x50, 0x90, 0x10,
58   0xe0, 0x60, 0xa0, 0x20, 0xc0, 0x40, 0x80, 0x00
59};
60
2661static const UINT16 udk_ptr[12] = {
2762   0x0000, 0x002a, 0x0054, 0x007e, 0x00a8, 0x00d2,
2863   0x0100, 0x012a, 0x0154, 0x017e, 0x01a8, 0x01d2
src/mess/drivers/x07.c
r8222r8223
2828#include "cpu/z80/z80.h"
2929#include "sound/beep.h"
3030#include "includes/x07.h"
31#include "devices/printer.h"
3132
3233static void t6834_cmd (running_machine *machine, UINT8 cmd);
3334static void receive_from_t6834 (running_machine *machine);
r8222r8223
9495   UINT8 kb_data[20];
9596   UINT8 kb_size;
9697   emu_timer *kb_clear;
98
99   /* Printer */
100   running_device *printer;
101   UINT8 send_bit;
102   UINT8 char_code;
103   UINT8 printer_buffer[0xff];
104   UINT8 printer_size;
97105};
98106
99107
r8222r8223
583591   }
584592}
585593
586
587static void send_to_printer (running_machine *machine)
594/****************************************************
595   this function emulate the color printer X-710
596   only the text functions are emulated
597****************************************************/
598static void send_to_printer(running_machine *machine)
588599{
589600   t6834_state *state = (t6834_state *)machine->driver_data;
590   static UINT8 send_bit = 0;
591   static UINT8 char_code = 0;
601   UINT16 char_pos = 0;
602   UINT16 text_color = 0;
603   UINT16 text_size = 1;
592604
593605   if (state->regs_r[4] & 0x20)
594      char_code |= 1;
606      state->char_code |= 1;
595607
596   send_bit++;
608   state->send_bit++;
597609
598   if (send_bit == 8)
610   if (state->send_bit == 8)
599611   {
600      if (char_code)
601         popmessage("Print 0x%02x\n", char_code);
602      send_bit = 0;
603      char_code = 0;
612      if (state->char_code)
613      {
614         //printf("Print char %x (%c)\n", state->char_code,printer_charcode[state->char_code]);
615         state->printer_buffer[state->printer_size++] = state->char_code;
616
617         if (state->printer_buffer[state->printer_size - 2] == 0x4f && state->printer_buffer[state->printer_size - 1] == 0xaf)
618         {
619            if (state->printer_buffer[0] == 0xff && state->printer_buffer[1] == 0xb7)
620            {
621               for (int i = 2; i < state->printer_size - 2; i++)
622               {
623                  if (state->printer_buffer[i - 1] == 0x4f && state->printer_buffer[i] == 0x3d)
624                     text_color = printer_charcode[state->printer_buffer[i + 1]] - 0x30;
625
626                  if (state->printer_buffer[i - 1] == 0x4f && state->printer_buffer[i] == 0x35)
627                  {
628                     if (state->printer_buffer[i + 2] == 0x4f)
629                        text_size = printer_charcode[state->printer_buffer[i + 1]] - 0x2f;
630                     else
631                        text_size = 0x0a + (printer_charcode[state->printer_buffer[i + 2]] - 0x2f);
632                  }
633
634                  if (state->printer_buffer[i - 1] == 0x4f && state->printer_buffer[i] == 0x77)
635                  {
636                     char_pos = i + 1 ;
637                     break;
638                  }
639               }
640            }
641
642            //send the chars to the printer, color and size are not used
643            for (int i = char_pos ;i < state->printer_size ; i++)
644               printer_output(state->printer, printer_charcode[state->printer_buffer[i]]);
645
646            //clears the print buffer
647            memset(state->printer_buffer, 0, sizeof(state->printer_buffer));
648            state->printer_size = 0;
649         }
650      }
651
652      state->send_bit = 0;
653      state->char_code = 0;
604654      state->regs_r[2] |= 0x80;
605655   }
606656   else
607      char_code <<= 1;
657      state->char_code <<= 1;
608658}
609659
610660
r8222r8223
11341184{
11351185   t6834_state *state = (t6834_state *)machine->driver_data;
11361186
1137   state ->irq_clear = timer_alloc(machine, irq_clear, 0);
1138   state ->beep_clear = timer_alloc(machine, beep_stop, 0);
1139   state ->kb_clear = timer_alloc(machine, keyboard_clear, 0);
1187   state->irq_clear = timer_alloc(machine, irq_clear, 0);
1188   state->beep_clear = timer_alloc(machine, beep_stop, 0);
1189   state->kb_clear = timer_alloc(machine, keyboard_clear, 0);
1190   state->printer = devtag_get_device(machine, "printer");
11401191
11411192   /* Save State */
11421193
r8222r8223
11771228   state_save_register_global(machine, state->kb_wait);
11781229   state_save_register_global_array(machine, state->kb_data);
11791230   state_save_register_global(machine, state->kb_size);
1231   state_save_register_global(machine, state->send_bit);
1232   state_save_register_global(machine, state->char_code);
1233   state_save_register_global_array(machine, state->printer_buffer);
1234   state_save_register_global(machine, state->printer_size);
11801235}
11811236
11821237static MACHINE_RESET( x07 )
r8222r8223
11921247   memset(state->out_data, 0, sizeof(state->out_data));
11931248   memset(state->lcd_map, 0, sizeof(state->lcd_map));
11941249   memset(state->kb_data, 0, sizeof(state->kb_data));
1250   memset(state->printer_buffer, 0, sizeof(state->printer_buffer));
11951251
11961252   state->enable_k7 =    0;
11971253   state->udk =       0;
r8222r8223
12211277   state->kb_brk =    0;
12221278   state->kb_wait =    0;
12231279   state->kb_size =    0;
1280   state->send_bit =   0;
1281   state->char_code =   0;
1282   state->printer_size = 0;
12241283
12251284   state->regs_r[2] = input_port_read(machine, "CARDBATTERY");
12261285}
r8222r8223
12501309   MDRV_GFXDECODE(x07)
12511310   MDRV_VIDEO_UPDATE(x07)
12521311
1253
1312   /* sound hardware */
12541313   MDRV_SPEAKER_STANDARD_MONO( "mono" )
12551314   MDRV_SOUND_ADD( "beep", BEEP, 0 )
12561315   MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
12571316
1317   /* printer */
1318   MDRV_PRINTER_ADD("printer")
1319
12581320   MDRV_TIMER_ADD_PERIODIC("keyboard", keyboard_poll, USEC(2500))
12591321
12601322   MDRV_NVRAM_HANDLER(x07)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team