1 // license:BSD-3-Clause 2 // copyright-holders:David Haywood, ElSemi 3 #ifndef MAME_INCLUDES_PGM_H 4 #define MAME_INCLUDES_PGM_H 5 6 #pragma once 7 8 #include "machine/igs025.h" 9 #include "machine/igs022.h" 10 #include "machine/igs028.h" 11 #include "machine/pgmcrypt.h" 12 13 #include "cpu/arm7/arm7.h" 14 #include "cpu/arm7/arm7core.h" 15 #include "cpu/m68000/m68000.h" 16 #include "cpu/z80/z80.h" 17 #include "machine/gen_latch.h" 18 #include "machine/nvram.h" 19 #include "machine/timer.h" 20 #include "machine/v3021.h" 21 #include "sound/ics2115.h" 22 #include "emupal.h" 23 #include "tilemap.h" 24 25 #define PGMARM7LOGERROR 0 26 27 class pgm_state : public driver_device 28 { 29 public: pgm_state(const machine_config & mconfig,device_type type,const char * tag)30 pgm_state(const machine_config &mconfig, device_type type, const char *tag) 31 : driver_device(mconfig, type, tag) 32 , m_mainram(*this, "sram") 33 , m_region(*this, "Region") 34 , m_regionhack(*this, "RegionHack") 35 , m_maincpu(*this, "maincpu") 36 , m_videoregs(*this, "videoregs") 37 , m_videoram(*this, "videoram") 38 , m_z80_mainram(*this, "z80_mainram") 39 , m_soundcpu(*this, "soundcpu") 40 , m_gfxdecode(*this, "gfxdecode") 41 , m_palette(*this, "palette") 42 , m_soundlatch(*this, "soundlatch") 43 , m_soundlatch3(*this, "soundlatch3") 44 , m_ics(*this, "ics") 45 , m_adata(*this, "sprcol") 46 , m_bdata(*this, "sprmask") 47 { 48 m_irq4_disabled = 0; 49 } 50 51 void init_pgm(); 52 53 void pgm_basic_init(bool set_bank = true); 54 void pgm(machine_config &config); 55 void pgmbase(machine_config &config); 56 57 protected: 58 virtual void machine_reset() override; 59 virtual void video_start() override; 60 61 /* memory pointers */ 62 required_shared_ptr<u16> m_mainram; 63 64 optional_ioport m_region; 65 optional_ioport m_regionhack; 66 67 /* devices */ 68 required_device<cpu_device> m_maincpu; 69 70 /* hack */ 71 int m_irq4_disabled; 72 73 void pgm_base_mem(address_map &map); 74 void pgm_mem(address_map &map); 75 76 private: 77 /* memory pointers */ 78 required_shared_ptr<u16> m_videoregs; 79 required_shared_ptr<u16> m_videoram; 80 required_shared_ptr<u8> m_z80_mainram; 81 u16 * m_bg_videoram; 82 u16 * m_tx_videoram; 83 u16 * m_rowscrollram; 84 85 /* video-related */ 86 struct sprite_t 87 { 88 int x,y; 89 bool xgrow, ygrow; 90 u32 xzoom, yzoom; 91 u32 color, offs; 92 u32 width, height; 93 u8 flip, pri; 94 }; 95 96 std::unique_ptr<sprite_t[]> m_spritelist; 97 struct sprite_t *m_sprite_ptr_pre; 98 tilemap_t *m_bg_tilemap; 99 tilemap_t *m_tx_tilemap; 100 101 /* devices */ 102 required_device<cpu_device> m_soundcpu; 103 required_device<gfxdecode_device> m_gfxdecode; 104 required_device<palette_device> m_palette; 105 required_device<generic_latch_8_device> m_soundlatch; 106 required_device<generic_latch_8_device> m_soundlatch3; 107 required_device<ics2115_device> m_ics; 108 109 /* used by rendering */ 110 required_region_ptr<u16> m_adata; 111 required_region_ptr<u16> m_bdata; 112 u32 m_aoffset; 113 u8 m_abit; 114 u32 m_boffset; 115 116 u16 videoram_r(offs_t offset); 117 void videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 118 void coin_counter_w(u16 data); 119 u8 z80_ram_r(offs_t offset); 120 void z80_ram_w(offs_t offset, u8 data); 121 void z80_reset_w(offs_t offset, u16 data, u16 mem_mask = ~0); 122 void z80_ctrl_w(offs_t offset, u16 data, u16 mem_mask = ~0); 123 void m68k_l1_w(u8 data); 124 void z80_l3_w(u8 data); 125 void tx_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 126 void bg_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 127 128 TILE_GET_INFO_MEMBER(get_tx_tile_info); 129 TILE_GET_INFO_MEMBER(get_bg_tile_info); 130 u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 131 DECLARE_WRITE_LINE_MEMBER(screen_vblank); 132 TIMER_DEVICE_CALLBACK_MEMBER(interrupt); 133 134 inline void pgm_draw_pix(int xdrawpos, int pri, u16* dest, u8* destpri, const rectangle &cliprect, u16 srcdat); 135 inline void pgm_draw_pix_nopri(int xdrawpos, u16* dest, u8* destpri, const rectangle &cliprect, u16 srcdat); 136 inline void pgm_draw_pix_pri(int xdrawpos, u16* dest, u8* destpri, const rectangle &cliprect, u16 srcdat); 137 inline u8 get_sprite_pix(); 138 void draw_sprite_line(int wide, u16* dest, u8* destpri, const rectangle &cliprect, int xzoom, bool xgrow, int flip, int xpos, int pri, int realxsize, int palt, bool draw); 139 void draw_sprite_new_zoomed(int wide, int high, int xpos, int ypos, int palt, int flip, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u32 xzoom, bool xgrow, u32 yzoom, bool ygrow, int pri); 140 void draw_sprite_line_basic(int wide, u16* dest, u8* destpri, const rectangle &cliprect, int flip, int xpos, int pri, int realxsize, int palt, bool draw); 141 void draw_sprite_new_basic(int wide, int high, int xpos, int ypos, int palt, int flip, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, int pri); 142 void draw_sprites(bitmap_ind16& spritebitmap, const rectangle &cliprect, bitmap_ind8& priority_bitmap); 143 void get_sprites(); 144 void pgm_basic_mem(address_map &map); 145 void pgm_z80_io(address_map &map); 146 void pgm_z80_mem(address_map &map); 147 }; 148 149 150 151 /*----------- defined in drivers/pgm.cpp -----------*/ 152 153 INPUT_PORTS_EXTERN(pgm); 154 155 extern gfx_decode_entry const gfx_pgm[]; 156 157 #endif // MAME_INCLUDES_PGM_H 158