branches/alto2/src/emu/cpu/alto2/a2disp.c
| r26307 | r26308 | |
| 147 | 147 | 0xffc0,0xffc3,0xffcc,0xffcf,0xfff0,0xfff3,0xfffc,0xffff |
| 148 | 148 | }; |
| 149 | 149 | |
| 150 | | #define BLACK 1 |
| 151 | | #define WHITE 0 |
| 152 | | |
| 153 | | //! update the internal bitmap to the MAME bitmap.pix16 |
| 150 | //! update the internal bitmap to a byte array |
| 154 | 151 | void alto2_cpu_device::update_bitmap_word(int x, int y, UINT16 word) |
| 155 | 152 | { |
| 156 | | UINT16* pix = &m_bitmap->pix16(y) + x; |
| 157 | | *pix++ = (word & 0100000) ? BLACK : WHITE; |
| 158 | | *pix++ = (word & 0040000) ? BLACK : WHITE; |
| 159 | | *pix++ = (word & 0020000) ? BLACK : WHITE; |
| 160 | | *pix++ = (word & 0010000) ? BLACK : WHITE; |
| 161 | | *pix++ = (word & 0004000) ? BLACK : WHITE; |
| 162 | | *pix++ = (word & 0002000) ? BLACK : WHITE; |
| 163 | | *pix++ = (word & 0001000) ? BLACK : WHITE; |
| 164 | | *pix++ = (word & 0000400) ? BLACK : WHITE; |
| 165 | | *pix++ = (word & 0000200) ? BLACK : WHITE; |
| 166 | | *pix++ = (word & 0000100) ? BLACK : WHITE; |
| 167 | | *pix++ = (word & 0000040) ? BLACK : WHITE; |
| 168 | | *pix++ = (word & 0000020) ? BLACK : WHITE; |
| 169 | | *pix++ = (word & 0000010) ? BLACK : WHITE; |
| 170 | | *pix++ = (word & 0000004) ? BLACK : WHITE; |
| 171 | | *pix++ = (word & 0000002) ? BLACK : WHITE; |
| 172 | | *pix++ = (word & 0000001) ? BLACK : WHITE; |
| 153 | const UINT8 white = 0; |
| 154 | const UINT8 black = 1; |
| 155 | UINT8* pix = m_dsp.scanline[y] + x; |
| 156 | *pix++ = (word & 0100000) ? black : white; |
| 157 | *pix++ = (word & 0040000) ? black : white; |
| 158 | *pix++ = (word & 0020000) ? black : white; |
| 159 | *pix++ = (word & 0010000) ? black : white; |
| 160 | *pix++ = (word & 0004000) ? black : white; |
| 161 | *pix++ = (word & 0002000) ? black : white; |
| 162 | *pix++ = (word & 0001000) ? black : white; |
| 163 | *pix++ = (word & 0000400) ? black : white; |
| 164 | *pix++ = (word & 0000200) ? black : white; |
| 165 | *pix++ = (word & 0000100) ? black : white; |
| 166 | *pix++ = (word & 0000040) ? black : white; |
| 167 | *pix++ = (word & 0000020) ? black : white; |
| 168 | *pix++ = (word & 0000010) ? black : white; |
| 169 | *pix++ = (word & 0000004) ? black : white; |
| 170 | *pix++ = (word & 0000002) ? black : white; |
| 171 | *pix++ = (word & 0000001) ? black : white; |
| 173 | 172 | } |
| 174 | 173 | |
| 175 | 174 | #define HLC1 ((m_dsp.hlc >> 0) & 1) //!< horizontal line counter bit 0 |
| r26307 | r26308 | |
| 214 | 213 | { |
| 215 | 214 | int x = m_unload_word; |
| 216 | 215 | int y = ((m_dsp.hlc - m_dsp.vblank) & ~(1024|1)) | HLC1024; |
| 217 | | UINT16* scanline = m_dsp.scanline[y]; |
| 216 | UINT16* scanline = m_dsp.raw_bitmap + y * ALTO2_DISPLAY_SCANLINE_WORDS; |
| 218 | 217 | |
| 219 | 218 | UINT32 word = m_dsp.inverse; |
| 220 | 219 | if (FIFO_MBEMPTY_0() == 0) { |
| r26307 | r26308 | |
| 444 | 443 | * @brief initialize the display context to useful values |
| 445 | 444 | * |
| 446 | 445 | * Zap the display context to all 0s. |
| 447 | | * Allocate a raw_bitmap array to save blitting to the screen when |
| 446 | * Allocate a bitmap array to save blitting to the screen when |
| 448 | 447 | * there is no change in the data words. |
| 449 | 448 | */ |
| 450 | 449 | void alto2_cpu_device::init_disp() |
| 451 | 450 | { |
| 452 | 451 | memset(&m_dsp, 0, sizeof(m_dsp)); |
| 453 | | // allocate the 16bpp bitmap |
| 454 | | m_bitmap = auto_bitmap_ind16_alloc(machine(), ALTO2_DISPLAY_TOTAL_WIDTH, ALTO2_DISPLAY_TOTAL_HEIGHT); |
| 455 | | LOG((LOG_DISPL,0," m_bitmap=%p\n", m_bitmap)); |
| 456 | 452 | m_dsp.hlc = ALTO2_DISPLAY_HLC_START; |
| 457 | | m_dsp.raw_bitmap = auto_alloc_array(machine(), UINT16, ALTO2_DISPLAY_TOTAL_HEIGHT * ALTO2_DISPLAY_SCANLINE_WORDS); |
| 458 | | m_dsp.scanline = auto_alloc_array(machine(), UINT16*, ALTO2_DISPLAY_TOTAL_HEIGHT); |
| 459 | | for (int y = 0; y < ALTO2_DISPLAY_TOTAL_HEIGHT; y++) { |
| 460 | | UINT16* scanline = m_dsp.raw_bitmap + y * ALTO2_DISPLAY_SCANLINE_WORDS; |
| 461 | | m_dsp.scanline[y] = scanline; |
| 462 | | } |
| 453 | |
| 454 | m_dsp.raw_bitmap = auto_alloc_array(machine(), UINT16, ALTO2_DISPLAY_HEIGHT * ALTO2_DISPLAY_SCANLINE_WORDS); |
| 455 | m_dsp.scanline = auto_alloc_array(machine(), UINT8*, ALTO2_DISPLAY_HEIGHT); |
| 456 | for (int y = 0; y < ALTO2_DISPLAY_HEIGHT; y++) |
| 457 | m_dsp.scanline[y] = auto_alloc_array(machine(), UINT8, ALTO2_DISPLAY_TOTAL_WIDTH); |
| 458 | |
| 459 | m_dsp.bitmap = auto_bitmap_ind16_alloc(machine(), ALTO2_DISPLAY_WIDTH, ALTO2_DISPLAY_HEIGHT); |
| 463 | 460 | } |
| 464 | 461 | |
| 465 | 462 | void alto2_cpu_device::exit_disp() |
| 466 | 463 | { |
| 467 | 464 | // nothing to do yet |
| 468 | 465 | } |
| 466 | |
| 467 | /* Video update */ |
| 468 | UINT32 alto2_cpu_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 469 | { |
| 470 | pen_t palette_bw[2]; |
| 471 | palette_bw[0] = get_white_pen(machine()); |
| 472 | palette_bw[1] = get_black_pen(machine()); |
| 473 | // copy even or odd field |
| 474 | for (int y = m_dsp.odd_frame ? 0 : 1; y < ALTO2_DISPLAY_HEIGHT; y += 2) |
| 475 | draw_scanline8(*m_dsp.bitmap, 0, y, ALTO2_DISPLAY_WIDTH, m_dsp.scanline[y], palette_bw); |
| 476 | |
| 477 | // copy bitmap |
| 478 | copybitmap(bitmap, *m_dsp.bitmap, 0, 0, 0, 0, cliprect); |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | void alto2_cpu_device::screen_eof(screen_device &screen, bool state) |
| 483 | { |
| 484 | if (state) |
| 485 | m_dsp.odd_frame = !m_dsp.odd_frame; |
| 486 | } |
branches/alto2/src/emu/cpu/alto2/a2disp.h
| r26307 | r26308 | |
| 81 | 81 | #define ALTO2_DISPLAY_SCANLINE_TIME ALTO2_DISPLAY_BITTIME(ALTO2_DISPLAY_TOTAL_WIDTH)//!< time for a scanline in pico seconds (768 * 49.6031ns ~= 38095.1808ns) |
| 82 | 82 | #define ALTO2_DISPLAY_VISIBLE_TIME ALTO2_DISPLAY_BITTIME(ALTO2_DISPLAY_WIDTH) //!< time of the visible part of a scanline in pico seconds (606 * 49.6031ns ~= 30059.4786ns) |
| 83 | 83 | #define ALTO2_DISPLAY_WORD_TIME ALTO2_DISPLAY_BITTIME(16) //!< time for a word in pico seconds (16 pixels * 49.6031ns ~= 793.6496ns) |
| 84 | | #define ALTO2_DISPLAY_VBLANK_TIME ((ALTO2_DISPLAY_TOTAL_HEIGHT-ALTO2_DISPLAY_HEIGHT)*HZ_TO_ATTOSECONDS(26250)) |
| 84 | #define ALTO2_DISPLAY_VBLANK_TIME ((ALTO2_DISPLAY_TOTAL_HEIGHT-ALTO2_DISPLAY_HEIGHT)*HZ_TO_ATTOSECONDS(26250)/2) |
| 85 | 85 | |
| 86 | 86 | #else // ALTO2_DEFINE_CONSTANTS |
| 87 | 87 | /** |
| r26307 | r26308 | |
| 194 | 194 | UINT32 curword; //!< helper: first cursor word in current scanline |
| 195 | 195 | UINT32 curdata; //!< helper: shifted cursor data (32-bit) |
| 196 | 196 | UINT16 *raw_bitmap; //!< array of words of the raw bitmap that is displayed |
| 197 | | UINT16 **scanline; //!< array of pointers to the scanlines |
| 197 | UINT8 **scanline; //!< array of scanlines with 1 byte per pixel |
| 198 | bitmap_ind16 *bitmap; //!< MAME bitmap with 16 bit indices |
| 199 | bool odd_frame; //!< true, if odd frame is drawn |
| 198 | 200 | } m_dsp; |
| 199 | 201 | |
| 200 | 202 | /** |
| r26307 | r26308 | |
| 303 | 305 | //! test the VBLANK (vertical blanking) signal in PROM a66 being low |
| 304 | 306 | static inline bool A66_VBLANK_LO(UINT8 a, int hlc1024) { return a & (hlc1024 ? A66_VBLANK_ODD : A66_VBLANK_EVEN) ? true : false; } |
| 305 | 307 | |
| 306 | | bitmap_ind16* m_bitmap; //!< screen bitmap |
| 307 | | |
| 308 | 308 | void update_bitmap_word(int x, int y, UINT16 word); //!< update a word in the screen bitmap |
| 309 | 309 | void unload_word(); //!< unload the next word from the display FIFO and shift it to the screen |
| 310 | 310 | void display_state_machine(); //!< function called by the CPU to enter the next display state |
| r26307 | r26308 | |
| 313 | 313 | |
| 314 | 314 | void init_disp(); //!< initialize the display context |
| 315 | 315 | void exit_disp(); //!< deinitialize the display context |
| 316 | |
| 316 | 317 | #endif // _A2DISP_H_ |
| 317 | 318 | #endif // ALTO2_DEFINE_CONSTANTS |
branches/alto2/src/mess/drivers/alto2.c
| r26307 | r26308 | |
| 8 | 8 | |
| 9 | 9 | #include "includes/alto2.h" |
| 10 | 10 | |
| 11 | | /* Video */ |
| 12 | | |
| 13 | | UINT32 alto2_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 14 | | { |
| 15 | | alto2_cpu_device* cpu = downcast<alto2_cpu_device *>(m_maincpu.target()); |
| 16 | | bitmap_ind16* source = cpu->bitmap(); |
| 17 | | if (source && source->valid()) |
| 18 | | copybitmap(bitmap, *source, 0, 0, 0, 0, cliprect); |
| 19 | | return 0; |
| 20 | | } |
| 21 | | |
| 22 | 11 | /* Input Ports */ |
| 23 | 12 | |
| 24 | 13 | static INPUT_PORTS_START( alto2 ) |
| r26307 | r26308 | |
| 123 | 112 | PORT_START("mousey") // Mouse - Y AXIS |
| 124 | 113 | PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(50) PORT_KEYDELTA(1) PORT_PLAYER(1) PORT_CHANGED_MEMBER( ":maincpu", alto2_cpu_device, mouse_motion_y, 0 ) |
| 125 | 114 | |
| 126 | | PORT_START("CONFIG") /* Memory switch on AIM board */ |
| 115 | PORT_START("CONFIG") /* Memory switch on AIM board */ |
| 127 | 116 | PORT_CONFNAME( 1<<9, 1<<9, "Memory switch") |
| 128 | 117 | PORT_CONFSETTING( 0, "on") |
| 129 | 118 | PORT_CONFSETTING( 1<<9, "off") |
| r26307 | r26308 | |
| 175 | 164 | MCFG_SCREEN_RAW_PARAMS(XTAL_20_16MHz, |
| 176 | 165 | ALTO2_DISPLAY_TOTAL_WIDTH, 0, ALTO2_DISPLAY_WIDTH, |
| 177 | 166 | ALTO2_DISPLAY_TOTAL_HEIGHT, 0, ALTO2_DISPLAY_HEIGHT) |
| 178 | | MCFG_SCREEN_UPDATE_DRIVER(alto2_state, screen_update) |
| 167 | MCFG_SCREEN_REFRESH_RATE(60) // two interlaced fields |
| 168 | MCFG_SCREEN_VBLANK_TIME(ALTO2_DISPLAY_VBLANK_TIME) |
| 169 | MCFG_SCREEN_UPDATE_DEVICE("maincpu", alto2_cpu_device, screen_update) |
| 170 | MCFG_SCREEN_VBLANK_DEVICE("maincpu", alto2_cpu_device, screen_eof) |
| 179 | 171 | |
| 180 | 172 | MCFG_PALETTE_LENGTH(2) |
| 181 | 173 | |