Previous 199869 Revisions Next

r19700 Thursday 20th December, 2012 at 13:11:12 UTC by Phil Bennett
rastersp.c - Hastily move the display list parsing outside of screen_update() or else things will break with frameskipping enabled (duh!) -nw-
[src/mame/drivers]rastersp.c

trunk/src/mame/drivers/rastersp.c
r19699r19700
128128   UINT16 *m_palette;
129129   UINT32   m_speedup_count;
130130   UINT32   m_tms_io_regs[0x80];
131   bitmap_ind16 m_update_bitmap;
131132
132133   UINT32   screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
133134   void   update_irq(UINT32 which, UINT32 state);
r19699r19700
193194
194195void rastersp_state::video_start()
195196{
196
197   m_update_bitmap.allocate(320, 240);
197198}
198199
199200
r19699r19700
201202{
202203   m_dpyaddr = data;
203204
204}
205
206
207void rastersp_state::upload_palette(UINT32 word1, UINT32 word2)
208{
209   if (word1 & 3)
210      fatalerror("Unalligned palette address! (%x, %x)\n", word1, word2);
211
212   UINT32 addr = word1 >> 8;
213   UINT32 entries = (word2 >> 16) & 0x1ff;
214   UINT32 index = ((word2 >> 12) & 0x1f) * 256;
215
216   // The third byte of each entry in RAM appears to contain an index
217   // but appears to be discared when written to palette RAM
218   while (entries--)
219   {
220      UINT32 data = m_dram[addr / 4];
221      m_palette[index++] = data & 0xffff;
222      addr += 4;
223   }
224}
225
226
227/*******************************************************************************
228
229   Display list register:
230
231   ..xxxxxx xxxxxxxx xxxxxxxx ........    Display list base (DWORD granularity)
232   ........ ........ ........ xxxxxxxx  ? (number of entries? Only seems to be valid for basic stuff)
233
234   Display list format:
235
236[0] ..xxxxxx xxxxxxxx xxxxxxxx ........    Source address (4MB mask?)
237
238Palette update: (8d000400)
239[1] 1....... ........ ........ ........  ?
240    ...0.... ........ ........ ........  0 for palette upload?
241   ....11.. ........ ........ ........  ?
242    .......x xxxxxxxx ........ ........  Entry count
243    ........ ........ .....1.. ........  ? (Usually 1)
244
245Pixel data: (94040100)
246[2] 1....... ........ ........ ........  ?
247    ...1.... ........ ........ ........  1 for video update?
248   .....1.. ........ ........ ........  ?
249    .......x xxxxxxxx ........ ........  Pixel count
250    ........ ........ xxxx.... ........  Palette
251   ........ ........ ....xxxx xxxxxxxx  Scale (4.8 signed fixed point)
252
253Unknown: (D4000100) - Present at start of a list
254[3] 1....... ........ ........ .........
255    .1...... ........ ........ ......... ?
256    ..1..... ........ ........ .........
257   .....1.. ........ ........ ......... ?
258   ........ ........ .......1 ......... ?
259
260
261   TODO: I'm not sure about bit 28. When creating the display list if it's 0,
262   0x1000 is added to the source address.
263
264*******************************************************************************/
265
266UINT32 rastersp_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
267{
205   // Update the video now
206   // TODO: This should probably be done in sync with the video scan
268207   if (m_dpyaddr == 0)
269208   {
270      bitmap.fill(get_black_pen(machine()), cliprect);
271      return 0;
209      m_update_bitmap.fill(get_black_pen(machine()));
210      return;
272211   }
273212
274213   UINT32 dpladdr = (m_dpyaddr & ~0xff) >> 6;
r19699r19700
276215   if ((m_dpyaddr & 0xff) != 0xb2 && (m_dpyaddr & 0xff) != 0xf2)
277216      logerror("Unusual display list data: %x\n", m_dpyaddr);
278217
279   int y = cliprect.min_y;
280   int x = cliprect.min_x;
281   UINT16 *bmpptr = &bitmap.pix16(cliprect.min_y, cliprect.min_x);
218   int y = 0;
219   int x = 0;
220   UINT16 *bmpptr = &m_update_bitmap.pix16(0, 0);
282221
283   while (y <= cliprect.max_y)
222   while (y < 240)
284223   {
285224      UINT32 word1 = m_dram[dpladdr/4];
286225
r19699r19700
315254            incr |= ~((incr & 0x800) - 1) & ~0xff;
316255
317256            // TODO: Assumes 8-bit palettized mode - the hardware also supports 16-bit direct
318            while (y <= cliprect.max_y && pixels)
257            while (y < 240 && pixels)
319258            {
320               while (x <= cliprect.max_x && pixels)
259               while (x < 320 && pixels)
321260               {
322261                  *bmpptr++ = palptr[srcptr[BYTE_XOR_LE(acc >> 8)]];
323262                  acc = (acc + incr) & VIDEO_ADDR_MASK;
r19699r19700
327266               }
328267
329268               // Advance to the next scanline
330               if (x > cliprect.max_x)
269               if (x >= 320)
331270               {
332                  x = cliprect.min_x;
271                  x = 0;
333272                  ++y;
334273               }
335274            }
r19699r19700
342281            upload_palette(word1, word2);
343282         }
344283      }
284   }   
285}
286
287
288void rastersp_state::upload_palette(UINT32 word1, UINT32 word2)
289{
290   if (word1 & 3)
291      fatalerror("Unalligned palette address! (%x, %x)\n", word1, word2);
292
293   UINT32 addr = word1 >> 8;
294   UINT32 entries = (word2 >> 16) & 0x1ff;
295   UINT32 index = ((word2 >> 12) & 0x1f) * 256;
296
297   // The third byte of each entry in RAM appears to contain an index
298   // but appears to be discared when written to palette RAM
299   while (entries--)
300   {
301      UINT32 data = m_dram[addr / 4];
302      m_palette[index++] = data & 0xffff;
303      addr += 4;
345304   }
305}
346306
307
308/*******************************************************************************
309
310   Display list register:
311
312   ..xxxxxx xxxxxxxx xxxxxxxx ........    Display list base (DWORD granularity)
313   ........ ........ ........ xxxxxxxx  ? (number of entries? Only seems to be valid for basic stuff)
314
315   Display list format:
316
317[0] ..xxxxxx xxxxxxxx xxxxxxxx ........    Source address (4MB mask?)
318
319Palette update: (8d000400)
320[1] 1....... ........ ........ ........  ?
321    ...0.... ........ ........ ........  0 for palette upload?
322   ....11.. ........ ........ ........  ?
323    .......x xxxxxxxx ........ ........  Entry count
324    ........ ........ .....1.. ........  ? (Usually 1)
325
326Pixel data: (94040100)
327[2] 1....... ........ ........ ........  ?
328    ...1.... ........ ........ ........  1 for video update?
329   .....1.. ........ ........ ........  ?
330    .......x xxxxxxxx ........ ........  Pixel count
331    ........ ........ xxxx.... ........  Palette
332   ........ ........ ....xxxx xxxxxxxx  Scale (4.8 signed fixed point)
333
334Unknown: (D4000100) - Present at start of a list
335[3] 1....... ........ ........ .........
336    .1...... ........ ........ ......... ?
337    ..1..... ........ ........ .........
338   .....1.. ........ ........ ......... ?
339   ........ ........ .......1 ......... ?
340
341
342   TODO: I'm not sure about bit 28. When creating the display list if it's 0,
343   0x1000 is added to the source address.
344
345*******************************************************************************/
346
347UINT32 rastersp_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
348{
349   copybitmap(bitmap, m_update_bitmap, 0, 0, 0, 0, cliprect);
347350   return 0;
348351}
349352

Previous 199869 Revisions Next


© 1997-2024 The MAME Team