1 // license:BSD-3-Clause 2 // copyright-holders:Curt Coder 3 /*************************************************************************** 4 5 MOS 7360/8360 Text Edit Device (TED) emulation 6 7 **************************************************************************** 8 _____ _____ 9 DB6 1 |* \_/ | 40 Vcc 10 DB5 2 | | 39 DB7 11 DB4 3 | | 38 DB8 12 DB3 4 | | 37 DB9 13 DB2 5 | | 36 DB10 14 DB1 6 | | 35 DB11 15 DB0 7 | | 34 A13 16 _IRQ 8 | | 33 A12 17 LP 9 | | 32 A11 18 _CS 10 | MOS7360 | 31 A10 19 R/W 11 | | 30 A9 20 BA 12 | | 29 A8 21 Vdd 13 | | 28 A7 22 COLOR 14 | | 27 A6 23 S/LUM 15 | | 26 A5 24 AEC 16 | | 25 A4 25 PH0 17 | | 24 A3 26 PHIN 18 | | 23 A2 27 PHCOL 19 | | 22 A1 28 Vss 20 |_____________| 21 A0 29 30 ***************************************************************************/ 31 32 #ifndef MAME_SOUND_MOS7360_H 33 #define MAME_SOUND_MOS7360_H 34 35 #pragma once 36 37 38 39 40 //************************************************************************** 41 // MACROS / CONSTANTS 42 //************************************************************************** 43 44 /* of course you clock select an other clock, but for accurate */ 45 /* video timing (these are used in c16/c116/plus4) */ 46 #define TED7360NTSC_CLOCK (14318180/4) 47 #define TED7360PAL_CLOCK (17734470/5) 48 49 50 51 /*************************************************************************** 52 TYPE DEFINITIONS 53 ***************************************************************************/ 54 55 // ======================> mos7360_device 56 57 class mos7360_device : public device_t, 58 public device_memory_interface, 59 public device_sound_interface, 60 public device_video_interface 61 { 62 public: 63 static constexpr unsigned NTSC_VRETRACERATE = 60; 64 static constexpr unsigned PAL_VRETRACERATE = 50; 65 static constexpr unsigned HRETRACERATE = 15625; 66 67 /* the following values depend on the VIC clock, 68 * but to achieve TV-frequency the clock must have a fix frequency */ 69 static constexpr unsigned HSIZE = 320; 70 static constexpr unsigned VSIZE = 200; 71 72 /* pal 50 Hz vertical screen refresh, screen consists of 312 lines 73 * ntsc 60 Hz vertical screen refresh, screen consists of 262 lines */ 74 static constexpr unsigned NTSC_LINES = 261; 75 static constexpr unsigned PAL_LINES = 312; 76 77 // construction/destruction 78 mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 79 80 // callbacks write_irq_callback()81 auto write_irq_callback() { return m_write_irq.bind(); } read_k_callback()82 auto read_k_callback() { return m_read_k.bind(); } 83 84 virtual space_config_vector memory_space_config() const override; 85 86 uint8_t read(offs_t offset, int &cs0, int &cs1); 87 void write(offs_t offset, uint8_t data, int &cs0, int &cs1); 88 89 uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 90 91 void mos7360_videoram_map(address_map &map); 92 protected: 93 enum 94 { 95 TYPE_7360 96 }; 97 98 enum 99 { 100 TIMER_ID_1, 101 TIMER_ID_2, 102 TIMER_ID_3, 103 TIMER_LINE, 104 TIMER_FRAME 105 }; 106 107 // device-level overrides 108 virtual void device_start() override; 109 virtual void device_reset() override; 110 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 111 112 // device_sound_interface callbacks 113 virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; 114 115 inline void set_interrupt(int mask); 116 inline void clear_interrupt(int mask); 117 inline int rastercolumn(); 118 inline uint8_t read_ram(offs_t offset); 119 inline uint8_t read_rom(offs_t offset); 120 121 void draw_character(int ybegin, int yend, int ch, int yoff, int xoff, uint16_t *color); 122 void draw_character_multi(int ybegin, int yend, int ch, int yoff, int xoff); 123 void draw_bitmap(int ybegin, int yend, int ch, int yoff, int xoff); 124 void draw_bitmap_multi(int ybegin, int yend, int ch, int yoff, int xoff); 125 void draw_cursor(int ybegin, int yend, int yoff, int xoff, int color); 126 void drawlines(int first, int last); 127 void soundport_w(int offset, int data); 128 void frame_interrupt_gen(); 129 void raster_interrupt_gen(); 130 int cs0_r(offs_t offset); 131 int cs1_r(offs_t offset); 132 133 const address_space_config m_videoram_space_config; 134 135 devcb_write_line m_write_irq; 136 devcb_read8 m_read_k; 137 138 sound_stream *m_stream; 139 140 uint8_t m_reg[0x20]; 141 uint8_t m_last_data; 142 143 bitmap_rgb32 m_bitmap; 144 145 int m_rom; 146 147 int m_frame_count; 148 149 int m_lines; 150 int m_timer1_active, m_timer2_active, m_timer3_active; 151 emu_timer *m_timer1, *m_timer2, *m_timer3; 152 int m_cursor1; 153 154 int m_chargenaddr, m_bitmapaddr, m_videoaddr; 155 156 int m_x_begin, m_x_end; 157 int m_y_begin, m_y_end; 158 159 uint16_t m_c16_bitmap[2], m_bitmapmulti[4], m_mono[2], m_monoinversed[2], m_multi[4], m_ecmcolor[2], m_colors[5]; 160 161 int m_rasterline, m_lastline; 162 double m_rastertime; 163 164 /* sound part */ 165 std::unique_ptr<uint8_t[]> m_noise; 166 int m_tone1pos, m_tone2pos, 167 m_tone1samples, m_tone2samples, 168 m_noisesize, /* number of samples */ 169 m_noisepos, /* pos of tone */ 170 m_noisesamples; /* count of samples to give out per tone */ 171 172 emu_timer *m_line_timer; 173 emu_timer *m_frame_timer; 174 }; 175 176 177 // device type definition 178 DECLARE_DEVICE_TYPE(MOS7360, mos7360_device) 179 180 #endif // MAME_SOUND_MOS7360_H 181