trunk/src/mame/drivers/rastersp.c
| r19699 | r19700 | |
| 128 | 128 | UINT16 *m_palette; |
| 129 | 129 | UINT32 m_speedup_count; |
| 130 | 130 | UINT32 m_tms_io_regs[0x80]; |
| 131 | bitmap_ind16 m_update_bitmap; |
| 131 | 132 | |
| 132 | 133 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 133 | 134 | void update_irq(UINT32 which, UINT32 state); |
| r19699 | r19700 | |
| 193 | 194 | |
| 194 | 195 | void rastersp_state::video_start() |
| 195 | 196 | { |
| 196 | | |
| 197 | m_update_bitmap.allocate(320, 240); |
| 197 | 198 | } |
| 198 | 199 | |
| 199 | 200 | |
| r19699 | r19700 | |
| 201 | 202 | { |
| 202 | 203 | m_dpyaddr = data; |
| 203 | 204 | |
| 204 | | } |
| 205 | | |
| 206 | | |
| 207 | | void 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 | | |
| 238 | | Palette update: (8d000400) |
| 239 | | [1] 1....... ........ ........ ........ ? |
| 240 | | ...0.... ........ ........ ........ 0 for palette upload? |
| 241 | | ....11.. ........ ........ ........ ? |
| 242 | | .......x xxxxxxxx ........ ........ Entry count |
| 243 | | ........ ........ .....1.. ........ ? (Usually 1) |
| 244 | | |
| 245 | | Pixel 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 | | |
| 253 | | Unknown: (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 | | |
| 266 | | UINT32 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 |
| 268 | 207 | if (m_dpyaddr == 0) |
| 269 | 208 | { |
| 270 | | bitmap.fill(get_black_pen(machine()), cliprect); |
| 271 | | return 0; |
| 209 | m_update_bitmap.fill(get_black_pen(machine())); |
| 210 | return; |
| 272 | 211 | } |
| 273 | 212 | |
| 274 | 213 | UINT32 dpladdr = (m_dpyaddr & ~0xff) >> 6; |
| r19699 | r19700 | |
| 276 | 215 | if ((m_dpyaddr & 0xff) != 0xb2 && (m_dpyaddr & 0xff) != 0xf2) |
| 277 | 216 | logerror("Unusual display list data: %x\n", m_dpyaddr); |
| 278 | 217 | |
| 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); |
| 282 | 221 | |
| 283 | | while (y <= cliprect.max_y) |
| 222 | while (y < 240) |
| 284 | 223 | { |
| 285 | 224 | UINT32 word1 = m_dram[dpladdr/4]; |
| 286 | 225 | |
| r19699 | r19700 | |
| 315 | 254 | incr |= ~((incr & 0x800) - 1) & ~0xff; |
| 316 | 255 | |
| 317 | 256 | // 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) |
| 319 | 258 | { |
| 320 | | while (x <= cliprect.max_x && pixels) |
| 259 | while (x < 320 && pixels) |
| 321 | 260 | { |
| 322 | 261 | *bmpptr++ = palptr[srcptr[BYTE_XOR_LE(acc >> 8)]]; |
| 323 | 262 | acc = (acc + incr) & VIDEO_ADDR_MASK; |
| r19699 | r19700 | |
| 327 | 266 | } |
| 328 | 267 | |
| 329 | 268 | // Advance to the next scanline |
| 330 | | if (x > cliprect.max_x) |
| 269 | if (x >= 320) |
| 331 | 270 | { |
| 332 | | x = cliprect.min_x; |
| 271 | x = 0; |
| 333 | 272 | ++y; |
| 334 | 273 | } |
| 335 | 274 | } |
| r19699 | r19700 | |
| 342 | 281 | upload_palette(word1, word2); |
| 343 | 282 | } |
| 344 | 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | |
| 288 | void 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; |
| 345 | 304 | } |
| 305 | } |
| 346 | 306 | |
| 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 | |
| 319 | Palette update: (8d000400) |
| 320 | [1] 1....... ........ ........ ........ ? |
| 321 | ...0.... ........ ........ ........ 0 for palette upload? |
| 322 | ....11.. ........ ........ ........ ? |
| 323 | .......x xxxxxxxx ........ ........ Entry count |
| 324 | ........ ........ .....1.. ........ ? (Usually 1) |
| 325 | |
| 326 | Pixel 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 | |
| 334 | Unknown: (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 | |
| 347 | UINT32 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); |
| 347 | 350 | return 0; |
| 348 | 351 | } |
| 349 | 352 | |