diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2013-04-18 10:18:52 +0000 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2013-04-18 10:18:52 +0000 |
commit | 2733f3422b2f5acbce086c28df32bdacb7b16c1a (patch) | |
tree | 0be533c7cd18cd9448373405a2f46a9ffbe9faaa /src/mess | |
parent | 060f4759708b3c8974645d4022aef9327231ada8 (diff) |
lynx and bbc cleanup (nw)
Diffstat (limited to 'src/mess')
-rw-r--r-- | src/mess/audio/lynx.c | 4 | ||||
-rw-r--r-- | src/mess/drivers/lynx.c | 2 | ||||
-rw-r--r-- | src/mess/includes/bbc.h | 2 | ||||
-rw-r--r-- | src/mess/includes/lynx.h | 21 | ||||
-rw-r--r-- | src/mess/machine/lynx.c | 604 | ||||
-rw-r--r-- | src/mess/video/bbc.c | 309 |
6 files changed, 325 insertions, 617 deletions
diff --git a/src/mess/audio/lynx.c b/src/mess/audio/lynx.c index 1376c101075..ada0feac08d 100644 --- a/src/mess/audio/lynx.c +++ b/src/mess/audio/lynx.c @@ -178,13 +178,13 @@ static void lynx_audio_shift(device_t *device, LYNX_AUDIO *channel) if(out_temp < -128) out_temp = -128; channel->reg.output = (INT16)out_temp; } - + lynx_state *drvstate = device->machine().driver_data<lynx_state>(); switch (channel_number) { case 0: lynx_audio_count_down(device, 1); break; case 1: lynx_audio_count_down(device, 2); break; case 2: lynx_audio_count_down(device, 3); break; - case 3: lynx_timer_count_down(device->machine(), 1); break; + case 3: drvstate->lynx_timer_count_down(1); break; default: logerror("Invalid channel number %d\n", channel_number); break; } } diff --git a/src/mess/drivers/lynx.c b/src/mess/drivers/lynx.c index 75662085cf5..3e86b94f974 100644 --- a/src/mess/drivers/lynx.c +++ b/src/mess/drivers/lynx.c @@ -149,7 +149,7 @@ static QUICKLOAD_LOAD( lynx ) return IMAGE_INIT_FAIL; /* Check the image */ - if (lynx_verify_cart((char*)header, LYNX_QUICKLOAD) == IMAGE_VERIFY_FAIL) + if (state->lynx_verify_cart((char*)header, LYNX_QUICKLOAD) == IMAGE_VERIFY_FAIL) return IMAGE_INIT_FAIL; start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu diff --git a/src/mess/includes/bbc.h b/src/mess/includes/bbc.h index 4499f6c2ff3..ba11b034d8d 100644 --- a/src/mess/includes/bbc.h +++ b/src/mess/includes/bbc.h @@ -356,6 +356,8 @@ protected: void MC6850_Receive_Clock(int new_clock); void BBC_Cassette_motor(unsigned char status); void bbc_update_fdq_int(int state); +public: + unsigned int calculate_video_address(int ma,int ra); }; diff --git a/src/mess/includes/lynx.h b/src/mess/includes/lynx.h index 31179009587..47f7233c1b5 100644 --- a/src/mess/includes/lynx.h +++ b/src/mess/includes/lynx.h @@ -130,6 +130,7 @@ public: DECLARE_READ8_MEMBER(suzy_read); DECLARE_WRITE8_MEMBER(suzy_write); DECLARE_WRITE8_MEMBER(lynx_uart_w); + DECLARE_READ8_MEMBER(lynx_uart_r); DECLARE_READ8_MEMBER(mikey_read); DECLARE_WRITE8_MEMBER(mikey_write); DECLARE_READ8_MEMBER(lynx_memory_config_r); @@ -148,17 +149,25 @@ public: void lynx_postload(); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( lynx_cart ); required_device<cpu_device> m_maincpu; + UINT8 lynx_read_ram(UINT16 address); + void lynx_write_ram(UINT16 address, UINT8 data); + inline void lynx_plot_pixel(const int mode, const INT16 x, const int y, const int color); + void lynx_blit_do_work(const int y, const int xdir, const int bits_per_pixel, const int mask ); + void lynx_blit_rle_do_work( const INT16 y, const int xdir, const int bits_per_pixel, const int mask ); + void lynx_blit_lines(); + void lynx_blitter(); + void lynx_draw_line(); + void lynx_timer_init(int which); + void lynx_timer_signal_irq(int which); + void lynx_timer_count_down(int which); + UINT32 lynx_time_factor(int val); + void lynx_uart_reset(); + int lynx_verify_cart (char *header, int kind); }; /*----------- defined in machine/lynx.c -----------*/ -void lynx_timer_count_down(running_machine &machine, int nr); - -/* These functions are also needed for the Quickload */ -int lynx_verify_cart (char *header, int kind); -void lynx_crc_keyword(device_image_interface &image); - MACHINE_CONFIG_EXTERN( lynx_cartslot ); diff --git a/src/mess/machine/lynx.c b/src/mess/machine/lynx.c index bc49d8f87a2..8c88eb42d82 100644 --- a/src/mess/machine/lynx.c +++ b/src/mess/machine/lynx.c @@ -47,34 +47,34 @@ enum { SHADOW }; -static UINT8 lynx_read_ram(lynx_state *state, UINT16 address) +UINT8 lynx_state::lynx_read_ram(UINT16 address) { UINT8 result = 0x00; if (address <= 0xfbff) - result = state->m_mem_0000[address - 0x0000]; + result = m_mem_0000[address - 0x0000]; else if (address <= 0xfcff) - result = state->m_mem_fc00[address - 0xfc00]; + result = m_mem_fc00[address - 0xfc00]; else if (address <= 0xfdff) - result = state->m_mem_fd00[address - 0xfd00]; + result = m_mem_fd00[address - 0xfd00]; else if (address <= 0xfff7) - result = state->m_mem_fe00[address - 0xfe00]; + result = m_mem_fe00[address - 0xfe00]; else if (address >= 0xfffa) - result = state->m_mem_fffa[address - 0xfffa]; + result = m_mem_fffa[address - 0xfffa]; return result; } -static void lynx_write_ram(lynx_state *state, UINT16 address, UINT8 data) +void lynx_state::lynx_write_ram(UINT16 address, UINT8 data) { if (address <= 0xfbff) - state->m_mem_0000[address - 0x0000] = data; + m_mem_0000[address - 0x0000] = data; else if (address <= 0xfcff) - state->m_mem_fc00[address - 0xfc00] = data; + m_mem_fc00[address - 0xfc00] = data; else if (address <= 0xfdff) - state->m_mem_fd00[address - 0xfd00] = data; + m_mem_fd00[address - 0xfd00] = data; else if (address <= 0xfff7) - state->m_mem_fe00[address - 0xfe00] = data; + m_mem_fe00[address - 0xfe00] = data; else if (address >= 0xfffa) - state->m_mem_fffa[address - 0xfffa] = data; + m_mem_fffa[address - 0xfffa] = data; } /* The pen numbers range from '0' to 'F. Pen numbers '1' through 'D' are always collidable and opaque. The other @@ -105,15 +105,15 @@ The sprite types relate to specific hardware functions according to the followin 0 0 0 0 0 0 0 1 exclusive-or the data */ -INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, const int y, const int color) +inline void lynx_state::lynx_plot_pixel(const int mode, const INT16 x, const int y, const int color) { UINT8 back; UINT16 screen; UINT16 colbuf; - state->m_blitter.everon = TRUE; - screen = state->m_blitter.screen + y * 80 + x / 2; - colbuf = state->m_blitter.colbuf + y * 80 + x / 2; + m_blitter.everon = TRUE; + screen = m_blitter.screen + y * 80 + x / 2; + colbuf = m_blitter.colbuf + y * 80 + x / 2; /* a note on timing: The hardware packs the pixel data and updates the screen and collision buffer a byte at a time. Thus the buffer update for two pixels takes 3 memory accesses for a normal sprite (write to screen buffer, read/write to collision buffer). @@ -129,31 +129,31 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co break; if (!(x & 0x01)) /* Upper nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; - if(state->m_blitter.sprite_collide && !(state->m_blitter.no_collide)) + if(m_blitter.sprite_collide && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0xf0) | (state->m_blitter.spritenr << 4)); - state->m_blitter.memory_accesses += 2; - if ((back >> 4) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4)); + m_blitter.memory_accesses += 2; + if ((back >> 4) > m_blitter.fred) + m_blitter.fred = back >> 4; } - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); - if(state->m_blitter.sprite_collide && !(state->m_blitter.no_collide)) + if(m_blitter.sprite_collide && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0x0f) | (state->m_blitter.spritenr)); - if ((back & 0x0f) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr)); + if ((back & 0x0f) > m_blitter.fred) + m_blitter.fred = back >> 4; } } break; @@ -167,33 +167,33 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co { if (color != 0x0f) { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; } - if(state->m_blitter.sprite_collide && !(state->m_blitter.no_collide)) + if(m_blitter.sprite_collide && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0xf0) | (state->m_blitter.spritenr << 4)); - if ((back >> 4) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; - state->m_blitter.memory_accesses += 2; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4)); + if ((back >> 4) > m_blitter.fred) + m_blitter.fred = back >> 4; + m_blitter.memory_accesses += 2; } - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { if (color != 0x0f) { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); } - if(state->m_blitter.sprite_collide && !(state->m_blitter.no_collide)) + if(m_blitter.sprite_collide && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0x0f) | (state->m_blitter.spritenr)); - if ((back & 0x0f) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr)); + if ((back & 0x0f) > m_blitter.fred) + m_blitter.fred = back >> 4; } } break; @@ -205,31 +205,31 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co break; if (!(x & 0x01)) /* Upper nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0xf0) | (state->m_blitter.spritenr << 4)); - if ((back >> 4) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; - state->m_blitter.memory_accesses += 2; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4)); + if ((back >> 4) > m_blitter.fred) + m_blitter.fred = back >> 4; + m_blitter.memory_accesses += 2; } - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0x0f) | (state->m_blitter.spritenr)); - if ((back & 0x0f) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr)); + if ((back & 0x0f) > m_blitter.fred) + m_blitter.fred = back >> 4; } } break; @@ -244,33 +244,33 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co { if (color != 0x0f) { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; } - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0xf0) | (state->m_blitter.spritenr << 4)); - if ((back >> 4) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; - state->m_blitter.memory_accesses += 2; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4)); + if ((back >> 4) > m_blitter.fred) + m_blitter.fred = back >> 4; + m_blitter.memory_accesses += 2; } - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { if (color != 0x0f) { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); } - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0x0f) | (state->m_blitter.spritenr)); - if ((back & 0x0f) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr)); + if ((back & 0x0f) > m_blitter.fred) + m_blitter.fred = back >> 4; } } break; @@ -283,27 +283,27 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co and therefore not clear the collision buffer */ if (!(x & 0x01)) /* Upper nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0xf0) | (state->m_blitter.spritenr << 4)); - state->m_blitter.memory_accesses++; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4)); + m_blitter.memory_accesses++; } - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0x0f) | (state->m_blitter.spritenr)); + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr)); } } break; @@ -312,15 +312,15 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co /* This is a 'background' sprite with the exception that no activity occurs in the collision buffer */ if (!(x & 0x01)) /* Upper nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); } break; @@ -331,15 +331,15 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co break; if (!(x & 0x01)) /* Upper nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0x0f) | (color << 4)); - state->m_blitter.memory_accesses++; - state->m_blitter.memory_accesses++; + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0x0f) | (color << 4)); + m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, (back & 0xf0) | color); + back = lynx_read_ram(screen); + lynx_write_ram(screen, (back & 0xf0) | color); } break; @@ -352,60 +352,60 @@ INLINE void lynx_plot_pixel(lynx_state *state, const int mode, const INT16 x, co break; if (!(x & 0x01)) /* Upper nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, back^(color << 4)); - state->m_blitter.memory_accesses += 2; - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + back = lynx_read_ram(screen); + lynx_write_ram(screen, back^(color << 4)); + m_blitter.memory_accesses += 2; + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0xf0) | (state->m_blitter.spritenr << 4)); - if ((back >> 4) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; - state->m_blitter.memory_accesses += 2; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4)); + if ((back >> 4) > m_blitter.fred) + m_blitter.fred = back >> 4; + m_blitter.memory_accesses += 2; } - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; } else /* Lower nibble */ { - back = lynx_read_ram(state, screen); - lynx_write_ram(state, screen, back^color); - if (state->m_blitter.sprite_collide && (color != 0x0e) && !(state->m_blitter.no_collide)) + back = lynx_read_ram(screen); + lynx_write_ram(screen, back^color); + if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide)) { - back = lynx_read_ram(state, colbuf); - lynx_write_ram(state, colbuf, (back & ~0x0f) | (state->m_blitter.spritenr)); - if ((back & 0x0f) > state->m_blitter.fred) - state->m_blitter.fred = back >> 4; + back = lynx_read_ram(colbuf); + lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr)); + if ((back & 0x0f) > m_blitter.fred) + m_blitter.fred = back >> 4; } } break; } } -static void lynx_blit_do_work( lynx_state *state, const int y, const int xdir, const int bits_per_pixel, const int mask ) +void lynx_state::lynx_blit_do_work( const int y, const int xdir, const int bits_per_pixel, const int mask ) { int next_line_addr,i,j; int xi, bits, color; UINT16 width_accum, buffer; - next_line_addr = lynx_read_ram(state, state->m_blitter.bitmap); // offset to second sprite line - width_accum = (xdir == 1) ? state->m_blitter.width_offset : 0; - state->m_blitter.memory_accesses++; + next_line_addr = lynx_read_ram(m_blitter.bitmap); // offset to second sprite line + width_accum = (xdir == 1) ? m_blitter.width_offset : 0; + m_blitter.memory_accesses++; - for (xi = state->m_blitter.x_pos - state->m_blitter.xoff, bits = 0, buffer = 0, j = 1; j < next_line_addr;j++) + for (xi = m_blitter.x_pos - m_blitter.xoff, bits = 0, buffer = 0, j = 1; j < next_line_addr;j++) { - buffer = (buffer << 8) | lynx_read_ram(state, state->m_blitter.bitmap + j); + buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j); bits += 8; // current bits in buffer - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; for ( ; bits > bits_per_pixel; bits -= bits_per_pixel) // last data packet at end of scanline is not rendered (qix, blulght) { - color = state->m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask]; - width_accum += state->m_blitter.width; + color = m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask]; + width_accum += m_blitter.width; for (i = 0; i < (width_accum>>8); i++, xi += xdir) { if ((xi >= 0) && (xi < 160)) { - lynx_plot_pixel(state, state->m_blitter.mode, xi, y, color); + lynx_plot_pixel(m_blitter.mode, xi, y, color); } } width_accum &= 0xff; @@ -413,12 +413,12 @@ static void lynx_blit_do_work( lynx_state *state, const int y, const int xdir, c } } -static void lynx_blit_2color_line(lynx_state *state, const int y, const int xdir) {lynx_blit_do_work(state, y, xdir, 1, 0x01);} -static void lynx_blit_4color_line(lynx_state *state, const int y, const int xdir) {lynx_blit_do_work(state, y, xdir, 2, 0x03);} -static void lynx_blit_8color_line(lynx_state *state, const int y, const int xdir) {lynx_blit_do_work(state, y, xdir, 3, 0x07);} -static void lynx_blit_16color_line(lynx_state *state, const int y, const int xdir) {lynx_blit_do_work(state, y, xdir, 4, 0x0f);} +static void lynx_blit_2color_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_do_work(y, xdir, 1, 0x01);} +static void lynx_blit_4color_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_do_work(y, xdir, 2, 0x03);} +static void lynx_blit_8color_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_do_work(y, xdir, 3, 0x07);} +static void lynx_blit_16color_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_do_work(y, xdir, 4, 0x0f);} -static void lynx_blit_rle_do_work( lynx_state *state, const INT16 y, const int xdir, const int bits_per_pixel, const int mask ) +void lynx_state::lynx_blit_rle_do_work( const INT16 y, const int xdir, const int bits_per_pixel, const int mask ) { int i; int xi; @@ -426,18 +426,18 @@ static void lynx_blit_rle_do_work( lynx_state *state, const INT16 y, const int x int literal_data, count, color; UINT16 width_accum; - width_accum = (xdir == 1) ? state->m_blitter.width_offset : 0; - for( bits = 0, j = 0, buffer = 0, xi = state->m_blitter.x_pos - state->m_blitter.xoff; ; ) /* through the rle entries */ + width_accum = (xdir == 1) ? m_blitter.width_offset : 0; + for( bits = 0, j = 0, buffer = 0, xi = m_blitter.x_pos - m_blitter.xoff; ; ) /* through the rle entries */ { if (bits < 5 + bits_per_pixel) /* under 7 bits no complete entry */ { j++; - if (j >= lynx_read_ram(state, state->m_blitter.bitmap)) + if (j >= lynx_read_ram(m_blitter.bitmap)) return; bits += 8; - buffer = (buffer << 8) | lynx_read_ram(state,state->m_blitter.bitmap + j); - state->m_blitter.memory_accesses++; + buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j); + m_blitter.memory_accesses++; } literal_data = (buffer >> (bits - 1)) & 0x01; @@ -452,20 +452,20 @@ static void lynx_blit_rle_do_work( lynx_state *state, const INT16 y, const int x if (bits < bits_per_pixel) { j++; - if (j >= lynx_read_ram(state, state->m_blitter.bitmap)) + if (j >= lynx_read_ram(m_blitter.bitmap)) return; bits += 8; - buffer = (buffer << 8) | lynx_read_ram(state, state->m_blitter.bitmap + j); - state->m_blitter.memory_accesses++; + buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j); + m_blitter.memory_accesses++; } - color = state->m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask]; + color = m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask]; bits -= bits_per_pixel; - width_accum += state->m_blitter.width; + width_accum += m_blitter.width; for (i = 0; i < (width_accum>>8); i++, xi += xdir) { if ((xi >= 0) && (xi < 160)) - lynx_plot_pixel(state, state->m_blitter.mode, xi, y, color); + lynx_plot_pixel(m_blitter.mode, xi, y, color); } width_accum &= 0xff; } @@ -478,23 +478,23 @@ static void lynx_blit_rle_do_work( lynx_state *state, const INT16 y, const int x if (bits < bits_per_pixel) { j++; - if (j >= lynx_read_ram(state, state->m_blitter.bitmap)) + if (j >= lynx_read_ram(m_blitter.bitmap)) return; bits += 8; - buffer = (buffer << 8) | lynx_read_ram(state, state->m_blitter.bitmap + j); - state->m_blitter.memory_accesses++; + buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j); + m_blitter.memory_accesses++; } - color = state->m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask]; + color = m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask]; bits -= bits_per_pixel; for ( ; count>=0; count--) { - width_accum += state->m_blitter.width; + width_accum += m_blitter.width; for (i = 0; i < (width_accum>>8); i++, xi += xdir) { if ((xi >= 0) && (xi < 160)) - lynx_plot_pixel(state, state->m_blitter.mode, xi, y, color); + lynx_plot_pixel(m_blitter.mode, xi, y, color); } width_accum &= 0xff; } @@ -502,21 +502,21 @@ static void lynx_blit_rle_do_work( lynx_state *state, const INT16 y, const int x } } -static void lynx_blit_2color_rle_line(lynx_state *state, const int y, const int xdir) {lynx_blit_rle_do_work(state, y, xdir, 1, 0x01);} -static void lynx_blit_4color_rle_line(lynx_state *state, const int y, const int xdir) {lynx_blit_rle_do_work(state, y, xdir, 2, 0x03);} -static void lynx_blit_8color_rle_line(lynx_state *state, const int y, const int xdir) {lynx_blit_rle_do_work(state, y, xdir, 3, 0x07);} -static void lynx_blit_16color_rle_line(lynx_state *state, const int y, const int xdir) {lynx_blit_rle_do_work(state, y, xdir, 4, 0x0f);} +static void lynx_blit_2color_rle_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_rle_do_work(y, xdir, 1, 0x01);} +static void lynx_blit_4color_rle_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_rle_do_work(y, xdir, 2, 0x03);} +static void lynx_blit_8color_rle_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_rle_do_work(y, xdir, 3, 0x07);} +static void lynx_blit_16color_rle_line(lynx_state *state, const int y, const int xdir) {state->lynx_blit_rle_do_work(y, xdir, 4, 0x0f);} -static void lynx_blit_lines(lynx_state *state) +void lynx_state::lynx_blit_lines() { int i; INT16 y; int ydir = 0, xdir = 0; int flip = 0; - state->m_blitter.everon = FALSE; + m_blitter.everon = FALSE; - switch (state->m_blitter.spr_ctl1 & 0x03) /* Initial drawing direction */ + switch (m_blitter.spr_ctl1 & 0x03) /* Initial drawing direction */ { case 0: // Down/Right (quadrant 0) xdir = 1; @@ -540,23 +540,23 @@ static void lynx_blit_lines(lynx_state *state) break; } - if (state->m_blitter.spr_ctl0 & 0x20) /* Horizontal Flip */ + if (m_blitter.spr_ctl0 & 0x20) /* Horizontal Flip */ { xdir *= -1; } - if (state->m_blitter.spr_ctl0 & 0x10) /* Vertical Flip */ + if (m_blitter.spr_ctl0 & 0x10) /* Vertical Flip */ { ydir *= -1; } // Set height accumulator based on drawing direction - state->m_blitter.height_accumulator = (ydir == 1) ? state->m_blitter.height_offset : 0x00; + m_blitter.height_accumulator = (ydir == 1) ? m_blitter.height_offset : 0x00; // loop through lines, next line offset of zero indicates end of sprite - for (y = state->m_blitter.y_pos - state->m_blitter.yoff; (i = lynx_read_ram(state, state->m_blitter.bitmap)); state->m_blitter.bitmap += i) + for (y = m_blitter.y_pos - m_blitter.yoff; (i = lynx_read_ram(m_blitter.bitmap)); m_blitter.bitmap += i) { - state->m_blitter.memory_accesses++; + m_blitter.memory_accesses++; if (i == 1) // draw next quadrant { @@ -566,37 +566,37 @@ static void lynx_blit_lines(lynx_state *state) case 0: case 2: ydir *= -1; - state->m_blitter.y_pos += ydir; + m_blitter.y_pos += ydir; break; case 1: case 3: xdir *= -1; - state->m_blitter.x_pos += xdir; + m_blitter.x_pos += xdir; break; } flip++; - y = state->m_blitter.y_pos - state->m_blitter.yoff; - state->m_blitter.height_accumulator = (ydir == 1) ? state->m_blitter.height_offset : 0x00; + y = m_blitter.y_pos - m_blitter.yoff; + m_blitter.height_accumulator = (ydir == 1) ? m_blitter.height_offset : 0x00; continue; } - state->m_blitter.height_accumulator += state->m_blitter.height; - for (int i=0; i < (state->m_blitter.height_accumulator>>8); i++, y += ydir) + m_blitter.height_accumulator += m_blitter.height; + for (int i=0; i < (m_blitter.height_accumulator>>8); i++, y += ydir) { if (y >= 0 && y < 102) - state->m_blitter.line_function(state, y, xdir); - state->m_blitter.width += (INT16)state->m_blitter.stretch; - if (state->m_blitter.vstretch) // doesn't seem to be used + m_blitter.line_function(this, y, xdir); + m_blitter.width += (INT16)m_blitter.stretch; + if (m_blitter.vstretch) // doesn't seem to be used { - state->m_blitter.height += (INT16)state->m_blitter.stretch; + m_blitter.height += (INT16)m_blitter.stretch; logerror("vertical stretch enabled"); } - state->m_blitter.tilt_accumulator += state->m_blitter.tilt; - state->m_blitter.x_pos += (state->m_blitter.tilt_accumulator>>8); - state->m_blitter.tilt_accumulator &= 0xff; + m_blitter.tilt_accumulator += m_blitter.tilt; + m_blitter.x_pos += (m_blitter.tilt_accumulator>>8); + m_blitter.tilt_accumulator &= 0xff; } - state->m_blitter.height_accumulator &= 0xff; + m_blitter.height_accumulator &= 0xff; } } @@ -679,9 +679,8 @@ TIMER_CALLBACK_MEMBER(lynx_state::lynx_blitter_timer) */ -static void lynx_blitter(running_machine &machine) +void lynx_state::lynx_blitter() { - lynx_state *state = machine.driver_data<lynx_state>(); static const int lynx_colors[4]={2,4,8,16}; UINT8 palette_offset; UINT8 coldep; @@ -702,109 +701,109 @@ static void lynx_blitter(running_machine &machine) int i; int colors; - state->m_blitter.mem = (UINT8*)state->m_maincpu->space(AS_PROGRAM).get_read_ptr(0x0000); + m_blitter.mem = (UINT8*)m_maincpu->space(AS_PROGRAM).get_read_ptr(0x0000); - state->m_blitter.busy = 1; // blitter working - state->m_blitter.memory_accesses = 0; + m_blitter.busy = 1; // blitter working + m_blitter.memory_accesses = 0; // Last SCB is indicated by zero in the high byte of SCBNEXT - while (state->m_blitter.scb_next & 0xff00) + while (m_blitter.scb_next & 0xff00) { - state->m_blitter.stretch = 0; - state->m_blitter.tilt = 0; - state->m_blitter.tilt_accumulator = 0; - - state->m_blitter.scb = state->m_blitter.scb_next; // current scb - state->m_blitter.scb_next = lynx_read_ram(state, state->m_blitter.scb + SCB_SCBNEXT) | (lynx_read_ram(state, state->m_blitter.scb + SCB_SCBNEXT + 1) << 8); // next scb - state->m_blitter.spr_ctl0 = lynx_read_ram(state, state->m_blitter.scb + SCB_SPRCTL0); - state->m_blitter.spr_ctl1 = lynx_read_ram(state, state->m_blitter.scb + SCB_SPRCTL1); - state->m_blitter.spr_coll = lynx_read_ram(state, state->m_blitter.scb + SCB_SPRCOLL); - state->m_blitter.memory_accesses += 5; - - if(!(state->m_blitter.spr_ctl1 & 0x04)) // sprite will be processed (if sprite is skipped first 5 bytes are still copied to suzy) + m_blitter.stretch = 0; + m_blitter.tilt = 0; + m_blitter.tilt_accumulator = 0; + + m_blitter.scb = m_blitter.scb_next; // current scb + m_blitter.scb_next = lynx_read_ram(m_blitter.scb + SCB_SCBNEXT) | (lynx_read_ram(m_blitter.scb + SCB_SCBNEXT + 1) << 8); // next scb + m_blitter.spr_ctl0 = lynx_read_ram(m_blitter.scb + SCB_SPRCTL0); + m_blitter.spr_ctl1 = lynx_read_ram(m_blitter.scb + SCB_SPRCTL1); + m_blitter.spr_coll = lynx_read_ram(m_blitter.scb + SCB_SPRCOLL); + m_blitter.memory_accesses += 5; + + if(!(m_blitter.spr_ctl1 & 0x04)) // sprite will be processed (if sprite is skipped first 5 bytes are still copied to suzy) { - state->m_blitter.bitmap = lynx_read_ram(state, state->m_blitter.scb + SCB_SPRDLINE) | (lynx_read_ram(state, state->m_blitter.scb + SCB_SPRDLINE + 1) << 8); - state->m_blitter.x_pos = lynx_read_ram(state, state->m_blitter.scb + SCB_HPOSSTRT) | (lynx_read_ram(state, state->m_blitter.scb + SCB_HPOSSTRT + 1) << 8); - state->m_blitter.y_pos = lynx_read_ram(state, state->m_blitter.scb + SCB_VPOSSTRT) | (lynx_read_ram(state, state->m_blitter.scb + SCB_VPOSSTRT + 1) << 8); - state->m_blitter.memory_accesses += 6; + m_blitter.bitmap = lynx_read_ram(m_blitter.scb + SCB_SPRDLINE) | (lynx_read_ram(m_blitter.scb + SCB_SPRDLINE + 1) << 8); + m_blitter.x_pos = lynx_read_ram(m_blitter.scb + SCB_HPOSSTRT) | (lynx_read_ram(m_blitter.scb + SCB_HPOSSTRT + 1) << 8); + m_blitter.y_pos = lynx_read_ram(m_blitter.scb + SCB_VPOSSTRT) | (lynx_read_ram(m_blitter.scb + SCB_VPOSSTRT + 1) << 8); + m_blitter.memory_accesses += 6; - switch(state->m_blitter.spr_ctl1 & 0x30) // reload sprite scaling + switch(m_blitter.spr_ctl1 & 0x30) // reload sprite scaling { case 0x30: // width, height, tilt, stretch - state->m_blitter.tilt = lynx_read_ram(state, state->m_blitter.scb + SCB_TILT) | (lynx_read_ram(state, state->m_blitter.scb + SCB_TILT + 1) << 8); - state->m_blitter.memory_accesses+=2; + m_blitter.tilt = lynx_read_ram(m_blitter.scb + SCB_TILT) | (lynx_read_ram(m_blitter.scb + SCB_TILT + 1) << 8); + m_blitter.memory_accesses+=2; case 0x20: // width, height, stretch - state->m_blitter.stretch = lynx_read_ram(state, state->m_blitter.scb + SCB_STRETCH) | (lynx_read_ram(state, state->m_blitter.scb + SCB_STRETCH + 1) << 8); - state->m_blitter.memory_accesses+=2; + m_blitter.stretch = lynx_read_ram(m_blitter.scb + SCB_STRETCH) | (lynx_read_ram(m_blitter.scb + SCB_STRETCH + 1) << 8); + m_blitter.memory_accesses+=2; case 0x10: // width, height - state->m_blitter.width = lynx_read_ram(state, state->m_blitter.scb + SCB_SPRHSIZ) | (lynx_read_ram(state, state->m_blitter.scb + SCB_SPRHSIZ + 1) << 8); - state->m_blitter.height = lynx_read_ram(state, state->m_blitter.scb + SCB_SPRVSIZ) | (lynx_read_ram(state, state->m_blitter.scb + SCB_SPRVSIZ + 1) << 8); - state->m_blitter.memory_accesses+=4; + m_blitter.width = lynx_read_ram(m_blitter.scb + SCB_SPRHSIZ) | (lynx_read_ram(m_blitter.scb + SCB_SPRHSIZ + 1) << 8); + m_blitter.height = lynx_read_ram(m_blitter.scb + SCB_SPRVSIZ) | (lynx_read_ram(m_blitter.scb + SCB_SPRVSIZ + 1) << 8); + m_blitter.memory_accesses+=4; } - if(!(state->m_blitter.spr_ctl1 & 0x08)) // reload palette + if(!(m_blitter.spr_ctl1 & 0x08)) // reload palette { - if (state->m_blitter.spr_ctl1 & 0x30) - palette_offset = 0x0b + 2*(((state->m_blitter.spr_ctl1 & 0x30)>>4) + 1); // palette data offset depends on width, height, etc. reloading + if (m_blitter.spr_ctl1 & 0x30) + palette_offset = 0x0b + 2*(((m_blitter.spr_ctl1 & 0x30)>>4) + 1); // palette data offset depends on width, height, etc. reloading else palette_offset = 0x0b; - colors = lynx_colors[state->m_blitter.spr_ctl0 >> 6]; + colors = lynx_colors[m_blitter.spr_ctl0 >> 6]; for (i = 0; i < colors / 2; i++) { - state->m_blitter.color[i * 2] = lynx_read_ram(state, state->m_blitter.scb + palette_offset + i) >> 4; - state->m_blitter.color[i * 2 + 1 ] = lynx_read_ram(state, state->m_blitter.scb + palette_offset + i) & 0x0f; - state->m_blitter.memory_accesses++; + m_blitter.color[i * 2] = lynx_read_ram(m_blitter.scb + palette_offset + i) >> 4; + m_blitter.color[i * 2 + 1 ] = lynx_read_ram(m_blitter.scb + palette_offset + i) & 0x0f; + m_blitter.memory_accesses++; } } } - if (!(state->m_blitter.spr_ctl1 & 0x04)) // if 0, we skip this sprite + if (!(m_blitter.spr_ctl1 & 0x04)) // if 0, we skip this sprite { - state->m_blitter.colpos = state->m_blitter.scb + (state->m_suzy.data[COLLOFFL] | (state->m_suzy.data[COLLOFFH]<<8)); - state->m_blitter.mode = state->m_blitter.spr_ctl0 & 0x07; + m_blitter.colpos = m_blitter.scb + (m_suzy.data[COLLOFFL] | (m_suzy.data[COLLOFFH]<<8)); + m_blitter.mode = m_blitter.spr_ctl0 & 0x07; - if (state->m_blitter.spr_ctl1 & 0x80) // totally literal sprite - state->m_blitter.line_function = blit_line[state->m_blitter.spr_ctl0 >> 6]; + if (m_blitter.spr_ctl1 & 0x80) // totally literal sprite + m_blitter.line_function = blit_line[m_blitter.spr_ctl0 >> 6]; else - state->m_blitter.line_function = blit_rle_line[state->m_blitter.spr_ctl0 >> 6]; + m_blitter.line_function = blit_rle_line[m_blitter.spr_ctl0 >> 6]; - state->m_blitter.sprite_collide = !(state->m_blitter.spr_coll & 0x20); - state->m_blitter.spritenr = state->m_blitter.spr_coll & 0x0f; - state->m_blitter.fred = 0; + m_blitter.sprite_collide = !(m_blitter.spr_coll & 0x20); + m_blitter.spritenr = m_blitter.spr_coll & 0x0f; + m_blitter.fred = 0; /* Draw Sprite */ - lynx_blit_lines(state); + lynx_blit_lines(); - if (state->m_blitter.sprite_collide && !(state->m_blitter.no_collide)) + if (m_blitter.sprite_collide && !(m_blitter.no_collide)) { - switch (state->m_blitter.mode) + switch (m_blitter.mode) { case BOUNDARY_SHADOW: case BOUNDARY: case NORMAL_SPRITE: case XOR_SPRITE: case SHADOW: - lynx_write_ram(state, state->m_blitter.colpos, state->m_blitter.fred); + lynx_write_ram(m_blitter.colpos, m_blitter.fred); break; } } - if (state->m_suzy.data[SPRGO] & 0x04) // Everon enabled + if (m_suzy.data[SPRGO] & 0x04) // Everon enabled { - coldep = lynx_read_ram(state, state->m_blitter.colpos); - if (!state->m_blitter.everon) + coldep = lynx_read_ram(m_blitter.colpos); + if (!m_blitter.everon) coldep |= 0x80; else coldep &= 0x7f; - lynx_write_ram(state, state->m_blitter.colpos, coldep); + lynx_write_ram(m_blitter.colpos, coldep); } } } - machine.scheduler().timer_set(state->m_maincpu->cycles_to_attotime(state->m_blitter.memory_accesses), timer_expired_delegate(FUNC(lynx_state::lynx_blitter_timer),state)); + machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(m_blitter.memory_accesses), timer_expired_delegate(FUNC(lynx_state::lynx_blitter_timer),this)); } @@ -1273,7 +1272,7 @@ WRITE8_MEMBER(lynx_state::suzy_write) if ((data & 0x01) && m_suzy.data[SUZYBUSEN]) { //m_blitter.time = machine().time(); - lynx_blitter(machine()); + lynx_blitter(); } break; case JOYSTICK: @@ -1313,9 +1312,8 @@ DISPCTL EQU $FD92 ; set to $D by INITMIKEY ; B0 1 EQU video DMA enabled */ -static void lynx_draw_line(running_machine &machine) +void lynx_state::lynx_draw_line() { - lynx_state *state = machine.driver_data<lynx_state>(); int x, y; UINT16 j; // clipping needed! UINT8 byte; @@ -1323,29 +1321,29 @@ static void lynx_draw_line(running_machine &machine) // calculate y: first three lines are vblank, - y = 101-state->m_timer[2].counter; + y = 101-m_timer[2].counter; // Documentation states lower two bits of buffer address are ignored (thus 0xfffc mask) - j = (state->m_mikey.disp_addr & 0xfffc) + y * 160 / 2; + j = (m_mikey.disp_addr & 0xfffc) + y * 160 / 2; - if (state->m_mikey.data[0x92] & 0x02) + if (m_mikey.data[0x92] & 0x02) { j -= 160 * 102 / 2 - 1; - line = &state->m_bitmap_temp.pix16(102 - 1 - y); + line = &m_bitmap_temp.pix16(102 - 1 - y); for (x = 160 - 2; x >= 0; j++, x -= 2) { - byte = lynx_read_ram(state, j); - line[x + 1] = state->m_palette[(byte >> 4) & 0x0f]; - line[x + 0] = state->m_palette[(byte >> 0) & 0x0f]; + byte = lynx_read_ram(j); + line[x + 1] = m_palette[(byte >> 4) & 0x0f]; + line[x + 0] = m_palette[(byte >> 0) & 0x0f]; } } else { - line = &state->m_bitmap_temp.pix16(y); + line = &m_bitmap_temp.pix16(y); for (x = 0; x < 160; j++, x += 2) { - byte = lynx_read_ram(state, j); - line[x + 0] = state->m_palette[(byte >> 4) & 0x0f]; - line[x + 1] = state->m_palette[(byte >> 0) & 0x0f]; + byte = lynx_read_ram(j); + line[x + 0] = m_palette[(byte >> 4) & 0x0f]; + line[x + 1] = m_palette[(byte >> 0) & 0x0f]; } } } @@ -1395,102 +1393,99 @@ TIM_BORROWOUT EQU %00000001 -static void lynx_timer_init(running_machine &machine, int which) +void lynx_state::lynx_timer_init(int which) { - lynx_state *state = machine.driver_data<lynx_state>(); - memset( &state->m_timer[which], 0, sizeof(LYNX_TIMER) ); - state->m_timer[which].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(lynx_state::lynx_timer_shot),state)); + memset( &m_timer[which], 0, sizeof(LYNX_TIMER) ); + m_timer[which].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(lynx_state::lynx_timer_shot),this)); } -static void lynx_timer_signal_irq(running_machine &machine, int which) +void lynx_state::lynx_timer_signal_irq(int which) { - lynx_state *state = machine.driver_data<lynx_state>(); - if ( ( state->m_timer[which].cntrl1 & 0x80 ) && ( which != 4 ) ) // if interrupts are enabled and timer != 4 + if ( ( m_timer[which].cntrl1 & 0x80 ) && ( which != 4 ) ) // if interrupts are enabled and timer != 4 { - state->m_mikey.data[0x81] |= ( 1 << which ); // set interupt poll register - state->m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); - state->m_maincpu->set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE); + m_mikey.data[0x81] |= ( 1 << which ); // set interupt poll register + m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); + m_maincpu->set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE); } switch ( which ) // count down linked timers { case 0: - switch (state->m_timer[2].counter) + switch (m_timer[2].counter) { case 104: break; case 103: - state->m_mikey.vb_rest = 1; + m_mikey.vb_rest = 1; break; case 102: - state->m_mikey.disp_addr = state->m_mikey.data[0x94] | (state->m_mikey.data[0x95] << 8); + m_mikey.disp_addr = m_mikey.data[0x94] | (m_mikey.data[0x95] << 8); break; case 101: - state->m_mikey.vb_rest = 0; - lynx_draw_line( machine ); + m_mikey.vb_rest = 0; + lynx_draw_line(); break; default: - lynx_draw_line( machine ); + lynx_draw_line(); } - lynx_timer_count_down( machine, 2 ); + lynx_timer_count_down( 2 ); break; case 2: - copybitmap(state->m_bitmap, state->m_bitmap_temp, 0, 0, 0, 0, machine.primary_screen->cliprect()); - lynx_timer_count_down( machine, 4 ); + copybitmap(m_bitmap, m_bitmap_temp, 0, 0, 0, 0, machine().primary_screen->cliprect()); + lynx_timer_count_down( 4 ); break; case 1: - lynx_timer_count_down( machine, 3 ); + lynx_timer_count_down( 3 ); break; case 3: - lynx_timer_count_down( machine, 5 ); + lynx_timer_count_down( 5 ); break; case 5: - lynx_timer_count_down( machine, 7 ); + lynx_timer_count_down( 7 ); break; case 7: - lynx_audio_count_down( state->m_audio, 0 ); + lynx_audio_count_down( m_audio, 0 ); break; } } -void lynx_timer_count_down(running_machine &machine, int which) +void lynx_state::lynx_timer_count_down(int which) { - lynx_state *state = machine.driver_data<lynx_state>(); - if ( ( state->m_timer[which].cntrl1 & 0x0f ) == 0x0f ) // count and linking enabled + if ( ( m_timer[which].cntrl1 & 0x0f ) == 0x0f ) // count and linking enabled { - if ( state->m_timer[which].counter > 0 ) + if ( m_timer[which].counter > 0 ) { - state->m_timer[which].counter--; - //state->m_timer[which].borrow_in = 1; + m_timer[which].counter--; + //m_timer[which].borrow_in = 1; return; } - if ( state->m_timer[which].counter == 0 ) + if ( m_timer[which].counter == 0 ) { - if (state->m_timer[which].cntrl2 & 0x01) // borrow out + if (m_timer[which].cntrl2 & 0x01) // borrow out { - lynx_timer_signal_irq(machine, which); - if ( state->m_timer[which].cntrl1 & 0x10 ) // if reload enabled + lynx_timer_signal_irq(which); + if ( m_timer[which].cntrl1 & 0x10 ) // if reload enabled { - state->m_timer[which].counter = state->m_timer[which].bakup; + m_timer[which].counter = m_timer[which].bakup; } else { - state->m_timer[which].cntrl2 |= 8; // set timer done + m_timer[which].cntrl2 |= 8; // set timer done } - state->m_timer[which].cntrl2 &= ~0x01; // clear borrow out + m_timer[which].cntrl2 &= ~0x01; // clear borrow out } else - state->m_timer[which].cntrl2 |= 0x01; // set borrow out + m_timer[which].cntrl2 |= 0x01; // set borrow out return; } } else { - //state->m_timer[which].borrow_in = 0; - state->m_timer[which].cntrl2 &= ~0x01; + //m_timer[which].borrow_in = 0; + m_timer[which].cntrl2 &= ~0x01; } } -static UINT32 lynx_time_factor(int val) +UINT32 lynx_state::lynx_time_factor(int val) { switch(val) { @@ -1507,7 +1502,7 @@ static UINT32 lynx_time_factor(int val) TIMER_CALLBACK_MEMBER(lynx_state::lynx_timer_shot) { - lynx_timer_signal_irq( machine(), param ); + lynx_timer_signal_irq( param ); if ( ! ( m_timer[param].cntrl1 & 0x10 ) ) // if reload not enabled { m_timer[param].timer_active = 0; @@ -1609,9 +1604,9 @@ void lynx_state::lynx_timer_write(int which, int offset, UINT8 data) ****************************************/ -static void lynx_uart_reset(lynx_state *state) +void lynx_state::lynx_uart_reset() { - memset(&state->m_uart, 0, sizeof(state->m_uart)); + memset(&m_uart, 0, sizeof(m_uart)); } TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_loopback_timer) @@ -1649,23 +1644,22 @@ TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_timer) } } -static READ8_HANDLER(lynx_uart_r) +READ8_MEMBER(lynx_state::lynx_uart_r) { - lynx_state *state = space.machine().driver_data<lynx_state>(); UINT8 value = 0x00; switch (offset) { case 0x8c: - if (!state->m_uart.buffer_loaded) + if (!m_uart.buffer_loaded) value |= 0x80; - if (state->m_uart.received) + if (m_uart.received) value |= 0x40; - if (!state->m_uart.sending) + if (!m_uart.sending) value |= 0x20; break; case 0x8d: - value = state->m_uart.data_received; + value = m_uart.data_received; break; } logerror("uart read %.2x %.2x\n", offset, value); @@ -1941,7 +1935,7 @@ void lynx_state::machine_reset() m_mikey.data[0x90] = 0x00; m_mikey.data[0x92] = 0x00; - lynx_uart_reset(this); + lynx_uart_reset(); // hack to allow current object loading to work #if 0 @@ -1979,7 +1973,7 @@ void lynx_state::machine_start() memset(&m_suzy, 0, sizeof(m_suzy)); for (i = 0; i < NR_LYNX_TIMERS; i++) - lynx_timer_init(machine(), i); + lynx_timer_init(i); } @@ -1998,7 +1992,7 @@ static void lynx_partialhash(hash_collection &dest, const unsigned char *data, dest.compute(&data[64], length - 64, functions); } -int lynx_verify_cart (char *header, int kind) +int lynx_state::lynx_verify_cart (char *header, int kind) { if (kind) { diff --git a/src/mess/video/bbc.c b/src/mess/video/bbc.c index 9b13c799a07..93c30a0a6e3 100644 --- a/src/mess/video/bbc.c +++ b/src/mess/video/bbc.c @@ -36,12 +36,12 @@ * the output of S4 is linked out to a 0v supply by link S25 to just access the 16K memory area. ************************************************************************/ -unsigned int calculate_video_address(bbc_state *state,int ma,int ra) +unsigned int bbc_state::calculate_video_address(int ma,int ra) { // ma = output from IC2 6845 MA address - int c0=state->m_b4_video0; // output from IC32 74LS259 bits 4 and 5 - int c1=state->m_b5_video1; + int c0=m_b4_video0; // output from IC32 74LS259 bits 4 and 5 + int c1=m_b5_video1; /* the 4 bit input port b on IC39 are produced by 4 NAND gates. these NAND gates take their @@ -81,7 +81,7 @@ unsigned int calculate_video_address(bbc_state *state,int ma,int ra) // IC 8 and IC 9 m=((ma&0xff)<<3)|(s<<11)|(ra&0x7); } - if (state->m_memorySize==16) + if (m_memorySize==16) return m & 0x3fff; return m; @@ -160,33 +160,10 @@ WRITE8_MEMBER(bbc_state::bbc_videoULA_w) } } -// VideoULA Internal Cursor controls - -/* -void bbc_state::set_cursor(bbc_state *state) -{ - m_cursor_state=m_VideoULA_CR?0:7; -} - -void bbc_state::BBC_Clock_CR(bbc_state *state) -{ - if (m_VideoULA_CR) - { - m_VideoULA_CR_counter-=1; - if (m_VideoULA_CR_counter<=0) { - m_VideoULA_CR=0; - set_cursor(state); - } - } -} -*/ /************************************************************************ * BBC circuits controlled by 6845 Outputs ************************************************************************/ -int returned_pixel_count; -int returned_pixels[6]; - static MC6845_UPDATE_ROW( vid_update_row ) { bbc_state *state = device->machine().driver_data<bbc_state>(); @@ -205,8 +182,6 @@ static MC6845_UPDATE_ROW( vid_update_row ) //Teletext Latch bit 6 is only passed onto bits 6 on the Teletext chip if DE is true //Teletext Latch bit 7 goes to LOSE on the Teletext chip - returned_pixel_count=0; - state->m_trom->write((state->m_Teletext_Latch&0x3f)|(state->m_Teletext_Latch&0x40)); state->m_trom->f1_w(1); @@ -216,7 +191,7 @@ static MC6845_UPDATE_ROW( vid_update_row ) { state->m_Teletext_Latch=0; } else { - state->m_Teletext_Latch=(state->m_BBC_Video_RAM[calculate_video_address(state,ma+x_pos,ra)]); + state->m_Teletext_Latch=(state->m_BBC_Video_RAM[state->calculate_video_address(ma+x_pos,ra)]); } for(int pixelno=0;pixelno<6;pixelno++) { @@ -250,7 +225,7 @@ static MC6845_UPDATE_ROW( vid_update_row ) { for(int x_pos=0; x_pos<x_count; x_pos++) { - int vmem=calculate_video_address(state,ma+x_pos,ra); + int vmem=state->calculate_video_address(ma+x_pos,ra); unsigned char i=state->m_BBC_Video_RAM[vmem]; for(int pixelno=0;pixelno<state->m_pixels_per_byte;pixelno++) @@ -380,275 +355,3 @@ VIDEO_START_MEMBER(bbc_state,bbcm) { common_init(32); } - - -/* - -Old removed BBC mc6845 video code. -This has now all been replaced by MAMEs mc6845 code. - - - -static void BBC_draw_hi_res(running_machine &machine); -static void BBC_draw_teletext(running_machine &machine); - - - - -void bbc_state::BBC_draw_teletext() -{ - - //Teletext Latch bits 0 to 5 go to bits 0 to 5 on the Teletext chip - //Teletext Latch bit 6 is only passed onto bits 6 on the Teletext chip if DE is true - //Teletext Latch bit 7 goes to LOSE on the Teletext chip - - teletext_LOSE_w(m_saa505x, 0, (m_Teletext_Latch>>7)&1); - - teletext_F1(m_saa505x); - - teletext_data_w(m_saa505x, 0, (m_Teletext_Latch&0x3f)|((m_Teletext_Latch&0x40)|(m6845_display_enabled_r(0)?0:0x40))); - - int meml=m6845_memory_address_r(0); - - if (((meml>>13)&1)==0) - { - m_Teletext_Latch=0; - } else { - m_Teletext_Latch=(m_BBC_Video_RAM[calculate_video_address(state,meml)]&0x7f)|(m6845_display_enabled_r(0)?0x80:0); - } - -} - - - - - -// This is the actual output of the Video ULA this fuction does all the output to the screen in the BBC emulator - -void bbc_state::BBC_ula_drawpixel(bbc_state *state, int col, int number_of_pixels) -{ - int pixel_count; - int pixel_temp; - if ((m_BBC_display>=m_BBC_display_left) && ((m_BBC_display+number_of_pixels)<m_BBC_display_right)) - { - - pixel_temp=col^m_cursor_state; - for(pixel_count=0;pixel_count<number_of_pixels;pixel_count++) - { - *(m_BBC_display++) = pixel_temp; - } - } else { - m_BBC_display += number_of_pixels; - } -} - - -// the Video ULA hi-res shift registers, pallette lookup and display enabled circuits - - - - - -static const struct m6845_interface BBC6845 = -{ - 0,// Memory Address register - 0,// Row Address register - BBC_Set_HSync,// Horizontal status - BBC_Set_VSync,// Vertical status - 0,// Display Enabled status - 0,// Cursor status - BBC_Set_CRE, // Cursor status Emulation -}; - - - -void bbc_state::BBC_draw_hi_res() -{ - int meml; - unsigned char i=0; - int sc1; - - // this is IC38 and IC41 takes 6845 DisplayEnabled and 6845 RA3 - int DE=m6845_display_enabled_r(0) && (!(m6845_row_address_r(0)&8)); - - if (DE) - { - // read the memory location for the next screen location. - meml=calculate_video_address(state,m6845_memory_address_r(0)); - - i=m_BBC_Video_RAM[meml]; - - for(sc1=0;sc1<m_pixels_per_byte;sc1++) - { - BBC_ula_drawpixel(state, m_videoULA_pallet_lookup[m_pixel_bits[i]], m_emulation_pixels_per_real_pixel); - i=(i<<1)|1; - } - - } else { - // if the display is not enable, just draw a blank area. - BBC_ula_drawpixel(state, 0, m_emulation_pixels_per_byte); - } -} - - -// RGB input to the Video ULA from the Teletext IC -// Just pass on the output at the correct pixel size. -void bbc_draw_RGB_in(device_t *device, int offset,int data) -{ - bbc_state *state = device->machine().driver_data<bbc_state>(); - BBC_ula_drawpixel(state, data, state->m_emulation_pixels_per_real_pixel); -} - - - - - - -// called when the 6845 changes the HSync -void bbc_state::BBC_Set_HSync(int offset, int data) -{ - // catch the falling edge - if((!data)&&(m_BBC_HSync)) - { - m_y_screen_pos+=1; - - if ((m_y_screen_pos>=0) && (m_y_screen_pos<300)) - { - m_BBC_display_left = &m_BBC_bitmap->pix16(m_y_screen_pos); - m_BBC_display_right = m_BBC_display_left + 800; - - } else { - m_BBC_display_left = &m_BBC_bitmap->pix16(0); - m_BBC_display_right = m_BBC_display_left; - } - - m_BBC_display = m_BBC_display_left + m_x_screen_offset; - - } - m_BBC_HSync=data; -} - -// called when the 6845 changes the VSync -void bbc_state::BBC_Set_VSync(int offset, int data) -{ - // catch the falling edge - if ((!data)&&(m_BBC_VSync)) - { - m_y_screen_pos=m_y_screen_offset; - - if ((m_y_screen_pos>=0) && (m_y_screen_pos<300)) - { - m_BBC_display_left = &m_BBC_bitmap->pix16(m_y_screen_pos); - m_BBC_display_right = m_BBC_display_left + 800; - - } else { - m_BBC_display_left = &m_BBC_bitmap->pix16(0); - m_BBC_display_right = m_BBC_display_left; - } - - m_BBC_display = m_BBC_display_left + m_x_screen_offset; - - teletext_DEW(m_saa505x); - } - m_BBC_VSync=data; - -} - -// called when the 6845 changes the Cursor Enabled -void bbc_state::BBC_Set_CRE(int offset, int data) -{ - if (data&2) { - m_VideoULA_CR_counter=m_emulation_cursor_size; - m_VideoULA_CR=1; - // set the pallet on - if (data&1) set_cursor(state); - } -} - - - - - -WRITE8_MEMBER(bbc_state::bbc_6845_w) -{ - switch(offset & 1) - { - case 0 : - m_mc6845->address_w(space,0,data); - break; - case 1 : - m_mc6845->register_w(space,0,data); - break; - } -} - - - READ8_HANDLER (bbc_6845_r) -{ - switch (offset&1) - { - case 0: return m_mc6845->status_r(space,0); break; - case 1: return m_mc6845->register_r(space,0); break; - } - return 0; -} - - - - - -UINT32 bbc_state::screen_update_bbc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - - m_mc6845->update( bitmap, cliprect); - - return 0; - - - - long c; - - //logerror ("Box %d by %d \n",cliprect.min_y,cliprect.max_y); - - c = 0; // this is used to time out the screen redraw, in the case that the 6845 is in some way out state. - - - m_BBC_bitmap=bitmap; - - m_BBC_display_left=&m_BBC_bitmap->pix16(0); - m_BBC_display_right=m_BBC_display_left; - m_BBC_display=m_BBC_display_left; - - // loop until the end of the Vertical Sync pulse - // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) - while((m_BBC_VSync)&&(c<60000)) - { - // Clock the 6845 - m6845_clock(machine()); - c++; - } - - - // loop until the Vertical Sync pulse goes high - // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) - while((!m_BBC_VSync)&&(c<60000)) - { - if ((m_y_screen_pos>=cliprect.min_y) && (m_y_screen_pos<=cliprect.max_y)) (m_draw_function)(machine()); - - // and check the cursor - if (m_VideoULA_CR) BBC_Clock_CR(this); - - // Clock the 6845 - m6845_clock(machine()); - c++; - } - - return 0; -} - -void bbc_state::bbc_frameclock() -{ - m6845_frameclock(); -} - -*/ |