commit a72a1a5569b6f683562789f3b90533753278be01
Author: Jon Bell <jondbell@protonmail.com>
AuthorDate: Sat May 16 09:15:34 2020 -0600
Commit: Jon Bell <jondbell@protonmail.com>
CommitDate: Sat May 16 09:15:34 2020 -0600
Rename Console to Vm
---
source/main.cpp | 30 +++++++++++++++---------------
source/picoluaapi.cpp | 12 ++++++------
source/picoluaapi.h | 4 ++--
source/{console.cpp => vm.cpp} | 24 ++++++++++++------------
source/{console.h => vm.h} | 7 ++++---
5 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/source/main.cpp b/source/main.cpp
index c30a509..ad13a6a 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -9,7 +9,7 @@
#include <string>
#include "graphics.h"
-#include "console.h"
+#include "vm.h"
#include "logger.h"
#include "input.h"
@@ -196,26 +196,26 @@ int main(int argc, char* argv[])
//use new 3ds cpu if we can
osSetSpeedupEnable(true);
- Logger::Write("initializing Console\n");
- Console *console = new Console();
- Logger::Write("initialized console\n");
+ Logger::Write("initializing Vm\n");
+ Vm *vm = new Vm();
+ Logger::Write("initialized Vm\n");
//test or not both hardcoded to loading test cart as of now
#if _TEST
consoleInit(GFX_BOTTOM, NULL);
Logger::Write("Loading cart\n");
- console->LoadCart("testcart.p8");
+ vm->LoadCart("testcart.p8");
Logger::Write("Cart Loaded\n");
#else
- console->LoadCart("lilking.p8");
+ vm->LoadCart("lilking.p8");
#endif
// Main loop
Logger::Write("Starting main loop\n");
- uint8_t targetFps = console->GetTargetFps();
+ uint8_t targetFps = vm->GetTargetFps();
double targetFrametimeMs = 1000.0 / (double)targetFps;
std::function<void()> clearFb = clear3dsFrameBuffer;
@@ -286,22 +286,22 @@ int main(int argc, char* argv[])
//cart draw
//_draw();
- console->UpdateAndDraw(frame_time, clear3dsFrameBuffer, p8kDown, p8kHeld);
+ vm->UpdateAndDraw(frame_time, clear3dsFrameBuffer, p8kDown, p8kHeld);
//send pico 8 screen to framebuffer, then call the function to flush and swap buffers, and wait for vblank
uint8_t* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
if (stretch == PixelPerfect) {
- console->FlipBuffer_PP(fb, ScreenWidth, ScreenHeight, postFlip);
+ vm->FlipBuffer_PP(fb, ScreenWidth, ScreenHeight, postFlip);
}
else if (stretch == StretchToFit) {
- console->FlipBuffer_STF(fb, ScreenWidth, ScreenHeight, postFlip);
+ vm->FlipBuffer_STF(fb, ScreenWidth, ScreenHeight, postFlip);
}
else if (stretch == StretchAndOverflow) {
uint8_t* fbb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
- console->FlipBuffer_SAO(
+ vm->FlipBuffer_SAO(
fb, ScreenWidth, ScreenHeight,
fbb, BottomScreenWidth, BottomScreenHeight,
postFlip);
@@ -309,7 +309,7 @@ int main(int argc, char* argv[])
if (waveBuf[fillBlock].status == NDSP_WBUF_DONE) {
- console->FillAudioBuffer(waveBuf[fillBlock].data_pcm16, stream_offset, waveBuf[fillBlock].nsamples);
+ vm->FillAudioBuffer(waveBuf[fillBlock].data_pcm16, stream_offset, waveBuf[fillBlock].nsamples);
DSP_FlushDataCache(waveBuf[fillBlock].data_pcm16, waveBuf[fillBlock].nsamples);
@@ -322,9 +322,9 @@ int main(int argc, char* argv[])
}
- Logger::Write("Turning off console and exiting logger\n");
- console->TurnOff();
- delete console;
+ Logger::Write("Turning off vm and exiting logger\n");
+ vm->TurnOff();
+ delete vm;
Logger::Exit();
audioCleanup();
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index e44935b..88841ed 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -4,7 +4,7 @@
#include "picoluaapi.h"
#include "graphics.h"
#include "Input.h"
-#include "console.h"
+#include "vm.h"
extern "C" {
#include <lua.h>
@@ -14,13 +14,13 @@ extern "C" {
Graphics* _graphicsForLuaApi;
Input* _inputForLuaApi;
-Console* _consoleForLuaApi;
+Vm* _vmForLuaApi;
Audio* _audioForLuaApi;
-void initPicoApi(Graphics* graphics, Input* input, Console* console, Audio* audio){
+void initPicoApi(Graphics* graphics, Input* input, Vm* vm, Audio* audio){
_graphicsForLuaApi = graphics;
_inputForLuaApi = input;
- _consoleForLuaApi = console;
+ _vmForLuaApi = vm;
_audioForLuaApi = audio;
}
@@ -537,8 +537,8 @@ int btnp(lua_State *L){
//System
int time(lua_State *L) {
- int frameCount = _consoleForLuaApi->GetFrameCount();
- int targetFps = _consoleForLuaApi->GetTargetFps();
+ int frameCount = _vmForLuaApi->GetFrameCount();
+ int targetFps = _vmForLuaApi->GetTargetFps();
double seconds = (double)frameCount / (double)targetFps;
diff --git a/source/picoluaapi.h b/source/picoluaapi.h
index 6b3bf2f..f0c5f29 100644
--- a/source/picoluaapi.h
+++ b/source/picoluaapi.h
@@ -10,10 +10,10 @@ extern "C" {
#include "graphics.h"
#include "Input.h"
-#include "console.h"
+#include "vm.h"
//this can probably go away when I'm loading actual carts and just have to expose api to lua
-void initPicoApi(Graphics* graphics, Input* input, Console* console, Audio* audio);
+void initPicoApi(Graphics* graphics, Input* input, Vm* vm, Audio* audio);
//graphics api
int cls(lua_State *L);
diff --git a/source/console.cpp b/source/vm.cpp
similarity index 92%
rename from source/console.cpp
rename to source/vm.cpp
index e0738cf..f072a30 100644
--- a/source/console.cpp
+++ b/source/vm.cpp
@@ -2,7 +2,7 @@
#include <functional>
#include <math.h>
-#include "console.h"
+#include "vm.h"
#include "graphics.h"
#include "fontdata.h"
#include "cart.h"
@@ -17,7 +17,7 @@ extern "C" {
#include <lauxlib.h>
}
-Console::Console(){
+Vm::Vm(){
Logger::Write("getting font string\n");
auto fontdata = get_font_data();
@@ -40,7 +40,7 @@ Console::Console(){
_targetFps = 30;
}
-Console::~Console(){
+Vm::~Vm(){
delete _graphics;
delete _input;
delete _audio;
@@ -50,7 +50,7 @@ Console::~Console(){
}
}
-void Console::LoadCart(std::string filename){
+void Vm::LoadCart(std::string filename){
Logger::Write("Calling Cart Constructor\n");
Cart *cart = new Cart(filename);
_picoFrameCount = 0;
@@ -183,7 +183,7 @@ void Console::LoadCart(std::string filename){
//how to call lua from c: https://www.cs.usfca.edu/~galles/cs420/lecture/LuaLectures/LuaAndC.html
-void Console::UpdateAndDraw(
+void Vm::UpdateAndDraw(
uint64_t ticksSinceLastCall,
std::function<void()> clearFbFunction,
uint8_t kdown,
@@ -222,7 +222,7 @@ void Console::UpdateAndDraw(
_picoFrameCount++;
}
-void Console::FlipBuffer_PP(uint8_t* fb, int width, int height, std::function<void()> postFlipFunction){
+void Vm::FlipBuffer_PP(uint8_t* fb, int width, int height, std::function<void()> postFlipFunction){
_graphics->flipBuffer(fb, width, height);
if (postFlipFunction) {
@@ -230,7 +230,7 @@ void Console::FlipBuffer_PP(uint8_t* fb, int width, int height, std::function<vo
}
}
-void Console::FlipBuffer_STF(uint8_t* fb, int width, int height, std::function<void()> postFlipFunction){
+void Vm::FlipBuffer_STF(uint8_t* fb, int width, int height, std::function<void()> postFlipFunction){
_graphics->flipBuffer_STF(fb, width, height);
if (postFlipFunction) {
@@ -238,7 +238,7 @@ void Console::FlipBuffer_STF(uint8_t* fb, int width, int height, std::function<v
}
}
-void Console::FlipBuffer_SAO(
+void Vm::FlipBuffer_SAO(
uint8_t* fb, int width, int height,
uint8_t* fb_o, int width_o, int height_o,
std::function<void()> postFlipFunction){
@@ -250,20 +250,20 @@ void Console::FlipBuffer_SAO(
}
-void Console::FillAudioBuffer(void *audioBuffer, size_t offset, size_t size){
+void Vm::FillAudioBuffer(void *audioBuffer, size_t offset, size_t size){
_audio->FillAudioBuffer(audioBuffer, offset, size);
}
-void Console::TurnOff() {
+void Vm::TurnOff() {
lua_close(_luaState);
}
-uint8_t Console::GetTargetFps() {
+uint8_t Vm::GetTargetFps() {
return _targetFps;
}
-int Console::GetFrameCount() {
+int Vm::GetFrameCount() {
return _picoFrameCount;
}
diff --git a/source/console.h b/source/vm.h
similarity index 96%
rename from source/console.h
rename to source/vm.h
index be89191..99fa760 100644
--- a/source/console.h
+++ b/source/vm.h
@@ -1,4 +1,5 @@
#pragma once
+
#include <functional>
#include "cart.h"
@@ -17,7 +18,7 @@ enum StretchOption {
StretchAndOverflow
};
-class Console {
+class Vm {
Cart* _loadedCart;
Graphics* _graphics;
Audio* _audio;
@@ -31,8 +32,8 @@ class Console {
bool _hasDraw;
public:
- Console();
- ~Console();
+ Vm();
+ ~Vm();
void LoadCart(std::string filename);