1 // license:GPL-2.0+ 2 // copyright-holders:Jarek Burczynski, Phil Stroffolino, Tomasz Slanina 3 4 #include "cpu/m6805/m68705.h" 5 #include "machine/timer.h" 6 #include "emupal.h" 7 #include "screen.h" 8 9 10 class changela_state : public driver_device 11 { 12 public: changela_state(const machine_config & mconfig,device_type type,const char * tag)13 changela_state(const machine_config &mconfig, device_type type, const char *tag) 14 : driver_device(mconfig, type, tag) 15 , m_spriteram(*this, "spriteram") 16 , m_videoram(*this, "videoram") 17 , m_colorram(*this, "colorram") 18 , m_mcu(*this, "mcu") 19 , m_maincpu(*this, "maincpu") 20 , m_screen(*this, "screen") 21 , m_palette(*this, "palette") 22 , m_port_a_out(0xff) 23 , m_port_c_out(0xff) 24 , m_mcu_out(0xff) 25 , m_mcu_in(0xff) 26 { 27 } 28 29 /* video-related */ 30 bitmap_ind16 m_obj0_bitmap; 31 bitmap_ind16 m_river_bitmap; 32 bitmap_ind16 m_tree0_bitmap; 33 bitmap_ind16 m_tree1_bitmap; 34 std::unique_ptr<uint8_t[]> m_tree_ram; 35 std::unique_ptr<uint8_t[]> m_memory_devices; 36 uint32_t m_mem_dev_selected; /* an offset within memory_devices area */ 37 uint32_t m_slopeROM_bank; 38 uint8_t m_tree_en; 39 uint8_t m_horizon; 40 uint8_t m_v_count_river; 41 uint8_t m_v_count_tree; 42 int m_tree_on[2]; 43 emu_timer* m_scanline_timer; 44 45 /* misc */ 46 uint8_t m_tree0_col; 47 uint8_t m_tree1_col; 48 uint8_t m_left_bank_col; 49 uint8_t m_right_bank_col; 50 uint8_t m_boat_shore_col; 51 uint8_t m_collision_reset; 52 uint8_t m_tree_collision_reset; 53 uint8_t m_prev_value_31; 54 int m_dir_31; 55 56 /* devices */ 57 uint8_t mcu_r(); 58 void mcu_w(uint8_t data); 59 void changela_68705_port_a_w(uint8_t data); 60 void changela_68705_port_c_w(uint8_t data); 61 uint8_t changela_24_r(); 62 uint8_t changela_25_r(); 63 uint8_t changela_30_r(); 64 uint8_t changela_31_r(); 65 uint8_t changela_2c_r(); 66 uint8_t changela_2d_r(); 67 DECLARE_WRITE_LINE_MEMBER(mcu_pc_0_w); 68 DECLARE_WRITE_LINE_MEMBER(collision_reset_0_w); 69 DECLARE_WRITE_LINE_MEMBER(collision_reset_1_w); 70 DECLARE_WRITE_LINE_MEMBER(coin_counter_1_w); 71 DECLARE_WRITE_LINE_MEMBER(coin_counter_2_w); 72 void changela_colors_w(offs_t offset, uint8_t data); 73 void changela_mem_device_select_w(uint8_t data); 74 void changela_mem_device_w(offs_t offset, uint8_t data); 75 uint8_t changela_mem_device_r(offs_t offset); 76 void changela_slope_rom_addr_hi_w(uint8_t data); 77 void changela_slope_rom_addr_lo_w(uint8_t data); 78 virtual void machine_start() override; 79 virtual void machine_reset() override; 80 virtual void video_start() override; 81 uint32_t screen_update_changela(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 82 INTERRUPT_GEN_MEMBER(chl_mcu_irq); 83 TIMER_CALLBACK_MEMBER(changela_scanline_callback); 84 TIMER_DEVICE_CALLBACK_MEMBER(changela_scanline); 85 void draw_obj0( bitmap_ind16 &bitmap, int sy ); 86 void draw_obj1( bitmap_ind16 &bitmap ); 87 void draw_river( bitmap_ind16 &bitmap, int sy ); 88 void draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ); 89 90 void changela(machine_config &config); 91 void changela_map(address_map &map); 92 protected: 93 // memory pointers 94 required_shared_ptr<u8> m_spriteram; 95 required_shared_ptr<u8> m_videoram; 96 required_shared_ptr<u8> m_colorram; 97 98 // devices 99 required_device<m68705p_device> m_mcu; 100 required_device<cpu_device> m_maincpu; 101 required_device<screen_device> m_screen; 102 required_device<palette_device> m_palette; 103 104 // mcu-related 105 u8 m_port_a_out; 106 u8 m_port_c_out; 107 u8 m_mcu_out; 108 u8 m_mcu_in; 109 }; 110