Previous 199869 Revisions Next

r20265 Monday 14th January, 2013 at 17:37:34 UTC by Angelo Salese
Major clean-ups of SMC-777
[src/mess/drivers]smc777.c

trunk/src/mess/drivers/smc777.c
r20264r20265
3838   { }
3939
4040   optional_device<sn76489a_device> m_sn;
41
42   UINT8 *m_ipl_rom;
43   UINT8 *m_work_ram;
44   UINT8 *m_vram;
45   UINT8 *m_attr;
46   UINT8 *m_gvram;
47   UINT8 *m_pcg;
48
4149   UINT16 m_cursor_addr;
4250   UINT16 m_cursor_raster;
4351   UINT8 m_keyb_press;
r20264r20265
107115{
108116   int x,y,yi;
109117   UINT16 count;
110   UINT8 *vram = machine().root_device().memregion("vram")->base();
111   UINT8 *attr = machine().root_device().memregion("attr")->base();
112   UINT8 *gram = memregion("fbuf")->base();
113   UINT8 *gfx_data = machine().root_device().memregion("pcg")->base();
114
115118   int x_width;
116119
117120   bitmap.fill(machine().pens[m_backdrop_pen], cliprect);
r20264r20265
128131         {
129132            UINT16 color;
130133
131            color = (gram[count] & 0xf0) >> 4;
134            color = (m_gvram[count] & 0xf0) >> 4;
132135            /* todo: clean this up! */
133136            if(x_width == 2)
134137            {
r20264r20265
140143               bitmap.pix16(y+yi+CRTC_MIN_Y, x*4+1+CRTC_MIN_X) = machine().pens[color];
141144            }
142145
143            color = (gram[count] & 0x0f) >> 0;
146            color = (m_gvram[count] & 0x0f) >> 0;
144147            if(x_width == 2)
145148            {
146149               bitmap.pix16(y+yi+CRTC_MIN_Y, x*2+1+CRTC_MIN_X) = machine().pens[color];
r20264r20265
171174         --xx x--- bg color (00 transparent, 01 white, 10 black, 11 complementary to fg color
172175         ---- -xxx fg color
173176         */
174         int tile = vram[count];
175         int color = attr[count] & 7;
176         int bk_color = (attr[count] & 0x18) >> 3;
177         int blink = attr[count] & 0x40;
177         int tile = m_vram[count];
178         int color = m_attr[count] & 7;
179         int bk_color = (m_attr[count] & 0x18) >> 3;
180         int blink = m_attr[count] & 0x40;
178181         int xi;
179182         int bk_pen;
180183         //int bk_struct[4] = { -1, 0x10, 0x11, (color & 7) ^ 8 };
r20264r20265
199202            {
200203               int pen;
201204
202               pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? (color) : bk_pen;
205               pen = ((m_pcg[tile*8+yi]>>(7-xi)) & 1) ? (color) : bk_pen;
203206
204207               if (pen != -1)
205208                  bitmap.pix16(y*8+CRTC_MIN_Y+yi, x*8+CRTC_MIN_X+xi) = machine().pens[pen];
r20264r20265
261264
262265READ8_MEMBER(smc777_state::smc777_vram_r)
263266{
264   UINT8 *vram = memregion("vram")->base();
265267   UINT16 vram_index;
266268
267269   vram_index  = ((offset & 0x0007) << 8);
268270   vram_index |= ((offset & 0xff00) >> 8);
269271
270   return vram[vram_index];
272   return m_vram[vram_index];
271273}
272274
273275READ8_MEMBER(smc777_state::smc777_attr_r)
274276{
275   UINT8 *attr = memregion("attr")->base();
276277   UINT16 vram_index;
277278
278279   vram_index  = ((offset & 0x0007) << 8);
279280   vram_index |= ((offset & 0xff00) >> 8);
280281
281   return attr[vram_index];
282   return m_attr[vram_index];
282283}
283284
284285READ8_MEMBER(smc777_state::smc777_pcg_r)
285286{
286   UINT8 *pcg = memregion("pcg")->base();
287287   UINT16 vram_index;
288288
289289   vram_index  = ((offset & 0x0007) << 8);
290290   vram_index |= ((offset & 0xff00) >> 8);
291291
292   return pcg[vram_index];
292   return m_pcg[vram_index];
293293}
294294
295295WRITE8_MEMBER(smc777_state::smc777_vram_w)
296296{
297   UINT8 *vram = memregion("vram")->base();
298297   UINT16 vram_index;
299298
300299   vram_index  = ((offset & 0x0007) << 8);
301300   vram_index |= ((offset & 0xff00) >> 8);
302301
303   vram[vram_index] = data;
302   m_vram[vram_index] = data;
304303}
305304
306305WRITE8_MEMBER(smc777_state::smc777_attr_w)
307306{
308   UINT8 *attr = memregion("attr")->base();
309307   UINT16 vram_index;
310308
311309   vram_index  = ((offset & 0x0007) << 8);
312310   vram_index |= ((offset & 0xff00) >> 8);
313311
314   attr[vram_index] = data;
312   m_attr[vram_index] = data;
315313}
316314
317315WRITE8_MEMBER(smc777_state::smc777_pcg_w)
318316{
319   UINT8 *pcg = memregion("pcg")->base();
320317   UINT16 vram_index;
321318
322319   vram_index  = ((offset & 0x0007) << 8);
323320   vram_index |= ((offset & 0xff00) >> 8);
324321
325   pcg[vram_index] = data;
322   m_pcg[vram_index] = data;
326323
327324   machine().gfx[0]->mark_dirty(vram_index >> 3);
328325}
329326
330327READ8_MEMBER(smc777_state::smc777_fbuf_r)
331328{
332   UINT8 *fbuf = memregion("fbuf")->base();
333329   UINT16 vram_index;
334330
335331   vram_index  = ((offset & 0x007f) << 8);
336332   vram_index |= ((offset & 0xff00) >> 8);
337333
338   return fbuf[vram_index];
334   return m_gvram[vram_index];
339335}
340336
341337WRITE8_MEMBER(smc777_state::smc777_fbuf_w)
342338{
343   UINT8 *fbuf = memregion("fbuf")->base();
344339   UINT16 vram_index;
345340
346341   vram_index  = ((offset & 0x00ff) << 8);
347342   vram_index |= ((offset & 0xff00) >> 8);
348343
349   fbuf[vram_index] = data;
344   m_gvram[vram_index] = data;
350345}
351346
352347
r20264r20265
579574
580575READ8_MEMBER(smc777_state::smc777_mem_r)
581576{
582   UINT8 *wram = memregion("wram")->base();
583   UINT8 *bios = memregion("bios")->base();
584577   UINT8 z80_r;
585578
586579   if(m_raminh_prefetch != 0xff) //do the bankswitch AFTER that the prefetch instruction is executed (FIXME: this is an hackish implementation)
r20264r20265
595588   }
596589
597590   if(m_raminh == 1 && ((offset & 0xc000) == 0))
598      return bios[offset];
591      return m_ipl_rom[offset];
599592
600   return wram[offset];
593   return m_work_ram[offset];
601594}
602595
603596WRITE8_MEMBER(smc777_state::smc777_mem_w)
604597{
605   UINT8 *wram = memregion("wram")->base();
606
607   wram[offset] = data;
598   m_work_ram[offset] = data;
608599}
609600
610601READ8_MEMBER(smc777_state::smc777_irq_mask_r)
r20264r20265
954945   }
955946}
956947
948static const gfx_layout smc777_charlayout =
949{
950   8, 8,
951   0x800 / 8,
952   1,
953   { 0 },
954   { 0, 1, 2, 3, 4, 5, 6, 7 },
955   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
956   8*8
957};
958
957959void smc777_state::machine_start()
958960{
961   m_ipl_rom = memregion("ipl")->base();
962   m_work_ram = auto_alloc_array(machine(), UINT8, 0x10000);
963   m_vram = auto_alloc_array(machine(), UINT8, 0x800);
964   m_attr = auto_alloc_array(machine(), UINT8, 0x800);
965   m_gvram = auto_alloc_array(machine(), UINT8, 0x8000);
966   m_pcg = auto_alloc_array(machine(), UINT8, 0x800);
967
959968   beep_set_frequency(machine().device(BEEPER_TAG),300); //guesswork
960969   beep_set_state(machine().device(BEEPER_TAG),0);
970
971   state_save_register_global_pointer(machine(), m_work_ram, 0x10000);
972   state_save_register_global_pointer(machine(), m_vram, 0x800);
973   state_save_register_global_pointer(machine(), m_attr, 0x800);
974   state_save_register_global_pointer(machine(), m_gvram, 0x8000);
975   state_save_register_global_pointer(machine(), m_pcg, 0x800);
976
977   machine().gfx[0] = auto_alloc(machine(), gfx_element(machine(), smc777_charlayout, (UINT8 *)m_pcg, 8, 0));
961978}
962979
963980void smc777_state::machine_reset()
r20264r20265
967984   m_raminh_prefetch = 0xff;
968985}
969986
970static const gfx_layout smc777_charlayout =
971{
972   8, 8,
973   RGN_FRAC(1,1),
974   1,
975   { 0 },
976   { 0, 1, 2, 3, 4, 5, 6, 7 },
977   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
978   8*8
979};
980987
981static GFXDECODE_START( smc777 )
982   GFXDECODE_ENTRY( "pcg", 0x0000, smc777_charlayout, 0, 8 )
983GFXDECODE_END
984
985988static const mc6845_interface mc6845_intf =
986989{
987990   "screen",   /* screen we are acting on */
r20264r20265
10761079   MCFG_CPU_IO_MAP(smc777_io)
10771080   MCFG_CPU_VBLANK_INT_DRIVER("screen", smc777_state, smc777_vblank_irq)
10781081
1079
10801082   /* video hardware */
10811083   MCFG_SCREEN_ADD("screen", RASTER)
10821084   MCFG_SCREEN_REFRESH_RATE(60)
r20264r20265
10861088   MCFG_SCREEN_UPDATE_DRIVER(smc777_state, screen_update_smc777)
10871089
10881090   MCFG_PALETTE_LENGTH(SMC777_NUMPENS)
1089   MCFG_GFXDECODE(smc777)
10901091
10911092   MCFG_MC6845_ADD("crtc", H46505, MASTER_CLOCK/2, mc6845_intf)    /* unknown clock, hand tuned to get ~60 fps */
10921093
1093
10941094   MCFG_MB8876_ADD("fdc",smc777_mb8876_interface)
10951095   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(smc777_floppy_interface)
10961096   MCFG_SOFTWARE_LIST_ADD("flop_list","smc777")
r20264r20265
11091109
11101110/* ROM definition */
11111111ROM_START( smc777 )
1112   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
1113
11141112   /* shadow ROM */
1115   ROM_REGION( 0x10000, "bios", ROMREGION_ERASEFF )
1113   ROM_REGION( 0x10000, "ipl", ROMREGION_ERASEFF )
11161114   ROM_SYSTEM_BIOS(0, "1st", "1st rev.")
11171115   ROMX_LOAD( "smcrom.dat", 0x0000, 0x4000, CRC(b2520d31) SHA1(3c24b742c38bbaac85c0409652ba36e20f4687a1), ROM_BIOS(1))
11181116   ROM_SYSTEM_BIOS(1, "2nd", "2nd rev.")
r20264r20265
11201118
11211119   ROM_REGION( 0x800, "mcu", ROMREGION_ERASEFF )
11221120   ROM_LOAD( "i80xx", 0x000, 0x800, NO_DUMP ) // keyboard mcu, needs decapping
1123
1124   ROM_REGION( 0x10000, "wram", ROMREGION_ERASE00 )
1125
1126   ROM_REGION( 0x800, "vram", ROMREGION_ERASE00 )
1127
1128   ROM_REGION( 0x800, "attr", ROMREGION_ERASE00 )
1129
1130   ROM_REGION( 0x800, "pcg", ROMREGION_ERASE00 )
1131
1132   ROM_REGION( 0x8000,"fbuf", ROMREGION_ERASE00 )
11331121ROM_END
11341122
11351123/* Driver */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team