diff --git a/Makefile b/Makefile index 4d440f0..3a21f86 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ ICON := icon.jpg APP_AUTHOR := Will Smith APP_TITLE := Vapor Spec -APP_VERSION := 0.4.1 +APP_VERSION := 1.0.0 #--------------------------------------------------------------------------------- # options for code generation diff --git a/source/display.h b/source/display.h index d8d448e..c06d8f4 100644 --- a/source/display.h +++ b/source/display.h @@ -3,7 +3,6 @@ #include "constants.h" #include "gpu.h" -#include #include // EGL library #include // EGL extensions #include // glad library (OpenGL loader) @@ -20,8 +19,8 @@ layout(location = 1) in vec2 a_texCoord; out vec2 v_texCoord; void main() { - gl_Position = a_position; - v_texCoord = a_texCoord; + gl_Position = a_position; + v_texCoord = a_texCoord; } )text"; @@ -35,7 +34,7 @@ layout(location = 0) out vec4 outColor; uniform sampler2D s_texture; void main() { - outColor = texture(s_texture, v_texCoord); + outColor = texture(s_texture, v_texCoord); } )text"; @@ -46,12 +45,12 @@ struct Display int scale; int pitch; EGLDisplay s_display; - EGLContext s_context; - EGLSurface s_surface; + EGLContext s_context; + EGLSurface s_surface; GLuint vertexShader, fragmentShader; - GLuint shaderProgram; - GLint samplerLoc; - GLuint textureId; + GLuint shaderProgram; + GLint samplerLoc; + GLuint textureId; }; GLuint loadShaderProgram(GLenum type, const char* source); diff --git a/source/vm.c b/source/vm.c index 8ffd9d7..ec8fabd 100644 --- a/source/vm.c +++ b/source/vm.c @@ -44,8 +44,9 @@ void run(VM* vm) uint32_t cpuInstructionCount = 0; // Enforce the instructions per second limit in sync with the display refreshes - // 500,000 instructions per second is almost the same as 8064 instructions per 16 milliseconds - uint32_t instructionsPerSecondFactor = 62; + // 500,000 instructions per second is almost the same as 8064 instructions per 16 milliseconds. + // 500,000 IPS == 8064 instructions / 0.0016 seconds + uint32_t instructionsPerFrame = 8064; int wait = 0; Instruction* decoded = malloc(sizeof(Instruction)); @@ -68,17 +69,17 @@ void run(VM* vm) vm->pc++; cpuInstructionCount++; - if (cpuInstructionCount > INSTRUCTIONS_PER_SECOND / instructionsPerSecondFactor) + if (cpuInstructionCount > instructionsPerFrame) wait = 1; } - if ((SDL_GetTicks() - cpuStartTime) > 1000 / instructionsPerSecondFactor) + if ((SDL_GetTicks() - cpuStartTime) > 16) { // 16 milliseconds have passed // Reset the instruction count and timer - if (cpuInstructionCount < INSTRUCTIONS_PER_SECOND / instructionsPerSecondFactor) + if (cpuInstructionCount < instructionsPerFrame) { - //printf("Running below desired instructions per second\n"); - //printf("Desired: %d Actual: %d\n", INSTRUCTIONS_PER_SECOND / instructionsPerSecondFactor, cpuInstructionCount); + //printf("Running below desired instructions per frame\n"); + //printf("Desired: %d Actual: %d\n", instructionsPerFrame, cpuInstructionCount); } cpuInstructionCount = 0; cpuStartTime = SDL_GetTicks();