Sprint game for GR-PEACH.

Dependencies:   GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP


What is this ?

This is a sprint time trial game. In this game you move by swiping from left to right.
The faster you swipe, the faster your character moves.
You can change the language of the comment by USER_BUTTON0. (defalt :English)
It uses the high speed Renesas graphics drawing library and the 2D graphics hardware accelerator.

Composition

GR-PEACH and GR-PEACH 4.3inch LCD Shield. /media/uploads/dkato/swipe_runner.jpg

About image to be drawn

Image files that are used in the sample program is easily possible replacement by using the "Convert Image to Binary Table" tool below.
This tool generates "BinaryImage_RZ_A1H.c" and "BinaryImage_RZ_A1H.h" in the Images folder and converts each image file to binary. Then, this tool outputs the data to "RGA_Sample_BinaryImage" table of "BinaryImage_RZ_A1H.c" and defines the macro name indicating the offset position in the table to "BinaryImage_RZ_A1H.h".
The sample program executes with reference to this macro name for offset.
/media/uploads/dkato/cnv_img_to_bin_tbl_swipe_runner.zip


概要

ゴールまでの到着時間を競うゲームです。画面の左から右へスワイプすると走ります。
速くスワイプすると走るスピードがあがります。
USER_BUTTON0を押すと吹き出しコメントを日本語に変更できます。(初期状態では英語に設定されています)
アクセラレータハードウェア アクセラレーションを使って高速に描画。

構成

GR-PEACH、GR-PEACH 4.3inch LCD Shield。 /media/uploads/dkato/swipe_runner.jpg

描画する画像について

サンプルプログラムで使用している画像ファイルは、下記の"Convert Image to Binary Table"ツールを利用する事で、簡単に差し替えが可能です。
このツールは、Imagesフォルダ内にBinaryImage_RZ_A1H.c ファイルと BinaryImage_RZ_A1H.h ファイルを生成し、各画像ファイルをバイナリ変換します。そして、そのデータをBinaryImage_RZ_A1H.c ファイルのRGA_Sample_BinaryImageテーブルに出力し、BinaryImage_RZ_A1H.h ファイルにテーブル内のオフセット位置を示すマクロ名を定義します。
サンプルプログラムでは、オフセット用のマクロ名を参照して動作します。
/media/uploads/dkato/cnv_img_to_bin_tbl_swipe_runner.zip

