- Seguim treballant en polir bugs i deixar guapeta la API
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
x=0
|
||||
|
||||
function _init()
|
||||
function mini.init()
|
||||
--text=other.peiv()
|
||||
--keyRight = tonumber(getconf("keyright")) or KEY_RIGHT
|
||||
--keyLeft = tonumber(getconf("keyleft")) or KEY_LEFT
|
||||
@@ -10,23 +10,34 @@ function _init()
|
||||
--turbo(false)
|
||||
--local perico = "péricòñ"
|
||||
--print(utf8.len(perico))
|
||||
ants = 0xc936;
|
||||
s = surface.load("tiles01.gif")
|
||||
--surface.source(s)
|
||||
p = palette.load("tiles01.gif")
|
||||
palette.set(p)
|
||||
palette.setTransparent(255)
|
||||
print(#p)
|
||||
surface.save(s, "data/copy.gif", p)
|
||||
surface.save(s, "data/copy.gif")
|
||||
s = surface.load("copy.gif")
|
||||
--draw.source(s)
|
||||
system.setBeat(4)
|
||||
end
|
||||
|
||||
function _update()
|
||||
if key.press(key.ESCAPE) then
|
||||
sys.quit()
|
||||
function mini.update()
|
||||
if keyboard.keyPressed(key.ESCAPE) then
|
||||
system.quit()
|
||||
end
|
||||
|
||||
draw.cls(5)
|
||||
draw.blit(s, 0, 0, 64, 64, 10, 10)
|
||||
if system.isBeat() then
|
||||
ants = (ants >> 12) | ((ants<<4)&0xffff)
|
||||
end
|
||||
surface.cls(5)
|
||||
draw.surface(s, 0, 0, 64, 64, 10, 10)
|
||||
draw.rect(10, 10, 73, 73, 8)
|
||||
draw.setPattern(ants)
|
||||
draw.rect(10, 10, 73, 73, 0)
|
||||
|
||||
draw.setPattern(0xffff)
|
||||
--draw.print(#p,0,0,2)
|
||||
end
|
||||
|
||||
|
||||
2
gifenc.h
2
gifenc.h
@@ -47,7 +47,7 @@ namespace gif
|
||||
|
||||
static void put_loop(gif_t *gif, uint16_t loop);
|
||||
|
||||
gif_t *create(const char *fname, uint16_t width, uint16_t height, uint8_t *palette, uint8_t depth, uint8_t bgindex, int loop)
|
||||
gif_t *create(const char *fname, uint16_t width, uint16_t height, uint8_t *palette, uint8_t depth, int16_t bgindex, int loop)
|
||||
{
|
||||
gif_t *gif = (gif_t*)calloc(1, sizeof(*gif) + (bgindex < 0 ? 2 : 1)*width*height);
|
||||
gif->w = width; gif->h = height;
|
||||
|
||||
26
mini.cpp
26
mini.cpp
@@ -7,6 +7,8 @@
|
||||
//#include "SDL2/SDL_mixer.h"
|
||||
#include "jail_audio.h"
|
||||
|
||||
#define MAX_TEXTURES 10
|
||||
|
||||
#ifdef MACOS_BUNDLE
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
@@ -33,7 +35,7 @@ bool screen_cursor = true;
|
||||
int desktop_width = 0;
|
||||
int desktop_height = 0;
|
||||
|
||||
surface_t surfaces[10];
|
||||
surface_t surfaces[MAX_TEXTURES];
|
||||
surface_t *screen_surface = &surfaces[0];
|
||||
surface_t *dest_surface = screen_surface;
|
||||
surface_t *source_surface = NULL;
|
||||
@@ -164,7 +166,7 @@ void reinit() {
|
||||
ds::trans=0;
|
||||
ds::fill_pattern = 0b1111111111111111;
|
||||
ds::fill_trans = false;
|
||||
for (int i=1; i<10; ++i) {
|
||||
for (int i=1; i<MAX_TEXTURES; ++i) {
|
||||
if (surfaces[i].p != NULL) free(surfaces[i].p);
|
||||
surfaces[i].p = NULL;
|
||||
}
|
||||
@@ -194,7 +196,7 @@ int scrh() {
|
||||
|
||||
uint8_t newsurf(int w, int h) {
|
||||
int i = 0;
|
||||
while (i<10 && surfaces[i].p != NULL) ++i;
|
||||
while (i<MAX_TEXTURES && surfaces[i].p != NULL) ++i;
|
||||
//[TODO] Gestionar el cas en que no queden surfaces lliures
|
||||
surfaces[i].w = w;
|
||||
surfaces[i].h = h;
|
||||
@@ -205,7 +207,7 @@ uint8_t newsurf(int w, int h) {
|
||||
|
||||
uint8_t loadsurf(const char* filename) {
|
||||
int i = 0;
|
||||
while (i<10 && surfaces[i].p != NULL) ++i;
|
||||
while (i<MAX_TEXTURES && surfaces[i].p != NULL) ++i;
|
||||
//[TODO] Gestionar el cas en que no queden surfaces lliures
|
||||
|
||||
int size;
|
||||
@@ -217,9 +219,11 @@ uint8_t loadsurf(const char* filename) {
|
||||
return i;
|
||||
}
|
||||
|
||||
void savesurf(uint8_t surface, const char* filename, uint8_t *pal)
|
||||
void savesurf(uint8_t surface, const char* filename, uint8_t *pal, uint8_t colors)
|
||||
{
|
||||
gif::gif_t *file = gif::create(filename, surfaces[surface].w, surfaces[surface].h, pal, (pal?8:0), 0, -1);
|
||||
uint8_t depth=colors;
|
||||
do { depth = depth >> 1; } while (depth!=0);
|
||||
gif::gif_t *file = gif::create(filename, surfaces[surface].w, surfaces[surface].h, pal, (pal?depth:0), -1, -1);
|
||||
memcpy(file->frame, surfaces[surface].p, surfaces[surface].w*surfaces[surface].h);
|
||||
gif::addFrame(file, 0);
|
||||
gif::close(file);
|
||||
@@ -260,6 +264,12 @@ void setmap(uint8_t surface) {
|
||||
map_surface = &surfaces[surface];
|
||||
}
|
||||
|
||||
uint8_t getmap()
|
||||
{
|
||||
for (int i=0; i<MAX_TEXTURES; ++i) if (map_surface == &surfaces[i]) return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void createDisplay() {
|
||||
if (screen_zoom <= 0) screen_zoom = 1;
|
||||
while (screen_width*screen_zoom > desktop_width || screen_height*screen_zoom > desktop_height) screen_zoom--;
|
||||
@@ -468,7 +478,7 @@ int main(int argc,char*argv[]){
|
||||
|
||||
//Mix_Quit();
|
||||
|
||||
for (int i=0;i<10;++i) freesurf(i);
|
||||
for (int i=0;i<MAX_TEXTURES;++i) freesurf(i);
|
||||
dest_surface = source_surface = map_surface = NULL;
|
||||
destroyDisplay();
|
||||
SDL_Quit();
|
||||
@@ -684,7 +694,7 @@ void rectfill(int x0, int y0, int x1, int y1, uint8_t color) {
|
||||
}
|
||||
|
||||
void fillp(uint16_t pat, bool transparent) {
|
||||
ds::fill_trans = transparent;
|
||||
ds::fill_trans = true; //transparent;
|
||||
ds::fill_pattern = pat;
|
||||
do_pset=(pat==0xffff?pset_fast:pset_pattern);
|
||||
}
|
||||
|
||||
3
mini.h
3
mini.h
@@ -119,7 +119,7 @@ int scrh();
|
||||
|
||||
uint8_t newsurf(int w, int h);
|
||||
uint8_t loadsurf(const char* filename);
|
||||
void savesurf(uint8_t surface, const char* filename, uint8_t *pal);
|
||||
void savesurf(uint8_t surface, const char* filename, uint8_t *pal, uint8_t colors=0);
|
||||
void freesurf(uint8_t surface);
|
||||
int surfw(uint8_t surface);
|
||||
int surfh(uint8_t surface);
|
||||
@@ -127,6 +127,7 @@ int surfh(uint8_t surface);
|
||||
void setdest(uint8_t surface);
|
||||
void setsource(uint8_t surface);
|
||||
void setmap(uint8_t surface);
|
||||
uint8_t getmap();
|
||||
|
||||
void cls(uint8_t color=0);
|
||||
void color(uint8_t color=6);
|
||||
|
||||
Reference in New Issue
Block a user