Skip to content

Commit b3a20de

Browse files
committed
SDL: use same pause time as FLTK for performance
1 parent 5b62143 commit b3a20de

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2015-08-02
2+
Fix display output before DELAY
3+
14
2015-07-18
25
Added IDE editor sdl/android
36
Made a few minor performance improvements (SDL)

src/platform/sdl/display.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of SmallBASIC
22
//
3-
// Copyright(C) 2001-2014 Chris Warren-Smith.
3+
// Copyright(C) 2001-2015 Chris Warren-Smith.
44
//
55
// This program is distributed under the terms of the GPL v2.0 or later
66
// Download the GNU Public License (GPL) from www.gnu.org
@@ -122,10 +122,10 @@ bool Graphics::construct(const char *font, const char *boldFont) {
122122

123123
if (loadFonts(font, boldFont)) {
124124
_screen = new Canvas();
125-
result = _screen != NULL;
126-
if (result) {
125+
if (_screen != NULL) {
127126
if (_surface == NULL) {
128127
_screen->setSurface(SDL_GetWindowSurface(_window), w, h);
128+
result = true;
129129
} else {
130130
result = _screen->create(w, h);
131131
}

src/platform/sdl/runtime.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of SmallBASIC
22
//
3-
// Copyright(C) 2001-2014 Chris Warren-Smith.
3+
// Copyright(C) 2001-2015 Chris Warren-Smith.
44
//
55
// This program is distributed under the terms of the GPL v2.0 or later
66
// Download the GNU Public License (GPL) from www.gnu.org
@@ -26,10 +26,13 @@
2626
#include <queue>
2727
#include <cmath>
2828

29-
#define WAIT_INTERVAL 25
29+
#define WAIT_INTERVAL 5
3030
#define MAIN_BAS "__main_bas__"
3131
#define AMPLITUDE 22000
3232
#define FREQUENCY 44100
33+
#define OPTIONS_BOX_WIDTH_EXTRA 4
34+
#define OPTIONS_BOX_BG 0xd2d1d0
35+
#define OPTIONS_BOX_FG 0x3e3f3e
3336

3437
Runtime *runtime;
3538

@@ -310,11 +313,8 @@ void Runtime::pause(int timeout) {
310313

311314
void Runtime::pollEvents(bool blocking) {
312315
if (isActive() && !isRestart()) {
313-
if (blocking) {
314-
SDL_WaitEvent(NULL);
315-
}
316316
SDL_Event ev;
317-
if (SDL_PollEvent(&ev)) {
317+
if (blocking ? SDL_WaitEvent(&ev) : SDL_PollEvent(&ev)) {
318318
MAEvent *maEvent = NULL;
319319
switch (ev.type) {
320320
case SDL_QUIT:
@@ -479,27 +479,27 @@ void Runtime::onResize(int width, int height) {
479479
}
480480

481481
void Runtime::optionsBox(StringList *items) {
482-
int width = 0;
483-
int textHeight = 0;
484-
485482
if (!_menuX) {
486483
_menuX = 2;
487484
}
488485
if (!_menuY) {
489486
_menuY = 2;
490487
}
491488

489+
int width = 0;
490+
int charWidth = _output->getCharWidth();
492491
_output->registerScreen(MENU_SCREEN);
493492
List_each(String *, it, *items) {
494493
char *str = (char *)(* it)->c_str();
495-
MAExtent extent = maGetTextSize(str);
496-
int w = EXTENT_X(extent);
497-
int h = EXTENT_Y(extent);
494+
int w = (strlen(str) * charWidth);
498495
if (w > width) {
499-
width = w + 48;
496+
width = w;
500497
}
501-
textHeight = h + 8;
502498
}
499+
width += (charWidth * OPTIONS_BOX_WIDTH_EXTRA);
500+
501+
int charHeight = _output->getCharHeight();
502+
int textHeight = charHeight + (charHeight / 3);
503503
int height = textHeight * items->size();
504504
if (_menuX + width >= _output->getWidth()) {
505505
_menuX = _output->getWidth() - width;
@@ -518,7 +518,7 @@ void Runtime::optionsBox(StringList *items) {
518518
char *str = (char *)(* it)->c_str();
519519
FormInput *item = new MenuButton(index, selectedIndex, str, 0, y, width, textHeight);
520520
_output->addInput(item);
521-
item->setColor(0xd2d1d0, 0x3e3f3e);
521+
item->setColor(OPTIONS_BOX_BG, OPTIONS_BOX_FG);
522522
index++;
523523
y += textHeight;
524524
}

src/ui/system.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,9 @@ void System::runMain(const char *mainBasPath) {
709709
// unexpected error in main.bas
710710
alert("", gsb_last_errmsg);
711711
_state = kClosingState;
712+
} else {
713+
// don't reload
714+
_loadPath.empty();
712715
}
713716
}
714717
if (!_mainBas && !networkFile) {
@@ -1198,6 +1201,7 @@ void lwrite(const char *str) {
11981201
}
11991202

12001203
void dev_delay(dword ms) {
1204+
g_system->getOutput()->redraw();
12011205
maWait(ms);
12021206
}
12031207

0 commit comments

Comments
 (0)