Commit 7f53689f authored by Jack's avatar Jack
Browse files

fixes for OpenDingux first OPK release

parent 08ea5a41
......@@ -4,6 +4,7 @@ Name=retro-8
Comment=PICO-8 Emulator
Terminal=false
StartupNotify=true
Exec=retro8
Exec=retro8 %f
Icon=icon
Categories=emulator;
Categories=emulators;
X-OD-Filter=.png,.p8
data/pico8_font.png

1020 Bytes | W: | H:

data/pico8_font.png

645 Bytes | W: | H:

data/pico8_font.png
data/pico8_font.png
data/pico8_font.png
data/pico8_font.png
  • 2-up
  • Swipe
  • Onion skin
rm -rf opk
mkdir -p opk
cp opendingux/retro8 opk
cp vs2017/retro8/api.lua opk
cp ../data/default.gcw0.desktop opk
cp ../data/pico8_font.png opk
cp ../data/icon.png opk
mksquashfs opk retro8.opk -all-root -noappend -no-exports -no-xattrs -no-progress > /dev/null
# rm -rf opk
......@@ -21,15 +21,17 @@ _gameView(new GameView(this)), _menuView(new MenuView(this))
void ui::ViewManager::deinit()
{
SDL_DestroyTexture(_font);
SDL::deinit();
}
bool ui::ViewManager::loadData()
{
SDL_Surface* font = IMG_Load("pico8_font.png");
assert(font);
machine.font().load(font);
_font = SDL_CreateTextureFromSurface(_renderer, font);
SDL_SetTextureBlendMode(_font, SDL_BLENDMODE_BLEND);
......@@ -68,7 +70,7 @@ void ui::ViewManager::text(const std::string& text, int32_t x, int32_t y)
}
void ViewManager::text(const std::string& text, int32_t x, int32_t y, SDL_Color color, TextAlign align, float scale)
{
{
constexpr int32_t GLYPHS_PER_ROW = 16;
const int32_t width = text.size() * 4 * scale;
......@@ -101,4 +103,4 @@ void ViewManager::backToGame()
{
_gameView->resume();
_view = _gameView;
}
\ No newline at end of file
}
......@@ -19,7 +19,7 @@ void ColorTable::init(SDL_PixelFormat* format)
void Font::load(SDL_Surface* surface)
{
assert(surface->w == SPRITE_WIDTH * FONT_GLYPHS_COLUMNS && surface->h == SPRITE_HEIGHT * FONT_GLYPHS_ROWS);
//assert(surface->w == SPRITE_WIDTH * FONT_GLYPHS_COLUMNS && surface->h == SPRITE_HEIGHT * FONT_GLYPHS_ROWS);
for (size_t gy = 0; gy < FONT_GLYPHS_ROWS; ++gy)
for (size_t gx = 0; gx < FONT_GLYPHS_COLUMNS; ++gx)
......@@ -36,4 +36,4 @@ void Font::load(SDL_Surface* surface)
glyph.set(sx, sy, static_cast<const uint8_t*>(surface->pixels)[index] ? color_t::WHITE : color_t::BLACK);
}
}
}
\ No newline at end of file
}
......@@ -32,7 +32,7 @@ namespace retro8
lua::Code _code;
SDL_Surface* _output;
private:
void circHelper(coord_t xc, coord_t yc, coord_t x, coord_t y, color_t col);
......@@ -40,7 +40,7 @@ namespace retro8
public:
Machine() : _sound(_memory)
Machine() : _sound(_memory)
{
}
......@@ -79,4 +79,4 @@ namespace retro8
lua::Code& code() { return _code; }
sfx::APU& sound() { return _sound; }
};
}
\ No newline at end of file
}
......@@ -9,6 +9,7 @@
#include <SDL.h>
#include <array>
#include <random>
#include <cstring>
namespace retro8
{
......@@ -31,7 +32,7 @@ namespace retro8
static constexpr address_t TILE_MAP_LOW = 0x1000;
static constexpr address_t TILE_MAP_HIGH = 0x2000;
static constexpr int32_t CART_DATA_LENGTH = 0x4300;
};
......@@ -69,7 +70,7 @@ namespace retro8
gfx::cursor_t* cursor() { return as<gfx::cursor_t>(address::CURSOR); }
gfx::camera_t* camera() { return as<gfx::camera_t>(address::CAMERA); }
gfx::clip_rect_t* clipRect() { return as<gfx::clip_rect_t>(address::CLIP_RECT); }
gfx::color_byte_t* spriteSheet(coord_t x, coord_t y) { return spriteSheet() + x / gfx::PIXEL_TO_BYTE_RATIO + y * gfx::SPRITE_SHEET_PITCH; }
gfx::color_byte_t* spriteSheet() { return as<gfx::color_byte_t>(address::SPRITE_SHEET); }
gfx::color_byte_t* screenData() { return as<gfx::color_byte_t>(address::SCREEN_DATA); }
......@@ -100,8 +101,8 @@ namespace retro8
return addr;
}
gfx::sprite_t* spriteAt(sprite_index_t index) {
return reinterpret_cast<gfx::sprite_t*>(&memory[address::SPRITE_SHEET
gfx::sprite_t* spriteAt(sprite_index_t index) {
return reinterpret_cast<gfx::sprite_t*>(&memory[address::SPRITE_SHEET
+ (index % gfx::SPRITES_PER_SPRITE_SHEET_ROW) * gfx::SPRITE_BYTES_PER_SPRITE_ROW]
+ (index / gfx::SPRITES_PER_SPRITE_SHEET_ROW) * gfx::SPRITE_SHEET_PITCH * gfx::SPRITE_HEIGHT
); }
......@@ -109,4 +110,4 @@ namespace retro8
template<typename T> T* as(address_t addr) { return reinterpret_cast<T*>(&memory[addr]); }
};
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment