Previous 15994 Revisions Next

r2597 Saturday 10th May, 2008 at 14:25:33 UTC by Curt Coder
[CDP1864] Fixed palette.
[src/mess/drivers]studio2.c tmc1800.c
[src/mess/includes]tmc1800.h
[src/mess/video]cdp1864.c cdp1864.h tmc1800.c

src/mess/includes/tmc1800.h
r2596r2597
1111{
1212   /* video state */
1313   int cdp1861_efx;      /* EFx */
14 
15   /* keyboard state */
16   int keylatch;         /* key latch */
1417};
1518 
1619typedef struct _tmc2000_state tmc2000_state;
r2596r2597
1821{
1922   /* video state */
2023   int cdp1864_efx;      /* EFx */
24 
25   /* keyboard state */
26   int keylatch;         /* key latch */
2127};
2228 
2329/* ---------- defined in video/tmc1800.c ---------- */
src/mess/video/tmc1800.c
r2596r2597
6565{
6666   SCREEN_TAG,
6767   CDP1864_CLK_FREQ,
68   CDP1864_INTERLACED,
6869   tmc2000_int_w,
6970   tmc2000_dmao_w,
7071   tmc2000_efx_w,
71   RES_K(2.2),   // unverified
72   RES_K(1),   // unverified
73   RES_K(5.1),   // unverified
74   RES_K(4.7)   // unverified
72   RES_K(1.21),   // RL64
73   RES_K(2.05),   // RL63
74   RES_K(2.26),   // RL61
75   RES_K(3.92)      // RL65 (also RH62 (2K pot) in series, but ignored here)
7576};
7677 
7778static VIDEO_UPDATE( tmc2000 )
r2596r2597
125126   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
126127   MDRV_SCREEN_RAW_PARAMS(CDP1864_CLK_FREQ, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
127128 
128   MDRV_PALETTE_LENGTH(8)
129   MDRV_PALETTE_LENGTH(8+8)
129130   MDRV_VIDEO_UPDATE(tmc2000)
130131 
131132   MDRV_DEVICE_ADD(CDP1864_TAG, CDP1864)
r2596r2597
137138   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
138139   MDRV_SCREEN_RAW_PARAMS(CDP1864_CLK_FREQ, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
139140 
140   MDRV_PALETTE_LENGTH(8)
141   MDRV_PALETTE_LENGTH(8+8)
141142   MDRV_VIDEO_UPDATE(tmc2000)
142143 
143144   MDRV_DEVICE_ADD(CDP1864_TAG, CDP1864)
src/mess/video/cdp1864.c
r2596r2597
99
1010    TODO:
1111
12   - interlace mode
1213    - connect to sound system when possible
1314
1415*/
r2596r2597
152153   }
153154}
154155
155
156156/* Palette Initialization */
157157
158static void cdp1864_init_palette(running_machine *machine, double res_r, double res_g, double res_b, double res_bkg)
158static void cdp1864_init_palette(const device_config *device)
159159{
160   int i, r, g, b, luma;
160   cdp1864_t *cdp1864 = get_safe_token(device);
161   int i;
161162
162   double res_total = res_r + res_g + res_b;
163   double res_total = cdp1864->intf->res_r + cdp1864->intf->res_g + cdp1864->intf->res_b + cdp1864->intf->res_bkg;
163164
164   int weight_r = (res_r / res_total) * 100;
165   int weight_g = (res_g / res_total) * 100;
166   int weight_b = (res_b / res_total) * 100;
165   int weight_r = (cdp1864->intf->res_r / res_total) * 100;
166   int weight_g = (cdp1864->intf->res_g / res_total) * 100;
167   int weight_b = (cdp1864->intf->res_b / res_total) * 100;
168   int weight_bkg = (cdp1864->intf->res_bkg / res_total) * 100;
167169
168   for (i = 0; i < 8; i++)
170   for (i = 0; i < 16; i++)
169171   {
170      luma = (i & 4) ? weight_r : 0;
172      int r, g, b, luma = 0;
173
174      luma += (i & 4) ? weight_r : 0;
171175      luma += (i & 1) ? weight_g : 0;
172176      luma += (i & 2) ? weight_b : 0;
177      luma += (i & 8) ? 0 : weight_bkg;
173178
179      luma = (luma * 0xff) / 100;
180
174181      r = (i & 4) ? luma : 0;
175182      g = (i & 1) ? luma : 0;
176183      b = (i & 2) ? luma : 0;
177184
178      luma = (luma * 0xff) / 100;
179
180      palette_set_color_rgb( machine, i, r, g, b );
185      palette_set_color_rgb( device->machine, i, r, g, b );
181186   }
182187}
183188
r2596r2597
253258
254259   for (x = 0; x < 8; x++)
255260   {
256      int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor];
261      int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8;
257262
258263      if (BIT(data, 7))
259264      {
r2596r2597
322327
323328   if (cdp1864->disp)
324329   {
325      fillbitmap(bitmap, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor], cliprect);
326      copybitmap_trans(bitmap, cdp1864->bitmap, 0, 0, 0, 0, cliprect, cdp1864->bgcolor);
330      copybitmap(bitmap, cdp1864->bitmap, 0, 0, 0, 0, cliprect);
331      fillbitmap(cdp1864->bitmap, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8, cliprect);
327332   }
328333   else
329334   {
r2596r2597
357362
358363   /* allocate the temporary bitmap */
359364   cdp1864->bitmap = auto_bitmap_alloc(video_screen_get_width(cdp1864->screen), video_screen_get_height(cdp1864->screen), video_screen_get_format(cdp1864->screen));
365   fillbitmap(cdp1864->bitmap, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8, 0);
360366
361367   /* initialize the palette */
362   cdp1864_init_palette(device->machine, cdp1864->intf->res_r, cdp1864->intf->res_g, cdp1864->intf->res_b, cdp1864->intf->res_bkg);
368   cdp1864_init_palette(device);
363369
364370   /* create the timers */
365371   cdp1864->int_timer = timer_alloc(cdp1864_int_tick, (void *)device);
src/mess/video/cdp1864.h
r2596r2597
7171
7272#define CDP1864      DEVICE_GET_INFO_NAME(cdp1864)
7373
74typedef enum _cdp1864_format cdp1864_format;
75enum _cdp1864_format {
76   CDP1864_NON_INTERLACED = 0,
77   CDP1864_INTERLACED
78};
79
7480/* interface */
7581typedef struct _cdp1864_interface cdp1864_interface;
7682struct _cdp1864_interface
r2596r2597
7884   const char *screen_tag;      /* screen we are acting on */
7985   int clock;               /* the clock (pin 2) of the chip */
8086
87   cdp1864_format interlace;   /* interlace */
88
8189   /* this gets called for every change of the INT pin (pin 36) */
8290   cdp1864_on_int_changed_func      on_int_changed;
8391
src/mess/drivers/studio2.c
r2596r2597
232232{
233233   SCREEN_TAG,
234234   CDP1864_CLK_FREQ,
235   CDP1864_INTERLACED,
235236   mpt02_int_w,
236237   mpt02_dmao_w,
237238   mpt02_efx_w,
r2596r2597
408409   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
409410   MDRV_SCREEN_RAW_PARAMS(CDP1864_CLK_FREQ, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
410411
411   MDRV_PALETTE_LENGTH(8)
412   MDRV_PALETTE_LENGTH(8+8)
412413   MDRV_VIDEO_UPDATE(mpt02)
413414
414415   MDRV_DEVICE_ADD(CDP1864_TAG, CDP1864)
src/mess/drivers/tmc1800.c
r2596r2597
8787
8888/* Read/Write Handlers */
8989
90static int keylatch;
91
9290static WRITE8_HANDLER( tmc1800_keylatch_w )
9391{
94   keylatch = data;
92   tmc1800_state *state = machine->driver_data;
93
94   state->keylatch = data;
9595}
9696
9797static WRITE8_HANDLER( tmc2000_keylatch_w )
r2596r2597
111111
112112   */
113113
114   keylatch = data & 0x3f;
114   tmc2000_state *state = machine->driver_data;
115
116   state->keylatch = data & 0x3f;
115117}
116118
117119static WRITE8_DEVICE_HANDLER( tmc2000_bankswitch_w )
r2596r2597
338340
339341   // keyboard
340342
341   sprintf(port, "IN%d", keylatch / 8);
342   if (~input_port_read(machine, port) & (1 << (keylatch % 8))) flags -= EF3;
343   sprintf(port, "IN%d", state->keylatch / 8);
344   if (~input_port_read(machine, port) & (1 << (state->keylatch % 8))) flags -= EF3;
343345
344346   return flags;
345347}
r2596r2597
418420
419421   // keyboard
420422
421   sprintf(port, "IN%d", keylatch / 8);
422   if (~input_port_read(machine, port) & (1 << (keylatch % 8))) flags -= EF3;
423   sprintf(port, "IN%d", state->keylatch / 8);
424   if (~input_port_read(machine, port) & (1 << (state->keylatch % 8))) flags -= EF3;
423425
424426   return flags;
425427}
r2596r2597
506508
507509   // keyboard
508510
509   sprintf(port, "IN%d", keylatch / 8);
510   if (~input_port_read(machine, port) & (1 << (keylatch % 8))) flags -= EF3;
511   sprintf(port, "IN%d", state->keylatch / 8);
512   if (~input_port_read(machine, port) & (1 << (state->keylatch % 8))) flags -= EF3;
511513
512514   // monitor
513515
r2596r2597
562564
563565static MACHINE_START( tmc1800 )
564566{
565   state_save_register_global(keylatch);
567   tmc1800_state *state = machine->driver_data;
568
569   state_save_register_global(state->keylatch);
566570}
567571
568572static MACHINE_RESET( tmc1800 )
r2596r2597
584588
585589static MACHINE_START( tmc2000 )
586590{
587   state_save_register_global(keylatch);
591   tmc2000_state *state = machine->driver_data;
592   UINT16 addr;
588593
594   state_save_register_global(state->keylatch);
595
589596   // RAM banking
590597
591598   memory_configure_bank(1, 0, 1, memory_region(REGION_CPU1) + 0x8000, 0);
r2596r2597
608615      break;
609616   }
610617
618   for (addr = 0; addr < mess_ram_size; addr++)
619   {
620      mess_ram[addr] = mame_rand(machine) & 0xff;
621   }
622
611623   // ROM/ColorRAM banking
612624
613625   colorram = auto_malloc(0x200);
r2596r2597
616628   memory_configure_bank(2, 1, 1, &colorram, 0);
617629
618630   memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x81ff, 0, 0x0e00, SMH_BANK2, SMH_UNMAP);
631
632   for (addr = 0; addr < 0x200; addr++)
633   {
634      colorram[addr] = mame_rand(machine) & 0xff;
635   }
619636}
620637
621638static MACHINE_RESET( tmc2000 )
r2596r2597
633650
634651static MACHINE_START( oscnano )
635652{
636   state_save_register_global(keylatch);
653   tmc2000_state *state = machine->driver_data;
637654
655   state_save_register_global(state->keylatch);
656
638657   // RAM banking
639658
640659   memory_configure_bank(1, 0, 1, memory_region(REGION_CPU1) + 0x8000, 0);
r2596r2597
758777ROM_START( tmc2000 )
759778   ROM_REGION( 0x10000, REGION_CPU1, 0 )
760779   ROM_SYSTEM_BIOS( 0, "default",  "PROM N:o 200" )
761   ROMX_LOAD( "200.m5",    0x8000, 0x0200, BAD_DUMP CRC(6af8e362) SHA1(ebc11e110ec355defb0a4fcbd0063eb3ad4ba23b), ROM_BIOS(1) ) // typed in from the manual
780   ROMX_LOAD( "200.m5",    0x8000, 0x0200, BAD_DUMP CRC(79da3221) SHA1(008da3ef4f69ab1a493362dfca856375b19c94bd), ROM_BIOS(1) ) // typed in from the manual
762781   ROM_SYSTEM_BIOS( 1, "prom202",  "PROM N:o 202" )
763782   ROMX_LOAD( "202.m5",    0x8000, 0x0200, NO_DUMP, ROM_BIOS(2) )
764783   ROM_SYSTEM_BIOS( 2, "tool2000", "TOOL-2000" )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team