public Background(GameboyAdvance gba, int bgNumber, BgControlRegister cntRegister) { this.gba = gba; this.BgNumber = bgNumber; CntRegister = cntRegister; AffineMode = false; TileMap = new TileMap(gba.Memory.VRam, cntRegister, bgNumber); AffineMatrix = new BgAffineMatrix(); }
public LcdController(GameboyAdvance gba) { this.gba = gba; frameBuffer0 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution); frameBuffer1 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution); FrameBuffer = frameBuffer0; drawBuffer = frameBuffer1; this.Palettes = new Palettes(); DisplayControlRegister = new DisplayControlRegister(this); DispStatRegister = new DisplayStatusRegister(this); BgControlRegisters = new BgControlRegister[4]; Bg = new Background[4]; for (int i = 0; i < 4; i++) { BgControlRegisters[i] = new BgControlRegister(this, i); Bg[i] = new Background(gba, i, BgControlRegisters[i]); priorityObjList[i] = new List<Obj>(); } Obj = new Obj[Max_Sprites]; for (int i = 0; i < Max_Sprites; i++) { Obj[i] = new Obj(gba, new ObjAttributes(gba, i * 8, gba.Memory.OamRam)); } OamAffineMatrices = new OamAffineMatrix[Max_OAM_Matrices]; UInt32 address = 0x00000006; for (int i = 0; i < 32; i++) { OamAffineMatrices[i] = new OamAffineMatrix(gba.Memory.OamRam, address); address += 0x20; } Windows = new Window[4]; for (int i = 0; i < 4; i++) { Windows[i] = new Window(gba); } #if THREADED_SCANLINE drawScanline = false; exitThread = false; scanlineThread = new Thread(new ThreadStart(ScanlineThread)); scanlineThread.Start(); #endif }
public LcdController(GameboyAdvance gba) { this.gba = gba; frameBuffer0 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution); frameBuffer1 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution); FrameBuffer = frameBuffer0; drawBuffer = frameBuffer1; this.Palettes = new Palettes(); DisplayControlRegister = new DisplayControlRegister(gba, this); DispStatRegister = new DisplayStatusRegister(gba, this); Bg = new Background[4]; UInt32 scrollBaseAddress = 0x4000010; for (int i = 0; i < 4; i++) { BgControlRegister cntReg = new BgControlRegister(gba, this, i, (UInt32) (0x4000008 + (i * 2))); MemoryRegister16 scrollXReg = new MemoryRegister16(gba.Memory, scrollBaseAddress, false, true, 0x01); MemoryRegister16 scrollYReg = new MemoryRegister16(gba.Memory, scrollBaseAddress + 2, false, true, 0x01); Bg[i] = new Background(gba, i, cntReg, scrollXReg, scrollYReg); scrollBaseAddress += 4; } VCount = new MemoryRegister8(gba.Memory, 0x04000006, true, false); this.ObjController = new ObjController(gba); Windows = new Window[4]; Windows[0] = new Window(gba, 0x4000040, 0x4000048); Windows[1] = new Window(gba, 0x4000042, 0x4000049); Windows[2] = new Window(gba, 0, 0x400004A); Windows[3] = new Window(gba, 0, 0x400004B); this.BlendControlRegister = new BlendControlRegister(this, gba); BlendingCoefficientRegister = new PixelCoefficientRegister(this, gba, 0x4000052); BrightnessCoefficientRegister = new PixelCoefficientRegister(this, gba, 0x4000054); #if THREADED_SCANLINE //Interlocked.Exchange(ref drawScanline, 0); drawScanline = 0; exitThread = false; scanlineThread = new Thread(new ThreadStart(ScanlineThread)); scanlineThread.Priority = ThreadPriority.Highest; scanlineThread.Start(); #endif }
public TileMap(byte[] vram, BgControlRegister cntReg, int bgNum) { this.cntReg = cntReg; this.vram = vram; this.bgNum = bgNum; // Regardless of Bg size, we create enough tol hold the max size screenBlock0 = new TileMapEntry[1024]; screenBlock1 = new TileMapEntry[1024]; screenBlock2 = new TileMapEntry[1024]; screenBlock3 = new TileMapEntry[1024]; for (int i = 0; i < 1024; i++) { screenBlock0[i] = new TileMapEntry(vram); screenBlock1[i] = new TileMapEntry(vram); screenBlock2[i] = new TileMapEntry(vram); screenBlock3[i] = new TileMapEntry(vram); } // This reset is important, we have to have default values set as some games don't setup the bg registers, they assume default values Reset(); }
public Background(GameboyAdvance gba, int bgNumber, BgControlRegister cntRegister, MemoryRegister16 scrollXReg, MemoryRegister16 scrollYReg) { this.gba = gba; this.BgNumber = bgNumber; CntRegister = cntRegister; AffineMode = false; TileMap = new TileMap(gba.Memory.VRam, cntRegister, bgNumber); BGXHOFS = scrollXReg; BGXVOFS = scrollYReg; // Only bg 2 & 3 can rotate and scale if (bgNumber == 2) { AffineMatrix = new BgAffineMatrix(gba, 0x4000020); AffineScrollXReg = new AffineScrollRegister(gba.Memory, 0x4000028, false, true); AffineScrollYReg = new AffineScrollRegister(gba.Memory, 0x400002C, false, true); } else if (bgNumber == 3) { AffineMatrix = new BgAffineMatrix(gba, 0x4000030); AffineScrollXReg = new AffineScrollRegister(gba.Memory, 0x4000038, false, true); AffineScrollYReg = new AffineScrollRegister(gba.Memory, 0x400003C, false, true); } ScanlineData = new int[LcdController.Screen_X_Resolution]; #if THREADED_SCANLINE Interlocked.Exchange(ref cacheScanline, 0); exitThread = false; scanlineThread = new Thread(new ThreadStart(ScanlineThread)); scanlineThread.Start(); #endif }