Previous 15994 Revisions Next

r9864 Saturday 1st January, 2011 at 00:01:44 UTC by Barry Rodewald
[PCW] Added preliminary printer timers, improving draft print quality under Mallard BASIC.
[docs]messnew.txt
[src/mess/drivers]pcw.c
[src/mess/includes]pcw.h

src/mess/includes/pcw.h
r9863r9864
1616
1717#define PCW_SCREEN_WIDTH   (PCW_DISPLAY_WIDTH + (PCW_BORDER_WIDTH<<1))
1818#define PCW_SCREEN_HEIGHT   (PCW_DISPLAY_HEIGHT  + (PCW_BORDER_HEIGHT<<1))
19#define PCW_PRINTER_WIDTH   (40*16)
19#define PCW_PRINTER_WIDTH   (80*16)
2020#define PCW_PRINTER_HEIGHT   (20*16)
2121
2222
r9863r9864
5858   UINT32 paper_feed;  // amount of paper fed through printer, by n/360 inches.  One line feed is 61/360in (from the linefeed command in CP/M;s ptr menu)
5959   bitmap_t* prn_output;
6060   UINT8 printer_p2_prev;
61   emu_timer* prn_stepper;
62   emu_timer* prn_pins;
6163};
6264
6365
src/mess/drivers/pcw.c
r9863r9864
740740 * T0: Paper sensor (?)
741741 * T1: Print head location (1 if not at left margin)
742742 */
743static TIMER_CALLBACK(pcw_stepper_callback)
744{
745   pcw_state *state = machine->driver_data<pcw_state>();
746
747   //popmessage("PRN: P2 bits %s %s %s\nSerial: %02x\nHeadpos: %i",state->printer_p2 & 0x40 ? " " : "6",state->printer_p2 & 0x20 ? " " : "5",state->printer_p2 & 0x10 ? " " : "4",state->printer_shift_output,state->printer_headpos);
748   if((state->printer_p2 & 0x10) == 0)  // print head motor active
749   {
750      UINT8 stepper_state = (state->printer_shift_output >> 4) & 0x0f;
751      if(stepper_state == full_step_table[(state->head_motor_state + 1) & 0x03])
752      {
753         state->printer_headpos += 2;
754         state->head_motor_state++;
755         logerror("Printer head moved forward by 2 to %i\n",state->printer_headpos);
756      }
757      if(stepper_state == half_step_table[(state->head_motor_state + 1) & 0x03])
758      {
759         state->printer_headpos += 1;
760         state->head_motor_state++;
761         logerror("Printer head moved forward by 1 to %i\n",state->printer_headpos);
762      }
763      if(stepper_state == full_step_table[(state->head_motor_state - 1) & 0x03])
764      {
765         state->printer_headpos -= 2;
766         state->head_motor_state--;
767         logerror("Printer head moved back by 2 to %i\n",state->printer_headpos);
768      }
769      if(stepper_state == half_step_table[(state->head_motor_state - 1) & 0x03])
770      {
771         state->printer_headpos -= 1;
772         state->head_motor_state--;
773         logerror("Printer head moved back by 1 to %i\n",state->printer_headpos);
774      }
775      if(state->printer_headpos < 0)
776         state->printer_headpos = 0;
777      if(state->printer_headpos > PCW_PRINTER_WIDTH)
778         state->printer_headpos = PCW_PRINTER_WIDTH;
779      state->head_motor_state &= 0x03;
780      state->printer_p2 |= 0x10;
781   }
782   if((state->printer_p2 & 0x20) == 0)  // line feed motor active
783   {
784      UINT8 stepper_state = state->printer_shift_output & 0x0f;
785      if(stepper_state == full_step_table[(state->linefeed_motor_state + 1) & 0x03])
786      {
787         state->paper_feed++;
788         if(state->paper_feed > PCW_PRINTER_HEIGHT*2)
789            state->paper_feed = 0;
790         state->linefeed_motor_state++;
791      }
792      if(stepper_state == half_step_table[(state->linefeed_motor_state + 1) & 0x03])
793      {
794         state->paper_feed++;
795         if(state->paper_feed > PCW_PRINTER_HEIGHT*2)
796            state->paper_feed = 0;
797         state->linefeed_motor_state++;
798      }
799      state->linefeed_motor_state &= 0x03;
800      state->printer_p2 |= 0x20;
801   }
802}
803
804static TIMER_CALLBACK(pcw_pins_callback)
805{
806   pcw_state *state = machine->driver_data<pcw_state>();
807
808   pcw_printer_fire_pins(machine,state->printer_pins);
809   state->printer_p2 |= 0x40;
810}
811
743812static READ8_HANDLER(mcu_printer_p1_r)
744813{
745814   pcw_state *state = space->machine->driver_data<pcw_state>();
r9863r9864
774843   //logerror("PRN: MCU writing %02x to P2\n",data);
775844   state->printer_p2 = data & 0x70;
776845
777   if((data & 0x40) == 0 && (state->printer_p2_prev & 0x40) != 0)
778      pcw_printer_fire_pins(space->machine,state->printer_pins);
779
780846   // handle shift/store
781847   state->printer_serial = data & 0x04;  // data
782848   if((data & 0x02) != 0)  // clock
r9863r9864
791857   {
792858      logerror("Strobe active [%02x]\n",state->printer_shift);
793859      state->printer_shift_output = state->printer_shift;
794      if((state->printer_p2 & 0x10) == 0)  // print head motor active
795      {
796         UINT8 stepper_state = (state->printer_shift_output >> 4) & 0x0f;
797         if(stepper_state == full_step_table[(state->head_motor_state + 1) & 0x03])
798         {
799            state->printer_headpos += 2;
800            state->head_motor_state++;
801            logerror("Printer head moved forward by 2 to %i\n",state->printer_headpos);
802         }
803         if(stepper_state == half_step_table[(state->head_motor_state + 1) & 0x03])
804         {
805            state->printer_headpos += 1;
806            state->head_motor_state++;
807            logerror("Printer head moved forward by 1 to %i\n",state->printer_headpos);
808         }
809         if(stepper_state == full_step_table[(state->head_motor_state - 1) & 0x03])
810         {
811            state->printer_headpos -= 2;
812            state->head_motor_state--;
813            logerror("Printer head moved back by 2 to %i\n",state->printer_headpos);
814         }
815         if(stepper_state == half_step_table[(state->head_motor_state - 1) & 0x03])
816         {
817            state->printer_headpos -= 1;
818            state->head_motor_state--;
819            logerror("Printer head moved back by 1 to %i\n",state->printer_headpos);
820         }
821         if(state->printer_headpos < 0)
822            state->printer_headpos = 0;
823         if(state->printer_headpos > PCW_PRINTER_WIDTH)
824            state->printer_headpos = PCW_PRINTER_WIDTH;
825         state->head_motor_state &= 0x03;
826      }
827      if((state->printer_p2 & 0x20) == 0)  // line feed motor active
828      {
829         UINT8 stepper_state = state->printer_shift_output & 0x0f;
830         if(stepper_state == full_step_table[(state->linefeed_motor_state + 1) & 0x03])
831         {
832            state->paper_feed++;
833            if(state->paper_feed > PCW_PRINTER_HEIGHT*2)
834               state->paper_feed = 0;
835            state->linefeed_motor_state++;
836         }
837         if(stepper_state == half_step_table[(state->linefeed_motor_state + 1) & 0x03])
838         {
839            state->paper_feed++;
840            if(state->paper_feed > PCW_PRINTER_HEIGHT*2)
841               state->paper_feed = 0;
842            state->linefeed_motor_state++;
843         }
844         state->linefeed_motor_state &= 0x03;
845      }
860      timer_adjust_oneshot(state->prn_stepper,PERIOD_OF_555_MONOSTABLE(22000,0.00000001),0);
846861   }
862
863   if(data & 0x40)
864      timer_adjust_oneshot(state->prn_pins,PERIOD_OF_555_MONOSTABLE(22000,0.0000000068),0);
865
847866   if(data & 0x01)
848867      state->printer_pins |= 0x0100;
849868   else
850869      state->printer_pins &= ~0x0100;
851870   state->printer_p2_prev = data;
852   //popmessage("PRN: P2 bits %s %s %s\nSerial: %02x\nHeadpos: %i",data & 0x40 ? " " : "6",data & 0x20 ? " " : "5",data & 0x10 ? " " : "4",state->printer_shift_output,state->printer_headpos);
853871}
854872
855873// Paper sensor
r9863r9864
11031121   timer_pulse(machine, ATTOTIME_IN_HZ(300), NULL, 0, pcw_timer_interrupt);
11041122
11051123   timer_set(machine, attotime_zero, NULL, 0, setup_beep);
1124
1125   state->prn_stepper = timer_alloc(machine,pcw_stepper_callback,NULL);
1126   state->prn_pins = timer_alloc(machine,pcw_pins_callback,NULL);
11061127}
11071128
11081129
r9863r9864
13641385   MDRV_SCREEN_VISIBLE_AREA(0, PCW_PRINTER_WIDTH-1, 0, PCW_PRINTER_HEIGHT-1)
13651386
13661387   MDRV_DEFAULT_LAYOUT( layout_pcw )
1388
13671389MACHINE_CONFIG_END
13681390
13691391static MACHINE_CONFIG_DERIVED( pcw8512, pcw )
docs/messnew.txt
r9863r9864
104104
105105- [PC8201] Added a software list for option ROMs. [Curt Coder]
106106
107- [PCW] Added very preliminary printer emulation, output to a separate screen.  [Barry Rodewald]
108
107109- [QL] Added a software list for cartridges. [Curt Coder]
108110
109111- [SMS] Improved Light Phaser emulation and converted it to use timers

Previous 15994 Revisions Next


© 1998-2018 The MESS Team