; Listing generated by Microsoft (R) Optimizing Compiler Version 15.00.30729.01 ; ; I compiled S9xGetWord() in getset.h of snes9x 1.51 rerecording, ; which causes an obvious graphical glitch in Donkey Kong Country, ; with Visual Studio 2008, using /Ox and code listing option. ; This might tell why the optimization causes such a weird glitch. ; ; Line numbers are not correct for some reasons, nevermind. PUBLIC ?S9xGetWord@@YAGIW4s9xwrap_t@@_N@Z ; S9xGetWord EXTRN _S9xGetBSX:PROC EXTRN _S9xGetST018:PROC EXTRN _S9xGetSetaDSP:PROC EXTRN _GetOBC1:PROC EXTRN _S9xGetSPC7110:PROC EXTRN _S9xGetSPC7110Byte:PROC EXTRN _S9xGetC4:PROC EXTRN _Multi:BYTE EXTRN _S9xGetDSP:PROC EXTRN _S9xGetCPU:PROC EXTRN _S9xGetPPU:PROC EXTRN _Memory:BYTE EXTRN _CPU:BYTE EXTRN _OpenBus:BYTE EXTRN ?S9xGetByte@@YAEI_N@Z:PROC ; S9xGetByte ; Function compile flags: /Ogtpy ; File .\snes9x-151\cpu.cpp _TEXT SEGMENT _Address$ = 8 ; size = 4 _a$66541 = 12 ; size = 4 _a$66539 = 12 ; size = 4 _w$ = 12 ; size = 4 _free$ = 16 ; size = 1 ?S9xGetWord@@YAGIW4s9xwrap_t@@_N@Z PROC ; S9xGetWord ; 199 : { push ebx push esi push edi ; 200 : uint32 mask=MEMMAP_MASK&(w==WRAP_PAGE?0xff:(w==WRAP_BANK?0xffff:0xffffff)); mov edi, DWORD PTR _w$[esp+8] cmp edi, 2 jne SHORT $LN36@S9xGetWord mov eax, 255 ; 000000ffH jmp SHORT $LN37@S9xGetWord $LN36@S9xGetWord: mov eax, edi dec eax neg eax sbb eax, eax and eax, 16711680 ; 00ff0000H add eax, 65535 ; 0000ffffH $LN37@S9xGetWord: ; 201 : if ((Address & mask) == mask) mov ebx, DWORD PTR _Address$[esp+8] and eax, 4095 ; 00000fffH mov ecx, eax and ecx, ebx cmp ecx, eax jne SHORT $LN31@S9xGetWord ; 202 : { ; 203 : OpenBus=S9xGetByte(Address, free); mov esi, DWORD PTR _free$[esp+8] push esi push ebx call ?S9xGetByte@@YAEI_N@Z ; S9xGetByte mov BYTE PTR _OpenBus, al add esp, 8 ; 204 : switch(w){ mov eax, edi sub eax, 1 ; 218 : } ; 219 : case WRAP_NONE: ; 220 : default: ; 221 : return (OpenBus | (S9xGetByte (Address + 1, free) << 8)); push esi je SHORT $LN29@S9xGetWord ; 204 : switch(w){ sub eax, 1 je SHORT $LN30@S9xGetWord ; 218 : } ; 219 : case WRAP_NONE: ; 220 : default: ; 221 : return (OpenBus | (S9xGetByte (Address + 1, free) << 8)); inc ebx push ebx call ?S9xGetByte@@YAEI_N@Z ; S9xGetByte movzx edx, BYTE PTR _OpenBus add esp, 8 movzx eax, al pop edi shl eax, 8 pop esi or eax, edx pop ebx ; 338 : } ; 339 : } ret 0 $LN30@S9xGetWord: ; 205 : case WRAP_PAGE: ; 206 : { ; 207 : PC_t a; ; 208 : a.xPBPC = Address; mov DWORD PTR _a$66539[esp+12], ebx ; 209 : a.B.xPCl++; inc bl mov BYTE PTR _a$66539[esp+12], bl ; 210 : return (OpenBus | (S9xGetByte (a.xPBPC, free) << 8)); mov eax, DWORD PTR _a$66539[esp+12] push eax $LN41@S9xGetWord: call ?S9xGetByte@@YAEI_N@Z ; S9xGetByte movzx ecx, BYTE PTR _OpenBus add esp, 8 movzx eax, al pop edi ; 330 : ; 331 : case CMemory::MAP_DEBUG: ; 332 : #ifdef DEBUGGER ; 333 : printf ("DEBUG R(W) %06x\n", Address); ; 334 : #endif ; 335 : default: ; 336 : case CMemory::MAP_NONE: ; 337 : return (OpenBus | (OpenBus<<8)); shl eax, 8 pop esi or eax, ecx pop ebx ; 338 : } ; 339 : } ret 0 $LN29@S9xGetWord: ; 211 : } ; 212 : case WRAP_BANK: ; 213 : { ; 214 : PC_t a; ; 215 : a.xPBPC = Address; mov DWORD PTR _a$66541[esp+12], ebx ; 216 : a.W.xPC++; inc ebx mov WORD PTR _a$66541[esp+12], bx ; 217 : return (OpenBus | (S9xGetByte (a.xPBPC, free) << 8)); mov edx, DWORD PTR _a$66541[esp+12] push edx jmp SHORT $LN41@S9xGetWord $LN31@S9xGetWord: ; 222 : } ; 223 : } ; 224 : int block; ; 225 : uint8 *GetAddress = Memory.Map [block = ((Address&0xffffff) >> MEMMAP_SHIFT)]; ; 226 : ; 227 : if(!CPU.InDMAorHDMA && !free) mov cl, BYTE PTR _CPU+8 mov edx, DWORD PTR _free$[esp+8] mov eax, ebx shr eax, 12 ; 0000000cH and eax, 4095 ; 00000fffH mov esi, DWORD PTR _Memory[eax*4+76] test cl, cl jne SHORT $LN39@S9xGetWord test dl, dl jne SHORT $LN39@S9xGetWord ; 228 : CPU.Cycles += (Memory.MemorySpeed [block]<<1); movzx edi, BYTE PTR _Memory[eax+41036] push ebp mov ebp, DWORD PTR _CPU+28 lea edi, DWORD PTR [ebp+edi*2] mov DWORD PTR _CPU+28, edi pop ebp $LN39@S9xGetWord: ; 229 : ; 230 : ; 231 : if (GetAddress >= (uint8 *) CMemory::MAP_LAST) cmp esi, 20 ; 00000014H jb SHORT $LN26@S9xGetWord ; 232 : { ; 233 : #ifdef CPU_SHUTDOWN ; 234 : if (Memory.BlockIsRAM [block] && !free) cmp BYTE PTR _Memory[eax+32844], 0 je SHORT $LN25@S9xGetWord test dl, dl jne SHORT $LN25@S9xGetWord ; 235 : CPU.WaitAddress = CPU.PBPCAtOpcodeStart; mov edx, DWORD PTR _CPU+16 mov DWORD PTR _CPU+20, edx $LN25@S9xGetWord: ; 236 : #endif ; 237 : return READ_WORD(GetAddress + (Address & 0xffff)); and ebx, 65535 ; 0000ffffH mov ax, WORD PTR [ebx+esi] pop edi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN26@S9xGetWord: ; 238 : } ; 239 : ; 240 : switch ((pint) GetAddress) cmp esi, 17 ; 00000011H ja $LN1@S9xGetWord jmp DWORD PTR $LN43@S9xGetWord[esi*4] $LN22@S9xGetWord: ; 241 : { ; 242 : case CMemory::MAP_PPU: ; 243 : if(CPU.InDMAorHDMA){ test cl, cl je SHORT $LN21@S9xGetWord ; 244 : OpenBus=S9xGetByte (Address, free); push edx push ebx call ?S9xGetByte@@YAEI_N@Z ; S9xGetByte mov BYTE PTR _OpenBus, al ; 245 : return (OpenBus | (S9xGetByte (Address + 1, free) << 8)); mov eax, DWORD PTR _free$[esp+16] push eax inc ebx push ebx call ?S9xGetByte@@YAEI_N@Z ; S9xGetByte movzx ecx, BYTE PTR _OpenBus add esp, 16 ; 00000010H movzx eax, al pop edi ; 330 : ; 331 : case CMemory::MAP_DEBUG: ; 332 : #ifdef DEBUGGER ; 333 : printf ("DEBUG R(W) %06x\n", Address); ; 334 : #endif ; 335 : default: ; 336 : case CMemory::MAP_NONE: ; 337 : return (OpenBus | (OpenBus<<8)); shl eax, 8 pop esi or eax, ecx pop ebx ; 338 : } ; 339 : } ret 0 $LN21@S9xGetWord: ; 246 : } ; 247 : return (S9xGetPPU (Address & 0xffff) | ; 248 : (S9xGetPPU ((Address + 1) & 0xffff) << 8)); lea edx, DWORD PTR [ebx+1] push edx call _S9xGetPPU movzx esi, al push ebx shl esi, 8 call _S9xGetPPU add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN20@S9xGetWord: ; 249 : case CMemory::MAP_CPU: ; 250 : return (S9xGetCPU (Address & 0xffff) | ; 251 : (S9xGetCPU ((Address + 1) & 0xffff) << 8)); lea eax, DWORD PTR [ebx+1] push eax call _S9xGetCPU movzx esi, al push ebx shl esi, 8 call _S9xGetCPU add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN19@S9xGetWord: ; 252 : case CMemory::MAP_DSP: ; 253 : #ifdef DSP_DUMMY_LOOPS ; 254 : printf("Get DSP Word @ %06X\n", Address); ; 255 : #endif ; 256 : return (S9xGetDSP (Address & 0xffff) | ; 257 : (S9xGetDSP ((Address + 1) & 0xffff) << 8)); lea ecx, DWORD PTR [ebx+1] push ecx call _S9xGetDSP movzx esi, al push ebx shl esi, 8 call _S9xGetDSP add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN18@S9xGetWord: ; 258 : case CMemory::MAP_SA1RAM: ; 259 : case CMemory::MAP_LOROM_SRAM: ; 260 : //Address &0x7FFF -offset into bank ; 261 : //Address&0xFF0000 -bank ; 262 : //bank>>1 | offset = s-ram address, unbound ; 263 : //unbound & SRAMMask = Sram offset ; 264 : if(Memory.SRAMMask>=MEMMAP_MASK){ mov ecx, DWORD PTR _Memory+45472 cmp ecx, 4095 ; 00000fffH jb SHORT $LN17@S9xGetWord ; 265 : return READ_WORD(Memory.SRAM + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Memory.SRAMMask)); mov eax, DWORD PTR _Memory+44 mov edx, ebx shr edx, 1 and ebx, 32767 ; 00007fffH and edx, 8355840 ; 007f8000H or edx, ebx pop edi and edx, ecx mov ax, WORD PTR [edx+eax] pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN17@S9xGetWord: ; 266 : } else { ; 267 : /* no READ_WORD here, since if Memory.SRAMMask=0x7ff ; 268 : * then the high byte doesn't follow the low byte. */ ; 269 : return ; 270 : (*(Memory.SRAM + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Memory.SRAMMask)))| ; 271 : ((*(Memory.SRAM + (((((Address+1)&0xFF0000)>>1) |((Address+1)&0x7FFF)) &Memory.SRAMMask)))<<8); mov edx, DWORD PTR _Memory+44 lea eax, DWORD PTR [ebx+1] mov esi, eax shr esi, 1 and esi, 8355840 ; 007f8000H and eax, 32767 ; 00007fffH or esi, eax and esi, ecx movzx eax, BYTE PTR [esi+edx] mov esi, ebx shr esi, 1 and esi, 8355840 ; 007f8000H and ebx, 32767 ; 00007fffH or esi, ebx and esi, ecx movzx ecx, BYTE PTR [esi+edx] pop edi ; 330 : ; 331 : case CMemory::MAP_DEBUG: ; 332 : #ifdef DEBUGGER ; 333 : printf ("DEBUG R(W) %06x\n", Address); ; 334 : #endif ; 335 : default: ; 336 : case CMemory::MAP_NONE: ; 337 : return (OpenBus | (OpenBus<<8)); shl eax, 8 pop esi or eax, ecx pop ebx ; 338 : } ; 339 : } ret 0 $LN16@S9xGetWord: ; 272 : } ; 273 : ; 274 : case CMemory::MAP_LOROM_SRAM_B: ; 275 : if(Multi.sramMaskB>=MEMMAP_MASK){ mov ecx, DWORD PTR _Multi+24 cmp ecx, 4095 ; 00000fffH jb SHORT $LN14@S9xGetWord ; 276 : return READ_WORD(Multi.sramB + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Multi.sramMaskB)); mov eax, DWORD PTR _Multi+40 mov edx, ebx shr edx, 1 and ebx, 32767 ; 00007fffH and edx, 8355840 ; 007f8000H or edx, ebx pop edi and edx, ecx mov ax, WORD PTR [edx+eax] pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN14@S9xGetWord: ; 277 : } else { ; 278 : return ; 279 : (*(Multi.sramB + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Multi.sramMaskB)))| ; 280 : ((*(Multi.sramB + (((((Address+1)&0xFF0000)>>1) |((Address+1)&0x7FFF)) &Multi.sramMaskB)))<<8); mov edx, DWORD PTR _Multi+40 lea eax, DWORD PTR [ebx+1] mov esi, eax shr esi, 1 and esi, 8355840 ; 007f8000H and eax, 32767 ; 00007fffH or esi, eax and esi, ecx movzx eax, BYTE PTR [esi+edx] mov esi, ebx shr esi, 1 and esi, 8355840 ; 007f8000H and ebx, 32767 ; 00007fffH or esi, ebx and esi, ecx movzx ecx, BYTE PTR [esi+edx] pop edi ; 330 : ; 331 : case CMemory::MAP_DEBUG: ; 332 : #ifdef DEBUGGER ; 333 : printf ("DEBUG R(W) %06x\n", Address); ; 334 : #endif ; 335 : default: ; 336 : case CMemory::MAP_NONE: ; 337 : return (OpenBus | (OpenBus<<8)); shl eax, 8 pop esi or eax, ecx pop ebx ; 338 : } ; 339 : } ret 0 $LN13@S9xGetWord: ; 281 : } ; 282 : ; 283 : case CMemory::MAP_RONLY_SRAM: ; 284 : case CMemory::MAP_HIROM_SRAM: ; 285 : if(Memory.SRAMMask>=MEMMAP_MASK){ mov ecx, DWORD PTR _Memory+45472 cmp ecx, 4095 ; 00000fffH jb SHORT $LN11@S9xGetWord ; 286 : return READ_WORD(Memory.SRAM + ; 287 : (((Address & 0x7fff) - 0x6000 + ; 288 : ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)); mov edx, ebx shr edx, 3 and ebx, 32767 ; 00007fffH and edx, 122880 ; 0001e000H lea eax, DWORD PTR [edx+ebx-24576] pop edi and eax, ecx mov ecx, DWORD PTR _Memory+44 mov ax, WORD PTR [eax+ecx] pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN11@S9xGetWord: ; 289 : } else { ; 290 : /* no READ_WORD here, since if Memory.SRAMMask=0x7ff ; 291 : * then the high byte doesn't follow the low byte. */ ; 292 : return (*(Memory.SRAM + ; 293 : (((Address & 0x7fff) - 0x6000 + ; 294 : ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)) | ; 295 : (*(Memory.SRAM + ; 296 : ((((Address + 1) & 0x7fff) - 0x6000 + ; 297 : (((Address + 1) & 0xf0000) >> 3)) & Memory.SRAMMask)) << 8)); lea eax, DWORD PTR [ebx+1] mov edx, eax shr edx, 3 and eax, 32767 ; 00007fffH mov esi, ebx shr esi, 3 and edx, 122880 ; 0001e000H lea eax, DWORD PTR [edx+eax-24576] mov edx, DWORD PTR _Memory+44 and esi, 122880 ; 0001e000H and ebx, 32767 ; 00007fffH and eax, ecx movzx eax, BYTE PTR [eax+edx] lea esi, DWORD PTR [esi+ebx-24576] and esi, ecx movzx ecx, BYTE PTR [esi+edx] pop edi ; 330 : ; 331 : case CMemory::MAP_DEBUG: ; 332 : #ifdef DEBUGGER ; 333 : printf ("DEBUG R(W) %06x\n", Address); ; 334 : #endif ; 335 : default: ; 336 : case CMemory::MAP_NONE: ; 337 : return (OpenBus | (OpenBus<<8)); shl eax, 8 pop esi or eax, ecx pop ebx ; 338 : } ; 339 : } ret 0 $LN10@S9xGetWord: ; 298 : } ; 299 : ; 300 : case CMemory::MAP_BWRAM: ; 301 : return READ_WORD(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)); mov edx, DWORD PTR _Memory+56 pop edi and ebx, 32767 ; 00007fffH mov ax, WORD PTR [ebx+edx-24576] pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN8@S9xGetWord: ; 302 : ; 303 : case CMemory::MAP_C4: ; 304 : return (S9xGetC4 (Address & 0xffff) | ; 305 : (S9xGetC4 ((Address + 1) & 0xffff) << 8)); lea eax, DWORD PTR [ebx+1] push eax call _S9xGetC4 movzx esi, al push ebx shl esi, 8 call _S9xGetC4 add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN7@S9xGetWord: ; 306 : ; 307 : case CMemory::MAP_SPC7110_ROM: ; 308 : #ifdef SPC7110_DEBUG ; 309 : printf("reading spc7110 ROM (word) at %06X\n", Address); ; 310 : #endif ; 311 : return (S9xGetSPC7110Byte(Address)| ; 312 : (S9xGetSPC7110Byte (Address+1))<<8); lea ecx, DWORD PTR [ebx+1] push ecx call _S9xGetSPC7110Byte movzx esi, al push ebx shl esi, 8 call _S9xGetSPC7110Byte add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN6@S9xGetWord: ; 313 : case CMemory::MAP_SPC7110_DRAM: ; 314 : #ifdef SPC7110_DEBUG ; 315 : printf("reading Bank 50 (word)\n"); ; 316 : #endif ; 317 : return (S9xGetSPC7110(0x4800)| ; 318 : (S9xGetSPC7110 (0x4800) << 8)); push 18432 ; 00004800H call _S9xGetSPC7110 movzx esi, al push 18432 ; 00004800H shl esi, 8 call _S9xGetSPC7110 add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN5@S9xGetWord: ; 319 : case CMemory::MAP_OBC_RAM: ; 320 : return GetOBC1(Address&0xFFFF)| (GetOBC1((Address+1)&0xFFFF)<<8); lea edx, DWORD PTR [ebx+1] push edx call _GetOBC1 movzx esi, al push ebx shl esi, 8 call _GetOBC1 add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN4@S9xGetWord: ; 321 : ; 322 : case CMemory::MAP_SETA_DSP: ; 323 : return S9xGetSetaDSP(Address)| (S9xGetSetaDSP((Address+1))<<8); lea eax, DWORD PTR [ebx+1] push eax call _S9xGetSetaDSP movzx esi, al push ebx shl esi, 8 call _S9xGetSetaDSP add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN3@S9xGetWord: ; 324 : ; 325 : case CMemory::MAP_SETA_RISC: ; 326 : return S9xGetST018(Address)| (S9xGetST018((Address+1))<<8); lea ecx, DWORD PTR [ebx+1] push ecx call _S9xGetST018 movzx esi, al push ebx shl esi, 8 call _S9xGetST018 add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN2@S9xGetWord: ; 327 : ; 328 : case CMemory::MAP_BSX: ; 329 : return S9xGetBSX(Address)| (S9xGetBSX((Address+1))<<8); lea edx, DWORD PTR [ebx+1] push edx call _S9xGetBSX movzx esi, al push ebx shl esi, 8 call _S9xGetBSX add esp, 8 movzx eax, al pop edi or eax, esi pop esi pop ebx ; 338 : } ; 339 : } ret 0 $LN1@S9xGetWord: ; 330 : ; 331 : case CMemory::MAP_DEBUG: ; 332 : #ifdef DEBUGGER ; 333 : printf ("DEBUG R(W) %06x\n", Address); ; 334 : #endif ; 335 : default: ; 336 : case CMemory::MAP_NONE: ; 337 : return (OpenBus | (OpenBus<<8)); movzx ecx, BYTE PTR _OpenBus pop edi mov eax, ecx shl eax, 8 pop esi or eax, ecx pop ebx ; 338 : } ; 339 : } ret 0 npad 1 $LN43@S9xGetWord: DD $LN22@S9xGetWord DD $LN20@S9xGetWord DD $LN18@S9xGetWord DD $LN16@S9xGetWord DD $LN13@S9xGetWord DD $LN19@S9xGetWord DD $LN8@S9xGetWord DD $LN10@S9xGetWord DD $LN1@S9xGetWord DD $LN1@S9xGetWord DD $LN18@S9xGetWord DD $LN7@S9xGetWord DD $LN6@S9xGetWord DD $LN13@S9xGetWord DD $LN5@S9xGetWord DD $LN4@S9xGetWord DD $LN3@S9xGetWord DD $LN2@S9xGetWord ?S9xGetWord@@YAGIW4s9xwrap_t@@_N@Z ENDP ; S9xGetWord _TEXT ENDS