diff --git a/src/devices/bus/centronics/epson_lx810l.cpp b/src/devices/bus/centronics/epson_lx810l.cpp index 3c954f3d28e..2b75d83fece 100644 --- a/src/devices/bus/centronics/epson_lx810l.cpp +++ b/src/devices/bus/centronics/epson_lx810l.cpp @@ -552,14 +552,12 @@ WRITE_LINE_MEMBER( epson_lx810l_device::co0_w ) * lines which are being printed in different directions is * noticeably off in the 20+ years old printer used for testing =). */ - if (m_bitmap_printer->m_xpos < m_bitmap_printer->m_page_bitmap.width()) { - for (int i = 0; i < 9; i++) - { - if ((m_printhead & (1<<(8-i))) != 0) - m_bitmap_printer->pix(m_bitmap_printer->m_ypos + i * 1, // * 1 for no interleave at 72 vdpi - m_bitmap_printer->m_xpos + CR_OFFSET + m_in_between_offset + - (m_bitmap_printer->m_cr_direction > 0 ? m_rightward_offset : 0)) = 0x000000; - } + for (int i = 0; i < 9; i++) + { + if ((m_printhead & (1<<(8-i))) != 0) + m_bitmap_printer->pix(m_bitmap_printer->m_ypos + i * 1, // * 1 for no interleave at 72 vdpi + m_bitmap_printer->m_xpos + CR_OFFSET + m_in_between_offset + + (m_bitmap_printer->m_cr_direction > 0 ? m_rightward_offset : 0)) = 0x000000; } } } diff --git a/src/devices/machine/bitmap_printer.cpp b/src/devices/machine/bitmap_printer.cpp index c0b5e4780de..ca552a14694 100644 --- a/src/devices/machine/bitmap_printer.cpp +++ b/src/devices/machine/bitmap_printer.cpp @@ -78,19 +78,15 @@ void bitmap_printer_device::device_add_mconfig(machine_config &config) bitmap_printer_device::bitmap_printer_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock), + m_cr_direction(1), + m_xpos(0), + m_ypos(0), m_screen(*this, "screen"), m_pf_stepper(*this, "pf_stepper"), m_cr_stepper(*this, "cr_stepper"), m_top_margin_ioport(*this, "TOPMARGIN"), m_bottom_margin_ioport(*this, "BOTTOMMARGIN"), m_draw_marks_ioport(*this, "DRAWMARKS"), - m_cr_direction(1), - m_pf_stepper_ratio0(1), - m_pf_stepper_ratio1(1), - m_cr_stepper_ratio0(1), - m_cr_stepper_ratio1(1), - m_xpos(0), - m_ypos(0), m_printhead_color(0x00EE00), m_printhead_bordercolor(0xEE0000), m_printhead_bordersize(2), @@ -104,15 +100,28 @@ bitmap_printer_device::bitmap_printer_device(const machine_config &mconfig, devi m_clear_pos(0), m_newpage_flag(0), m_led_state{0,1,1,1,1}, - m_num_leds(1) + m_num_leds(1), + m_pf_stepper_ratio0(1), + m_pf_stepper_ratio1(1), + m_cr_stepper_ratio0(1), + m_cr_stepper_ratio1(1) { } bitmap_printer_device::bitmap_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - bitmap_printer_device(mconfig, BITMAP_PRINTER, tag, owner, clock) + bitmap_printer_device(mconfig, BITMAP_PRINTER, tag, owner, clock) { } +bitmap_printer_device::bitmap_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, int paper_width, int paper_height, int hdpi, int vdpi) : + bitmap_printer_device(mconfig, tag, owner, u32(0)) +{ + m_paper_width = paper_width; + m_paper_height = paper_height; + m_hdpi = hdpi; + m_vdpi = vdpi; +} + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -229,6 +238,22 @@ void bitmap_printer_device::set_printhead_size(int xsize, int ysize, int borders m_printhead_bordersize = bordersize; } +void bitmap_printer_device::set_led_state(int led, int value) +{ + m_led_state[led] = value; + m_num_leds = std::max(m_num_leds, led); +} + +void bitmap_printer_device::setheadpos(int x, int y) +{ + if (m_xpos != x) + { + m_newpage_flag = 0; + } + m_xpos = x; + m_ypos = y; +} + u32 bitmap_printer_device::dimcolor(u32 incolor, int factor) { return (((incolor & 0xff0000) >> 16) / factor << 16) | @@ -381,28 +406,32 @@ bool bitmap_printer_device::check_new_page() m_ypos = get_top_margin(); // lock to the top of page until we seek horizontally m_pf_stepper->set_absolute_position(get_top_margin() / m_pf_stepper_ratio0 * m_pf_stepper_ratio1); } + + // If we are at the bottom of the page we will + // write the page to a file, then erase the top part of the page + // so we can still see the last page printed. if (m_ypos > m_page_bitmap.height() - 1 - get_bottom_margin()) - // If we are at the bottom of the page we will - // write the page to a file, then erase the top part of the page - // so we can still see the last page printed. - { - // clear paper to bottom from current position - clear_to_pos(m_paper_height - 1, rgb_t::white()); + { + // clear paper to bottom from current position + clear_to_pos(m_paper_height - 1, rgb_t::white()); - // save a snapshot - write_snapshot_to_file(); + // save a snapshot + write_snapshot_to_file(); - m_newpage_flag = 1; + m_newpage_flag = 1; - // clear page down to visible area, starting from the top of page - m_clear_pos = 0; - clear_to_pos(m_paper_height - 1 - PAPER_SCREEN_HEIGHT), + // clear page down to visible area, starting from the top of page + m_clear_pos = 0; + clear_to_pos(m_paper_height - 1 - PAPER_SCREEN_HEIGHT), - m_ypos = get_top_margin(); // lock to the top of page until we seek horizontally - m_pf_stepper->set_absolute_position(get_top_margin() / m_pf_stepper_ratio0 * m_pf_stepper_ratio1); - retval = true; - } - else { clear_to_pos ( m_ypos + m_distfrombottom); } + m_ypos = get_top_margin(); // lock to the top of page until we seek horizontally + m_pf_stepper->set_absolute_position(get_top_margin() / m_pf_stepper_ratio0 * m_pf_stepper_ratio1); + retval = true; + } + else + { + clear_to_pos ( m_ypos + m_distfrombottom); + } return retval; } @@ -441,3 +470,15 @@ void bitmap_printer_device::update_pf_stepper(int pattern) check_new_page(); } +void bitmap_printer_device::set_pf_stepper_ratio(int ratio0, int ratio1) +{ + m_pf_stepper_ratio0 = ratio0; + m_pf_stepper_ratio1 = ratio1; +} + +void bitmap_printer_device::set_cr_stepper_ratio(int ratio0, int ratio1) +{ + m_cr_stepper_ratio0 = ratio0; + m_cr_stepper_ratio1 = ratio1; +} + diff --git a/src/devices/machine/bitmap_printer.h b/src/devices/machine/bitmap_printer.h index 637a6b3a26f..7b05f0e8c15 100644 --- a/src/devices/machine/bitmap_printer.h +++ b/src/devices/machine/bitmap_printer.h @@ -25,15 +25,44 @@ class bitmap_printer_device : public device_t { public: bitmap_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + bitmap_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, int paper_width, int paper_height, int hdpi, int vdpi); - bitmap_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, int paper_width, int paper_height, int hdpi, int vdpi) : - bitmap_printer_device(mconfig, tag, owner, u32(0)) + enum { - m_paper_width = paper_width; - m_paper_height = paper_height; - m_hdpi = hdpi; - m_vdpi = vdpi; - } + LED_ERROR, + LED_READY, + LED_ONLINE + }; + + void set_led_state(int led, int value); + void set_printhead_color(int headcolor, int bordcolor); + void set_printhead_size(int xsize, int ysize, int bordersize); + void setheadpos(int x, int y); + + void write_snapshot_to_file(); + + void draw_pixel(int x, int y, int pixelval); + int get_pixel(int x, int y); + unsigned int &pix(int y, int x); + + void bitmap_clear_band(bitmap_rgb32 &bitmap, int from_line, int to_line, u32 color); + void bitmap_clear_band(int from_line, int to_line, u32 color); + void clear_to_pos(int to_line, u32 color = 0xffffff); + + int get_top_margin(); + int get_bottom_margin(); + bool check_new_page(); + + int update_stepper_delta(stepper_device *stepper, uint8_t pattern); + void update_cr_stepper(int pattern); + void update_pf_stepper(int pattern); + + void set_pf_stepper_ratio(int ratio0, int ratio1); + void set_cr_stepper_ratio(int ratio0, int ratio1); + + int m_cr_direction; // direction of carriage + int m_xpos; + int m_ypos; protected: bitmap_printer_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -47,25 +76,18 @@ protected: private: required_device m_screen; -public: required_device m_pf_stepper; required_device m_cr_stepper; required_ioport m_top_margin_ioport; required_ioport m_bottom_margin_ioport; required_ioport m_draw_marks_ioport; - int m_cr_direction; // direction of carriage - int m_pf_stepper_ratio0; - int m_pf_stepper_ratio1; - int m_cr_stepper_ratio0; - int m_cr_stepper_ratio1; - int m_xpos; - int m_ypos; - bitmap_rgb32 m_page_bitmap; // page bitmap -private: + bitmap_rgb32 m_page_bitmap; // page bitmap + static constexpr int PAPER_SCREEN_HEIGHT = 384; // match the height of the apple II driver static constexpr int m_distfrombottom = 50; // print position from bottom of screen + static constexpr int MAX_LEDS = 5; int m_printhead_color; int m_printhead_bordercolor; @@ -79,41 +101,13 @@ private: int m_vdpi; int m_clear_pos; int m_newpage_flag; // used to keep printhead at the top of page until actual printing - static constexpr int MAX_LEDS = 5; int m_led_state[MAX_LEDS]; int m_num_leds; + int m_pf_stepper_ratio0; + int m_pf_stepper_ratio1; + int m_cr_stepper_ratio0; + int m_cr_stepper_ratio1; -public: - - enum { LED_ERROR, LED_READY, LED_ONLINE }; - - void set_led_state(int led, int value) { m_led_state[led] = value; m_num_leds = std::max(m_num_leds, led); } - void set_printhead_color(int headcolor, int bordcolor); - void set_printhead_size(int xsize, int ysize, int bordersize); - void setheadpos(int x, int y){ if (m_xpos != x) m_newpage_flag = 0; m_xpos = x; m_ypos = y;} - - void write_snapshot_to_file(); - - void draw_pixel(int x, int y, int pixelval); - int get_pixel(int x, int y); - unsigned int& pix(int y, int x); - - void bitmap_clear_band(bitmap_rgb32 &bitmap, int from_line, int to_line, u32 color); - void bitmap_clear_band(int from_line, int to_line, u32 color); - void clear_to_pos(int to_line, u32 color = 0xffffff); - - int get_top_margin(); - int get_bottom_margin(); - bool check_new_page(); - - int update_stepper_delta(stepper_device * stepper, uint8_t pattern); - void update_cr_stepper(int pattern); - void update_pf_stepper(int pattern); - - void set_pf_stepper_ratio(int ratio0, int ratio1) { m_pf_stepper_ratio0 = ratio0; m_pf_stepper_ratio1 = ratio1;} - void set_cr_stepper_ratio(int ratio0, int ratio1) { m_cr_stepper_ratio0 = ratio0; m_cr_stepper_ratio1 = ratio1;} - -private: void draw_printhead(bitmap_rgb32 &bitmap, int x, int y); u32 dimcolor(u32 incolor, int factor);