- Seguim treballant en polir bugs i deixar guapeta la API
This commit is contained in:
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user