Committer:
dkato
Date:
Thu Jul 28 02:44:47 2016 +0000
Revision:
0:a2445295913c
Child:
2:9c5f0045c9df
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:a2445295913c 1 #include<stdio.h>
dkato 0:a2445295913c 2 #include<stdlib.h>
dkato 0:a2445295913c 3 #include<time.h>
dkato 0:a2445295913c 4 #include "mbed.h"
dkato 0:a2445295913c 5 #include "DisplayBace.h"
dkato 0:a2445295913c 6 #include "RGA.h"
dkato 0:a2445295913c 7 #include "rtos.h"
dkato 0:a2445295913c 8 #include "BinaryImage_RZ_A1H.h"
dkato 0:a2445295913c 9 #include "LCD_shield_config_4_3inch.h"
dkato 0:a2445295913c 10
dkato 0:a2445295913c 11 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565)
dkato 0:a2445295913c 12 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
dkato 0:a2445295913c 13
dkato 0:a2445295913c 14 /* FRAME BUFFER Parameter */
dkato 0:a2445295913c 15 #define FRAME_BUFFER_BYTE_PER_PIXEL (2)
dkato 0:a2445295913c 16 #define FRAME_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 0:a2445295913c 17
dkato 0:a2445295913c 18 #define GOAL_POINT (15000)
dkato 0:a2445295913c 19 #define NO_IMAGE (0xFFFFFFFF)
dkato 0:a2445295913c 20
dkato 0:a2445295913c 21 typedef struct {
dkato 0:a2445295913c 22 int now_pos;
dkato 0:a2445295913c 23 int tutorial_seq;
dkato 0:a2445295913c 24 int total_time;
dkato 0:a2445295913c 25 int record_time;
dkato 0:a2445295913c 26 int result_seq;
dkato 0:a2445295913c 27 int hito_ofs;
dkato 0:a2445295913c 28 int max_speed;
dkato 0:a2445295913c 29 int goal_seq;
dkato 0:a2445295913c 30 int hosi_seq;
dkato 0:a2445295913c 31 int speed;
dkato 0:a2445295913c 32 uint32_t hito_no;
dkato 0:a2445295913c 33 uint32_t comment_no;
dkato 0:a2445295913c 34 uint32_t ready_set_go;
dkato 0:a2445295913c 35 const graphics_image_t * p_hito;
dkato 0:a2445295913c 36 bool tutorial;
dkato 0:a2445295913c 37 bool swipe_on;
dkato 0:a2445295913c 38 bool goal_on;
dkato 0:a2445295913c 39 bool result_on;
dkato 0:a2445295913c 40 bool new_record;
dkato 0:a2445295913c 41 bool hosi;
dkato 0:a2445295913c 42 bool first_record;
dkato 0:a2445295913c 43 bool time_and_speed;
dkato 0:a2445295913c 44 } disp_func_t;
dkato 0:a2445295913c 45
dkato 0:a2445295913c 46 static DisplayBase Display;
dkato 0:a2445295913c 47 static Canvas2D_ContextClass canvas2d;
dkato 0:a2445295913c 48 static DigitalOut lcd_pwon(P7_15);
dkato 0:a2445295913c 49 static DigitalOut lcd_blon(P8_1);
dkato 0:a2445295913c 50 static PwmOut lcd_cntrst(P8_15);
dkato 0:a2445295913c 51 static Serial pc(USBTX, USBRX);
dkato 0:a2445295913c 52 static Semaphore sem_touch_int(0);
dkato 0:a2445295913c 53 static TouckKey_LCD_shield touch(P4_0, P2_13, I2C_SDA, I2C_SCL);
dkato 0:a2445295913c 54 static Timer stop_watch;
dkato 0:a2445295913c 55 static disp_func_t disp_info;
dkato 0:a2445295913c 56 static bool touch_click = false;
dkato 0:a2445295913c 57 static bool touch_start = false;
dkato 0:a2445295913c 58 static bool race_start = false;
dkato 0:a2445295913c 59 static int total_move_x = 0;
dkato 0:a2445295913c 60 static int wk_wait = 0;
dkato 0:a2445295913c 61 static int pic_idx = 0;
dkato 0:a2445295913c 62 static int tukare = 0;
dkato 0:a2445295913c 63 static int table_no = 0;
dkato 0:a2445295913c 64
dkato 0:a2445295913c 65 #if defined(__ICCARM__)
dkato 0:a2445295913c 66 #pragma data_alignment=32
dkato 0:a2445295913c 67 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 0:a2445295913c 68 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 0:a2445295913c 69 #pragma data_alignment=4
dkato 0:a2445295913c 70 #else
dkato 0:a2445295913c 71 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */
dkato 0:a2445295913c 72 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */
dkato 0:a2445295913c 73 #endif
dkato 0:a2445295913c 74 static frame_buffer_t frame_buffer_info;
dkato 0:a2445295913c 75 static volatile int32_t vsync_count = 0;
dkato 0:a2445295913c 76
dkato 0:a2445295913c 77 static const graphics_image_t * hito_tukare[] = {tukare1_File, tukare2_File};
dkato 0:a2445295913c 78 static const graphics_image_t * hito_speed_1[] = {run1_File, run2_File, run3_File, run4_File, run5_File, run6_File, run7_File, run6_File, run5_File, run4_File, run3_File, run2_File};
dkato 0:a2445295913c 79 static const graphics_image_t * hito_speed_2[] = {dash1_File, dash2_File, dash3_File, dash4_File, dash3_File, dash2_File};
dkato 0:a2445295913c 80 static const graphics_image_t * hito_speed_3[] = {sdash1_File, sdash2_File, sdash3_File, sdash2_File};
dkato 0:a2445295913c 81 static const graphics_image_t * comment_tbl[] = {comment3_File, comment4_File, comment5_File};
dkato 0:a2445295913c 82 static const graphics_image_t * ready_set_go_tbl[] = {go_File, start1_File, start2_File, start3_File};
dkato 0:a2445295913c 83 static const graphics_image_t * num_tbl[] = {num_0_File, num_1_File, num_2_File, num_3_File, num_4_File, num_5_File, num_6_File, num_7_File, num_8_File, num_9_File};
dkato 0:a2445295913c 84
dkato 0:a2445295913c 85 static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) {
dkato 0:a2445295913c 86 /* Interrupt callback function for Vsync interruption */
dkato 0:a2445295913c 87 if (vsync_count > 0) {
dkato 0:a2445295913c 88 vsync_count--;
dkato 0:a2445295913c 89 }
dkato 0:a2445295913c 90 }
dkato 0:a2445295913c 91
dkato 0:a2445295913c 92 static void Wait_Vsync(const int32_t wait_count) {
dkato 0:a2445295913c 93 /* Wait for the specified number of times Vsync occurs */
dkato 0:a2445295913c 94 vsync_count = wait_count;
dkato 0:a2445295913c 95 while (vsync_count > 0) {
dkato 0:a2445295913c 96 /* Do nothing */
dkato 0:a2445295913c 97 }
dkato 0:a2445295913c 98 }
dkato 0:a2445295913c 99
dkato 0:a2445295913c 100 static void Init_LCD_Display(void) {
dkato 0:a2445295913c 101 DisplayBase::graphics_error_t error;
dkato 0:a2445295913c 102 DisplayBase::lcd_config_t lcd_config;
dkato 0:a2445295913c 103 PinName lvds_pin[8] = {
dkato 0:a2445295913c 104 /* data pin */
dkato 0:a2445295913c 105 P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
dkato 0:a2445295913c 106 };
dkato 0:a2445295913c 107
dkato 0:a2445295913c 108 lcd_pwon = 0;
dkato 0:a2445295913c 109 lcd_blon = 0;
dkato 0:a2445295913c 110 Thread::wait(100);
dkato 0:a2445295913c 111 lcd_pwon = 1;
dkato 0:a2445295913c 112 lcd_blon = 1;
dkato 0:a2445295913c 113
dkato 0:a2445295913c 114 Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
dkato 0:a2445295913c 115
dkato 0:a2445295913c 116 /* Graphics initialization process */
dkato 0:a2445295913c 117 lcd_config = LcdCfgTbl_LCD_shield;
dkato 0:a2445295913c 118 error = Display.Graphics_init(&lcd_config);
dkato 0:a2445295913c 119 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:a2445295913c 120 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:a2445295913c 121 mbed_die();
dkato 0:a2445295913c 122 }
dkato 0:a2445295913c 123
dkato 0:a2445295913c 124 #if(1) /* When needing LCD Vsync interrupt, please make it effective. */
dkato 0:a2445295913c 125 /* Interrupt callback function setting (Vsync signal output from scaler 0) */
dkato 0:a2445295913c 126 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync);
dkato 0:a2445295913c 127 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:a2445295913c 128 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:a2445295913c 129 mbed_die();
dkato 0:a2445295913c 130 }
dkato 0:a2445295913c 131 #endif
dkato 0:a2445295913c 132 }
dkato 0:a2445295913c 133
dkato 0:a2445295913c 134 static void Start_LCD_Display(uint8_t * p_buf) {
dkato 0:a2445295913c 135 DisplayBase::rect_t rect;
dkato 0:a2445295913c 136
dkato 0:a2445295913c 137 rect.vs = 0;
dkato 0:a2445295913c 138 rect.vw = LCD_PIXEL_HEIGHT;
dkato 0:a2445295913c 139 rect.hs = 0;
dkato 0:a2445295913c 140 rect.hw = LCD_PIXEL_WIDTH;
dkato 0:a2445295913c 141 Display.Graphics_Read_Setting(
dkato 0:a2445295913c 142 DisplayBase::GRAPHICS_LAYER_0,
dkato 0:a2445295913c 143 (void *)p_buf,
dkato 0:a2445295913c 144 FRAME_BUFFER_STRIDE,
dkato 0:a2445295913c 145 GRAPHICS_FORMAT,
dkato 0:a2445295913c 146 WR_RD_WRSWA,
dkato 0:a2445295913c 147 &rect
dkato 0:a2445295913c 148 );
dkato 0:a2445295913c 149 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
dkato 0:a2445295913c 150 }
dkato 0:a2445295913c 151
dkato 0:a2445295913c 152 static void Update_LCD_Display(frame_buffer_t * frmbuf_info) {
dkato 0:a2445295913c 153 Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0,
dkato 0:a2445295913c 154 (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]);
dkato 0:a2445295913c 155 Wait_Vsync(1);
dkato 0:a2445295913c 156 }
dkato 0:a2445295913c 157
dkato 0:a2445295913c 158 static void Swap_FrameBuffer(frame_buffer_t * frmbuf_info) {
dkato 0:a2445295913c 159 if (frmbuf_info->draw_buffer_index == 1) {
dkato 0:a2445295913c 160 frmbuf_info->draw_buffer_index = 0;
dkato 0:a2445295913c 161 } else {
dkato 0:a2445295913c 162 frmbuf_info->draw_buffer_index = 1;
dkato 0:a2445295913c 163 }
dkato 0:a2445295913c 164 }
dkato 0:a2445295913c 165
dkato 0:a2445295913c 166 static void draw_time(int time_num, int pos_x, int pos_y, int disp_flg) {
dkato 0:a2445295913c 167 int wk_num;
dkato 0:a2445295913c 168
dkato 0:a2445295913c 169 wk_num = (time_num / 100) % 10;
dkato 0:a2445295913c 170 if ((wk_num != 0) || (disp_flg != false)) {
dkato 0:a2445295913c 171 canvas2d.drawImage(num_tbl[wk_num], pos_x + 17 * 0, pos_y); /* 400x42 */
dkato 0:a2445295913c 172 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 173 disp_flg = true;
dkato 0:a2445295913c 174 }
dkato 0:a2445295913c 175 wk_num = (time_num / 10) % 10;
dkato 0:a2445295913c 176 if ((wk_num != 0) || (disp_flg != false)) {
dkato 0:a2445295913c 177 canvas2d.drawImage(num_tbl[wk_num], pos_x + 17 * 1, pos_y); /* 400x42 */
dkato 0:a2445295913c 178 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 179 }
dkato 0:a2445295913c 180 wk_num = time_num % 10;
dkato 0:a2445295913c 181 canvas2d.drawImage(num_tbl[wk_num], pos_x + 17 * 2, pos_y); /* 400x42 */
dkato 0:a2445295913c 182 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 183 }
dkato 0:a2445295913c 184
dkato 0:a2445295913c 185 static void draw_total_time(int time_ms, int x, int y) {
dkato 0:a2445295913c 186 int wk_time_sec = time_ms / 1000; /* sec */
dkato 0:a2445295913c 187 int wk_time_ms = time_ms % 1000; /* ms */
dkato 0:a2445295913c 188
dkato 0:a2445295913c 189 if (wk_time_sec > 999) {
dkato 0:a2445295913c 190 wk_time_sec = 999;
dkato 0:a2445295913c 191 wk_time_ms = 999;
dkato 0:a2445295913c 192 }
dkato 0:a2445295913c 193 draw_time(wk_time_sec, x, y, false);
dkato 0:a2445295913c 194 draw_time(wk_time_ms, x + 61, y, true);
dkato 0:a2445295913c 195 }
dkato 0:a2445295913c 196
dkato 0:a2445295913c 197 static void touch_int_callback(void) {
dkato 0:a2445295913c 198 sem_touch_int.release();
dkato 0:a2445295913c 199 }
dkato 0:a2445295913c 200
dkato 0:a2445295913c 201 void touch_task(void const *) {
dkato 0:a2445295913c 202 TouchKey::touch_pos_t touch_pos;
dkato 0:a2445295913c 203 int touch_num = 0;
dkato 0:a2445295913c 204 int touch_num_last = 0;
dkato 0:a2445295913c 205 int move_x = 0;
dkato 0:a2445295913c 206 uint32_t last_x = 0;
dkato 0:a2445295913c 207
dkato 0:a2445295913c 208 /* Callback setting */
dkato 0:a2445295913c 209 touch.SetCallback(&touch_int_callback);
dkato 0:a2445295913c 210
dkato 0:a2445295913c 211 /* Reset touch IC */
dkato 0:a2445295913c 212 touch.Reset();
dkato 0:a2445295913c 213
dkato 0:a2445295913c 214 while (1) {
dkato 0:a2445295913c 215 /* Wait touch event */
dkato 0:a2445295913c 216 sem_touch_int.wait();
dkato 0:a2445295913c 217
dkato 0:a2445295913c 218 /* Get touch coordinates */
dkato 0:a2445295913c 219 touch_num = touch.GetCoordinates(1, &touch_pos);
dkato 0:a2445295913c 220
dkato 0:a2445295913c 221 if (touch_num != 0) {
dkato 0:a2445295913c 222 if (touch_num_last == 0) {
dkato 0:a2445295913c 223 /* key On */
dkato 0:a2445295913c 224 } else {
dkato 0:a2445295913c 225 /* Move */
dkato 0:a2445295913c 226 if (touch_start) {
dkato 0:a2445295913c 227 move_x = (int)touch_pos.x - (int)last_x;
dkato 0:a2445295913c 228 if (move_x > 0) {
dkato 0:a2445295913c 229 total_move_x += move_x;
dkato 0:a2445295913c 230 }
dkato 0:a2445295913c 231 }
dkato 0:a2445295913c 232 }
dkato 0:a2445295913c 233 } else {
dkato 0:a2445295913c 234 /* key Off */
dkato 0:a2445295913c 235 touch_click = true;
dkato 0:a2445295913c 236 }
dkato 0:a2445295913c 237
dkato 0:a2445295913c 238 touch_num_last = touch_num;
dkato 0:a2445295913c 239 last_x = touch_pos.x;
dkato 0:a2445295913c 240 }
dkato 0:a2445295913c 241 }
dkato 0:a2445295913c 242
dkato 0:a2445295913c 243 static void display_func(frame_buffer_t* frmbuf_info) {
dkato 0:a2445295913c 244 int wk_osf;
dkato 0:a2445295913c 245 int wk_pos;
dkato 0:a2445295913c 246
dkato 0:a2445295913c 247 Swap_FrameBuffer(frmbuf_info);
dkato 0:a2445295913c 248
dkato 0:a2445295913c 249 /* Clear */
dkato 0:a2445295913c 250 canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:a2445295913c 251
dkato 0:a2445295913c 252 /* Distant background */
dkato 0:a2445295913c 253 wk_osf = ((disp_info.now_pos / 8) % 1000) + LCD_PIXEL_WIDTH - 1000;
dkato 0:a2445295913c 254 canvas2d.globalAlpha = 0.6f;
dkato 0:a2445295913c 255 if (wk_osf > 0) {
dkato 0:a2445295913c 256 canvas2d.drawImage(haikei_File, -1000 + wk_osf, 40); /* 1000x173 */
dkato 0:a2445295913c 257 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 258 }
dkato 0:a2445295913c 259 canvas2d.drawImage(haikei_File, wk_osf, 40);
dkato 0:a2445295913c 260 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 261
dkato 0:a2445295913c 262 /* Nearby background */
dkato 0:a2445295913c 263 wk_osf = ((disp_info.now_pos / 2) % 500) + LCD_PIXEL_WIDTH - 500;
dkato 0:a2445295913c 264 canvas2d.globalAlpha = 1.0f;
dkato 0:a2445295913c 265 if (wk_osf > 0) {
dkato 0:a2445295913c 266 canvas2d.drawImage(haikei_temae_File, -500 + wk_osf, 91); /* 500x130 */
dkato 0:a2445295913c 267 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 268 }
dkato 0:a2445295913c 269 canvas2d.drawImage(haikei_temae_File, wk_osf, 91); /* 500x130 */
dkato 0:a2445295913c 270 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 271
dkato 0:a2445295913c 272 /* Progress */
dkato 0:a2445295913c 273 canvas2d.globalAlpha = 1.0f;
dkato 0:a2445295913c 274 canvas2d.drawImage(logo_goal_File, 10, 5); /* 23x20 */
dkato 0:a2445295913c 275 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 276 canvas2d.drawImage(logo_start_File, LCD_PIXEL_WIDTH - 23 - 10, 5); /* 23x20 */
dkato 0:a2445295913c 277 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 278
dkato 0:a2445295913c 279 wk_pos = disp_info.now_pos;
dkato 0:a2445295913c 280
dkato 0:a2445295913c 281 if (wk_pos > GOAL_POINT) {
dkato 0:a2445295913c 282 wk_pos = GOAL_POINT;
dkato 0:a2445295913c 283 }
dkato 0:a2445295913c 284 canvas2d.drawImage(logo_genzai_File,
dkato 0:a2445295913c 285 (int)(((float_t)LCD_PIXEL_WIDTH - 75) * ((float_t)(GOAL_POINT - wk_pos) / GOAL_POINT) + 26), 5);
dkato 0:a2445295913c 286 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 287
dkato 0:a2445295913c 288 /* Human */
dkato 0:a2445295913c 289 if (disp_info.p_hito != NULL) {
dkato 0:a2445295913c 290 canvas2d.globalAlpha = 1.0f;
dkato 0:a2445295913c 291 canvas2d.drawImage(disp_info.p_hito, (LCD_PIXEL_WIDTH - 143) / 2 + disp_info.hito_ofs, LCD_PIXEL_HEIGHT - 210);
dkato 0:a2445295913c 292 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 293 }
dkato 0:a2445295913c 294
dkato 0:a2445295913c 295 /* Serif */
dkato 0:a2445295913c 296 canvas2d.globalAlpha = 1.0f;
dkato 0:a2445295913c 297 if (disp_info.tutorial) {
dkato 0:a2445295913c 298 canvas2d.drawImage(comment1_File, 43, 50);
dkato 0:a2445295913c 299 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 300 canvas2d.drawImage(comment2_File, 275, 50);
dkato 0:a2445295913c 301 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 302 }
dkato 0:a2445295913c 303 if (disp_info.comment_no != NO_IMAGE) {
dkato 0:a2445295913c 304 canvas2d.drawImage(comment_tbl[disp_info.comment_no], 265, 50);
dkato 0:a2445295913c 305 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 306 }
dkato 0:a2445295913c 307
dkato 0:a2445295913c 308 /* Swipe */
dkato 0:a2445295913c 309 if (disp_info.swipe_on) {
dkato 0:a2445295913c 310 canvas2d.globalAlpha = 0.9f;
dkato 0:a2445295913c 311 canvas2d.drawImage(swipe_File, disp_info.tutorial_seq * 6, (LCD_PIXEL_HEIGHT / 2) - 10);
dkato 0:a2445295913c 312 disp_info.tutorial_seq++;
dkato 0:a2445295913c 313 if ((disp_info.tutorial_seq * 6) >= LCD_PIXEL_WIDTH) {
dkato 0:a2445295913c 314 disp_info.tutorial_seq = 0;
dkato 0:a2445295913c 315 }
dkato 0:a2445295913c 316 }
dkato 0:a2445295913c 317
dkato 0:a2445295913c 318 /* Ready Set Go! */
dkato 0:a2445295913c 319 if (disp_info.ready_set_go != NO_IMAGE) {
dkato 0:a2445295913c 320 canvas2d.globalAlpha = 0.82f;
dkato 0:a2445295913c 321 canvas2d.drawImage(ready_set_go_tbl[disp_info.ready_set_go], (LCD_PIXEL_WIDTH - 100) / 2,
dkato 0:a2445295913c 322 (LCD_PIXEL_HEIGHT - 100) / 2);
dkato 0:a2445295913c 323 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 324 }
dkato 0:a2445295913c 325
dkato 0:a2445295913c 326 /* Goooal! */
dkato 0:a2445295913c 327 if (disp_info.goal_on) {
dkato 0:a2445295913c 328 canvas2d.globalAlpha = (0.04f * disp_info.goal_seq);
dkato 0:a2445295913c 329 canvas2d.drawImage(goooal_File,
dkato 0:a2445295913c 330 (LCD_PIXEL_WIDTH - 260 * (2.0 - (float_t)disp_info.goal_seq / 25)) / 2,
dkato 0:a2445295913c 331 (LCD_PIXEL_HEIGHT - 53 * (2.0 - (float_t)disp_info.goal_seq / 25)) / 2,
dkato 0:a2445295913c 332 260 * (2.0 - (float_t)disp_info.goal_seq / 25),
dkato 0:a2445295913c 333 53 * (2.0 - (float_t)disp_info.goal_seq / 25)); /* 260x53 */
dkato 0:a2445295913c 334 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 335 }
dkato 0:a2445295913c 336
dkato 0:a2445295913c 337 /* Result */
dkato 0:a2445295913c 338 if (disp_info.result_on) {
dkato 0:a2445295913c 339 /* record */
dkato 0:a2445295913c 340 canvas2d.globalAlpha = (0.025f * disp_info.result_seq);
dkato 0:a2445295913c 341 canvas2d.drawImage(result_File, (LCD_PIXEL_WIDTH - 400) / 2,
dkato 0:a2445295913c 342 LCD_PIXEL_HEIGHT / 2 + 32 - disp_info.result_seq); /* 400x68 */
dkato 0:a2445295913c 343 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 344 draw_total_time(disp_info.total_time, (LCD_PIXEL_WIDTH / 2 - 200 + 185),
dkato 0:a2445295913c 345 (LCD_PIXEL_HEIGHT / 2 + 9) + 32 - disp_info.result_seq);
dkato 0:a2445295913c 346 draw_time(disp_info.max_speed, (LCD_PIXEL_WIDTH / 2 - 200 + 185 + 34),
dkato 0:a2445295913c 347 (LCD_PIXEL_HEIGHT / 2 + 20 + 9) + 32 - disp_info.result_seq, false);
dkato 0:a2445295913c 348 }
dkato 0:a2445295913c 349
dkato 0:a2445295913c 350 /* 1st record */
dkato 0:a2445295913c 351 if (disp_info.first_record) {
dkato 0:a2445295913c 352 canvas2d.drawImage(record_1st_File, 145, 201);
dkato 0:a2445295913c 353 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 354 draw_total_time(disp_info.record_time, 145 + 20, 201);
dkato 0:a2445295913c 355 canvas2d.drawImage(dot_File, 145 + 20 + 52, 201 + 11); /* . */
dkato 0:a2445295913c 356 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 357 canvas2d.drawImage(sec_File, 145 + 20 + 115, 201); /* sec */
dkato 0:a2445295913c 358 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 359 }
dkato 0:a2445295913c 360
dkato 0:a2445295913c 361 /* New Record */
dkato 0:a2445295913c 362 if (disp_info.new_record) {
dkato 0:a2445295913c 363 canvas2d.globalAlpha = 1.0f;
dkato 0:a2445295913c 364 canvas2d.drawImage(new_record_File, (LCD_PIXEL_WIDTH - 194) / 2, 20);
dkato 0:a2445295913c 365 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 366 }
dkato 0:a2445295913c 367
dkato 0:a2445295913c 368 /* Star */
dkato 0:a2445295913c 369 if (disp_info.hosi) {
dkato 0:a2445295913c 370 int wk_seq;
dkato 0:a2445295913c 371
dkato 0:a2445295913c 372 if (disp_info.hosi_seq < 25) {
dkato 0:a2445295913c 373 wk_seq = disp_info.hosi_seq;
dkato 0:a2445295913c 374 canvas2d.globalAlpha = 1.0f - (0.04f * wk_seq);
dkato 0:a2445295913c 375 canvas2d.drawImage(hosi_File, 300, 60);
dkato 0:a2445295913c 376 } else if (disp_info.hosi_seq < 50) {
dkato 0:a2445295913c 377 wk_seq = disp_info.hosi_seq - 25;
dkato 0:a2445295913c 378 canvas2d.globalAlpha = 1.0f - (0.04f * wk_seq);
dkato 0:a2445295913c 379 canvas2d.drawImage(hosi_File, 70, 100);
dkato 0:a2445295913c 380 } else {
dkato 0:a2445295913c 381 wk_seq = disp_info.hosi_seq - 50;
dkato 0:a2445295913c 382 canvas2d.globalAlpha = 1.0f - (0.04f * wk_seq);
dkato 0:a2445295913c 383 canvas2d.drawImage(hosi_File, 270, 170);
dkato 0:a2445295913c 384 }
dkato 0:a2445295913c 385 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 386 disp_info.hosi_seq++;
dkato 0:a2445295913c 387 if (disp_info.hosi_seq >= 75) {
dkato 0:a2445295913c 388 disp_info.hosi_seq = 0;
dkato 0:a2445295913c 389 }
dkato 0:a2445295913c 390 }
dkato 0:a2445295913c 391
dkato 0:a2445295913c 392 /* Speed and Time */
dkato 0:a2445295913c 393 if (disp_info.time_and_speed) {
dkato 0:a2445295913c 394 int wk_ofs;
dkato 0:a2445295913c 395
dkato 0:a2445295913c 396 canvas2d.globalAlpha = 1.0f;
dkato 0:a2445295913c 397
dkato 0:a2445295913c 398 /* Speed */
dkato 0:a2445295913c 399 if (disp_info.speed >= 100) {
dkato 0:a2445295913c 400 wk_ofs = 10;
dkato 0:a2445295913c 401 } else if (disp_info.speed >= 10) {
dkato 0:a2445295913c 402 wk_ofs = 10 - 17;
dkato 0:a2445295913c 403 } else {
dkato 0:a2445295913c 404 wk_ofs = 10 - 17 - 17;
dkato 0:a2445295913c 405 }
dkato 0:a2445295913c 406 draw_time(disp_info.speed, wk_ofs, LCD_PIXEL_HEIGHT - 19 - 5, false);
dkato 0:a2445295913c 407 /* Time */
dkato 0:a2445295913c 408 draw_total_time(stop_watch.read_ms(), LCD_PIXEL_WIDTH - 112 - 5, LCD_PIXEL_HEIGHT - 19 - 5);
dkato 0:a2445295913c 409 canvas2d.drawImage(dot_File, LCD_PIXEL_WIDTH - 112 - 5 + 52, LCD_PIXEL_HEIGHT - 19 - 5 + 11); /* . */
dkato 0:a2445295913c 410 R_OSPL_CLEAR_ERROR();
dkato 0:a2445295913c 411 }
dkato 0:a2445295913c 412
dkato 0:a2445295913c 413 /* Complete drawing */
dkato 0:a2445295913c 414 R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
dkato 0:a2445295913c 415 Update_LCD_Display(frmbuf_info);
dkato 0:a2445295913c 416 }
dkato 0:a2445295913c 417
dkato 0:a2445295913c 418 static void set_hito_pic(void) {
dkato 0:a2445295913c 419 int new_table_no = 0;
dkato 0:a2445295913c 420 int bonus;
dkato 0:a2445295913c 421 float_t bonu_rate;
dkato 0:a2445295913c 422
dkato 0:a2445295913c 423 disp_info.speed = total_move_x / 50;
dkato 0:a2445295913c 424 bonu_rate = ((float_t)disp_info.speed / 100.00);
dkato 0:a2445295913c 425 if (bonu_rate > 0.70) {
dkato 0:a2445295913c 426 bonu_rate = 0.70;
dkato 0:a2445295913c 427 }
dkato 0:a2445295913c 428 bonus = (int)((float_t)disp_info.speed * bonu_rate);
dkato 0:a2445295913c 429
dkato 0:a2445295913c 430 if (disp_info.speed > disp_info.max_speed) {
dkato 0:a2445295913c 431 disp_info.max_speed = disp_info.speed;
dkato 0:a2445295913c 432 }
dkato 0:a2445295913c 433
dkato 0:a2445295913c 434 if (disp_info.speed >= 50) {
dkato 0:a2445295913c 435 disp_info.comment_no = NO_IMAGE;
dkato 0:a2445295913c 436 new_table_no = 3;
dkato 0:a2445295913c 437 } else if (disp_info.speed >= 30) {
dkato 0:a2445295913c 438 tukare = 8;
dkato 0:a2445295913c 439 if ((race_start != false) && (disp_info.comment_no == 1)) {
dkato 0:a2445295913c 440 disp_info.comment_no = 2;
dkato 0:a2445295913c 441 }
dkato 0:a2445295913c 442 new_table_no = 2;
dkato 0:a2445295913c 443 } else if (disp_info.speed >= 1) {
dkato 0:a2445295913c 444 if ((race_start != false) && (disp_info.comment_no == 0)) {
dkato 0:a2445295913c 445 disp_info.comment_no = 1;
dkato 0:a2445295913c 446 }
dkato 0:a2445295913c 447 new_table_no = 1;
dkato 0:a2445295913c 448 } else {
dkato 0:a2445295913c 449 if (race_start != false) {
dkato 0:a2445295913c 450 disp_info.comment_no = 0;
dkato 0:a2445295913c 451 }
dkato 0:a2445295913c 452 new_table_no = 0;
dkato 0:a2445295913c 453 }
dkato 0:a2445295913c 454
dkato 0:a2445295913c 455 if (new_table_no != table_no) {
dkato 0:a2445295913c 456 table_no = new_table_no;
dkato 0:a2445295913c 457 pic_idx = 0;
dkato 0:a2445295913c 458 }
dkato 0:a2445295913c 459
dkato 0:a2445295913c 460 if (wk_wait == 0) {
dkato 0:a2445295913c 461 switch (table_no) {
dkato 0:a2445295913c 462 case 0:
dkato 0:a2445295913c 463 if (tukare > 0) {
dkato 0:a2445295913c 464 tukare--;
dkato 0:a2445295913c 465 disp_info.p_hito = hito_tukare[pic_idx++];
dkato 0:a2445295913c 466 if (pic_idx >= (sizeof(hito_tukare) / sizeof(graphics_image_t *))) {
dkato 0:a2445295913c 467 pic_idx = 0;
dkato 0:a2445295913c 468 }
dkato 0:a2445295913c 469 wk_wait = 20;
dkato 0:a2445295913c 470 } else {
dkato 0:a2445295913c 471 disp_info.p_hito = start_File;
dkato 0:a2445295913c 472 pic_idx = 0;
dkato 0:a2445295913c 473 wk_wait = 3;
dkato 0:a2445295913c 474 }
dkato 0:a2445295913c 475 break;
dkato 0:a2445295913c 476 case 1:
dkato 0:a2445295913c 477 disp_info.p_hito = hito_speed_1[pic_idx++];
dkato 0:a2445295913c 478 if (pic_idx >= (sizeof(hito_speed_1) / sizeof(graphics_image_t *))) {
dkato 0:a2445295913c 479 pic_idx = 0;
dkato 0:a2445295913c 480 }
dkato 0:a2445295913c 481 if (disp_info.speed <= 1) {
dkato 0:a2445295913c 482 wk_wait = 6;
dkato 0:a2445295913c 483 } else if (disp_info.speed <= 3) {
dkato 0:a2445295913c 484 wk_wait = 5;
dkato 0:a2445295913c 485 } else if (disp_info.speed <= 6) {
dkato 0:a2445295913c 486 wk_wait = 4;
dkato 0:a2445295913c 487 } else if (disp_info.speed <= 12) {
dkato 0:a2445295913c 488 wk_wait = 3;
dkato 0:a2445295913c 489 } else if (disp_info.speed <= 20) {
dkato 0:a2445295913c 490 wk_wait = 2;
dkato 0:a2445295913c 491 } else {
dkato 0:a2445295913c 492 wk_wait = 1;
dkato 0:a2445295913c 493 }
dkato 0:a2445295913c 494 break;
dkato 0:a2445295913c 495 case 2:
dkato 0:a2445295913c 496 disp_info.p_hito = hito_speed_2[pic_idx++];
dkato 0:a2445295913c 497 if (pic_idx >= (sizeof(hito_speed_2) / sizeof(graphics_image_t *))) {
dkato 0:a2445295913c 498 pic_idx = 0;
dkato 0:a2445295913c 499 }
dkato 0:a2445295913c 500 if (disp_info.speed <= 40) {
dkato 0:a2445295913c 501 wk_wait = 1;
dkato 0:a2445295913c 502 } else {
dkato 0:a2445295913c 503 wk_wait = 0;
dkato 0:a2445295913c 504 }
dkato 0:a2445295913c 505 break;
dkato 0:a2445295913c 506 case 3:
dkato 0:a2445295913c 507 disp_info.p_hito = hito_speed_3[pic_idx++];
dkato 0:a2445295913c 508 if (pic_idx >= (sizeof(hito_speed_3) / sizeof(graphics_image_t *))) {
dkato 0:a2445295913c 509 pic_idx = 0;
dkato 0:a2445295913c 510 }
dkato 0:a2445295913c 511 wk_wait = 0;
dkato 0:a2445295913c 512 break;
dkato 0:a2445295913c 513 default:
dkato 0:a2445295913c 514 break;
dkato 0:a2445295913c 515 }
dkato 0:a2445295913c 516 } else {
dkato 0:a2445295913c 517 wk_wait--;
dkato 0:a2445295913c 518 }
dkato 0:a2445295913c 519
dkato 0:a2445295913c 520 disp_info.now_pos += disp_info.speed;
dkato 0:a2445295913c 521 if (disp_info.now_pos > GOAL_POINT) {
dkato 0:a2445295913c 522 disp_info.now_pos = GOAL_POINT;
dkato 0:a2445295913c 523 }
dkato 0:a2445295913c 524 total_move_x -= (disp_info.speed - bonus);
dkato 0:a2445295913c 525 }
dkato 0:a2445295913c 526
dkato 0:a2445295913c 527 int main(void) {
dkato 0:a2445295913c 528 errnum_t err;
dkato 0:a2445295913c 529 Canvas2D_ContextConfigClass config;
dkato 0:a2445295913c 530
dkato 0:a2445295913c 531 /* Change the baud rate of the printf() */
dkato 0:a2445295913c 532 pc.baud(921600);
dkato 0:a2445295913c 533
dkato 0:a2445295913c 534 /* Initialization of LCD */
dkato 0:a2445295913c 535 Init_LCD_Display();
dkato 0:a2445295913c 536
dkato 0:a2445295913c 537 memset(user_frame_buffer1, 0, sizeof(user_frame_buffer1));
dkato 0:a2445295913c 538 memset(user_frame_buffer2, 0, sizeof(user_frame_buffer2));
dkato 0:a2445295913c 539 frame_buffer_info.buffer_address[0] = user_frame_buffer1;
dkato 0:a2445295913c 540 frame_buffer_info.buffer_address[1] = user_frame_buffer2;
dkato 0:a2445295913c 541 frame_buffer_info.buffer_count = 2;
dkato 0:a2445295913c 542 frame_buffer_info.show_buffer_index = 0;
dkato 0:a2445295913c 543 frame_buffer_info.draw_buffer_index = 0;
dkato 0:a2445295913c 544 frame_buffer_info.width = LCD_PIXEL_WIDTH;
dkato 0:a2445295913c 545 frame_buffer_info.byte_per_pixel = FRAME_BUFFER_BYTE_PER_PIXEL;
dkato 0:a2445295913c 546 frame_buffer_info.stride = LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL;
dkato 0:a2445295913c 547 frame_buffer_info.height = LCD_PIXEL_HEIGHT;
dkato 0:a2445295913c 548 frame_buffer_info.pixel_format = PIXEL_FORMAT_RGB565;
dkato 0:a2445295913c 549
dkato 0:a2445295913c 550 config.frame_buffer = &frame_buffer_info;
dkato 0:a2445295913c 551 canvas2d = R_RGA_New_Canvas2D_ContextClass(config);
dkato 0:a2445295913c 552 err = R_OSPL_GetErrNum();
dkato 0:a2445295913c 553 if (err != 0) {
dkato 0:a2445295913c 554 printf("Line %d, error %d\n", __LINE__, err);
dkato 0:a2445295913c 555 mbed_die();
dkato 0:a2445295913c 556 }
dkato 0:a2445295913c 557
dkato 0:a2445295913c 558 /* Start of LCD */
dkato 0:a2445295913c 559 Start_LCD_Display(frame_buffer_info.buffer_address[0]);
dkato 0:a2445295913c 560
dkato 0:a2445295913c 561 /* Backlight on */
dkato 0:a2445295913c 562 Thread::wait(200);
dkato 0:a2445295913c 563 lcd_cntrst.write(1.0);
dkato 0:a2445295913c 564
dkato 0:a2445295913c 565 Thread touchTask(touch_task, NULL, osPriorityNormal, 1024 * 2);
dkato 0:a2445295913c 566 Timer system_timer;
dkato 0:a2445295913c 567
dkato 0:a2445295913c 568 disp_info.tutorial = true;
dkato 0:a2445295913c 569 disp_info.record_time = 15000;
dkato 0:a2445295913c 570 stop_watch.reset();
dkato 0:a2445295913c 571 system_timer.reset();
dkato 0:a2445295913c 572
dkato 0:a2445295913c 573 while (1) {
dkato 0:a2445295913c 574 if (disp_info.tutorial) {
dkato 0:a2445295913c 575 touch_start = false;
dkato 0:a2445295913c 576 stop_watch.reset();
dkato 0:a2445295913c 577 stop_watch.stop();
dkato 0:a2445295913c 578 disp_info.speed = 0;
dkato 0:a2445295913c 579 disp_info.ready_set_go = NO_IMAGE;
dkato 0:a2445295913c 580 disp_info.now_pos = 0;
dkato 0:a2445295913c 581 disp_info.comment_no = NO_IMAGE;
dkato 0:a2445295913c 582 disp_info.p_hito = start_File;
dkato 0:a2445295913c 583 disp_info.hito_ofs = 0;
dkato 0:a2445295913c 584 disp_info.max_speed = 0;
dkato 0:a2445295913c 585 disp_info.swipe_on = false;
dkato 0:a2445295913c 586 disp_info.goal_on = false;
dkato 0:a2445295913c 587 disp_info.result_on = false;
dkato 0:a2445295913c 588 disp_info.new_record = false;
dkato 0:a2445295913c 589 disp_info.hosi = false;
dkato 0:a2445295913c 590 disp_info.first_record = true;
dkato 0:a2445295913c 591 disp_info.time_and_speed = false;
dkato 0:a2445295913c 592 disp_info.total_time = 0;
dkato 0:a2445295913c 593 disp_info.swipe_on = true;
dkato 0:a2445295913c 594 disp_info.tutorial_seq = 0;
dkato 0:a2445295913c 595 total_move_x = 0;
dkato 0:a2445295913c 596 race_start = false;
dkato 0:a2445295913c 597 pic_idx = 0;
dkato 0:a2445295913c 598 wk_wait = 0;
dkato 0:a2445295913c 599 tukare = 0;
dkato 0:a2445295913c 600 touch_click = false;
dkato 0:a2445295913c 601 while (touch_click == false) {
dkato 0:a2445295913c 602 display_func(&frame_buffer_info);
dkato 0:a2445295913c 603 }
dkato 0:a2445295913c 604 disp_info.swipe_on = false;
dkato 0:a2445295913c 605 disp_info.tutorial = false;
dkato 0:a2445295913c 606
dkato 0:a2445295913c 607 /* Ready Go! */
dkato 0:a2445295913c 608 system_timer.reset();
dkato 0:a2445295913c 609 system_timer.start();
dkato 0:a2445295913c 610 disp_info.time_and_speed = true;
dkato 0:a2445295913c 611 disp_info.first_record = false;
dkato 0:a2445295913c 612 disp_info.ready_set_go = 3;
dkato 0:a2445295913c 613 disp_info.now_pos = 0;
dkato 0:a2445295913c 614 disp_info.speed = 0;
dkato 0:a2445295913c 615 total_move_x = 0;
dkato 0:a2445295913c 616 pic_idx = 0;
dkato 0:a2445295913c 617 table_no = 0;
dkato 0:a2445295913c 618 }
dkato 0:a2445295913c 619
dkato 0:a2445295913c 620 if (disp_info.ready_set_go != NO_IMAGE) {
dkato 0:a2445295913c 621 int wk_system_time = system_timer.read_ms();
dkato 0:a2445295913c 622 if (wk_system_time > 4000) {
dkato 0:a2445295913c 623 disp_info.ready_set_go = NO_IMAGE;
dkato 0:a2445295913c 624 if (disp_info.now_pos == 0) {
dkato 0:a2445295913c 625 disp_info.swipe_on = true;
dkato 0:a2445295913c 626 disp_info.tutorial_seq = 0;
dkato 0:a2445295913c 627 }
dkato 0:a2445295913c 628 } else if (wk_system_time > 3000) {
dkato 0:a2445295913c 629 if (disp_info.ready_set_go != 0) {
dkato 0:a2445295913c 630 disp_info.ready_set_go = 0;
dkato 0:a2445295913c 631 touch_start = true;
dkato 0:a2445295913c 632 race_start = true;
dkato 0:a2445295913c 633 stop_watch.start();
dkato 0:a2445295913c 634 disp_info.comment_no = 0;
dkato 0:a2445295913c 635 }
dkato 0:a2445295913c 636 } else if (wk_system_time > 2000) {
dkato 0:a2445295913c 637 disp_info.ready_set_go = 1;
dkato 0:a2445295913c 638 } else if (wk_system_time > 1000) {
dkato 0:a2445295913c 639 disp_info.ready_set_go = 2;
dkato 0:a2445295913c 640 } else {
dkato 0:a2445295913c 641 /* do nothing */
dkato 0:a2445295913c 642 }
dkato 0:a2445295913c 643 }
dkato 0:a2445295913c 644 if (disp_info.now_pos != 0) {
dkato 0:a2445295913c 645 disp_info.swipe_on = false;
dkato 0:a2445295913c 646 }
dkato 0:a2445295913c 647
dkato 0:a2445295913c 648 set_hito_pic();
dkato 0:a2445295913c 649 display_func(&frame_buffer_info);
dkato 0:a2445295913c 650
dkato 0:a2445295913c 651 disp_info.total_time = stop_watch.read_ms();
dkato 0:a2445295913c 652 if ((disp_info.total_time > 35000) && (disp_info.speed == 0)) {
dkato 0:a2445295913c 653 disp_info.tutorial = true;
dkato 0:a2445295913c 654 }
dkato 0:a2445295913c 655 if (disp_info.now_pos >= GOAL_POINT) {
dkato 0:a2445295913c 656 int over_run = 0;
dkato 0:a2445295913c 657 int wk_ofs;
dkato 0:a2445295913c 658 int back_speed;
dkato 0:a2445295913c 659 int i;
dkato 0:a2445295913c 660
dkato 0:a2445295913c 661 stop_watch.stop();
dkato 0:a2445295913c 662 race_start = false;
dkato 0:a2445295913c 663 disp_info.comment_no = NO_IMAGE;
dkato 0:a2445295913c 664
dkato 0:a2445295913c 665 /* Through the goal */
dkato 0:a2445295913c 666 disp_info.goal_on = true;
dkato 0:a2445295913c 667 disp_info.goal_seq = 0;
dkato 0:a2445295913c 668
dkato 0:a2445295913c 669 system_timer.reset();
dkato 0:a2445295913c 670 system_timer.start();
dkato 0:a2445295913c 671
dkato 0:a2445295913c 672 while (system_timer.read_ms() < 1500) {
dkato 0:a2445295913c 673 total_move_x = total_move_x * 0.9;
dkato 0:a2445295913c 674 set_hito_pic();
dkato 0:a2445295913c 675 disp_info.comment_no = NO_IMAGE;
dkato 0:a2445295913c 676 disp_info.hito_ofs -= disp_info.speed;
dkato 0:a2445295913c 677 over_run += disp_info.speed;
dkato 0:a2445295913c 678 display_func(&frame_buffer_info);
dkato 0:a2445295913c 679 if (disp_info.goal_seq < 25) {
dkato 0:a2445295913c 680 disp_info.goal_seq++;
dkato 0:a2445295913c 681 }
dkato 0:a2445295913c 682 }
dkato 0:a2445295913c 683
dkato 0:a2445295913c 684 /* Catch up background */
dkato 0:a2445295913c 685 disp_info.time_and_speed = false;
dkato 0:a2445295913c 686 back_speed = over_run / 60 + 1;
dkato 0:a2445295913c 687
dkato 0:a2445295913c 688 for (i = 0; i < 60; i++) {
dkato 0:a2445295913c 689 if (over_run > back_speed) {
dkato 0:a2445295913c 690 wk_ofs = back_speed;
dkato 0:a2445295913c 691 if (wk_wait == 0) {
dkato 0:a2445295913c 692 disp_info.p_hito = hito_tukare[pic_idx++];
dkato 0:a2445295913c 693 if (pic_idx >= (sizeof(hito_tukare) / sizeof(graphics_image_t *))) {
dkato 0:a2445295913c 694 pic_idx = 0;
dkato 0:a2445295913c 695 }
dkato 0:a2445295913c 696 wk_wait = 20;
dkato 0:a2445295913c 697 } else {
dkato 0:a2445295913c 698 wk_wait--;
dkato 0:a2445295913c 699 }
dkato 0:a2445295913c 700 } else {
dkato 0:a2445295913c 701 wk_ofs = over_run;
dkato 0:a2445295913c 702 disp_info.p_hito = goal_File;
dkato 0:a2445295913c 703 }
dkato 0:a2445295913c 704 if (over_run != 0) {
dkato 0:a2445295913c 705 over_run -= wk_ofs;
dkato 0:a2445295913c 706 disp_info.now_pos += wk_ofs;
dkato 0:a2445295913c 707 disp_info.hito_ofs += wk_ofs;
dkato 0:a2445295913c 708 }
dkato 0:a2445295913c 709 display_func(&frame_buffer_info);
dkato 0:a2445295913c 710 if (disp_info.goal_seq > 1) {
dkato 0:a2445295913c 711 disp_info.goal_seq--;
dkato 0:a2445295913c 712 } else {
dkato 0:a2445295913c 713 disp_info.goal_on = false;
dkato 0:a2445295913c 714 }
dkato 0:a2445295913c 715 }
dkato 0:a2445295913c 716
dkato 0:a2445295913c 717 disp_info.result_on = true;
dkato 0:a2445295913c 718 disp_info.first_record = true;
dkato 0:a2445295913c 719 for (disp_info.result_seq = 1; disp_info.result_seq < 40; disp_info.result_seq++) {
dkato 0:a2445295913c 720 display_func(&frame_buffer_info);
dkato 0:a2445295913c 721 }
dkato 0:a2445295913c 722
dkato 0:a2445295913c 723 if (disp_info.total_time < disp_info.record_time) {
dkato 0:a2445295913c 724 disp_info.record_time = disp_info.total_time;
dkato 0:a2445295913c 725 disp_info.new_record = true;
dkato 0:a2445295913c 726 disp_info.hosi = true;
dkato 0:a2445295913c 727 disp_info.hosi_seq = 0;
dkato 0:a2445295913c 728 touch_click = false;
dkato 0:a2445295913c 729 }
dkato 0:a2445295913c 730
dkato 0:a2445295913c 731 touch_click = false;
dkato 0:a2445295913c 732 while (touch_click == false) {
dkato 0:a2445295913c 733 display_func(&frame_buffer_info);
dkato 0:a2445295913c 734 }
dkato 0:a2445295913c 735 disp_info.tutorial = true;
dkato 0:a2445295913c 736 }
dkato 0:a2445295913c 737 }
dkato 0:a2445295913c 738 }