+ calling ControlRegisterUpdated Event

~ fixed setPixel performance
This commit is contained in:
Julian Hinxlage 2019-12-04 13:08:21 +01:00
parent 128951d856
commit 9ced919be4
2 changed files with 15 additions and 4 deletions

View File

@ -50,18 +50,21 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->layout_version = newValue; getRegisters()->layout_version = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto setCharactersPerColumn(int newValue) -> void { auto setCharactersPerColumn(int newValue) -> void {
lockSharedMemory(); lockSharedMemory();
getRegisters()->characters_per_column = newValue; getRegisters()->characters_per_column = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto setCharactersPerRow(int newValue) -> void { auto setCharactersPerRow(int newValue) -> void {
lockSharedMemory(); lockSharedMemory();
getRegisters()->characters_per_row = newValue; getRegisters()->characters_per_row = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto setMousePosition(int x, int y) -> void { auto setMousePosition(int x, int y) -> void {
@ -69,6 +72,7 @@ namespace vkvm {
getRegisters()->mouse_pos_x = x; getRegisters()->mouse_pos_x = x;
getRegisters()->mouse_pos_y = y; getRegisters()->mouse_pos_y = y;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto buttonPressed(KeyCode keyCode) -> void { auto buttonPressed(KeyCode keyCode) -> void {

View File

@ -18,7 +18,6 @@ namespace vkvm {
auto setDefaultValues() -> void { auto setDefaultValues() -> void {
impl.localMemoryWarn = false; impl.localMemoryWarn = false;
if (getSharedMemory() != nullptr) { if (getSharedMemory() != nullptr) {
//set default values
setMode(GraphicMode::RGB); setMode(GraphicMode::RGB);
setCharactersPerRow(60); setCharactersPerRow(60);
setCharactersPerColumn(20); setCharactersPerColumn(20);
@ -67,7 +66,7 @@ namespace vkvm {
if (x > getWidth() || y > getHeight()) { if (x > getWidth() || y > getHeight()) {
return false; return false;
} }
lockSharedMemory(); //lockSharedMemory();
auto reg = getRegisters(); auto reg = getRegisters();
const int bitsPerPixel = 8; const int bitsPerPixel = 8;
@ -111,7 +110,7 @@ namespace vkvm {
break; break;
} }
} }
unlockSharedMemory(); //unlockSharedMemory();
return true; return true;
} }
@ -164,7 +163,7 @@ namespace vkvm {
auto setText(std::string text) -> bool { auto setText(std::string text) -> bool {
lockSharedMemory(); lockSharedMemory();
char *ptr = getTextArea(); char *ptr = getTextArea();
for (int i = 0; i < text.size(); i++) { for (int i = 0; i < static_cast<int>(text.size()); i++) {
if (i < getCharactersPerColumn() * getCharactersPerRow()) { if (i < getCharactersPerColumn() * getCharactersPerRow()) {
ptr[i] = text[i]; ptr[i] = text[i];
} }
@ -209,6 +208,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->width_pixels = newValue; getRegisters()->width_pixels = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getHeight() -> int { auto getHeight() -> int {
@ -219,6 +219,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->height_pixels = newValue; getRegisters()->height_pixels = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getMode() -> GraphicMode { auto getMode() -> GraphicMode {
@ -254,6 +255,7 @@ namespace vkvm {
reg->graphicMode = newValue; reg->graphicMode = newValue;
} }
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getRedrawInterval() -> int { auto getRedrawInterval() -> int {
@ -264,6 +266,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->autoRedrawInterval = newValue; getRegisters()->autoRedrawInterval = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getTimerInterruptInterval() -> int { auto getTimerInterruptInterval() -> int {
@ -274,6 +277,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->timerInterruptInterval = newValue; getRegisters()->timerInterruptInterval = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getBackgroundColor() -> Color { auto getBackgroundColor() -> Color {
@ -284,6 +288,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->background_color = newValue; getRegisters()->background_color = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getForegroundColor() -> Color { auto getForegroundColor() -> Color {
@ -294,6 +299,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->foreground_color = newValue; getRegisters()->foreground_color = newValue;
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getCharactersPerRow() -> int { auto getCharactersPerRow() -> int {
@ -314,6 +320,7 @@ namespace vkvm {
lockSharedMemory(); lockSharedMemory();
getRegisters()->textMode_font = newValue.getId(); getRegisters()->textMode_font = newValue.getId();
unlockSharedMemory(); unlockSharedMemory();
callEvent(EventType::UpdateControlRegisters);
} }
auto getMousePosition() -> Coordinates { auto getMousePosition() -> Coordinates {