SDL newlib: clean

git-svn-id: svn://kolibrios.org@8494 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
maxcodehack 2020-12-29 14:04:01 +00:00
parent 906e6d8dce
commit d6dcd6eccb
34 changed files with 52 additions and 449 deletions

View File

@ -50,7 +50,7 @@ install: libSDL.a
mv -f libSDL.a $(SDK_DIR)/lib
libSDL.a: $(OBJS)
$(AR) $(ARFLAGS) libSDL.a $(OBJS) SYSCALL/src/*.o
$(AR) $(ARFLAGS) libSDL.a $(OBJS) SYSCALL/src/os.o
%.o : %.asm Makefile
nasm -f coff $< $

View File

@ -1,26 +0,0 @@
#include<menuet/os.h>
void __menuet__set_background_size(__u32 xsz,__u32 ysz)
{
__asm__ __volatile__("int $0x40"::"a"(15),"b"(1),"c"(xsz),"d"(ysz));
}
void __menuet__write_background_mem(__u32 pos,__u32 color)
{
__asm__ __volatile__("int $0x40"::"a"(15),"b"(2),"c"(pos),"d"(color));
}
void __menuet__draw_background(void)
{
__asm__ __volatile__("int $0x40"::"a"(15),"b"(3));
}
void __menuet__set_background_draw_type(int type)
{
__asm__ __volatile__("int $0x40"::"a"(15),"b"(3),"c"(type));
}
void __menuet__background_blockmove(char * src_ptr,__u32 bgr_dst,__u32 count)
{
__asm__ __volatile__("int $0x40"::"a"(15),"b"(3),"c"(src_ptr),"d"(bgr_dst),"S"(count));
}

View File

@ -1,9 +0,0 @@
#include<menuet/os.h>
void __menuet__bar(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,__u32 color)
{
__u32 a,b;
a=(x1<<16)|xsize;
b=(y1<<16)|ysize;
__asm__ __volatile__("int $0x40"::"a"(13),"b"(a),"c"(b),"d"(color));
}

View File

@ -1,17 +0,0 @@
#include<menuet/os.h>
void __menuet__make_button(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,
int id,__u32 color)
{
__u32 a,b;
a=(x1<<16)|xsize;
b=(y1<<16)|ysize;
__asm__ __volatile__("int $0x40"::"a"(8),"b"(a),"c"(b),"d"(id),"S"(color));
}
int __menuet__get_button_id(void)
{
__u16 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(17));
if((__ret & 0xFF)==0) return (__ret>>8)&0xFF; else return -1;
}

View File

@ -1,8 +0,0 @@
#include<menuet/os.h>
__u32 __menuet__getsystemclock(void)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(3));
return __ret;
}

View File

@ -1,15 +0,0 @@
#include <menuet/os.h>
#include <stdio.h>
#include <string.h>
IMP_TABLE __kolibri__cofflib_load(const char* name){
__asm__ __volatile__("int $0x40"::"a"(68L),"b"(19L),"c"((__u32)name));
}
__u32 __kolibri__cofflib_getproc(IMP_TABLE lib, const char* name){
if(!name || !name[0]) return 0;
int i;
for(i = 0; lib[i].name && strcmp(name, lib[i].name); i++);
if(lib[i].name) return (__u32)lib[i].pointer;
else return 0;
}

View File

@ -1,8 +0,0 @@
#include<menuet/os.h>
__u32 __menuet__get_date(void)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(29));
return __ret;
}

View File

@ -1,5 +0,0 @@
#include <menuet/os.h>
void __menuet__debug_out(const char* str){
while(*str)
__menuet__debug_out_byte(*str++);
}

View File

@ -1,11 +0,0 @@
#include<menuet/os.h>
void __menuet__delay100(int m)
{
__asm__ __volatile__("int $0x40"::"a"(5),"b"(m));
}
void __menuet__idle(void)
{
__menuet__delay100(10);
}

View File

@ -1,19 +0,0 @@
#include<menuet/os.h>
void __menuet__dga_get_caps(int * xres,int * yres,int * bpp,int * bpscan)
{
int p;
__asm__ __volatile__("int $0x40":"=a"(p):"0"(61),"b"(1));
if(xres) *xres=(p>>16)&0xFFFF;
if(yres) *yres=p & 0xFFFF;
if(bpp)
{
__asm__ __volatile__("int $0x40":"=a"(p):"0"(61),"b"(2));
*bpp=p;
}
if(bpscan)
{
__asm__ __volatile__("int $0x40":"=a"(p):"0"(61),"b"(3));
*bpscan=p;
}
}

View File

@ -1,20 +0,0 @@
#include<menuet/os.h>
int __menuet__wait_for_event(void)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(10));
return __ret;
}
int __menuet__check_for_event(void)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(11));
return __ret;
}
void __menuet__set_bitfield_for_wanted_events(__u32 ev)
{
__asm__ __volatile__("int $0x40"::"a"(40),"b"(ev));
}

View File

@ -1,6 +0,0 @@
#include<menuet/os.h>
void __menuet__sys_exit(void)
{
__asm__ __volatile__("int $0x40"::"a"(0xFFFFFFFF));
}

View File

@ -1,45 +0,0 @@
#include<menuet/os.h>
#include<stdio.h>
#include<stdarg.h>
#include<string.h>
__u32 __menuet__open(char * name,char * data)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(6),"b"((__u32)name),"c"(0),"d"(0xFFFFFFFF),"S"((__u32)data));
return __ret;
}
void __menuet__save(char * name,char * data,__u32 count)
{
__asm__ __volatile__("int $0x40"::"a"(33),"b"((__u32)name),"c"((__u32)data),"d"(count),"S"(0));
}
void __menuet__exec_ramdisk(char * filename,char * args,...)
{
va_list argz;
char buffer[1024];
memset(buffer,0,1024);
if(args)
{
va_start(argz,args);
vsprintf(buffer,args,argz);
}
va_end(argz);
__asm__ __volatile__("int $0x40"::"a"(19),"b"(filename),"c"((args ? buffer : NULL)));
}
void __menuet__exec_hd(char * filename,char * args,...)
{
va_list argz;
char buffer[1024];
char work_area[0xFFFF];
memset(buffer,0,1024);
if(args)
{
va_start(argz,args);
vsprintf(buffer,args,argz);
}
va_end(argz);
__asm__ __volatile__("int $0x40"::"a"(19),"b"(filename),"c"(args ? buffer : NULL),"d"(work_area));
}

View File

@ -1,9 +0,0 @@
#include<menuet/os.h>
void __menuet__putimage(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,char * image)
{
__u32 a,b;
a=(xsize<<16)|ysize;
b=(x1<<16)|y1;
__asm__ __volatile__("int $0x40"::"a"(7),"b"(image),"c"(a),"d"(b));
}

View File

@ -1,11 +0,0 @@
#include<menuet/os.h>
void send_message(int pid,void * msg_ptr,int message_size)
{
__asm__ __volatile__("int $0x40"::"a"(60),"b"(2),"c"(pid),"d"(msg_ptr),"S"(message_size));
}
void define_receive_area(msgrcva_t * rcva_ptr,int size)
{
__asm__ __volatile__("int $0x40"::"a"(60),"b"(1),"c"(rcva_ptr),"d"(size));
}

View File

@ -1,62 +0,0 @@
#include<menuet/os.h>
__u32 __menuet__get_irq_owner(__u32 irq)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(41),"b"(irq));
return __ret;
}
int __menuet__get_data_read_by_irq(__u32 irq,__u32 * num_bytes_in_buf,__u8 * data)
{
__u32 a,b,c;
__asm__ __volatile__("int $0x40":"=a"(a),"=b"(b),"=c"(c):"0"(42),"1"(irq));
if(num_bytes_in_buf) *num_bytes_in_buf=a;
if(data) *data=b & 0xFF;
return c;
}
int __menuet__send_data_to_device(__u16 port,__u8 val)
{
int __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(43),"b"(port),"c"(val));
return __ret;
}
void __menuet__program_irq(void * intr_table,__u32 irq_num)
{
__asm__ __volatile__("int $0x40"::"a"(44),"b"(intr_table),"c"(irq_num));
}
int __menuet__reserve_irq(int irqno)
{
int __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(45),"b"(0),"c"(irqno));
return __ret;
}
int __menuet__free_irq(int irqno)
{
int __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(45),"b"(1),"c"(irqno));
return __ret;
}
int __menuet__reserve_port_area(__u32 start,__u32 end)
{
int __ret;
__asm__("int $0x40":"=a"(__ret):"a"(45),"b"(0),"c"(start),"d"(end));
return __ret;
}
int __menuet__free_port_area(__u32 start,__u32 end)
{
int __ret;
__asm__("int $0x40":"=a"(__ret):"a"(45),"b"(1),"c"(start),"d"(end));
return __ret;
}
void __menuet__define_app_internal_intrs(void * intr_table)
{
__asm__("int $0x40"::"a"(49),"b"(0),"c"(intr_table));
}

View File

@ -1,8 +0,0 @@
#include<menuet/os.h>
int __menuet__getkey(void)
{
__u16 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(2));
if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0;
}

View File

@ -1,9 +0,0 @@
#include<menuet/os.h>
void __menuet__line(__u16 x1,__u16 y1,__u16 x2,__u16 y2,__u32 color)
{
__u32 b,c;
b=(x1<<16)|x1;
c=(y1<<16)|y2;
__asm__ __volatile__("int $0x40"::"a"(38),"b"(b),"c"(c),"d"(color));
}

View File

@ -1,11 +0,0 @@
#include<menuet/os.h>
void __menuet__reset_mpu401(void)
{
__asm__ __volatile__("int $0x40"::"a"(20),"b"(1));
}
void __menuet__write_mpu401(__u8 d)
{
__asm__ __volatile__("int $0x40"::"a"(20),"b"(2),"c"(d));
}

View File

@ -0,0 +1,39 @@
#include <menuet/os.h>
void __menuet__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,
__u32 body_color,__u32 grab_color,__u32 frame_color)
{
__u32 a,b;
a=(x1<<16)|xsize;
b=(y1<<16)|ysize;
__asm__ __volatile__("int $0x40"::"a"(0),"b"(a),"c"(b),"d"(body_color),"S"(grab_color),
"D"(frame_color));
}
void __menuet__window_redraw(int status)
{
__asm__ __volatile__("int $0x40"::"a"(12),"b"(status));
}
void __menuet__putimage(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,char * image)
{
__u32 a,b;
a=(xsize<<16)|ysize;
b=(x1<<16)|y1;
__asm__ __volatile__("int $0x40"::"a"(7),"b"(image),"c"(a),"d"(b));
}
int __menuet__getkey(void)
{
__u16 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(2));
if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0;
}
int __menuet__check_for_event(void)
{
__u32 __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(11));
return __ret;
}

View File

@ -1,7 +0,0 @@
#include<menuet/os.h>
#define APP_PARAM_SZ (1024)
#define APP_PATH_SZ (1024)
char __menuet__app_param_area[APP_PARAM_SZ];
char __menuet__app_path_area[APP_PATH_SZ];

View File

@ -1,50 +0,0 @@
#include<menuet/os.h>
#define PCI_FN 62
void get_pci_version(__u8 * major,__u8 * minor)
{
int r;
__asm__ __volatile__("int $0x40":"=a"(r):"0"(PCI_FN),"b"(0));
*minor=r&0xFF;
*major=(r>>8)&0xFF;
}
void pci_get_last_bus(__u8 * last_bus)
{
__asm__ __volatile__("int $0x40":"=a"(*last_bus):"0"(PCI_FN),"b"(1));
}
void get_pci_access_mechanism(__u8 * mechanism)
{
__asm__ __volatile__("int $0x40":"=a"(*mechanism):"0"(PCI_FN),"b"(2));
}
#define read_config(x,c,bits) \
__u##bits pci_read_config_##x (__u8 bus,__u8 dev,__u8 fn,__u8 reg) \
{ \
__u##bits __ret; \
__u16 cx; \
__u16 bx; \
cx=(((fn&7)|(((dev)&~7)<<3))<<8)|reg; \
bx=(bus<<8)|(c); \
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(PCI_FN),"b"(bx),"c"(cx)); \
return __ret; \
}
#define write_config(x,c,bits) \
void pci_write_config_##x (__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u##bits val) \
{ \
__u16 cx,bx; \
cx=(((fn&7)|(((dev)&~7)<<3))<<8)|reg; \
bx=(bus<<8)|(c); \
__asm__ __volatile__("int $0x40"::"a"(PCI_FN),"b"(bx),"c"(cx),"d"(val)); \
}
#define rw_config(x,c,bits) \
read_config(x,4+c,bits) \
write_config(x,7+c,bits)
rw_config(byte,0,8)
rw_config(word,1,16)
rw_config(dword,2,32)

View File

@ -1,6 +0,0 @@
#include<menuet/os.h>
void __menuet__putpixel(__u32 x,__u32 y,__u32 color)
{
__asm__ __volatile__("int $0x40"::"a"(1),"b"(x),"c"(y),"d"(color));
}

View File

@ -1,8 +0,0 @@
#include<menuet/os.h>
int __menuet__get_process_table(struct process_table_entry * proctab,int pid)
{
int __ret;
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(9),"b"((__u32)proctab),"c"(pid));
return __ret;
}

View File

@ -1,9 +0,0 @@
#include<menuet/os.h>
void __menuet__get_screen_max(__u16 * x,__u16 * y)
{
__u32 v;
__asm__ __volatile__("int $0x40":"=a"(v):"0"(14));
if(x) *x=v>>16;
if(y) *y=v & 0xFFFF;
}

View File

@ -1,11 +0,0 @@
#include<menuet/os.h>
void __menuet__sound_load_block(char * blockptr)
{
__asm__ __volatile__("int $0x40"::"a"(55),"b"(0),"c"(blockptr));
}
void __menuet__sound_play_block(void)
{
__asm__ __volatile__("int $0x40"::"a"(55),"b"(1));
}

View File

@ -1,16 +0,0 @@
#include<menuet/os.h>
int __kolibri__system_tree_access(struct systree_info * info)
{
int __ret;
int d0;
__asm__ __volatile__("int $0x40":"=a"(__ret),"=&b"(d0):"0"(70),"1"((__u32)info));
return __ret;
}
int __kolibri__system_tree_access2(struct systree_info2 * info)
{
int __ret;
int d0;
__asm__ __volatile__("int $0x40":"=a"(__ret),"=&b"(d0):"0"(70),"1"((__u32)info));
return __ret;
}

View File

@ -1,6 +0,0 @@
#include<menuet/os.h>
void __menuet__write_text(__u16 x,__u16 y,__u32 color,char * text,int len)
{
__asm__ __volatile__("int $0x40"::"a"(4),"b"((x<<16)|y),"c"(color),"d"((__u32)text),"S"(len));
}

View File

@ -1,12 +0,0 @@
#include<menuet/os.h>
#include<stdio.h>
#include<stdlib.h>
void * __menuet__exec_thread(void (* func_ptr)(void),__u32 stack_size,int * retp)
{
void * __stk, * __ret;
__ret=__stk=malloc(stack_size);
__stk+=stack_size-1;
__asm__ __volatile__("int $0x40":"=a"(*retp):"0"(51L),"b"(1L),"c"((__u32)func_ptr),"d"((__u32)__stk));
return __ret;
}

View File

@ -1,16 +0,0 @@
#include<menuet/os.h>
void __menuet__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,
__u32 body_color,__u32 grab_color,__u32 frame_color)
{
__u32 a,b;
a=(x1<<16)|xsize;
b=(y1<<16)|ysize;
__asm__ __volatile__("int $0x40"::"a"(0),"b"(a),"c"(b),"d"(body_color),"S"(grab_color),
"D"(frame_color));
}
void __menuet__window_redraw(int status)
{
__asm__ __volatile__("int $0x40"::"a"(12),"b"(status));
}

View File

@ -1,4 +1,5 @@
#include "SDL_audio.h"
#include <kos32sys.h>
#include <menuet/os.h>
#include <stdlib.h>
#include <string.h>
@ -86,14 +87,14 @@ static void audio_thread(void)
if (CreateBuffer(used_format|PCM_RING, 0, &hBuff))
{
audio_response=1;
__menuet__sys_exit();
exit(0);
}
GetBufferSize(hBuff, &mix_size);
SDL_printf("buffer created, size is %d\n",mix_size);
mix_size >>= 1;
data = malloc(mix_size);
audio_response=1;
if (!data) __menuet__sys_exit();
if (!data) exit(0);
// wait for resume
while (audio_command!=AUDIO_RESUME)
Yield();
@ -130,7 +131,7 @@ static void audio_thread(void)
audio_response = 1;
StopBuffer(hBuff);
DestroyBuffer(hBuff);
__menuet__sys_exit();
exit(0);
}
else
{
@ -142,7 +143,7 @@ static void audio_thread(void)
}
}
if (bPaused)
__menuet__delay100(5);
delay(5);
else
{
GetNotify(event);

View File

@ -31,6 +31,7 @@ static char rcsid =
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <kos32sys.h>
#include "SDL_error.h"
#include "SDL_timer.h"
@ -88,7 +89,7 @@ Uint32 SDL_GetTicks (void)
void SDL_Delay (Uint32 ms)
{
__menuet__delay100(ms);
delay(ms);
/* Uint32 start = SDL_GetTicks();
do
__asm__("int $0x40" :: "a"(68),"b"(1));

View File

@ -1,4 +1,5 @@
#include <menuet/os.h>
#include <kos32sys.h>
#include <stdlib.h>
#include <stdio.h>
#include "SDL.h"
@ -198,7 +199,7 @@ void MenuetOS_PumpEvents(_THIS)
SDL_PrivateKeyboard(code,&key);
break;
case 3:
if(__menuet__get_button_id()==1) exit(0);
if(get_os_button()==1) exit(0);
break;
case 6: {
int __tmp,mx,my;

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <menuet/os.h>
#include <kos32sys.h>
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_video.h"
@ -150,7 +151,7 @@ SDL_Surface * MenuetOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int
}
else
{
__menuet__set_bitfield_for_wanted_events(0x27);
set_wanted_events_mask(0x27);
was_initialized=1;
MenuetOS_SDL_RepaintWnd();
}