forked from KolibriOS/kolibrios
Port libSDL from Menuetlibc to Newlib
git-svn-id: svn://kolibrios.org@6347 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2a90425400
commit
7199ee861f
@ -1,9 +1,13 @@
|
|||||||
OUTFILE = ../lib/libSDL.a
|
CC = kos32-gcc
|
||||||
|
AR = kos32-ar
|
||||||
|
LD = kos32-ld
|
||||||
|
|
||||||
|
SDK_DIR:= $(abspath ../../..)
|
||||||
|
|
||||||
endian_OBJS = endian/SDL_endian.o
|
endian_OBJS = endian/SDL_endian.o
|
||||||
file_OBJS = file/SDL_rwops.o
|
file_OBJS = file/SDL_rwops.o
|
||||||
hermes_OBJS = hermes/mmxp2_32.o hermes/mmx_main.o hermes/x86p_16.o \
|
hermes_OBJS = hermes/mmxp2_32.obj hermes/mmx_main.obj hermes/x86p_16.obj \
|
||||||
hermes/x86p_32.o hermes/x86_main.o
|
hermes/x86p_32.obj hermes/x86_main.obj
|
||||||
thread_OBJS = thread/SDL_syscond.o thread/SDL_sysmutex.o thread/SDL_syssem.o \
|
thread_OBJS = thread/SDL_syscond.o thread/SDL_sysmutex.o thread/SDL_syssem.o \
|
||||||
thread/SDL_systhread.o thread/SDL_thread.o
|
thread/SDL_systhread.o thread/SDL_thread.o
|
||||||
timer_OBJS = timer/SDL_timer.o timer/dummy/SDL_systimer.o
|
timer_OBJS = timer/SDL_timer.o timer/dummy/SDL_systimer.o
|
||||||
@ -17,30 +21,47 @@ video_OBJS = video/SDL_blit_0.o video/SDL_blit_1.o video/SDL_blit_A.o \
|
|||||||
video/SDL_video.o video/SDL_yuv.o video/SDL_yuv_mmx.o \
|
video/SDL_video.o video/SDL_yuv.o video/SDL_yuv_mmx.o \
|
||||||
video/SDL_yuv_sw.o video/menuetos/SDL_menuetevents.o \
|
video/SDL_yuv_sw.o video/menuetos/SDL_menuetevents.o \
|
||||||
video/menuetos/SDL_menuetvideo.o
|
video/menuetos/SDL_menuetvideo.o
|
||||||
audio_OBJS = audio/SDL_kolibri_audio.o \
|
audio_OBJS = audio/SDL_kolibri_audio.o
|
||||||
audio/klbr_sdk/src/init.o audio/klbr_sdk/src/setbuf.o \
|
#\
|
||||||
audio/klbr_sdk/src/stopbuf.o audio/klbr_sdk/src/sndgetsize.o
|
# audio/klbr_sdk/src/init.o audio/klbr_sdk/src/setbuf.o \
|
||||||
|
# audio/klbr_sdk/src/stopbuf.o audio/klbr_sdk/src/sndgetsize.o
|
||||||
|
|
||||||
curr_OBJS = SDL.o SDL_error.o SDL_fatal.o SDL_getenv.o
|
curr_OBJS = SDL.o SDL_error.o SDL_fatal.o SDL_getenv.o
|
||||||
|
|
||||||
OBJS = $(endian_OBJS) $(file_OBJS) $(hermes_OBJS) $(thread_OBJS) \
|
OBJS = $(endian_OBJS) $(file_OBJS) $(hermes_OBJS) $(thread_OBJS) \
|
||||||
$(timer_OBJS) $(event_OBJS) $(video_OBJS) $(curr_OBJS) $(audio_OBJS)
|
$(timer_OBJS) $(event_OBJS) $(video_OBJS) $(curr_OBJS) $(audio_OBJS)
|
||||||
|
|
||||||
CFLAGS = -D_REENTRANT -I../include -I. -DPACKAGE=\"SDL\" -DVERSION=\"1.2.2\" \
|
CFLAGS = -c -O2 -D_REENTRANT -I../include -I. -DPACKAGE=\"SDL\" -DVERSION=\"1.2.2\" \
|
||||||
-fexpensive-optimizations -Wall -DENABLE_AUDIO -UDISABLE_AUDIO -DDISABLE_JOYSTICK \
|
-fexpensive-optimizations -Wall -DENABLE_AUDIO -UDISABLE_AUDIO -DDISABLE_JOYSTICK \
|
||||||
-DDISABLE_CDROM -DDISABLE_THREADS -DENABLE_TIMERS \
|
-DDISABLE_CDROM -DDISABLE_THREADS -DENABLE_TIMERS \
|
||||||
-DUSE_ASMBLIT -Ihermes -Iaudio -Ivideo -Ievents \
|
-DUSE_ASMBLIT -Ihermes -Iaudio -Ivideo -Ievents \
|
||||||
-Ijoystick -Icdrom -Ithread -Itimer -Iendian -Ifile -DENABLE_MENUETOS \
|
-Ijoystick -Icdrom -Ithread -Itimer -Iendian -Ifile -DENABLE_MENUETOS \
|
||||||
-DNO_SIGNAL_H -DDISABLE_STDIO -DNEED_SDL_GETENV -DENABLE_FILE -UDISABLE_FILE \
|
-DNO_SIGNAL_H -DDISABLE_STDIO -DNEED_SDL_GETENV -DENABLE_FILE -UDISABLE_FILE \
|
||||||
-D__MENUETOS__ -DDEBUG_VIDEO -UWIN32
|
-D__MENUETOS__ -DDEBUG_VIDEO -UWIN32 -U_Win32 -U_WIN32 -U__MINGW32__ \
|
||||||
|
-I../../newlib/libc/include/
|
||||||
|
|
||||||
|
|
||||||
|
LDFLAGS = -shared -s -T../../newlib/libc/app.lds -nostdlib --image-base 0 -L/home/autobuild/tools/win32/mingw32/lib -lgcc /home/autobuild/tools/win32/lib/libz.a /home/autobuild/tools/win32/lib/libdll.a /home/autobuild/tools/win32/lib/libapp.a /home/autobuild/tools/win32/lib/libc.dll.a
|
||||||
|
|
||||||
|
ARFLAGS = crs
|
||||||
|
|
||||||
|
#include $(MENUETDEV)/makefiles/Makefile_for_lib
|
||||||
|
|
||||||
|
all: libSDL.a
|
||||||
|
|
||||||
|
install: libSDL.a
|
||||||
|
mv -f libSDL.a $(SDK_DIR)/lib
|
||||||
|
|
||||||
|
libSDL.a: $(OBJS)
|
||||||
|
$(AR) $(ARFLAGS) libSDL.a
|
||||||
|
|
||||||
|
%.obj : %.asm Makefile
|
||||||
|
nasm -f coff $< $
|
||||||
|
|
||||||
|
%.o : %.c Makefile
|
||||||
|
$(CC) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f */*.o
|
||||||
|
|
||||||
include $(MENUETDEV)/makefiles/Makefile_for_lib
|
|
||||||
|
|
||||||
audio/klbr_sdk/src/init.o : audio/klbr_sdk/src/init.asm
|
|
||||||
fasm audio/klbr_sdk/src/init.asm audio/klbr_sdk/src/init.o
|
|
||||||
audio/klbr_sdk/src/setbuf.o : audio/klbr_sdk/src/setbuf.asm
|
|
||||||
fasm audio/klbr_sdk/src/setbuf.asm audio/klbr_sdk/src/setbuf.o
|
|
||||||
audio/klbr_sdk/src/stopbuf.o : audio/klbr_sdk/src/stopbuf.asm
|
|
||||||
fasm audio/klbr_sdk/src/stopbuf.asm audio/klbr_sdk/src/stopbuf.o
|
|
||||||
audio/klbr_sdk/src/sndgetsize.o : audio/klbr_sdk/src/sndgetsize.asm
|
|
||||||
fasm audio/klbr_sdk/src/sndgetsize.asm audio/klbr_sdk/src/sndgetsize.o
|
|
||||||
|
@ -115,7 +115,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
printf("Setting FIRST=VALUE1 in the environment... ");
|
printf("Setting FIRST=VALUE1 in the environment... ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if ( putenv("FIRST=VALUE1") == 0 ) {
|
if ( sdlputenv("FIRST=VALUE1") == 0 ) {
|
||||||
printf("okay\n");
|
printf("okay\n");
|
||||||
} else {
|
} else {
|
||||||
printf("failed\n");
|
printf("failed\n");
|
||||||
@ -130,7 +130,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
printf("Setting SECOND=VALUE2 in the environment... ");
|
printf("Setting SECOND=VALUE2 in the environment... ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if ( putenv("SECOND=VALUE2") == 0 ) {
|
if ( sdlputenv("SECOND=VALUE2") == 0 ) {
|
||||||
printf("okay\n");
|
printf("okay\n");
|
||||||
} else {
|
} else {
|
||||||
printf("failed\n");
|
printf("failed\n");
|
||||||
@ -145,7 +145,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
printf("Setting FIRST=NOVALUE in the environment... ");
|
printf("Setting FIRST=NOVALUE in the environment... ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if ( putenv("FIRST=NOVALUE") == 0 ) {
|
if ( sdlputenv("FIRST=NOVALUE") == 0 ) {
|
||||||
printf("okay\n");
|
printf("okay\n");
|
||||||
} else {
|
} else {
|
||||||
printf("failed\n");
|
printf("failed\n");
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#include "SDL_audio.h"
|
#include "SDL_audio.h"
|
||||||
#include <menuet/os.h>
|
#include <kos32sys.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sound.h>
|
#include <sound.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static void GetNotify(__u32* event)
|
static void GetNotify(uint32_t* event)
|
||||||
{
|
{
|
||||||
__asm__("int $0x40" :: "a"(68),"b"(14),"c"(event));
|
__asm__("int $0x40" :: "a"(68),"b"(14),"c"(event));
|
||||||
}
|
}
|
||||||
@ -36,9 +36,9 @@ static SNDBUF hBuff=0;
|
|||||||
static char* data=NULL;
|
static char* data=NULL;
|
||||||
static int audio_tid=0;
|
static int audio_tid=0;
|
||||||
static int main_slot;
|
static int main_slot;
|
||||||
static __u32 main_tid;
|
static uint32_t main_tid;
|
||||||
static char audio_thread_stack[40960];
|
static char audio_thread_stack[40960];
|
||||||
static __u32 used_format=0;
|
static uint32_t used_format=0;
|
||||||
static volatile int mix_size=0;
|
static volatile int mix_size=0;
|
||||||
|
|
||||||
static void (*callback)(void* userdata, Uint8* stream, int len);
|
static void (*callback)(void* userdata, Uint8* stream, int len);
|
||||||
@ -81,20 +81,20 @@ static void audio_thread(void)
|
|||||||
{
|
{
|
||||||
SDL_printf("audio_thread created\n");
|
SDL_printf("audio_thread created\n");
|
||||||
int bPaused;
|
int bPaused;
|
||||||
__u32 event[6];
|
uint32_t event[6];
|
||||||
// initialize
|
// initialize
|
||||||
if (CreateBuffer(used_format|PCM_RING, 0, &hBuff))
|
if (CreateBuffer(used_format|PCM_RING, 0, &hBuff))
|
||||||
{
|
{
|
||||||
audio_response=1;
|
audio_response=1;
|
||||||
__menuet__sys_exit();
|
__asm__ __volatile__("int $0x40" ::"a"(-1));
|
||||||
}
|
}
|
||||||
GetBufferSize(hBuff, &mix_size);
|
GetBufferSize(hBuff, &mix_size);
|
||||||
SDL_printf("buffer created, size is %d\n",mix_size);
|
SDL_printf("buffer created, size is %d\n",mix_size);
|
||||||
mix_size >>= 1;
|
mix_size >>= 1;
|
||||||
data = malloc(mix_size);
|
data = malloc(mix_size);
|
||||||
audio_response=1;
|
audio_response=1;
|
||||||
if (!data) __menuet__sys_exit();
|
if (!data) __asm__ __volatile__("int $0x40" ::"a"(-1));
|
||||||
// wait for resume
|
// wait for resume
|
||||||
while (audio_command!=AUDIO_RESUME)
|
while (audio_command!=AUDIO_RESUME)
|
||||||
Yield();
|
Yield();
|
||||||
// initialize
|
// initialize
|
||||||
@ -130,19 +130,19 @@ static void audio_thread(void)
|
|||||||
audio_response = 1;
|
audio_response = 1;
|
||||||
StopBuffer(hBuff);
|
StopBuffer(hBuff);
|
||||||
DestroyBuffer(hBuff);
|
DestroyBuffer(hBuff);
|
||||||
__menuet__sys_exit();
|
__asm__ __volatile__("int $0x40" ::"a"(-1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetProcessInfo(main_slot);
|
GetProcessInfo(main_slot);
|
||||||
if (pinfo[0x32]==9 || *(__u32*)(pinfo+0x1E)!=main_tid)
|
if (pinfo[0x32]==9 || *(uint32_t*)(pinfo+0x1E)!=main_tid)
|
||||||
{
|
{
|
||||||
audio_command = AUDIO_DIE;
|
audio_command = AUDIO_DIE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bPaused)
|
if (bPaused)
|
||||||
__menuet__delay100(5);
|
delay(500);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetNotify(event);
|
GetNotify(event);
|
||||||
@ -230,11 +230,11 @@ int SDL_OpenAudio(SDL_AudioSpec* desired, SDL_AudioSpec* obtained)
|
|||||||
callback=desired->callback;
|
callback=desired->callback;
|
||||||
userdata=desired->userdata;
|
userdata=desired->userdata;
|
||||||
GetProcessInfo(-1);
|
GetProcessInfo(-1);
|
||||||
main_tid = *(__u32*)(pinfo+0x1E);
|
main_tid = *(uint32_t*)(pinfo+0x1E);
|
||||||
for (main_slot=0;;main_slot++)
|
for (main_slot=0;;main_slot++)
|
||||||
{
|
{
|
||||||
GetProcessInfo(main_slot);
|
GetProcessInfo(main_slot);
|
||||||
if (pinfo[0x32]!=9 && *(__u32*)(pinfo+0x1E)==main_tid)
|
if (pinfo[0x32]!=9 && *(uint32_t*)(pinfo+0x1E)==main_tid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
audio_tid=CreateThread(audio_thread,audio_thread_stack+40960);
|
audio_tid=CreateThread(audio_thread,audio_thread_stack+40960);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include<menuet/os.h>
|
#include<kos32sys.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_sysevents.h"
|
#include "SDL_sysevents.h"
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
@ -161,9 +162,9 @@ void MenuetOS_PumpEvents(_THIS)
|
|||||||
int i;
|
int i;
|
||||||
SDL_keysym key;
|
SDL_keysym key;
|
||||||
static int ext_code=0;
|
static int ext_code=0;
|
||||||
static __u8 old_mode=0;
|
static uint8_t old_mode=0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
i=__menuet__check_for_event();
|
i=check_os_event();
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -172,7 +173,7 @@ void MenuetOS_PumpEvents(_THIS)
|
|||||||
MenuetOS_SDL_RepaintWnd();
|
MenuetOS_SDL_RepaintWnd();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
key.scancode = __menuet__getkey();
|
key.scancode = get_key;
|
||||||
if (key.scancode == 0xE0 || key.scancode == 0xE1)
|
if (key.scancode == 0xE0 || key.scancode == 0xE1)
|
||||||
{ext_code=key.scancode;break;}
|
{ext_code=key.scancode;break;}
|
||||||
if (ext_code == 0xE1 && (key.scancode & 0x7F) == 0x1D) break;
|
if (ext_code == 0xE1 && (key.scancode & 0x7F) == 0x1D) break;
|
||||||
@ -198,7 +199,7 @@ void MenuetOS_PumpEvents(_THIS)
|
|||||||
SDL_PrivateKeyboard(code,&key);
|
SDL_PrivateKeyboard(code,&key);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(__menuet__get_button_id()==1) exit(0);
|
if(get_os_button()==1) exit(0);
|
||||||
break;
|
break;
|
||||||
case 6: {
|
case 6: {
|
||||||
int __tmp,mx,my;
|
int __tmp,mx,my;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <menuet/os.h>
|
#include <kos32sys.h>
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
#include "SDL_video.h"
|
#include "SDL_video.h"
|
||||||
@ -11,6 +11,25 @@
|
|||||||
#include "SDL_menuetvideo.h"
|
#include "SDL_menuetvideo.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
struct process_table_entry
|
||||||
|
{
|
||||||
|
uint32_t cpu_usage;
|
||||||
|
uint16_t pos_in_windowing_stack;
|
||||||
|
uint16_t win_stack_val_at_ecx;
|
||||||
|
uint16_t reserved1;
|
||||||
|
char name[12];
|
||||||
|
uint32_t memstart;
|
||||||
|
uint32_t memused;
|
||||||
|
uint32_t pid;
|
||||||
|
uint32_t winx_start,winy_start;
|
||||||
|
uint32_t winx_size,winy_size;
|
||||||
|
uint16_t thread_state;
|
||||||
|
uint16_t reserved2;
|
||||||
|
uint32_t client_left,client_top,client_width,client_height;
|
||||||
|
uint8_t window_state;
|
||||||
|
uint8_t reserved3[1024-71];
|
||||||
|
};
|
||||||
|
|
||||||
static SDL_VideoDevice * vm_suf=NULL;
|
static SDL_VideoDevice * vm_suf=NULL;
|
||||||
static int was_initialized=0;
|
static int was_initialized=0;
|
||||||
|
|
||||||
@ -32,8 +51,8 @@ static int IsStyle4Available=0;
|
|||||||
|
|
||||||
void MenuetOS_SDL_RepaintWnd(void)
|
void MenuetOS_SDL_RepaintWnd(void)
|
||||||
{
|
{
|
||||||
__menuet__window_redraw(1);
|
begin_draw();
|
||||||
__menuet__define_window(1,1,vm_suf->hidden->win_size_x+9,vm_suf->hidden->win_size_y+get_skinh()+4,
|
sys_create_window(1,1,vm_suf->hidden->win_size_x+9,vm_suf->hidden->win_size_y+get_skinh()+4,
|
||||||
#ifdef KEEP_OBSOLETE_STYLE3
|
#ifdef KEEP_OBSOLETE_STYLE3
|
||||||
IsStyle4Available?0x34000000:0x33000000
|
IsStyle4Available?0x34000000:0x33000000
|
||||||
#else
|
#else
|
||||||
@ -41,10 +60,11 @@ void MenuetOS_SDL_RepaintWnd(void)
|
|||||||
#endif
|
#endif
|
||||||
,0,(int)vm_suf->hidden->__title);
|
,0,(int)vm_suf->hidden->__title);
|
||||||
if(vm_suf && vm_suf->hidden->__video_buffer)
|
if(vm_suf && vm_suf->hidden->__video_buffer)
|
||||||
__menuet__putimage(0,0,
|
put_image(0,0,
|
||||||
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y,
|
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y,
|
||||||
vm_suf->hidden->__video_buffer);
|
vm_suf->hidden->__video_buffer);
|
||||||
__menuet__window_redraw(2);
|
|
||||||
|
begin_draw();;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MenuetOS_AllocHWSurface(_THIS,SDL_Surface * surface)
|
static int MenuetOS_AllocHWSurface(_THIS,SDL_Surface * surface)
|
||||||
@ -69,7 +89,7 @@ static void MenuetOS_DirectUpdate(_THIS,int numrects,SDL_Rect * rects)
|
|||||||
{
|
{
|
||||||
if(numrects)
|
if(numrects)
|
||||||
{
|
{
|
||||||
__menuet__putimage(0,0,
|
put_image(0,0,
|
||||||
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y,
|
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y,
|
||||||
this->hidden->__video_buffer);
|
this->hidden->__video_buffer);
|
||||||
}
|
}
|
||||||
@ -126,7 +146,7 @@ SDL_Surface * MenuetOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__menuet__set_bitfield_for_wanted_events(0x27);
|
set_wanted_events_mask(0x27);
|
||||||
was_initialized=1;
|
was_initialized=1;
|
||||||
MenuetOS_SDL_RepaintWnd();
|
MenuetOS_SDL_RepaintWnd();
|
||||||
}
|
}
|
||||||
@ -194,8 +214,7 @@ static int MenuetOS_VideoInit(_THIS,SDL_PixelFormat * vformat)
|
|||||||
|
|
||||||
static int MenuetOS_FlipHWSurface(_THIS,SDL_Surface * surface)
|
static int MenuetOS_FlipHWSurface(_THIS,SDL_Surface * surface)
|
||||||
{
|
{
|
||||||
__menuet__putimage(0,0,surface->w,surface->h,
|
put_image(0,0,surface->w,surface->h, surface->pixels);
|
||||||
surface->pixels);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user