Previous 199869 Revisions Next

r26308 Wednesday 20th November, 2013 at 17:42:31 UTC by Jürgen Buchmüller
Try to handle interlaced display using a screen_eof function which toggles the even/odd frames.
[/branches/alto2/src/emu/cpu/alto2]a2disp.c a2disp.h alto2cpu.c alto2cpu.h
[/branches/alto2/src/mess/drivers]alto2.c
[/branches/alto2/src/mess/includes]alto2.h

branches/alto2/src/emu/cpu/alto2/a2disp.c
r26307r26308
147147   0xffc0,0xffc3,0xffcc,0xffcf,0xfff0,0xfff3,0xfffc,0xffff
148148};
149149
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
154151void alto2_cpu_device::update_bitmap_word(int x, int y, UINT16 word)
155152{
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;
173172}
174173
175174#define   HLC1   ((m_dsp.hlc >>  0) & 1)      //!< horizontal line counter bit 0
r26307r26308
214213{
215214   int x = m_unload_word;
216215   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;
218217
219218   UINT32 word = m_dsp.inverse;
220219   if (FIFO_MBEMPTY_0() == 0) {
r26307r26308
444443 * @brief initialize the display context to useful values
445444 *
446445 * 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
448447 * there is no change in the data words.
449448 */
450449void alto2_cpu_device::init_disp()
451450{
452451   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));
456452   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);
463460}
464461
465462void alto2_cpu_device::exit_disp()
466463{
467464   // nothing to do yet
468465}
466
467/* Video update */
468UINT32 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
482void 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
r26307r26308
8181#define   ALTO2_DISPLAY_SCANLINE_TIME   ALTO2_DISPLAY_BITTIME(ALTO2_DISPLAY_TOTAL_WIDTH)//!< time for a scanline in pico seconds (768 * 49.6031ns ~= 38095.1808ns)
8282#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)
8383#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)
8585
8686#else   // ALTO2_DEFINE_CONSTANTS
8787/**
r26307r26308
194194   UINT32 curword;                  //!< helper: first cursor word in current scanline
195195   UINT32 curdata;                  //!< helper: shifted cursor data (32-bit)
196196   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
198200}   m_dsp;
199201
200202/**
r26307r26308
303305//! test the VBLANK (vertical blanking) signal in PROM a66 being low
304306static inline bool A66_VBLANK_LO(UINT8 a, int hlc1024) { return a & (hlc1024 ? A66_VBLANK_ODD : A66_VBLANK_EVEN) ? true : false; }
305307
306bitmap_ind16* m_bitmap;            //!< screen bitmap
307
308308void update_bitmap_word(int x, int y, UINT16 word);   //!< update a word in the screen bitmap
309309void unload_word();               //!< unload the next word from the display FIFO and shift it to the screen
310310void display_state_machine();      //!< function called by the CPU to enter the next display state
r26307r26308
313313
314314void init_disp();               //!< initialize the display context
315315void exit_disp();               //!< deinitialize the display context
316
316317#endif   // _A2DISP_H_
317318#endif   // ALTO2_DEFINE_CONSTANTS
branches/alto2/src/emu/cpu/alto2/alto2cpu.c
r26307r26308
158158   m_disp_a38(0),
159159   m_disp_a63(0),
160160   m_disp_a66(0),
161   m_bitmap(0),
162161   m_mem(),
163162   m_emu(),
164163   m_ether_a41(0),
r26307r26308
250249}
251250
252251//-------------------------------------------------
253// driver interface to get the internal bitmap
254//-------------------------------------------------
255
256bitmap_ind16*alto2_cpu_device::bitmap()
257{
258   return m_bitmap;
259}
260
261//-------------------------------------------------
262252//  device_rom_region - device-specific (P)ROMs
263253//-------------------------------------------------
264254
branches/alto2/src/emu/cpu/alto2/alto2cpu.h
r26307r26308
164164   //! call in for the next sector callback
165165   void next_sector(int unit);
166166
167   //! return the display bitmap
168   bitmap_ind16* bitmap();
167   //! update the screen bitmap
168   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
169169
170   //! screen VBLANK handler
171   void screen_eof(screen_device &screen, bool state);
172
170173   DECLARE_ADDRESS_MAP( ucode_map, 32 );
171174   DECLARE_ADDRESS_MAP( const_map, 16 );
172175   DECLARE_ADDRESS_MAP( iomem_map, 16 );
branches/alto2/src/mess/includes/alto2.h
r26307r26308
2828      m_io_config(*this, "CONFIG")
2929   { }
3030
31   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32
3331   DECLARE_DRIVER_INIT(alto2);
3432
3533   virtual void palette_init();
branches/alto2/src/mess/drivers/alto2.c
r26307r26308
88
99#include "includes/alto2.h"
1010
11/* Video */
12
13UINT32 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
2211/* Input Ports */
2312
2413static INPUT_PORTS_START( alto2 )
r26307r26308
123112   PORT_START("mousey")   // Mouse - Y AXIS
124113   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 )
125114
126PORT_START("CONFIG")    /* Memory switch on AIM board */
115   PORT_START("CONFIG")    /* Memory switch on AIM board */
127116   PORT_CONFNAME( 1<<9, 1<<9, "Memory switch")
128117   PORT_CONFSETTING( 0,    "on")
129118   PORT_CONFSETTING( 1<<9, "off")
r26307r26308
175164   MCFG_SCREEN_RAW_PARAMS(XTAL_20_16MHz,
176165                     ALTO2_DISPLAY_TOTAL_WIDTH,   0, ALTO2_DISPLAY_WIDTH,
177166                     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)
179171
180172   MCFG_PALETTE_LENGTH(2)
181173

Previous 199869 Revisions Next


© 1997-2024 The MAME Team