this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

libretro: Use memset() to set the initial TIC-80 state (#2591)

authored by

Rob Loach and committed by
GitHub
ed1de626 b255c613

+12 -19
+12 -19
src/system/libretro/tic80_libretro.c
··· 125 125 if (environ_cb) { 126 126 struct retro_message msg = { 127 127 info, 128 - 400 128 + 6 * TIC80_FRAMERATE 129 129 }; 130 130 environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &msg); 131 131 } ··· 176 176 return; 177 177 } 178 178 179 - // Initialize the base state. 179 + // Initialize the base state with some default values. 180 180 state = (struct tic80_state*) malloc(sizeof(struct tic80_state)); 181 - state->quit = false; 182 - state->cropBorder = false; 183 - state->pointerDevice = POINTER_DEVICE_MOUSE; 181 + memset(state, 0, sizeof(struct tic80_state)); 184 182 state->pointerSpeed = 1.0f; 185 - state->slowGamepadMouse = false; 186 - state->mouseCursor = MOUSE_CURSOR_NONE; 187 183 state->mouseCursorColor = 15; 188 184 state->analogDeadzone = (int)(0.15f * (float)RETRO_ANALOG_RANGE); 189 - state->mouseX = 0; 190 - state->mouseY = 0; 191 - state->mousePreviousX = 0; 192 - state->mousePreviousY = 0; 193 - state->mouseXAccumulator = 0.0f; 194 - state->mouseYAccumulator = 0.0f; 195 - state->mouseHideTimer = state->mouseHideTimerStart; 196 185 197 186 // Initialize the keyboard mappings. 198 187 state->keymap[RETROK_UNKNOWN] = tic_key_unknown; ··· 766 755 state->mousePreviousX = state->mouseX; 767 756 state->mousePreviousY = state->mouseY; 768 757 } 769 - if (state->mouseHideTimer > 0) { 758 + else if (state->mouseHideTimer > 0) { 770 759 state->mouseHideTimer--; 771 760 } 772 761 ··· 782 771 void tic80_libretro_mousecursor(tic80* game, tic80_mouse* mouse, enum mouse_cursor_type cursortype) 783 772 { 784 773 TIC_UNUSED(mouse); 774 + 785 775 // Only draw the mouse cursor if it's active. 786 - if (state->mouseHideTimer == 0) { 776 + if (state->mouseHideTimerStart > 0 && state->mouseHideTimer == 0) { 787 777 return; 788 778 } 789 779 790 780 tic_mem* tic = (tic_mem*)state->tic; 791 781 792 - // Determine which cursor to draw. 782 + // Draw the cursor. 783 + // TODO: Fix the cursor not being drawn on the screen by possibly modifing game->screen directly. 793 784 switch (cursortype) { 794 785 case MOUSE_CURSOR_NONE: 795 786 // Nothing. ··· 974 965 } 975 966 976 967 // Mouse Hide Delay 977 - state->mouseHideTimerStart = -1; 968 + state->mouseHideTimerStart = 0; 978 969 var.key = "tic80_mouse_hide_delay"; 979 970 var.value = NULL; 980 971 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { 981 972 state->mouseHideTimerStart = atoi(var.value); 982 973 if (state->mouseHideTimerStart > 0) { 983 974 state->mouseHideTimerStart = state->mouseHideTimerStart * TIC80_FRAMERATE; 975 + state->mouseHideTimer = state->mouseHideTimerStart; 984 976 } 985 977 else { 986 - state->mouseHideTimerStart = -1; 978 + state->mouseHideTimerStart = 0; 979 + state->mouseHideTimer = 0; 987 980 } 988 981 } 989 982