/* testdol.c : simply displays an image converted using gc-a2ycbycr
 * Copyright (C) 2003  Alexandre Boeglin <alex AT boeglin DOT org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#include <mygcn.h>
#include "image.c"

//reset
#define REG_HOTRESET (0xCC003024)
#define REG_HOTRESET_PTR ((volatile u32*)REG_HOTRESET)
#define M_HOTRESET *REG_HOTRESET_PTR = 0x00000000;

//framebuffer
u32 *fb=(u32*)0xC0500000;

PAD pad;

int main(){

	int i,j;

	VIDEO_Init(VIDEO_640X480_PAL60_YUV16);
	VIDEO_SetFrameBuffer(VIDEO_FRAMEBUFFER_1,(u32)fb);
	VIDEO_SetFrameBuffer(VIDEO_FRAMEBUFFER_2,(u32)(fb+320));

	RENDER_ClearFrameBuffer(fb, COLOR_NAVY);

	while(1){

		VIDEO_WaitVSync();

		PAD_ReadState(&pad, PAD_CHANNEL_0);

		if(pad.Digital.B)
			RENDER_ClearFrameBuffer(fb, COLOR_NAVY);

		if(pad.Digital.A)
			for(j=0;j<IMAGE_HEIGHT;j++)
				for(i=0;i<IMAGE_WIDTH;i++)
					fb[320*j+i]=IMAGE_BITMAP[j][i];

		if(pad.Digital.Start)
			M_HOTRESET

	}
	return 0;
}
