unit U_Ricoh_5C7x; {$ModeSwitch AdvancedRecords}
// SNES PPU = picture processing unit (Ricoh 5C77 + 5C78)
interface /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// uses
// U_Tools;
// --- from U_Tools ---
const Bit0 = 1 SHL 0; Bits0 = Bit0 - 1;
const Bit1 = 1 SHL 1; Bits1 = Bit1 - 1; type u1 = 0..Bits1;
const Bit2 = 1 SHL 2; Bits2 = Bit2 - 1; type u2 = 0..Bits2;
const Bit3 = 1 SHL 3; Bits3 = Bit3 - 1; type u3 = 0..Bits3;
const Bit4 = 1 SHL 4; Bits4 = Bit4 - 1; type u4 = 0..Bits4;
const Bit5 = 1 SHL 5; Bits5 = Bit5 - 1; type u5 = 0..Bits5;
const Bit6 = 1 SHL 6; Bits6 = Bit6 - 1; type u6 = 0..Bits6;
const Bit7 = 1 SHL 7; Bits7 = Bit7 - 1; type u7 = 0..Bits7;
const Bit8 = 1 SHL 8; Bits8 = Bit8 - 1; type u8 = 0..Bits8;
const Bit9 = 1 SHL 9; Bits9 = Bit9 - 1; type u9 = 0..Bits9;
const Bit16 = 1 SHL 16; Bits16 = Bit16 - 1; type u16 = 0..Bits16;
const Bit24 = 1 SHL 24; Bits24 = Bit24 - 1; type u24 = 0..Bits24;
const Bit32 = 1 SHL 32; Bits32 = Bit32 - 1; type u32 = 0..Bits32; uint = u32;
const Bits64 = high(QWord); type u64 = QWord;
type
i8 = System.ShortInt; i16 = System.SmallInt; i32 = System.LongInt; i64 = System.Int64; int = i32;
b8 = System.Boolean; b16 = System.Boolean16; b32 = System.Boolean32; b64 = System.Boolean64; bool = b32;
// ---
type Ricoh_5C7x = packed record
procedure PowerOn(const PAL : bool = False);
procedure Step;
type
OAM_Info1 = bitpacked record
X, Y, Tile : u8; // x position (8 of 9 bits), y position, first 8x8 pixel tile index
NameTable : u1; // where to grab the tiles from - https://wiki.superfamicom.org/sprites
Palette : u3; // a slice of the global palette
Priority : u2; // relationship to the 4 backgrounds
FlipX, FlipY : bool; // is sprite mirrored horizontally and/or vertically
end; {$if SizeOf(OAM_Info1) <> 4} {$fatal} {$endif}
OAM_Info2 = bitpacked record // using this on ObjectAttributeMemory.Table2[i] causes internal error 20060521 in FPC 3.2.2
X_Bit8 : u1; // 9th bit of the sprite's X position
Size : u1; // one of the two sizes possible per screen
end;
ObjectAttributeMemory = bitpacked record
case uint of
0: (Bytes : array[0..(512 + 32) - 1] of u8);
1: (
Table1 : array[u7] of OAM_Info1; // 512
Table2 : bitpacked array[u7] of u2; // 32
);
end; {$if SizeOf(ObjectAttributeMemory) <> 544} {$fatal} {$endif}