History

Pushed v1.17 code

- Fixed some bugs with sample data marking/hand-drawing and sample loop pin dragging, which appeared in v1.16.

Olav Sørensen committed 6 years ago

Commit 4cb9cdc1 parent c8e0c5e7 files · +101 −115Browse files

Unified · Split

7 files
  1. src/ft2_header.h +1 −1
  2. src/ft2_main.c +1 −1
  3. src/ft2_mouse.c +12 −12
  4. src/ft2_mouse.h +0 −1
  5. src/ft2_replayer.c +1 −1
  6. src/ft2_sample_ed.c +82 −95
  7. src/ft2_video.c +4 −4
src/ft2_header.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#endif12#endif
13#include "ft2_replayer.h"13#include "ft2_replayer.h"
14 14
15#define PROG_VER_STR "1.16"15#define PROG_VER_STR "1.17"
16 16
17// do NOT change these! It will only mess things up...17// do NOT change these! It will only mess things up...
18 18
src/ft2_main.c+1−1
@@ -420,7 +420,7 @@ static void setupPerfFreq(void) · 419 unmodified lines
420 dFrac = modf(editor.dPerfFreq / VBLANK_HZ, &dInt);420 dFrac = modf(editor.dPerfFreq / VBLANK_HZ, &dInt);
421 421
422 // integer part422 // integer part
423 video.vblankTimeLen = (uint32_t)dInt;423 video.vblankTimeLen = (int32_t)dInt;
424 424
425 // fractional part scaled to 0..2^32-1425 // fractional part scaled to 0..2^32-1
426 dFrac *= UINT32_MAX;426 dFrac *= UINT32_MAX;
src/ft2_mouse.c+12−12
@@ -718,6 +718,18 @@ void mouseButtonDownHandler(uint8_t mouseButton) · 717 unmodified lines
718#endif718#endif
719}719}
720 720
721static void sendMouseButtonUpEvent(uint8_t button)
722{
723 SDL_Event event;
724
725 memset(&event, 0, sizeof (event));
726
727 event.type = SDL_MOUSEBUTTONUP;
728 event.button.button = button;
729
730 SDL_PushEvent(&event);
731}
732
721void handleLastGUIObjectDown(void)733void handleLastGUIObjectDown(void)
722{734{
723 if (mouse.lastUsedObjectType == OBJECT_NONE)735 if (mouse.lastUsedObjectType == OBJECT_NONE)
@@ -773,18 +785,6 @@ void updateMouseScaling(void) · 49 unmodified lines
773 if (video.renderH > 0.0) video.dMouseYMul = (double)SCREEN_H / video.renderH;785 if (video.renderH > 0.0) video.dMouseYMul = (double)SCREEN_H / video.renderH;
774}786}
775 787
776void sendMouseButtonUpEvent(uint8_t button)
777{
778 SDL_Event event;
779
780 memset(&event, 0, sizeof (event));
781
782 event.type = SDL_MOUSEBUTTONUP;
783 event.button.button = button;
784
785 SDL_PushEvent(&event);
786}
787
788void readMouseXY(void)788void readMouseXY(void)
789{789{
790 int32_t mx, my, windowX, windowY;790 int32_t mx, my, windowX, windowY;
src/ft2_mouse.h+0−1
@@ -31,7 +31,6 @@ struct mouse_t · 30 unmodified lines
31#define MOUSE_GLASS_ANI_FRAMES 2231#define MOUSE_GLASS_ANI_FRAMES 22
32#define MOUSE_CLOCK_ANI_FRAMES 532#define MOUSE_CLOCK_ANI_FRAMES 5
33 33
34void sendMouseButtonUpEvent(uint8_t button);
35void freeMouseCursors(void);34void freeMouseCursors(void);
36bool createMouseCursors(void);35bool createMouseCursors(void);
37void setMousePosToCenter(void);36void setMousePosToCenter(void);
src/ft2_replayer.c+1−1
@@ -334,7 +334,7 @@ void calcReplayRate(int32_t rate) // 100% FT2-accurate routine, do not touch! · 333 unmodified lines
334 dVal = dMul * (256.0 * 65536.0 * 8363.0);334 dVal = dMul * (256.0 * 65536.0 * 8363.0);
335 frequenceMulFactor = (int32_t)(dVal + 0.5);335 frequenceMulFactor = (int32_t)(dVal + 0.5);
336 336
337 audio.dScopeFreqMul = rate * (1.0 / SCOPE_HZ);337 audio.dScopeFreqMul = rate / SCOPE_HZ;
338 338
339 // for volume ramping (FT2 doesn't round here)339 // for volume ramping (FT2 doesn't round here)
340 audio.quickVolSizeVal = rate / 200;340 audio.quickVolSizeVal = rate / 200;
src/ft2_sample_ed.c+82−95
@@ -1180,16 +1180,6 @@ static void setSampleRange(int32_t start, int32_t end) · 1179 unmodified lines
1180 if (end < 0)1180 if (end < 0)
1181 end = 0;1181 end = 0;
1182 1182
1183 // kludge so that you can mark the last sample of what we see
1184 // XXX: This doesn't seem to work properly!
1185 if (end == SCREEN_W-1)
1186 {
1187 if (smpEd_ViewSize < SAMPLE_AREA_WIDTH) // zoomed in
1188 end += 2;
1189 else if (smpEd_ScrPos+smpEd_ViewSize >= s->len)
1190 end++;
1191 }
1192
1193 smpEd_Rx1 = scr2SmpPos(start);1183 smpEd_Rx1 = scr2SmpPos(start);
1194 smpEd_Rx2 = scr2SmpPos(end);1184 smpEd_Rx2 = scr2SmpPos(end);
1195 1185
@@ -3095,12 +3085,30 @@ static void setRightLoopPinPos(int32_t x) · 1899 unmodified lines
3095 updateLoopsOnMouseUp = true;3085 updateLoopsOnMouseUp = true;
3096}3086}
3097 3087
3088static int32_t mouseYToSampleY(int32_t my)
3089{
3090 int32_t tmp32;
3091
3092 if (my == 250) // center
3093 {
3094 return 128;
3095 }
3096 else
3097 {
3098 tmp32 = my - 174;
3099 tmp32 = ((tmp32 << 8) + (SAMPLE_AREA_HEIGHT/2)) / SAMPLE_AREA_HEIGHT;
3100 tmp32 = CLAMP(tmp32, 0, 255);
3101 tmp32 ^= 0xFF;
3102 }
3103
3104 return tmp32;
3105}
3106
3098static void editSampleData(bool mouseButtonHeld)3107static void editSampleData(bool mouseButtonHeld)
3099{3108{
3100 int8_t *ptr8;3109 int8_t *ptr8;
3101 int16_t *ptr16;3110 int16_t *ptr16;
3102 int32_t mx, my, tmp32, p, vl, tvl, r, rl, rvl, start, end;3111 int32_t mx, my, tmp32, p, vl, tvl, r, rl, rvl, start, end;
3103 double dVal;
3104 sampleTyp *s = getCurSample();3112 sampleTyp *s = getCurSample();
3105 3113
3106 if (s == NULL || s->pek == NULL || s->len <= 0)3114 if (s == NULL || s->pek == NULL || s->len <= 0)
@@ -3109,6 +3117,9 @@ static void editSampleData(bool mouseButtonHeld) · 2 unmodified lines
3109 // ported directly from FT2 and slightly modified3117 // ported directly from FT2 and slightly modified
3110 3118
3111 mx = mouse.x;3119 mx = mouse.x;
3120 if (mx > SCREEN_W)
3121 mx = SCREEN_W;
3122
3112 my = mouse.y;3123 my = mouse.y;
3113 3124
3114 if (!mouseButtonHeld)3125 if (!mouseButtonHeld)
@@ -3121,17 +3132,7 @@ static void editSampleData(bool mouseButtonHeld) · 6 unmodified lines
3121 if (s->typ & 16)3132 if (s->typ & 16)
3122 lastDrawX >>= 1;3133 lastDrawX >>= 1;
3123 3134
3124 if (my == 250) // center3135 lastDrawY = mouseYToSampleY(my);
3125 {
3126 lastDrawY = 128;
3127 }
3128 else
3129 {
3130 dVal = (my - 174) * (256.0 / SAMPLE_AREA_HEIGHT);
3131 lastDrawY = (int32_t)(dVal + 0.5);
3132 lastDrawY = CLAMP(lastDrawY, 0, 255);
3133 lastDrawY ^= 0xFF;
3134 }
3135 3136
3136 lastMouseX = mx;3137 lastMouseX = mx;
3137 lastMouseY = my;3138 lastMouseY = my;
@@ -3141,10 +3142,6 @@ static void editSampleData(bool mouseButtonHeld) · 3 unmodified lines
3141 return; // don't continue if we didn't move the mouse3142 return; // don't continue if we didn't move the mouse
3142 }3143 }
3143 3144
3144 // kludge so that you can edit the very end of the sample
3145 if (mx == SCREEN_W-1 && smpEd_ScrPos+smpEd_ViewSize >= s->len)
3146 mx++;
3147
3148 if (mx != lastMouseX)3145 if (mx != lastMouseX)
3149 {3146 {
3150 p = scr2SmpPos(mx);3147 p = scr2SmpPos(mx);
@@ -3157,23 +3154,9 @@ static void editSampleData(bool mouseButtonHeld) · 6 unmodified lines
3157 }3154 }
3158 3155
3159 if (!keyb.leftShiftPressed && my != lastMouseY)3156 if (!keyb.leftShiftPressed && my != lastMouseY)
3160 {3157 vl = mouseYToSampleY(my);
3161 if (my == 250) // center
3162 {
3163 vl = 128;
3164 }
3165 else
3166 {
3167 dVal = (my - 174) * (256.0 / SAMPLE_AREA_HEIGHT);
3168 vl = (int32_t)(dVal + 0.5);
3169 vl = CLAMP(vl, 0, 255);
3170 vl ^= 0xFF;
3171 }
3172 }
3173 else3158 else
3174 {
3175 vl = lastDrawY;3159 vl = lastDrawY;
3176 }
3177 3160
3178 lastMouseX = mx;3161 lastMouseX = mx;
3179 lastMouseY = my;3162 lastMouseY = my;
@@ -3213,30 +3196,31 @@ static void editSampleData(bool mouseButtonHeld) · 33 unmodified lines
3213 3196
3214 if (p == lastDrawX)3197 if (p == lastDrawX)
3215 {3198 {
3216 int16_t smpVal = (int16_t)((vl << 8) ^ 0x8000);3199 const int16_t smpVal = (int16_t)((vl << 8) ^ 0x8000);
3217 for (rl = start; rl < end; rl++)3200 for (rl = start; rl < end; rl++)
3218 ptr16[rl] = smpVal;3201 ptr16[rl] = smpVal;
3219 }3202 }
3220 else3203 else
3221 {3204 {
3222 int32_t y = lastDrawY - vl;3205 int32_t y = lastDrawY - vl;
3223 uint32_t x = lastDrawX - p;3206 int32_t x = lastDrawX - p;
3224 3207
3225 int32_t xMul = 0xFFFFFFFF;
3226 if (x != 0)3208 if (x != 0)
3227 xMul /= x;
3228
3229 int32_t i = 0;
3230 for (rl = start; rl < end; rl++)
3231 {3209 {
3232 tvl = y * i;3210 double dMul = 1.0 / x;
3233 tvl = ((int64_t)tvl * xMul) >> 32; // tvl /= x;3211 int32_t i = 0;
3234 tvl += vl;3212
3235 tvl <<= 8;3213 for (rl = start; rl < end; rl++)
3236 tvl ^= 0x8000;3214 {
3237 3215 tvl = y * i;
3238 ptr16[rl] = (int16_t)tvl;3216 tvl = (int32_t)(tvl * dMul); // tvl /= x
3239 i++;3217 tvl += vl;
3218 tvl <<= 8;
3219 tvl ^= 0x8000;
3220
3221 ptr16[rl] = (int16_t)tvl;
3222 i++;
3223 }
3240 }3224 }
3241 }3225 }
3242 }3226 }
@@ -3256,29 +3240,30 @@ static void editSampleData(bool mouseButtonHeld) · 13 unmodified lines
3256 3240
3257 if (p == lastDrawX)3241 if (p == lastDrawX)
3258 {3242 {
3259 int8_t smpVal = (int8_t)(vl ^ 0x80);3243 const int8_t smpVal = (int8_t)(vl ^ 0x80);
3260 for (rl = start; rl < end; rl++)3244 for (rl = start; rl < end; rl++)
3261 ptr8[rl] = smpVal;3245 ptr8[rl] = smpVal;
3262 }3246 }
3263 else3247 else
3264 {3248 {
3265 int32_t y = lastDrawY - vl;3249 int32_t y = lastDrawY - vl;
3266 uint32_t x = lastDrawX - p;3250 int32_t x = lastDrawX - p;
3267 3251
3268 int32_t xMul = 0xFFFFFFFF;
3269 if (x != 0)3252 if (x != 0)
3270 xMul /= x;
3271
3272 int32_t i = 0;
3273 for (rl = start; rl < end; rl++)
3274 {3253 {
3275 tvl = y * i;3254 double dMul = 1.0 / x;
3276 tvl = ((int64_t)tvl * xMul) >> 32; // tvl /= x;3255 int32_t i = 0;
3277 tvl += vl;3256
3278 tvl ^= 0x80;3257 for (rl = start; rl < end; rl++)
3258 {
3259 tvl = y * i;
3260 tvl = (int32_t)(tvl * dMul); // tvl /= x
3261 tvl += vl;
3262 tvl ^= 0x80;
3279 3263
3280 ptr8[rl] = (int8_t)tvl;3264 ptr8[rl] = (int8_t)tvl;
3281 i++;3265 i++;
3266 }
3282 }3267 }
3283 }3268 }
3284 }3269 }
@@ -3291,11 +3276,14 @@ static void editSampleData(bool mouseButtonHeld) · 6 unmodified lines
3291 3276
3292void handleSampleDataMouseDown(bool mouseButtonHeld)3277void handleSampleDataMouseDown(bool mouseButtonHeld)
3293{3278{
3294 int32_t tmp, leftLoopPinPos, rightLoopPinPos;3279 int32_t mx, my, leftLoopPinPos, rightLoopPinPos;
3295 3280
3296 if (editor.curInstr == 0)3281 if (editor.curInstr == 0)
3297 return;3282 return;
3298 3283
3284 mx = CLAMP(mouse.x, 0, SCREEN_W+8); // allow some pixels outside of the screen
3285 my = CLAMP(mouse.y, 0, SCREEN_H-1);
3286
3299 if (!mouseButtonHeld)3287 if (!mouseButtonHeld)
3300 {3288 {
3301 editor.ui.rightLoopPinMoving = false;3289 editor.ui.rightLoopPinMoving = false;
@@ -3303,41 +3291,41 @@ void handleSampleDataMouseDown(bool mouseButtonHeld) · 1 unmodified line
3303 editor.ui.sampleDataOrLoopDrag = -1;3291 editor.ui.sampleDataOrLoopDrag = -1;
3304 3292
3305 mouseXOffs = 0;3293 mouseXOffs = 0;
3306 lastMouseX = mouse.x;3294 lastMouseX = mx;
3307 lastMouseY = mouse.y;3295 lastMouseY = my;
3308 3296
3309 mouse.lastUsedObjectType = OBJECT_SMPDATA;3297 mouse.lastUsedObjectType = OBJECT_SMPDATA;
3310 3298
3311 if (mouse.leftButtonPressed)3299 if (mouse.leftButtonPressed)
3312 {3300 {
3313 // move loop pins3301 // move loop pins
3314 if (mouse.y < 183)3302 if (my < 183)
3315 {3303 {
3316 leftLoopPinPos = getSpritePosX(SPRITE_LEFT_LOOP_PIN);3304 leftLoopPinPos = getSpritePosX(SPRITE_LEFT_LOOP_PIN);
3317 if (mouse.x >= leftLoopPinPos && mouse.x <= leftLoopPinPos+16)3305 if (mx >= leftLoopPinPos && mx <= leftLoopPinPos+16)
3318 {3306 {
3319 mouseXOffs = (leftLoopPinPos + 8) - mouse.x;3307 mouseXOffs = (leftLoopPinPos + 8) - mx;
3320 3308
3321 editor.ui.sampleDataOrLoopDrag = true;3309 editor.ui.sampleDataOrLoopDrag = true;
3322 3310
3323 setLeftLoopPinState(true);3311 setLeftLoopPinState(true);
3324 lastMouseX = mouse.x;3312 lastMouseX = mx;
3325 3313
3326 editor.ui.leftLoopPinMoving = true;3314 editor.ui.leftLoopPinMoving = true;
3327 return;3315 return;
3328 }3316 }
3329 }3317 }
3330 else if (mouse.y > 318)3318 else if (my > 318)
3331 {3319 {
3332 rightLoopPinPos = getSpritePosX(SPRITE_RIGHT_LOOP_PIN);3320 rightLoopPinPos = getSpritePosX(SPRITE_RIGHT_LOOP_PIN);
3333 if (mouse.x >= rightLoopPinPos && mouse.x <= rightLoopPinPos+16)3321 if (mx >= rightLoopPinPos && mx <= rightLoopPinPos+16)
3334 {3322 {
3335 mouseXOffs = (rightLoopPinPos + 8) - mouse.x;3323 mouseXOffs = (rightLoopPinPos + 8) - mx;
3336 3324
3337 editor.ui.sampleDataOrLoopDrag = true;3325 editor.ui.sampleDataOrLoopDrag = true;
3338 3326
3339 setRightLoopPinState(true);3327 setRightLoopPinState(true);
3340 lastMouseX = mouse.x;3328 lastMouseX = mx;
3341 3329
3342 editor.ui.rightLoopPinMoving = true;3330 editor.ui.rightLoopPinMoving = true;
3343 return;3331 return;
@@ -3345,9 +3333,10 @@ void handleSampleDataMouseDown(bool mouseButtonHeld) · 1 unmodified line
3345 }3333 }
3346 3334
3347 // mark data3335 // mark data
3348 editor.ui.sampleDataOrLoopDrag = mouse.x;3336 lastMouseX = mx;
3349 lastMouseX = editor.ui.sampleDataOrLoopDrag;3337 editor.ui.sampleDataOrLoopDrag = mx;
3350 setSampleRange(editor.ui.sampleDataOrLoopDrag, editor.ui.sampleDataOrLoopDrag);3338
3339 setSampleRange(mx, mx);
3351 }3340 }
3352 else if (mouse.rightButtonPressed)3341 else if (mouse.rightButtonPressed)
3353 {3342 {
@@ -3365,33 +3354,31 @@ void handleSampleDataMouseDown(bool mouseButtonHeld) · 11 unmodified lines
3365 return;3354 return;
3366 }3355 }
3367 3356
3368 if (mouse.x != lastMouseX)3357 if (mx != lastMouseX)
3369 {3358 {
3370 if (mouse.leftButtonPressed)3359 if (mouse.leftButtonPressed)
3371 {3360 {
3372 if (editor.ui.leftLoopPinMoving)3361 if (editor.ui.leftLoopPinMoving)
3373 {3362 {
3374 lastMouseX = mouse.x;3363 lastMouseX = mx;
3375 setLeftLoopPinPos(mouseXOffs + lastMouseX);3364 setLeftLoopPinPos(mouseXOffs + mx);
3376 }3365 }
3377 else if (editor.ui.rightLoopPinMoving)3366 else if (editor.ui.rightLoopPinMoving)
3378 {3367 {
3379 lastMouseX = mouse.x;3368 lastMouseX = mx;
3380 setRightLoopPinPos(mouseXOffs + lastMouseX);3369 setRightLoopPinPos(mouseXOffs + mx);
3381 }3370 }
3382 else if (editor.ui.sampleDataOrLoopDrag >= 0)3371 else if (editor.ui.sampleDataOrLoopDrag >= 0)
3383 {3372 {
3384 // mark data3373 // mark data
3374 lastMouseX = mx;
3385 3375
3386 lastMouseX = mouse.x;3376 if (lastMouseX > editor.ui.sampleDataOrLoopDrag)
3387 tmp = lastMouseX;3377 setSampleRange(editor.ui.sampleDataOrLoopDrag, mx);
3388
3389 if (lastMouseX > editor.ui.sampleDataOrLoopDrag)
3390 setSampleRange(editor.ui.sampleDataOrLoopDrag, tmp);
3391 else if (lastMouseX == editor.ui.sampleDataOrLoopDrag)3378 else if (lastMouseX == editor.ui.sampleDataOrLoopDrag)
3392 setSampleRange(editor.ui.sampleDataOrLoopDrag, editor.ui.sampleDataOrLoopDrag);3379 setSampleRange(editor.ui.sampleDataOrLoopDrag, editor.ui.sampleDataOrLoopDrag);
3393 else if (lastMouseX < editor.ui.sampleDataOrLoopDrag)3380 else if (lastMouseX < editor.ui.sampleDataOrLoopDrag)
3394 setSampleRange(tmp, editor.ui.sampleDataOrLoopDrag);3381 setSampleRange(mx, editor.ui.sampleDataOrLoopDrag);
3395 }3382 }
3396 }3383 }
3397 }3384 }
src/ft2_video.c+4−4
@@ -260,8 +260,8 @@ static void updateRenderSizeVars(void) · 259 unmodified lines
260 if (dXUpscale != 0.0) video.renderW = (int32_t)(video.renderW / dXUpscale);260 if (dXUpscale != 0.0) video.renderW = (int32_t)(video.renderW / dXUpscale);
261 if (dYUpscale != 0.0) video.renderH = (int32_t)(video.renderH / dYUpscale);261 if (dYUpscale != 0.0) video.renderH = (int32_t)(video.renderH / dYUpscale);
262#endif262#endif
263 video.renderX = (video.displayW - video.renderW) / 2;263 video.renderX = (video.displayW - video.renderW) >> 1;
264 video.renderY = (video.displayH - video.renderH) / 2;264 video.renderY = (video.displayH - video.renderH) >> 1;
265 }265 }
266 }266 }
267 else267 else
@@ -273,8 +273,8 @@ static void updateRenderSizeVars(void) · 5 unmodified lines
273 }273 }
274 274
275 // for mouse cursor creation275 // for mouse cursor creation
276 video.xScale = (uint32_t)round(video.renderW / (double)SCREEN_W);276 video.xScale = (uint32_t)round(video.renderW * (1.0 / SCREEN_W));
277 video.yScale = (uint32_t)round(video.renderH / (double)SCREEN_H);277 video.yScale = (uint32_t)round(video.renderH * (1.0 / SCREEN_H));
278 createMouseCursors();278 createMouseCursors();
279}279}
280 280

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t