| 2104 | |
| 2105 | int framectr = 0; |
| 2106 | int FCEUX_PPU_Loop(int skip) { |
| 2107 | |
| 2108 | if (new_ppu_reset) // first frame since reset, time to initialize |
| 2109 | { |
| 2110 | ppur.reset(); |
| 2111 | spr_read.reset(); |
| 2112 | new_ppu_reset = false; |
| 2113 | } |
| 2114 | |
| 2115 | //262 scanlines |
| 2116 | if (ppudead) { |
| 2117 | // not quite emulating all the NES power up behavior |
| 2118 | // since it is known that the NES ignores writes to some |
| 2119 | // register before around a full frame, but no games |
| 2120 | // should write to those regs during that time, it needs |
| 2121 | // to wait for vblank |
| 2122 | ppur.status.sl = 241; |
| 2123 | if (PAL) |
| 2124 | runppu(70 * kLineTime); |
| 2125 | else |
| 2126 | runppu(20 * kLineTime); |
| 2127 | ppur.status.sl = 0; |
| 2128 | runppu(242 * kLineTime); |
| 2129 | --ppudead; |
| 2130 | goto finish; |
| 2131 | } |
| 2132 | |
| 2133 | { |
| 2134 | PPU_status |= 0x80; |
| 2135 | ppuphase = PPUPHASE_VBL; |
| 2136 | |
| 2137 | //Not sure if this is correct. According to Matt Conte and my own tests, it is. |
| 2138 | //Timing is probably off, though. |
| 2139 | //NOTE: Not having this here breaks a Super Donkey Kong game. |
| 2140 | PPU[3] = PPUSPL = 0; |
| 2141 | const int delay = 20; //fceu used 12 here but I couldnt get it to work in marble madness and pirates. |
| 2142 | |
| 2143 | ppur.status.sl = 241; //for sprite reads |
| 2144 | |
| 2145 | //formerly: runppu(delay); |
| 2146 | for(int dot=0;dot<delay;dot++) |
| 2147 | runppu(1); |
| 2148 | |
| 2149 | if (VBlankON) TriggerNMI(); |
| 2150 | int sltodo = PAL?70:20; |
| 2151 | |
| 2152 | //formerly: runppu(20 * (kLineTime) - delay); |
| 2153 | for(int S=0;S<sltodo;S++) |
| 2154 | { |
| 2155 | for(int dot=(S==0?delay:0);dot<kLineTime;dot++) |
| 2156 | runppu(1); |
| 2157 | ppur.status.sl++; |
| 2158 | } |
| 2159 | |
| 2160 | //this seems to run just before the dummy scanline begins |
| 2161 | PPU_status = 0; |
| 2162 | //this early out caused metroid to fail to boot. I am leaving it here as a reminder of what not to do |
| 2163 | //if(!PPUON) { runppu(kLineTime*242); goto finish; } |
no test coverage detected