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:
Fri Nov 25 03:53:25 2016 +0000
Revision:
4:ee278c441f98
Parent:
2:9c5f0045c9df
Fixed memory allocation when using IAR compiler.

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