mirror of
https://github.com/autc04/Retro68.git
synced 2025-01-14 08:33:16 +00:00
some minor cleanup
This commit is contained in:
parent
dea5fa2a21
commit
02c92021ab
@ -79,7 +79,6 @@ void Console::ScrollUp(short n)
|
|||||||
cursorY--;
|
cursorY--;
|
||||||
std::copy(chars.begin() + cols, chars.end(), chars.begin());
|
std::copy(chars.begin() + cols, chars.end(), chars.begin());
|
||||||
std::fill(chars.end() - cols, chars.end(), ' ');
|
std::fill(chars.end() - cols, chars.end(), ' ');
|
||||||
//Console::Draw();
|
|
||||||
RgnHandle rgn = NewRgn();
|
RgnHandle rgn = NewRgn();
|
||||||
ScrollRect(&bounds, 0, -cellSizeY, rgn);
|
ScrollRect(&bounds, 0, -cellSizeY, rgn);
|
||||||
DisposeRgn(rgn);
|
DisposeRgn(rgn);
|
||||||
@ -89,7 +88,6 @@ void Console::putch(char c)
|
|||||||
{
|
{
|
||||||
PortSetter setport(consolePort);
|
PortSetter setport(consolePort);
|
||||||
|
|
||||||
//Debugger();
|
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case '\r':
|
case '\r':
|
||||||
@ -132,22 +130,20 @@ std::string Console::ReadLine()
|
|||||||
|
|
||||||
if(c == '\b')
|
if(c == '\b')
|
||||||
{
|
{
|
||||||
cursorX--;
|
if(buffer.size())
|
||||||
putch(' ');
|
{
|
||||||
cursorX--;
|
cursorX--;
|
||||||
|
putch(' ');
|
||||||
buffer.substr(0,buffer.size()-1);
|
cursorX--;
|
||||||
|
|
||||||
|
buffer.resize(buffer.size()-1);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
//c = 'X';
|
|
||||||
}
|
|
||||||
if(c == 127)
|
|
||||||
{
|
|
||||||
c = 'Y';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
putch(c);
|
putch(c);
|
||||||
buffer += std::string(1,c);
|
buffer.append(1,c);
|
||||||
} while(c != '\n');
|
} while(c != '\n');
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
41
App2/test.cc
41
App2/test.cc
@ -101,28 +101,9 @@ int main(int argc, char** argv)
|
|||||||
__write_hook = &consolewrite;
|
__write_hook = &consolewrite;
|
||||||
__read_hook = &consoleread;
|
__read_hook = &consoleread;
|
||||||
|
|
||||||
console.putch('x');
|
|
||||||
console.putch('a');
|
|
||||||
console.putch('b');
|
|
||||||
console.putch('c');
|
|
||||||
console.putch('a');
|
|
||||||
console.putch('a');
|
|
||||||
Console::currentInstance->putch('Y');
|
|
||||||
printf("Hello...\n");
|
|
||||||
console.putch('b');
|
|
||||||
console.putch('\n');
|
|
||||||
|
|
||||||
std::cout << "Hello, world.\n";
|
|
||||||
printf("Hello, world.\n");
|
printf("Hello, world.\n");
|
||||||
console.putch('a');
|
std::cout << "Hello, world, again.\n";
|
||||||
Console::currentInstance->putch('Y');
|
|
||||||
|
|
||||||
/*std::cout << "X\n";
|
|
||||||
for(int i = 1; i <= 100; i++)
|
|
||||||
std::cout << "Hello, world: " << i << std::endl;
|
|
||||||
std::cout << std::flush;
|
|
||||||
|
|
||||||
std::cout << "Say something: " << std::flush;*/
|
|
||||||
printf("Say something: ");
|
printf("Say something: ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
printf("You said: %s\n", console.ReadLine().c_str());
|
printf("You said: %s\n", console.ReadLine().c_str());
|
||||||
@ -136,15 +117,18 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
//std::cout << "Exception speed test: " << std::flush;
|
int n = i == 0 ? 1 : 100;
|
||||||
printf("Exception speed test: "); fflush(stdout);
|
printf("Exception speed test (%3d iterations): ", n); fflush(stdout);
|
||||||
long start = TickCount();
|
long start = TickCount();
|
||||||
try { foobar(); } catch(...) {}
|
for(int j = 0; j < n; j++)
|
||||||
long end = TickCount();
|
{
|
||||||
//std::cout << (end-start)*1000 / 60.0 << " ms\n";
|
try { foobar(); } catch(...) {}
|
||||||
printf("%g\n",(end-start)*1000 / 60.0);
|
}
|
||||||
|
long end = TickCount();
|
||||||
|
|
||||||
|
printf("%g ms per throw/catch\n",(end-start)*1000 / 60.0 / n);
|
||||||
}
|
}
|
||||||
//std::cout << "Click mouse 10 times...\n";
|
|
||||||
const int n = 3;
|
const int n = 3;
|
||||||
printf("Click mouse %d times...\n", n);
|
printf("Click mouse %d times...\n", n);
|
||||||
for(int i = 0; i < n; i++)
|
for(int i = 0; i < n; i++)
|
||||||
@ -153,8 +137,7 @@ int main(int argc, char** argv)
|
|||||||
;
|
;
|
||||||
while(Button())
|
while(Button())
|
||||||
;
|
;
|
||||||
//std::cout << "Click #" << i + 1 << std::endl;
|
printf("Click #%d\n", i+1);
|
||||||
printf("Click #%d\n", i+1);
|
|
||||||
}
|
}
|
||||||
FlushEvents(everyEvent, 0);
|
FlushEvents(everyEvent, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user