src/mess/drivers/mstation.c
| r13097 | r13098 | |
| 45 | 45 | UINT8 *m_ram_base; |
| 46 | 46 | int m_flash_at_0x4000; |
| 47 | 47 | int m_flash_at_0x8000; |
| 48 | UINT8 *m_vram; |
| 49 | UINT8 m_screen_column; |
| 50 | UINT8 m_port2; |
| 48 | 51 | |
| 49 | 52 | DECLARE_READ8_MEMBER( flash_0x0000_read_handler ); |
| 50 | 53 | DECLARE_WRITE8_MEMBER( flash_0x0000_write_handler ); |
| r13097 | r13098 | |
| 53 | 56 | DECLARE_READ8_MEMBER( flash_0x8000_read_handler ); |
| 54 | 57 | DECLARE_WRITE8_MEMBER( flash_0x8000_write_handler ); |
| 55 | 58 | |
| 59 | void lcd_w(UINT16 offset, int column, UINT8 data); |
| 60 | UINT8 lcd_r(UINT16 offset, int column); |
| 61 | DECLARE_READ8_MEMBER( lcd_right_r ); |
| 62 | DECLARE_WRITE8_MEMBER( lcd_right_w ); |
| 63 | DECLARE_READ8_MEMBER( lcd_left_r ); |
| 64 | DECLARE_WRITE8_MEMBER( lcd_left_w ); |
| 65 | |
| 56 | 66 | void refresh_memory(UINT8 bank, UINT8 chip_select); |
| 57 | 67 | DECLARE_READ8_MEMBER( bank1_r ); |
| 58 | 68 | DECLARE_WRITE8_MEMBER( bank1_w ); |
| 59 | 69 | DECLARE_READ8_MEMBER( bank2_r ); |
| 60 | 70 | DECLARE_WRITE8_MEMBER( bank2_w ); |
| 61 | 71 | |
| 72 | DECLARE_READ8_MEMBER( battery_status_r ); |
| 73 | DECLARE_WRITE8_MEMBER( port2_w ); |
| 74 | |
| 62 | 75 | virtual void machine_start(); |
| 63 | 76 | virtual void machine_reset(); |
| 64 | 77 | virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect); |
| r13097 | r13098 | |
| 76 | 89 | |
| 77 | 90 | READ8_MEMBER( mstation_state::flash_0x4000_read_handler ) |
| 78 | 91 | { |
| 79 | | return m_flashes[m_flash_at_0x4000]->read(((m_bank1[0] & 0x3f)<<14) | offset); |
| 92 | if (m_flash_at_0x4000 == 1) |
| 93 | return 0x00; //TODO: read from SST-28SF040 |
| 94 | else |
| 95 | return m_flashes[m_flash_at_0x4000]->read(((m_bank1[0] & 0x3f)<<14) | offset); |
| 80 | 96 | } |
| 81 | 97 | |
| 82 | 98 | WRITE8_MEMBER( mstation_state::flash_0x4000_write_handler ) |
| r13097 | r13098 | |
| 94 | 110 | m_flashes[m_flash_at_0x8000]->write(((m_bank2[0] & 0x3f)<<14) | offset, data); |
| 95 | 111 | } |
| 96 | 112 | |
| 113 | |
| 114 | //*************************************************************************** |
| 115 | // video hardware emulation |
| 116 | //***************************************************************************/ |
| 117 | |
| 118 | void mstation_state::lcd_w(UINT16 offset, int column, UINT8 data) |
| 119 | { |
| 120 | if (m_port2 & 0x08) |
| 121 | m_vram[(column * 240) + (offset % 240)] = data; |
| 122 | else |
| 123 | m_screen_column = data % 20; |
| 124 | } |
| 125 | |
| 126 | UINT8 mstation_state::lcd_r(UINT16 offset, int column) |
| 127 | { |
| 128 | if (m_port2 & 0x08) |
| 129 | return m_vram[(column * 240) + (offset % 240)]; |
| 130 | else |
| 131 | return m_screen_column % 20; |
| 132 | } |
| 133 | |
| 134 | READ8_MEMBER ( mstation_state::lcd_left_r ) { return lcd_r(offset, m_screen_column); } |
| 135 | WRITE8_MEMBER( mstation_state::lcd_left_w ) { lcd_w(offset, m_screen_column, data); } |
| 136 | READ8_MEMBER ( mstation_state::lcd_right_r ) { return lcd_r(offset, m_screen_column + 20); } |
| 137 | WRITE8_MEMBER( mstation_state::lcd_right_w ) { lcd_w(offset, m_screen_column + 20, data); } |
| 138 | |
| 97 | 139 | bool mstation_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect) |
| 98 | 140 | { |
| 141 | for (int x=0; x<40; x++) |
| 142 | for (int y=0; y<128; y++) |
| 143 | { |
| 144 | UINT8 data = m_vram[56 + y + x * 240]; |
| 145 | |
| 146 | for (int b=0; b<8; b++) |
| 147 | { |
| 148 | // columns are inverted (right to left) |
| 149 | int col = ((x < 20) ? 19 : 59) - x; |
| 150 | |
| 151 | *BITMAP_ADDR16(&bitmap, y, col*8 + b)= BIT(data, 0); |
| 152 | data >>= 1; |
| 153 | } |
| 154 | } |
| 99 | 155 | return 0; |
| 100 | 156 | } |
| 101 | 157 | |
| r13097 | r13098 | |
| 129 | 185 | program->install_readwrite_bank (bank * 0x4000, bank * 0x4000 + 0x3fff, bank_tag); |
| 130 | 186 | active_flash = -1; |
| 131 | 187 | break; |
| 188 | case 2: // left LCD panel |
| 189 | program->install_readwrite_handler(bank * 0x4000, bank * 0x4000 + 0x3fff, 0, 0, read8_delegate(FUNC(mstation_state::lcd_left_r), this), write8_delegate(FUNC(mstation_state::lcd_left_w), this)); |
| 190 | active_flash = -1; |
| 191 | break; |
| 192 | case 4: // right LCD panel |
| 193 | program->install_readwrite_handler(bank * 0x4000, bank * 0x4000 + 0x3fff, 0, 0, read8_delegate(FUNC(mstation_state::lcd_right_r), this), write8_delegate(FUNC(mstation_state::lcd_right_w), this)); |
| 194 | active_flash = -1; |
| 195 | break; |
| 132 | 196 | default: |
| 133 | 197 | program->unmap_readwrite(bank * 0x4000, bank * 0x4000 + 0x3fff); |
| 134 | 198 | active_flash = -1; |
| r13097 | r13098 | |
| 161 | 225 | } |
| 162 | 226 | |
| 163 | 227 | |
| 228 | |
| 229 | WRITE8_MEMBER( mstation_state::port2_w ) |
| 230 | { |
| 231 | m_port2 = data; |
| 232 | } |
| 233 | |
| 234 | READ8_MEMBER( mstation_state::battery_status_r ) |
| 235 | { |
| 236 | /* |
| 237 | bit 0-6 - unknown |
| 238 | bit 7 - battery status |
| 239 | */ |
| 240 | return 0x80; |
| 241 | } |
| 242 | |
| 243 | |
| 164 | 244 | static ADDRESS_MAP_START(mstation_mem, AS_PROGRAM, 8, mstation_state) |
| 165 | 245 | AM_RANGE(0x0000, 0x3fff) AM_READWRITE(flash_0x0000_read_handler, flash_0x0000_write_handler) |
| 166 | 246 | AM_RANGE(0x4000, 0x7fff) AM_READWRITE_BANK("bank1") // bank 1 |
| r13097 | r13098 | |
| 170 | 250 | |
| 171 | 251 | static ADDRESS_MAP_START(mstation_io , AS_IO, 8, mstation_state) |
| 172 | 252 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 253 | AM_RANGE( 0x02, 0x02 ) AM_WRITE(port2_w) |
| 173 | 254 | AM_RANGE( 0x05, 0x06 ) AM_READWRITE(bank1_r, bank1_w) |
| 174 | 255 | AM_RANGE( 0x07, 0x08 ) AM_READWRITE(bank2_r, bank2_w) |
| 256 | AM_RANGE( 0x09, 0x09 ) AM_READ(battery_status_r) |
| 175 | 257 | AM_RANGE( 0x10, 0x1f ) AM_DEVREADWRITE("rtc", rp5c01_device, read, write) |
| 176 | 258 | ADDRESS_MAP_END |
| 177 | 259 | |
| r13097 | r13098 | |
| 185 | 267 | m_flashes[0] = machine().device<intelfsh8_device>("flash0"); |
| 186 | 268 | m_flashes[1] = machine().device<intelfsh8_device>("flash1"); |
| 187 | 269 | |
| 270 | // allocate the vireoram |
| 271 | m_vram = (UINT8*)machine().region_alloc( "vram", 9600, 1, ENDIANNESS_LITTLE )->base(); |
| 188 | 272 | m_ram_base = (UINT8*)ram_get_ptr(machine().device(RAM_TAG)); |
| 189 | 273 | |
| 190 | 274 | // map firsh RAM bank at 0xc000-0xffff |
| r13097 | r13098 | |
| 198 | 282 | m_flash_at_0x8000 = 0; |
| 199 | 283 | m_bank1[0] = m_bank1[1] = 0; |
| 200 | 284 | m_bank2[0] = m_bank2[1] = 0; |
| 285 | memset(m_vram, 0, 9600); |
| 201 | 286 | |
| 202 | 287 | // reset banks |
| 203 | 288 | refresh_memory(1, m_bank1[1]); |