Previous 15994 Revisions Next

r7654 Saturday 27th March, 2010 at 17:01:17 UTC by Angelo Salese
[MZ2500]: Implemented basic video and irq system
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r7653r7654
22
33    Sharp MZ-2500 (c) 1985 Sharp Corporation
44
5    26/03/2010 Skeleton driver.
5   preliminary driver by Angelo Salese
66
77    memory map:
88
99    0x00000-0x3ffff Work RAM
1010    0x40000-0x5ffff CG RAM (bitswapped!)
11    0x60000-0x67fff NOP?
11    0x60000-0x67fff "Read modify write" area (related to the CG RAM)
1212    0x68000-0x6ffff IPL ROM
1313    0x70000-0x71fff TVRAM
1414    0x72000-0x73fff PCG / Kanji RAM
r7653r7654
2323#include "emu.h"
2424#include "cpu/z80/z80.h"
2525
26/* machine stuff */
2627static UINT8 bank_val[8],bank_addr;
28static UINT8 irq_sel,irq_vector[4];
2729
30/* video stuff*/
31static UINT8 text_reg[0x100], text_reg_index;
32
2833static VIDEO_START( mz2500 )
2934{
3035}
3136
3237static VIDEO_UPDATE( mz2500 )
3338{
39   UINT8 *vram = memory_region(screen->machine, "maincpu");
40   int x,y,count;
41   const gfx_element *gfx = screen->machine->gfx[0];
42
43   count = 0x70000;
44
45   for (y=0;y<32;y+=2)
46   {
47      for (x=0;x<32;x++)
48      {
49         int tile = vram[count+0x000] & 0xfe;
50         //int attr = vram[count+0x800];
51         int tile_bank = vram[count+0x1000] & 0x3f;
52
53         tile|= tile_bank << 8;
54
55         drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*8,(y)*8);
56         drawgfx_opaque(bitmap,cliprect,gfx,tile+1,0,0,0,x*8,(y+1)*8);
57
58         count++;
59      }
60   }
61
62
3463    return 0;
3564}
3665
r7653r7654
6392
6493   bank_val[bank_addr] = data & 0x3f;
6594
66   printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2);
95//   printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2);
6796
6897   memory_set_bankptr(space->machine, bank_name[bank_addr], &ROM[bank_val[bank_addr]*0x2000]);
6998
r7653r7654
71100   bank_addr&=7;
72101}
73102
103static READ8_HANDLER( mz2500_crtc_r )
104{
105   static UINT8 vblank_bit, hblank_bit;
74106
107   /* TODO */
108   vblank_bit^= 1;//video_screen_get_vblank(space->machine->primary_screen) ? 0 : 1;
109   hblank_bit = video_screen_get_hblank(space->machine->primary_screen) ? 0 : 2;
110
111   return vblank_bit | hblank_bit;
112}
113
114static WRITE8_HANDLER( mz2500_crtc_w )
115{
116   switch(offset)
117   {
118      case 0: text_reg_index = data; break;
119      case 1:
120         text_reg[text_reg_index] = data;
121         //printf("[%02x]<- %02x\n",text_reg[text_reg_index],text_reg_index);
122         break;
123      case 2: /* CG MASK reg */ break;
124      case 3:
125         /* Font size reg */
126         printf("%02x FONT\n",data);
127         break;
128   }
129}
130
131static WRITE8_HANDLER( mz2500_irq_sel_w )
132{
133   irq_sel = data;
134   // FIXME: bit 0-3 are irq masks?
135//   printf("%02x\n",irq_sel);
136}
137
138static WRITE8_HANDLER( mz2500_irq_data_w )
139{
140   if(irq_sel & 0x80)
141      irq_vector[0] = data; //CRTC
142   if(irq_sel & 0x40)
143      irq_vector[1] = data; //i8253
144   if(irq_sel & 0x20)
145      irq_vector[2] = data; //printer
146   if(irq_sel & 0x10)
147      irq_vector[3] = data; //RP5c15
148}
149
75150static ADDRESS_MAP_START(mz2500_map, ADDRESS_SPACE_PROGRAM, 8)
76151   AM_RANGE(0x0000, 0x1fff) AM_RAMBANK("bank0")
77152   AM_RANGE(0x2000, 0x3fff) AM_RAMBANK("bank1")
r7653r7654
83158   AM_RANGE(0xe000, 0xffff) AM_RAMBANK("bank7")
84159ADDRESS_MAP_END
85160
161#if 0
162
163static READ8_HANDLER( kludge_r )
164{
165   return mame_rand(space->machine);
166}
167#endif
168
86169static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8)
87170   ADDRESS_MAP_GLOBAL_MASK(0xff)
88171//   AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w)
r7653r7654
99182   AM_RANGE(0xb5, 0xb5) AM_READWRITE(mz2500_bank_data_r,mz2500_bank_data_w)
100183//    AM_RANGE(0xb8, 0xb9) AM_READWRITE(kanji_r,kanji_w)
101184//   AM_RANGE(0xbc, 0xbd) AM_READWRITE(crtc_r,crtc_w)
102//   AM_RANGE(0xc6, 0xc7) AM_WRITE(irq_w)
185   AM_RANGE(0xc6, 0xc6) AM_WRITE(mz2500_irq_sel_w)
186   AM_RANGE(0xc7, 0xc7) AM_WRITE(mz2500_irq_data_w)
103187//   AM_RANGE(0xc8, 0xc9) AM_READWRITE(opn_r,opn_w)
104188//   AM_RANGE(0xca, 0xca) AM_READWRITE(voice_r,voice_w)
105189//   AM_RANGE(0xcc, 0xcc) AM_READWRITE(calendar_r,calendar_w)
r7653r7654
111195//   AM_RANGE(0xe8, 0xeb) AM_READWRITE(pio1_r,pio1_w)
112196//   AM_RANGE(0xef, 0xef) AM_READWRITE(joystick_r,joystick_w)
113197//   AM_RANGE(0xf0, 0xf3) AM_WRITE(timer_w)
114//   AM_RANGE(0xf4, 0xf7) AM_READWRITE(crtc_r,crtc_w)
198   AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_r) AM_WRITE(mz2500_crtc_w)
115199//   AM_RANGE(0xf8, 0xf9) AM_READWRITE(extrom_r,extrom_w)
116200ADDRESS_MAP_END
117201
r7653r7654
141225   memory_set_bankptr(machine, "bank5", &ROM[bank_val[5]*0x2000]);
142226   memory_set_bankptr(machine, "bank6", &ROM[bank_val[6]*0x2000]);
143227   memory_set_bankptr(machine, "bank7", &ROM[bank_val[7]*0x2000]);
228
229   irq_vector[0] = 0xef; /* RST 28h - vblank */
144230}
145231
146232static const gfx_layout mz2500_cg_layout =
147233{
148234   8, 8,      /* 8 x 8 graphics */
149   256,      /* 512 codes */
235   RGN_FRAC(1,1),      /* 512 codes */
150236   1,      /* 1 bit per pixel */
151237   { 0 },      /* no bitplanes */
152238   { 0, 1, 2, 3, 4, 5, 6, 7 },
r7653r7654
169255static const gfx_layout mz2500_16_layout =
170256{
171257   16, 16,      /* 16 x 16 graphics */
172   8192,      /* 8192 codes */
258   RGN_FRAC(1,1),      /* 8192 codes */
173259   1,      /* 1 bit per pixel */
174260   { 0 },      /* no bitplanes */
175261   { 0, 1, 2, 3, 4, 5, 6, 7, 128, 129, 130, 131, 132, 133, 134, 135 },
r7653r7654
178264};
179265
180266static GFXDECODE_START( mz2500 )
181   GFXDECODE_ENTRY("cgrom", 0, mz2500_cg_layout, 0, 256)
267   GFXDECODE_ENTRY("gfx1", 0, mz2500_cg_layout, 0, 256)
182268   GFXDECODE_ENTRY("gfx1", 0x4400, mz2500_8_layout, 0, 256)   // for viewer only
183269   GFXDECODE_ENTRY("gfx1", 0, mz2500_16_layout, 0, 256)      // for viewer only
184270GFXDECODE_END
185271
272static INTERRUPT_GEN( mz2500_vbl )
273{
274   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, irq_vector[0]);
275}
276
186277static MACHINE_DRIVER_START( mz2500 )
187278    /* basic machine hardware */
188279    MDRV_CPU_ADD("maincpu", Z80, 6000000)
189280    MDRV_CPU_PROGRAM_MAP(mz2500_map)
190281    MDRV_CPU_IO_MAP(mz2500_io)
282   MDRV_CPU_VBLANK_INT("screen", mz2500_vbl)
191283
192284    MDRV_MACHINE_RESET(mz2500)
193285
r7653r7654
212304   ROM_LOAD( "ipl.rom", 0x00000, 0x8000, CRC(7a659f20) SHA1(ccb3cfdf461feea9db8d8d3a8815f7e345d274f7) )
213305   ROM_RELOAD( 0x68000, 0x8000 )
214306
307   /* this is probably an hand made ROM, will be removed in the end ...*/
215308   ROM_REGION( 0x1000, "cgrom", 0 )
216309   ROM_LOAD( "cg.rom", 0x0000, 0x0800, CRC(a082326f) SHA1(dfa1a797b2159838d078650801c7291fa746ad81) )
217310

Previous 15994 Revisions Next


© 1998-2018 The MESS Team