| 1 | struct Sprite { |
| 2 | struct SpriteItem { |
| 3 | uint16 x; |
| 4 | uint16 y; |
| 5 | uint8 character; |
| 6 | bool nameselect; |
| 7 | bool vflip; |
| 8 | bool hflip; |
| 9 | uint8 priority; |
| 10 | uint8 palette; |
| 11 | bool size; |
| 12 | unsigned width() const; |
| 13 | unsigned height() const; |
| 14 | } list[128]; |
| 15 | |
| 16 | struct TileItem { |
| 17 | uint16 x; |
| 18 | uint16 priority; |
| 19 | uint16 palette; |
| 20 | bool hflip; |
| 21 | uint8 d0, d1, d2, d3; |
| 22 | }; |
| 23 | |
| 24 | struct State { |
| 25 | unsigned x; |
| 26 | unsigned y; |
| 27 | |
| 28 | unsigned item_count; |
| 29 | unsigned tile_count; |
| 30 | |
| 31 | bool active; |
| 32 | uint8 item[2][32]; |
| 33 | TileItem tile[2][34]; |
| 34 | } t; |
| 35 | |
| 36 | struct Regs { |
| 37 | bool main_enable; |
| 38 | bool sub_enable; |
| 39 | bool interlace; |
| 40 | |
| 41 | uint3 base_size; |
| 42 | uint2 nameselect; |
| 43 | uint16 tiledata_addr; |
| 44 | uint8 first_sprite; |
| 45 | |
| 46 | unsigned priority0; |
| 47 | unsigned priority1; |
| 48 | unsigned priority2; |
| 49 | unsigned priority3; |
| 50 | |
| 51 | bool time_over; |
| 52 | bool range_over; |
| 53 | } regs; |
| 54 | |
| 55 | struct Output { |
| 56 | struct Pixel { |
| 57 | unsigned priority; //0 = none (transparent) |
| 58 | uint8 palette; |
| 59 | } main, sub; |
| 60 | } output; |
| 61 | |
| 62 | //list.cpp |
| 63 | inline void update(unsigned addr, uint8 data); |
| 64 | inline void synchronize(); |
| 65 | |
| 66 | //sprite.cpp |
| 67 | inline void address_reset(); |
| 68 | inline void set_first_sprite(); |
| 69 | inline void frame(); |
| 70 | inline void scanline(); |
| 71 | inline void run(); |
| 72 | inline void tilefetch(); |
| 73 | inline void reset(); |
| 74 | |
| 75 | inline bool on_scanline(SpriteItem&); |
| 76 | |
| 77 | inline void serialize(serializer&); |
| 78 | inline Sprite(PPU& self); |
| 79 | |
| 80 | PPU& self; |
| 81 | friend class PPU; |
| 82 | }; |