Notice : 内容無保証。禁無断転載。リンク不自由。

ayaka.c

#include <piece.h>

//

#define    vWidth  128
#define    vHeight 88

#define    ayakaWidth  48
#define    ayakaHeight 72
#define    ayakaPtn(n) (ayakaHeight * (n))

#define    speed   3

#define pceLCDDraw(\
    pBmp, dstX, dstY, srcX, srcY, w, h, param\
){\
    DRAW_OBJECT obj ;\
    pceLCDSetObject(&obj, (pBmp), (dstX), (dstY), (srcX), (srcY), (w), (h), (param)) ;\
    pceLCDDrawObject(obj) ;\
}

//

static unsigned char vbuff[vWidth * vHeight];

extern unsigned char A[] ;
extern unsigned char B[] ;

static PIECE_BMP   pbmpAyaka ;
static PIECE_BMP   pbmpBackG ;

static unsigned char seq[] = {
#include "sample.c"
} ;

//

static void pceBmpInit(
    PIECE_BMP*      pBmp,
    unsigned char* pDat
){
    pBmp->header = *(PBMP_FILEHEADER*)pDat ;
    pBmp->buf        = pDat + sizeof(PBMP_FILEHEADER) ;
    pBmp->mask       = pBmp->buf + (pBmp->header.h * pBmp->header.w)/4 ;
}

static void drawBackG(void){
    static unsigned int    x = 0 ;

    pceLCDDraw(&pbmpBackG, 0, 0, x, 0, vWidth-x, vHeight, DRW_NOMAL) ;
    pceLCDDraw(&pbmpBackG, vWidth-x, 0, 0, 0, x, vHeight, DRW_NOMAL) ;

    x += speed ;
    x %= vWidth ;
}

static void drawAyaka(void){
    static int ptn[] = {
        ayakaPtn(0),
        ayakaPtn(1),
        ayakaPtn(2),
        ayakaPtn(0),
        ayakaPtn(3),
        ayakaPtn(4)
    } ;

    static int*    EOP = ptn + sizeof(ptn)/sizeof(ptn[0]) ;
    static int*    pPtn = ptn ;

    pceLCDDraw(&pbmpAyaka, 40, 0, 0, *pPtn, ayakaWidth, ayakaHeight, DRW_NOMAL) ;

    pPtn++ ;
    if (EOP <= pPtn) {
        pPtn = ptn ;
    }
}

//

void pceAppInit( void ){
    pceLCDDispStop();

    pceAppSetProcPeriod(160) ;

    InitMusic() ;
    PlayMusic(seq) ;

    pceLCDSetBuffer( vbuff );

    pceBmpInit(&pbmpAyaka, A) ;
    pceBmpInit(&pbmpBackG, B) ;

    drawBackG() ;
    drawAyaka() ;
    pceLCDTrans() ;

    pceLCDDispStart();
}

void pceAppProc( int cnt ){
    drawBackG() ;
    drawAyaka() ;
    pceLCDTrans() ;
}

void pceAppExit( void ){
    pceWaveStop(0) ;
}