src/mess/video/tx0.c
| r2037 | r2038 | |
| 16 | 16 | |
| 17 | 17 | INLINE void tx0_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color) |
| 18 | 18 | { |
| 19 | | *BITMAP_ADDR16(bitmap, y, x) = (UINT16)color; |
| 19 | *BITMAP_ADDR16(bitmap, y, x) = color; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | static const rectangle panel_bitmap_bounds = |
| r2037 | r2038 | |
| 48 | 48 | /* set up out bitmaps */ |
| 49 | 49 | tx0_draw_panel_backdrop(machine, panel_bitmap); |
| 50 | 50 | |
| 51 | | fillbitmap(typewriter_bitmap, machine->pens[pen_typewriter_bg], &typewriter_bitmap_bounds); |
| 51 | fillbitmap(typewriter_bitmap, pen_typewriter_bg, &typewriter_bitmap_bounds); |
| 52 | 52 | |
| 53 | 53 | /* initialize CRT */ |
| 54 | 54 | video_start_crt(pen_crt_num_levels, crt_window_offset_x, crt_window_offset_y, crt_window_width, crt_window_height); |
| r2037 | r2038 | |
| 128 | 128 | |
| 129 | 129 | for (yy=1; yy<7; yy++) |
| 130 | 130 | 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); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /* draw nb_bits leds which represent nb_bits bits in value */ |
| r2037 | r2038 | |
| 154 | 154 | /* erase area */ |
| 155 | 155 | for (yy=0; yy<8; yy++) |
| 156 | 156 | 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); |
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | /* draw nut (-> circle) */ |
| 161 | 161 | for (i=0; i<4;i++) |
| 162 | 162 | { |
| 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); |
| 167 | 167 | } |
| 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); |
| 172 | 172 | |
| 173 | 173 | /* draw button (->disc) */ |
| 174 | 174 | if (! state) |
| 175 | 175 | y += 4; |
| 176 | 176 | for (i=0; i<2;i++) |
| 177 | 177 | { |
| 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); |
| 180 | 180 | } |
| 181 | 181 | for (i=0; i<4;i++) |
| 182 | 182 | { |
| 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); |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| r2037 | r2038 | |
| 245 | 245 | char buf[3]; |
| 246 | 246 | |
| 247 | 247 | /* 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); |
| 249 | 249 | |
| 250 | 250 | /* column 1: registers, test accumulator, test buffer, toggle switch storage */ |
| 251 | 251 | tx0_draw_string(machine, bitmap, "program counter", x_panel_col1b_offset, y_panel_pc_offset, color_panel_caption); |
| r2037 | r2038 | |
| 342 | 342 | typewriter_write_offset_y = typewriter_window_height-typewriter_line_height, |
| 343 | 343 | typewriter_scroll_step = typewriter_line_height |
| 344 | 344 | }; |
| 345 | |
| 345 | 346 | static const rectangle typewriter_scroll_clear_window = |
| 346 | 347 | { |
| 347 | 348 | 0, typewriter_window_width-1, /* min_x, max_x */ |
| r2037 | r2038 | |
| 365 | 366 | draw_scanline8(typewriter_bitmap, 0, y, typewriter_window_width, buf, machine->pens, -1); |
| 366 | 367 | } |
| 367 | 368 | |
| 368 | | fillbitmap(typewriter_bitmap, machine->pens[pen_typewriter_bg], &typewriter_scroll_clear_window); |
| 369 | fillbitmap(typewriter_bitmap, pen_typewriter_bg, &typewriter_scroll_clear_window); |
| 369 | 370 | } |
| 370 | 371 | |
| 371 | 372 | void tx0_typewriter_drawchar(running_machine *machine, int character) |
src/mess/drivers/tx0.c
| r2037 | r2038 | |
| 14 | 14 | /* pointer to TX-0 RAM */ |
| 15 | 15 | static UINT32 *tx0_memory; |
| 16 | 16 | |
| 17 | | |
| 18 | 17 | /* |
| 19 | 18 | driver init function |
| 20 | 19 | |
| r2037 | r2038 | |
| 227 | 226 | black. Grey levels follow an exponential law, so that decrementing the |
| 228 | 227 | color index periodically will simulate the remanence of a cathode ray tube. |
| 229 | 228 | */ |
| 230 | | static const unsigned char palette[] = |
| 229 | static const UINT8 tx0_colors[] = |
| 231 | 230 | { |
| 231 | 0x00,0x00,0x00, /* black */ |
| 232 | 232 | 0xFF,0xFF,0xFF, /* white */ |
| 233 | 233 | 0x00,0xFF,0x00, /* green */ |
| 234 | 234 | 0x00,0x40,0x00, /* dark green */ |
| r2037 | r2038 | |
| 236 | 236 | 0x80,0x80,0x80 /* light gray */ |
| 237 | 237 | }; |
| 238 | 238 | |
| 239 | | static const unsigned short tx0_colortable[] = |
| 239 | static const UINT8 tx0_palette[] = |
| 240 | 240 | { |
| 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 */ |
| 244 | 244 | }; |
| 245 | 245 | |
| 246 | static UINT8 total_colors_needed = pen_crt_num_levels + sizeof(tx0_colors) / 3; |
| 247 | |
| 246 | 248 | /* Initialise the palette */ |
| 247 | 249 | static PALETTE_INIT( tx0 ) |
| 248 | 250 | { |
| r2037 | r2038 | |
| 254 | 256 | const double update_period = 1./refresh_rate; |
| 255 | 257 | double decay_1, decay_2; |
| 256 | 258 | double cur_level_1, cur_level_2; |
| 259 | #if 0 |
| 257 | 260 | #ifdef MAME_DEBUG |
| 258 | 261 | /* level at which we stop emulating the decay and say the pixel is black */ |
| 259 | 262 | double cut_level = .02; |
| 260 | 263 | #endif |
| 261 | | int i; |
| 262 | | int r, g, b; |
| 264 | #endif |
| 265 | UINT8 i, r, g, b; |
| 263 | 266 | |
| 267 | machine->colortable = colortable_alloc(machine, total_colors_needed); |
| 264 | 268 | |
| 265 | 269 | /* initialize CRT palette */ |
| 266 | 270 | |
| r2037 | r2038 | |
| 277 | 281 | g = (int) ((g1*cur_level_1 + g2*cur_level_2) + .5); |
| 278 | 282 | b = (int) ((b1*cur_level_1 + b2*cur_level_2) + .5); |
| 279 | 283 | /* 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)); |
| 281 | 285 | /* apply decay for next iteration */ |
| 282 | 286 | cur_level_1 *= decay_1; |
| 283 | 287 | cur_level_2 *= decay_2; |
| 284 | 288 | } |
| 285 | | |
| 289 | #if 0 |
| 286 | 290 | #ifdef MAME_DEBUG |
| 287 | 291 | { |
| 288 | 292 | int recommended_pen_crt_num_levels; |
| r2037 | r2038 | |
| 296 | 300 | /*if ((cur_level_1 > 255.*cut_level) || (cur_level_2 > 255.*cut_level)) |
| 297 | 301 | mame_printf_debug("File %s line %d: Please take higher value for pen_crt_num_levels or smaller value for decay\n", __FILE__, __LINE__);*/ |
| 298 | 302 | #endif |
| 303 | #endif |
| 304 | colortable_palette_set_color(machine->colortable, 0, MAKE_RGB(0, 0, 0)); |
| 299 | 305 | |
| 300 | | palette_set_color_rgb(machine, 0, 0, 0, 0); |
| 301 | | |
| 302 | 306 | /* 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)); |
| 305 | 311 | } |
| 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]); |
| 306 | 320 | } |
| 307 | 321 | |
| 308 | 322 | |
| r2037 | r2038 | |
| 325 | 339 | |
| 326 | 340 | static MACHINE_DRIVER_START(tx0_64kw) |
| 327 | 341 | /* 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) */ |
| 330 | 343 | MDRV_CPU_ADD_TAG("main", TX0_64KW, 166667) |
| 331 | 344 | MDRV_CPU_CONFIG(tx0_reset_param) |
| 332 | 345 | MDRV_CPU_PROGRAM_MAP(tx0_64kw_map, 0) |
| r2037 | r2038 | |
| 345 | 358 | MDRV_SCREEN_VISIBLE_AREA(0, virtual_width-1, 0, virtual_height-1) |
| 346 | 359 | |
| 347 | 360 | 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) |
| 349 | 362 | |
| 350 | 363 | MDRV_PALETTE_INIT(tx0) |
| 351 | 364 | MDRV_VIDEO_START(tx0) |