Compare commits
2 Commits
fe444fc0ec
...
e1518cf76f
| Author | SHA1 | Date | |
|---|---|---|---|
| e1518cf76f | |||
| 19df09dddc |
3
gif.c
3
gif.c
@@ -434,6 +434,9 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
|
|||||||
// sizeof( screen_descriptor_t ) = 8!
|
// sizeof( screen_descriptor_t ) = 8!
|
||||||
READ(&screen_descriptor, 7);
|
READ(&screen_descriptor, 7);
|
||||||
|
|
||||||
|
if (w) *w = screen_descriptor.width;
|
||||||
|
if (h) *h = screen_descriptor.height;
|
||||||
|
|
||||||
color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1;
|
color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1;
|
||||||
|
|
||||||
if ( screen_descriptor.fields & 0x80 )
|
if ( screen_descriptor.fields & 0x80 )
|
||||||
|
|||||||
32
jdraw8.cpp
32
jdraw8.cpp
@@ -27,15 +27,15 @@ SDL_Renderer* sdlRenderer = NULL;
|
|||||||
SDL_Texture* sdlTexture = NULL;
|
SDL_Texture* sdlTexture = NULL;
|
||||||
|
|
||||||
void JD8_Init(const char *title) {
|
void JD8_Init(const char *title) {
|
||||||
screen = (JD8_Surface)calloc( 1, 64000 );
|
screen = (JD8_Surface)calloc( 1, 320 * 200 );
|
||||||
main_palette = (JD8_Palette)calloc( 1, 768 );
|
main_palette = (JD8_Palette)calloc( 1, 256 * sizeof(uint32_t) );
|
||||||
pixel_data = (Uint32*)calloc(1, 320 * 200 * 4); // 1048576 );
|
pixel_data = (Uint32*)calloc(1, 320 * 200 * 4); // 1048576 );
|
||||||
|
|
||||||
sdlWindow = SDL_CreateWindow( title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
|
sdlWindow = SDL_CreateWindow( title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
|
||||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
|
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
|
||||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||||
|
|
||||||
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, 320, 200);
|
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JD8_Quit() {
|
void JD8_Quit() {
|
||||||
@@ -50,9 +50,9 @@ void JD8_ClearScreen(Uint8 color) {
|
|||||||
memset( screen, color, 64000 );
|
memset( screen, color, 64000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
JD8_Surface JD8_NewSurface() {
|
JD8_Surface JD8_NewSurface(const int w, const int h) {
|
||||||
JD8_Surface surface = (JD8_Surface)malloc( 64000 );
|
JD8_Surface surface = (JD8_Surface)malloc( w * h );
|
||||||
memset( surface, 0, 64000 );
|
memset( surface, 0, w*h );
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +70,8 @@ JD8_Surface JD8_LoadSurface(const char *file) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
JD8_Surface image = JD8_NewSurface();
|
JD8_Surface image = JD8_NewSurface(w, h);
|
||||||
memcpy(image, pixels, 64000);
|
memcpy(image, pixels, w * h);
|
||||||
|
|
||||||
free(pixels);
|
free(pixels);
|
||||||
return image;
|
return image;
|
||||||
@@ -82,8 +82,15 @@ JD8_Palette JD8_LoadPalette(const char *file) {
|
|||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
buffer = JF_GetBufferFromResource(file, filesize);
|
buffer = JF_GetBufferFromResource(file, filesize);
|
||||||
|
|
||||||
JD8_Palette palette = (JD8_Palette)LoadPalette((unsigned char*)buffer);
|
uint8_t *pal = LoadPalette((unsigned char*)buffer);
|
||||||
|
|
||||||
|
JD8_Palette palette = (JD8_Palette)malloc(256 * sizeof(uint32_t));
|
||||||
|
for (int i=0; i<256; ++i) {
|
||||||
|
palette[i].r = pal[i*3];
|
||||||
|
palette[i].g = pal[1 + i*3];
|
||||||
|
palette[i].b = pal[2 + i*3];
|
||||||
|
//palette[i].hex = 0xff0000;
|
||||||
|
}
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,12 +180,7 @@ void JD8_BlitCKToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int
|
|||||||
SDL_Rect rect{0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
SDL_Rect rect{0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
||||||
|
|
||||||
void JD8_Flip() {
|
void JD8_Flip() {
|
||||||
for( int x = 0; x < 320; x++ ) {
|
for (int i=0; i<64000; ++i) pixel_data[i] = main_palette[screen[i]].hex;
|
||||||
for( int y = 0; y < 200; y++ ) {
|
|
||||||
Uint32 color = 0xFF000000 + main_palette[screen[x + ( y * 320 )]].r + ( main_palette[screen[x + ( y * 320 )]].g << 8 ) + ( main_palette[screen[x + ( y * 320 )]].b << 16 );
|
|
||||||
pixel_data[x + ( y * 320 )] = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SDL_UpdateTexture(sdlTexture, NULL, pixel_data, 320 * sizeof(Uint32));
|
SDL_UpdateTexture(sdlTexture, NULL, pixel_data, 320 * sizeof(Uint32));
|
||||||
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, &rect);
|
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, &rect);
|
||||||
SDL_RenderPresent(sdlRenderer);
|
SDL_RenderPresent(sdlRenderer);
|
||||||
|
|||||||
11
jdraw8.h
11
jdraw8.h
@@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
struct Color {
|
union Color {
|
||||||
Uint8 r;
|
struct {
|
||||||
Uint8 g;
|
uint8_t b, g, r, a;
|
||||||
Uint8 b;
|
};
|
||||||
|
uint32_t hex;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Uint8* JD8_Surface;
|
typedef Uint8* JD8_Surface;
|
||||||
@@ -16,7 +17,7 @@ void JD8_Quit();
|
|||||||
|
|
||||||
void JD8_ClearScreen(Uint8 color);
|
void JD8_ClearScreen(Uint8 color);
|
||||||
|
|
||||||
JD8_Surface JD8_NewSurface();
|
JD8_Surface JD8_NewSurface(const int w, const int h);
|
||||||
|
|
||||||
JD8_Surface JD8_LoadSurface(const char *file);
|
JD8_Surface JD8_LoadSurface(const char *file);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace module
|
|||||||
{
|
{
|
||||||
bool eixir = false;
|
bool eixir = false;
|
||||||
|
|
||||||
fondo_temp = JD8_NewSurface();
|
fondo_temp = JD8_NewSurface(320, 200);
|
||||||
JD8_BlitToSurface(0, 0, fondo, 0, 0, 320, 200, fondo_temp);
|
JD8_BlitToSurface(0, 0, fondo, 0, 0, 320, 200, fondo_temp);
|
||||||
JD8_Blit(fondo_temp);
|
JD8_Blit(fondo_temp);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user