Previous 15994 Revisions Next

r14678 Thursday 1st March, 2012 at 21:04:11 UTC by Sandro Ronco
Z88: fixed screen size, added cursor and some other cleanups. (no whatsnew)
[src/mess/drivers]z88.c
[src/mess/includes]z88.h
[src/mess/machine]upd65031.c upd65031.h
[src/mess/video]z88.c

src/mess/machine/upd65031.c
r14677r14678
238238
239239   // allocate timers
240240   m_rtc_timer = timer_alloc(TIMER_RTC);
241   m_flash_timer = timer_alloc(TIMER_FLASH);
241242   m_rtc_timer->adjust(attotime::from_msec(5), 0, attotime::from_msec(5));
243   m_flash_timer->adjust(attotime::from_hz(2), 0, attotime::from_hz(2));
242244
243245   // state saving
244246   save_item(NAME(m_mode));
r14677r14678
252254   save_item(NAME(m_tmk));
253255   save_item(NAME(m_tack));
254256   save_item(NAME(m_com));
257   save_item(NAME(m_flash));
255258}
256259
257260
r14677r14678
271274   m_tmk = TSTA_TICK | TSTA_SEC | TSTA_MIN;
272275   m_tack = 0;
273276   m_com = 0;
277   m_flash = 0;
274278   set_mode(STATE_AWAKE);
275279
276280   if (m_out_mem_cb)
r14677r14678
379383         interrupt_refresh();
380384      }
381385      break;
386   case TIMER_FLASH:
387      m_flash = !m_flash;
388      break;
382389   }
383390}
384391
r14677r14678
390397UINT32 upd65031_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
391398{
392399   if (m_screen_update_cb)
393      (m_screen_update_cb)(*this, bitmap, m_lcd_regs[4], m_lcd_regs[2], m_lcd_regs[3], m_lcd_regs[0], m_lcd_regs[1]);
400      (m_screen_update_cb)(*this, bitmap, m_lcd_regs[4], m_lcd_regs[2], m_lcd_regs[3], m_lcd_regs[0], m_lcd_regs[1], m_flash);
394401
395402   return 0;
396403}
src/mess/machine/upd65031.h
r14677r14678
2929//  TYPE DEFINITIONS
3030//**************************************************************************
3131
32typedef void (*upd65031_screen_update_func)(device_t &device, bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1);
33#define UPD65031_SCREEN_UPDATE(name) void name(device_t &device, bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1)
32typedef void (*upd65031_screen_update_func)(device_t &device, bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1, int flash);
33#define UPD65031_SCREEN_UPDATE(name) void name(device_t &device, bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1, int flash)
3434
3535typedef void (*upd65031_memory_update_func)(device_t &device, int bank, UINT16 page, int rams);
3636#define UPD65031_MEMORY_UPDATE(name) void name(device_t &device, int bank, UINT16 page, int rams)
r14677r14678
7474   inline void update_rtc_interrupt();
7575   inline void set_mode(int mode);
7676   static const device_timer_id TIMER_RTC = 0;
77   static const device_timer_id TIMER_FLASH = 1;
7778
7879   devcb_resolved_write_line   m_out_int_func;
7980   devcb_resolved_write_line   m_out_nmi_func;
r14677r14678
9192   UINT8   m_tmk;            // timer interrupt mask
9293   UINT8   m_tack;            // timer interrupts acknowledge
9394   UINT8   m_com;            // command register
95   int      m_flash;         // cursor flash
9496
9597   // timers
9698   emu_timer *m_rtc_timer;
99   emu_timer *m_flash_timer;
97100};
98101
99102
src/mess/includes/z88.h
r14677r14678
1515
1616#define Z88_NUM_COLOURS 3
1717
18#define Z88_SCREEN_WIDTH        856
18#define Z88_SCREEN_WIDTH        640
1919#define Z88_SCREEN_HEIGHT       64
2020
2121#define Z88_SCR_HW_REV  (1<<4)
r14677r14678
2323#define Z88_SCR_HW_UND  (1<<1)
2424#define Z88_SCR_HW_FLS  (1<<3)
2525#define Z88_SCR_HW_GRY  (1<<2)
26#define Z88_SCR_HW_CURS (Z88_SCR_HW_HRS|Z88_SCR_HW_FLS|Z88_SCR_HW_REV)
27#define Z88_SCR_HW_NULL (Z88_SCR_HW_HRS|Z88_SCR_HW_GRY|Z88_SCR_HW_REV)
2628
2729class z88_state : public driver_device
2830{
r14677r14678
3638   required_device<cpu_device> m_maincpu;
3739   required_device<device_t> m_speaker;
3840
39   UINT8 m_frame_number;
40   bool m_flash_invert;
41
4241   virtual void machine_start();
4342   void bankswitch_update(int bank, UINT16 page, int rams);
4443   DECLARE_READ8_MEMBER(kb_r);
44
45   // defined in video/z88.c
46   inline void plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT16 color);
47   inline UINT8* convert_address(UINT32 offset);
48   void vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx);
49   void vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx);
50   void vh_render_line(bitmap_ind16 &bitmap, int x, int y, UINT16 pen);
51   void lcd_update(bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1, int flash);
4552};
4653
4754
4855/*----------- defined in video/z88.c -----------*/
4956
5057extern PALETTE_INIT( z88 );
51extern UPD65031_SCREEN_UPDATE(z88_screen_update);
52extern SCREEN_VBLANK( z88 );
5358
5459
5560#endif /* Z88_H_ */
src/mess/video/z88.c
r14677r14678
99#include "includes/z88.h"
1010
1111
12INLINE void z88_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color)
12inline void z88_state::plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT16 color)
1313{
14   bitmap.pix16(y, x) = (UINT16)color;
14   if (x<Z88_SCREEN_WIDTH)
15      bitmap.pix16(y, x) = color;
1516}
1617
18// convert absolute offset into correct address to get data from
19inline UINT8* z88_state::convert_address(UINT32 offset)
20{
21   return machine().region("maincpu")->base() + offset;
22}
23
1724/***************************************************************************
1825  Start the video hardware emulation.
1926***************************************************************************/
2027
21/* two colours */
22static const unsigned short z88_colour_table[Z88_NUM_COLOURS] =
23{
24   0, 1, 2
25};
26
27/* black/white */
28static const rgb_t z88_palette[Z88_NUM_COLOURS] =
29{
30   MAKE_RGB(0x000, 0x000, 0x000),
31   MAKE_RGB(0x0ff, 0x0ff, 0x0ff),
32   MAKE_RGB(0x080, 0x080, 0x080)
33};
34
35
36/* Initialise the palette */
28// Initialise the palette
3729PALETTE_INIT( z88 )
3830{
39   palette_set_colors(machine, 0, z88_palette, ARRAY_LENGTH(z88_palette));
31   palette_set_color(machine, 0, MAKE_RGB(138, 146, 148));
32   palette_set_color(machine, 1, MAKE_RGB(92,  83,  88));
33   palette_set_color(machine, 2, MAKE_RGB(122, 126, 129));
4034}
4135
4236/* temp - change to gfxelement structure */
4337
44static void z88_vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, int pen0, int pen1, unsigned char *pData)
38void z88_state::vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx)
4539{
46   int h,b;
47
48   for (h=0; h<8; h++)
40   for (int h=0; h<8; h++)
4941   {
50      UINT8 data;
42      UINT8 data = gfx[h];
5143
52      data = pData[h];
53      for (b=0; b<8; b++)
44      for (int b=0; b<8; b++)
5445      {
55         int pen;
46         plot_pixel(bitmap, x+b, y+h, (data & 0x80) ? pen1 : pen0);
5647
57         if (data & 0x080)
58         {
59            pen = pen1;
60         }
61         else
62         {
63            pen = pen0;
64         }
65
66         z88_plot_pixel(bitmap, x+b, y+h, pen);
67
6848         data = data<<1;
6949      }
7050   }
7151}
7252
73static void z88_vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, int pen0, int pen1, unsigned char *pData)
53void z88_state::vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx)
7454{
75   int h,b;
76
77   for (h=0; h<8; h++)
55   for (int h=0; h<8; h++)
7856   {
79      UINT8 data;
57      UINT8 data = gfx[h]<<2;
8058
81      data = pData[h];
82      data = data<<2;
83
84      for (b=0; b<6; b++)
59      for (int b=0; b<6; b++)
8560      {
86         int pen;
87         if (data & 0x080)
88         {
89            pen = pen1;
90         }
91         else
92         {
93            pen = pen0;
94         }
95
96         z88_plot_pixel(bitmap, x+1+b, y+h, pen);
61         plot_pixel(bitmap, x+1+b, y+h, (data & 0x80) ? pen1 : pen0);
9762         data = data<<1;
9863      }
99
100      z88_plot_pixel(bitmap,x,y+h, pen0);
101      z88_plot_pixel(bitmap,x+7,y+h, pen0);
10264   }
10365}
10466
105static void z88_vh_render_line(bitmap_ind16 &bitmap, int x, int y,int pen)
67void z88_state::vh_render_line(bitmap_ind16 &bitmap, int x, int y, UINT16 pen)
10668{
107   z88_plot_pixel(bitmap, x, y+7, pen);
108   z88_plot_pixel(bitmap, x+1, y+7, pen);
109   z88_plot_pixel(bitmap, x+2, y+7, pen);
110   z88_plot_pixel(bitmap, x+3, y+7, pen);
111   z88_plot_pixel(bitmap, x+4, y+7, pen);
112   z88_plot_pixel(bitmap, x+5, y+7, pen);
113   z88_plot_pixel(bitmap, x+6, y+7, pen);
114   z88_plot_pixel(bitmap, x+7, y+7, pen);
69   for (int i=0; i<8; i++)
70      plot_pixel(bitmap, x + i, y + 7, pen);
11571}
11672
117/* convert absolute offset into correct address to get data from */
118static unsigned char *z88_convert_address(running_machine &machine, unsigned long offset)
73void z88_state::lcd_update(bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1, int flash)
11974{
120   return machine.region("maincpu")->base() + offset;
121}
122
123
124SCREEN_VBLANK( z88 )
125{
126   // rising edge
127   if (vblank_on)
75   if (sbf == 0)
12876   {
129      z88_state *state = screen.machine().driver_data<z88_state>();
130      state->m_frame_number++;
131      if (state->m_frame_number >= 50)
132      {
133         state->m_frame_number = 0;
134         state->m_flash_invert = !state->m_flash_invert;
135      }
77      // LCD disabled
78      bitmap.fill(0);
13679   }
137}
138
139
140UPD65031_SCREEN_UPDATE(z88_screen_update)
141{
142   int x,y;
143   unsigned char *ptr = z88_convert_address(device.machine(), sbf<<11);
144   unsigned char *stored_ptr = ptr;
145   int pen0, pen1;
146
147   for (y=0; y<(Z88_SCREEN_HEIGHT>>3); y++)
80   else
14881   {
149      ptr = stored_ptr;
82      UINT8 *vram = convert_address(sbf<<11);
15083
151      for (x=0; x<(Z88_SCREEN_WIDTH>>3); x++)
84      for (int y=0; y<(Z88_SCREEN_HEIGHT>>3); y++)
15285      {
153         int ch;
86         int x = 0, c = 0;
15487
155         UINT8 byte0, byte1;
156
157         byte0 = ptr[0];
158         byte1 = ptr[1];
159         ptr+=2;
160
161         /* inverted graphics? */
162         if (byte1 & Z88_SCR_HW_REV)
88         while (x < Z88_SCREEN_WIDTH)
16389         {
164            pen1 = 0;
90            UINT16 pen0, pen1;
91            UINT8 *char_gfx;
92            UINT8 byte0 = vram[(y * 0x100) + c];
93            UINT8 byte1 = vram[(y * 0x100) + c + 1];
16594
166            if (byte1 & Z88_SCR_HW_GRY)
95            // inverted graphics?
96            if (byte1 & Z88_SCR_HW_REV)
16797            {
168               pen0 = 2;
98               pen0 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1;
99               pen1 = 0;
169100            }
170101            else
171102            {
172               pen0 = 1;
103               pen0 = 0;
104               pen1 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1;
173105            }
174         }
175         else
176         {
177            pen0 = 0;
178            if (byte1 & Z88_SCR_HW_GRY)
106
107            if ((byte1 & Z88_SCR_HW_NULL) == Z88_SCR_HW_NULL)
179108            {
180               pen1 = 2;
109               // hidden
181110            }
182            else
111            else if (!(byte1 & Z88_SCR_HW_HRS) || (((byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS)))
183112            {
184               pen1 = 1;
185            }
186         }
113               // low-res 6x8
114               UINT16 ch = (byte0 | (byte1<<8)) & 0x1ff;
187115
188//          if (byte1 & Z88_SCR_HW_FLS)
189//          {
190//              if (state->m_flash_invert)
191//              {
192//                  pen1 = pen0;
193//              }
194//          }
195
196
197         /* hi-res? */
198         if (byte1 & Z88_SCR_HW_HRS)
199         {
200               int ch_index;
201               unsigned char *pCharGfx;
202
203               ch = (byte0 & 0x0ff) | ((byte1 & 0x01)<<8);
204
205               if (ch & 0x0100)
116               if ((ch & 0x01c0) == 0x01c0)
206117               {
207                  ch_index =ch & 0x0ff;   //(~0x0100);
208                  pCharGfx = z88_convert_address(device.machine(), hires1<<11);
118                  ch &= 0x3f;
119
120                  char_gfx = convert_address(lores0<<9);
209121               }
210122               else
211123               {
212                  ch_index = ch & 0x0ff;
213                  pCharGfx = z88_convert_address(device.machine(), hires0<<13);
124                  char_gfx = convert_address(lores1<<12);
214125               }
215126
216               pCharGfx += (ch_index<<3);
127               char_gfx += (ch<<3);
217128
218            z88_vh_render_8x8(bitmap, (x<<3),(y<<3), pen0, pen1, pCharGfx);
219         }
220         else
221         {
222            unsigned char *pCharGfx;
223            int ch_index;
129               // cursor flash
130               if (flash && (byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS)
131                  vh_render_6x8(bitmap, x,(y<<3), pen1, pen0, char_gfx);
132               else
133                  vh_render_6x8(bitmap, x,(y<<3), pen0, pen1, char_gfx);
224134
225            ch = (byte0 & 0x0ff) | ((byte1 & 0x01)<<8);
135               // underline?
136               if (byte1 & Z88_SCR_HW_UND)
137                  vh_render_line(bitmap, x, (y<<3), pen1);
226138
227            if ((ch & 0x01c0)==0x01c0)
228            {
229               ch_index = ch & (~0x01c0);
230
231               pCharGfx = z88_convert_address(device.machine(), lores0<<9);
139               x += 6;
232140            }
233            else
141            else if ((byte1 & Z88_SCR_HW_HRS) && !(byte1 & Z88_SCR_HW_REV))
234142            {
235               ch_index = ch;
143               // high-res 8x8
144               UINT16 ch = (byte0 | (byte1<<8)) & 0x3ff;
236145
237               pCharGfx = z88_convert_address(device.machine(), lores1<<12);
238            }
146               if (ch & 0x0100)
147               {
148                  ch &= 0xff;
149                  char_gfx = convert_address(hires1<<11);
150               }
151               else
152               {
153                  ch &= 0x7f;
154                  char_gfx = convert_address(hires0<<13);
155               }
239156
240            pCharGfx += (ch_index<<3);
157               char_gfx += (ch<<3);
241158
242            z88_vh_render_6x8(bitmap, (x<<3),(y<<3), pen0,pen1,pCharGfx);
159               // flash
160               if ((byte1 & Z88_SCR_HW_FLS) && flash)
161                  pen0 = pen1 = 0;
243162
244            /* underline? */
245            if (byte1 & Z88_SCR_HW_UND)
246            {
247               z88_vh_render_line(bitmap, (x<<3), (y<<3), pen1);
163               vh_render_8x8(bitmap, x,(y<<3), pen0, pen1, char_gfx);
164
165               x += 8;
248166            }
249         }
250167
251
252
168            // every char takes 2 bytes
169            c += 2;
170         }
253171      }
254
255      stored_ptr+=256;
256172   }
257173}
src/mess/drivers/z88.c
r14677r14678
77        system driver
88
99        TODO:
10        - screen should be 640x64
1110        - speaker controlled by constant tone or txd
1211        - Facility to load games
1312        - expansion interface
r14677r14678
259258   state->bankswitch_update(bank, page, rams);
260259}
261260
261static UPD65031_SCREEN_UPDATE(z88_screen_update)
262{
263   z88_state *state = device.machine().driver_data<z88_state>();
264   state->lcd_update(bitmap, sbf, hires0, hires1, lores0, lores1, flash);
265}
262266
263267static UPD65031_INTERFACE( z88_blink_intf )
264268{
r14677r14678
285289   MCFG_SCREEN_SIZE(Z88_SCREEN_WIDTH, Z88_SCREEN_HEIGHT)
286290   MCFG_SCREEN_VISIBLE_AREA(0, (Z88_SCREEN_WIDTH - 1), 0, (Z88_SCREEN_HEIGHT - 1))
287291   MCFG_SCREEN_UPDATE_DEVICE("blink", upd65031_device, screen_update)
288   MCFG_SCREEN_VBLANK_STATIC( z88 )
289292
290293   MCFG_PALETTE_LENGTH(Z88_NUM_COLOURS)
291294   MCFG_PALETTE_INIT( z88 )
r14677r14678
308311***************************************************************************/
309312
310313ROM_START(z88)
311   ROM_REGION(0x400000, "maincpu", ROMREGION_ERASE00)
314   ROM_REGION(0x100000, "maincpu", ROMREGION_ERASE00)
312315   ROM_DEFAULT_BIOS("ver4")
313316   ROM_SYSTEM_BIOS( 0, "ver3", "Version 3.0 UK")
314317   ROMX_LOAD("z88v300.rom" ,  0x00000, 0x20000, CRC(802cb9aa) SHA1(ceb688025b79454cf229cae4dbd0449df2747f79), ROM_BIOS(1) )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team