Previous 15994 Revisions Next

r12324 Monday 25th July, 2011 at 19:24:09 UTC by Angelo Salese
Improved video, properly draws stuff now
[src/mess/drivers]z100.c

src/mess/drivers/z100.c
r12323r12324
149149      : driver_device(mconfig, type, tag)
150150   { }
151151
152   UINT8 *m_tvram;
153   UINT8 *m_gvram;
152   UINT8 *m_gvram, *m_wram;
154153   UINT8 m_keyb_press,m_keyb_status;
155   UINT8 m_tbank;
154   UINT8 m_tbank,m_PA7_latch;
156155   UINT8 m_gbank;
157156   UINT8 m_clr_val;
158157   UINT8 m_crtc_vreg[0x100],m_crtc_index;
158   UINT16 m_start_addr;
159159
160160   mc6845_device *m_mc6845;
161161
r12323r12324
183183{
184184   z100_state *state = machine.driver_data<z100_state>();
185185
186   state->m_tvram = auto_alloc_array_clear(machine, UINT8, 0x30000);
187   state->m_gvram = auto_alloc_array_clear(machine, UINT8, 0x30000*3);
186   state->m_gvram = auto_alloc_array_clear(machine, UINT8, 0x30000);
187   state->m_wram = auto_alloc_array_clear(machine, UINT8, 0x30000);
188188}
189189
190190static SCREEN_UPDATE( z100 )
191191{
192192   z100_state *state = screen->machine().driver_data<z100_state>();
193193   int x,y,xi,yi;
194   int dot;
195   UINT32 count;
194   //int dot;
196195   int r,g,b;
197196
198197   bitmap_fill(bitmap, cliprect, 0);
199198
200   count = 0;
201   for(y=0;y<216;y++)
199   for(y=0;y<mc6845_v_display;y++)
202200   {
203      for(x=0;x<1024;x+=8)
201      for(x=0;x<mc6845_h_display;x++)
204202      {
205         for(xi=0;xi<8;xi++)
203         UINT32 base_offs;
204
205         for(yi=0;yi<mc6845_tile_height;yi++)
206206         {
207            b = ((state->m_gvram[count+0x20000] >> (7-xi)) & 1) << 0;
208            r = ((state->m_gvram[count+0x00000] >> (7-xi)) & 1) << 1;
209            g = ((state->m_gvram[count+0x10000] >> (7-xi)) & 1) << 2;
207            base_offs = (y+state->m_start_addr) * 0x800 + yi * 0x80 + x;
210208
211            if(y < 216 && x+xi < 640) /* TODO: safety check */
212               *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine().pens[r|g|b];
209            for(xi=0;xi<8;xi++)
210            {
211               b = ((state->m_gvram[(base_offs & 0xffff)+0x20000] >> (7-xi)) & 1) << 0;
212               r = ((state->m_gvram[(base_offs & 0xffff)+0x00000] >> (7-xi)) & 1) << 1;
213               g = ((state->m_gvram[(base_offs & 0xffff)+0x10000] >> (7-xi)) & 1) << 2;
214
215               if(y*mc6845_tile_height+yi < 216 && x*8+xi < 640) /* TODO: safety check */
216                  *BITMAP_ADDR16(bitmap, y*mc6845_tile_height+yi, x*8+xi) = screen->machine().pens[r|g|b];
217            }
213218         }
214
215         count++;
216219      }
217220   }
218221
222   #if 0
219223   for(y=0;y<mc6845_v_display;y++)
220224   {
221225      for(x=0;x<mc6845_h_display;x++)
r12323r12324
242246         }
243247      }
244248   }
249   #endif
245250
246251    return 0;
247252}
r12323r12324
253258
254259   res = 0;
255260
256   if(state->m_gbank == 0xf)
257      res |= state->m_tvram[offset & 0x3ffff];
258   else if(state->m_gbank & 7)
259      res |= state->m_gvram[offset];
261   if(!state->m_tbank)
262      res = state->m_wram[offset];
263   else
264      res = state->m_gvram[offset];
260265
261266   return res;
262267}
r12323r12324
265270{
266271   z100_state *state = space->machine().driver_data<z100_state>();
267272
268   if(state->m_gbank == 0xf)
269      state->m_tvram[offset & 0x3ffff] = data;
273   if(!state->m_tbank)
274      state->m_wram[offset & 0x3ffff] = data;
270275   else
271276   {
272277      int i;
273278
279      //if(state->m_gbank & (1 << i))
280      //   state->m_gvram[offset] = data;
281
274282      for(i=0;i<3;i++)
275283      {
276284         if(state->m_gbank & (1 << i))
r12323r12324
281289
282290static ADDRESS_MAP_START(z100_mem, AS_PROGRAM, 8)
283291   ADDRESS_MAP_UNMAP_HIGH
284   AM_RANGE(0x00000,0x1ffff) AM_RAM // 128 KB RAM
292   AM_RANGE(0x00000,0x3ffff) AM_RAM // 128*2 KB RAM
285293//   AM_RANGE(0xb0000,0xbffff) AM_ROM // expansion ROM
286294   AM_RANGE(0xc0000,0xeffff) AM_READWRITE(z100_vram_r,z100_vram_w) // Blue / Red / Green
287295//   AM_RANGE(0xfbffa,0xfbffb) // expansion ROM check ID 0x4550
r12323r12324
597605     ---- --x- -> enable green display
598606    ---- ---x -> enable red display
599607    */
600    if(data != 0x08 && data != 0xf8)
601    printf("%02x\n",data);
608    if(state->m_PA7_latch & 0x80 && ((data & 0x80) == 0x00))
609       state->m_tbank = 1;
602610
603    state->m_gbank = ((data & 0xf0) >> 4) ^ 0xf;
611    if(((state->m_PA7_latch & 0x80) == 0x00) && (data & 0x80))
612       state->m_tbank = 0;
613
614    state->m_PA7_latch = data & 0x80;
615
616    state->m_gbank = ((data & 0x70) >> 4) ^ 0x7;
604617}
605618
619static WRITE8_DEVICE_HANDLER( video_pia_B_w )
620{
621   z100_state *state = device->machine().driver_data<z100_state>();
622
623   state->m_start_addr = 0;//data <- TODO
624}
625
606626/* clear screen */
607627static WRITE_LINE_DEVICE_HANDLER( video_pia_CA2_w )
608628{
609629   z100_state *drvstate = device->machine().driver_data<z100_state>();
610630   int i;
611631
612   for(i=0;i<0x10000;i++)
613      drvstate->m_tvram[i] = drvstate->m_clr_val;
614
615632   for(i=0;i<0x30000;i++)
616633      drvstate->m_gvram[i] = drvstate->m_clr_val;
617634}
r12323r12324
632649   DEVCB_NULL,      /* line CA2 in */
633650   DEVCB_NULL,      /* line CB2 in */
634651   DEVCB_HANDLER(video_pia_A_w),      /* port A out */
635   DEVCB_NULL,      /* port B out */
652   DEVCB_HANDLER(video_pia_B_w),      /* port B out */
636653   DEVCB_LINE(video_pia_CA2_w),      /* line CA2 out */
637654   DEVCB_HANDLER(video_pia_CB2_w),      /* port CB2 out */
638655   DEVCB_NULL,      /* IRQA */
r12323r12324
670687
671688static MACHINE_RESET(z100)
672689{
690   z100_state *state = machine.driver_data<z100_state>();
673691   int i;
674692
675693   if(input_port_read(machine,"CONFIG") & 1)
r12323r12324
682700      for(i=0;i<8;i++)
683701         palette_set_color_rgb(machine, i,pal3bit(i),pal3bit(i),pal3bit(i));
684702   }
703
704   state->m_PA7_latch = 0x00;
685705}
686706
687707static MACHINE_CONFIG_START( z100, z100_state )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team