diff --git a/src/main.c b/src/main.c index 09e34c9..f875674 100644 --- a/src/main.c +++ b/src/main.c @@ -513,7 +513,10 @@ static void processGamepad() static void pollEvent() { tic80_input* input = &platform.studio->tic->ram.input; - input->mouse.btns = 0; + + { + input->mouse.btns = 0; + } SDL_Event event; @@ -784,6 +787,44 @@ static void renderGamepad() platform.gamepad.show = false; } +static void renderCursor() +{ + if(platform.studio->tic->ram.vram.vars.cursor.system) + { + SDL_SystemCursor sdlCursor = SDL_SYSTEM_CURSOR_ARROW; + + switch(platform.studio->tic->ram.vram.vars.cursor.sprite) + { + case tic_cursor_hand: sdlCursor = SDL_SYSTEM_CURSOR_HAND; break; + case tic_cursor_ibeam: sdlCursor = SDL_SYSTEM_CURSOR_IBEAM; break; + default: sdlCursor = SDL_SYSTEM_CURSOR_ARROW; + } + + SDL_SetCursor(SDL_CreateSystemCursor(sdlCursor)); + } + else + { + // render cursor here + } + +// if(studioImpl.mode == TIC_RUN_MODE && !studioImpl.studio.tic->input.mouse) +// { +// SDL_ShowCursor(SDL_DISABLE); +// return; +// } +// if(studioImpl.mode == TIC_RUN_MODE && studioImpl.studio.tic->ram.vram.vars.cursor) +// { +// SDL_ShowCursor(SDL_DISABLE); +// blitCursor(studioImpl.studio.tic->ram.sprites.data[studioImpl.studio.tic->ram.vram.vars.cursor].data); +// return; +// } + +// SDL_ShowCursor(getConfig()->theme.cursor.sprite >= 0 ? SDL_DISABLE : SDL_ENABLE); + +// if(getConfig()->theme.cursor.sprite >= 0) +// blitCursor(studioImpl.studio.tic->config.bank0.tiles.data[getConfig()->theme.cursor.sprite].data); +} + static void tick() { pollEvent(); @@ -808,6 +849,8 @@ static void tick() blitTexture(); + renderCursor(); + // if(platform.mode == TIC_RUN_MODE && platform.studio->tic->input.gamepad) renderGamepad(); diff --git a/src/studio.c b/src/studio.c index 334fe55..7ef1120 100644 --- a/src/studio.c +++ b/src/studio.c @@ -130,7 +130,7 @@ static struct // SDL_Texture* texture; // const u8* src; - tic_cursor system; + // tic_cursor system; } mouse; struct @@ -1153,7 +1153,6 @@ bool checkMouseDown(const tic_rect* rect, s32 button) return state->down && pointInRect(&state->start, rect); } - bool getGesturePos(tic_point* pos) { if(studioImpl.gesture.active) @@ -1168,8 +1167,9 @@ bool getGesturePos(tic_point* pos) void setCursor(tic_cursor id) { - if(id != tic_cursor_arrow) - studioImpl.mouse.system = id; + tic_mem* tic = studioImpl.studio.tic; + + tic->ram.vram.vars.cursor.sprite = id; } void hideDialog() @@ -2969,6 +2969,9 @@ static void processMouseStates() tic_mem* tic = studioImpl.studio.tic; + tic->ram.vram.vars.cursor.sprite = tic_cursor_arrow; + tic->ram.vram.vars.cursor.system = true; + for(int i = 0; i < COUNT_OF(studioImpl.mouse.state); i++) { MouseState* state = &studioImpl.mouse.state[i]; diff --git a/src/tic.h b/src/tic.h index abb39fe..0ef2df2 100644 --- a/src/tic.h +++ b/src/tic.h @@ -385,7 +385,12 @@ typedef union s8 y; } offset; - u8 cursor; + struct + { + u8 sprite:7; + bool system:1; + } cursor; + } vars; u8 reserved[4];