Previous 15994 Revisions Next

r13227 Saturday 12th November, 2011 at 17:47:03 UTC by Sandro Ronco
iq151: improved MS151A/Minigraf emulation. (no whatsnew)
[src/mess/machine]iq151_minigraf.c iq151_minigraf.h iq151_ms151a.c iq151_ms151a.h

src/mess/machine/iq151_minigraf.c
r13226r13227
77#include "emu.h"
88#include "iq151_minigraf.h"
99
10#include "emuopts.h"
11#include "png.h"
1012
13// paper is A4 (297x210mm)
14#define PAPER_HEIGHT   (210*8)
15#define PAPER_WIDTH      (297*8)
16
17// usable area is 187.5x262.5mm step is 0.125mm
18#define PAPER_MAX_X         2100
19#define PAPER_MAX_Y         1500
20
21// dump the m_paper bitmap into a png
22#define DUMP_PAPER_INTO_PNG      0
23
1124/***************************************************************************
1225    IMPLEMENTATION
1326***************************************************************************/
r13226r13227
4558void iq151_minigraf_device::device_start()
4659{
4760   m_rom = (UINT8*)subregion("minigraf")->base();
61
62   // allocate a bitmap for represent the paper
63   m_paper = auto_bitmap_alloc(machine(), PAPER_WIDTH, PAPER_HEIGHT, BITMAP_FORMAT_INDEXED16);
64   bitmap_fill(m_paper, NULL , 0);
65
66   m_pen = 0;
67   m_posx = m_posy = 0;
4868}
4969
5070//-------------------------------------------------
71//  device_stop - clean up anything that needs to
72//  happen before the running_machine goes away
73//-------------------------------------------------
74
75void iq151_minigraf_device::device_stop()
76{
77#if DUMP_PAPER_INTO_PNG
78   emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
79   file_error filerr = file.open("iq151_minigraf.png");
80
81   if (filerr == FILERR_NONE)
82   {
83      static const rgb_t png_palette[] = { RGB_WHITE, RGB_BLACK };
84
85      // save the paper into a png
86      png_write_bitmap(file, NULL, m_paper, 2, png_palette);
87   }
88#endif
89}
90
91//-------------------------------------------------
5192//  rom_region - device-specific ROM region
5293//-------------------------------------------------
5394
r13226r13227
75116{
76117   if (offset >= 0xf0 && offset < 0xf4)
77118   {
78      // Plotter control lines
119      /*
120            Plotter control lines
121
122            ---- -xxx   horizontal step
123            --xx x---   vertical step
124            -x-- ----   ???
125            x--- ----   pen up/down
126        */
127
128      plotter_update(data);
79129   }
80130}
131
132
133//**************************************************************************
134//  Aritma MINIGRAF 0507
135//**************************************************************************
136
137inline int iq151_minigraf_device::get_direction(UINT8 old_val, UINT8 new_val)
138{
139   if (new_val == 0 && old_val == 7)   return +1;
140   if (new_val == 7 && old_val == 0)   return -1;
141
142   return (new_val - old_val);
143}
144
145void iq151_minigraf_device::plotter_update(UINT8 control)
146{
147   // update pen and paper positions
148   m_posx += get_direction(m_control & 7, control & 7);
149   m_posy += get_direction((m_control>>3) & 7, (control>>3) & 7);
150
151   // bit 7 is pen up/down
152   m_pen = BIT(control, 7);
153
154   // clamp within range
155   m_posx = MAX(m_posx, 0);
156   m_posx = MIN(m_posx, PAPER_MAX_X);
157   m_posy = MAX(m_posy, 0);
158   m_posy = MIN(m_posy, PAPER_MAX_Y);
159
160   // if pen is down draws a point
161   if (m_pen)
162      *BITMAP_ADDR16(m_paper, ((PAPER_HEIGHT-PAPER_MAX_Y)/2) + PAPER_MAX_Y - m_posy, ((PAPER_WIDTH-PAPER_MAX_X)/2) + m_posx) = 1;
163
164   m_control = control;
165}
src/mess/machine/iq151_minigraf.h
r13226r13227
2323   // optional information overrides
2424   virtual const rom_entry *device_rom_region() const;
2525
26
2726protected:
2827   // device-level overrides
2928   virtual void device_start();
29   virtual void device_stop();
3030   virtual void device_config_complete() { m_shortname = "iq151_minigraf"; }
3131
3232   // iq151cart_interface overrides
3333   virtual void read(offs_t offset, UINT8 &data);
3434   virtual void io_write(offs_t offset, UINT8 data);
3535
36   // Aritma MINIGRAF 0507
37   void plotter_update(UINT8 control);
38   int get_direction(UINT8 old_val, UINT8 new_val);
39
3640private:
3741
3842   UINT8 *      m_rom;
43   INT16      m_posx;
44   INT16      m_posy;
45   UINT8      m_pen;
46   UINT8      m_control;
47
48   bitmap_t *   m_paper;
3949};
4050
4151
src/mess/machine/iq151_ms151a.c
r13226r13227
77#include "emu.h"
88#include "iq151_ms151a.h"
99
10#include "emuopts.h"
11#include "png.h"
1012
13// paper is A4 (210x297mm)
14#define PAPER_HEIGHT   (210*10)
15#define PAPER_WIDTH      (297*10)
16
17// usable area is 175x250mm step is 0.1mm
18#define PAPER_MAX_X         (250*10)
19#define PAPER_MAX_Y         (175*10)
20
21// dump the m_paper bitmap into a png
22#define DUMP_PAPER_INTO_PNG      0
23
1124/***************************************************************************
1225    IMPLEMENTATION
1326***************************************************************************/
r13226r13227
4457void iq151_ms151a_device::device_start()
4558{
4659   m_rom = (UINT8*)subregion("ms151a")->base();
60
61   // allocate a bitmap for represent the paper
62   m_paper = auto_bitmap_alloc(machine(), PAPER_WIDTH, PAPER_HEIGHT, BITMAP_FORMAT_INDEXED16);
63   bitmap_fill(m_paper, NULL , 0);
64
65   m_pen = 0;
66   m_posx = m_posy = 0;
4767}
4868
4969//-------------------------------------------------
70//  device_stop - clean up anything that needs to
71//  happen before the running_machine goes away
72//-------------------------------------------------
73
74void iq151_ms151a_device::device_stop()
75{
76#if DUMP_PAPER_INTO_PNG
77   emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
78   file_error filerr = file.open("iq151_ms151a.png");
79
80   if (filerr == FILERR_NONE)
81   {
82      static const rgb_t png_palette[] = { RGB_WHITE, RGB_BLACK };
83
84      // save the paper into a png
85      png_write_bitmap(file, NULL, m_paper, 2, png_palette);
86   }
87#endif
88}
89
90//-------------------------------------------------
5091//  rom_region - device-specific ROM region
5192//-------------------------------------------------
5293
r13226r13227
72113
73114void iq151_ms151a_device::io_read(offs_t offset, UINT8 &data)
74115{
75
116   if (offset == 0xc4)
117      data = plotter_status();
76118}
77119
78120//-------------------------------------------------
r13226r13227
81123
82124void iq151_ms151a_device::io_write(offs_t offset, UINT8 data)
83125{
126   if (offset >= 0xc0 && offset <= 0xc4)
127      plotter_update(offset - 0xc0, data);
128}
84129
130
131//**************************************************************************
132//  XY 4130/4131
133//**************************************************************************
134
135UINT8 iq151_ms151a_device::plotter_status()
136{
137   /*
138        bit 7 - plotter READY line
139    */
140
141   return 0x80;
85142}
143
144void iq151_ms151a_device::plotter_update(UINT8 offset, UINT8 data)
145{
146   // update pen and paper positions
147   switch (offset)
148   {
149      case 0:      m_posx++;            break;
150      case 1:      m_posx--;            break;
151      case 2:      m_posy++;            break;
152      case 3:      m_posy--;            break;
153      case 4:      m_pen = data & 0x01;   break;
154   }
155
156   // clamp within range
157   m_posx = MAX(m_posx, 0);
158   m_posx = MIN(m_posx, PAPER_MAX_X);
159   m_posy = MAX(m_posy, 0);
160   m_posy = MIN(m_posy, PAPER_MAX_Y);
161
162   // if pen is down draws a point
163   if (m_pen)
164      *BITMAP_ADDR16(m_paper, ((PAPER_HEIGHT-PAPER_MAX_Y)/2) + PAPER_MAX_Y - m_posy, ((PAPER_WIDTH-PAPER_MAX_X)/2) + m_posx) = 1;
165}
src/mess/machine/iq151_ms151a.h
r13226r13227
2626protected:
2727   // device-level overrides
2828   virtual void device_start();
29   virtual void device_stop();
2930   virtual void device_config_complete() { m_shortname = "iq151_ms151a"; }
3031
3132   // iq151cart_interface overrides
r13226r13227
3334   virtual void io_read(offs_t offset, UINT8 &data);
3435   virtual void io_write(offs_t offset, UINT8 data);
3536
37   // XY 4130/4131
38   UINT8 plotter_status();
39   void plotter_update(UINT8 offset, UINT8 data);
40
3641private:
3742
3843   UINT8 *      m_rom;
44   INT32      m_posx;
45   INT32      m_posy;
46   UINT8      m_pen;
47
48   bitmap_t *   m_paper;
3949};
4050
4151

Previous 15994 Revisions Next


© 1998-2018 The MESS Team