Previous 15994 Revisions Next

r13098 Sunday 23rd October, 2011 at 11:49:36 UTC by Sandro Ronco
mstation: Added LCD emulation. (no whatsnew)
[src/mess/drivers]mstation.c

src/mess/drivers/mstation.c
r13097r13098
4545   UINT8 *m_ram_base;
4646   int m_flash_at_0x4000;
4747   int m_flash_at_0x8000;
48   UINT8 *m_vram;
49   UINT8 m_screen_column;
50   UINT8 m_port2;
4851
4952   DECLARE_READ8_MEMBER( flash_0x0000_read_handler );
5053   DECLARE_WRITE8_MEMBER( flash_0x0000_write_handler );
r13097r13098
5356   DECLARE_READ8_MEMBER( flash_0x8000_read_handler );
5457   DECLARE_WRITE8_MEMBER( flash_0x8000_write_handler );
5558
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
5666   void refresh_memory(UINT8 bank, UINT8 chip_select);
5767   DECLARE_READ8_MEMBER( bank1_r );
5868   DECLARE_WRITE8_MEMBER( bank1_w );
5969   DECLARE_READ8_MEMBER( bank2_r );
6070   DECLARE_WRITE8_MEMBER( bank2_w );
6171
72   DECLARE_READ8_MEMBER( battery_status_r );
73   DECLARE_WRITE8_MEMBER( port2_w );
74
6275   virtual void machine_start();
6376   virtual void machine_reset();
6477   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
r13097r13098
7689
7790READ8_MEMBER( mstation_state::flash_0x4000_read_handler )
7891{
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);
8096}
8197
8298WRITE8_MEMBER( mstation_state::flash_0x4000_write_handler )
r13097r13098
94110   m_flashes[m_flash_at_0x8000]->write(((m_bank2[0] & 0x3f)<<14) | offset, data);
95111}
96112
113
114//***************************************************************************
115//  video hardware emulation
116//***************************************************************************/
117
118void 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
126UINT8 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
134READ8_MEMBER ( mstation_state::lcd_left_r )  {   return lcd_r(offset, m_screen_column);   }
135WRITE8_MEMBER( mstation_state::lcd_left_w )  {   lcd_w(offset, m_screen_column, data);   }
136READ8_MEMBER ( mstation_state::lcd_right_r ) {   return lcd_r(offset, m_screen_column + 20);   }
137WRITE8_MEMBER( mstation_state::lcd_right_w ) {   lcd_w(offset, m_screen_column + 20, data);   }
138
97139bool mstation_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
98140{
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      }
99155   return 0;
100156}
101157
r13097r13098
129185         program->install_readwrite_bank (bank * 0x4000, bank * 0x4000 + 0x3fff, bank_tag);
130186         active_flash = -1;
131187         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;
132196      default:
133197         program->unmap_readwrite(bank * 0x4000, bank * 0x4000 + 0x3fff);
134198         active_flash = -1;
r13097r13098
161225}
162226
163227
228
229WRITE8_MEMBER( mstation_state::port2_w )
230{
231   m_port2 = data;
232}
233
234READ8_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
164244static ADDRESS_MAP_START(mstation_mem, AS_PROGRAM, 8, mstation_state)
165245   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(flash_0x0000_read_handler, flash_0x0000_write_handler)
166246   AM_RANGE(0x4000, 0x7fff) AM_READWRITE_BANK("bank1")      // bank 1
r13097r13098
170250
171251static ADDRESS_MAP_START(mstation_io , AS_IO, 8, mstation_state)
172252   ADDRESS_MAP_GLOBAL_MASK(0xff)
253   AM_RANGE( 0x02, 0x02 ) AM_WRITE(port2_w)
173254   AM_RANGE( 0x05, 0x06 ) AM_READWRITE(bank1_r, bank1_w)
174255   AM_RANGE( 0x07, 0x08 ) AM_READWRITE(bank2_r, bank2_w)
256   AM_RANGE( 0x09, 0x09 ) AM_READ(battery_status_r)
175257   AM_RANGE( 0x10, 0x1f ) AM_DEVREADWRITE("rtc", rp5c01_device, read, write)
176258ADDRESS_MAP_END
177259
r13097r13098
185267   m_flashes[0] = machine().device<intelfsh8_device>("flash0");
186268   m_flashes[1] = machine().device<intelfsh8_device>("flash1");
187269
270   // allocate the vireoram
271   m_vram = (UINT8*)machine().region_alloc( "vram", 9600, 1, ENDIANNESS_LITTLE )->base();
188272   m_ram_base = (UINT8*)ram_get_ptr(machine().device(RAM_TAG));
189273
190274   // map firsh RAM bank at 0xc000-0xffff
r13097r13098
198282   m_flash_at_0x8000 = 0;
199283   m_bank1[0] =  m_bank1[1] = 0;
200284   m_bank2[0] =  m_bank2[1] = 0;
285   memset(m_vram, 0, 9600);
201286
202287   // reset banks
203288   refresh_memory(1, m_bank1[1]);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team