Previous 15994 Revisions Next

r2038 Friday 21st March, 2008 at 08:22:38 UTC by Robbbert
[TX0] Fixed palette.
[src/mess/drivers]tx0.c
[src/mess/includes]tx0.h
[src/mess/video]tx0.c

src/mess/includes/tx0.h
r2037r2038
143143   pen_crt_max_intensity = pen_crt_num_levels-1,
144144
145145   /* next colors used for control panel and typewriter */
146   pen_black = 0,
147   pen_white = pen_crt_num_levels,
146   pen_black = pen_crt_num_levels,
147   pen_white,
148148   pen_green,
149149   pen_dk_green,
150150   pen_red,
r2037r2038
161161
162162   /* color constants for typewriter */
163163   pen_typewriter_bg = pen_white,
164   color_typewriter_black = 1,
165   color_typewriter_red = 2,
164   color_typewriter_black = 1,      /* palette 1 = black on white */
165   color_typewriter_red = 2,      /* palette 2 = red on white */
166166
167167   /* color constants used for light pen */
168168   pen_lightpen_nonpressed = pen_red,
src/mess/video/tx0.c
r2037r2038
1616
1717INLINE void tx0_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color)
1818{
19   *BITMAP_ADDR16(bitmap, y, x) = (UINT16)color;
19   *BITMAP_ADDR16(bitmap, y, x) = color;
2020}
2121
2222static const rectangle panel_bitmap_bounds =
r2037r2038
4848   /* set up out bitmaps */
4949   tx0_draw_panel_backdrop(machine, panel_bitmap);
5050
51   fillbitmap(typewriter_bitmap, machine->pens[pen_typewriter_bg], &typewriter_bitmap_bounds);
51   fillbitmap(typewriter_bitmap, pen_typewriter_bg, &typewriter_bitmap_bounds);
5252
5353   /* initialize CRT */
5454   video_start_crt(pen_crt_num_levels, crt_window_offset_x, crt_window_offset_y, crt_window_width, crt_window_height);
r2037r2038
128128
129129   for (yy=1; yy<7; yy++)
130130      for (xx=1; xx<7; xx++)
131         tx0_plot_pixel(bitmap, x+xx, y+yy, machine->pens[state ? pen_lit_lamp : pen_unlit_lamp]);
131         tx0_plot_pixel(bitmap, x+xx, y+yy, state ? pen_lit_lamp : pen_unlit_lamp);
132132}
133133
134134/* draw nb_bits leds which represent nb_bits bits in value */
r2037r2038
154154   /* erase area */
155155   for (yy=0; yy<8; yy++)
156156      for (xx=0; xx<8; xx++)
157         tx0_plot_pixel(bitmap, x+xx, y+yy, machine->pens[pen_panel_bg]);
157         tx0_plot_pixel(bitmap, x+xx, y+yy, pen_panel_bg);
158158
159159
160160   /* draw nut (-> circle) */
161161   for (i=0; i<4;i++)
162162   {
163      tx0_plot_pixel(bitmap, x+2+i, y+1, machine->pens[pen_switch_nut]);
164      tx0_plot_pixel(bitmap, x+2+i, y+6, machine->pens[pen_switch_nut]);
165      tx0_plot_pixel(bitmap, x+1, y+2+i, machine->pens[pen_switch_nut]);
166      tx0_plot_pixel(bitmap, x+6, y+2+i, machine->pens[pen_switch_nut]);
163      tx0_plot_pixel(bitmap, x+2+i, y+1, pen_switch_nut);
164      tx0_plot_pixel(bitmap, x+2+i, y+6, pen_switch_nut);
165      tx0_plot_pixel(bitmap, x+1, y+2+i, pen_switch_nut);
166      tx0_plot_pixel(bitmap, x+6, y+2+i, pen_switch_nut);
167167   }
168   tx0_plot_pixel(bitmap, x+2, y+2, machine->pens[pen_switch_nut]);
169   tx0_plot_pixel(bitmap, x+5, y+2, machine->pens[pen_switch_nut]);
170   tx0_plot_pixel(bitmap, x+2, y+5, machine->pens[pen_switch_nut]);
171   tx0_plot_pixel(bitmap, x+5, y+5, machine->pens[pen_switch_nut]);
168   tx0_plot_pixel(bitmap, x+2, y+2, pen_switch_nut);
169   tx0_plot_pixel(bitmap, x+5, y+2, pen_switch_nut);
170   tx0_plot_pixel(bitmap, x+2, y+5, pen_switch_nut);
171   tx0_plot_pixel(bitmap, x+5, y+5, pen_switch_nut);
172172
173173   /* draw button (->disc) */
174174   if (! state)
175175      y += 4;
176176   for (i=0; i<2;i++)
177177   {
178      tx0_plot_pixel(bitmap, x+3+i, y, machine->pens[pen_switch_button]);
179      tx0_plot_pixel(bitmap, x+3+i, y+3, machine->pens[pen_switch_button]);
178      tx0_plot_pixel(bitmap, x+3+i, y, pen_switch_button);
179      tx0_plot_pixel(bitmap, x+3+i, y+3, pen_switch_button);
180180   }
181181   for (i=0; i<4;i++)
182182   {
183      tx0_plot_pixel(bitmap, x+2+i, y+1, machine->pens[pen_switch_button]);
184      tx0_plot_pixel(bitmap, x+2+i, y+2, machine->pens[pen_switch_button]);
183      tx0_plot_pixel(bitmap, x+2+i, y+1, pen_switch_button);
184      tx0_plot_pixel(bitmap, x+2+i, y+2, pen_switch_button);
185185   }
186186}
187187
r2037r2038
245245   char buf[3];
246246
247247   /* fill with black */
248   fillbitmap(panel_bitmap, machine->pens[pen_panel_bg], &panel_bitmap_bounds);
248   fillbitmap(panel_bitmap, pen_panel_bg, &panel_bitmap_bounds);
249249
250250   /* column 1: registers, test accumulator, test buffer, toggle switch storage */
251251   tx0_draw_string(machine, bitmap, "program counter", x_panel_col1b_offset, y_panel_pc_offset, color_panel_caption);
r2037r2038
342342   typewriter_write_offset_y = typewriter_window_height-typewriter_line_height,
343343   typewriter_scroll_step = typewriter_line_height
344344};
345
345346static const rectangle typewriter_scroll_clear_window =
346347{
347348   0, typewriter_window_width-1,   /* min_x, max_x */
r2037r2038
365366      draw_scanline8(typewriter_bitmap, 0, y, typewriter_window_width, buf, machine->pens, -1);
366367   }
367368
368   fillbitmap(typewriter_bitmap, machine->pens[pen_typewriter_bg], &typewriter_scroll_clear_window);
369   fillbitmap(typewriter_bitmap, pen_typewriter_bg, &typewriter_scroll_clear_window);
369370}
370371
371372void tx0_typewriter_drawchar(running_machine *machine, int character)
src/mess/drivers/tx0.c
r2037r2038
1414/* pointer to TX-0 RAM */
1515static UINT32 *tx0_memory;
1616
17
1817/*
1918    driver init function
2019
r2037r2038
227226    black.  Grey levels follow an exponential law, so that decrementing the
228227    color index periodically will simulate the remanence of a cathode ray tube.
229228*/
230static const unsigned char palette[] =
229static const UINT8 tx0_colors[] =
231230{
231   0x00,0x00,0x00,   /* black */
232232   0xFF,0xFF,0xFF,   /* white */
233233   0x00,0xFF,0x00,   /* green */
234234   0x00,0x40,0x00,   /* dark green */
r2037r2038
236236   0x80,0x80,0x80   /* light gray */
237237};
238238
239static const unsigned short tx0_colortable[] =
239static const UINT8 tx0_palette[] =
240240{
241   pen_panel_bg, pen_panel_caption,
242   pen_typewriter_bg, pen_black,
243   pen_typewriter_bg, pen_red
241   pen_panel_bg, pen_panel_caption,   /* captions */
242   pen_typewriter_bg, pen_black,      /* black typing in typewriter */
243   pen_typewriter_bg, pen_red      /* red typing in typewriter */
244244};
245245
246static UINT8 total_colors_needed = pen_crt_num_levels + sizeof(tx0_colors) / 3;
247
246248/* Initialise the palette */
247249static PALETTE_INIT( tx0 )
248250{
r2037r2038
254256   const double update_period = 1./refresh_rate;
255257   double decay_1, decay_2;
256258   double cur_level_1, cur_level_2;
259#if 0
257260#ifdef MAME_DEBUG
258261   /* level at which we stop emulating the decay and say the pixel is black */
259262   double cut_level = .02;
260263#endif
261   int i;
262   int r, g, b;
264#endif
265   UINT8 i, r, g, b;
263266
267   machine->colortable = colortable_alloc(machine, total_colors_needed);
264268
265269   /* initialize CRT palette */
266270
r2037r2038
277281      g = (int) ((g1*cur_level_1 + g2*cur_level_2) + .5);
278282      b = (int) ((b1*cur_level_1 + b2*cur_level_2) + .5);
279283      /* write color in palette */
280      palette_set_color_rgb(machine, i, r, g, b);
284      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
281285      /* apply decay for next iteration */
282286      cur_level_1 *= decay_1;
283287      cur_level_2 *= decay_2;
284288   }
285
289#if 0
286290#ifdef MAME_DEBUG
287291   {
288292      int recommended_pen_crt_num_levels;
r2037r2038
296300   /*if ((cur_level_1 > 255.*cut_level) || (cur_level_2 > 255.*cut_level))
297301        mame_printf_debug("File %s line %d: Please take higher value for pen_crt_num_levels or smaller value for decay\n", __FILE__, __LINE__);*/
298302#endif
303#endif
304   colortable_palette_set_color(machine->colortable, 0, MAKE_RGB(0, 0, 0));
299305
300   palette_set_color_rgb(machine, 0, 0, 0, 0);
301
302306   /* load static palette */
303   for ( i = 0; i < sizeof(palette) / sizeof(palette[0]) / 3; i++ ) {
304      palette_set_color_rgb(machine, pen_crt_num_levels + i, palette[i*3], palette[i*3+1], palette[i*3+2]);
307   for ( i = 0; i < 6; i++ )
308   {
309      r = tx0_colors[i*3]; g = tx0_colors[i*3+1]; b = tx0_colors[i*3+2];
310      colortable_palette_set_color(machine->colortable, pen_crt_num_levels + i, MAKE_RGB(r, g, b));
305311   }
312
313   /* copy colortable to palette */
314   for( i = 0; i < total_colors_needed; i++ )
315      colortable_entry_set_value(machine->colortable, i, i);
316
317   /* overwrite unneeded lowest palette entries with text values */
318   for( i = 0; i < 6; i++ )
319      colortable_entry_set_value(machine->colortable, i, tx0_palette[i]);
306320}
307321
308322
r2037r2038
325339
326340static MACHINE_DRIVER_START(tx0_64kw)
327341   /* basic machine hardware */
328   /* TX0 CPU @ approx. 167 kHz (no master clock, but the memory cycle time is
329    approximately 6usec) */
342   /* TX0 CPU @ approx. 167 kHz (no master clock, but the memory cycle time is approximately 6usec) */
330343   MDRV_CPU_ADD_TAG("main", TX0_64KW, 166667)
331344   MDRV_CPU_CONFIG(tx0_reset_param)
332345   MDRV_CPU_PROGRAM_MAP(tx0_64kw_map, 0)
r2037r2038
345358   MDRV_SCREEN_VISIBLE_AREA(0, virtual_width-1, 0, virtual_height-1)
346359
347360   MDRV_GFXDECODE(tx0)
348   MDRV_PALETTE_LENGTH(pen_crt_num_levels + (sizeof(palette) / sizeof(palette[0]) / 3))
361   MDRV_PALETTE_LENGTH(pen_crt_num_levels + sizeof(tx0_colors) / 3)
349362
350363   MDRV_PALETTE_INIT(tx0)
351364   MDRV_VIDEO_START(tx0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team