trunk/src/emu/video/snes_ppu.c
r241562 | r241563 | |
214 | 214 | { |
215 | 215 | m_openbus_cb.resolve_safe(0); |
216 | 216 | |
217 | | #if SNES_LAYER_DEBUG |
218 | | memset(&m_debug_options, 0, sizeof(m_debug_options)); |
219 | | #endif |
220 | | |
221 | 217 | m_vram = auto_alloc_array(machine(), UINT8, SNES_VRAM_SIZE); |
222 | 218 | m_cgram = auto_alloc_array(machine(), UINT16, SNES_CGRAM_SIZE/2); |
223 | 219 | m_oam_ram = auto_alloc_array(machine(), UINT16, SNES_OAM_SIZE/2); |
224 | 220 | |
225 | | /* Inititialize registers/variables */ |
226 | | m_update_windows = 1; |
227 | | m_beam.latch_vert = 0; |
228 | | m_beam.latch_horz = 0; |
229 | | m_beam.current_vert = 0; |
230 | | m_beam.current_horz = 0; |
231 | | m_beam.last_visible_line = 225; /* TODO: PAL setting */ |
232 | | m_mode = 0; |
233 | | m_ppu1_version = 1; // 5C77 chip version number, read by STAT77, only '1' is known |
234 | | m_ppu2_version = 3; // 5C78 chip version number, read by STAT78, only '2' & '3' encountered so far. |
235 | | |
236 | | m_cgram_address = 0; |
237 | | m_read_ophct = 0; |
238 | | m_read_opvct = 0; |
239 | | |
240 | | PPU_REG(VMAIN) = 0x80; |
241 | | // what about other regs? |
242 | | |
243 | | /* Inititialize mosaic table */ |
244 | | for (int j = 0; j < 16; j++) |
245 | | { |
246 | | for (int i = 0; i < 4096; i++) |
247 | | m_mosaic_table[j][i] = (i / (j + 1)) * (j + 1); |
248 | | } |
249 | | |
250 | | /* Init VRAM */ |
251 | | memset(m_vram, 0, SNES_VRAM_SIZE); |
252 | | |
253 | | /* Init Palette RAM */ |
254 | | memset((UINT8 *)m_cgram, 0, SNES_CGRAM_SIZE); |
255 | | |
256 | | /* Init oam RAM */ |
257 | | memset((UINT8 *)m_oam_ram, 0xff, SNES_OAM_SIZE); |
258 | | |
259 | | m_stat78 = 0; |
260 | | memset(m_regs, 0x00, sizeof(m_regs)); |
261 | | |
262 | 221 | for (int i = 0; i < 2; i++) |
263 | 222 | { |
264 | 223 | save_item(NAME(m_scanlines[i].enable), i); |
r241562 | r241563 | |
400 | 359 | save_pointer(NAME(m_oam_ram), SNES_OAM_SIZE/2); |
401 | 360 | } |
402 | 361 | |
| 362 | void snes_ppu_device::device_reset() |
| 363 | { |
| 364 | |
| 365 | #if SNES_LAYER_DEBUG |
| 366 | memset(&m_debug_options, 0, sizeof(m_debug_options)); |
| 367 | #endif |
| 368 | |
| 369 | /* Inititialize registers/variables */ |
| 370 | m_update_windows = 1; |
| 371 | m_beam.latch_vert = 0; |
| 372 | m_beam.latch_horz = 0; |
| 373 | m_beam.current_vert = 0; |
| 374 | m_beam.current_horz = 0; |
| 375 | m_beam.last_visible_line = 225; /* TODO: PAL setting */ |
| 376 | m_mode = 0; |
| 377 | m_ppu1_version = 1; // 5C77 chip version number, read by STAT77, only '1' is known |
| 378 | m_ppu2_version = 3; // 5C78 chip version number, read by STAT78, only '2' & '3' encountered so far. |
| 379 | |
| 380 | m_cgram_address = 0; |
| 381 | m_read_ophct = 0; |
| 382 | m_read_opvct = 0; |
| 383 | |
| 384 | PPU_REG(VMAIN) = 0x80; |
| 385 | // what about other regs? |
| 386 | |
| 387 | /* Inititialize mosaic table */ |
| 388 | for (int j = 0; j < 16; j++) |
| 389 | { |
| 390 | for (int i = 0; i < 4096; i++) |
| 391 | m_mosaic_table[j][i] = (i / (j + 1)) * (j + 1); |
| 392 | } |
| 393 | |
| 394 | /* Init VRAM */ |
| 395 | memset(m_vram, 0, SNES_VRAM_SIZE); |
| 396 | |
| 397 | /* Init Palette RAM */ |
| 398 | memset((UINT8 *)m_cgram, 0, SNES_CGRAM_SIZE); |
| 399 | |
| 400 | /* Init oam RAM */ |
| 401 | memset((UINT8 *)m_oam_ram, 0xff, SNES_OAM_SIZE); |
| 402 | |
| 403 | m_stat78 = 0; |
403 | 404 | |
| 405 | // other initializations to 0 |
| 406 | memset(m_regs, 0, sizeof(m_regs)); |
| 407 | memset(m_oam_itemlist, 0, sizeof(m_oam_itemlist)); |
| 408 | memset(&m_oam, 0, sizeof(m_oam)); |
| 409 | memset(&m_mode7, 0, sizeof(m_mode7)); |
404 | 410 | |
| 411 | for (int i = 0; i < 2; i++) |
| 412 | { |
| 413 | m_scanlines[i].enable = 0; |
| 414 | m_scanlines[i].clip = 0; |
| 415 | memset(m_scanlines[i].buffer, 0, SNES_SCR_WIDTH); |
| 416 | memset(m_scanlines[i].priority, 0, SNES_SCR_WIDTH); |
| 417 | memset(m_scanlines[i].layer, 0, SNES_SCR_WIDTH); |
| 418 | memset(m_scanlines[i].blend_exception, 0, SNES_SCR_WIDTH); |
| 419 | } |
| 420 | |
| 421 | for (int i = 0; i < 6; i++) |
| 422 | { |
| 423 | m_layer[i].window1_enabled = 0; |
| 424 | m_layer[i].window1_invert = 0; |
| 425 | m_layer[i].window2_enabled = 0; |
| 426 | m_layer[i].window2_invert = 0; |
| 427 | m_layer[i].wlog_mask = 0; |
| 428 | m_layer[i].color_math = 0; |
| 429 | m_layer[i].charmap = 0; |
| 430 | m_layer[i].tilemap = 0; |
| 431 | m_layer[i].tilemap_size = 0; |
| 432 | m_layer[i].tile_size = 0; |
| 433 | m_layer[i].mosaic_enabled = 0; |
| 434 | m_layer[i].main_window_enabled = 0; |
| 435 | m_layer[i].sub_window_enabled = 0; |
| 436 | m_layer[i].main_bg_enabled = 0; |
| 437 | m_layer[i].sub_bg_enabled = 0; |
| 438 | m_layer[i].hoffs = 0; |
| 439 | m_layer[i].voffs = 0; |
| 440 | |
| 441 | memset(m_clipmasks[i], 0, SNES_SCR_WIDTH); |
| 442 | } |
| 443 | |
| 444 | for (int i = 0; i < ARRAY_LENGTH(m_oam_spritelist); i++) |
| 445 | { |
| 446 | m_oam_spritelist[i].tile = 0; |
| 447 | m_oam_spritelist[i].x = 0; |
| 448 | m_oam_spritelist[i].y = 0; |
| 449 | m_oam_spritelist[i].size = 0; |
| 450 | m_oam_spritelist[i].vflip = 0; |
| 451 | m_oam_spritelist[i].hflip = 0; |
| 452 | m_oam_spritelist[i].priority_bits = 0; |
| 453 | m_oam_spritelist[i].pal = 0; |
| 454 | m_oam_spritelist[i].height = 0; |
| 455 | m_oam_spritelist[i].width = 0; |
| 456 | } |
| 457 | |
| 458 | for (int i = 0; i < ARRAY_LENGTH(m_oam_tilelist); i++) |
| 459 | { |
| 460 | m_oam_tilelist[i].x = 0; |
| 461 | m_oam_tilelist[i].priority = 0; |
| 462 | m_oam_tilelist[i].pal = 0; |
| 463 | m_oam_tilelist[i].tileaddr = 0; |
| 464 | m_oam_tilelist[i].hflip = 0; |
| 465 | } |
| 466 | } |
| 467 | |
405 | 468 | /***************************************** |
406 | 469 | * get_bgcolor() |
407 | 470 | * |