Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. namespace ConsoleApplication1.SP
  2. {
  3.     public sealed class OamWriteCycle : ICycle
  4.     {
  5.         private readonly Oam oam;
  6.         private readonly Registers registers;
  7.  
  8.         public OamWriteCycle(Oam oam, Registers registers)
  9.         {
  10.             this.oam = oam;
  11.             this.registers = registers;
  12.         }
  13.  
  14.         public void Execute()
  15.         {
  16.             oam.Sprite[oam.SpriteIndex] = oam.Latch;
  17.  
  18.             if ((oam.SpriteIndex & 3) == 0)
  19.             {
  20.                 int compare = (registers.V - oam.Latch) & 0x1ff;
  21.                 if (compare >= 8)
  22.                 {
  23.                     oam.MemoryIndex = (oam.MemoryIndex + 4) & 0xff;
  24.  
  25.                     if (oam.SpriteCount < 8)
  26.                     {
  27.                         return;
  28.                     }
  29.                 }
  30.             }
  31.  
  32.             oam.MemoryIndex = (oam.MemoryIndex + 1) & 0xff;
  33.             oam.SpriteIndex = (oam.SpriteIndex + 1) & 0x1f;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement