#define printf rpclog

struct
{
        int ime;
        uint16_t ie,ifr;
        uint16_t waitcnt;
        uint16_t bright,blend,blalpha;
        int bootflag;
        uint16_t keycnt;
        uint16_t rcnt;
        int bl1,bl2,br;
} gba;

struct
{
        uint16_t ctrl;
        uint16_t dispstat;
        uint16_t mosaic;
        int line;
        unsigned short bgctrl[4];
        int xscroll[4],yscroll[4];
        unsigned long bg2x,bg2y,bg3x,bg3y;
        unsigned long dx[2],dy[2],dmx[2],dmy[2];
        unsigned short winin,winout;
} lcd;

struct
{
        int x1[2],y1[2];
        int x2[2],y2[2];
} windows;

struct
{
        uint32_t src,dst;
        uint16_t len;
        uint16_t ctrl;
        uint32_t srcl,dstl;
        uint16_t lenl;
} dma[4];

struct
{
        uint16_t latch[4];
        int count[4];
        uint16_t ctrl[4];
        uint16_t dat[4];
} timers;

struct
{
        uint16_t bias;
        uint16_t ctrll,ctrlh,ctrlx;
        uint16_t ctrls[16];

        int vol1,latch1,stat1,curvol1;
        float count1;
        int env1,envdir1,envcnt1;

        int vol2,latch2,stat2,curvol2;
        float count2;
        int env2,envdir2,envcnt2;
        int wave1,wave2;

        int vol4,latch4,stat4,curvol4;
        float count4;
        int env4,envdir4,envcnt4;
        unsigned short nshift;
        int polylen;

        int envtime;
        
        int wavebank;
        int wavemask,waveset,waveon;
        
        int count3,curvol3,stat3;
        float latch3;
} sound;

struct
{
        unsigned long bg2x,bg2y;
        unsigned long bg3x,bg3y;
} rotozoom;

int indma;

char romname[1024];

int romwait16[3],romwait32[3];

int soundaclocks,soundbclocks;

int savelen;
int savechange;

int scale;
