diff options
Diffstat (limited to 'src/devices/machine/spg2xx.h')
-rw-r--r-- | src/devices/machine/spg2xx.h | 190 |
1 files changed, 45 insertions, 145 deletions
diff --git a/src/devices/machine/spg2xx.h b/src/devices/machine/spg2xx.h index b35559d0dd3..806e8395c4d 100644 --- a/src/devices/machine/spg2xx.h +++ b/src/devices/machine/spg2xx.h @@ -36,6 +36,9 @@ #include "cpu/unsp/unsp.h" #include "spg2xx_audio.h" +#include "spg2xx_io.h" +#include "spg2xx_sysdma.h" +#include "spg2xx_video.h" #include "screen.h" class spg2xx_device : public device_t, public device_mixer_interface @@ -64,14 +67,16 @@ public: auto chip_select() { return m_chip_sel.bind(); } - void uart_rx(uint8_t data); - - void extint_w(int channel, bool state); + required_device<spg2xx_audio_device> m_spg_audio; + required_device<spg2xx_io_device> m_spg_io; + required_device<spg2xx_sysdma_device> m_spg_sysdma; + required_device<spg2xx_video_device> m_spg_video; - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - DECLARE_WRITE_LINE_MEMBER(vblank); + void extint_w(int channel, bool state) { m_spg_io->extint_w(channel, state); } + void uart_rx(uint8_t data) { m_spg_io->uart_rx(data); } - required_device<spg2xx_audio_device> m_spg_audio; + DECLARE_WRITE_LINE_MEMBER(vblank) { m_spg_video->vblank(state); } + uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { return m_spg_video->screen_update(screen, bitmap, cliprect); } protected: spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, const uint32_t sprite_limit) @@ -80,132 +85,28 @@ protected: m_sprite_limit = sprite_limit; } - virtual void device_add_mconfig(machine_config &config) override; - - enum - { - PAGE_ENABLE_MASK = 0x0008, - PAGE_WALLPAPER_MASK = 0x0004, - - SPRITE_ENABLE_MASK = 0x0001, - SPRITE_COORD_TL_MASK = 0x0002, - - PAGE_DEPTH_FLAG_MASK = 0x3000, - PAGE_DEPTH_FLAG_SHIFT = 12, - PAGE_TILE_HEIGHT_MASK = 0x00c0, - PAGE_TILE_HEIGHT_SHIFT = 6, - PAGE_TILE_WIDTH_MASK = 0x0030, - PAGE_TILE_WIDTH_SHIFT = 4, - TILE_X_FLIP = 0x0004, - TILE_Y_FLIP = 0x0008 - }; - - DECLARE_READ16_MEMBER(video_r); - DECLARE_WRITE16_MEMBER(video_w); - - virtual DECLARE_READ16_MEMBER(io_r); - virtual DECLARE_WRITE16_MEMBER(io_w); - + DECLARE_WRITE_LINE_MEMBER(videoirq_w); DECLARE_WRITE_LINE_MEMBER(audioirq_w); - DECLARE_READ16_MEMBER(space_r); + DECLARE_WRITE_LINE_MEMBER(timerirq_w); + DECLARE_WRITE_LINE_MEMBER(uartirq_w); + DECLARE_WRITE_LINE_MEMBER(extirq_w); + DECLARE_WRITE_LINE_MEMBER(ffreq1_w); + DECLARE_WRITE_LINE_MEMBER(ffreq2_w); - void check_extint_irq(int channel); - void check_irqs(const uint16_t changed); - inline void check_video_irq(); + DECLARE_READ16_MEMBER(space_r); void spg2xx_map(address_map &map); - static const device_timer_id TIMER_TMB1 = 0; - static const device_timer_id TIMER_TMB2 = 1; - static const device_timer_id TIMER_SCREENPOS = 2; - static const device_timer_id TIMER_BEAT = 3; - static const device_timer_id TIMER_UART_TX = 4; - static const device_timer_id TIMER_UART_RX = 5; - static const device_timer_id TIMER_4KHZ = 6; - static const device_timer_id TIMER_SRC_AB = 7; - static const device_timer_id TIMER_SRC_C = 8; - virtual void device_start() override; virtual void device_reset() override; - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; - - void update_porta_special_modes(); - void update_portb_special_modes(); - void do_gpio(uint32_t offset, bool write); - uint16_t do_special_gpio(uint32_t index, uint16_t mask); - - void update_timer_b_rate(); - void update_timer_ab_src(); - void update_timer_c_src(); - void increment_timer_a(); - - void uart_transmit_tick(); - void uart_receive_tick(); - - void system_timer_tick(); - - void do_i2c(); - void do_cpu_dma(uint32_t len); - void do_sprite_dma(uint32_t len); - - enum blend_enable_t : bool - { - BlendOff = false, - BlendOn = true - }; - - enum rowscroll_enable_t : bool - { - RowScrollOff = false, - RowScrollOn = true - }; - - enum flipx_t : bool - { - FlipXOff = false, - FlipXOn = true - }; - - void apply_saturation(const rectangle &cliprect); - void apply_fade(const rectangle &cliprect); - - template<blend_enable_t Blend, rowscroll_enable_t RowScroll, flipx_t FlipX> - void blit(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t attr, uint32_t ctrl, uint32_t bitmap_addr, uint16_t tile); - void blit_page(const rectangle &cliprect, uint32_t scanline, int depth, uint32_t bitmap_addr, uint16_t *regs); - void blit_sprite(const rectangle &cliprect, uint32_t scanline, int depth, uint32_t base_addr); - void blit_sprites(const rectangle &cliprect, uint32_t scanline, int depth); - - uint8_t mix_channel(uint8_t a, uint8_t b); - - uint32_t m_screenbuf[320 * 240]; - uint8_t m_rgb5_to_rgb8[32]; - uint32_t m_rgb555_to_rgb888[0x8000]; - - bool m_hide_page0; - bool m_hide_page1; - bool m_hide_sprites; - bool m_debug_sprites; - bool m_debug_blit; - bool m_debug_palette; - uint8_t m_sprite_index_to_debug; - - - uint16_t m_io_regs[0x200]; - uint8_t m_uart_rx_fifo[8]; - uint8_t m_uart_rx_fifo_start; - uint8_t m_uart_rx_fifo_end; - uint8_t m_uart_rx_fifo_count; - bool m_uart_rx_available; - bool m_uart_rx_irq; - bool m_uart_tx_irq; - - bool m_extint[2]; - - uint16_t m_video_regs[0x100]; - uint32_t m_sprite_limit; - int m_rowscrolloffset; // auto racing in 'zone60' minigames needs this to be 15, the JAKKS games (Star Wars Revenge of the sith - Gunship Battle, Wheel of Fortune, Namco Ms. Pac-Man 5-in-1 Pole Position) need it to be 0, where does it come from? + // TODO: these are fixed values, put them in relevant devices? + uint16_t m_sprite_limit; + uint16_t m_rowscrolloffset; // auto racing in 'zone60' minigames needs this to be 15, the JAKKS games (Star Wars Revenge of the sith - Gunship Battle, Wheel of Fortune, Namco Ms. Pac-Man 5-in-1 Pole Position) need it to be 0, where does it come from? uint16_t m_pal_flag; + DECLARE_READ16_MEMBER(get_sprlimit) { return m_sprite_limit; } + DECLARE_READ16_MEMBER(get_rowscrolloffset) { return m_rowscrolloffset; } + DECLARE_READ16_MEMBER(get_pal_ntsc) { return m_pal_flag; } devcb_write16 m_porta_out; devcb_write16 m_portb_out; @@ -223,31 +124,26 @@ protected: devcb_write8 m_chip_sel; - uint16_t m_timer_a_preload; - uint16_t m_timer_b_preload; - uint16_t m_timer_b_divisor; - uint16_t m_timer_b_tick_rate; - - emu_timer *m_tmb1; - emu_timer *m_tmb2; - emu_timer *m_timer_src_ab; - emu_timer *m_timer_src_c; emu_timer *m_screenpos_timer; - emu_timer *m_4khz_timer; - uint32_t m_2khz_divider; - uint32_t m_1khz_divider; - uint32_t m_4hz_divider; - - uint32_t m_uart_baud_rate; - emu_timer *m_uart_tx_timer; - emu_timer *m_uart_rx_timer; - required_device<unsp_device> m_cpu; required_device<screen_device> m_screen; - required_shared_ptr<uint16_t> m_scrollram; - required_shared_ptr<uint16_t> m_paletteram; - required_shared_ptr<uint16_t> m_spriteram; + + void configure_spg_io(spg2xx_io_device* io); + + DECLARE_READ16_MEMBER(porta_r) { return m_porta_in(); } + DECLARE_READ16_MEMBER(portb_r) { return m_portb_in(); } + DECLARE_READ16_MEMBER(portc_r) { return m_portc_in(); } + DECLARE_WRITE16_MEMBER(porta_w) { m_porta_out(offset, data, mem_mask); } + DECLARE_WRITE16_MEMBER(portb_w) { m_portb_out(offset, data, mem_mask); } + DECLARE_WRITE16_MEMBER(portc_w) { m_portc_out(offset, data, mem_mask); } + template <size_t Line> DECLARE_READ16_MEMBER(adc_r) { return m_adc_in[Line](); } + + DECLARE_WRITE8_MEMBER(eepromx_w) { m_eeprom_w(offset, data, mem_mask); } + DECLARE_READ8_MEMBER(eepromx_r) { return m_eeprom_r(); }; + + DECLARE_WRITE8_MEMBER(tx_w) { m_uart_tx(offset, data, mem_mask); } + DECLARE_WRITE8_MEMBER(cs_w) { m_chip_sel(offset, data, mem_mask); } }; class spg24x_device : public spg2xx_device @@ -262,6 +158,9 @@ public: } spg24x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + virtual void device_add_mconfig(machine_config &config) override; + }; class spg28x_device : public spg2xx_device @@ -277,7 +176,8 @@ public: spg28x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual DECLARE_WRITE16_MEMBER(io_w) override; + virtual void device_add_mconfig(machine_config &config) override; + }; DECLARE_DEVICE_TYPE(SPG24X, spg24x_device) |