From 8f7f72712c2aef80651d5b684ee821dacae35154 Mon Sep 17 00:00:00 2001 From: JiXieShi Date: Sat, 21 Sep 2024 23:07:22 +0800 Subject: [PATCH] UP --- demo/arg/t_arg.h | 2 +- demo/arg/test.c | 2 +- demo/iic/t_iic.h | 2 +- demo/iic/test.c | 2 +- demo/key/t_key.h | 2 +- demo/key/test.c | 2 +- demo/list/t_list.h | 4 ++-- demo/list/test.c | 4 ++-- demo/lvgl/t_lvgl.h | 2 +- demo/lvgl/test.c | 12 ++++++------ demo/oled/t_oled.h | 2 +- demo/oled/test.c | 2 +- demo/spi/t_spi.h | 2 +- demo/spi/test.c | 2 +- demo/task/t_task.h | 2 +- demo/task/test.c | 2 +- demo/tft/t_tft.h | 2 +- demo/tft/test.c | 20 ++++++++++---------- main.c | 14 +++++++------- sim/Test/sim_test.cpp | 10 +++------- sim/Test/sim_test.h | 6 +++--- sim/display/sim_display.cpp | 14 ++++++++------ sim/display/sim_display.h | 20 ++++++++++++++++---- sim/lvgl/lv_conf.h | 4 ++-- sim/lvgl/lv_port_disp.cpp | 20 ++++++++++---------- sim/thread/sim_thread.h | 9 ++++++--- sim/thread/thread.cpp | 16 +++++++++++----- 27 files changed, 100 insertions(+), 81 deletions(-) diff --git a/demo/arg/t_arg.h b/demo/arg/t_arg.h index 2abdbb1..a9f3940 100644 --- a/demo/arg/t_arg.h +++ b/demo/arg/t_arg.h @@ -5,6 +5,6 @@ #ifndef HW_LIB_T_ARG_H #define HW_LIB_T_ARG_H -void Test_argpase(void *pVoid); +int Test_argpase(void *pVoid); #endif //HW_LIB_T_ARG_H diff --git a/demo/arg/test.c b/demo/arg/test.c index d8a0cc6..bbfb070 100644 --- a/demo/arg/test.c +++ b/demo/arg/test.c @@ -11,7 +11,7 @@ Option Opts[6] = {{"T0", T0}, {"T4", T4}, {"T5", T5}}; -void Test_argpase(void *pVoid) { +int Test_argpase(void *pVoid) { OptList *Head = Options_Creat("Head", -1); OptList *t; int i; diff --git a/demo/iic/t_iic.h b/demo/iic/t_iic.h index 05608cf..c2c4c42 100644 --- a/demo/iic/t_iic.h +++ b/demo/iic/t_iic.h @@ -5,6 +5,6 @@ #ifndef HW_LIB_T_IIC_H #define HW_LIB_T_IIC_H -void Test_iic(void *pVoid); +int Test_iic(void *pVoid); #endif //HW_LIB_T_IIC_H diff --git a/demo/iic/test.c b/demo/iic/test.c index 4feb0f1..bd67b2b 100644 --- a/demo/iic/test.c +++ b/demo/iic/test.c @@ -28,7 +28,7 @@ uint8_t SDA_Read() { return l; } -void Test_iic(void *pVoid) { +int Test_iic(void *pVoid) { SW_Dev_IIC dev = { .CLK_SET = CLK_Pin, .SDA_SET = SDA_Set, diff --git a/demo/key/t_key.h b/demo/key/t_key.h index aad7698..a85b12e 100644 --- a/demo/key/t_key.h +++ b/demo/key/t_key.h @@ -1,6 +1,6 @@ #ifndef HW_LIB_T_KEY_H #define HW_LIB_T_KEY_H -void Test_Key(void *pVoid); +int Test_Key(void *pVoid); #endif //HW_LIB_T_KEY_H diff --git a/demo/key/test.c b/demo/key/test.c index c61d981..5111f89 100644 --- a/demo/key/test.c +++ b/demo/key/test.c @@ -38,7 +38,7 @@ void Key_Call(Key_t *key) { } } -void Test_Key(void *pVoid) { +int Test_Key(void *pVoid) { Key_t k1, k2, k3, k4, k5, k6, ks; key_init(&k1, SIM_KEY_UP, 1, SIM_Key_UP); key_init(&k2, SIM_KEY_DOWN, 1, SIM_Key_DOWN); diff --git a/demo/list/t_list.h b/demo/list/t_list.h index ce29f58..8c9b60c 100644 --- a/demo/list/t_list.h +++ b/demo/list/t_list.h @@ -5,7 +5,7 @@ #ifndef HW_LIB_T_LIST_H #define HW_LIB_T_LIST_H -extern void Test_List(void *pVoid); +extern int Test_List(void *pVoid); -extern void Test_Queue(void *pVoid1); +extern int Test_Queue(void *pVoid1); #endif //HW_LIB_T_LIST_H diff --git a/demo/list/test.c b/demo/list/test.c index 690ab10..4a38e86 100644 --- a/demo/list/test.c +++ b/demo/list/test.c @@ -38,7 +38,7 @@ void print(List_t *list) { } } -void Test_List(void *pVoid) { +int Test_List(void *pVoid) { List_t list; list_init(&list); // 初始化链表 @@ -102,7 +102,7 @@ void Test_List(void *pVoid) { list_destroy(&list, NULL); // 销毁链表 } -void Test_Queue(void *pVoid) { +int Test_Queue(void *pVoid) { Queue_List_t *deque = newQueue_List(sizeof(int)); // 创建一个int类型的双端队列 // 测试入队操作 diff --git a/demo/lvgl/t_lvgl.h b/demo/lvgl/t_lvgl.h index c067322..94776c1 100644 --- a/demo/lvgl/t_lvgl.h +++ b/demo/lvgl/t_lvgl.h @@ -5,6 +5,6 @@ #ifndef HW_LIB_T_LVGL_H #define HW_LIB_T_LVGL_H -void Test_lvgl(void *pVoid); +int Test_lvgl(void *pVoid); #endif //HW_LIB_T_LVGL_H diff --git a/demo/lvgl/test.c b/demo/lvgl/test.c index dfe8a81..564f983 100644 --- a/demo/lvgl/test.c +++ b/demo/lvgl/test.c @@ -4,7 +4,7 @@ #include "lvgl.h" #include #include "t_lvgl.h" - +#include "SDL3/SDL.h" static void btn_event_cb(lv_event_t *e) { lv_event_code_t code = lv_event_get_code(e); @@ -33,21 +33,21 @@ void lv_example_get_started_1(void) { lv_obj_center(label); } -void Test_lvgl(void *pVoid) { +int Test_lvgl(void *pVoid) { lv_init(); lv_port_disp_init(); - lv_port_indev_init(); +// lv_port_indev_init(); lv_example_get_started_1(); // lv_demo_widgets(); - printf("\nTEST Widgets\n"); +// printf("\nTEST Widgets\n"); while (1) { /* Periodically call the lv_task handler. * It could be done in a timer interrupt or an OS task too.*/ lv_timer_handler(); lv_tick_inc(5); - Sleep(5); + SDL_Delay(5); } - + return 0; } diff --git a/demo/oled/t_oled.h b/demo/oled/t_oled.h index f1609cb..4eb8e7d 100644 --- a/demo/oled/t_oled.h +++ b/demo/oled/t_oled.h @@ -1,6 +1,6 @@ #ifndef HW_LIB_T_OLED_H #define HW_LIB_T_OLED_H -void Test_OLED(void *pVoid); +int Test_OLED(void *pVoid); #endif //HW_LIB_T_OLED_H diff --git a/demo/oled/test.c b/demo/oled/test.c index a82953d..3ca105d 100644 --- a/demo/oled/test.c +++ b/demo/oled/test.c @@ -111,7 +111,7 @@ OLED_T oled = { .call=Refresh_Call, }; -void Test_OLED(void *pVoid) { +int Test_OLED(void *pVoid) { SIM_OLED_INIT(128, 64, CYAN, 0x0, 5, 0); OLED_Init(&oled); diff --git a/demo/spi/t_spi.h b/demo/spi/t_spi.h index 438eb40..fc23618 100644 --- a/demo/spi/t_spi.h +++ b/demo/spi/t_spi.h @@ -5,5 +5,5 @@ #ifndef HW_LIB_T_SPI_H #define HW_LIB_T_SPI_H -void Test_spi(void *pVoid); +int Test_spi(void *pVoid); #endif //HW_LIB_T_SPI_H diff --git a/demo/spi/test.c b/demo/spi/test.c index f830af8..e1e5731 100644 --- a/demo/spi/test.c +++ b/demo/spi/test.c @@ -32,7 +32,7 @@ uint8_t Miso_Pin() { return l; } -void Test_spi(void *pVoid) { +int Test_spi(void *pVoid) { SW_Dev_Spi ltl = { .MOSI_SET=Mosi_Pin, .SCK_SET=Sck_Pin, diff --git a/demo/task/t_task.h b/demo/task/t_task.h index 13c1f09..8a677be 100644 --- a/demo/task/t_task.h +++ b/demo/task/t_task.h @@ -5,6 +5,6 @@ #ifndef HW_LIB_T_TASK_H #define HW_LIB_T_TASK_H -_Noreturn void Test_task(void *pVoid); +_Noreturn int Test_task(void *pVoid); #endif //HW_LIB_T_TASK_H diff --git a/demo/task/test.c b/demo/task/test.c index fd440d9..7404e28 100644 --- a/demo/task/test.c +++ b/demo/task/test.c @@ -40,7 +40,7 @@ void exampleTimer4Callback(Task_t *task, void *userData) { } } -void Test_task(void *pVoid) { +int Test_task(void *pVoid) { TaskInit(GetTick); TaskCreat(task1, 1000, -1, exampleTimer1Callback, "1000ms CYCLE task"); TaskCreat(task2, 5000, -1, exampleTimer2Callback, "5000ms ONCE task"); diff --git a/demo/tft/t_tft.h b/demo/tft/t_tft.h index f6cc25b..21468c6 100644 --- a/demo/tft/t_tft.h +++ b/demo/tft/t_tft.h @@ -1,6 +1,6 @@ #ifndef HW_LIB_T_TFT_H #define HW_LIB_T_TFT_H -void Test_tft(void *); +int Test_tft(void *); #endif //HW_LIB_T_TFT_H diff --git a/demo/tft/test.c b/demo/tft/test.c index d079aa5..bd04f1e 100644 --- a/demo/tft/test.c +++ b/demo/tft/test.c @@ -9,7 +9,7 @@ TFT_T demo_tft; uint16_t xs = 0, ys = 0, xe = 0, ye = 0; bool fill; -static SIM_Display_t tft_display; +SIM_Display_t tft_display; //屏幕指令 #define WGRAM_CMD 0x5C #define SETXCMD 0x2A @@ -79,7 +79,7 @@ uint8_t tft_senddata(uint8_t *data, size_t len) { if (len == 2) { color_u.u8[1] = *data; color_u.u8[0] = *data++; - SIM_Color_DrawPiexl(&tft_display, (SIM_Color_t) RGB565_to_RGB888(color_u.u16, true), xs, ys); + SIM_Color_DrawPiexl(&tft_display, (SIM_Color_t) RGB565_to_ARGB8888(color_u.u16, true), xs, ys); // LOGT("Piexl","color:%x,x:%d,y:%d,len:%d",color_u.u16,xs,ys,len); // SIM_Color_ImgFromBuffer(color,xs, ys, uint16_t width, 1) } else { @@ -88,7 +88,7 @@ uint8_t tft_senddata(uint8_t *data, size_t len) { data++; color_u.u8[0] = *data; data++; - color[i] = RGB565_to_RGB888(color_u.u16, true) | 0xFF000000; + color[i] = RGB565_to_ARGB8888(color_u.u16, true); } SIM_Color_ImgFromBuffer(&tft_display, color, xs, ys, len / 2 - 1, 1); // SIM_Color_DrawHLineBuffer(color, xs, ys, len / 2); @@ -103,8 +103,7 @@ uint8_t tft_senddata(uint8_t *data, size_t len) { return result; } -void Test_tft(void *) { - +int Test_tft(void *arg) { //设备信息预填充 demo_tft.width = 480;//实际如有支持不用填(如ST7735/7796) demo_tft.height = 320;//实际如有支持不用填(如ST7735/7796) @@ -159,9 +158,10 @@ void Test_tft(void *) { TFT_ShowBar(&demo_tft, 0, 142, demo_tft.width, 12, p); TFT_ShowBar(&demo_tft, 0, 155, demo_tft.width, 3, p); } - while (1) { - - Sleep(5); - } - +// while (1) { +// +// Sleep(5); +// } + SIM_Display_STOP(&tft_display); + return 0; } diff --git a/main.c b/main.c index 1705473..c2fd844 100644 --- a/main.c +++ b/main.c @@ -160,15 +160,15 @@ int main(int argc, char *argv[]) { // char str[] = "123.456"; // float result = Str2Float(str); // printf("Result: %.3f\n", result); -// Test_Run("SPI", Test_spi); -// Test_Run("IIC", Test_iic); -// Test_Run("ArgPase", Test_argpase); -// Test_Run("List", Test_List); +// Test_Run("SPI", Test_spi,NULL); +// Test_Run("IIC", Test_iic,NULL); +// Test_Run("ArgPase", Test_argpase,NULL); +// Test_Run("List", Test_List,NULL); // Test_RunTime("Key", Test_Key); // Test_RunTime("Queue", Test_Queue); // Test_RunTime("Task", Test_task); -// Test_Run("OLED", Test_OLED); -// Test_Run("LVGL", Test_lvgl); - Test_RunTime("TFT", Test_tft); +// Test_RunTime("OLED", Test_OLED); + Test_RunTime("LVGL", Test_lvgl); +// Test_RunTime("TFT", Test_tft); return 0; } diff --git a/sim/Test/sim_test.cpp b/sim/Test/sim_test.cpp index a371e9b..b87d58c 100644 --- a/sim/Test/sim_test.cpp +++ b/sim/Test/sim_test.cpp @@ -7,7 +7,7 @@ #include #include "sim_test.h" -void Test_RunTime(char *name, void (*pFunction)(void *)) { +void Test_RunTime(char *name, int (*pFunction)(void *)) { clock_t start, end; double cpu_time_used; @@ -24,11 +24,7 @@ void Test_RunTime(char *name, void (*pFunction)(void *)) { printf("\nTime taken by %s: %f seconds\n", name, cpu_time_used); } -void Test_Run(char *name, void (*pFunction)(void *)) { - - +SDL_Thread *Test_Run(char *name, int (*pFunction)(void *), void *arg) { printf("\n------< %s TEST >------\n", name); - _beginthread(pFunction, 0, NULL); - - + return ThreadCreat(pFunction, name, arg); } diff --git a/sim/Test/sim_test.h b/sim/Test/sim_test.h index 98a74c9..b21266c 100644 --- a/sim/Test/sim_test.h +++ b/sim/Test/sim_test.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif - +#include "sim_thread.h" /** * @brief 测试函数执行时间 * @param name: [输入] 测试名称 @@ -15,9 +15,9 @@ extern "C" { * @return void * @example Test("FunctionName", functionName); **/ -void Test_RunTime(char *name, void (*pFunction)(void *)); +void Test_RunTime(char *name, int (*pFunction)(void *)); -void Test_Run(char *name, void (*pFunction)(void *)); +SDL_Thread *Test_Run(char *name, int (*pFunction)(void *), void *arg); #ifdef __cplusplus diff --git a/sim/display/sim_display.cpp b/sim/display/sim_display.cpp index 162281d..09f8068 100644 --- a/sim/display/sim_display.cpp +++ b/sim/display/sim_display.cpp @@ -4,7 +4,7 @@ #define GET_BIT(x, bit) ((x & (1 << bit)) >> bit) -uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) { +uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR) { uint8_t r5 = (rgb565 >> 11) & 0x1F; uint8_t g6 = (rgb565 >> 5) & 0x3F; uint8_t b5 = rgb565 & 0x1F; @@ -14,12 +14,11 @@ uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) { uint8_t b8 = (b5 * 527 + 23) >> 6; if (isBGR) { - return (b8 << 16) | (g8 << 8) | r8; + return 0xFF000000 | (b8 << 16) | (g8 << 8) | r8; } else { - return (r8 << 16) | (g8 << 8) | b8; + return 0xFF000000 | (r8 << 16) | (g8 << 8) | b8; } } - #ifndef USER_SDL3 static uint32_t pixelColor, backgroundColor; static int scaleFactor, w, h; @@ -211,8 +210,8 @@ void SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, void SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye) { SIM_Color_t color; - for (int y_i = ys; y_i < ye; y_i++) { - for (int x_i = xs; x_i < xe; x_i++) { + for (int y_i = ys; y_i <= ye; y_i++) { + for (int x_i = xs; x_i <= xe; x_i++) { color.full = *buf; SIM_Color_DrawPiexl(display, color, x_i, y_i); buf++; @@ -221,6 +220,9 @@ SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uin SDL_RenderPresent(display->renderer); } +void SIM_Display_Refresh(SIM_Display_t *display) { + SDL_RenderPresent(display->renderer); +} void SIM_Display_STOP(SIM_Display_t *display) { SDL_DestroyRenderer(display->renderer); diff --git a/sim/display/sim_display.h b/sim/display/sim_display.h index 2875d2e..e567608 100644 --- a/sim/display/sim_display.h +++ b/sim/display/sim_display.h @@ -153,7 +153,6 @@ typedef struct { bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, SIM_Display_t *display); - /** * @brief 在指定的坐标位置绘制一个像素点 * @param display: [输入] 输入窗口实例 @@ -163,6 +162,13 @@ bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint */ void SIM_Color_DrawPiexl(SIM_Display_t *display, SIM_Color_t color, uint16_t x, uint16_t y); +/** + * @brief 从颜色缓冲区绘制单色图像到模拟显示器 + * @param display 模拟显示器指针 + * @param buf 颜色缓冲区指针 + * @param width 绘制区域宽度 + * @param height 绘制区域高度 + */ void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t width, uint16_t height); /** @@ -176,8 +182,8 @@ void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t * @return void * @example SIM_Color_ImgFromBuffer(buf, 100, 50, 320, 240); **/ -void -SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint16_t y, uint16_t width, uint16_t height); +void SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint16_t y, + uint16_t width, uint16_t height); /** * @brief 从缓冲区中填充颜色 @@ -193,6 +199,12 @@ SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint1 void SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye); +/** + * @brief 刷新模拟显示器 + * + * @param display 模拟显示器指针 + */ +void SIM_Display_Refresh(SIM_Display_t *display); /** * @brief 停止模拟 显示 @@ -204,7 +216,7 @@ void SIM_Display_STOP(SIM_Display_t *display); #endif -uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR); +uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR); #ifdef __cplusplus } diff --git a/sim/lvgl/lv_conf.h b/sim/lvgl/lv_conf.h index 8f1b1e3..23ab8f9 100644 --- a/sim/lvgl/lv_conf.h +++ b/sim/lvgl/lv_conf.h @@ -24,7 +24,7 @@ *====================*/ /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ -#define LV_COLOR_DEPTH 16 +#define LV_COLOR_DEPTH 32 /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ #define LV_COLOR_16_SWAP 0 @@ -230,7 +230,7 @@ *-----------*/ /*Enable the log module*/ -#define LV_USE_LOG 1 +#define LV_USE_LOG 0 #if LV_USE_LOG /*How important log should be added: diff --git a/sim/lvgl/lv_port_disp.cpp b/sim/lvgl/lv_port_disp.cpp index 75b9382..d219280 100644 --- a/sim/lvgl/lv_port_disp.cpp +++ b/sim/lvgl/lv_port_disp.cpp @@ -44,7 +44,7 @@ static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_ /********************** * STATIC VARIABLES **********************/ -static SIM_Display_t lvgl_display; +SIM_Display_t lvgl_display; /********************** * MACROS **********************/ @@ -142,7 +142,7 @@ void lv_port_disp_init(void) static void disp_init(void) { /*You code here*/ - SIM_Display_Init("LVGL", MY_DISP_HOR_RES, MY_DISP_VER_RES, 0xffffff, BLACK, 1, &lvgl_display); + SIM_Display_Init("LVGL", MY_DISP_HOR_RES, MY_DISP_VER_RES, 0xffffff, BLACK, 2, &lvgl_display); } volatile bool disp_flush_enabled = true; @@ -165,7 +165,7 @@ void colortorgb24(lv_color_t* color_p, uint32_t* color, size_t len) { while (len) { - *color = RGB565_to_RGB888(color_p->full, false); + *color = RGB565_to_ARGB8888(color_p->full, false); color_p++; color++; len--; @@ -180,13 +180,13 @@ static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_ if (disp_flush_enabled) { /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/ - uint32_t* color; - size_t l = (area->x2 - area->x1) * (area->y2 - area->y1); - color = (uint32_t*)malloc(sizeof(uint32_t) * l); - - colortorgb24(color_p, color, l); - SIM_Color_FillFromBuffer(&lvgl_display, color, area->x1, area->y1, area->x2, area->y2); - free(color); +// uint32_t* color; + size_t l = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1); +// color = (uint32_t*)malloc(sizeof(uint32_t) * l); +// +// colortorgb24(color_p, color, l); + SIM_Color_FillFromBuffer(&lvgl_display, (uint32_t *) color_p, area->x1, area->y1, area->x2, area->y2); +// free(color); } /*IMPORTANT!!! diff --git a/sim/thread/sim_thread.h b/sim/thread/sim_thread.h index 9866234..c445d7a 100644 --- a/sim/thread/sim_thread.h +++ b/sim/thread/sim_thread.h @@ -4,10 +4,13 @@ extern "C" { #endif -typedef void (*Thread_Func_t)(void *pArg); +#include "SDL3/SDL.h" -void ThreadCreat(Thread_Func_t func, unsigned int stackSize, void *pArg); -void ThreadStop(); +typedef int (*Thread_Func_t)(void *pArg); + +SDL_Thread *ThreadCreat(Thread_Func_t func, char *name, void *pArg); + +void ThreadStop(SDL_Thread *t); #ifdef __cplusplus } #endif diff --git a/sim/thread/thread.cpp b/sim/thread/thread.cpp index 40e5ff2..34224f0 100644 --- a/sim/thread/thread.cpp +++ b/sim/thread/thread.cpp @@ -1,11 +1,17 @@ #include "sim_thread.h" -#include + #include -void ThreadCreat(Thread_Func_t func, unsigned int stackSize, void *pArg) { - _beginthread(func, stackSize, pArg); +SDL_Thread *ThreadCreat(Thread_Func_t func, char *name, void *pArg) { + SDL_Thread *t = SDL_CreateThread(func, name, NULL); + if (!t) { + SDL_Log("CreateThread: %s", SDL_GetError); + return nullptr; + + } + return t; } -void ThreadStop() { - _endthread(); +void ThreadStop(SDL_Thread *t) { + SDL_WaitThread(t, NULL); }