src/mess/machine/upd65031.h
| r14677 | r14678 | |
| 29 | 29 | // TYPE DEFINITIONS |
| 30 | 30 | //************************************************************************** |
| 31 | 31 | |
| 32 | | typedef 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) |
| 32 | typedef 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) |
| 34 | 34 | |
| 35 | 35 | typedef void (*upd65031_memory_update_func)(device_t &device, int bank, UINT16 page, int rams); |
| 36 | 36 | #define UPD65031_MEMORY_UPDATE(name) void name(device_t &device, int bank, UINT16 page, int rams) |
| r14677 | r14678 | |
| 74 | 74 | inline void update_rtc_interrupt(); |
| 75 | 75 | inline void set_mode(int mode); |
| 76 | 76 | static const device_timer_id TIMER_RTC = 0; |
| 77 | static const device_timer_id TIMER_FLASH = 1; |
| 77 | 78 | |
| 78 | 79 | devcb_resolved_write_line m_out_int_func; |
| 79 | 80 | devcb_resolved_write_line m_out_nmi_func; |
| r14677 | r14678 | |
| 91 | 92 | UINT8 m_tmk; // timer interrupt mask |
| 92 | 93 | UINT8 m_tack; // timer interrupts acknowledge |
| 93 | 94 | UINT8 m_com; // command register |
| 95 | int m_flash; // cursor flash |
| 94 | 96 | |
| 95 | 97 | // timers |
| 96 | 98 | emu_timer *m_rtc_timer; |
| 99 | emu_timer *m_flash_timer; |
| 97 | 100 | }; |
| 98 | 101 | |
| 99 | 102 | |
src/mess/includes/z88.h
| r14677 | r14678 | |
| 15 | 15 | |
| 16 | 16 | #define Z88_NUM_COLOURS 3 |
| 17 | 17 | |
| 18 | | #define Z88_SCREEN_WIDTH 856 |
| 18 | #define Z88_SCREEN_WIDTH 640 |
| 19 | 19 | #define Z88_SCREEN_HEIGHT 64 |
| 20 | 20 | |
| 21 | 21 | #define Z88_SCR_HW_REV (1<<4) |
| r14677 | r14678 | |
| 23 | 23 | #define Z88_SCR_HW_UND (1<<1) |
| 24 | 24 | #define Z88_SCR_HW_FLS (1<<3) |
| 25 | 25 | #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) |
| 26 | 28 | |
| 27 | 29 | class z88_state : public driver_device |
| 28 | 30 | { |
| r14677 | r14678 | |
| 36 | 38 | required_device<cpu_device> m_maincpu; |
| 37 | 39 | required_device<device_t> m_speaker; |
| 38 | 40 | |
| 39 | | UINT8 m_frame_number; |
| 40 | | bool m_flash_invert; |
| 41 | | |
| 42 | 41 | virtual void machine_start(); |
| 43 | 42 | void bankswitch_update(int bank, UINT16 page, int rams); |
| 44 | 43 | 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); |
| 45 | 52 | }; |
| 46 | 53 | |
| 47 | 54 | |
| 48 | 55 | /*----------- defined in video/z88.c -----------*/ |
| 49 | 56 | |
| 50 | 57 | extern PALETTE_INIT( z88 ); |
| 51 | | extern UPD65031_SCREEN_UPDATE(z88_screen_update); |
| 52 | | extern SCREEN_VBLANK( z88 ); |
| 53 | 58 | |
| 54 | 59 | |
| 55 | 60 | #endif /* Z88_H_ */ |
src/mess/video/z88.c
| r14677 | r14678 | |
| 9 | 9 | #include "includes/z88.h" |
| 10 | 10 | |
| 11 | 11 | |
| 12 | | INLINE void z88_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) |
| 12 | inline void z88_state::plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT16 color) |
| 13 | 13 | { |
| 14 | | bitmap.pix16(y, x) = (UINT16)color; |
| 14 | if (x<Z88_SCREEN_WIDTH) |
| 15 | bitmap.pix16(y, x) = color; |
| 15 | 16 | } |
| 16 | 17 | |
| 18 | // convert absolute offset into correct address to get data from |
| 19 | inline UINT8* z88_state::convert_address(UINT32 offset) |
| 20 | { |
| 21 | return machine().region("maincpu")->base() + offset; |
| 22 | } |
| 23 | |
| 17 | 24 | /*************************************************************************** |
| 18 | 25 | Start the video hardware emulation. |
| 19 | 26 | ***************************************************************************/ |
| 20 | 27 | |
| 21 | | /* two colours */ |
| 22 | | static const unsigned short z88_colour_table[Z88_NUM_COLOURS] = |
| 23 | | { |
| 24 | | 0, 1, 2 |
| 25 | | }; |
| 26 | | |
| 27 | | /* black/white */ |
| 28 | | static 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 |
| 37 | 29 | PALETTE_INIT( z88 ) |
| 38 | 30 | { |
| 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)); |
| 40 | 34 | } |
| 41 | 35 | |
| 42 | 36 | /* temp - change to gfxelement structure */ |
| 43 | 37 | |
| 44 | | static void z88_vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, int pen0, int pen1, unsigned char *pData) |
| 38 | void z88_state::vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx) |
| 45 | 39 | { |
| 46 | | int h,b; |
| 47 | | |
| 48 | | for (h=0; h<8; h++) |
| 40 | for (int h=0; h<8; h++) |
| 49 | 41 | { |
| 50 | | UINT8 data; |
| 42 | UINT8 data = gfx[h]; |
| 51 | 43 | |
| 52 | | data = pData[h]; |
| 53 | | for (b=0; b<8; b++) |
| 44 | for (int b=0; b<8; b++) |
| 54 | 45 | { |
| 55 | | int pen; |
| 46 | plot_pixel(bitmap, x+b, y+h, (data & 0x80) ? pen1 : pen0); |
| 56 | 47 | |
| 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 | | |
| 68 | 48 | data = data<<1; |
| 69 | 49 | } |
| 70 | 50 | } |
| 71 | 51 | } |
| 72 | 52 | |
| 73 | | static void z88_vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, int pen0, int pen1, unsigned char *pData) |
| 53 | void z88_state::vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx) |
| 74 | 54 | { |
| 75 | | int h,b; |
| 76 | | |
| 77 | | for (h=0; h<8; h++) |
| 55 | for (int h=0; h<8; h++) |
| 78 | 56 | { |
| 79 | | UINT8 data; |
| 57 | UINT8 data = gfx[h]<<2; |
| 80 | 58 | |
| 81 | | data = pData[h]; |
| 82 | | data = data<<2; |
| 83 | | |
| 84 | | for (b=0; b<6; b++) |
| 59 | for (int b=0; b<6; b++) |
| 85 | 60 | { |
| 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); |
| 97 | 62 | data = data<<1; |
| 98 | 63 | } |
| 99 | | |
| 100 | | z88_plot_pixel(bitmap,x,y+h, pen0); |
| 101 | | z88_plot_pixel(bitmap,x+7,y+h, pen0); |
| 102 | 64 | } |
| 103 | 65 | } |
| 104 | 66 | |
| 105 | | static void z88_vh_render_line(bitmap_ind16 &bitmap, int x, int y,int pen) |
| 67 | void z88_state::vh_render_line(bitmap_ind16 &bitmap, int x, int y, UINT16 pen) |
| 106 | 68 | { |
| 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); |
| 115 | 71 | } |
| 116 | 72 | |
| 117 | | /* convert absolute offset into correct address to get data from */ |
| 118 | | static unsigned char *z88_convert_address(running_machine &machine, unsigned long offset) |
| 73 | void z88_state::lcd_update(bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1, int flash) |
| 119 | 74 | { |
| 120 | | return machine.region("maincpu")->base() + offset; |
| 121 | | } |
| 122 | | |
| 123 | | |
| 124 | | SCREEN_VBLANK( z88 ) |
| 125 | | { |
| 126 | | // rising edge |
| 127 | | if (vblank_on) |
| 75 | if (sbf == 0) |
| 128 | 76 | { |
| 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); |
| 136 | 79 | } |
| 137 | | } |
| 138 | | |
| 139 | | |
| 140 | | UPD65031_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 |
| 148 | 81 | { |
| 149 | | ptr = stored_ptr; |
| 82 | UINT8 *vram = convert_address(sbf<<11); |
| 150 | 83 | |
| 151 | | for (x=0; x<(Z88_SCREEN_WIDTH>>3); x++) |
| 84 | for (int y=0; y<(Z88_SCREEN_HEIGHT>>3); y++) |
| 152 | 85 | { |
| 153 | | int ch; |
| 86 | int x = 0, c = 0; |
| 154 | 87 | |
| 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) |
| 163 | 89 | { |
| 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]; |
| 165 | 94 | |
| 166 | | if (byte1 & Z88_SCR_HW_GRY) |
| 95 | // inverted graphics? |
| 96 | if (byte1 & Z88_SCR_HW_REV) |
| 167 | 97 | { |
| 168 | | pen0 = 2; |
| 98 | pen0 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1; |
| 99 | pen1 = 0; |
| 169 | 100 | } |
| 170 | 101 | else |
| 171 | 102 | { |
| 172 | | pen0 = 1; |
| 103 | pen0 = 0; |
| 104 | pen1 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1; |
| 173 | 105 | } |
| 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) |
| 179 | 108 | { |
| 180 | | pen1 = 2; |
| 109 | // hidden |
| 181 | 110 | } |
| 182 | | else |
| 111 | else if (!(byte1 & Z88_SCR_HW_HRS) || (((byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS))) |
| 183 | 112 | { |
| 184 | | pen1 = 1; |
| 185 | | } |
| 186 | | } |
| 113 | // low-res 6x8 |
| 114 | UINT16 ch = (byte0 | (byte1<<8)) & 0x1ff; |
| 187 | 115 | |
| 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) |
| 206 | 117 | { |
| 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); |
| 209 | 121 | } |
| 210 | 122 | else |
| 211 | 123 | { |
| 212 | | ch_index = ch & 0x0ff; |
| 213 | | pCharGfx = z88_convert_address(device.machine(), hires0<<13); |
| 124 | char_gfx = convert_address(lores1<<12); |
| 214 | 125 | } |
| 215 | 126 | |
| 216 | | pCharGfx += (ch_index<<3); |
| 127 | char_gfx += (ch<<3); |
| 217 | 128 | |
| 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); |
| 224 | 134 | |
| 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); |
| 226 | 138 | |
| 227 | | if ((ch & 0x01c0)==0x01c0) |
| 228 | | { |
| 229 | | ch_index = ch & (~0x01c0); |
| 230 | | |
| 231 | | pCharGfx = z88_convert_address(device.machine(), lores0<<9); |
| 139 | x += 6; |
| 232 | 140 | } |
| 233 | | else |
| 141 | else if ((byte1 & Z88_SCR_HW_HRS) && !(byte1 & Z88_SCR_HW_REV)) |
| 234 | 142 | { |
| 235 | | ch_index = ch; |
| 143 | // high-res 8x8 |
| 144 | UINT16 ch = (byte0 | (byte1<<8)) & 0x3ff; |
| 236 | 145 | |
| 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 | } |
| 239 | 156 | |
| 240 | | pCharGfx += (ch_index<<3); |
| 157 | char_gfx += (ch<<3); |
| 241 | 158 | |
| 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; |
| 243 | 162 | |
| 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; |
| 248 | 166 | } |
| 249 | | } |
| 250 | 167 | |
| 251 | | |
| 252 | | |
| 168 | // every char takes 2 bytes |
| 169 | c += 2; |
| 170 | } |
| 253 | 171 | } |
| 254 | | |
| 255 | | stored_ptr+=256; |
| 256 | 172 | } |
| 257 | 173 | } |