-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance, bug fixes, debug options, documentation updates.
Performance stats., refactoring, bug fixes, documentation updates, cosmetic changes, debug options.
- Loading branch information
Showing
22 changed files
with
1,925 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
/* | ||
*-------------------------------------------------------------------- | ||
* Project: VM65 - Virtual Machine/CPU emulator programming | ||
* framework. | ||
* | ||
* File: ConsoleIO.cpp | ||
* | ||
* Purpose: Implementation of ConsoleIO class. | ||
* The ConsoleIO class has methods helpful when | ||
* UI is utilizing STDIO (DOS) console. | ||
* | ||
* Date: 8/26/2016 | ||
* | ||
* Copyright: (C) by Marek Karcz 2016. All rights reserved. | ||
* | ||
* Contact: [email protected] | ||
* | ||
* License Agreement and Warranty: | ||
This software is provided with No Warranty. | ||
I (Marek Karcz) will not be held responsible for any damage to | ||
computer systems, data or user's health resulting from use. | ||
Please proceed responsibly and apply common sense. | ||
This software is provided in hope that it will be useful. | ||
It is free of charge for non-commercial and educational use. | ||
Distribution of this software in non-commercial and educational | ||
derivative work is permitted under condition that original | ||
copyright notices and comments are preserved. Some 3-rd party work | ||
included with this project may require separate application for | ||
permission from their respective authors/copyright owners. | ||
*-------------------------------------------------------------------- | ||
*/ | ||
#include <stdio.h> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string.h> | ||
#include "system.h" | ||
#include "ConsoleIO.h" | ||
|
||
#include "MKGenException.h" | ||
|
||
#if defined(WINDOWS) | ||
#include <conio.h> | ||
#endif | ||
|
||
using namespace std; | ||
|
||
namespace MKBasic { | ||
|
||
/* | ||
*-------------------------------------------------------------------- | ||
* Method: | ||
* Purpose: | ||
* Arguments: | ||
* Returns: | ||
*-------------------------------------------------------------------- | ||
*/ | ||
ConsoleIO::ConsoleIO() | ||
{ | ||
|
||
} | ||
|
||
/* | ||
*-------------------------------------------------------------------- | ||
* Method: | ||
* Purpose: | ||
* Arguments: | ||
* Returns: | ||
*-------------------------------------------------------------------- | ||
*/ | ||
ConsoleIO::~ConsoleIO() | ||
{ | ||
|
||
} | ||
|
||
#if defined(WINDOWS) | ||
|
||
/* | ||
*-------------------------------------------------------------------- | ||
* Method: ClearScreen() | ||
* Purpose: Clear the console screen. | ||
* Arguments: n/a | ||
* Returns: n/a | ||
*-------------------------------------------------------------------- | ||
*/ | ||
void ConsoleIO::ClearScreen() | ||
{ | ||
HANDLE hStdOut; | ||
CONSOLE_SCREEN_BUFFER_INFO csbi; | ||
DWORD count; | ||
DWORD cellCount; | ||
COORD homeCoords = { 0, 0 }; | ||
|
||
hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); | ||
if (hStdOut == INVALID_HANDLE_VALUE) return; | ||
|
||
/* Get the number of cells in the current buffer */ | ||
if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return; | ||
cellCount = csbi.dwSize.X *csbi.dwSize.Y; | ||
|
||
/* Fill the entire buffer with spaces */ | ||
if (!FillConsoleOutputCharacter( | ||
hStdOut, | ||
(TCHAR) ' ', | ||
cellCount, | ||
homeCoords, | ||
&count | ||
)) return; | ||
|
||
/* Fill the entire buffer with the current colors and attributes */ | ||
if (!FillConsoleOutputAttribute( | ||
hStdOut, | ||
csbi.wAttributes, | ||
cellCount, | ||
homeCoords, | ||
&count | ||
)) return; | ||
|
||
/* Move the cursor home */ | ||
SetConsoleCursorPosition( hStdOut, homeCoords ); | ||
} | ||
|
||
/* | ||
*-------------------------------------------------------------------- | ||
* Method: ScrHome() | ||
* Purpose: Bring the console cursor to home position. | ||
* Arguments: n/a | ||
* Returns: n/a | ||
*-------------------------------------------------------------------- | ||
*/ | ||
void ConsoleIO::ScrHome() | ||
{ | ||
HANDLE hStdOut; | ||
COORD homeCoords = { 0, 0 }; | ||
|
||
hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); | ||
if (hStdOut == INVALID_HANDLE_VALUE) return; | ||
|
||
/* Move the cursor home */ | ||
SetConsoleCursorPosition( hStdOut, homeCoords ); | ||
} | ||
|
||
#endif | ||
|
||
#if defined(LINUX) | ||
|
||
/* | ||
*-------------------------------------------------------------------- | ||
* Method: ClearScreen() | ||
* Purpose: Clear the console screen. | ||
* Arguments: n/a | ||
* Returns: n/a | ||
*-------------------------------------------------------------------- | ||
*/ | ||
void ConsoleIO::ClearScreen() | ||
{ | ||
system("clear"); | ||
} | ||
|
||
/* | ||
*-------------------------------------------------------------------- | ||
* Method: ScrHome() | ||
* Purpose: Bring the console cursor to home position. | ||
* Arguments: n/a | ||
* Returns: n/a | ||
*-------------------------------------------------------------------- | ||
*/ | ||
void ConsoleIO::ScrHome() | ||
{ | ||
cout << "\033[1;1H"; | ||
} | ||
|
||
#endif // #devine LINUX | ||
|
||
} // END namespace MKBasic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
*-------------------------------------------------------------------- | ||
* Project: VM65 - Virtual Machine/CPU emulator programming | ||
* framework. | ||
* | ||
* File: ConsoleIO.h | ||
* | ||
* Purpose: Prototype of ConsoleIO class. | ||
* | ||
* Date: 8/26/2016 | ||
* | ||
* Copyright: (C) by Marek Karcz 2016. All rights reserved. | ||
* | ||
* Contact: [email protected] | ||
* | ||
* License Agreement and Warranty: | ||
This software is provided with No Warranty. | ||
I (Marek Karcz) will not be held responsible for any damage to | ||
computer systems, data or user's health resulting from use. | ||
Please proceed responsibly and apply common sense. | ||
This software is provided in hope that it will be useful. | ||
It is free of charge for non-commercial and educational use. | ||
Distribution of this software in non-commercial and educational | ||
derivative work is permitted under condition that original | ||
copyright notices and comments are preserved. Some 3-rd party work | ||
included with this project may require separate application for | ||
permission from their respective authors/copyright owners. | ||
*-------------------------------------------------------------------- | ||
*/ | ||
#ifndef CONSOLEIO_H | ||
#define CONSOLEIO_H | ||
|
||
#include <string> | ||
#include <queue> | ||
#include <chrono> | ||
#include "system.h" | ||
|
||
//#define WINDOWS 1 | ||
#if defined (WINDOWS) | ||
#include <windows.h> | ||
#endif | ||
|
||
namespace MKBasic { | ||
|
||
class ConsoleIO | ||
{ | ||
public: | ||
|
||
ConsoleIO(); | ||
~ConsoleIO(); | ||
|
||
void ClearScreen(); | ||
void ScrHome(); | ||
|
||
}; | ||
|
||
} // namespace MKBasic | ||
|
||
#endif // #ifndef CONSOLEIO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,39 @@ | ||
/* | ||
*-------------------------------------------------------------------- | ||
* Project: VM65 - Virtual Machine/CPU emulator programming | ||
* framework. | ||
* | ||
* File: Display.cpp | ||
* | ||
* Purpose: Implementation of Display class. | ||
* The Display class emulates the character I/O device. | ||
* It defines the abstract device. The actual | ||
* input/output to the screen of the platform on which | ||
* the emulator runs is defined in MemMapDev class | ||
* or on higher level of abstraction. | ||
* | ||
* Date: 8/25/2016 | ||
* | ||
* Copyright: (C) by Marek Karcz 2016. All rights reserved. | ||
* | ||
* Contact: [email protected] | ||
* | ||
* License Agreement and Warranty: | ||
This software is provided with No Warranty. | ||
I (Marek Karcz) will not be held responsible for any damage to | ||
computer systems, data or user's health resulting from use. | ||
Please proceed responsibly and apply common sense. | ||
This software is provided in hope that it will be useful. | ||
It is free of charge for non-commercial and educational use. | ||
Distribution of this software in non-commercial and educational | ||
derivative work is permitted under condition that original | ||
copyright notices and comments are preserved. Some 3-rd party work | ||
included with this project may require separate application for | ||
permission from their respective authors/copyright owners. | ||
*-------------------------------------------------------------------- | ||
*/ | ||
#include "Display.h" | ||
#include <ctype.h> | ||
#include <cstdlib> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
/* | ||
*-------------------------------------------------------------------- | ||
* Project: VM65 - Virtual Machine/CPU emulator programming | ||
* framework. | ||
* | ||
* File: Display.h | ||
* | ||
* Purpose: Prototype of Display class and all supportig data | ||
* structures, enumerations, constants and macros. | ||
* | ||
* Date: 8/25/2016 | ||
* | ||
* Copyright: (C) by Marek Karcz 2016. All rights reserved. | ||
* | ||
* Contact: [email protected] | ||
* | ||
* License Agreement and Warranty: | ||
This software is provided with No Warranty. | ||
I (Marek Karcz) will not be held responsible for any damage to | ||
computer systems, data or user's health resulting from use. | ||
Please proceed responsibly and apply common sense. | ||
This software is provided in hope that it will be useful. | ||
It is free of charge for non-commercial and educational use. | ||
Distribution of this software in non-commercial and educational | ||
derivative work is permitted under condition that original | ||
copyright notices and comments are preserved. Some 3-rd party work | ||
included with this project may require separate application for | ||
permission from their respective authors/copyright owners. | ||
*-------------------------------------------------------------------- | ||
*/ | ||
#ifndef DISPLAY_H | ||
#define DISPLAY_H | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
/* | ||
*-------------------------------------------------------------------- | ||
* Project: VM65 - Virtual Machine/CPU emulator programming | ||
* framework. | ||
* | ||
* File: GraphDisp.cpp | ||
* | ||
* Purpose: Implementation of GraphDisp class. | ||
* The GraphDisp class emulates the graphics raster | ||
* device. It handles displaying of the graphics, the | ||
* events loop and the 'hardware' API to the device. | ||
* The higher level abstraction layer - MemMapDev | ||
* defines the actual behavior/response of the emulated | ||
* device in the emulated system. | ||
* | ||
* Date: 8/25/2016 | ||
* | ||
* Copyright: (C) by Marek Karcz 2016. All rights reserved. | ||
* | ||
* Contact: [email protected] | ||
* | ||
* License Agreement and Warranty: | ||
This software is provided with No Warranty. | ||
I (Marek Karcz) will not be held responsible for any damage to | ||
computer systems, data or user's health resulting from use. | ||
Please proceed responsibly and apply common sense. | ||
This software is provided in hope that it will be useful. | ||
It is free of charge for non-commercial and educational use. | ||
Distribution of this software in non-commercial and educational | ||
derivative work is permitted under condition that original | ||
copyright notices and comments are preserved. Some 3-rd party work | ||
included with this project may require separate application for | ||
permission from their respective authors/copyright owners. | ||
*-------------------------------------------------------------------- | ||
*/ | ||
#include "GraphDisp.h" | ||
#include "MKGenException.h" | ||
#include "system.h" | ||
|
@@ -75,6 +111,8 @@ void GraphDisp::Initialize() | |
{ | ||
int desk_w, desk_h, winbd_top = 5, winbd_right = 5; | ||
|
||
mPixelSizeX = GRAPHDISP_MAXW / mWidth; | ||
mPixelSizeY = GRAPHDISP_MAXH / mHeight; | ||
GetDesktopResolution(desk_w, desk_h); | ||
// Available in version > 2.0.4 | ||
//SDL_GetWindowBordersSize(mpWindow, &winbd_top, NULL, NULL, &winbd_right); | ||
|
Oops, something went wrong.