Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
middleware-emwin/Sample/Application/Bounce.c@5:f62a9e4a499a, 2021-11-13 (annotated)
- Committer:
- reedas
- Date:
- Sat Nov 13 12:02:49 2021 +0000
- Revision:
- 5:f62a9e4a499a
trying to include mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
reedas | 5:f62a9e4a499a | 1 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 2 | * SEGGER Microcontroller GmbH * |
reedas | 5:f62a9e4a499a | 3 | * Solutions for real time microcontroller applications * |
reedas | 5:f62a9e4a499a | 4 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 5 | * * |
reedas | 5:f62a9e4a499a | 6 | * (c) 1996 - 2018 SEGGER Microcontroller GmbH * |
reedas | 5:f62a9e4a499a | 7 | * * |
reedas | 5:f62a9e4a499a | 8 | * Internet: www.segger.com Support: support@segger.com * |
reedas | 5:f62a9e4a499a | 9 | * * |
reedas | 5:f62a9e4a499a | 10 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 11 | |
reedas | 5:f62a9e4a499a | 12 | ** emWin V5.48 - Graphical user interface for embedded applications ** |
reedas | 5:f62a9e4a499a | 13 | All Intellectual Property rights in the Software belongs to SEGGER. |
reedas | 5:f62a9e4a499a | 14 | emWin is protected by international copyright laws. Knowledge of the |
reedas | 5:f62a9e4a499a | 15 | source code may not be used to write a similar product. This file may |
reedas | 5:f62a9e4a499a | 16 | only be used in accordance with the following terms: |
reedas | 5:f62a9e4a499a | 17 | |
reedas | 5:f62a9e4a499a | 18 | The software has been licensed to Cypress Semiconductor Corporation, |
reedas | 5:f62a9e4a499a | 19 | whose registered office is situated at 198 Champion Ct. San Jose, CA |
reedas | 5:f62a9e4a499a | 20 | 95134 USA solely for the purposes of creating libraries for Cypress |
reedas | 5:f62a9e4a499a | 21 | PSoC3 and PSoC5 processor-based devices, sublicensed and distributed |
reedas | 5:f62a9e4a499a | 22 | under the terms and conditions of the Cypress End User License |
reedas | 5:f62a9e4a499a | 23 | Agreement. |
reedas | 5:f62a9e4a499a | 24 | Full source code is available at: www.segger.com |
reedas | 5:f62a9e4a499a | 25 | |
reedas | 5:f62a9e4a499a | 26 | We appreciate your understanding and fairness. |
reedas | 5:f62a9e4a499a | 27 | ---------------------------------------------------------------------- |
reedas | 5:f62a9e4a499a | 28 | Licensing information |
reedas | 5:f62a9e4a499a | 29 | Licensor: SEGGER Microcontroller Systems LLC |
reedas | 5:f62a9e4a499a | 30 | Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA |
reedas | 5:f62a9e4a499a | 31 | Licensed SEGGER software: emWin |
reedas | 5:f62a9e4a499a | 32 | License number: GUI-00319 |
reedas | 5:f62a9e4a499a | 33 | License model: Services and License Agreement, signed June 10th, 2009 |
reedas | 5:f62a9e4a499a | 34 | Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) |
reedas | 5:f62a9e4a499a | 35 | ---------------------------------------------------------------------- |
reedas | 5:f62a9e4a499a | 36 | Support and Update Agreement (SUA) |
reedas | 5:f62a9e4a499a | 37 | SUA period: 2009-06-12 - 2022-07-27 |
reedas | 5:f62a9e4a499a | 38 | Contact to extend SUA: sales@segger.com |
reedas | 5:f62a9e4a499a | 39 | ---------------------------------------------------------------------- |
reedas | 5:f62a9e4a499a | 40 | File : Bounce.c |
reedas | 5:f62a9e4a499a | 41 | Purpose : Bouncing balls demo |
reedas | 5:f62a9e4a499a | 42 | ---------------------------END-OF-HEADER------------------------------ |
reedas | 5:f62a9e4a499a | 43 | */ |
reedas | 5:f62a9e4a499a | 44 | |
reedas | 5:f62a9e4a499a | 45 | #include <stddef.h> |
reedas | 5:f62a9e4a499a | 46 | #include <stdlib.h> |
reedas | 5:f62a9e4a499a | 47 | #include <malloc.h> |
reedas | 5:f62a9e4a499a | 48 | #include <math.h> |
reedas | 5:f62a9e4a499a | 49 | |
reedas | 5:f62a9e4a499a | 50 | #include "DIALOG.h" |
reedas | 5:f62a9e4a499a | 51 | |
reedas | 5:f62a9e4a499a | 52 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 53 | * |
reedas | 5:f62a9e4a499a | 54 | * Define |
reedas | 5:f62a9e4a499a | 55 | * |
reedas | 5:f62a9e4a499a | 56 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 57 | */ |
reedas | 5:f62a9e4a499a | 58 | #define ID_WINDOW_0 (GUI_ID_USER + 0x00) |
reedas | 5:f62a9e4a499a | 59 | #define ID_BUTTON_0 (GUI_ID_USER + 0x01) |
reedas | 5:f62a9e4a499a | 60 | #define ID_BUTTON_1 (GUI_ID_USER + 0x02) |
reedas | 5:f62a9e4a499a | 61 | #define ID_BUTTON_2 (GUI_ID_USER + 0x03) |
reedas | 5:f62a9e4a499a | 62 | #define ID_CHECKBOX_0 (GUI_ID_USER + 0x04) |
reedas | 5:f62a9e4a499a | 63 | #define ID_CHECKBOX_1 (GUI_ID_USER + 0x05) |
reedas | 5:f62a9e4a499a | 64 | #define ID_TEXT_0 (GUI_ID_USER + 0x06) |
reedas | 5:f62a9e4a499a | 65 | #define ID_SLIDER_0 (GUI_ID_USER + 0x07) |
reedas | 5:f62a9e4a499a | 66 | |
reedas | 5:f62a9e4a499a | 67 | #define MIN_RANDOM_V 0 // Minimum velocity (x or y) to be used in generating random balls |
reedas | 5:f62a9e4a499a | 68 | #define MAX_RANDOM_V 80 // Maximum velocity (x or y) to be used in generating random balls |
reedas | 5:f62a9e4a499a | 69 | #define MIN_RANDOM_R 5 // Minimum radius to be used in generating random balls |
reedas | 5:f62a9e4a499a | 70 | #define MAX_RANDOM_R 40 // Maximum radius to be used in generating random balls |
reedas | 5:f62a9e4a499a | 71 | #define M_PI 3.1415926f |
reedas | 5:f62a9e4a499a | 72 | #define M_TO_A_RATIO 0.1f // Ratio of mass to area used in generating random balls |
reedas | 5:f62a9e4a499a | 73 | |
reedas | 5:f62a9e4a499a | 74 | #define TIME_SLICE 20 |
reedas | 5:f62a9e4a499a | 75 | #define NUM_BALLS 10 |
reedas | 5:f62a9e4a499a | 76 | #define GRAVITY 100 |
reedas | 5:f62a9e4a499a | 77 | |
reedas | 5:f62a9e4a499a | 78 | #define XSIZE_SPLASH 220 |
reedas | 5:f62a9e4a499a | 79 | #define YSIZE_SPLASH 120 |
reedas | 5:f62a9e4a499a | 80 | #define PERIOD_SPLASH 3000 |
reedas | 5:f62a9e4a499a | 81 | |
reedas | 5:f62a9e4a499a | 82 | #if GUI_VERSION < 54400 |
reedas | 5:f62a9e4a499a | 83 | #define WM_USER_DATA (WM_USER + 0) |
reedas | 5:f62a9e4a499a | 84 | #endif |
reedas | 5:f62a9e4a499a | 85 | |
reedas | 5:f62a9e4a499a | 86 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 87 | * |
reedas | 5:f62a9e4a499a | 88 | * Types |
reedas | 5:f62a9e4a499a | 89 | * |
reedas | 5:f62a9e4a499a | 90 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 91 | */ |
reedas | 5:f62a9e4a499a | 92 | enum Wall { WALL_NONE, WALL_X1, WALL_Y1, WALL_X2, WALL_Y2 }; |
reedas | 5:f62a9e4a499a | 93 | enum Type { TYPE_NONE, TYPE_WALL, TYPE_BALL }; |
reedas | 5:f62a9e4a499a | 94 | |
reedas | 5:f62a9e4a499a | 95 | typedef struct { |
reedas | 5:f62a9e4a499a | 96 | float x, y; |
reedas | 5:f62a9e4a499a | 97 | } VECTOR; |
reedas | 5:f62a9e4a499a | 98 | |
reedas | 5:f62a9e4a499a | 99 | typedef struct { |
reedas | 5:f62a9e4a499a | 100 | float x1, y1, x2, y2; |
reedas | 5:f62a9e4a499a | 101 | } WALLS; |
reedas | 5:f62a9e4a499a | 102 | |
reedas | 5:f62a9e4a499a | 103 | typedef struct BALL BALL; |
reedas | 5:f62a9e4a499a | 104 | |
reedas | 5:f62a9e4a499a | 105 | struct BALL { |
reedas | 5:f62a9e4a499a | 106 | VECTOR p; // Position |
reedas | 5:f62a9e4a499a | 107 | VECTOR v; // Velocity |
reedas | 5:f62a9e4a499a | 108 | float m; // Mass |
reedas | 5:f62a9e4a499a | 109 | float r; // Radius |
reedas | 5:f62a9e4a499a | 110 | U32 Index; // Normally used as color |
reedas | 5:f62a9e4a499a | 111 | int Id; // ID |
reedas | 5:f62a9e4a499a | 112 | BALL * pNext; |
reedas | 5:f62a9e4a499a | 113 | }; |
reedas | 5:f62a9e4a499a | 114 | |
reedas | 5:f62a9e4a499a | 115 | typedef struct { |
reedas | 5:f62a9e4a499a | 116 | int CollisionType; |
reedas | 5:f62a9e4a499a | 117 | int WhichWall; |
reedas | 5:f62a9e4a499a | 118 | float TimeToCollision; |
reedas | 5:f62a9e4a499a | 119 | } COLLISION; |
reedas | 5:f62a9e4a499a | 120 | |
reedas | 5:f62a9e4a499a | 121 | typedef struct { |
reedas | 5:f62a9e4a499a | 122 | int xPos, yPos; |
reedas | 5:f62a9e4a499a | 123 | int xSize, ySize; |
reedas | 5:f62a9e4a499a | 124 | void (* pfDrawBk) (WM_HWIN hWin, void * pConfig); |
reedas | 5:f62a9e4a499a | 125 | void (* pfDrawBall)(WM_HWIN hWin, void * pConfig, U32 Index, float x, float y, float r); |
reedas | 5:f62a9e4a499a | 126 | unsigned Range; |
reedas | 5:f62a9e4a499a | 127 | unsigned * pRadius; |
reedas | 5:f62a9e4a499a | 128 | unsigned NumBalls; |
reedas | 5:f62a9e4a499a | 129 | float vMin, vMax; |
reedas | 5:f62a9e4a499a | 130 | float rMin, rMax; |
reedas | 5:f62a9e4a499a | 131 | unsigned TimeSlice; |
reedas | 5:f62a9e4a499a | 132 | float Gravity; |
reedas | 5:f62a9e4a499a | 133 | int HasBallGravity; |
reedas | 5:f62a9e4a499a | 134 | int HasGroundGravity; |
reedas | 5:f62a9e4a499a | 135 | int HasInitialVelocity; |
reedas | 5:f62a9e4a499a | 136 | GUI_COLOR ColorBk; // Used if pfDrawBk() not set |
reedas | 5:f62a9e4a499a | 137 | } BALLSIM_CONFIG; |
reedas | 5:f62a9e4a499a | 138 | |
reedas | 5:f62a9e4a499a | 139 | typedef struct { |
reedas | 5:f62a9e4a499a | 140 | BALL * pFirstBall; // Stores all the balls |
reedas | 5:f62a9e4a499a | 141 | int HasWalls; // Have wall boundaries been set? |
reedas | 5:f62a9e4a499a | 142 | WALLS Walls; |
reedas | 5:f62a9e4a499a | 143 | int NextId; // Next ID to assign to an added ball |
reedas | 5:f62a9e4a499a | 144 | unsigned MaxCollisions; // Max number of collisions per frame in advanceSim |
reedas | 5:f62a9e4a499a | 145 | unsigned MaxCollisionsPerBall; // Max number of collisions per frame based on the number of balls |
reedas | 5:f62a9e4a499a | 146 | float MinArea; // Minimum area within walls |
reedas | 5:f62a9e4a499a | 147 | float MaxDiameter; // Maximum diameter out of all the balls |
reedas | 5:f62a9e4a499a | 148 | unsigned NumBalls; |
reedas | 5:f62a9e4a499a | 149 | BALLSIM_CONFIG * pConfig; |
reedas | 5:f62a9e4a499a | 150 | } BALLSIM; |
reedas | 5:f62a9e4a499a | 151 | |
reedas | 5:f62a9e4a499a | 152 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 153 | * |
reedas | 5:f62a9e4a499a | 154 | * Static (const) data |
reedas | 5:f62a9e4a499a | 155 | * |
reedas | 5:f62a9e4a499a | 156 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 157 | */ |
reedas | 5:f62a9e4a499a | 158 | static GUI_CONST_STORAGE GUI_COLOR _ColorsSeggerLogo_80x40[] = { |
reedas | 5:f62a9e4a499a | 159 | #if (GUI_USE_ARGB == 0) |
reedas | 5:f62a9e4a499a | 160 | 0x000000, 0xFFFFFF, 0x292929, 0x5F5F5F, |
reedas | 5:f62a9e4a499a | 161 | 0x96433D, 0xB0726E, 0xCACACA, 0xF8F3F3, |
reedas | 5:f62a9e4a499a | 162 | 0xD7D7D7, 0xEBDCDB, 0x363636, 0x9D4F49, |
reedas | 5:f62a9e4a499a | 163 | 0xAA6661, 0x949494, 0xA1A1A1, 0xB77E7A, |
reedas | 5:f62a9e4a499a | 164 | 0x444444, 0xBD8A86, 0xD1ADAA, 0xE4E4E4, |
reedas | 5:f62a9e4a499a | 165 | 0xF2F2F2, 0x6C6C6C, 0x797979, 0xA35B55, |
reedas | 5:f62a9e4a499a | 166 | 0xD8B9B6, 0xAFAFAF, 0xBCBCBC, 0xF2E8E7, |
reedas | 5:f62a9e4a499a | 167 | 0x515151, 0xCBA19E, 0xE5D0CF, 0x878787, |
reedas | 5:f62a9e4a499a | 168 | 0xC49592, 0xDEC4C2 |
reedas | 5:f62a9e4a499a | 169 | #else |
reedas | 5:f62a9e4a499a | 170 | 0xFF000000, 0xFFFFFFFF, 0xFF292929, 0xFF5F5F5F, |
reedas | 5:f62a9e4a499a | 171 | 0xFF3D4396, 0xFF6E72B0, 0xFFCACACA, 0xFFF3F3F8, |
reedas | 5:f62a9e4a499a | 172 | 0xFFD7D7D7, 0xFFDBDCEB, 0xFF363636, 0xFF494F9D, |
reedas | 5:f62a9e4a499a | 173 | 0xFF6166AA, 0xFF949494, 0xFFA1A1A1, 0xFF7A7EB7, |
reedas | 5:f62a9e4a499a | 174 | 0xFF444444, 0xFF868ABD, 0xFFAAADD1, 0xFFE4E4E4, |
reedas | 5:f62a9e4a499a | 175 | 0xFFF2F2F2, 0xFF6C6C6C, 0xFF797979, 0xFF555BA3, |
reedas | 5:f62a9e4a499a | 176 | 0xFFB6B9D8, 0xFFAFAFAF, 0xFFBCBCBC, 0xFFE7E8F2, |
reedas | 5:f62a9e4a499a | 177 | 0xFF515151, 0xFF9EA1CB, 0xFFCFD0E5, 0xFF878787, |
reedas | 5:f62a9e4a499a | 178 | 0xFF9295C4, 0xFFC2C4DE |
reedas | 5:f62a9e4a499a | 179 | #endif |
reedas | 5:f62a9e4a499a | 180 | |
reedas | 5:f62a9e4a499a | 181 | }; |
reedas | 5:f62a9e4a499a | 182 | |
reedas | 5:f62a9e4a499a | 183 | static GUI_CONST_STORAGE GUI_LOGPALETTE _PalSeggerLogo_80x40 = { |
reedas | 5:f62a9e4a499a | 184 | 34, // Number of entries |
reedas | 5:f62a9e4a499a | 185 | 1, // Has transparency |
reedas | 5:f62a9e4a499a | 186 | &_ColorsSeggerLogo_80x40[0] |
reedas | 5:f62a9e4a499a | 187 | }; |
reedas | 5:f62a9e4a499a | 188 | |
reedas | 5:f62a9e4a499a | 189 | static GUI_CONST_STORAGE unsigned char _acSeggerLogo_80x40[] = { |
reedas | 5:f62a9e4a499a | 190 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 191 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 192 | 0x02, 0x02, 0x0A, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, |
reedas | 5:f62a9e4a499a | 193 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0A, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 194 | 0x02, 0x02, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 195 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 196 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 197 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 198 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 199 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 200 | 0x02, 0x03, 0x01, 0x01, 0x21, 0x0F, 0x09, 0x01, 0x01, 0x01, 0x01, 0x09, 0x11, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 201 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 202 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x01, 0x05, 0x04, 0x0B, 0x1B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 203 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 204 | 0x02, 0x03, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x20, 0x04, 0x04, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 205 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 206 | 0x02, 0x03, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x0C, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 207 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 208 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x09, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x07, 0x0B, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 209 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 210 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x1E, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 211 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 212 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 213 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 214 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 215 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 216 | 0x02, 0x03, 0x01, 0x01, 0x12, 0x01, 0x01, 0x01, 0x09, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x12, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 217 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 218 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x1E, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x09, 0x0B, 0x04, 0x04, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 219 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 220 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x18, 0x04, 0x04, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 221 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 222 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x05, 0x01, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x11, 0x04, 0x04, 0x17, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, |
reedas | 5:f62a9e4a499a | 223 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x1B, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 224 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x04, 0x1D, 0x01, 0x01, 0x01, 0x09, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x07, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, |
reedas | 5:f62a9e4a499a | 225 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1D, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 226 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x04, 0x04, 0x1E, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x1B, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, |
reedas | 5:f62a9e4a499a | 227 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x1B, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 228 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x04, 0x04, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x1D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 229 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 230 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x04, 0x04, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x1D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 231 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 232 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x04, 0x04, 0x1E, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x1B, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, |
reedas | 5:f62a9e4a499a | 233 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x1B, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 234 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x04, 0x1D, 0x01, 0x01, 0x01, 0x09, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x07, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, |
reedas | 5:f62a9e4a499a | 235 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1D, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 236 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x05, 0x01, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x11, 0x04, 0x04, 0x17, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, |
reedas | 5:f62a9e4a499a | 237 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x1B, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 238 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x18, 0x04, 0x04, 0x0B, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 239 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 240 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x1E, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x09, 0x0B, 0x04, 0x04, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 241 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 242 | 0x02, 0x03, 0x01, 0x01, 0x12, 0x01, 0x01, 0x01, 0x09, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x12, 0x01, 0x01, 0x14, 0x1A, 0x0D, 0x0D, 0x1A, 0x01, 0x01, 0x01, 0x13, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, 0x01, 0x01, 0x01, 0x13, 0x19, |
reedas | 5:f62a9e4a499a | 243 | 0x0D, 0x0E, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x13, 0x0E, 0x0D, 0x0E, 0x08, 0x01, 0x01, 0x01, 0x14, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 244 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x0F, 0x01, 0x01, 0x08, 0x0A, 0x02, 0x02, 0x02, 0x02, 0x10, 0x13, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x01, 0x1F, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 245 | 0x02, 0x02, 0x02, 0x03, 0x14, 0x01, 0x01, 0x1F, 0x02, 0x02, 0x02, 0x02, 0x02, 0x15, 0x01, 0x01, 0x16, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 246 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x1F, 0x02, 0x15, 0x13, 0x08, 0x1C, 0x02, 0x0D, 0x01, 0x03, 0x02, 0x0E, 0x06, 0x06, 0x06, 0x06, 0x01, 0x19, 0x02, 0x02, 0x0D, |
reedas | 5:f62a9e4a499a | 247 | 0x06, 0x19, 0x0A, 0x02, 0x19, 0x01, 0x0D, 0x02, 0x02, 0x0E, 0x06, 0x0E, 0x0A, 0x02, 0x06, 0x01, 0x03, 0x02, 0x16, 0x06, 0x06, 0x06, 0x06, 0x14, 0x06, 0x02, 0x1C, 0x06, 0x06, 0x0D, 0x02, 0x02, 0x06, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 248 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x1E, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x01, 0x1F, 0x02, 0x10, 0x0E, 0x08, 0x14, 0x06, 0x14, 0x01, 0x03, 0x02, 0x0E, 0x06, 0x06, 0x06, 0x13, 0x01, 0x03, 0x02, 0x16, 0x01, |
reedas | 5:f62a9e4a499a | 249 | 0x01, 0x01, 0x08, 0x0D, 0x14, 0x01, 0x10, 0x02, 0x0D, 0x01, 0x01, 0x01, 0x08, 0x0E, 0x14, 0x01, 0x03, 0x02, 0x16, 0x06, 0x06, 0x06, 0x13, 0x01, 0x06, 0x02, 0x03, 0x01, 0x01, 0x14, 0x10, 0x02, 0x06, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 250 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x09, 0x04, 0x04, 0x0B, 0x09, 0x01, 0x01, 0x07, 0x0B, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x01, 0x08, 0x10, 0x02, 0x02, 0x02, 0x02, 0x15, 0x08, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x1A, 0x01, |
reedas | 5:f62a9e4a499a | 251 | 0x13, 0x03, 0x03, 0x03, 0x0E, 0x01, 0x02, 0x02, 0x06, 0x01, 0x08, 0x03, 0x03, 0x03, 0x0E, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0A, 0x01, 0x06, 0x02, 0x0A, 0x03, 0x03, 0x0A, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 252 | 0x02, 0x03, 0x01, 0x01, 0x07, 0x17, 0x04, 0x04, 0x18, 0x01, 0x01, 0x01, 0x0C, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x0D, 0x03, 0x02, 0x02, 0x1C, 0x01, 0x03, 0x02, 0x0E, 0x06, 0x06, 0x06, 0x13, 0x01, 0x10, 0x02, 0x0E, 0x01, |
reedas | 5:f62a9e4a499a | 253 | 0x08, 0x0A, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x1A, 0x01, 0x1A, 0x0A, 0x02, 0x02, 0x03, 0x01, 0x03, 0x02, 0x16, 0x06, 0x06, 0x06, 0x08, 0x01, 0x06, 0x02, 0x0A, 0x03, 0x03, 0x0A, 0x02, 0x1C, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 254 | 0x02, 0x03, 0x01, 0x01, 0x0F, 0x04, 0x04, 0x11, 0x01, 0x01, 0x01, 0x20, 0x04, 0x04, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x02, 0x19, 0x01, 0x01, 0x1A, 0x02, 0x02, 0x01, 0x03, 0x02, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x16, 0x02, 0x10, 0x14, |
reedas | 5:f62a9e4a499a | 255 | 0x01, 0x01, 0x0D, 0x02, 0x03, 0x01, 0x15, 0x02, 0x1C, 0x14, 0x01, 0x01, 0x16, 0x02, 0x03, 0x01, 0x03, 0x02, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x02, 0x03, 0x01, 0x01, 0x06, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 256 | 0x02, 0x03, 0x01, 0x01, 0x04, 0x04, 0x0C, 0x07, 0x01, 0x01, 0x01, 0x05, 0x04, 0x0B, 0x1B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x02, 0x02, 0x03, 0x16, 0x10, 0x02, 0x15, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0A, 0x1A, 0x13, 0x0A, 0x02, 0x0A, |
reedas | 5:f62a9e4a499a | 257 | 0x03, 0x1C, 0x02, 0x02, 0x03, 0x01, 0x08, 0x0A, 0x02, 0x0A, 0x03, 0x10, 0x02, 0x02, 0x03, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x19, 0x06, 0x02, 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 258 | 0x02, 0x03, 0x01, 0x01, 0x21, 0x0F, 0x09, 0x01, 0x01, 0x01, 0x01, 0x09, 0x11, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x19, 0x1C, 0x02, 0x02, 0x10, 0x16, 0x14, 0x01, 0x0D, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x08, 0x01, 0x13, 0x16, 0x0A, |
reedas | 5:f62a9e4a499a | 259 | 0x02, 0x0A, 0x1F, 0x15, 0x15, 0x01, 0x01, 0x08, 0x15, 0x0A, 0x02, 0x10, 0x0D, 0x03, 0x15, 0x01, 0x19, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x1A, 0x08, 0x03, 0x0D, 0x01, 0x01, 0x01, 0x15, 0x10, 0x13, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 260 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 261 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 262 | 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 263 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, |
reedas | 5:f62a9e4a499a | 264 | 0x02, 0x02, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
reedas | 5:f62a9e4a499a | 265 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 266 | 0x02, 0x02, 0x0A, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, |
reedas | 5:f62a9e4a499a | 267 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0A, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 268 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
reedas | 5:f62a9e4a499a | 269 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 |
reedas | 5:f62a9e4a499a | 270 | }; |
reedas | 5:f62a9e4a499a | 271 | |
reedas | 5:f62a9e4a499a | 272 | static GUI_CONST_STORAGE GUI_BITMAP _bmSeggerLogo_80x40 = { |
reedas | 5:f62a9e4a499a | 273 | 80, // xSize |
reedas | 5:f62a9e4a499a | 274 | 40, // ySize |
reedas | 5:f62a9e4a499a | 275 | 80, // BytesPerLine |
reedas | 5:f62a9e4a499a | 276 | 8, // BitsPerPixel |
reedas | 5:f62a9e4a499a | 277 | _acSeggerLogo_80x40, // Pointer to picture data (indices) |
reedas | 5:f62a9e4a499a | 278 | &_PalSeggerLogo_80x40 // Pointer to palette |
reedas | 5:f62a9e4a499a | 279 | }; |
reedas | 5:f62a9e4a499a | 280 | |
reedas | 5:f62a9e4a499a | 281 | static GUI_CONST_STORAGE unsigned char acGUI_Font32_AA4_Bounce_0042[152] = { /* code 0042, LATIN CAPITAL LETTER B */ |
reedas | 5:f62a9e4a499a | 282 | 0x5E, 0xFF, 0xFF, 0xFF, 0xFE, 0xC7, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 283 | 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, |
reedas | 5:f62a9e4a499a | 284 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x00, |
reedas | 5:f62a9e4a499a | 285 | 0xFF, 0xFF, 0x00, 0x00, 0x19, 0xFF, 0xFE, 0x00, |
reedas | 5:f62a9e4a499a | 286 | 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, |
reedas | 5:f62a9e4a499a | 287 | 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, |
reedas | 5:f62a9e4a499a | 288 | 0xFF, 0xFF, 0x00, 0x00, 0x19, 0xFF, 0xFA, 0x00, |
reedas | 5:f62a9e4a499a | 289 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, 0x00, |
reedas | 5:f62a9e4a499a | 290 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, |
reedas | 5:f62a9e4a499a | 291 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0x00, |
reedas | 5:f62a9e4a499a | 292 | 0xFF, 0xFF, 0x00, 0x00, 0x04, 0xDF, 0xFF, 0x70, |
reedas | 5:f62a9e4a499a | 293 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xC0, |
reedas | 5:f62a9e4a499a | 294 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xF0, |
reedas | 5:f62a9e4a499a | 295 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xF0, |
reedas | 5:f62a9e4a499a | 296 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xC0, |
reedas | 5:f62a9e4a499a | 297 | 0xFF, 0xFF, 0x00, 0x00, 0x04, 0xDF, 0xFF, 0x80, |
reedas | 5:f62a9e4a499a | 298 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x10, |
reedas | 5:f62a9e4a499a | 299 | 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0x00, |
reedas | 5:f62a9e4a499a | 300 | 0x6E, 0xFF, 0xFF, 0xFF, 0xFE, 0xB6, 0x00, 0x00 |
reedas | 5:f62a9e4a499a | 301 | }; |
reedas | 5:f62a9e4a499a | 302 | |
reedas | 5:f62a9e4a499a | 303 | static GUI_CONST_STORAGE unsigned char acGUI_Font32_AA4_Bounce_0063[ 84] = { /* code 0063, LATIN SMALL LETTER C */ |
reedas | 5:f62a9e4a499a | 304 | 0x00, 0x06, 0xBE, 0xFE, 0xB6, 0x00, |
reedas | 5:f62a9e4a499a | 305 | 0x01, 0xCF, 0xFF, 0xFF, 0xFF, 0xC1, |
reedas | 5:f62a9e4a499a | 306 | 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, |
reedas | 5:f62a9e4a499a | 307 | 0x5F, 0xFF, 0xE4, 0x02, 0xBF, 0xFF, |
reedas | 5:f62a9e4a499a | 308 | 0xAF, 0xFF, 0x60, 0x00, 0x1B, 0xF8, |
reedas | 5:f62a9e4a499a | 309 | 0xEF, 0xFF, 0x20, 0x00, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 310 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 311 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 312 | 0xEF, 0xFF, 0x20, 0x00, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 313 | 0xBF, 0xFF, 0x70, 0x00, 0x1A, 0xF8, |
reedas | 5:f62a9e4a499a | 314 | 0x5F, 0xFF, 0xE4, 0x02, 0xBF, 0xFF, |
reedas | 5:f62a9e4a499a | 315 | 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, |
reedas | 5:f62a9e4a499a | 316 | 0x01, 0xCF, 0xFF, 0xFF, 0xFF, 0xB1, |
reedas | 5:f62a9e4a499a | 317 | 0x00, 0x07, 0xCF, 0xFE, 0xB5, 0x00 |
reedas | 5:f62a9e4a499a | 318 | }; |
reedas | 5:f62a9e4a499a | 319 | |
reedas | 5:f62a9e4a499a | 320 | static GUI_CONST_STORAGE unsigned char acGUI_Font32_AA4_Bounce_0065[ 98] = { /* code 0065, LATIN SMALL LETTER E */ |
reedas | 5:f62a9e4a499a | 321 | 0x00, 0x06, 0xCE, 0xFE, 0xB6, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 322 | 0x01, 0xCF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, |
reedas | 5:f62a9e4a499a | 323 | 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, |
reedas | 5:f62a9e4a499a | 324 | 0x5F, 0xFF, 0xD3, 0x03, 0xDF, 0xFF, 0x60, |
reedas | 5:f62a9e4a499a | 325 | 0xBF, 0xFF, 0x50, 0x00, 0x4F, 0xFF, 0xB0, |
reedas | 5:f62a9e4a499a | 326 | 0xEF, 0xFF, 0x10, 0x00, 0x1F, 0xFF, 0xE0, |
reedas | 5:f62a9e4a499a | 327 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, |
reedas | 5:f62a9e4a499a | 328 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, |
reedas | 5:f62a9e4a499a | 329 | 0xDF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 330 | 0xAF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, |
reedas | 5:f62a9e4a499a | 331 | 0x5F, 0xFF, 0xE4, 0x00, 0x4B, 0xFB, 0x00, |
reedas | 5:f62a9e4a499a | 332 | 0x0B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, |
reedas | 5:f62a9e4a499a | 333 | 0x01, 0xCF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, |
reedas | 5:f62a9e4a499a | 334 | 0x00, 0x06, 0xCE, 0xFE, 0xB7, 0x10, 0x00 |
reedas | 5:f62a9e4a499a | 335 | }; |
reedas | 5:f62a9e4a499a | 336 | |
reedas | 5:f62a9e4a499a | 337 | static GUI_CONST_STORAGE unsigned char acGUI_Font32_AA4_Bounce_006E[ 84] = { /* code 006E, LATIN SMALL LETTER N */ |
reedas | 5:f62a9e4a499a | 338 | 0x6E, 0xE5, 0x06, 0xCF, 0xEB, 0x30, |
reedas | 5:f62a9e4a499a | 339 | 0xEF, 0xFC, 0x9F, 0xFF, 0xFF, 0xF3, |
reedas | 5:f62a9e4a499a | 340 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, |
reedas | 5:f62a9e4a499a | 341 | 0xFF, 0xFF, 0xC2, 0x08, 0xFF, 0xFE, |
reedas | 5:f62a9e4a499a | 342 | 0xFF, 0xFF, 0x30, 0x02, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 343 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 344 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 345 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 346 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 347 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 348 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 349 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 350 | 0xEF, 0xFE, 0x00, 0x00, 0xEF, 0xFE, |
reedas | 5:f62a9e4a499a | 351 | 0x6E, 0xE6, 0x00, 0x00, 0x6E, 0xE6 |
reedas | 5:f62a9e4a499a | 352 | }; |
reedas | 5:f62a9e4a499a | 353 | |
reedas | 5:f62a9e4a499a | 354 | static GUI_CONST_STORAGE unsigned char acGUI_Font32_AA4_Bounce_006F[ 98] = { /* code 006F, LATIN SMALL LETTER O */ |
reedas | 5:f62a9e4a499a | 355 | 0x00, 0x04, 0xAD, 0xFF, 0xDA, 0x40, 0x00, |
reedas | 5:f62a9e4a499a | 356 | 0x01, 0xAF, 0xFF, 0xFF, 0xFF, 0xFA, 0x10, |
reedas | 5:f62a9e4a499a | 357 | 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, |
reedas | 5:f62a9e4a499a | 358 | 0x4F, 0xFF, 0xF6, 0x11, 0x6F, 0xFF, 0xF4, |
reedas | 5:f62a9e4a499a | 359 | 0xAF, 0xFF, 0x70, 0x00, 0x07, 0xFF, 0xFA, |
reedas | 5:f62a9e4a499a | 360 | 0xDF, 0xFF, 0x30, 0x00, 0x03, 0xFF, 0xFD, |
reedas | 5:f62a9e4a499a | 361 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 362 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 363 | 0xDF, 0xFF, 0x30, 0x00, 0x03, 0xFF, 0xFD, |
reedas | 5:f62a9e4a499a | 364 | 0xAF, 0xFF, 0x70, 0x00, 0x07, 0xFF, 0xFA, |
reedas | 5:f62a9e4a499a | 365 | 0x4F, 0xFF, 0xF6, 0x11, 0x6F, 0xFF, 0xF4, |
reedas | 5:f62a9e4a499a | 366 | 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, |
reedas | 5:f62a9e4a499a | 367 | 0x01, 0xAF, 0xFF, 0xFF, 0xFF, 0xFA, 0x10, |
reedas | 5:f62a9e4a499a | 368 | 0x00, 0x04, 0xAD, 0xFF, 0xDA, 0x40, 0x00 |
reedas | 5:f62a9e4a499a | 369 | }; |
reedas | 5:f62a9e4a499a | 370 | |
reedas | 5:f62a9e4a499a | 371 | static GUI_CONST_STORAGE unsigned char acGUI_Font32_AA4_Bounce_0075[ 84] = { /* code 0075, LATIN SMALL LETTER U */ |
reedas | 5:f62a9e4a499a | 372 | 0x6E, 0xE6, 0x00, 0x00, 0x6E, 0xE6, |
reedas | 5:f62a9e4a499a | 373 | 0xEF, 0xFE, 0x00, 0x00, 0xEF, 0xFE, |
reedas | 5:f62a9e4a499a | 374 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 375 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 376 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 377 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 378 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 379 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 380 | 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 381 | 0xFF, 0xFF, 0x10, 0x03, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 382 | 0xEF, 0xFF, 0x80, 0x2C, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 383 | 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
reedas | 5:f62a9e4a499a | 384 | 0x3F, 0xFF, 0xFF, 0xF9, 0xCF, 0xFE, |
reedas | 5:f62a9e4a499a | 385 | 0x04, 0xBF, 0xFC, 0x60, 0x5E, 0xE6 |
reedas | 5:f62a9e4a499a | 386 | }; |
reedas | 5:f62a9e4a499a | 387 | |
reedas | 5:f62a9e4a499a | 388 | static GUI_CONST_STORAGE GUI_CHARINFO_EXT GUI_Font32_AA4_Bounce_CharInfo[6] = { |
reedas | 5:f62a9e4a499a | 389 | { 15, 19, 2, 7, 18, acGUI_Font32_AA4_Bounce_0042 } /* code 0042, LATIN CAPITAL LETTER B */ |
reedas | 5:f62a9e4a499a | 390 | ,{ 12, 14, 1, 12, 14, acGUI_Font32_AA4_Bounce_0063 } /* code 0063, LATIN SMALL LETTER C */ |
reedas | 5:f62a9e4a499a | 391 | ,{ 13, 14, 1, 12, 15, acGUI_Font32_AA4_Bounce_0065 } /* code 0065, LATIN SMALL LETTER E */ |
reedas | 5:f62a9e4a499a | 392 | ,{ 12, 14, 2, 12, 16, acGUI_Font32_AA4_Bounce_006E } /* code 006E, LATIN SMALL LETTER N */ |
reedas | 5:f62a9e4a499a | 393 | ,{ 14, 14, 1, 12, 16, acGUI_Font32_AA4_Bounce_006F } /* code 006F, LATIN SMALL LETTER O */ |
reedas | 5:f62a9e4a499a | 394 | ,{ 12, 14, 2, 12, 16, acGUI_Font32_AA4_Bounce_0075 } /* code 0075, LATIN SMALL LETTER U */ |
reedas | 5:f62a9e4a499a | 395 | }; |
reedas | 5:f62a9e4a499a | 396 | |
reedas | 5:f62a9e4a499a | 397 | static GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_Font32_AA4_Bounce_Prop5 = { |
reedas | 5:f62a9e4a499a | 398 | 0x0075 /* first character */ |
reedas | 5:f62a9e4a499a | 399 | ,0x0075 /* last character */ |
reedas | 5:f62a9e4a499a | 400 | ,&GUI_Font32_AA4_Bounce_CharInfo[ 5] /* address of first character */ |
reedas | 5:f62a9e4a499a | 401 | ,(GUI_CONST_STORAGE GUI_FONT_PROP_EXT *)0 /* pointer to next GUI_FONT_PROP_EXT */ |
reedas | 5:f62a9e4a499a | 402 | }; |
reedas | 5:f62a9e4a499a | 403 | |
reedas | 5:f62a9e4a499a | 404 | static GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_Font32_AA4_Bounce_Prop4 = { |
reedas | 5:f62a9e4a499a | 405 | 0x006E /* first character */ |
reedas | 5:f62a9e4a499a | 406 | ,0x006F /* last character */ |
reedas | 5:f62a9e4a499a | 407 | ,&GUI_Font32_AA4_Bounce_CharInfo[ 3] /* address of first character */ |
reedas | 5:f62a9e4a499a | 408 | ,&GUI_Font32_AA4_Bounce_Prop5 /* pointer to next GUI_FONT_PROP_EXT */ |
reedas | 5:f62a9e4a499a | 409 | }; |
reedas | 5:f62a9e4a499a | 410 | |
reedas | 5:f62a9e4a499a | 411 | static GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_Font32_AA4_Bounce_Prop3 = { |
reedas | 5:f62a9e4a499a | 412 | 0x0065 /* first character */ |
reedas | 5:f62a9e4a499a | 413 | ,0x0065 /* last character */ |
reedas | 5:f62a9e4a499a | 414 | ,&GUI_Font32_AA4_Bounce_CharInfo[ 2] /* address of first character */ |
reedas | 5:f62a9e4a499a | 415 | ,&GUI_Font32_AA4_Bounce_Prop4 /* pointer to next GUI_FONT_PROP_EXT */ |
reedas | 5:f62a9e4a499a | 416 | }; |
reedas | 5:f62a9e4a499a | 417 | |
reedas | 5:f62a9e4a499a | 418 | static GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_Font32_AA4_Bounce_Prop2 = { |
reedas | 5:f62a9e4a499a | 419 | 0x0063 /* first character */ |
reedas | 5:f62a9e4a499a | 420 | ,0x0063 /* last character */ |
reedas | 5:f62a9e4a499a | 421 | ,&GUI_Font32_AA4_Bounce_CharInfo[ 1] /* address of first character */ |
reedas | 5:f62a9e4a499a | 422 | ,&GUI_Font32_AA4_Bounce_Prop3 /* pointer to next GUI_FONT_PROP_EXT */ |
reedas | 5:f62a9e4a499a | 423 | }; |
reedas | 5:f62a9e4a499a | 424 | |
reedas | 5:f62a9e4a499a | 425 | static GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_Font32_AA4_Bounce_Prop1 = { |
reedas | 5:f62a9e4a499a | 426 | 0x0042 /* first character */ |
reedas | 5:f62a9e4a499a | 427 | ,0x0042 /* last character */ |
reedas | 5:f62a9e4a499a | 428 | ,&GUI_Font32_AA4_Bounce_CharInfo[ 0] /* address of first character */ |
reedas | 5:f62a9e4a499a | 429 | ,&GUI_Font32_AA4_Bounce_Prop2 /* pointer to next GUI_FONT_PROP_EXT */ |
reedas | 5:f62a9e4a499a | 430 | }; |
reedas | 5:f62a9e4a499a | 431 | |
reedas | 5:f62a9e4a499a | 432 | static GUI_CONST_STORAGE GUI_FONT GUI_Font32_AA4_Bounce = { |
reedas | 5:f62a9e4a499a | 433 | GUI_FONTTYPE_PROP_AA4_EXT /* type of font */ |
reedas | 5:f62a9e4a499a | 434 | ,32 /* height of font */ |
reedas | 5:f62a9e4a499a | 435 | ,32 /* space of font y */ |
reedas | 5:f62a9e4a499a | 436 | ,1 /* magnification x */ |
reedas | 5:f62a9e4a499a | 437 | ,1 /* magnification y */ |
reedas | 5:f62a9e4a499a | 438 | ,{&GUI_Font32_AA4_Bounce_Prop1} |
reedas | 5:f62a9e4a499a | 439 | ,26 /* Baseline */ |
reedas | 5:f62a9e4a499a | 440 | ,14 /* Height of lowercase characters */ |
reedas | 5:f62a9e4a499a | 441 | ,19 /* Height of capital characters */ |
reedas | 5:f62a9e4a499a | 442 | }; |
reedas | 5:f62a9e4a499a | 443 | |
reedas | 5:f62a9e4a499a | 444 | static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { |
reedas | 5:f62a9e4a499a | 445 | { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 280, 130, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 446 | { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 10, 10, 120, 20, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 447 | { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 10, 40, 120, 20, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 448 | { BUTTON_CreateIndirect, "Button", ID_BUTTON_2, 10, 100, 260, 20, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 449 | { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 150, 40, 120, 20, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 450 | { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_1, 150, 10, 120, 20, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 451 | { TEXT_CreateIndirect, "Text", ID_TEXT_0, 10, 73, 120, 20, 0, 0x64, 0 }, |
reedas | 5:f62a9e4a499a | 452 | { SLIDER_CreateIndirect, "Slider", ID_SLIDER_0, 150, 70, 120, 20, 0, 0x0, 0 }, |
reedas | 5:f62a9e4a499a | 453 | }; |
reedas | 5:f62a9e4a499a | 454 | |
reedas | 5:f62a9e4a499a | 455 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 456 | * |
reedas | 5:f62a9e4a499a | 457 | * Static code: Helper(s) |
reedas | 5:f62a9e4a499a | 458 | * |
reedas | 5:f62a9e4a499a | 459 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 460 | */ |
reedas | 5:f62a9e4a499a | 461 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 462 | * |
reedas | 5:f62a9e4a499a | 463 | * _Square |
reedas | 5:f62a9e4a499a | 464 | */ |
reedas | 5:f62a9e4a499a | 465 | static float _Square(float x) { |
reedas | 5:f62a9e4a499a | 466 | return x * x; |
reedas | 5:f62a9e4a499a | 467 | } |
reedas | 5:f62a9e4a499a | 468 | |
reedas | 5:f62a9e4a499a | 469 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 470 | * |
reedas | 5:f62a9e4a499a | 471 | * _GetRandomNumber |
reedas | 5:f62a9e4a499a | 472 | */ |
reedas | 5:f62a9e4a499a | 473 | static float _GetRandomNumber(float min, float max) { |
reedas | 5:f62a9e4a499a | 474 | return (max - min) * rand() / RAND_MAX + min; |
reedas | 5:f62a9e4a499a | 475 | } |
reedas | 5:f62a9e4a499a | 476 | |
reedas | 5:f62a9e4a499a | 477 | #ifdef WIN32 |
reedas | 5:f62a9e4a499a | 478 | static size_t _AllocatedBytes; |
reedas | 5:f62a9e4a499a | 479 | #endif |
reedas | 5:f62a9e4a499a | 480 | |
reedas | 5:f62a9e4a499a | 481 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 482 | * |
reedas | 5:f62a9e4a499a | 483 | * _Free |
reedas | 5:f62a9e4a499a | 484 | */ |
reedas | 5:f62a9e4a499a | 485 | static void _Free(void * p) { |
reedas | 5:f62a9e4a499a | 486 | #ifdef WIN32 |
reedas | 5:f62a9e4a499a | 487 | _AllocatedBytes -= _msize(p); |
reedas | 5:f62a9e4a499a | 488 | #endif |
reedas | 5:f62a9e4a499a | 489 | free(p); |
reedas | 5:f62a9e4a499a | 490 | } |
reedas | 5:f62a9e4a499a | 491 | |
reedas | 5:f62a9e4a499a | 492 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 493 | * |
reedas | 5:f62a9e4a499a | 494 | * _Calloc |
reedas | 5:f62a9e4a499a | 495 | */ |
reedas | 5:f62a9e4a499a | 496 | static void * _Calloc(size_t Num, size_t Size) { |
reedas | 5:f62a9e4a499a | 497 | void * p; |
reedas | 5:f62a9e4a499a | 498 | p = calloc(Num, Size); |
reedas | 5:f62a9e4a499a | 499 | #ifdef WIN32 |
reedas | 5:f62a9e4a499a | 500 | _AllocatedBytes += _msize(p); |
reedas | 5:f62a9e4a499a | 501 | #endif |
reedas | 5:f62a9e4a499a | 502 | return calloc(Num, Size); |
reedas | 5:f62a9e4a499a | 503 | } |
reedas | 5:f62a9e4a499a | 504 | |
reedas | 5:f62a9e4a499a | 505 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 506 | * |
reedas | 5:f62a9e4a499a | 507 | * Static code: VECTOR |
reedas | 5:f62a9e4a499a | 508 | * |
reedas | 5:f62a9e4a499a | 509 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 510 | */ |
reedas | 5:f62a9e4a499a | 511 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 512 | * |
reedas | 5:f62a9e4a499a | 513 | * _VECTOR_Create |
reedas | 5:f62a9e4a499a | 514 | */ |
reedas | 5:f62a9e4a499a | 515 | static VECTOR * _VECTOR_Create(float x, float y) { |
reedas | 5:f62a9e4a499a | 516 | VECTOR * pVectorNew; |
reedas | 5:f62a9e4a499a | 517 | |
reedas | 5:f62a9e4a499a | 518 | pVectorNew = (VECTOR *)_Calloc(sizeof(VECTOR), 1); |
reedas | 5:f62a9e4a499a | 519 | pVectorNew->x = x; |
reedas | 5:f62a9e4a499a | 520 | pVectorNew->y = y; |
reedas | 5:f62a9e4a499a | 521 | return pVectorNew; |
reedas | 5:f62a9e4a499a | 522 | } |
reedas | 5:f62a9e4a499a | 523 | |
reedas | 5:f62a9e4a499a | 524 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 525 | * |
reedas | 5:f62a9e4a499a | 526 | * _VECTOR_CreateCopy |
reedas | 5:f62a9e4a499a | 527 | */ |
reedas | 5:f62a9e4a499a | 528 | static VECTOR * _VECTOR_CreateCopy(VECTOR * pVector) { |
reedas | 5:f62a9e4a499a | 529 | return _VECTOR_Create(pVector->x, pVector->y); |
reedas | 5:f62a9e4a499a | 530 | } |
reedas | 5:f62a9e4a499a | 531 | |
reedas | 5:f62a9e4a499a | 532 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 533 | * |
reedas | 5:f62a9e4a499a | 534 | * _VECTOR_CreateCopyPlus |
reedas | 5:f62a9e4a499a | 535 | */ |
reedas | 5:f62a9e4a499a | 536 | static VECTOR * _VECTOR_CreateCopyPlus(VECTOR * pVector, VECTOR * pVector1) { |
reedas | 5:f62a9e4a499a | 537 | return _VECTOR_Create(pVector->x + pVector1->x, pVector->y + pVector1->y); |
reedas | 5:f62a9e4a499a | 538 | } |
reedas | 5:f62a9e4a499a | 539 | |
reedas | 5:f62a9e4a499a | 540 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 541 | * |
reedas | 5:f62a9e4a499a | 542 | * _VECTOR_CreateCopyMinus |
reedas | 5:f62a9e4a499a | 543 | */ |
reedas | 5:f62a9e4a499a | 544 | static VECTOR * _VECTOR_CreateCopyMinus(VECTOR * pVector, VECTOR * pVector1) { |
reedas | 5:f62a9e4a499a | 545 | return _VECTOR_Create(pVector->x - pVector1->x, pVector->y - pVector1->y); |
reedas | 5:f62a9e4a499a | 546 | } |
reedas | 5:f62a9e4a499a | 547 | |
reedas | 5:f62a9e4a499a | 548 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 549 | * |
reedas | 5:f62a9e4a499a | 550 | * _VECTOR_CreateCopyMult |
reedas | 5:f62a9e4a499a | 551 | */ |
reedas | 5:f62a9e4a499a | 552 | static VECTOR * _VECTOR_CreateCopyMult(VECTOR * pVector, float c) { |
reedas | 5:f62a9e4a499a | 553 | return _VECTOR_Create(pVector->x * c, pVector->y * c); |
reedas | 5:f62a9e4a499a | 554 | } |
reedas | 5:f62a9e4a499a | 555 | |
reedas | 5:f62a9e4a499a | 556 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 557 | * |
reedas | 5:f62a9e4a499a | 558 | * _VECTOR_Delete |
reedas | 5:f62a9e4a499a | 559 | */ |
reedas | 5:f62a9e4a499a | 560 | static void _VECTOR_Delete(VECTOR * pVector) { |
reedas | 5:f62a9e4a499a | 561 | _Free(pVector); |
reedas | 5:f62a9e4a499a | 562 | } |
reedas | 5:f62a9e4a499a | 563 | |
reedas | 5:f62a9e4a499a | 564 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 565 | * |
reedas | 5:f62a9e4a499a | 566 | * _VECTOR_SetX |
reedas | 5:f62a9e4a499a | 567 | */ |
reedas | 5:f62a9e4a499a | 568 | static void _VECTOR_SetX(VECTOR * pVector, float x) { |
reedas | 5:f62a9e4a499a | 569 | pVector->x = x; |
reedas | 5:f62a9e4a499a | 570 | } |
reedas | 5:f62a9e4a499a | 571 | |
reedas | 5:f62a9e4a499a | 572 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 573 | * |
reedas | 5:f62a9e4a499a | 574 | * _VECTOR_SetY |
reedas | 5:f62a9e4a499a | 575 | */ |
reedas | 5:f62a9e4a499a | 576 | static void _VECTOR_SetY(VECTOR * pVector, float y) { |
reedas | 5:f62a9e4a499a | 577 | pVector->y = y; |
reedas | 5:f62a9e4a499a | 578 | } |
reedas | 5:f62a9e4a499a | 579 | |
reedas | 5:f62a9e4a499a | 580 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 581 | * |
reedas | 5:f62a9e4a499a | 582 | * _VECTOR_SetXY |
reedas | 5:f62a9e4a499a | 583 | */ |
reedas | 5:f62a9e4a499a | 584 | static void _VECTOR_SetXY(VECTOR * pVector, float x, float y) { |
reedas | 5:f62a9e4a499a | 585 | pVector->x = x; |
reedas | 5:f62a9e4a499a | 586 | pVector->y = y; |
reedas | 5:f62a9e4a499a | 587 | } |
reedas | 5:f62a9e4a499a | 588 | |
reedas | 5:f62a9e4a499a | 589 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 590 | * |
reedas | 5:f62a9e4a499a | 591 | * _VECTOR_Magnitude |
reedas | 5:f62a9e4a499a | 592 | */ |
reedas | 5:f62a9e4a499a | 593 | static float _VECTOR_Magnitude(VECTOR * pVector) { |
reedas | 5:f62a9e4a499a | 594 | return sqrt(pVector->x * pVector->x + pVector->y * pVector->y); |
reedas | 5:f62a9e4a499a | 595 | } |
reedas | 5:f62a9e4a499a | 596 | |
reedas | 5:f62a9e4a499a | 597 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 598 | * |
reedas | 5:f62a9e4a499a | 599 | * _VECTOR_CreateUnitVector |
reedas | 5:f62a9e4a499a | 600 | */ |
reedas | 5:f62a9e4a499a | 601 | static VECTOR * _VECTOR_CreateUnitVector(VECTOR * pVector) { |
reedas | 5:f62a9e4a499a | 602 | VECTOR * pVectorNew; |
reedas | 5:f62a9e4a499a | 603 | float Mag; |
reedas | 5:f62a9e4a499a | 604 | |
reedas | 5:f62a9e4a499a | 605 | Mag = _VECTOR_Magnitude(pVector); |
reedas | 5:f62a9e4a499a | 606 | if (Mag != 0.f) { |
reedas | 5:f62a9e4a499a | 607 | pVectorNew = _VECTOR_Create(pVector->x / Mag, pVector->y / Mag); |
reedas | 5:f62a9e4a499a | 608 | } else { |
reedas | 5:f62a9e4a499a | 609 | pVectorNew = _VECTOR_Create(0.f, 0.f); |
reedas | 5:f62a9e4a499a | 610 | } |
reedas | 5:f62a9e4a499a | 611 | return pVectorNew; |
reedas | 5:f62a9e4a499a | 612 | } |
reedas | 5:f62a9e4a499a | 613 | |
reedas | 5:f62a9e4a499a | 614 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 615 | * |
reedas | 5:f62a9e4a499a | 616 | * _VECTOR_DotProduct |
reedas | 5:f62a9e4a499a | 617 | */ |
reedas | 5:f62a9e4a499a | 618 | static float _VECTOR_DotProduct(VECTOR * pVector, VECTOR * pVector1) { |
reedas | 5:f62a9e4a499a | 619 | float DotProduct; |
reedas | 5:f62a9e4a499a | 620 | |
reedas | 5:f62a9e4a499a | 621 | DotProduct = pVector->x * pVector1->x + pVector->y * pVector1->y; |
reedas | 5:f62a9e4a499a | 622 | return DotProduct; |
reedas | 5:f62a9e4a499a | 623 | } |
reedas | 5:f62a9e4a499a | 624 | |
reedas | 5:f62a9e4a499a | 625 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 626 | * |
reedas | 5:f62a9e4a499a | 627 | * Static code: WALLS |
reedas | 5:f62a9e4a499a | 628 | * |
reedas | 5:f62a9e4a499a | 629 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 630 | */ |
reedas | 5:f62a9e4a499a | 631 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 632 | * |
reedas | 5:f62a9e4a499a | 633 | * _WALLS_Create |
reedas | 5:f62a9e4a499a | 634 | */ |
reedas | 5:f62a9e4a499a | 635 | static WALLS * _WALLS_Create(float x1, float y1, float x2, float y2) { |
reedas | 5:f62a9e4a499a | 636 | WALLS * pWall; |
reedas | 5:f62a9e4a499a | 637 | |
reedas | 5:f62a9e4a499a | 638 | pWall = (WALLS *)_Calloc(sizeof(WALLS), 1); |
reedas | 5:f62a9e4a499a | 639 | pWall->x1 = x1; |
reedas | 5:f62a9e4a499a | 640 | pWall->y1 = y1; |
reedas | 5:f62a9e4a499a | 641 | pWall->x2 = x2; |
reedas | 5:f62a9e4a499a | 642 | pWall->y2 = y2; |
reedas | 5:f62a9e4a499a | 643 | return pWall; |
reedas | 5:f62a9e4a499a | 644 | } |
reedas | 5:f62a9e4a499a | 645 | |
reedas | 5:f62a9e4a499a | 646 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 647 | * |
reedas | 5:f62a9e4a499a | 648 | * _WALLS_CreateEmpty |
reedas | 5:f62a9e4a499a | 649 | */ |
reedas | 5:f62a9e4a499a | 650 | static WALLS * _WALLS_CreateEmpty(void) { |
reedas | 5:f62a9e4a499a | 651 | return _WALLS_Create(0.f, 0.f, 0.f, 0.f); |
reedas | 5:f62a9e4a499a | 652 | } |
reedas | 5:f62a9e4a499a | 653 | |
reedas | 5:f62a9e4a499a | 654 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 655 | * |
reedas | 5:f62a9e4a499a | 656 | * Static code: BALL |
reedas | 5:f62a9e4a499a | 657 | * |
reedas | 5:f62a9e4a499a | 658 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 659 | */ |
reedas | 5:f62a9e4a499a | 660 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 661 | * |
reedas | 5:f62a9e4a499a | 662 | * _BALL_Create |
reedas | 5:f62a9e4a499a | 663 | */ |
reedas | 5:f62a9e4a499a | 664 | static BALL * _BALL_Create(void) { |
reedas | 5:f62a9e4a499a | 665 | BALL * pBall; |
reedas | 5:f62a9e4a499a | 666 | |
reedas | 5:f62a9e4a499a | 667 | pBall = (BALL *)_Calloc(sizeof(BALL), 1); |
reedas | 5:f62a9e4a499a | 668 | pBall->m = 0.f; |
reedas | 5:f62a9e4a499a | 669 | pBall->r = 0.f; |
reedas | 5:f62a9e4a499a | 670 | return pBall; |
reedas | 5:f62a9e4a499a | 671 | } |
reedas | 5:f62a9e4a499a | 672 | |
reedas | 5:f62a9e4a499a | 673 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 674 | * |
reedas | 5:f62a9e4a499a | 675 | * _BALL_AdvanceBallPosition |
reedas | 5:f62a9e4a499a | 676 | */ |
reedas | 5:f62a9e4a499a | 677 | static void _BALL_AdvanceBallPosition(BALL * pBall, const float dt) { |
reedas | 5:f62a9e4a499a | 678 | _VECTOR_SetXY(&pBall->p, pBall->p.x + pBall->v.x * dt, pBall->p.y + pBall->v.y * dt); |
reedas | 5:f62a9e4a499a | 679 | } |
reedas | 5:f62a9e4a499a | 680 | |
reedas | 5:f62a9e4a499a | 681 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 682 | * |
reedas | 5:f62a9e4a499a | 683 | * _BALL_DoBallGravity |
reedas | 5:f62a9e4a499a | 684 | */ |
reedas | 5:f62a9e4a499a | 685 | static void _BALL_DoBallGravity(BALL * pb0, BALL * pb1, const float dt, float g) { |
reedas | 5:f62a9e4a499a | 686 | VECTOR * v_n; |
reedas | 5:f62a9e4a499a | 687 | VECTOR * v_un; |
reedas | 5:f62a9e4a499a | 688 | float r, f, a0, a1, v0, v1; |
reedas | 5:f62a9e4a499a | 689 | |
reedas | 5:f62a9e4a499a | 690 | v_n = _VECTOR_CreateCopyMinus(&pb0->p, &pb1->p); // v_n = normal vec. - a vector normal to the collision surface |
reedas | 5:f62a9e4a499a | 691 | v_un = _VECTOR_CreateUnitVector(v_n); // unit normal vector |
reedas | 5:f62a9e4a499a | 692 | r = _VECTOR_Magnitude(v_n); |
reedas | 5:f62a9e4a499a | 693 | f = g * (pb0->m * pb1->m) / (r * r); |
reedas | 5:f62a9e4a499a | 694 | a0 = f / pb0->m; |
reedas | 5:f62a9e4a499a | 695 | a1 = f / pb1->m; |
reedas | 5:f62a9e4a499a | 696 | v0 = a0 * dt; |
reedas | 5:f62a9e4a499a | 697 | v1 = a1 * dt; |
reedas | 5:f62a9e4a499a | 698 | _VECTOR_SetXY(&pb0->v, pb0->v.x - v_un->x * v0, pb0->v.y - v_un->y * v0); |
reedas | 5:f62a9e4a499a | 699 | _VECTOR_SetXY(&pb1->v, pb1->v.x + v_un->x * v1, pb1->v.y + v_un->y * v1); |
reedas | 5:f62a9e4a499a | 700 | _VECTOR_Delete(v_n); |
reedas | 5:f62a9e4a499a | 701 | _VECTOR_Delete(v_un); |
reedas | 5:f62a9e4a499a | 702 | } |
reedas | 5:f62a9e4a499a | 703 | |
reedas | 5:f62a9e4a499a | 704 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 705 | * |
reedas | 5:f62a9e4a499a | 706 | * _BALL_DoGroundGravity |
reedas | 5:f62a9e4a499a | 707 | */ |
reedas | 5:f62a9e4a499a | 708 | static void _BALL_DoGroundGravity(BALL * pb, const float dt, float g) { |
reedas | 5:f62a9e4a499a | 709 | _VECTOR_SetY(&pb->v, pb->v.y + g * dt * 0.95); |
reedas | 5:f62a9e4a499a | 710 | } |
reedas | 5:f62a9e4a499a | 711 | |
reedas | 5:f62a9e4a499a | 712 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 713 | * |
reedas | 5:f62a9e4a499a | 714 | * Static code: COLLISION |
reedas | 5:f62a9e4a499a | 715 | * |
reedas | 5:f62a9e4a499a | 716 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 717 | */ |
reedas | 5:f62a9e4a499a | 718 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 719 | * |
reedas | 5:f62a9e4a499a | 720 | * _COLLISION_Reset |
reedas | 5:f62a9e4a499a | 721 | */ |
reedas | 5:f62a9e4a499a | 722 | static void _COLLISION_Reset(COLLISION * pCollision) { |
reedas | 5:f62a9e4a499a | 723 | pCollision->CollisionType = TYPE_NONE; |
reedas | 5:f62a9e4a499a | 724 | pCollision->WhichWall = WALL_NONE; |
reedas | 5:f62a9e4a499a | 725 | pCollision->TimeToCollision = 0.f; |
reedas | 5:f62a9e4a499a | 726 | } |
reedas | 5:f62a9e4a499a | 727 | |
reedas | 5:f62a9e4a499a | 728 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 729 | * |
reedas | 5:f62a9e4a499a | 730 | * _COLLISION_Create |
reedas | 5:f62a9e4a499a | 731 | */ |
reedas | 5:f62a9e4a499a | 732 | static COLLISION * _COLLISION_Create(void) { |
reedas | 5:f62a9e4a499a | 733 | COLLISION * pCollision; |
reedas | 5:f62a9e4a499a | 734 | |
reedas | 5:f62a9e4a499a | 735 | pCollision = (COLLISION *)_Calloc(sizeof(COLLISION), 1); |
reedas | 5:f62a9e4a499a | 736 | _COLLISION_Reset(pCollision); |
reedas | 5:f62a9e4a499a | 737 | return pCollision; |
reedas | 5:f62a9e4a499a | 738 | } |
reedas | 5:f62a9e4a499a | 739 | |
reedas | 5:f62a9e4a499a | 740 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 741 | * |
reedas | 5:f62a9e4a499a | 742 | * _COLLISION_SetCollisionWithWall |
reedas | 5:f62a9e4a499a | 743 | */ |
reedas | 5:f62a9e4a499a | 744 | static void _COLLISION_SetCollisionWithWall(COLLISION * pCollision, const float t, int WhichWall) { |
reedas | 5:f62a9e4a499a | 745 | pCollision->CollisionType = TYPE_WALL; |
reedas | 5:f62a9e4a499a | 746 | pCollision->WhichWall = WhichWall; |
reedas | 5:f62a9e4a499a | 747 | pCollision->TimeToCollision = t; |
reedas | 5:f62a9e4a499a | 748 | } |
reedas | 5:f62a9e4a499a | 749 | |
reedas | 5:f62a9e4a499a | 750 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 751 | * |
reedas | 5:f62a9e4a499a | 752 | * _COLLISION_SetCollisionWithBall |
reedas | 5:f62a9e4a499a | 753 | */ |
reedas | 5:f62a9e4a499a | 754 | static void _COLLISION_SetCollisionWithBall(COLLISION * pCollision, const float t) { |
reedas | 5:f62a9e4a499a | 755 | pCollision->CollisionType = TYPE_BALL; |
reedas | 5:f62a9e4a499a | 756 | pCollision->WhichWall = WALL_NONE; |
reedas | 5:f62a9e4a499a | 757 | pCollision->TimeToCollision = t; |
reedas | 5:f62a9e4a499a | 758 | } |
reedas | 5:f62a9e4a499a | 759 | |
reedas | 5:f62a9e4a499a | 760 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 761 | * |
reedas | 5:f62a9e4a499a | 762 | * _COLLISION_Ball1HasCollision |
reedas | 5:f62a9e4a499a | 763 | */ |
reedas | 5:f62a9e4a499a | 764 | static int _COLLISION_Ball1HasCollision(COLLISION * pCollision) { |
reedas | 5:f62a9e4a499a | 765 | return pCollision->CollisionType != TYPE_NONE; |
reedas | 5:f62a9e4a499a | 766 | } |
reedas | 5:f62a9e4a499a | 767 | |
reedas | 5:f62a9e4a499a | 768 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 769 | * |
reedas | 5:f62a9e4a499a | 770 | * _COLLISION_Ball2HasCollision |
reedas | 5:f62a9e4a499a | 771 | */ |
reedas | 5:f62a9e4a499a | 772 | static int _COLLISION_Ball2HasCollision(COLLISION * pCollision) { |
reedas | 5:f62a9e4a499a | 773 | return pCollision->CollisionType == TYPE_BALL; |
reedas | 5:f62a9e4a499a | 774 | } |
reedas | 5:f62a9e4a499a | 775 | |
reedas | 5:f62a9e4a499a | 776 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 777 | * |
reedas | 5:f62a9e4a499a | 778 | * _COLLISION_Ball1HasCollisionWithWall |
reedas | 5:f62a9e4a499a | 779 | */ |
reedas | 5:f62a9e4a499a | 780 | static int _COLLISION_Ball1HasCollisionWithWall(COLLISION * pCollision) { |
reedas | 5:f62a9e4a499a | 781 | return pCollision->CollisionType == TYPE_WALL; |
reedas | 5:f62a9e4a499a | 782 | } |
reedas | 5:f62a9e4a499a | 783 | |
reedas | 5:f62a9e4a499a | 784 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 785 | * |
reedas | 5:f62a9e4a499a | 786 | * _COLLISION_Ball1HasCollisionWithBall |
reedas | 5:f62a9e4a499a | 787 | */ |
reedas | 5:f62a9e4a499a | 788 | static int _COLLISION_Ball1HasCollisionWithBall(COLLISION * pCollision) { |
reedas | 5:f62a9e4a499a | 789 | return pCollision->CollisionType == TYPE_BALL; |
reedas | 5:f62a9e4a499a | 790 | } |
reedas | 5:f62a9e4a499a | 791 | |
reedas | 5:f62a9e4a499a | 792 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 793 | * |
reedas | 5:f62a9e4a499a | 794 | * _COLLISION_GetCollisionWall |
reedas | 5:f62a9e4a499a | 795 | */ |
reedas | 5:f62a9e4a499a | 796 | static int _COLLISION_GetCollisionWall(COLLISION * pCollision) { |
reedas | 5:f62a9e4a499a | 797 | return (int)pCollision->WhichWall; |
reedas | 5:f62a9e4a499a | 798 | } |
reedas | 5:f62a9e4a499a | 799 | |
reedas | 5:f62a9e4a499a | 800 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 801 | * |
reedas | 5:f62a9e4a499a | 802 | * _COLLISION_FindTimeUntilTwoBallsCollide |
reedas | 5:f62a9e4a499a | 803 | * |
reedas | 5:f62a9e4a499a | 804 | * Function description: |
reedas | 5:f62a9e4a499a | 805 | * Finds the time until two specified balls collide. If they don't collide, |
reedas | 5:f62a9e4a499a | 806 | * the returned Collision will indicate that. If the balls are overlapping |
reedas | 5:f62a9e4a499a | 807 | * a collision is NOT detected. |
reedas | 5:f62a9e4a499a | 808 | */ |
reedas | 5:f62a9e4a499a | 809 | static COLLISION _COLLISION_FindTimeUntilTwoBallsCollide(const BALL * pb1, const BALL * pb2) { |
reedas | 5:f62a9e4a499a | 810 | COLLISION clsn = {0}; |
reedas | 5:f62a9e4a499a | 811 | float a, b, c, det, t; |
reedas | 5:f62a9e4a499a | 812 | |
reedas | 5:f62a9e4a499a | 813 | // Compute parts of quadratic formula |
reedas | 5:f62a9e4a499a | 814 | // |
reedas | 5:f62a9e4a499a | 815 | // a = (v2x - v1x) ^ 2 + (v2y - v1y) ^ 2 |
reedas | 5:f62a9e4a499a | 816 | // |
reedas | 5:f62a9e4a499a | 817 | a = _Square(pb2->v.x - pb1->v.x) + _Square(pb2->v.y - pb1->v.y); |
reedas | 5:f62a9e4a499a | 818 | // |
reedas | 5:f62a9e4a499a | 819 | // b = 2 * ((x20 - x10) * (v2x - v1x) + (y20 - y10) * (v2y - v1y)) |
reedas | 5:f62a9e4a499a | 820 | // |
reedas | 5:f62a9e4a499a | 821 | b = 2.f * ((pb2->p.x - pb1->p.x) * (pb2->v.x - pb1->v.x) + (pb2->p.y - pb1->p.y) * (pb2->v.y - pb1->v.y)); |
reedas | 5:f62a9e4a499a | 822 | // |
reedas | 5:f62a9e4a499a | 823 | // c = (x20 - x10) ^ 2 + (y20 - y10) ^ 2 - (r1 + r2) ^ 2 |
reedas | 5:f62a9e4a499a | 824 | // |
reedas | 5:f62a9e4a499a | 825 | c = _Square(pb2->p.x - pb1->p.x) + _Square(pb2->p.y - pb1->p.y) - _Square(pb1->r + pb2->r); |
reedas | 5:f62a9e4a499a | 826 | // |
reedas | 5:f62a9e4a499a | 827 | // Determinant = b^2 - 4ac |
reedas | 5:f62a9e4a499a | 828 | // |
reedas | 5:f62a9e4a499a | 829 | det = _Square(b) - 4 * a * c; |
reedas | 5:f62a9e4a499a | 830 | if (a != 0.f) { // If a == 0 then v2x==v1x and v2y==v1y and there will be no collision |
reedas | 5:f62a9e4a499a | 831 | t = (-b - sqrt(det)) / (2. * a); // Quadratic formula. t = time to collision |
reedas | 5:f62a9e4a499a | 832 | if (t >= 0.) { // If collision occurs... |
reedas | 5:f62a9e4a499a | 833 | _COLLISION_SetCollisionWithBall(&clsn, t); |
reedas | 5:f62a9e4a499a | 834 | } |
reedas | 5:f62a9e4a499a | 835 | } |
reedas | 5:f62a9e4a499a | 836 | return clsn; |
reedas | 5:f62a9e4a499a | 837 | } |
reedas | 5:f62a9e4a499a | 838 | |
reedas | 5:f62a9e4a499a | 839 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 840 | * |
reedas | 5:f62a9e4a499a | 841 | * _COLLISION_FindTimeUntilBallCollidesWithWall |
reedas | 5:f62a9e4a499a | 842 | * |
reedas | 5:f62a9e4a499a | 843 | * Function description: |
reedas | 5:f62a9e4a499a | 844 | * Finds time until specified ball collides with any wall. If they |
reedas | 5:f62a9e4a499a | 845 | * don't collide, the returned Collision indicates that. If there |
reedas | 5:f62a9e4a499a | 846 | * will be collisions with more than one wall, this function returns |
reedas | 5:f62a9e4a499a | 847 | * the earliest collision. |
reedas | 5:f62a9e4a499a | 848 | * |
reedas | 5:f62a9e4a499a | 849 | * IMPORTANT: This function assumes that the ball is bounded within |
reedas | 5:f62a9e4a499a | 850 | * the specified walls. |
reedas | 5:f62a9e4a499a | 851 | */ |
reedas | 5:f62a9e4a499a | 852 | static COLLISION _COLLISION_FindTimeUntilBallCollidesWithWall(const BALL * pb, const WALLS * pw) { |
reedas | 5:f62a9e4a499a | 853 | COLLISION clsn = {0}; |
reedas | 5:f62a9e4a499a | 854 | float timeToCollision; |
reedas | 5:f62a9e4a499a | 855 | float t; |
reedas | 5:f62a9e4a499a | 856 | int whichWall; |
reedas | 5:f62a9e4a499a | 857 | |
reedas | 5:f62a9e4a499a | 858 | timeToCollision = 0.f; |
reedas | 5:f62a9e4a499a | 859 | whichWall = WALL_NONE; |
reedas | 5:f62a9e4a499a | 860 | // |
reedas | 5:f62a9e4a499a | 861 | // Check for collision with wall X1 |
reedas | 5:f62a9e4a499a | 862 | // |
reedas | 5:f62a9e4a499a | 863 | if (pb->v.x < 0.f) { |
reedas | 5:f62a9e4a499a | 864 | t = (pb->r - pb->p.x + pw->x1) / pb->v.x; |
reedas | 5:f62a9e4a499a | 865 | if (t >= 0.f) { // If t < 0 then ball is headed away from wall |
reedas | 5:f62a9e4a499a | 866 | timeToCollision = t; |
reedas | 5:f62a9e4a499a | 867 | whichWall = WALL_X1; |
reedas | 5:f62a9e4a499a | 868 | } |
reedas | 5:f62a9e4a499a | 869 | } |
reedas | 5:f62a9e4a499a | 870 | // |
reedas | 5:f62a9e4a499a | 871 | // Check for collision with wall Y1 |
reedas | 5:f62a9e4a499a | 872 | // |
reedas | 5:f62a9e4a499a | 873 | if (pb->v.y < 0.f) { |
reedas | 5:f62a9e4a499a | 874 | t = (pb->r - pb->p.y + pw->y1) / pb->v.y; |
reedas | 5:f62a9e4a499a | 875 | if (t >= 0.f) { |
reedas | 5:f62a9e4a499a | 876 | if (whichWall == WALL_NONE || t < timeToCollision) { |
reedas | 5:f62a9e4a499a | 877 | timeToCollision = t; |
reedas | 5:f62a9e4a499a | 878 | whichWall = WALL_Y1; |
reedas | 5:f62a9e4a499a | 879 | } |
reedas | 5:f62a9e4a499a | 880 | } |
reedas | 5:f62a9e4a499a | 881 | } |
reedas | 5:f62a9e4a499a | 882 | // |
reedas | 5:f62a9e4a499a | 883 | // Check for collision with wall X2 |
reedas | 5:f62a9e4a499a | 884 | // |
reedas | 5:f62a9e4a499a | 885 | if (pb->v.x > 0.f) { |
reedas | 5:f62a9e4a499a | 886 | t = (pw->x2 - pb->r - pb->p.x) / pb->v.x; |
reedas | 5:f62a9e4a499a | 887 | if (t >= 0.f) { |
reedas | 5:f62a9e4a499a | 888 | if (whichWall == WALL_NONE || t < timeToCollision) { |
reedas | 5:f62a9e4a499a | 889 | timeToCollision = t; |
reedas | 5:f62a9e4a499a | 890 | whichWall = WALL_X2; |
reedas | 5:f62a9e4a499a | 891 | } |
reedas | 5:f62a9e4a499a | 892 | } |
reedas | 5:f62a9e4a499a | 893 | } |
reedas | 5:f62a9e4a499a | 894 | // |
reedas | 5:f62a9e4a499a | 895 | // Check for collision with wall Y2 |
reedas | 5:f62a9e4a499a | 896 | // |
reedas | 5:f62a9e4a499a | 897 | if (pb->v.y > 0.f) { |
reedas | 5:f62a9e4a499a | 898 | t = (pw->y2 - pb->r - pb->p.y) / pb->v.y; |
reedas | 5:f62a9e4a499a | 899 | if (t >= 0.f) { |
reedas | 5:f62a9e4a499a | 900 | if (whichWall == WALL_NONE || t < timeToCollision) { |
reedas | 5:f62a9e4a499a | 901 | timeToCollision = t; |
reedas | 5:f62a9e4a499a | 902 | whichWall = WALL_Y2; |
reedas | 5:f62a9e4a499a | 903 | } |
reedas | 5:f62a9e4a499a | 904 | } |
reedas | 5:f62a9e4a499a | 905 | } |
reedas | 5:f62a9e4a499a | 906 | // |
reedas | 5:f62a9e4a499a | 907 | // Setup Collision return value |
reedas | 5:f62a9e4a499a | 908 | // |
reedas | 5:f62a9e4a499a | 909 | if (whichWall != WALL_NONE) { // If there is a collision... |
reedas | 5:f62a9e4a499a | 910 | _COLLISION_SetCollisionWithWall(&clsn, timeToCollision, whichWall); |
reedas | 5:f62a9e4a499a | 911 | } |
reedas | 5:f62a9e4a499a | 912 | return clsn; |
reedas | 5:f62a9e4a499a | 913 | } |
reedas | 5:f62a9e4a499a | 914 | |
reedas | 5:f62a9e4a499a | 915 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 916 | * |
reedas | 5:f62a9e4a499a | 917 | * _COLLISION_DoElasticCollisionTwoBalls |
reedas | 5:f62a9e4a499a | 918 | * |
reedas | 5:f62a9e4a499a | 919 | * Function description: |
reedas | 5:f62a9e4a499a | 920 | * Updates the velocities of b1 and b2 to reflect the effect of an elastic |
reedas | 5:f62a9e4a499a | 921 | * collision between the two. IMPORTANT: This function does NOT check the |
reedas | 5:f62a9e4a499a | 922 | * positions of the balls to see if they're actually colliding. It just |
reedas | 5:f62a9e4a499a | 923 | * assumes that they are. Use findTimeUntilTwoBallsCollide() to see |
reedas | 5:f62a9e4a499a | 924 | * if the balls are colliding. |
reedas | 5:f62a9e4a499a | 925 | */ |
reedas | 5:f62a9e4a499a | 926 | static void _COLLISION_DoElasticCollisionTwoBalls(BALL * pb1, BALL * pb2) { |
reedas | 5:f62a9e4a499a | 927 | VECTOR * v_n; |
reedas | 5:f62a9e4a499a | 928 | VECTOR * v_un; |
reedas | 5:f62a9e4a499a | 929 | VECTOR * v_ut; |
reedas | 5:f62a9e4a499a | 930 | VECTOR * v_v1nPrime; |
reedas | 5:f62a9e4a499a | 931 | VECTOR * v_v1tPrime; |
reedas | 5:f62a9e4a499a | 932 | VECTOR * v_v2nPrime; |
reedas | 5:f62a9e4a499a | 933 | VECTOR * v_v2tPrime; |
reedas | 5:f62a9e4a499a | 934 | float v1n, v1t, v2n, v2t; |
reedas | 5:f62a9e4a499a | 935 | float v1tPrime, v2tPrime; |
reedas | 5:f62a9e4a499a | 936 | float v1nPrime, v2nPrime; |
reedas | 5:f62a9e4a499a | 937 | |
reedas | 5:f62a9e4a499a | 938 | // |
reedas | 5:f62a9e4a499a | 939 | // Avoid division by zero below in computing new normal velocities |
reedas | 5:f62a9e4a499a | 940 | // Doing a collision where both balls have no mass makes no sense anyway |
reedas | 5:f62a9e4a499a | 941 | // |
reedas | 5:f62a9e4a499a | 942 | if ((pb1->m == 0.f) && (pb2->m == 0.f)) { |
reedas | 5:f62a9e4a499a | 943 | return; |
reedas | 5:f62a9e4a499a | 944 | } |
reedas | 5:f62a9e4a499a | 945 | // |
reedas | 5:f62a9e4a499a | 946 | // Compute unit normal and unit tangent vectors |
reedas | 5:f62a9e4a499a | 947 | // |
reedas | 5:f62a9e4a499a | 948 | v_n = _VECTOR_CreateCopyMinus(&pb2->p, &pb1->p); // v_n = normal vec. - a vector normal to the collision surface |
reedas | 5:f62a9e4a499a | 949 | v_un = _VECTOR_CreateUnitVector(v_n); // unit normal vector |
reedas | 5:f62a9e4a499a | 950 | v_ut = _VECTOR_Create(-v_un->y, v_un->x); // unit tangent vector |
reedas | 5:f62a9e4a499a | 951 | // |
reedas | 5:f62a9e4a499a | 952 | // Compute scalar projections of velocities onto v_un and v_ut |
reedas | 5:f62a9e4a499a | 953 | // |
reedas | 5:f62a9e4a499a | 954 | v1n = _VECTOR_DotProduct(v_un, &pb1->v); // Dot product |
reedas | 5:f62a9e4a499a | 955 | v1t = _VECTOR_DotProduct(v_ut, &pb1->v); |
reedas | 5:f62a9e4a499a | 956 | v2n = _VECTOR_DotProduct(v_un, &pb2->v); |
reedas | 5:f62a9e4a499a | 957 | v2t = _VECTOR_DotProduct(v_ut, &pb2->v); |
reedas | 5:f62a9e4a499a | 958 | // |
reedas | 5:f62a9e4a499a | 959 | // Compute new tangential velocities |
reedas | 5:f62a9e4a499a | 960 | // |
reedas | 5:f62a9e4a499a | 961 | v1tPrime = v1t; // Note: in reality, the tangential velocities do not change after the collision |
reedas | 5:f62a9e4a499a | 962 | v2tPrime = v2t; |
reedas | 5:f62a9e4a499a | 963 | // |
reedas | 5:f62a9e4a499a | 964 | // Compute new normal velocities using one-dimensional elastic collision equations in the normal direction |
reedas | 5:f62a9e4a499a | 965 | // Division by zero avoided. See early return above. |
reedas | 5:f62a9e4a499a | 966 | // |
reedas | 5:f62a9e4a499a | 967 | v1nPrime = (v1n * (pb1->m - pb2->m) + 2.f * pb2->m * v2n) / (pb1->m + pb2->m); |
reedas | 5:f62a9e4a499a | 968 | v2nPrime = (v2n * (pb2->m - pb1->m) + 2.f * pb1->m * v1n) / (pb1->m + pb2->m); |
reedas | 5:f62a9e4a499a | 969 | // |
reedas | 5:f62a9e4a499a | 970 | // Compute new normal and tangential velocity vectors |
reedas | 5:f62a9e4a499a | 971 | // |
reedas | 5:f62a9e4a499a | 972 | v_v1nPrime = _VECTOR_CreateCopyMult(v_un, v1nPrime); // Multiplication by a scalar |
reedas | 5:f62a9e4a499a | 973 | v_v1tPrime = _VECTOR_CreateCopyMult(v_ut, v1tPrime); |
reedas | 5:f62a9e4a499a | 974 | v_v2nPrime = _VECTOR_CreateCopyMult(v_un, v2nPrime); |
reedas | 5:f62a9e4a499a | 975 | v_v2tPrime = _VECTOR_CreateCopyMult(v_ut, v2tPrime); |
reedas | 5:f62a9e4a499a | 976 | // |
reedas | 5:f62a9e4a499a | 977 | // Set new velocities in x and y coordinates |
reedas | 5:f62a9e4a499a | 978 | // |
reedas | 5:f62a9e4a499a | 979 | _VECTOR_SetXY(&pb1->v, v_v1nPrime->x + v_v1tPrime->x, v_v1nPrime->y + v_v1tPrime->y); |
reedas | 5:f62a9e4a499a | 980 | _VECTOR_SetXY(&pb2->v, v_v2nPrime->x + v_v2tPrime->x, v_v2nPrime->y + v_v2tPrime->y); |
reedas | 5:f62a9e4a499a | 981 | // |
reedas | 5:f62a9e4a499a | 982 | // CleanUp |
reedas | 5:f62a9e4a499a | 983 | // |
reedas | 5:f62a9e4a499a | 984 | _VECTOR_Delete(v_n); |
reedas | 5:f62a9e4a499a | 985 | _VECTOR_Delete(v_un); |
reedas | 5:f62a9e4a499a | 986 | _VECTOR_Delete(v_ut); |
reedas | 5:f62a9e4a499a | 987 | _VECTOR_Delete(v_v1nPrime); |
reedas | 5:f62a9e4a499a | 988 | _VECTOR_Delete(v_v1tPrime); |
reedas | 5:f62a9e4a499a | 989 | _VECTOR_Delete(v_v2nPrime); |
reedas | 5:f62a9e4a499a | 990 | _VECTOR_Delete(v_v2tPrime); |
reedas | 5:f62a9e4a499a | 991 | } |
reedas | 5:f62a9e4a499a | 992 | |
reedas | 5:f62a9e4a499a | 993 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 994 | * |
reedas | 5:f62a9e4a499a | 995 | * _COLLISION_DoElasticCollisionWithWall |
reedas | 5:f62a9e4a499a | 996 | */ |
reedas | 5:f62a9e4a499a | 997 | static void _COLLISION_DoElasticCollisionWithWall(BALL * pb, int w) { |
reedas | 5:f62a9e4a499a | 998 | switch (w) { |
reedas | 5:f62a9e4a499a | 999 | case WALL_X1: |
reedas | 5:f62a9e4a499a | 1000 | _VECTOR_SetX(&pb->v, fabs(pb->v.x)); |
reedas | 5:f62a9e4a499a | 1001 | break; |
reedas | 5:f62a9e4a499a | 1002 | case WALL_Y1: |
reedas | 5:f62a9e4a499a | 1003 | _VECTOR_SetY(&pb->v, fabs(pb->v.y)); |
reedas | 5:f62a9e4a499a | 1004 | break; |
reedas | 5:f62a9e4a499a | 1005 | case WALL_X2: |
reedas | 5:f62a9e4a499a | 1006 | _VECTOR_SetX(&pb->v, -fabs(pb->v.x)); |
reedas | 5:f62a9e4a499a | 1007 | break; |
reedas | 5:f62a9e4a499a | 1008 | case WALL_Y2: |
reedas | 5:f62a9e4a499a | 1009 | _VECTOR_SetY(&pb->v, -fabs(pb->v.y)); |
reedas | 5:f62a9e4a499a | 1010 | break; |
reedas | 5:f62a9e4a499a | 1011 | } |
reedas | 5:f62a9e4a499a | 1012 | } |
reedas | 5:f62a9e4a499a | 1013 | |
reedas | 5:f62a9e4a499a | 1014 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1015 | * |
reedas | 5:f62a9e4a499a | 1016 | * Static code: BALLSIM |
reedas | 5:f62a9e4a499a | 1017 | * |
reedas | 5:f62a9e4a499a | 1018 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 1019 | */ |
reedas | 5:f62a9e4a499a | 1020 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1021 | * |
reedas | 5:f62a9e4a499a | 1022 | * _BALLSIM_ResetBalls |
reedas | 5:f62a9e4a499a | 1023 | */ |
reedas | 5:f62a9e4a499a | 1024 | static void _BALLSIM_ResetBalls(BALLSIM * pBallsim) { |
reedas | 5:f62a9e4a499a | 1025 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1026 | BALL * pBalld; |
reedas | 5:f62a9e4a499a | 1027 | |
reedas | 5:f62a9e4a499a | 1028 | pBallsim->NextId = 0; // Reset ID counter |
reedas | 5:f62a9e4a499a | 1029 | pBallsim->MinArea = 0.; |
reedas | 5:f62a9e4a499a | 1030 | pBallsim->MaxDiameter = 0.; |
reedas | 5:f62a9e4a499a | 1031 | pBallsim->MaxCollisions = 10; // This will be overwritten on the first call to addBall() |
reedas | 5:f62a9e4a499a | 1032 | // |
reedas | 5:f62a9e4a499a | 1033 | // Delete all balls |
reedas | 5:f62a9e4a499a | 1034 | // |
reedas | 5:f62a9e4a499a | 1035 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1036 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1037 | pBalld = pBalli; |
reedas | 5:f62a9e4a499a | 1038 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1039 | _Free(pBalld); |
reedas | 5:f62a9e4a499a | 1040 | } |
reedas | 5:f62a9e4a499a | 1041 | } |
reedas | 5:f62a9e4a499a | 1042 | |
reedas | 5:f62a9e4a499a | 1043 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1044 | * |
reedas | 5:f62a9e4a499a | 1045 | * _BALLSIM_Create |
reedas | 5:f62a9e4a499a | 1046 | */ |
reedas | 5:f62a9e4a499a | 1047 | static BALLSIM * _BALLSIM_Create(void) { |
reedas | 5:f62a9e4a499a | 1048 | BALLSIM * pBallsim; |
reedas | 5:f62a9e4a499a | 1049 | |
reedas | 5:f62a9e4a499a | 1050 | pBallsim = (BALLSIM *)_Calloc(sizeof(BALLSIM), 1); |
reedas | 5:f62a9e4a499a | 1051 | pBallsim->HasWalls = 0; |
reedas | 5:f62a9e4a499a | 1052 | pBallsim->MaxCollisionsPerBall = 10; |
reedas | 5:f62a9e4a499a | 1053 | _BALLSIM_ResetBalls(pBallsim); |
reedas | 5:f62a9e4a499a | 1054 | return pBallsim; |
reedas | 5:f62a9e4a499a | 1055 | } |
reedas | 5:f62a9e4a499a | 1056 | |
reedas | 5:f62a9e4a499a | 1057 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1058 | * |
reedas | 5:f62a9e4a499a | 1059 | * _BALLSIM_AdvanceBallPositions |
reedas | 5:f62a9e4a499a | 1060 | */ |
reedas | 5:f62a9e4a499a | 1061 | static void _BALLSIM_AdvanceBallPositions(BALLSIM * pBallsim, const float dt) { |
reedas | 5:f62a9e4a499a | 1062 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1063 | |
reedas | 5:f62a9e4a499a | 1064 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1065 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1066 | _BALL_AdvanceBallPosition(pBalli, dt); |
reedas | 5:f62a9e4a499a | 1067 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1068 | } |
reedas | 5:f62a9e4a499a | 1069 | } |
reedas | 5:f62a9e4a499a | 1070 | |
reedas | 5:f62a9e4a499a | 1071 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1072 | * |
reedas | 5:f62a9e4a499a | 1073 | * BALLSSIM_FindEarliestCollisionOfTwoBalls |
reedas | 5:f62a9e4a499a | 1074 | */ |
reedas | 5:f62a9e4a499a | 1075 | static COLLISION BALLSSIM_FindEarliestCollisionOfTwoBalls(BALLSIM * pBallsim, BALL ** ppb1, BALL ** ppb2) { |
reedas | 5:f62a9e4a499a | 1076 | COLLISION earliestCollision; |
reedas | 5:f62a9e4a499a | 1077 | COLLISION c; |
reedas | 5:f62a9e4a499a | 1078 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1079 | BALL * pBallj; |
reedas | 5:f62a9e4a499a | 1080 | |
reedas | 5:f62a9e4a499a | 1081 | _COLLISION_Reset(&earliestCollision); |
reedas | 5:f62a9e4a499a | 1082 | // |
reedas | 5:f62a9e4a499a | 1083 | // Compare each pair of balls. Index i runs from the first |
reedas | 5:f62a9e4a499a | 1084 | // ball up through the second-to-last ball. For each value of |
reedas | 5:f62a9e4a499a | 1085 | // i, index j runs from the ball after i up through the last ball. |
reedas | 5:f62a9e4a499a | 1086 | // |
reedas | 5:f62a9e4a499a | 1087 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1088 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1089 | pBallj = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1090 | while (pBallj) { |
reedas | 5:f62a9e4a499a | 1091 | c = _COLLISION_FindTimeUntilTwoBallsCollide(pBalli, pBallj); |
reedas | 5:f62a9e4a499a | 1092 | if (_COLLISION_Ball1HasCollisionWithBall(&c)) { |
reedas | 5:f62a9e4a499a | 1093 | if (!_COLLISION_Ball1HasCollision(&earliestCollision) || c.TimeToCollision < earliestCollision.TimeToCollision) { |
reedas | 5:f62a9e4a499a | 1094 | earliestCollision = c; |
reedas | 5:f62a9e4a499a | 1095 | *ppb1 = pBalli; |
reedas | 5:f62a9e4a499a | 1096 | *ppb2 = pBallj; |
reedas | 5:f62a9e4a499a | 1097 | } |
reedas | 5:f62a9e4a499a | 1098 | } |
reedas | 5:f62a9e4a499a | 1099 | pBallj = pBallj->pNext; |
reedas | 5:f62a9e4a499a | 1100 | } |
reedas | 5:f62a9e4a499a | 1101 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1102 | } |
reedas | 5:f62a9e4a499a | 1103 | return earliestCollision; |
reedas | 5:f62a9e4a499a | 1104 | } |
reedas | 5:f62a9e4a499a | 1105 | |
reedas | 5:f62a9e4a499a | 1106 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1107 | * |
reedas | 5:f62a9e4a499a | 1108 | * BALLSSIM_FindEarliestCollisionWithWall |
reedas | 5:f62a9e4a499a | 1109 | */ |
reedas | 5:f62a9e4a499a | 1110 | static COLLISION BALLSSIM_FindEarliestCollisionWithWall(BALLSIM * pBallsim, BALL ** ppb) { |
reedas | 5:f62a9e4a499a | 1111 | COLLISION earliestCollision; |
reedas | 5:f62a9e4a499a | 1112 | COLLISION c; |
reedas | 5:f62a9e4a499a | 1113 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1114 | |
reedas | 5:f62a9e4a499a | 1115 | _COLLISION_Reset(&earliestCollision); |
reedas | 5:f62a9e4a499a | 1116 | // |
reedas | 5:f62a9e4a499a | 1117 | // If there are no walls, return no collision |
reedas | 5:f62a9e4a499a | 1118 | // |
reedas | 5:f62a9e4a499a | 1119 | if (!pBallsim->HasWalls) { |
reedas | 5:f62a9e4a499a | 1120 | return earliestCollision; |
reedas | 5:f62a9e4a499a | 1121 | } |
reedas | 5:f62a9e4a499a | 1122 | // |
reedas | 5:f62a9e4a499a | 1123 | // Check each ball to see if any collide. Store the earliest colliding ball. |
reedas | 5:f62a9e4a499a | 1124 | // |
reedas | 5:f62a9e4a499a | 1125 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1126 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1127 | c = _COLLISION_FindTimeUntilBallCollidesWithWall(pBalli, &pBallsim->Walls); |
reedas | 5:f62a9e4a499a | 1128 | if (_COLLISION_Ball1HasCollisionWithWall(&c)) { |
reedas | 5:f62a9e4a499a | 1129 | if (!_COLLISION_Ball1HasCollision(&earliestCollision) || c.TimeToCollision < earliestCollision.TimeToCollision) { |
reedas | 5:f62a9e4a499a | 1130 | earliestCollision = c; |
reedas | 5:f62a9e4a499a | 1131 | *ppb = pBalli; |
reedas | 5:f62a9e4a499a | 1132 | } |
reedas | 5:f62a9e4a499a | 1133 | } |
reedas | 5:f62a9e4a499a | 1134 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1135 | } |
reedas | 5:f62a9e4a499a | 1136 | return earliestCollision; |
reedas | 5:f62a9e4a499a | 1137 | } |
reedas | 5:f62a9e4a499a | 1138 | |
reedas | 5:f62a9e4a499a | 1139 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1140 | * |
reedas | 5:f62a9e4a499a | 1141 | * BALLSSIM_FindEarliestCollision |
reedas | 5:f62a9e4a499a | 1142 | */ |
reedas | 5:f62a9e4a499a | 1143 | static COLLISION BALLSSIM_FindEarliestCollision(BALLSIM * pBallsim, BALL ** ppb1, BALL ** ppb2) { |
reedas | 5:f62a9e4a499a | 1144 | COLLISION earliestCollision; |
reedas | 5:f62a9e4a499a | 1145 | COLLISION cWalls; |
reedas | 5:f62a9e4a499a | 1146 | BALL * pbCollideWithWall; |
reedas | 5:f62a9e4a499a | 1147 | |
reedas | 5:f62a9e4a499a | 1148 | earliestCollision = BALLSSIM_FindEarliestCollisionOfTwoBalls(pBallsim, ppb1, ppb2); |
reedas | 5:f62a9e4a499a | 1149 | if (pBallsim->HasWalls) { |
reedas | 5:f62a9e4a499a | 1150 | cWalls = BALLSSIM_FindEarliestCollisionWithWall(pBallsim, &pbCollideWithWall); |
reedas | 5:f62a9e4a499a | 1151 | if (_COLLISION_Ball1HasCollisionWithWall(&cWalls)) { |
reedas | 5:f62a9e4a499a | 1152 | if (!_COLLISION_Ball1HasCollisionWithBall(&earliestCollision) || cWalls.TimeToCollision < earliestCollision.TimeToCollision) { |
reedas | 5:f62a9e4a499a | 1153 | earliestCollision = cWalls; |
reedas | 5:f62a9e4a499a | 1154 | *ppb1 = pbCollideWithWall; |
reedas | 5:f62a9e4a499a | 1155 | } |
reedas | 5:f62a9e4a499a | 1156 | } |
reedas | 5:f62a9e4a499a | 1157 | } |
reedas | 5:f62a9e4a499a | 1158 | return earliestCollision; |
reedas | 5:f62a9e4a499a | 1159 | } |
reedas | 5:f62a9e4a499a | 1160 | |
reedas | 5:f62a9e4a499a | 1161 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1162 | * |
reedas | 5:f62a9e4a499a | 1163 | * _BALLSIM_AdvanceBallGravity |
reedas | 5:f62a9e4a499a | 1164 | */ |
reedas | 5:f62a9e4a499a | 1165 | static void _BALLSIM_AdvanceBallGravity(BALLSIM * pBallsim, const float dt) { |
reedas | 5:f62a9e4a499a | 1166 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1167 | BALL * pBallj; |
reedas | 5:f62a9e4a499a | 1168 | |
reedas | 5:f62a9e4a499a | 1169 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1170 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1171 | pBallj = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1172 | while (pBallj) { |
reedas | 5:f62a9e4a499a | 1173 | _BALL_DoBallGravity(pBalli, pBallj, dt, pBallsim->pConfig->Gravity); |
reedas | 5:f62a9e4a499a | 1174 | pBallj = pBallj->pNext; |
reedas | 5:f62a9e4a499a | 1175 | } |
reedas | 5:f62a9e4a499a | 1176 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1177 | } |
reedas | 5:f62a9e4a499a | 1178 | } |
reedas | 5:f62a9e4a499a | 1179 | |
reedas | 5:f62a9e4a499a | 1180 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1181 | * |
reedas | 5:f62a9e4a499a | 1182 | * _BALLSIM_AdvanceGroundGravity |
reedas | 5:f62a9e4a499a | 1183 | */ |
reedas | 5:f62a9e4a499a | 1184 | static void _BALLSIM_AdvanceGroundGravity(BALLSIM * pBallsim, const float dt) { |
reedas | 5:f62a9e4a499a | 1185 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1186 | |
reedas | 5:f62a9e4a499a | 1187 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1188 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1189 | _BALL_DoGroundGravity(pBalli, dt, pBallsim->pConfig->Gravity); |
reedas | 5:f62a9e4a499a | 1190 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1191 | } |
reedas | 5:f62a9e4a499a | 1192 | } |
reedas | 5:f62a9e4a499a | 1193 | |
reedas | 5:f62a9e4a499a | 1194 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1195 | * |
reedas | 5:f62a9e4a499a | 1196 | * BALLSSIM_AdvanceSim |
reedas | 5:f62a9e4a499a | 1197 | */ |
reedas | 5:f62a9e4a499a | 1198 | static void BALLSSIM_AdvanceSim(BALLSIM * pBallsim, const float dt) { |
reedas | 5:f62a9e4a499a | 1199 | float tElapsed; |
reedas | 5:f62a9e4a499a | 1200 | COLLISION c; |
reedas | 5:f62a9e4a499a | 1201 | BALL * pb1; |
reedas | 5:f62a9e4a499a | 1202 | BALL * pb2; |
reedas | 5:f62a9e4a499a | 1203 | unsigned i; |
reedas | 5:f62a9e4a499a | 1204 | |
reedas | 5:f62a9e4a499a | 1205 | tElapsed = 0.f; |
reedas | 5:f62a9e4a499a | 1206 | for (i = 0; i < pBallsim->MaxCollisions; i++) { |
reedas | 5:f62a9e4a499a | 1207 | // |
reedas | 5:f62a9e4a499a | 1208 | // Find earliest collision |
reedas | 5:f62a9e4a499a | 1209 | // |
reedas | 5:f62a9e4a499a | 1210 | c = BALLSSIM_FindEarliestCollision(pBallsim, &pb1, &pb2); |
reedas | 5:f62a9e4a499a | 1211 | // |
reedas | 5:f62a9e4a499a | 1212 | // If no collisions, break |
reedas | 5:f62a9e4a499a | 1213 | // |
reedas | 5:f62a9e4a499a | 1214 | if (!_COLLISION_Ball1HasCollision(&c)) { |
reedas | 5:f62a9e4a499a | 1215 | break; |
reedas | 5:f62a9e4a499a | 1216 | } |
reedas | 5:f62a9e4a499a | 1217 | // |
reedas | 5:f62a9e4a499a | 1218 | // Is collision within the time frame? |
reedas | 5:f62a9e4a499a | 1219 | // Note: condition is tElapsed + timeToCollision strictly < dt, not <=, because if the two were exactly |
reedas | 5:f62a9e4a499a | 1220 | // equal, we would perform the velocity adjustment for collision but not move the balls any more, so the |
reedas | 5:f62a9e4a499a | 1221 | // collision could be detected again on the next call to advanceSim(). |
reedas | 5:f62a9e4a499a | 1222 | // |
reedas | 5:f62a9e4a499a | 1223 | if (tElapsed + c.TimeToCollision < dt) { |
reedas | 5:f62a9e4a499a | 1224 | // |
reedas | 5:f62a9e4a499a | 1225 | // Collision is within time frame |
reedas | 5:f62a9e4a499a | 1226 | // Advance balls to point of collision |
reedas | 5:f62a9e4a499a | 1227 | // |
reedas | 5:f62a9e4a499a | 1228 | _BALLSIM_AdvanceBallPositions(pBallsim, c.TimeToCollision); |
reedas | 5:f62a9e4a499a | 1229 | // |
reedas | 5:f62a9e4a499a | 1230 | // Collision is now occuring. Do collision calculation |
reedas | 5:f62a9e4a499a | 1231 | // |
reedas | 5:f62a9e4a499a | 1232 | if (_COLLISION_Ball1HasCollisionWithWall(&c)) { |
reedas | 5:f62a9e4a499a | 1233 | _COLLISION_DoElasticCollisionWithWall(pb1, c.WhichWall); |
reedas | 5:f62a9e4a499a | 1234 | } else if (_COLLISION_Ball1HasCollisionWithBall(&c)) { |
reedas | 5:f62a9e4a499a | 1235 | _COLLISION_DoElasticCollisionTwoBalls(pb1, pb2); |
reedas | 5:f62a9e4a499a | 1236 | } |
reedas | 5:f62a9e4a499a | 1237 | tElapsed += c.TimeToCollision; // Move time counter forward |
reedas | 5:f62a9e4a499a | 1238 | } else { |
reedas | 5:f62a9e4a499a | 1239 | break; // Break if collision is not within this frame |
reedas | 5:f62a9e4a499a | 1240 | } |
reedas | 5:f62a9e4a499a | 1241 | } |
reedas | 5:f62a9e4a499a | 1242 | // |
reedas | 5:f62a9e4a499a | 1243 | // Advance ball positions further if necessary after any collisions to complete the time frame |
reedas | 5:f62a9e4a499a | 1244 | // |
reedas | 5:f62a9e4a499a | 1245 | _BALLSIM_AdvanceBallPositions(pBallsim, dt - tElapsed); |
reedas | 5:f62a9e4a499a | 1246 | // |
reedas | 5:f62a9e4a499a | 1247 | // Manage ball gravity |
reedas | 5:f62a9e4a499a | 1248 | // |
reedas | 5:f62a9e4a499a | 1249 | if (pBallsim->pConfig->HasBallGravity) { |
reedas | 5:f62a9e4a499a | 1250 | _BALLSIM_AdvanceBallGravity(pBallsim, dt); |
reedas | 5:f62a9e4a499a | 1251 | } |
reedas | 5:f62a9e4a499a | 1252 | // |
reedas | 5:f62a9e4a499a | 1253 | // Manage ground gravity |
reedas | 5:f62a9e4a499a | 1254 | // |
reedas | 5:f62a9e4a499a | 1255 | if (pBallsim->pConfig->HasGroundGravity) { |
reedas | 5:f62a9e4a499a | 1256 | _BALLSIM_AdvanceGroundGravity(pBallsim, dt); |
reedas | 5:f62a9e4a499a | 1257 | } |
reedas | 5:f62a9e4a499a | 1258 | } |
reedas | 5:f62a9e4a499a | 1259 | |
reedas | 5:f62a9e4a499a | 1260 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1261 | * |
reedas | 5:f62a9e4a499a | 1262 | * BALLSSIM_MoveBallToWithinBounds |
reedas | 5:f62a9e4a499a | 1263 | */ |
reedas | 5:f62a9e4a499a | 1264 | static void BALLSSIM_MoveBallToWithinBounds(BALLSIM * pBallsim, BALL * pb) { |
reedas | 5:f62a9e4a499a | 1265 | // |
reedas | 5:f62a9e4a499a | 1266 | // Check wall X1 |
reedas | 5:f62a9e4a499a | 1267 | // |
reedas | 5:f62a9e4a499a | 1268 | if (pb->p.x - pb->r < pBallsim->Walls.x1) { |
reedas | 5:f62a9e4a499a | 1269 | _VECTOR_SetX(&pb->p, pBallsim->Walls.x1 + pb->r); |
reedas | 5:f62a9e4a499a | 1270 | } |
reedas | 5:f62a9e4a499a | 1271 | // |
reedas | 5:f62a9e4a499a | 1272 | // Check wall Y1 |
reedas | 5:f62a9e4a499a | 1273 | // |
reedas | 5:f62a9e4a499a | 1274 | if (pb->p.y - pb->r < pBallsim->Walls.y1) { |
reedas | 5:f62a9e4a499a | 1275 | _VECTOR_SetY(&pb->p, pBallsim->Walls.y1 + pb->r); |
reedas | 5:f62a9e4a499a | 1276 | } |
reedas | 5:f62a9e4a499a | 1277 | // |
reedas | 5:f62a9e4a499a | 1278 | // Check wall X2 |
reedas | 5:f62a9e4a499a | 1279 | // |
reedas | 5:f62a9e4a499a | 1280 | if (pb->p.x + pb->r > pBallsim->Walls.x2) { |
reedas | 5:f62a9e4a499a | 1281 | _VECTOR_SetX(&pb->p, pBallsim->Walls.x2 - pb->r); |
reedas | 5:f62a9e4a499a | 1282 | } |
reedas | 5:f62a9e4a499a | 1283 | // |
reedas | 5:f62a9e4a499a | 1284 | // Check wall Y2 |
reedas | 5:f62a9e4a499a | 1285 | // |
reedas | 5:f62a9e4a499a | 1286 | if (pb->p.y + pb->r > pBallsim->Walls.y2) { |
reedas | 5:f62a9e4a499a | 1287 | _VECTOR_SetY(&pb->p, pBallsim->Walls.y2 - pb->r); |
reedas | 5:f62a9e4a499a | 1288 | } |
reedas | 5:f62a9e4a499a | 1289 | } |
reedas | 5:f62a9e4a499a | 1290 | |
reedas | 5:f62a9e4a499a | 1291 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1292 | * |
reedas | 5:f62a9e4a499a | 1293 | * BALLSSIM_MoveWalls |
reedas | 5:f62a9e4a499a | 1294 | */ |
reedas | 5:f62a9e4a499a | 1295 | static void BALLSSIM_MoveWalls(BALLSIM * pBallsim, const WALLS * pNewWalls) { |
reedas | 5:f62a9e4a499a | 1296 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1297 | |
reedas | 5:f62a9e4a499a | 1298 | pBallsim->Walls = *pNewWalls; |
reedas | 5:f62a9e4a499a | 1299 | pBallsim->HasWalls = 1; |
reedas | 5:f62a9e4a499a | 1300 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1301 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1302 | BALLSSIM_MoveBallToWithinBounds(pBallsim, pBalli); |
reedas | 5:f62a9e4a499a | 1303 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1304 | } |
reedas | 5:f62a9e4a499a | 1305 | } |
reedas | 5:f62a9e4a499a | 1306 | |
reedas | 5:f62a9e4a499a | 1307 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1308 | * |
reedas | 5:f62a9e4a499a | 1309 | * BALLSSIM_GetMinWallDimension |
reedas | 5:f62a9e4a499a | 1310 | */ |
reedas | 5:f62a9e4a499a | 1311 | static float BALLSSIM_GetMinWallDimension(BALLSIM * pBallsim, float fixedWallDimension) { |
reedas | 5:f62a9e4a499a | 1312 | float minDimension; |
reedas | 5:f62a9e4a499a | 1313 | |
reedas | 5:f62a9e4a499a | 1314 | minDimension = 0.f; |
reedas | 5:f62a9e4a499a | 1315 | if (fixedWallDimension > 0.f) { |
reedas | 5:f62a9e4a499a | 1316 | minDimension = 4.f * pBallsim->MinArea / fixedWallDimension; |
reedas | 5:f62a9e4a499a | 1317 | } |
reedas | 5:f62a9e4a499a | 1318 | if (minDimension <= pBallsim->MaxDiameter) { |
reedas | 5:f62a9e4a499a | 1319 | minDimension = pBallsim->MaxDiameter + 1; |
reedas | 5:f62a9e4a499a | 1320 | } |
reedas | 5:f62a9e4a499a | 1321 | return minDimension; |
reedas | 5:f62a9e4a499a | 1322 | } |
reedas | 5:f62a9e4a499a | 1323 | |
reedas | 5:f62a9e4a499a | 1324 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1325 | * |
reedas | 5:f62a9e4a499a | 1326 | * BALLSSIM_AddBall |
reedas | 5:f62a9e4a499a | 1327 | */ |
reedas | 5:f62a9e4a499a | 1328 | static void BALLSSIM_AddBall(BALLSIM * pBallsim, BALL * pNewBall) { |
reedas | 5:f62a9e4a499a | 1329 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1330 | |
reedas | 5:f62a9e4a499a | 1331 | pBallsim->NumBalls = 0; |
reedas | 5:f62a9e4a499a | 1332 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1333 | if (pBalli) { |
reedas | 5:f62a9e4a499a | 1334 | pBallsim->NumBalls++; |
reedas | 5:f62a9e4a499a | 1335 | while (pBalli->pNext) { |
reedas | 5:f62a9e4a499a | 1336 | pBallsim->NumBalls++; |
reedas | 5:f62a9e4a499a | 1337 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1338 | } |
reedas | 5:f62a9e4a499a | 1339 | pBallsim->NumBalls++; |
reedas | 5:f62a9e4a499a | 1340 | pBalli->pNext = pNewBall; |
reedas | 5:f62a9e4a499a | 1341 | } else { |
reedas | 5:f62a9e4a499a | 1342 | pBallsim->NumBalls++; |
reedas | 5:f62a9e4a499a | 1343 | pBallsim->pFirstBall = pNewBall; |
reedas | 5:f62a9e4a499a | 1344 | pNewBall->pNext = NULL; |
reedas | 5:f62a9e4a499a | 1345 | } |
reedas | 5:f62a9e4a499a | 1346 | pBallsim->MaxCollisions = pBallsim->MaxCollisionsPerBall * pBallsim->NumBalls; |
reedas | 5:f62a9e4a499a | 1347 | BALLSSIM_MoveBallToWithinBounds(pBallsim, pNewBall); |
reedas | 5:f62a9e4a499a | 1348 | if (pNewBall->r * 2.f > pBallsim->MaxDiameter) { |
reedas | 5:f62a9e4a499a | 1349 | pBallsim->MaxDiameter = pNewBall->r * 2.f; |
reedas | 5:f62a9e4a499a | 1350 | pBallsim->MinArea += 4.f * pNewBall->r * pNewBall->r; |
reedas | 5:f62a9e4a499a | 1351 | } |
reedas | 5:f62a9e4a499a | 1352 | } |
reedas | 5:f62a9e4a499a | 1353 | |
reedas | 5:f62a9e4a499a | 1354 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1355 | * |
reedas | 5:f62a9e4a499a | 1356 | * _BALLSIM_GetBallFromPos |
reedas | 5:f62a9e4a499a | 1357 | */ |
reedas | 5:f62a9e4a499a | 1358 | static BALL * _BALLSIM_GetBallFromPos(BALLSIM * pBallsim, float xPos, float yPos) { |
reedas | 5:f62a9e4a499a | 1359 | float d, dx, dy; |
reedas | 5:f62a9e4a499a | 1360 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1361 | |
reedas | 5:f62a9e4a499a | 1362 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1363 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1364 | dx = xPos - pBalli->p.x; |
reedas | 5:f62a9e4a499a | 1365 | dy = yPos - pBalli->p.y; |
reedas | 5:f62a9e4a499a | 1366 | d = sqrt(dx * dx + dy * dy); |
reedas | 5:f62a9e4a499a | 1367 | if (d < pBalli->r) { |
reedas | 5:f62a9e4a499a | 1368 | return pBalli; |
reedas | 5:f62a9e4a499a | 1369 | } |
reedas | 5:f62a9e4a499a | 1370 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1371 | } |
reedas | 5:f62a9e4a499a | 1372 | return NULL; |
reedas | 5:f62a9e4a499a | 1373 | } |
reedas | 5:f62a9e4a499a | 1374 | |
reedas | 5:f62a9e4a499a | 1375 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1376 | * |
reedas | 5:f62a9e4a499a | 1377 | * _BALLSIM_DeleteBall |
reedas | 5:f62a9e4a499a | 1378 | */ |
reedas | 5:f62a9e4a499a | 1379 | static void _BALLSIM_DeleteBall(BALLSIM * pBallsim, BALL * pBall) { |
reedas | 5:f62a9e4a499a | 1380 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1381 | BALL * pBallPrev = NULL; |
reedas | 5:f62a9e4a499a | 1382 | |
reedas | 5:f62a9e4a499a | 1383 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1384 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1385 | if (pBalli == pBall) { |
reedas | 5:f62a9e4a499a | 1386 | if (pBallPrev) { |
reedas | 5:f62a9e4a499a | 1387 | pBallPrev->pNext = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1388 | } else { |
reedas | 5:f62a9e4a499a | 1389 | pBallsim->pFirstBall = pBallsim->pFirstBall->pNext; |
reedas | 5:f62a9e4a499a | 1390 | } |
reedas | 5:f62a9e4a499a | 1391 | pBallsim->NumBalls--; |
reedas | 5:f62a9e4a499a | 1392 | _Free(pBall); |
reedas | 5:f62a9e4a499a | 1393 | break; |
reedas | 5:f62a9e4a499a | 1394 | } |
reedas | 5:f62a9e4a499a | 1395 | pBallPrev = pBalli; |
reedas | 5:f62a9e4a499a | 1396 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1397 | } |
reedas | 5:f62a9e4a499a | 1398 | } |
reedas | 5:f62a9e4a499a | 1399 | |
reedas | 5:f62a9e4a499a | 1400 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1401 | * |
reedas | 5:f62a9e4a499a | 1402 | * _BALLSIM_StopMoving |
reedas | 5:f62a9e4a499a | 1403 | */ |
reedas | 5:f62a9e4a499a | 1404 | static void _BALLSIM_StopMoving(BALLSIM * pBallsim) { |
reedas | 5:f62a9e4a499a | 1405 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1406 | |
reedas | 5:f62a9e4a499a | 1407 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1408 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1409 | _VECTOR_SetXY(&pBalli->v, 0.f, 0.f); |
reedas | 5:f62a9e4a499a | 1410 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1411 | } |
reedas | 5:f62a9e4a499a | 1412 | } |
reedas | 5:f62a9e4a499a | 1413 | |
reedas | 5:f62a9e4a499a | 1414 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1415 | * |
reedas | 5:f62a9e4a499a | 1416 | * _BALLSIM_Delete |
reedas | 5:f62a9e4a499a | 1417 | */ |
reedas | 5:f62a9e4a499a | 1418 | static void _BALLSIM_Delete(BALLSIM * pBallsim) { |
reedas | 5:f62a9e4a499a | 1419 | _BALLSIM_ResetBalls(pBallsim); |
reedas | 5:f62a9e4a499a | 1420 | _Free(pBallsim); |
reedas | 5:f62a9e4a499a | 1421 | } |
reedas | 5:f62a9e4a499a | 1422 | |
reedas | 5:f62a9e4a499a | 1423 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1424 | * |
reedas | 5:f62a9e4a499a | 1425 | * Static code: Ballsim Window |
reedas | 5:f62a9e4a499a | 1426 | * |
reedas | 5:f62a9e4a499a | 1427 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 1428 | */ |
reedas | 5:f62a9e4a499a | 1429 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1430 | * |
reedas | 5:f62a9e4a499a | 1431 | * _UpdateDisplay |
reedas | 5:f62a9e4a499a | 1432 | */ |
reedas | 5:f62a9e4a499a | 1433 | static void _UpdateDisplay(WM_HWIN hWin, BALLSIM * pBallsim) { |
reedas | 5:f62a9e4a499a | 1434 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1435 | U32 Color; |
reedas | 5:f62a9e4a499a | 1436 | |
reedas | 5:f62a9e4a499a | 1437 | // |
reedas | 5:f62a9e4a499a | 1438 | // Draw background |
reedas | 5:f62a9e4a499a | 1439 | // |
reedas | 5:f62a9e4a499a | 1440 | if (pBallsim->pConfig->pfDrawBk) { |
reedas | 5:f62a9e4a499a | 1441 | pBallsim->pConfig->pfDrawBk(hWin, pBallsim->pConfig); |
reedas | 5:f62a9e4a499a | 1442 | } else { |
reedas | 5:f62a9e4a499a | 1443 | GUI_SetBkColor(pBallsim->pConfig->ColorBk); |
reedas | 5:f62a9e4a499a | 1444 | GUI_Clear(); |
reedas | 5:f62a9e4a499a | 1445 | } |
reedas | 5:f62a9e4a499a | 1446 | // |
reedas | 5:f62a9e4a499a | 1447 | // Draw all balls |
reedas | 5:f62a9e4a499a | 1448 | // |
reedas | 5:f62a9e4a499a | 1449 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1450 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1451 | if (pBallsim->pConfig->pfDrawBall) { |
reedas | 5:f62a9e4a499a | 1452 | pBallsim->pConfig->pfDrawBall(hWin, pBallsim->pConfig, pBalli->Index, pBalli->p.x, pBalli->p.y, pBalli->r); |
reedas | 5:f62a9e4a499a | 1453 | } else { |
reedas | 5:f62a9e4a499a | 1454 | Color = GUI_MAKE_COLOR(pBalli->Index); |
reedas | 5:f62a9e4a499a | 1455 | GUI_SetColor(Color); |
reedas | 5:f62a9e4a499a | 1456 | GUI_FillCircle(pBalli->p.x, pBalli->p.y, pBalli->r); |
reedas | 5:f62a9e4a499a | 1457 | } |
reedas | 5:f62a9e4a499a | 1458 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1459 | } |
reedas | 5:f62a9e4a499a | 1460 | } |
reedas | 5:f62a9e4a499a | 1461 | |
reedas | 5:f62a9e4a499a | 1462 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1463 | * |
reedas | 5:f62a9e4a499a | 1464 | * _AddRandomBalls |
reedas | 5:f62a9e4a499a | 1465 | */ |
reedas | 5:f62a9e4a499a | 1466 | static void _AddRandomBalls(BALLSIM * pBallsim) { |
reedas | 5:f62a9e4a499a | 1467 | unsigned i, PosOccupied, Cnt; |
reedas | 5:f62a9e4a499a | 1468 | float d, dx, dy; |
reedas | 5:f62a9e4a499a | 1469 | BALL * pBall; |
reedas | 5:f62a9e4a499a | 1470 | BALL * pBalli; |
reedas | 5:f62a9e4a499a | 1471 | BALLSIM_CONFIG * pConfig; |
reedas | 5:f62a9e4a499a | 1472 | |
reedas | 5:f62a9e4a499a | 1473 | pConfig = pBallsim->pConfig; |
reedas | 5:f62a9e4a499a | 1474 | for (i = 0; i < pConfig->NumBalls; i++) { |
reedas | 5:f62a9e4a499a | 1475 | pBall = _BALL_Create(); |
reedas | 5:f62a9e4a499a | 1476 | if (pBallsim->pConfig->HasInitialVelocity) { |
reedas | 5:f62a9e4a499a | 1477 | pBall->v.x = _GetRandomNumber(pConfig->vMin, pConfig->vMax); |
reedas | 5:f62a9e4a499a | 1478 | pBall->v.y = _GetRandomNumber(pConfig->vMin, pConfig->vMax); |
reedas | 5:f62a9e4a499a | 1479 | } |
reedas | 5:f62a9e4a499a | 1480 | pBall->Index = (U32)_GetRandomNumber(0, pConfig->Range); |
reedas | 5:f62a9e4a499a | 1481 | if (pConfig->pRadius) { |
reedas | 5:f62a9e4a499a | 1482 | pBall->r = *(pConfig->pRadius + pBall->Index); |
reedas | 5:f62a9e4a499a | 1483 | } else { |
reedas | 5:f62a9e4a499a | 1484 | pBall->r = _GetRandomNumber(pConfig->rMin, pConfig->rMax); |
reedas | 5:f62a9e4a499a | 1485 | } |
reedas | 5:f62a9e4a499a | 1486 | pBall->m = M_TO_A_RATIO * M_PI * pBall->r * pBall->r; |
reedas | 5:f62a9e4a499a | 1487 | // |
reedas | 5:f62a9e4a499a | 1488 | // Generate legal position |
reedas | 5:f62a9e4a499a | 1489 | // |
reedas | 5:f62a9e4a499a | 1490 | Cnt = 0; |
reedas | 5:f62a9e4a499a | 1491 | do { |
reedas | 5:f62a9e4a499a | 1492 | pBall->p.x = _GetRandomNumber((float)pBall->r, (float)(pConfig->xSize) - pBall->r); |
reedas | 5:f62a9e4a499a | 1493 | pBall->p.y = _GetRandomNumber((float)pBall->r, (float)(pConfig->ySize) - pBall->r); |
reedas | 5:f62a9e4a499a | 1494 | PosOccupied = 0; |
reedas | 5:f62a9e4a499a | 1495 | pBalli = pBallsim->pFirstBall; |
reedas | 5:f62a9e4a499a | 1496 | while (pBalli) { |
reedas | 5:f62a9e4a499a | 1497 | dx = pBalli->p.x - pBall->p.x; |
reedas | 5:f62a9e4a499a | 1498 | dy = pBalli->p.y - pBall->p.y; |
reedas | 5:f62a9e4a499a | 1499 | d = sqrt(dx * dx + dy * dy); |
reedas | 5:f62a9e4a499a | 1500 | if (d < pBalli->r + pBall->r) { |
reedas | 5:f62a9e4a499a | 1501 | PosOccupied = 1; |
reedas | 5:f62a9e4a499a | 1502 | break; |
reedas | 5:f62a9e4a499a | 1503 | } |
reedas | 5:f62a9e4a499a | 1504 | pBalli = pBalli->pNext; |
reedas | 5:f62a9e4a499a | 1505 | } |
reedas | 5:f62a9e4a499a | 1506 | } while (PosOccupied && (Cnt++ < 10)); |
reedas | 5:f62a9e4a499a | 1507 | // |
reedas | 5:f62a9e4a499a | 1508 | // Add ball to array |
reedas | 5:f62a9e4a499a | 1509 | // |
reedas | 5:f62a9e4a499a | 1510 | if (PosOccupied == 0) { |
reedas | 5:f62a9e4a499a | 1511 | BALLSSIM_AddBall(pBallsim, pBall); |
reedas | 5:f62a9e4a499a | 1512 | } |
reedas | 5:f62a9e4a499a | 1513 | } |
reedas | 5:f62a9e4a499a | 1514 | } |
reedas | 5:f62a9e4a499a | 1515 | |
reedas | 5:f62a9e4a499a | 1516 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1517 | * |
reedas | 5:f62a9e4a499a | 1518 | * _cbConfig |
reedas | 5:f62a9e4a499a | 1519 | */ |
reedas | 5:f62a9e4a499a | 1520 | static void _cbConfig(WM_MESSAGE * pMsg) { |
reedas | 5:f62a9e4a499a | 1521 | WM_HWIN hItem; |
reedas | 5:f62a9e4a499a | 1522 | static BALLSIM * pBallsim; |
reedas | 5:f62a9e4a499a | 1523 | int Id, NCode; |
reedas | 5:f62a9e4a499a | 1524 | int xSize, ySize; |
reedas | 5:f62a9e4a499a | 1525 | WM_PID_STATE_CHANGED_INFO * pInfo; |
reedas | 5:f62a9e4a499a | 1526 | GUI_PID_STATE * pState; |
reedas | 5:f62a9e4a499a | 1527 | static int IsDown; |
reedas | 5:f62a9e4a499a | 1528 | static GUI_POINT pDown; |
reedas | 5:f62a9e4a499a | 1529 | |
reedas | 5:f62a9e4a499a | 1530 | switch (pMsg->MsgId) { |
reedas | 5:f62a9e4a499a | 1531 | case WM_PAINT: |
reedas | 5:f62a9e4a499a | 1532 | xSize = WM_GetWindowSizeX(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1533 | ySize = WM_GetWindowSizeY(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1534 | GUI_SetColor(GUI_BLACK); |
reedas | 5:f62a9e4a499a | 1535 | GUI_DrawRect(0, 0, xSize - 1, ySize - 1); |
reedas | 5:f62a9e4a499a | 1536 | break; |
reedas | 5:f62a9e4a499a | 1537 | case WM_PID_STATE_CHANGED: |
reedas | 5:f62a9e4a499a | 1538 | pInfo = (WM_PID_STATE_CHANGED_INFO *)pMsg->Data.p; |
reedas | 5:f62a9e4a499a | 1539 | if (pInfo->StatePrev == 0) { |
reedas | 5:f62a9e4a499a | 1540 | IsDown = 1; |
reedas | 5:f62a9e4a499a | 1541 | pDown.x = pInfo->x; |
reedas | 5:f62a9e4a499a | 1542 | pDown.y = pInfo->y; |
reedas | 5:f62a9e4a499a | 1543 | WM_SetCapture(pMsg->hWin, 1); |
reedas | 5:f62a9e4a499a | 1544 | } else { |
reedas | 5:f62a9e4a499a | 1545 | IsDown = 0; |
reedas | 5:f62a9e4a499a | 1546 | } |
reedas | 5:f62a9e4a499a | 1547 | break; |
reedas | 5:f62a9e4a499a | 1548 | case WM_TOUCH: |
reedas | 5:f62a9e4a499a | 1549 | if (IsDown) { |
reedas | 5:f62a9e4a499a | 1550 | pState = (GUI_PID_STATE *)pMsg->Data.p; |
reedas | 5:f62a9e4a499a | 1551 | if (pState) { |
reedas | 5:f62a9e4a499a | 1552 | WM_MoveWindow(pMsg->hWin, pState->x - pDown.x, pState->y - pDown.y); |
reedas | 5:f62a9e4a499a | 1553 | } |
reedas | 5:f62a9e4a499a | 1554 | } |
reedas | 5:f62a9e4a499a | 1555 | break; |
reedas | 5:f62a9e4a499a | 1556 | case WM_USER_DATA: |
reedas | 5:f62a9e4a499a | 1557 | WM_GetUserData(pMsg->hWin, &pBallsim, sizeof(void *)); |
reedas | 5:f62a9e4a499a | 1558 | WINDOW_SetBkColor(pMsg->hWin, GUI_WHITE); |
reedas | 5:f62a9e4a499a | 1559 | WM_MakeModal(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1560 | hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); |
reedas | 5:f62a9e4a499a | 1561 | BUTTON_SetText(hItem, "Stop moving"); |
reedas | 5:f62a9e4a499a | 1562 | hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); |
reedas | 5:f62a9e4a499a | 1563 | BUTTON_SetText(hItem, "Create random balls"); |
reedas | 5:f62a9e4a499a | 1564 | hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2); |
reedas | 5:f62a9e4a499a | 1565 | BUTTON_SetText(hItem, "Back"); |
reedas | 5:f62a9e4a499a | 1566 | hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0); |
reedas | 5:f62a9e4a499a | 1567 | CHECKBOX_SetText(hItem, "Ball Gravity"); |
reedas | 5:f62a9e4a499a | 1568 | if (pBallsim->pConfig->HasBallGravity) { |
reedas | 5:f62a9e4a499a | 1569 | CHECKBOX_Check(hItem); |
reedas | 5:f62a9e4a499a | 1570 | } else { |
reedas | 5:f62a9e4a499a | 1571 | CHECKBOX_Uncheck(hItem); |
reedas | 5:f62a9e4a499a | 1572 | } |
reedas | 5:f62a9e4a499a | 1573 | hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1); |
reedas | 5:f62a9e4a499a | 1574 | CHECKBOX_SetText(hItem, "Ground Gravity"); |
reedas | 5:f62a9e4a499a | 1575 | if (pBallsim->pConfig->HasGroundGravity) { |
reedas | 5:f62a9e4a499a | 1576 | CHECKBOX_Check(hItem); |
reedas | 5:f62a9e4a499a | 1577 | } else { |
reedas | 5:f62a9e4a499a | 1578 | CHECKBOX_Uncheck(hItem); |
reedas | 5:f62a9e4a499a | 1579 | } |
reedas | 5:f62a9e4a499a | 1580 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); |
reedas | 5:f62a9e4a499a | 1581 | TEXT_SetText(hItem, "Gravity:"); |
reedas | 5:f62a9e4a499a | 1582 | TEXT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER); |
reedas | 5:f62a9e4a499a | 1583 | hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0); |
reedas | 5:f62a9e4a499a | 1584 | SLIDER_SetRange(hItem, 0, 400); |
reedas | 5:f62a9e4a499a | 1585 | SLIDER_SetValue(hItem, (int)pBallsim->pConfig->Gravity); |
reedas | 5:f62a9e4a499a | 1586 | break; |
reedas | 5:f62a9e4a499a | 1587 | case WM_NOTIFY_PARENT: |
reedas | 5:f62a9e4a499a | 1588 | Id = WM_GetId(pMsg->hWinSrc); |
reedas | 5:f62a9e4a499a | 1589 | NCode = pMsg->Data.v; |
reedas | 5:f62a9e4a499a | 1590 | switch(Id) { |
reedas | 5:f62a9e4a499a | 1591 | case ID_BUTTON_0: |
reedas | 5:f62a9e4a499a | 1592 | switch(NCode) { |
reedas | 5:f62a9e4a499a | 1593 | case WM_NOTIFICATION_RELEASED: |
reedas | 5:f62a9e4a499a | 1594 | _BALLSIM_StopMoving(pBallsim); |
reedas | 5:f62a9e4a499a | 1595 | break; |
reedas | 5:f62a9e4a499a | 1596 | } |
reedas | 5:f62a9e4a499a | 1597 | break; |
reedas | 5:f62a9e4a499a | 1598 | case ID_BUTTON_1: |
reedas | 5:f62a9e4a499a | 1599 | switch(NCode) { |
reedas | 5:f62a9e4a499a | 1600 | case WM_NOTIFICATION_RELEASED: |
reedas | 5:f62a9e4a499a | 1601 | _AddRandomBalls(pBallsim); |
reedas | 5:f62a9e4a499a | 1602 | break; |
reedas | 5:f62a9e4a499a | 1603 | } |
reedas | 5:f62a9e4a499a | 1604 | break; |
reedas | 5:f62a9e4a499a | 1605 | case ID_BUTTON_2: |
reedas | 5:f62a9e4a499a | 1606 | switch(NCode) { |
reedas | 5:f62a9e4a499a | 1607 | case WM_NOTIFICATION_RELEASED: |
reedas | 5:f62a9e4a499a | 1608 | WM_DeleteWindow(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1609 | break; |
reedas | 5:f62a9e4a499a | 1610 | } |
reedas | 5:f62a9e4a499a | 1611 | break; |
reedas | 5:f62a9e4a499a | 1612 | case ID_CHECKBOX_0: |
reedas | 5:f62a9e4a499a | 1613 | switch(NCode) { |
reedas | 5:f62a9e4a499a | 1614 | case WM_NOTIFICATION_VALUE_CHANGED: |
reedas | 5:f62a9e4a499a | 1615 | pBallsim->pConfig->HasBallGravity = CHECKBOX_IsChecked(pMsg->hWinSrc) ? 1 : 0; |
reedas | 5:f62a9e4a499a | 1616 | break; |
reedas | 5:f62a9e4a499a | 1617 | } |
reedas | 5:f62a9e4a499a | 1618 | break; |
reedas | 5:f62a9e4a499a | 1619 | case ID_CHECKBOX_1: |
reedas | 5:f62a9e4a499a | 1620 | switch(NCode) { |
reedas | 5:f62a9e4a499a | 1621 | case WM_NOTIFICATION_VALUE_CHANGED: |
reedas | 5:f62a9e4a499a | 1622 | pBallsim->pConfig->HasGroundGravity = CHECKBOX_IsChecked(pMsg->hWinSrc) ? 1 : 0; |
reedas | 5:f62a9e4a499a | 1623 | break; |
reedas | 5:f62a9e4a499a | 1624 | } |
reedas | 5:f62a9e4a499a | 1625 | break; |
reedas | 5:f62a9e4a499a | 1626 | case ID_SLIDER_0: |
reedas | 5:f62a9e4a499a | 1627 | switch(NCode) { |
reedas | 5:f62a9e4a499a | 1628 | case WM_NOTIFICATION_VALUE_CHANGED: |
reedas | 5:f62a9e4a499a | 1629 | pBallsim->pConfig->Gravity = (float)SLIDER_GetValue(pMsg->hWinSrc); |
reedas | 5:f62a9e4a499a | 1630 | break; |
reedas | 5:f62a9e4a499a | 1631 | } |
reedas | 5:f62a9e4a499a | 1632 | break; |
reedas | 5:f62a9e4a499a | 1633 | } |
reedas | 5:f62a9e4a499a | 1634 | break; |
reedas | 5:f62a9e4a499a | 1635 | default: |
reedas | 5:f62a9e4a499a | 1636 | WM_DefaultProc(pMsg); |
reedas | 5:f62a9e4a499a | 1637 | } |
reedas | 5:f62a9e4a499a | 1638 | } |
reedas | 5:f62a9e4a499a | 1639 | |
reedas | 5:f62a9e4a499a | 1640 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1641 | * |
reedas | 5:f62a9e4a499a | 1642 | * _CreateConfigWindow |
reedas | 5:f62a9e4a499a | 1643 | */ |
reedas | 5:f62a9e4a499a | 1644 | static void _CreateConfigWindow(BALLSIM * pBallsim, WM_HWIN hParent) { |
reedas | 5:f62a9e4a499a | 1645 | WM_HWIN hWin; |
reedas | 5:f62a9e4a499a | 1646 | int xPos, yPos; |
reedas | 5:f62a9e4a499a | 1647 | |
reedas | 5:f62a9e4a499a | 1648 | xPos = (pBallsim->pConfig->xSize - _aDialogCreate[0].xSize) / 2; |
reedas | 5:f62a9e4a499a | 1649 | yPos = (pBallsim->pConfig->ySize - _aDialogCreate[0].ySize) / 3; |
reedas | 5:f62a9e4a499a | 1650 | hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbConfig, WM_HBKWIN, xPos, yPos); |
reedas | 5:f62a9e4a499a | 1651 | WM_SetUserData(hWin, &pBallsim, sizeof(void *)); |
reedas | 5:f62a9e4a499a | 1652 | } |
reedas | 5:f62a9e4a499a | 1653 | |
reedas | 5:f62a9e4a499a | 1654 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1655 | * |
reedas | 5:f62a9e4a499a | 1656 | * _CreateBallsim |
reedas | 5:f62a9e4a499a | 1657 | */ |
reedas | 5:f62a9e4a499a | 1658 | static BALLSIM * _CreateBallsim(WM_HWIN hWin) { |
reedas | 5:f62a9e4a499a | 1659 | BALLSIM_CONFIG * pConfig; |
reedas | 5:f62a9e4a499a | 1660 | BALLSIM * pBallsim; |
reedas | 5:f62a9e4a499a | 1661 | WALLS * pWalls; |
reedas | 5:f62a9e4a499a | 1662 | |
reedas | 5:f62a9e4a499a | 1663 | WM_GetUserData(hWin, &pConfig, sizeof(void *)); |
reedas | 5:f62a9e4a499a | 1664 | pBallsim = _BALLSIM_Create(); |
reedas | 5:f62a9e4a499a | 1665 | pBallsim->pConfig = pConfig; |
reedas | 5:f62a9e4a499a | 1666 | pWalls = _WALLS_Create(0.f, 0.f, (float)pConfig->xSize, (float)pConfig->ySize); |
reedas | 5:f62a9e4a499a | 1667 | BALLSSIM_MoveWalls(pBallsim, pWalls); |
reedas | 5:f62a9e4a499a | 1668 | _AddRandomBalls(pBallsim); |
reedas | 5:f62a9e4a499a | 1669 | _Free(pWalls); |
reedas | 5:f62a9e4a499a | 1670 | return pBallsim; |
reedas | 5:f62a9e4a499a | 1671 | } |
reedas | 5:f62a9e4a499a | 1672 | |
reedas | 5:f62a9e4a499a | 1673 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1674 | * |
reedas | 5:f62a9e4a499a | 1675 | * _cbBallsim |
reedas | 5:f62a9e4a499a | 1676 | */ |
reedas | 5:f62a9e4a499a | 1677 | static void _cbBallsim(WM_MESSAGE * pMsg) { |
reedas | 5:f62a9e4a499a | 1678 | static BALLSIM * pBallsim; |
reedas | 5:f62a9e4a499a | 1679 | static GUI_TIMER_TIME Time; |
reedas | 5:f62a9e4a499a | 1680 | GUI_TIMER_TIME tNow; |
reedas | 5:f62a9e4a499a | 1681 | WM_HTIMER hTimer; |
reedas | 5:f62a9e4a499a | 1682 | WM_PID_STATE_CHANGED_INFO * pInfo; |
reedas | 5:f62a9e4a499a | 1683 | BALL * pBall; |
reedas | 5:f62a9e4a499a | 1684 | |
reedas | 5:f62a9e4a499a | 1685 | switch (pMsg->MsgId) { |
reedas | 5:f62a9e4a499a | 1686 | case WM_PID_STATE_CHANGED: |
reedas | 5:f62a9e4a499a | 1687 | pInfo = (WM_PID_STATE_CHANGED_INFO *)pMsg->Data.p; |
reedas | 5:f62a9e4a499a | 1688 | if (pInfo->StatePrev == 0) { |
reedas | 5:f62a9e4a499a | 1689 | pBall = _BALLSIM_GetBallFromPos(pBallsim, (float)pInfo->x, (float)pInfo->y); |
reedas | 5:f62a9e4a499a | 1690 | if (pBall) { |
reedas | 5:f62a9e4a499a | 1691 | _BALLSIM_DeleteBall(pBallsim, pBall); |
reedas | 5:f62a9e4a499a | 1692 | } else { |
reedas | 5:f62a9e4a499a | 1693 | _CreateConfigWindow(pBallsim, pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1694 | } |
reedas | 5:f62a9e4a499a | 1695 | } |
reedas | 5:f62a9e4a499a | 1696 | break; |
reedas | 5:f62a9e4a499a | 1697 | case WM_DELETE: |
reedas | 5:f62a9e4a499a | 1698 | _BALLSIM_Delete(pBallsim); |
reedas | 5:f62a9e4a499a | 1699 | break; |
reedas | 5:f62a9e4a499a | 1700 | case WM_USER_DATA: |
reedas | 5:f62a9e4a499a | 1701 | pBallsim = _CreateBallsim(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1702 | hTimer = WM_CreateTimer(pMsg->hWin, 0, TIME_SLICE, 0); |
reedas | 5:f62a9e4a499a | 1703 | Time = GUI_GetTime(); |
reedas | 5:f62a9e4a499a | 1704 | break; |
reedas | 5:f62a9e4a499a | 1705 | case WM_PAINT: |
reedas | 5:f62a9e4a499a | 1706 | _UpdateDisplay(pMsg->hWin, pBallsim); |
reedas | 5:f62a9e4a499a | 1707 | break; |
reedas | 5:f62a9e4a499a | 1708 | case WM_TIMER: |
reedas | 5:f62a9e4a499a | 1709 | WM_RestartTimer(pMsg->Data.v, pBallsim->pConfig->TimeSlice); |
reedas | 5:f62a9e4a499a | 1710 | tNow = GUI_GetTime(); |
reedas | 5:f62a9e4a499a | 1711 | BALLSSIM_AdvanceSim(pBallsim, (float)(tNow - Time) / 1000); |
reedas | 5:f62a9e4a499a | 1712 | Time = tNow; |
reedas | 5:f62a9e4a499a | 1713 | WM_InvalidateWindow(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1714 | break; |
reedas | 5:f62a9e4a499a | 1715 | default: |
reedas | 5:f62a9e4a499a | 1716 | WM_DefaultProc(pMsg); |
reedas | 5:f62a9e4a499a | 1717 | } |
reedas | 5:f62a9e4a499a | 1718 | } |
reedas | 5:f62a9e4a499a | 1719 | |
reedas | 5:f62a9e4a499a | 1720 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1721 | * |
reedas | 5:f62a9e4a499a | 1722 | * _CreateBallsimWindow |
reedas | 5:f62a9e4a499a | 1723 | */ |
reedas | 5:f62a9e4a499a | 1724 | static WM_HWIN _CreateBallsimWindow(BALLSIM_CONFIG * pConfig, WM_HWIN hParent) { |
reedas | 5:f62a9e4a499a | 1725 | WM_HWIN hWin; |
reedas | 5:f62a9e4a499a | 1726 | |
reedas | 5:f62a9e4a499a | 1727 | hWin = WM_CreateWindowAsChild(pConfig->xPos, pConfig->yPos, pConfig->xSize, pConfig->ySize, hParent, WM_CF_SHOW, _cbBallsim, sizeof(void *)); |
reedas | 5:f62a9e4a499a | 1728 | WM_SetUserData(hWin, &pConfig, sizeof(void *)); |
reedas | 5:f62a9e4a499a | 1729 | #if GUI_VERSION < 54400 |
reedas | 5:f62a9e4a499a | 1730 | WM_SendMessageNoPara(hWin, WM_USER_DATA); |
reedas | 5:f62a9e4a499a | 1731 | #endif |
reedas | 5:f62a9e4a499a | 1732 | return hWin; |
reedas | 5:f62a9e4a499a | 1733 | } |
reedas | 5:f62a9e4a499a | 1734 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1735 | * |
reedas | 5:f62a9e4a499a | 1736 | * Static code: Application |
reedas | 5:f62a9e4a499a | 1737 | * |
reedas | 5:f62a9e4a499a | 1738 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 1739 | */ |
reedas | 5:f62a9e4a499a | 1740 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1741 | * |
reedas | 5:f62a9e4a499a | 1742 | * _DrawBk |
reedas | 5:f62a9e4a499a | 1743 | */ |
reedas | 5:f62a9e4a499a | 1744 | static void _DrawBk(WM_HWIN hWin, void * pVoid) { |
reedas | 5:f62a9e4a499a | 1745 | GUI_SetBkColor(GUI_MAKE_COLOR(0x202020)); |
reedas | 5:f62a9e4a499a | 1746 | GUI_Clear(); |
reedas | 5:f62a9e4a499a | 1747 | } |
reedas | 5:f62a9e4a499a | 1748 | |
reedas | 5:f62a9e4a499a | 1749 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1750 | * |
reedas | 5:f62a9e4a499a | 1751 | * _DrawBall |
reedas | 5:f62a9e4a499a | 1752 | */ |
reedas | 5:f62a9e4a499a | 1753 | static void _DrawBall(WM_HWIN hWin, void * pVoid, U32 Index, float x, float y, float r) { |
reedas | 5:f62a9e4a499a | 1754 | GUI_SetColor(GUI_MAKE_COLOR(Index)); |
reedas | 5:f62a9e4a499a | 1755 | GUI_AA_FillCircle((int)x, (int)y, (int)r); |
reedas | 5:f62a9e4a499a | 1756 | } |
reedas | 5:f62a9e4a499a | 1757 | |
reedas | 5:f62a9e4a499a | 1758 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1759 | * |
reedas | 5:f62a9e4a499a | 1760 | * _cbSplash |
reedas | 5:f62a9e4a499a | 1761 | */ |
reedas | 5:f62a9e4a499a | 1762 | static void _cbSplash(WM_MESSAGE * pMsg) { |
reedas | 5:f62a9e4a499a | 1763 | int xSize, ySize; |
reedas | 5:f62a9e4a499a | 1764 | const GUI_BITMAP * pBm; |
reedas | 5:f62a9e4a499a | 1765 | |
reedas | 5:f62a9e4a499a | 1766 | switch (pMsg->MsgId) { |
reedas | 5:f62a9e4a499a | 1767 | case WM_PAINT: |
reedas | 5:f62a9e4a499a | 1768 | xSize = WM_GetWindowSizeX(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1769 | ySize = WM_GetWindowSizeY(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1770 | GUI_SetBkColor(GUI_WHITE); |
reedas | 5:f62a9e4a499a | 1771 | GUI_Clear(); |
reedas | 5:f62a9e4a499a | 1772 | pBm = &_bmSeggerLogo_80x40; |
reedas | 5:f62a9e4a499a | 1773 | GUI_DrawBitmap(pBm, xSize - pBm->XSize - 10, 5); |
reedas | 5:f62a9e4a499a | 1774 | GUI_SetColor(GUI_BLACK); |
reedas | 5:f62a9e4a499a | 1775 | GUI_SetFont(&GUI_Font32_AA4_Bounce); |
reedas | 5:f62a9e4a499a | 1776 | GUI_DispStringAt("Bounce", 10, 10); |
reedas | 5:f62a9e4a499a | 1777 | GUI_SetFont(GUI_FONT_13_ASCII); |
reedas | 5:f62a9e4a499a | 1778 | GUI_DispStringHCenterAt("Press screen for config dialog,\n" |
reedas | 5:f62a9e4a499a | 1779 | "Tap balls to remove them.\n\n" |
reedas | 5:f62a9e4a499a | 1780 | "Have fun...", xSize / 2, pBm->YSize + 20); |
reedas | 5:f62a9e4a499a | 1781 | break; |
reedas | 5:f62a9e4a499a | 1782 | case WM_CREATE: |
reedas | 5:f62a9e4a499a | 1783 | WM_CreateTimer(pMsg->hWin, 0, PERIOD_SPLASH, 0); |
reedas | 5:f62a9e4a499a | 1784 | WM_MakeModal(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1785 | break; |
reedas | 5:f62a9e4a499a | 1786 | case WM_TIMER: |
reedas | 5:f62a9e4a499a | 1787 | WM_DeleteWindow(pMsg->hWin); |
reedas | 5:f62a9e4a499a | 1788 | break; |
reedas | 5:f62a9e4a499a | 1789 | default: |
reedas | 5:f62a9e4a499a | 1790 | WM_DefaultProc(pMsg); |
reedas | 5:f62a9e4a499a | 1791 | } |
reedas | 5:f62a9e4a499a | 1792 | } |
reedas | 5:f62a9e4a499a | 1793 | |
reedas | 5:f62a9e4a499a | 1794 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1795 | * |
reedas | 5:f62a9e4a499a | 1796 | * _Test |
reedas | 5:f62a9e4a499a | 1797 | */ |
reedas | 5:f62a9e4a499a | 1798 | static void _Test(void) { |
reedas | 5:f62a9e4a499a | 1799 | int xSize, ySize; |
reedas | 5:f62a9e4a499a | 1800 | int xPos, yPos; |
reedas | 5:f62a9e4a499a | 1801 | WM_HWIN hWin; |
reedas | 5:f62a9e4a499a | 1802 | static BALLSIM_CONFIG Config; |
reedas | 5:f62a9e4a499a | 1803 | |
reedas | 5:f62a9e4a499a | 1804 | xSize = LCD_GetXSize(); |
reedas | 5:f62a9e4a499a | 1805 | ySize = LCD_GetYSize(); |
reedas | 5:f62a9e4a499a | 1806 | // |
reedas | 5:f62a9e4a499a | 1807 | // Configuration of ball simulation |
reedas | 5:f62a9e4a499a | 1808 | // |
reedas | 5:f62a9e4a499a | 1809 | Config.xSize = xSize; |
reedas | 5:f62a9e4a499a | 1810 | Config.ySize = ySize; |
reedas | 5:f62a9e4a499a | 1811 | Config.Range = 0xE0E0E0; |
reedas | 5:f62a9e4a499a | 1812 | Config.NumBalls = NUM_BALLS; |
reedas | 5:f62a9e4a499a | 1813 | Config.TimeSlice = TIME_SLICE; |
reedas | 5:f62a9e4a499a | 1814 | Config.vMin = MIN_RANDOM_V; |
reedas | 5:f62a9e4a499a | 1815 | Config.vMax = MAX_RANDOM_V; |
reedas | 5:f62a9e4a499a | 1816 | Config.rMin = MIN_RANDOM_R; |
reedas | 5:f62a9e4a499a | 1817 | Config.rMax = MAX_RANDOM_R; |
reedas | 5:f62a9e4a499a | 1818 | Config.Gravity = GRAVITY; |
reedas | 5:f62a9e4a499a | 1819 | Config.pfDrawBk = _DrawBk; |
reedas | 5:f62a9e4a499a | 1820 | Config.pfDrawBall = _DrawBall; |
reedas | 5:f62a9e4a499a | 1821 | hWin = _CreateBallsimWindow(&Config, WM_HBKWIN); |
reedas | 5:f62a9e4a499a | 1822 | // |
reedas | 5:f62a9e4a499a | 1823 | // Create splash screen |
reedas | 5:f62a9e4a499a | 1824 | // |
reedas | 5:f62a9e4a499a | 1825 | xPos = (xSize - XSIZE_SPLASH) / 2; |
reedas | 5:f62a9e4a499a | 1826 | yPos = (ySize - YSIZE_SPLASH) / 3; |
reedas | 5:f62a9e4a499a | 1827 | WM_CreateWindowAsChild(xPos, yPos, XSIZE_SPLASH, YSIZE_SPLASH, hWin, WM_CF_SHOW, _cbSplash, 0); |
reedas | 5:f62a9e4a499a | 1828 | } |
reedas | 5:f62a9e4a499a | 1829 | |
reedas | 5:f62a9e4a499a | 1830 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1831 | * |
reedas | 5:f62a9e4a499a | 1832 | * Public code |
reedas | 5:f62a9e4a499a | 1833 | * |
reedas | 5:f62a9e4a499a | 1834 | ********************************************************************** |
reedas | 5:f62a9e4a499a | 1835 | */ |
reedas | 5:f62a9e4a499a | 1836 | /********************************************************************* |
reedas | 5:f62a9e4a499a | 1837 | * |
reedas | 5:f62a9e4a499a | 1838 | * MainTask |
reedas | 5:f62a9e4a499a | 1839 | */ |
reedas | 5:f62a9e4a499a | 1840 | void MainTask(void) { |
reedas | 5:f62a9e4a499a | 1841 | GUI_Init(); |
reedas | 5:f62a9e4a499a | 1842 | WM_MULTIBUF_Enable(1); |
reedas | 5:f62a9e4a499a | 1843 | BUTTON_SetReactOnLevel(); |
reedas | 5:f62a9e4a499a | 1844 | _Test(); |
reedas | 5:f62a9e4a499a | 1845 | while (1) { |
reedas | 5:f62a9e4a499a | 1846 | GUI_Delay(100); |
reedas | 5:f62a9e4a499a | 1847 | } |
reedas | 5:f62a9e4a499a | 1848 | } |
reedas | 5:f62a9e4a499a | 1849 | |
reedas | 5:f62a9e4a499a | 1850 | /*************************** End of file ****************************/ |