src/mess/video/pcw.c
| r9753 | r9754 | |
| 21 | 21 | |
| 22 | 22 | VIDEO_START( pcw ) |
| 23 | 23 | { |
| 24 | pcw_state *state = machine->driver_data<pcw_state>(); |
| 25 | rectangle rect; |
| 26 | rect.min_x = rect.min_y = 0; |
| 27 | rect.max_x = PCW_PRINTER_WIDTH - 1; |
| 28 | rect.max_y = PCW_PRINTER_HEIGHT - 1; |
| 29 | |
| 30 | state->prn_output = auto_bitmap_alloc(machine,PCW_PRINTER_WIDTH,PCW_PRINTER_HEIGHT,BITMAP_FORMAT_INDEXED16); |
| 31 | bitmap_fill(state->prn_output,&rect,1); |
| 24 | 32 | } |
| 25 | 33 | |
| 26 | 34 | /* two colours */ |
| r9753 | r9754 | |
| 56 | 64 | unsigned char *roller_ram_ptr; |
| 57 | 65 | int pen0,pen1; |
| 58 | 66 | |
| 59 | | pen0 = 0; |
| 60 | | pen1 = 1; |
| 61 | | |
| 62 | | /* invert? */ |
| 63 | | if (state->vdu_video_control_register & (1<<7)) |
| 67 | if(screen == screen->machine->device("screen")) |
| 64 | 68 | { |
| 65 | | /* yes */ |
| 66 | | pen1^=1; |
| 67 | | pen0^=1; |
| 68 | | } |
| 69 | pen0 = 0; |
| 70 | pen1 = 1; |
| 69 | 71 | |
| 70 | | /* video enable? */ |
| 71 | | if ((state->vdu_video_control_register & (1<<6))!=0) |
| 72 | | { |
| 73 | | rectangle rect; |
| 72 | /* invert? */ |
| 73 | if (state->vdu_video_control_register & (1<<7)) |
| 74 | { |
| 75 | /* yes */ |
| 76 | pen1^=1; |
| 77 | pen0^=1; |
| 78 | } |
| 74 | 79 | |
| 75 | | /* render top border */ |
| 76 | | rect.min_x = 0; |
| 77 | | rect.min_y = 0; |
| 78 | | rect.max_x = PCW_SCREEN_WIDTH; |
| 79 | | rect.max_y = PCW_BORDER_HEIGHT; |
| 80 | | bitmap_fill(bitmap, &rect, pen0); |
| 80 | /* video enable? */ |
| 81 | if ((state->vdu_video_control_register & (1<<6))!=0) |
| 82 | { |
| 83 | rectangle rect; |
| 81 | 84 | |
| 82 | | /* render bottom border */ |
| 83 | | rect.min_x = 0; |
| 84 | | rect.min_y = PCW_BORDER_HEIGHT + PCW_DISPLAY_HEIGHT; |
| 85 | | rect.max_x = PCW_SCREEN_WIDTH; |
| 86 | | rect.max_y = rect.min_y + PCW_BORDER_HEIGHT; |
| 87 | | bitmap_fill(bitmap, &rect, pen0); |
| 85 | /* render top border */ |
| 86 | rect.min_x = 0; |
| 87 | rect.min_y = 0; |
| 88 | rect.max_x = PCW_SCREEN_WIDTH; |
| 89 | rect.max_y = PCW_BORDER_HEIGHT; |
| 90 | bitmap_fill(bitmap, &rect, pen0); |
| 88 | 91 | |
| 89 | | /* yes */ |
| 92 | /* render bottom border */ |
| 93 | rect.min_x = 0; |
| 94 | rect.min_y = PCW_BORDER_HEIGHT + PCW_DISPLAY_HEIGHT; |
| 95 | rect.max_x = PCW_SCREEN_WIDTH; |
| 96 | rect.max_y = rect.min_y + PCW_BORDER_HEIGHT; |
| 97 | bitmap_fill(bitmap, &rect, pen0); |
| 90 | 98 | |
| 91 | | /* offset to start in table */ |
| 92 | | roller_ram_offs = (state->roller_ram_offset<<1); |
| 99 | /* offset to start in table */ |
| 100 | roller_ram_offs = (state->roller_ram_offset<<1); |
| 93 | 101 | |
| 94 | | for (y=0; y<256; y++) |
| 95 | | { |
| 96 | | int by; |
| 97 | | unsigned short line_data; |
| 98 | | unsigned char *line_ptr; |
| 102 | for (y=0; y<256; y++) |
| 103 | { |
| 104 | int by; |
| 105 | unsigned short line_data; |
| 106 | unsigned char *line_ptr; |
| 99 | 107 | |
| 100 | | x = PCW_BORDER_WIDTH; |
| 108 | x = PCW_BORDER_WIDTH; |
| 101 | 109 | |
| 102 | | roller_ram_ptr = messram_get_ptr(screen->machine->device("messram")) + state->roller_ram_addr + roller_ram_offs; |
| 110 | roller_ram_ptr = messram_get_ptr(screen->machine->device("messram")) + state->roller_ram_addr + roller_ram_offs; |
| 103 | 111 | |
| 104 | | /* get line address */ |
| 105 | | /* b16-14 control which bank the line is to be found in, b13-3 the address in the bank (in 16-byte units), and b2-0 the offset. Thus a roller RAM address bbbxxxxxxxxxxxyyy indicates bank bbb, address 00xxxxxxxxxxx0yyy. */ |
| 106 | | line_data = ((unsigned char *)roller_ram_ptr)[0] | (((unsigned char *)roller_ram_ptr)[1]<<8); |
| 112 | /* get line address */ |
| 113 | /* b16-14 control which bank the line is to be found in, b13-3 the address in the bank (in 16-byte units), and b2-0 the offset. Thus a roller RAM address bbbxxxxxxxxxxxyyy indicates bank bbb, address 00xxxxxxxxxxx0yyy. */ |
| 114 | line_data = ((unsigned char *)roller_ram_ptr)[0] | (((unsigned char *)roller_ram_ptr)[1]<<8); |
| 107 | 115 | |
| 108 | | /* calculate address of pixel data */ |
| 109 | | line_ptr = messram_get_ptr(screen->machine->device("messram")) + ((line_data & 0x0e000)<<1) + ((line_data & 0x01ff8)<<1) + (line_data & 0x07); |
| 116 | /* calculate address of pixel data */ |
| 117 | line_ptr = messram_get_ptr(screen->machine->device("messram")) + ((line_data & 0x0e000)<<1) + ((line_data & 0x01ff8)<<1) + (line_data & 0x07); |
| 110 | 118 | |
| 111 | | for (by=0; by<90; by++) |
| 112 | | { |
| 113 | | unsigned char byte; |
| 119 | for (by=0; by<90; by++) |
| 120 | { |
| 121 | unsigned char byte; |
| 114 | 122 | |
| 115 | | byte = line_ptr[0]; |
| 123 | byte = line_ptr[0]; |
| 116 | 124 | |
| 117 | | for (b=0; b<8; b++) |
| 118 | | { |
| 119 | | if (byte & 0x080) |
| 125 | for (b=0; b<8; b++) |
| 120 | 126 | { |
| 121 | | pcw_plot_pixel(bitmap,x+b, y+PCW_BORDER_HEIGHT, pen1); |
| 127 | if (byte & 0x080) |
| 128 | { |
| 129 | pcw_plot_pixel(bitmap,x+b, y+PCW_BORDER_HEIGHT, pen1); |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | pcw_plot_pixel(bitmap,x+b, y+PCW_BORDER_HEIGHT, pen0); |
| 134 | |
| 135 | } |
| 136 | byte = byte<<1; |
| 122 | 137 | } |
| 123 | | else |
| 124 | | { |
| 125 | | pcw_plot_pixel(bitmap,x+b, y+PCW_BORDER_HEIGHT, pen0); |
| 126 | 138 | |
| 127 | | } |
| 128 | | byte = byte<<1; |
| 139 | x = x + 8; |
| 140 | |
| 141 | |
| 142 | line_ptr = line_ptr+8; |
| 129 | 143 | } |
| 130 | 144 | |
| 131 | | x = x + 8; |
| 145 | /* update offset, wrap within 512 byte range */ |
| 146 | roller_ram_offs+=2; |
| 147 | roller_ram_offs&=511; |
| 132 | 148 | |
| 133 | | |
| 134 | | line_ptr = line_ptr+8; |
| 135 | 149 | } |
| 136 | 150 | |
| 137 | | /* update offset, wrap within 512 byte range */ |
| 138 | | roller_ram_offs+=2; |
| 139 | | roller_ram_offs&=511; |
| 151 | /* render border */ |
| 152 | /* 8 pixels either side of display */ |
| 153 | for (y=0; y<256; y++) |
| 154 | { |
| 155 | pcw_plot_pixel(bitmap, 0, y+PCW_BORDER_HEIGHT, pen0); |
| 156 | pcw_plot_pixel(bitmap, 1, y+PCW_BORDER_HEIGHT, pen0); |
| 157 | pcw_plot_pixel(bitmap, 2, y+PCW_BORDER_HEIGHT, pen0); |
| 158 | pcw_plot_pixel(bitmap, 3, y+PCW_BORDER_HEIGHT, pen0); |
| 159 | pcw_plot_pixel(bitmap, 4, y+PCW_BORDER_HEIGHT, pen0); |
| 160 | pcw_plot_pixel(bitmap, 5, y+PCW_BORDER_HEIGHT, pen0); |
| 161 | pcw_plot_pixel(bitmap, 6, y+PCW_BORDER_HEIGHT, pen0); |
| 162 | pcw_plot_pixel(bitmap, 7, y+PCW_BORDER_HEIGHT, pen0); |
| 140 | 163 | |
| 164 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+0, y+PCW_BORDER_HEIGHT, pen0); |
| 165 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+1, y+PCW_BORDER_HEIGHT, pen0); |
| 166 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+2, y+PCW_BORDER_HEIGHT, pen0); |
| 167 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+3, y+PCW_BORDER_HEIGHT, pen0); |
| 168 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+4, y+PCW_BORDER_HEIGHT, pen0); |
| 169 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+5, y+PCW_BORDER_HEIGHT, pen0); |
| 170 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+6, y+PCW_BORDER_HEIGHT, pen0); |
| 171 | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+7, y+PCW_BORDER_HEIGHT, pen0); |
| 172 | } |
| 141 | 173 | } |
| 142 | | |
| 143 | | /* render border */ |
| 144 | | /* 8 pixels either side of display */ |
| 145 | | for (y=0; y<256; y++) |
| 174 | else |
| 146 | 175 | { |
| 147 | | pcw_plot_pixel(bitmap, 0, y+PCW_BORDER_HEIGHT, pen0); |
| 148 | | pcw_plot_pixel(bitmap, 1, y+PCW_BORDER_HEIGHT, pen0); |
| 149 | | pcw_plot_pixel(bitmap, 2, y+PCW_BORDER_HEIGHT, pen0); |
| 150 | | pcw_plot_pixel(bitmap, 3, y+PCW_BORDER_HEIGHT, pen0); |
| 151 | | pcw_plot_pixel(bitmap, 4, y+PCW_BORDER_HEIGHT, pen0); |
| 152 | | pcw_plot_pixel(bitmap, 5, y+PCW_BORDER_HEIGHT, pen0); |
| 153 | | pcw_plot_pixel(bitmap, 6, y+PCW_BORDER_HEIGHT, pen0); |
| 154 | | pcw_plot_pixel(bitmap, 7, y+PCW_BORDER_HEIGHT, pen0); |
| 176 | /* not video - render whole lot in pen 0 */ |
| 177 | rectangle rect; |
| 155 | 178 | |
| 156 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+0, y+PCW_BORDER_HEIGHT, pen0); |
| 157 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+1, y+PCW_BORDER_HEIGHT, pen0); |
| 158 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+2, y+PCW_BORDER_HEIGHT, pen0); |
| 159 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+3, y+PCW_BORDER_HEIGHT, pen0); |
| 160 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+4, y+PCW_BORDER_HEIGHT, pen0); |
| 161 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+5, y+PCW_BORDER_HEIGHT, pen0); |
| 162 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+6, y+PCW_BORDER_HEIGHT, pen0); |
| 163 | | pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+7, y+PCW_BORDER_HEIGHT, pen0); |
| 179 | /* render top border */ |
| 180 | rect.min_x = 0; |
| 181 | rect.min_y = 0; |
| 182 | rect.max_x = PCW_SCREEN_WIDTH; |
| 183 | rect.max_y = PCW_SCREEN_HEIGHT; |
| 184 | |
| 185 | bitmap_fill(bitmap, &rect, pen0); |
| 164 | 186 | } |
| 165 | 187 | } |
| 166 | 188 | else |
| 167 | 189 | { |
| 168 | | /* not video - render whole lot in pen 0 */ |
| 190 | // printer output |
| 169 | 191 | rectangle rect; |
| 170 | | |
| 171 | | /* render top border */ |
| 172 | | rect.min_x = 0; |
| 173 | | rect.min_y = 0; |
| 174 | | rect.max_x = PCW_SCREEN_WIDTH; |
| 175 | | rect.max_y = PCW_SCREEN_HEIGHT; |
| 176 | | |
| 177 | | bitmap_fill(bitmap, &rect, pen0); |
| 192 | INT32 feed; |
| 193 | rect.min_x = rect.min_y = 0; |
| 194 | rect.max_x = PCW_PRINTER_WIDTH - 1; |
| 195 | rect.max_y = PCW_PRINTER_HEIGHT - 1; |
| 196 | feed = -(state->paper_feed / 2); |
| 197 | copyscrollbitmap(bitmap,state->prn_output,0,NULL,1,&feed,&rect); |
| 198 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-1,state->printer_headpos) = 0; |
| 199 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-2,state->printer_headpos) = 0; |
| 200 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-3,state->printer_headpos) = 0; |
| 201 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-1,state->printer_headpos-1) = 0; |
| 202 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-2,state->printer_headpos-1) = 0; |
| 203 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-1,state->printer_headpos+1) = 0; |
| 204 | *BITMAP_ADDR16(bitmap,PCW_PRINTER_HEIGHT-2,state->printer_headpos+1) = 0; |
| 178 | 205 | } |
| 179 | 206 | return 0; |
| 180 | 207 | } |
src/mess/drivers/pcw.c
| r9753 | r9754 | |
| 105 | 105 | #include "sound/beep.h" |
| 106 | 106 | #include "devices/messram.h" |
| 107 | 107 | |
| 108 | #include "pcw.lh" |
| 109 | |
| 108 | 110 | #define VERBOSE 1 |
| 109 | 111 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 110 | 112 | |
| 113 | static const UINT8 half_step_table[4] = { 0x01, 0x02, 0x04, 0x08 }; |
| 114 | static const UINT8 full_step_table[4] = { 0x03, 0x06, 0x0c, 0x09 }; |
| 115 | |
| 111 | 116 | static WRITE_LINE_DEVICE_HANDLER( pcw_fdc_interrupt ); |
| 112 | 117 | |
| 113 | | // pointer to pcw ram |
| 114 | | // flag to indicate if boot-program is enabled/disabled |
| 115 | | // code for CPU int type generated when FDC int is triggered |
| 116 | | |
| 117 | | |
| 118 | | |
| 119 | | |
| 120 | | |
| 121 | | |
| 122 | 118 | static void pcw_update_interrupt_counter(pcw_state *state) |
| 123 | 119 | { |
| 124 | 120 | /* never increments past 15! */ |
| r9753 | r9754 | |
| 669 | 665 | } |
| 670 | 666 | |
| 671 | 667 | /* TODO: Implement the printer for PCW8256, PCW8512,PCW9256*/ |
| 668 | static void pcw_printer_fire_pins(running_machine* machine, UINT16 pins) |
| 669 | { |
| 670 | pcw_state *state = machine->driver_data<pcw_state>(); |
| 671 | int x,line; |
| 672 | INT32 feed = (state->paper_feed / 2); |
| 673 | |
| 674 | for(x=feed+PCW_PRINTER_HEIGHT-16;x<feed+PCW_PRINTER_HEIGHT-7;x++) |
| 675 | { |
| 676 | line = x % PCW_PRINTER_HEIGHT; |
| 677 | if((pins & 0x01) == 0) |
| 678 | *BITMAP_ADDR16(state->prn_output,line,state->printer_headpos) = (UINT16)(pins & 0x01); |
| 679 | pins >>= 1; |
| 680 | } |
| 681 | // if(state->printer_headpos < PCW_PRINTER_WIDTH) |
| 682 | // state->printer_headpos++; |
| 683 | } |
| 684 | |
| 672 | 685 | static WRITE8_HANDLER(pcw_printer_data_w) |
| 673 | 686 | { |
| 674 | 687 | pcw_state *state = space->machine->driver_data<pcw_state>(); |
| r9753 | r9754 | |
| 712 | 725 | } |
| 713 | 726 | |
| 714 | 727 | /* MCU handlers */ |
| 728 | /* I/O ports: (likely to be completely wrong...) |
| 729 | * (write) |
| 730 | * all are active low |
| 731 | * P1: pins 0-7 |
| 732 | * P2 bit 0: pin 8 |
| 733 | * P2 bit 1: serial shift/store clock |
| 734 | * P2 bit 2: serial shift store data |
| 735 | * P2 bit 3: serial shift/store strobe |
| 736 | * P2 bit 4: print head motor |
| 737 | * P2 bit 5: paper feed motor |
| 738 | * P2 bit 6: fire pins |
| 739 | * (read) |
| 740 | * P2 bit 7: bail bar status (0 if out) |
| 741 | * T0: Paper sensor (?) |
| 742 | * T1: Print head location (1 if not at left margin) |
| 743 | */ |
| 715 | 744 | static READ8_HANDLER(mcu_printer_p1_r) |
| 716 | 745 | { |
| 746 | pcw_state *state = space->machine->driver_data<pcw_state>(); |
| 717 | 747 | // logerror("PRN: MCU reading data from P1\n"); |
| 718 | | return 0x00; |
| 748 | return state->printer_pins & 0x00ff; |
| 719 | 749 | } |
| 720 | 750 | |
| 721 | 751 | static WRITE8_HANDLER(mcu_printer_p1_w) |
| 722 | 752 | { |
| 723 | | logerror("PRN: MCU writing %02x to P1\n",data); |
| 753 | pcw_state *state = space->machine->driver_data<pcw_state>(); |
| 754 | state->printer_pins = (state->printer_pins & 0x0100) | data; |
| 755 | //popmessage("PRN: Print head position = %i",state->printer_headpos); |
| 756 | logerror("PRN: MCU writing %02x to P1 [%03x]\n",data,state->printer_pins); |
| 724 | 757 | } |
| 725 | 758 | |
| 726 | 759 | static READ8_HANDLER(mcu_printer_p2_r) |
| 727 | 760 | { |
| 728 | 761 | UINT8 ret = 0x00; |
| 762 | pcw_state *state = space->machine->driver_data<pcw_state>(); |
| 729 | 763 | // logerror("PRN: MCU reading data from P2\n"); |
| 730 | | ret |= 0x80; |
| 764 | ret |= 0x80; // make sure bail bar is in |
| 765 | ret |= (state->printer_p2 & 0x70); |
| 766 | ret |= (state->printer_pins & 0x100) ? 0x01 : 0x00; // ninth pin |
| 767 | ret |= 0x0e; |
| 731 | 768 | return ret; |
| 732 | 769 | } |
| 733 | 770 | |
| 734 | 771 | static WRITE8_HANDLER(mcu_printer_p2_w) |
| 735 | 772 | { |
| 736 | 773 | pcw_state *state = space->machine->driver_data<pcw_state>(); |
| 737 | | // logerror("PRN: MCU writing %02x to P2\n",data); |
| 738 | | if((data & 0x20) == 0) |
| 739 | | state->printer_headpos = 1; // move head |
| 740 | | if((data & 0x10) == 0) |
| 741 | | state->printer_headpos = 0; |
| 774 | static UINT8 prev; |
| 775 | |
| 776 | //logerror("PRN: MCU writing %02x to P2\n",data); |
| 777 | state->printer_p2 = data & 0x70; |
| 778 | |
| 779 | if((data & 0x40) == 0 && (prev & 0x40) != 0) |
| 780 | pcw_printer_fire_pins(space->machine,state->printer_pins); |
| 781 | |
| 782 | // handle shift/store |
| 783 | state->printer_serial = data & 0x04; // data |
| 784 | if((data & 0x02) != 0) // clock |
| 785 | { |
| 786 | state->printer_shift <<= 1; |
| 787 | if(state->printer_serial == 0) |
| 788 | state->printer_shift &= ~0x01; |
| 789 | else |
| 790 | state->printer_shift |= 0x01; |
| 791 | } |
| 792 | if((data & 0x08) != 0) // strobe |
| 793 | { |
| 794 | state->printer_shift_output = state->printer_shift; |
| 795 | if((state->printer_p2 & 0x10) == 0) // print head motor active |
| 796 | { |
| 797 | UINT8 stepper_state = (state->printer_shift_output >> 4) & 0x0f; |
| 798 | if(stepper_state == full_step_table[(state->head_motor_state + 1) & 0x03]) |
| 799 | { |
| 800 | state->printer_headpos += 2; |
| 801 | state->head_motor_state++; |
| 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 | } |
| 808 | if(stepper_state == full_step_table[(state->head_motor_state - 1) & 0x03]) |
| 809 | { |
| 810 | state->printer_headpos -= 2; |
| 811 | state->head_motor_state--; |
| 812 | } |
| 813 | if(stepper_state == half_step_table[(state->head_motor_state - 1) & 0x03]) |
| 814 | { |
| 815 | state->printer_headpos -= 1; |
| 816 | state->head_motor_state--; |
| 817 | } |
| 818 | if(state->printer_headpos < 0) |
| 819 | state->printer_headpos = 0; |
| 820 | if(state->printer_headpos > PCW_PRINTER_WIDTH) |
| 821 | state->printer_headpos = PCW_PRINTER_WIDTH; |
| 822 | state->head_motor_state &= 0x03; |
| 823 | } |
| 824 | if((state->printer_p2 & 0x20) == 0) // line feed motor active |
| 825 | { |
| 826 | UINT8 stepper_state = state->printer_shift_output & 0x0f; |
| 827 | if(stepper_state == full_step_table[(state->linefeed_motor_state + 1) & 0x03]) |
| 828 | { |
| 829 | state->paper_feed++; |
| 830 | state->linefeed_motor_state++; |
| 831 | } |
| 832 | if(stepper_state == half_step_table[(state->linefeed_motor_state + 1) & 0x03]) |
| 833 | { |
| 834 | state->paper_feed++; |
| 835 | state->linefeed_motor_state++; |
| 836 | } |
| 837 | state->linefeed_motor_state &= 0x03; |
| 838 | } |
| 839 | } |
| 840 | if(data & 0x01) |
| 841 | state->printer_pins |= 0x0100; |
| 842 | else |
| 843 | state->printer_pins &= ~0x0100; |
| 844 | prev = data; |
| 845 | //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); |
| 742 | 846 | } |
| 743 | 847 | |
| 744 | | // Paper sensor? |
| 848 | // Paper sensor |
| 745 | 849 | static READ8_HANDLER(mcu_printer_t1_r) |
| 746 | 850 | { |
| 747 | 851 | return 1; |
| 748 | 852 | } |
| 749 | 853 | |
| 750 | | // Print head location? (0 if at left margin, otherwise 1) |
| 854 | // Print head location (0 if at left margin, otherwise 1) |
| 751 | 855 | static READ8_HANDLER(mcu_printer_t0_r) |
| 752 | 856 | { |
| 753 | 857 | pcw_state *state = space->machine->driver_data<pcw_state>(); |
| 754 | | return state->printer_headpos; |
| 858 | |
| 859 | if(state->printer_headpos == 0) |
| 860 | return 0; |
| 861 | else |
| 862 | return 1; |
| 755 | 863 | } |
| 756 | 864 | |
| 757 | 865 | /* |
| r9753 | r9754 | |
| 967 | 1075 | state->printer_command = 0xff; |
| 968 | 1076 | state->printer_data = 0x00; |
| 969 | 1077 | state->printer_headpos = 0x00; // bring printer head to left margin |
| 1078 | state->printer_shift = 0; |
| 1079 | state->printer_shift_output = 0; |
| 970 | 1080 | } |
| 971 | 1081 | |
| 972 | 1082 | static DRIVER_INIT(pcw) |
| r9753 | r9754 | |
| 1196 | 1306 | /* PCW8256, PCW8512, PCW9256 */ |
| 1197 | 1307 | static MACHINE_CONFIG_START( pcw, pcw_state ) |
| 1198 | 1308 | /* basic machine hardware */ |
| 1199 | | MDRV_CPU_ADD("maincpu", Z80, 4000000) /* clock supplied to chip, but in reality it is 3.4 MHz */ |
| 1309 | MDRV_CPU_ADD("maincpu", Z80, 3400000) /* clock supplied to chip, but in reality it is 3.4 MHz */ |
| 1200 | 1310 | MDRV_CPU_PROGRAM_MAP(pcw_map) |
| 1201 | 1311 | MDRV_CPU_IO_MAP(pcw_io) |
| 1202 | | MDRV_QUANTUM_TIME(HZ(50)) |
| 1312 | // MDRV_QUANTUM_TIME(HZ(50)) |
| 1313 | MDRV_QUANTUM_PERFECT_CPU("maincpu") |
| 1203 | 1314 | |
| 1204 | 1315 | MDRV_CPU_ADD("printer_mcu", I8041, 11000000) // 11MHz |
| 1205 | 1316 | MDRV_CPU_IO_MAP(pcw_printer_io) |
| 1317 | MDRV_QUANTUM_PERFECT_CPU("printer_mcu") |
| 1206 | 1318 | |
| 1207 | 1319 | MDRV_CPU_ADD("keyboard_mcu", I8048, 5000000) // 5MHz |
| 1208 | 1320 | MDRV_CPU_IO_MAP(pcw_keyboard_io) |
| 1321 | MDRV_QUANTUM_PERFECT_CPU("keyboard_mcu") |
| 1209 | 1322 | |
| 1210 | 1323 | MDRV_MACHINE_START(pcw) |
| 1211 | 1324 | MDRV_MACHINE_RESET(pcw) |
| r9753 | r9754 | |
| 1237 | 1350 | MDRV_RAM_DEFAULT_SIZE("256K") |
| 1238 | 1351 | MACHINE_CONFIG_END |
| 1239 | 1352 | |
| 1240 | | static MACHINE_CONFIG_DERIVED( pcw_512, pcw ) |
| 1353 | static MACHINE_CONFIG_DERIVED( pcw8256, pcw ) |
| 1354 | MDRV_SCREEN_ADD("printer",RASTER) |
| 1355 | MDRV_SCREEN_REFRESH_RATE(50) |
| 1356 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1357 | MDRV_SCREEN_SIZE( PCW_PRINTER_WIDTH, PCW_PRINTER_HEIGHT ) |
| 1358 | MDRV_SCREEN_VISIBLE_AREA(0, PCW_PRINTER_WIDTH-1, 0, PCW_PRINTER_HEIGHT-1) |
| 1241 | 1359 | |
| 1360 | MDRV_DEFAULT_LAYOUT( layout_pcw ) |
| 1361 | MACHINE_CONFIG_END |
| 1362 | |
| 1363 | static MACHINE_CONFIG_DERIVED( pcw8512, pcw ) |
| 1364 | MDRV_SCREEN_ADD("printer",RASTER) |
| 1365 | MDRV_SCREEN_REFRESH_RATE(50) |
| 1366 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1367 | MDRV_SCREEN_SIZE( PCW_PRINTER_WIDTH, PCW_PRINTER_HEIGHT ) |
| 1368 | MDRV_SCREEN_VISIBLE_AREA(0, PCW_PRINTER_WIDTH-1, 0, PCW_PRINTER_HEIGHT-1) |
| 1369 | |
| 1370 | MDRV_DEFAULT_LAYOUT( layout_pcw ) |
| 1371 | |
| 1242 | 1372 | /* internal ram */ |
| 1243 | 1373 | MDRV_RAM_MODIFY("messram") |
| 1244 | 1374 | MDRV_RAM_DEFAULT_SIZE("512K") |
| r9753 | r9754 | |
| 1264 | 1394 | ROM_START(pcw8256) |
| 1265 | 1395 | ROM_REGION(0x10000,"maincpu",0) |
| 1266 | 1396 | ROM_FILL(0x0000,0x10000,0x00) \ |
| 1267 | | ROM_REGION(0x400,"printer_mcu",0) // i8041 |
| 1397 | ROM_REGION(0x400,"printer_mcu",0) // i8041 9-pin dot-matrix |
| 1268 | 1398 | ROM_LOAD("40026.ic701", 0, 0x400, CRC(ee8890ae) SHA1(91679cc5e07464ac55ef9a10f7095b2438223332)) |
| 1269 | 1399 | ROM_REGION(0x400,"keyboard_mcu",0) // i8048 |
| 1270 | 1400 | ROM_LOAD("40027.ic801", 0, 0x400, CRC(25260958) SHA1(210e7e25228c79d2920679f217d68e4f14055825)) |
| r9753 | r9754 | |
| 1273 | 1403 | ROM_START(pcw8512) |
| 1274 | 1404 | ROM_REGION(0x10000,"maincpu",0) |
| 1275 | 1405 | ROM_FILL(0x0000,0x10000,0x00) \ |
| 1276 | | ROM_REGION(0x400,"printer_mcu",0) // i8041 |
| 1406 | ROM_REGION(0x400,"printer_mcu",0) // i8041 9-pin dot-matrix |
| 1277 | 1407 | ROM_LOAD("40026.ic701", 0, 0x400, CRC(ee8890ae) SHA1(91679cc5e07464ac55ef9a10f7095b2438223332)) |
| 1278 | 1408 | ROM_REGION(0x400,"keyboard_mcu",0) // i8048 |
| 1279 | 1409 | ROM_LOAD("40027.ic801", 0, 0x400, CRC(25260958) SHA1(210e7e25228c79d2920679f217d68e4f14055825)) |
| r9753 | r9754 | |
| 1282 | 1412 | ROM_START(pcw9256) |
| 1283 | 1413 | ROM_REGION(0x10000,"maincpu",0) |
| 1284 | 1414 | ROM_FILL(0x0000,0x10000,0x00) \ |
| 1285 | | ROM_REGION(0x2000,"printer_mcu",0) // i8041 |
| 1286 | | ROM_LOAD("40103.ic109", 0, 0x2000, CRC(a64d450a) SHA1(ebbf0ef19d39912c1c127c748514dd299915f88b)) |
| 1415 | ROM_REGION(0x2000,"printer_mcu",0) // i8041 9-pin dot-matrix (does this model have different MCU code?) |
| 1416 | ROM_LOAD("40026.ic701", 0, 0x400, CRC(ee8890ae) SHA1(91679cc5e07464ac55ef9a10f7095b2438223332)) |
| 1287 | 1417 | ROM_REGION(0x400,"keyboard_mcu",0) // i8048 |
| 1288 | 1418 | ROM_LOAD("40027.ic801", 0, 0x400, CRC(25260958) SHA1(210e7e25228c79d2920679f217d68e4f14055825)) |
| 1289 | 1419 | ROM_END |
| r9753 | r9754 | |
| 1291 | 1421 | ROM_START(pcw9512) |
| 1292 | 1422 | ROM_REGION(0x10000,"maincpu",0) |
| 1293 | 1423 | ROM_FILL(0x0000,0x10000,0x00) \ |
| 1294 | | ROM_REGION(0x2000,"printer_mcu",0) // i8041 |
| 1424 | ROM_REGION(0x2000,"printer_mcu",0) // i8041 daisywheel |
| 1295 | 1425 | ROM_LOAD("40103.ic109", 0, 0x2000, CRC(a64d450a) SHA1(ebbf0ef19d39912c1c127c748514dd299915f88b)) |
| 1296 | 1426 | ROM_REGION(0x400,"keyboard_mcu",0) // i8048 |
| 1297 | 1427 | ROM_LOAD("40027.ic801", 0, 0x400, CRC(25260958) SHA1(210e7e25228c79d2920679f217d68e4f14055825)) |
| r9753 | r9754 | |
| 1300 | 1430 | ROM_START(pcw10) |
| 1301 | 1431 | ROM_REGION(0x10000,"maincpu",0) |
| 1302 | 1432 | ROM_FILL(0x0000,0x10000,0x00) \ |
| 1303 | | ROM_REGION(0x2000,"printer_mcu",0) // i8041 |
| 1433 | ROM_REGION(0x2000,"printer_mcu",0) // i8041 daisywheel |
| 1304 | 1434 | ROM_LOAD("40103.ic109", 0, 0x2000, CRC(a64d450a) SHA1(ebbf0ef19d39912c1c127c748514dd299915f88b)) |
| 1305 | 1435 | ROM_REGION(0x400,"keyboard_mcu",0) // i8048 |
| 1306 | 1436 | ROM_LOAD("40027.ic801", 0, 0x400, CRC(25260958) SHA1(210e7e25228c79d2920679f217d68e4f14055825)) |
| r9753 | r9754 | |
| 1310 | 1440 | /* these are all variants on the pcw design */ |
| 1311 | 1441 | /* major difference is memory configuration and drive type */ |
| 1312 | 1442 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 1313 | | COMP( 1985, pcw8256, 0, 0, pcw, pcw, pcw, "Amstrad plc", "PCW8256", GAME_NOT_WORKING) |
| 1314 | | COMP( 1985, pcw8512, pcw8256, 0, pcw_512, pcw, pcw, "Amstrad plc", "PCW8512", GAME_NOT_WORKING) |
| 1315 | | COMP( 1987, pcw9256, pcw8256, 0, pcw, pcw, pcw, "Amstrad plc", "PCW9256", GAME_NOT_WORKING) |
| 1443 | COMP( 1985, pcw8256, 0, 0, pcw8256, pcw, pcw, "Amstrad plc", "PCW8256", GAME_NOT_WORKING) |
| 1444 | COMP( 1985, pcw8512, pcw8256, 0, pcw8512, pcw, pcw, "Amstrad plc", "PCW8512", GAME_NOT_WORKING) |
| 1445 | COMP( 1987, pcw9256, pcw8256, 0, pcw8256, pcw, pcw, "Amstrad plc", "PCW9256", GAME_NOT_WORKING) |
| 1316 | 1446 | COMP( 1987, pcw9512, pcw8256, 0, pcw9512, pcw, pcw, "Amstrad plc", "PCW9512 (+)", GAME_NOT_WORKING) |
| 1317 | 1447 | COMP( 1993, pcw10, pcw8256, 0, pcw9512, pcw, pcw, "Amstrad plc", "PCW10", GAME_NOT_WORKING) |