static OAMParse FrameToDump(Frame f) {//このルーチンは、stan の apdump.pyの成果を参考にしました。 OAMParse p = new OAMParse(); int sharp1 = (int)((f.OAM0 >> 14) & 0x3); int sharp2 = (int)((f.OAM1 >> 14) & 0x3); Size s = SharpTable[sharp1][sharp2]; p.width = s.Width; p.height = s.Height; p.image_x = (int)(f.OAM1 & 0x1FF); p.image_y = (int)(f.OAM0 & 0x0FF); if ((p.image_x & 0x100) == 0x100) { p.image_x = (p.image_x & 0xFF) - 256; } if ((p.image_y & 0x80) == 0x80) { p.image_y = (p.image_y & 0x7F) - 128; } p.tile = (f.OAM2 & 0x3FF); p.paletteShift = (int)((f.OAM2 & 0xF000) >> 12); p.oamFlag = (OAMFlag)((f.OAM0 & 0x0C00) >> 10); p.v_flipped = (f.OAM1 & 0x2000) == 0x2000; // 垂直に反転する p.h_flipped = (f.OAM1 & 0x1000) == 0x1000; // 水平に反転する return(p); }
public Bitmap DrawFrame(Bitmap ret, int index, int originX, int originY, Bitmap parts) { if (index >= FrameArray.Count) { return(ret); } int graphicsWidth = parts.Width / 8; FrameArr fa = FrameArray[index]; for (int i = 0; i < fa.Frames.Count; i++) { Frame f = fa.Frames[i]; OAMParse t = FrameToDump(f); int src = (int)(t.tile); int src_x = (src % graphicsWidth) * 8; int src_y = (src / graphicsWidth) * 8; ImageUtil.BitBlt(ret , originX + t.image_x, originY + t.image_y , t.width * 8 , t.height * 8 , parts , src_x, src_y , t.paletteShift , 0 , t.v_flipped , t.h_flipped ); // Log.Debug("_" + index + "_" + i + " " + t.image_x + "," + t.image_y + "@" + t.width * 8 + "," + t.height * 8); // ret.Save("_" + index + "_" + i + ".png"); } return(ret); }