libc.obj:

- Added vsprintf to export
 - Added sdltest.c example

git-svn-id: svn://kolibrios.org@9204 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-09-26 17:55:43 +00:00
parent 3f48750ec0
commit 2076a4a777
6 changed files with 91 additions and 3 deletions

View File

@ -40,6 +40,7 @@ extern int _FUNC(printf)(const char* format, ...);
extern int _FUNC(sprintf)(char* buffer, const char* format, ...);
extern int _FUNC(snprintf)(char* buffer, size_t count, const char* format, ...);
extern int _FUNC(vsnprintf)(char* buffer, size_t count, const char* format, va_list va);
extern int _FUNC(vsprintf)(char* buffer, const char* format, va_list va);
extern int _FUNC(vprintf)(const char* format, va_list va);
extern void _FUNC(debug_printf)(const char* format, ...);

View File

@ -2,7 +2,7 @@
KTCC=kos32-tcc
FASM= fasm
KPACK = kpack
CFLAGS = -I../include
CFLAGS = -I../include -I../../../../../../contrib/sdk/sources/SDL-1.2.2_newlib/include
LDFLAGS = -nostdlib -L../../bin/lib ../../bin/lib/crt0.o
BIN= stdio_test.kex \
@ -21,9 +21,10 @@ clayer/libimg.kex \
clayer/dialog.kex \
clayer/msgbox.kex \
clayer/boxlib.kex \
thread_work.kex
thread_work.kex \
sdltest.kex
LIBS= -ltcc -ldialog -lrasterworks -limg -lbox -lmsgbox -lnetwork -lc.obj
LIBS= -lSDL -ltcc -lsound -ldialog -lrasterworks -limg -lbox -lmsgbox -lnetwork -lc.obj
all: $(BIN)

View File

@ -17,3 +17,4 @@ cp /kolibrios/develop/tcc/samples/clayer/logo.png /tmp0/1/tcc_samples/logo.png
/kolibrios/develop/tcc/tcc clayer/msgbox.c -o /tmp0/1/tcc_samples/msgbox -ltcc -lmsgbox -lc.obj
/kolibrios/develop/tcc/tcc clayer/rasterworks.c -o /tmp0/1/tcc_samples/rasterworks -ltcc -lrasterworks -lc.obj
/kolibrios/develop/tcc/tcc thread_work.c -o /tmp0/1/tcc_samples/thread_work -ltcc -lc.obj
/kolibrios/develop/tcc/tcc -I/kolibrios/develop/tcc/include/SDL sdltest.c -o /tmp0/1/tcc_samples/sdltest -lSDL -lsound -ltcc -lc.obj

View File

@ -0,0 +1,79 @@
#include "SDL.h"
#include <stdlib.h>
#define WIDTH 640
#define HEIGHT 480
#define BPP 4
#define DEPTH 32
void setpixel(SDL_Surface *screen, int x, int y, Uint8 r, Uint8 g, Uint8 b)
{
Uint32 *pixmem32;
Uint32 colour;
colour = SDL_MapRGB( screen->format, r, g, b );
pixmem32 = (Uint32*) screen->pixels + y + x;
*pixmem32 = colour;
}
void DrawScreen(SDL_Surface* screen, int h)
{
int x, y, ytimesw;
if(SDL_MUSTLOCK(screen))
{
if(SDL_LockSurface(screen) < 0) return;
}
for(y = 0; y < screen->h; y++ )
{
ytimesw = y*screen->pitch/BPP;
for( x = 0; x < screen->w; x++ )
{
setpixel(screen, x, ytimesw, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
}
}
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
SDL_Flip(screen);
}
int main(int argc, char* argv[])
{
SDL_Surface *screen;
SDL_Event event;
int keypress = 0;
int h=0;
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN|SDL_HWSURFACE)))
{
SDL_Quit();
return 1;
}
while(!keypress)
{
DrawScreen(screen,h++);
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
keypress = 1;
break;
case SDL_KEYDOWN:
keypress = 1;
break;
}
}
}
SDL_Quit();
return 0;
}

View File

@ -10,6 +10,11 @@
#include <limits.h>
//#include "format_print.h"
int vsprintf (char * s, const char * format, va_list arg)
{
return vsnprintf(s, STDIO_MAX_MEM, format, arg);
}
int vprintf ( const char * format, va_list arg )
{
int len = 0;

View File

@ -38,6 +38,7 @@ tmpnam
vfscanf
vprintf
vfscanf
vsprintf
vsnprintf
vsscanf
ungetc