Continue gamebuino

This commit is contained in:
Miloslav Číž 2020-09-24 17:41:52 +02:00
parent 5d3965772b
commit e8ee39b3d5

View File

@ -15,11 +15,8 @@
#include <Gamebuino-Meta.h> #include <Gamebuino-Meta.h>
#define SFG_ARDUINO 1 #define SFG_ARDUINO 1
#define SFG_CAN_EXIT 0 #define SFG_CAN_EXIT 0
#define SFG_FPS 30
#define SFG_FPS 20
#define SFG_SCREEN_RESOLUTION_X 80 #define SFG_SCREEN_RESOLUTION_X 80
#define SFG_SCREEN_RESOLUTION_Y 64 #define SFG_SCREEN_RESOLUTION_Y 64
#define SFG_RESOLUTION_SCALEDOWN 1 #define SFG_RESOLUTION_SCALEDOWN 1
@ -34,6 +31,9 @@
Gamebuino_Meta::Color palette[256]; Gamebuino_Meta::Color palette[256];
const Gamebuino_Meta::SaveDefault saveDefault[] =
{ { 0, SAVETYPE_BLOB, SFG_SAVE_SIZE, 0 } };
void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex) void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex)
{ {
Gamebuino_Meta::Color c = palette[colorIndex]; Gamebuino_Meta::Color c = palette[colorIndex];
@ -73,15 +73,31 @@ void SFG_enableMusic(uint8_t enable)
void SFG_save(uint8_t data[SFG_SAVE_SIZE]) void SFG_save(uint8_t data[SFG_SAVE_SIZE])
{ {
gb.save.set(0,data,SFG_SAVE_SIZE);
} }
uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE]) uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE])
{ {
return 0; gb.save.get(0,data,SFG_SAVE_SIZE);
return 1;
} }
void SFG_playSound(uint8_t soundIndex, uint8_t volume) void SFG_playSound(uint8_t soundIndex, uint8_t volume)
{ {
switch (soundIndex)
{
case 2:
gb.sound.playCancel();
break;
case 5:
gb.sound.playOK();
break;
default:
gb.sound.playTick();
break;
}
} }
uint32_t SFG_getTimeMs() uint32_t SFG_getTimeMs()
@ -92,8 +108,8 @@ uint32_t SFG_getTimeMs()
void setup() void setup()
{ {
gb.begin(); gb.begin();
gb.setFrameRate(SFG_FPS); gb.setFrameRate(SFG_FPS);
gb.save.config(saveDefault);
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
@ -104,14 +120,11 @@ void setup()
SFG_init(); SFG_init();
} }
void loop() void loop()
{ {
while(!gb.update()) while(!gb.update())
{ {
} }
//gb.display.clear();
SFG_mainLoopBody(); SFG_mainLoopBody();
} }