Mre Sdk | 4K 2024 |

#endif // 3. Example MRE SDK Implementation ( mre_impl.c ) #include "mre.h" #include <stdio.h> // Simulated display buffer static DWORD display_buffer[320*240]; static int screen_w = 240, screen_h = 320; static DWORD bg_color = RGB(255,255,255); static int running = 1;

// External functions implemented by app void mre_app_entry(void); void mre_handle_event(MRE_EVENT event, int param);

// Events typedef enum MRE_EVENT_KEY_PRESS, MRE_EVENT_KEY_RELEASE, MRE_EVENT_TIMER, MRE_EVENT_PEN_DOWN, MRE_EVENT_PEN_UP, MRE_EVENT_PEN_MOVE MRE_EVENT;

void mre_init(void) printf("[MRE] Initialized\n"); mre_display_set_background(RGB(255,255,255)); mre sdk

#define TRUE 1 #define FALSE 0

// Simulate event loop while(running) // In real MRE, events come from platform // Simulate a key press to exit static int counter = 0; if(counter++ > 1000000) mre_handle_event(MRE_EVENT_KEY_PRESS, MRE_KEY_SOFT_LEFT); break;

// Keys typedef enum MRE_KEY_SOFT_LEFT = 1, MRE_KEY_SOFT_RIGHT = 2, MRE_KEY_UP = 3, MRE_KEY_DOWN = 4, MRE_KEY_LEFT = 5, MRE_KEY_RIGHT = 6, MRE_KEY_OK = 7, MRE_KEY_BACK = 8, MRE_KEY_NUMBER_0 = 9 MRE_KEY; #endif // 3

// Event handler void mre_handle_event(MRE_EVENT event, int param)

void mre_draw_rect(int x, int y, int w, int h, DWORD color, BOOL fill) printf("[MRE] Draw rect (%d,%d,%d,%d) %s %06X\n", x, y, w, h, fill ? "fill" : "border", color);

// Main loop simulation int main(void) mre_app_entry(); static int screen_w = 240

// Types typedef uint8_t BOOL; typedef uint8_t BYTE; typedef uint16_t WORD; typedef uint32_t DWORD;

void mre_set_timer(int ms, int timer_id) printf("[MRE] Timer %d set for %d ms\n", timer_id, ms);