src/mame/machine/snes.c
| r5438 | r5439 | |
| 103 | 103 | snes_hirq_tick(machine); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | | static TIMER_CALLBACK( snes_scanline_tick ) |
| 106 | static TIMER_CALLBACK( snes_reset_oam_address ) |
| 107 | 107 | { |
| 108 | 108 | // make sure we're in the 65816's context since we're messing with the OAM and stuff |
| 109 | 109 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 110 | 110 | |
| 111 | if(!(snes_ram[INIDISP]&0x80)) //Reset OAM address, byuu says it happens at H=10 |
| 112 | { |
| 113 | memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low ); /* Reset oam address */ |
| 114 | memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | static TIMER_CALLBACK( snes_scanline_tick ) |
| 119 | { |
| 111 | 120 | /* Increase current line - we want to latch on this line during it, not after it */ |
| 112 | 121 | snes_ppu.beam.current_vert = video_screen_get_vpos(machine->primary_screen); |
| 113 | 122 | |
| r5438 | r5439 | |
| 157 | 166 | /* Start of VBlank */ |
| 158 | 167 | if( snes_ppu.beam.current_vert == snes_ppu.beam.last_visible_line ) |
| 159 | 168 | { |
| 160 | | if(!(snes_ram[INIDISP]&0x80)) |
| 161 | | { |
| 162 | | memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low ); /* Reset oam address */ |
| 163 | | memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high ); |
| 164 | | } |
| 169 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, snes_ppu.beam.current_vert, 10), NULL, 0, snes_reset_oam_address); |
| 170 | |
| 165 | 171 | snes_ram[HVBJOY] |= 0x81; /* Set vblank bit to on & indicate controllers being read */ |
| 166 | 172 | snes_ram[RDNMI] |= 0x80; /* Set NMI occured bit */ |
| 167 | 173 | |
| r5438 | r5439 | |
| 664 | 670 | // APU is mirrored from 2140 to 217f |
| 665 | 671 | if (offset >= APU00 && offset < WMDATA) |
| 666 | 672 | { |
| 667 | | // printf("816: %02x to APU @ %d\n", data, offset&3); |
| 668 | | spc_port_in[offset & 0x3] = data; |
| 673 | // printf("816: %02x to APU @ %d\n", data, offset&3); |
| 674 | spc_port_in[offset & 0x3] = data; |
| 669 | 675 | cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(20)); |
| 670 | 676 | return; |
| 671 | 677 | } |
| r5438 | r5439 | |
| 674 | 680 | switch( offset ) |
| 675 | 681 | { |
| 676 | 682 | case INIDISP: /* Initial settings for screen */ |
| 683 | if((snes_ram[INIDISP] & 0x80) && (!(data & 0x80))) //a 1->0 force blank transition causes a reset OAM address |
| 684 | { |
| 685 | memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low ); |
| 686 | memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high ); |
| 687 | } |
| 677 | 688 | break; |
| 678 | 689 | case OBSEL: /* Object size and data area designation */ |
| 679 | 690 | snes_ppu.layer[4].data = ((data & 0x3) * 0x2000) << 1; |