1 // license:BSD-3-Clause 2 // copyright-holders:Wilbert Pol,Gabriele D'Antona 3 4 /* 5 6 Research Machines RM 380Z 7 8 */ 9 10 #ifndef MAME_INCLUDES_RM380Z_H 11 #define MAME_INCLUDES_RM380Z_H 12 13 #pragma once 14 15 #include "cpu/z80/z80.h" 16 #include "imagedev/cassette.h" 17 #include "machine/ram.h" 18 #include "imagedev/floppy.h" 19 #include "machine/wd_fdc.h" 20 #include "machine/keyboard.h" 21 22 // 23 // 24 // 25 26 #define RM380Z_MAINCPU_TAG "maincpu" 27 #define RM380Z_PORTS_ENABLED_HIGH ( m_port0 & 0x80 ) 28 #define RM380Z_PORTS_ENABLED_LOW ( ( m_port0 & 0x80 ) == 0x00 ) 29 30 #define RM380Z_VIDEOMODE_40COL 0x01 31 #define RM380Z_VIDEOMODE_80COL 0x02 32 33 #define RM380Z_CHDIMX 5 34 #define RM380Z_CHDIMY 9 35 #define RM380Z_NCX 8 36 #define RM380Z_NCY 16 37 #define RM380Z_SCREENCOLS 80 38 #define RM380Z_SCREENROWS 24 39 40 #define RM380Z_VIDEORAM_SIZE 0x600 41 #define RM380Z_SCREENSIZE 0x1200 42 43 44 // 45 // 46 // 47 48 49 class rm380z_state : public driver_device 50 { 51 public: rm380z_state(const machine_config & mconfig,device_type type,const char * tag)52 rm380z_state(const machine_config &mconfig, device_type type, const char *tag) : 53 driver_device(mconfig, type, tag), 54 m_maincpu(*this, RM380Z_MAINCPU_TAG), 55 m_cassette(*this, "cassette"), 56 m_messram(*this, RAM_TAG), 57 m_fdc(*this, "wd1771"), 58 m_floppy0(*this, "wd1771:0"), 59 m_floppy1(*this, "wd1771:1") 60 { 61 } 62 63 void rm480z(machine_config &config); 64 void rm380z(machine_config &config); 65 66 void init_rm380z(); 67 void init_rm380z34d(); 68 void init_rm380z34e(); 69 void init_rm480z(); 70 71 private: 72 void put_point(int charnum,int x,int y,int col); 73 void init_graphic_chars(); 74 75 void putChar(int charnum,int attribs,int x,int y,bitmap_ind16 &bitmap,unsigned char* chsb,int vmode); 76 void decode_videoram_char(int pos,uint8_t& chr,uint8_t& attrib); 77 void scroll_videoram(); 78 void config_videomode(); 79 void check_scroll_register(); 80 81 int writenum; 82 83 virtual void machine_reset() override; 84 virtual void machine_start() override; 85 86 uint8_t m_port0; 87 uint8_t m_port0_mask; 88 uint8_t m_port0_kbd; 89 uint8_t m_port1; 90 uint8_t m_fbfd; 91 uint8_t m_fbfe; 92 93 uint8_t m_graphic_chars[0x80][(RM380Z_CHDIMX+1)*(RM380Z_CHDIMY+1)]; 94 95 uint8_t m_mainVideoram[RM380Z_VIDEORAM_SIZE]; 96 uint8_t m_vramchars[RM380Z_SCREENSIZE]; 97 uint8_t m_vramattribs[RM380Z_SCREENSIZE]; 98 uint8_t m_vram[RM380Z_SCREENSIZE]; 99 100 int m_rasterlineCtr; 101 emu_timer* m_vblankTimer; 102 103 int m_old_fbfd; 104 int m_old_old_fbfd; 105 106 int m_videomode; 107 int m_old_videomode; 108 109 emu_timer *m_static_vblank_timer; 110 111 required_device<cpu_device> m_maincpu; 112 optional_device<cassette_image_device> m_cassette; 113 optional_device<ram_device> m_messram; 114 optional_device<fd1771_device> m_fdc; 115 optional_device<floppy_connector> m_floppy0; 116 optional_device<floppy_connector> m_floppy1; 117 118 void port_write(offs_t offset, uint8_t data); 119 uint8_t port_read(offs_t offset); 120 void port_write_1b00(offs_t offset, uint8_t data); 121 uint8_t port_read_1b00(offs_t offset); 122 123 uint8_t videoram_read(offs_t offset); 124 void videoram_write(offs_t offset, uint8_t data); 125 126 uint8_t hiram[0x1000]; 127 uint8_t hiram_read(offs_t offset); 128 void hiram_write(offs_t offset, uint8_t data); 129 130 uint8_t rm380z_portlow_r(); 131 void rm380z_portlow_w(offs_t offset, uint8_t data); 132 uint8_t rm380z_porthi_r(); 133 void rm380z_porthi_w(offs_t offset, uint8_t data); 134 135 void disk_0_control(uint8_t data); 136 137 void keyboard_put(u8 data); 138 139 DECLARE_MACHINE_RESET(rm480z); 140 141 void config_memory_map(); 142 void update_screen(bitmap_ind16 &bitmap); 143 uint32_t screen_update_rm380z(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 144 uint32_t screen_update_rm480z(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 145 TIMER_CALLBACK_MEMBER(static_vblank_timer); 146 147 void rm380z_io(address_map &map); 148 void rm380z_mem(address_map &map); 149 void rm480z_io(address_map &map); 150 void rm480z_mem(address_map &map); 151 }; 152 153 #endif // MAME_INCLUDES_RM380Z_H 154