Hi everyone,
I'm playing around with Vincent Rivière's m68k set of GCC tools, including the port of SDL. I know, I know, it's very limited in xbios mode on an ST (16 colour greyscale according to the docs) and slow, but I'm just wanting to try a few things.
However, I'm not having any luck at all getting anything displayed.
I'm using Hatari, configured as a vanilla ST, and no matter what I do, whether it's trying to display a bitmap, or render a simple flat rectangle it doesn't work. The behaviour I see is SDL initialises the screen (320x200x8), it goes black, then whatever I try to blit to the screen gets at most, shown as a 1 pixel line at the top of the screen - even if all I'm doing is filling the entire screen with white as follows:
Code: Select all
#include <stdio.h>
#include <unistd.h>
#include <SDL/SDL.h>
SDL_version compiled;
SDL_version linked;
int main(int argc, char* argv[]){
SDL_Surface *bg;
SDL_Surface *image;
SDL_Surface *bmp;
SDL_Surface *display;
SDL_Rect src, dest;
char vdriver[32];
FILE *log;
SDL_VERSION(&compiled);
log = fopen("MENU.LOG","w");
fprintf(log, "Menu tool running\n");
fprintf(log, "-----------------\n");
fprintf(log, "\n");
fprintf(log, "libSDL: Initialising...\n");
fflush(log);
if (SDL_Init(SDL_INIT_VIDEO) != 0){
// Error occurred loading SDL
fprintf(log, "SDL_Init Error: %s\n", SDL_GetError());
fflush(log);
fclose(log);
sleep(2);
exit(-1);
} else {
fprintf(log, "libSDL: Initialised v%d.%d.%d ok!\n", compiled.major, compiled.minor, compiled.patch);
fflush(log);
// Set display mode for the SDL screen
fprintf(log, "Display: Driver loading...\n");
fflush(log);
display = SDL_SetVideoMode(320, 200, 0, SDL_SWSURFACE);
if(display == NULL){
fprintf(log, "SDL_SetVideoMode Error: %s\n", SDL_GetError());
fflush(log);
SDL_Quit();
fclose(log);
sleep(2);
exit(-1);
} else {
fprintf(log, "Display: Driver %s ok!\n", SDL_VideoDriverName(vdriver, 32));
fprintf(log, "Display: Driver mode %dx%dx%dbpp ok!\n", display->w, display->h, display->format->BitsPerPixel);
fflush(log);
}
// Load splash bitmap
fprintf(log, "Bitmap: Loading...\n");
fflush(log);
bmp = SDL_LoadBMP("C:\\COMPILER\\MENU\\LOGO.BMP");
if (bmp == NULL){
fprintf(log, "SDL_LoadBMP Error: %s\n", SDL_GetError());
fflush(log);
SDL_Quit();
fclose(log);
sleep(2);
exit(-1);
} else {
fprintf(log, "Bitmap: Loaded %dx%dx%dbpp ok!\n", bmp->w, bmp->h, bmp->format->BitsPerPixel);
fflush(log);
bg = SDL_DisplayFormat(bmp);
SDL_FreeSurface(bmp);
}
// Fill screen white
fprintf(log, "Box: Drawing...\n");
SDL_FillRect(display, NULL, 0xFFFFFF);
SDL_Flip(display);
fprintf(log, "Box: Drawn\n");
fflush(log);
// Display bitmap on screen
image = SDL_DisplayFormat(bg);
SDL_FreeSurface(bg);
fprintf(log, "Display: Blitting...\n");
fflush(log);
//Construct the source rectangle for our blit
src.x = 0;
src.y = 0;
src.w = image->w; //Use image->w to display the entire width of the image
src.h = image->h; //Use image->h to display the entire height of the image
//Construct the destination rectangle for our blit
dest.x = 140;
dest.y = 0;
dest.w = image->w; //Ensure the destination is large enough for the image's entire width/height
dest.h = image->h;
SDL_BlitSurface(image, NULL, display, &dest);
SDL_Flip(display);
fprintf(log, "Display: Blitted ok!\n");
fflush(log);
SDL_Delay(3000);
SDL_FreeSurface(image);
fprintf(log, "Bitmap: Freed\n");
fflush(log);
}
fprintf(log, "libSDL: Unloading...\n");
fflush(log);
SDL_Quit();
fprintf(log, "libSDL: ok\n");
fflush(log);
fclose(log);
sleep(2);
return 0;
}
My log file indicates everything proceeds okay, but the white box renders as a single pixel white line at the top of the screen, as does the bitmap image:
The output I'm writing to the log shows no errors:
Code: Select all
Menu tool running
-----------------
libSDL: Initialising...
libSDL: Initialised v1.2.15 ok!
Display: Driver loading...
Display: Driver xbios ok!
Display: Driver mode 320x200x8bpp ok!
Bitmap: Loading...
Bitmap: Loaded 180x135x8bpp ok!
Box: Drawing...
Box: Drawn
Display: Blitting...
Display: Blitted ok!
Bitmap: Freed
libSDL: Unloading...
libSDL: ok
I suppose most people (if any) have used SDL in GEM, but did anyone come across this behaviour?