r8625 Sunday 25th July, 2010 at 18:50:17 UTC by Angelo Salese
[MULTI8]: Fixed work RAM / video RAM banking, fixes BASIC behaviour. Also did some other graphical tweaks
[src/mess/drivers]multi8.c

src/mess/drivers/multi8.c
r8624r8625
55   preliminary driver by Angelo Salese
66
77   TODO:
8   - can't compile any code snippet out of BASIC, just single commands seems
9     to work
8   - dunno how to trigger the text color mode in BASIC, I just modify
9     $f0b1 to 1 for now
10   - bitmap B/W mode is untested
1011
1112****************************************************************************/
1213
r8624r8625
2021static UINT8 keyb_press,keyb_press_flag,display_reg;
2122static UINT16 cursor_addr,cursor_raster;
2223static UINT8 vram_bank;
24static UINT8 pen_clut[8],bw_mode;
2325
2426static VIDEO_START( multi8 )
2527{
r8624r8625
4951            pen_r = (vram[count | 0x4000] >> (7-xi)) & 1;
5052            pen_g = (vram[count | 0x8000] >> (7-xi)) & 1;
5153
52            color = (pen_b) | (pen_r << 1) | (pen_g << 2);
54            if(bw_mode)
55            {
56               pen_b = (display_reg & 1) ? pen_b : 0;
57               pen_r = (display_reg & 2) ? pen_r : 0;
58               pen_g = (display_reg & 4) ? pen_g : 0;
5359
54            *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine->pens[color];
60               color = ((pen_b) | (pen_r) | (pen_g)) ? 7 : 0;
61            }
62            else
63               color = (pen_b) | (pen_r << 1) | (pen_g << 2);
64
65            *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine->pens[pen_clut[color]];
5566         }
5667         count++;
5768      }
r8624r8625
6576      for(x=0;x<x_width;x++)
6677      {
6778         int tile = vram[count];
68         int color = (vram[count+0x800] & 0x38) >> 3;
79         int attr = vram[count+0x800];
80         int color = (display_reg & 0x80) ? 7 : (attr & 0x07);
6981
70         if(color == 0)
71            color = 7;
72
7382         for(yi=0;yi<8;yi++)
7483         {
7584            for(xi=0;xi<8;xi++)
r8624r8625
7887
7988               pen = (gfx_rom[tile*8+yi] >> (7-xi) & 1) ? color : 0;
8089
90               if(attr & 0x20)
91                  pen^=7;
92
8193               if(pen)
8294                  *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen];
8395            }
r8624r8625
160172static READ8_HANDLER( multi8_vram_r )
161173{
162174   static UINT8 *vram = memory_region(space->machine, "vram");
175   static UINT8 *wram = memory_region(space->machine, "wram");
163176   UINT8 res;
164177
178   if(!(vram_bank & 0x10)) //select plain work ram
179      return wram[offset];
180
165181   res = 0xff;
166182   if(!(vram_bank & 1)) { res &= vram[offset | 0x0000]; }
167183   if(!(vram_bank & 2)) { res &= vram[offset | 0x4000]; }
r8624r8625
174190static WRITE8_HANDLER( multi8_vram_w )
175191{
176192   static UINT8 *vram = memory_region(space->machine, "vram");
193   static UINT8 *wram = memory_region(space->machine, "wram");
177194
195   if(!(vram_bank & 0x10)) //select plain work ram
196   {
197      wram[offset] = data;
198      return;
199   }
200
178201   if(!(vram_bank & 1)) { vram[offset | 0x0000] = data; }
179202   if(!(vram_bank & 2)) { vram[offset | 0x4000] = data; }
180203   if(!(vram_bank & 4)) { vram[offset | 0x8000] = data; }
181204   if(!(vram_bank & 8)) { vram[offset | 0xc000] = data; }
182205}
183206
207static READ8_HANDLER( pal_r )
208{
209   return pen_clut[offset];
210}
184211
212static WRITE8_HANDLER( pal_w )
213{
214   pen_clut[offset] = data;
215
216   {
217      int i;
218      for(i=0;i<8;i++)
219      {
220         if(pen_clut[i]) { bw_mode = 0; return; }
221      }
222      bw_mode = 1;
223   }
224}
225
185226static ADDRESS_MAP_START(multi8_mem, ADDRESS_SPACE_PROGRAM, 8)
186227   ADDRESS_MAP_UNMAP_HIGH
187228   AM_RANGE(0x0000, 0x7fff) AM_ROM
r8624r8625
190231ADDRESS_MAP_END
191232
192233static ADDRESS_MAP_START( multi8_io , ADDRESS_SPACE_IO, 8)
193   ADDRESS_MAP_UNMAP_HIGH
234//   ADDRESS_MAP_UNMAP_HIGH
194235   ADDRESS_MAP_GLOBAL_MASK(0xff)
195236   AM_RANGE(0x00, 0x00) AM_READ(key_input_r) AM_WRITENOP//keyboard
196237   AM_RANGE(0x01, 0x01) AM_READ(key_status_r) AM_WRITENOP//keyboard
r8624r8625
202243//   AM_RANGE(0x24, 0x27) //pit
203244   AM_RANGE(0x28, 0x2b) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w)
204245//   AM_RANGE(0x2c, 0x2d) //i8259
205//   AM_RANGE(0x30, 0x37) //vdp regs
246   AM_RANGE(0x30, 0x37) AM_READWRITE(pal_r,pal_w)
206247//   AM_RANGE(0x40, 0x41) //kanji regs
207248//   AM_RANGE(0x70, 0x74) //upd765a fdc
208249//   AM_RANGE(0x78, 0x78) //memory banking
r8624r8625
260301   PORT_BIT(0x00000100,IP_ACTIVE_HIGH,IPT_UNUSED) //0x28 (
261302   PORT_BIT(0x00000200,IP_ACTIVE_HIGH,IPT_UNUSED) //0x29 )
262303   PORT_BIT(0x00000400,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2a *
263   PORT_BIT(0x00000800,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2b +
304   PORT_BIT(0x00000800,IP_ACTIVE_HIGH,IPT_UNUSED)
264305   PORT_BIT(0x00001000,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2c ,
265306   PORT_BIT(0x00002000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')
266307   PORT_BIT(0x00004000,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2e .
r8624r8625
356397
357398               if(scancode == 0x3a)
358399                  scancode = 0x2e;
400               if(scancode == 0x5b)
401                  scancode = 0x2b;
359402            }
360403            keyb_press = scancode;
361404            keyb_press_flag = 1;
r8624r8625
420463{
421464   int vsync = (input_port_read(device->machine, "VBLANK") & 0x1) << 5;
422465
423   return 0xdf | vsync;
466   return ~0x60 | vsync;
424467}
425468
426static READ8_DEVICE_HANDLER( portb_r )
427{
428//   printf("Port B r\n");
429469
430   return 0xff;
431}
432
433static READ8_DEVICE_HANDLER( portc_r )
470static WRITE8_DEVICE_HANDLER( portb_w )
434471{
435//   printf("Port C r\n");
472   /*
473      x--- ---- color mode
474      -x-- ---- screen width (80 / 40)
475      ---- x--- memory bank status
476      ---- -xxx page screen graphics in B/W mode
477   */
478//   const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
436479
437   return 0xff;
438}
480//   printf("Port B w = %02x %04x\n",data,cpu_get_pc(space->cpu));
439481
440static WRITE8_DEVICE_HANDLER( porta_w )
441{
442//   printf("Port A w = %02x\n",data);
443}
444
445static WRITE8_DEVICE_HANDLER( portb_w )
446{
447//   printf("Port B w = %02x\n",data);
448
449482   {
450483      if((display_reg & 0x40) != (data & 0x40))
451484      {
r8624r8625
462495      }
463496   }
464497
465
466498   display_reg = data;
467499}
468500
469501static WRITE8_DEVICE_HANDLER( portc_w )
470502{
471503//   printf("Port C w = %02x\n",data);
472   vram_bank = data & 0xf;
504   vram_bank = data & 0x1f;
473505
474//   if(data & 0x20)
506   if(data & 0x20 && data != 0xff)
507      printf("Work RAM bank selected!\n");
475508//      fatalerror("Work RAM bank selected");
476509}
477510
r8624r8625
479512static I8255A_INTERFACE( ppi8255_intf_0 )
480513{
481514   DEVCB_HANDLER(porta_r),         /* Port A read */
482   DEVCB_HANDLER(portb_r),         /* Port B read */
483   DEVCB_HANDLER(portc_r),         /* Port C read */
484   DEVCB_HANDLER(porta_w),         /* Port A write */
515   DEVCB_NULL,                  /* Port B read */
516   DEVCB_NULL,                  /* Port C read */
517   DEVCB_NULL,                  /* Port A write */
485518   DEVCB_HANDLER(portb_w),         /* Port B write */
486519   DEVCB_HANDLER(portc_w)         /* Port C write */
487520};
r8624r8625
528561   ROM_REGION( 0x0800, "chargen", 0 )
529562   ROM_LOAD( "font.rom",  0x0000, 0x0800, CRC(08f9ed0e) SHA1(57480510fb30af1372df5a44b23066ca61c6f0d9))
530563
564   ROM_REGION( 0x1000, "fdc_bios", 0 )
565   ROM_LOAD( "disk.rom",  0x0000, 0x1000, NO_DUMP )
566
531567   ROM_REGION( 0x10000, "vram", ROMREGION_ERASEFF )
568
569   ROM_REGION( 0x4000, "wram", ROMREGION_ERASEFF )
532570ROM_END
533571
534572/* Driver */

Previous 509070 RevisionsNext 50


© 1998-2010 The MESS Team