forked from KolibriOS/kolibrios
git-svn-id: svn://kolibrios.org@8211 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ab5677a586
commit
e51739d633
19
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/Makefile
Executable file
19
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/Makefile
Executable file
@ -0,0 +1,19 @@
|
||||
CC = kos32-gcc
|
||||
LD = kos32-ld
|
||||
|
||||
SDK_DIR = $(abspath ../../../../../)
|
||||
|
||||
CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32
|
||||
|
||||
INCLUDES = -I ../include -I $(SDK_DIR)/sources/newlib/libc/include
|
||||
|
||||
FITZ_SRC := $(notdir $(wildcard *.c))
|
||||
OBJECTS = $(patsubst %.c, %.o, $(FITZ_SRC))
|
||||
|
||||
default: $(patsubst %.c,%.o,$(FITZ_SRC))
|
||||
|
||||
%.o : %.c Makefile $(FITZ_SRC)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm *.o
|
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/alloca.s
Executable file
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/alloca.s
Executable file
@ -0,0 +1,6 @@
|
||||
#include <libc/asm.h>
|
||||
MK_C_SYM(_alloca)
|
||||
sub %eax, %esp
|
||||
mov (%esp,%eax),%eax
|
||||
mov %eax, (%esp)
|
||||
ret
|
26
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/backgr.c
Executable file
26
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/backgr.c
Executable file
@ -0,0 +1,26 @@
|
||||
#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));
|
||||
}
|
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/bar.c
Executable file
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/bar.c
Executable file
@ -0,0 +1,9 @@
|
||||
#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));
|
||||
}
|
17
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/button.c
Executable file
17
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/button.c
Executable file
@ -0,0 +1,17 @@
|
||||
#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;
|
||||
}
|
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/clock.c
Executable file
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/clock.c
Executable file
@ -0,0 +1,8 @@
|
||||
#include<menuet/os.h>
|
||||
|
||||
__u32 __menuet__getsystemclock(void)
|
||||
{
|
||||
__u32 __ret;
|
||||
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(3));
|
||||
return __ret;
|
||||
}
|
15
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/cofflib.c
Executable file
15
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/cofflib.c
Executable file
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
}
|
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/date.c
Executable file
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/date.c
Executable file
@ -0,0 +1,8 @@
|
||||
#include<menuet/os.h>
|
||||
|
||||
__u32 __menuet__get_date(void)
|
||||
{
|
||||
__u32 __ret;
|
||||
__asm__ __volatile__("int $0x40":"=a"(__ret):"0"(29));
|
||||
return __ret;
|
||||
}
|
5
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/debug.c
Executable file
5
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/debug.c
Executable file
@ -0,0 +1,5 @@
|
||||
#include <menuet/os.h>
|
||||
void __menuet__debug_out(const char* str){
|
||||
while(*str)
|
||||
__menuet__debug_out_byte(*str++);
|
||||
}
|
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/delay.c
Executable file
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/delay.c
Executable file
@ -0,0 +1,11 @@
|
||||
#include<menuet/os.h>
|
||||
|
||||
void __menuet__delay100(int m)
|
||||
{
|
||||
__asm__ __volatile__("int $0x40"::"a"(5),"b"(m));
|
||||
}
|
||||
|
||||
void __menuet__idle(void)
|
||||
{
|
||||
__menuet__delay100(10);
|
||||
}
|
19
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/dga.c
Executable file
19
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/dga.c
Executable file
@ -0,0 +1,19 @@
|
||||
#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;
|
||||
}
|
||||
}
|
20
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/event.c
Executable file
20
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/event.c
Executable file
@ -0,0 +1,20 @@
|
||||
#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));
|
||||
}
|
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/exit.c
Executable file
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/exit.c
Executable file
@ -0,0 +1,6 @@
|
||||
#include<menuet/os.h>
|
||||
|
||||
void __menuet__sys_exit(void)
|
||||
{
|
||||
__asm__ __volatile__("int $0x40"::"a"(0xFFFFFFFF));
|
||||
}
|
45
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/file.c
Executable file
45
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/file.c
Executable file
@ -0,0 +1,45 @@
|
||||
#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));
|
||||
}
|
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/image.c
Executable file
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/image.c
Executable file
@ -0,0 +1,9 @@
|
||||
#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));
|
||||
}
|
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/ipc.c
Executable file
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/ipc.c
Executable file
@ -0,0 +1,11 @@
|
||||
#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));
|
||||
}
|
62
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/irq.c
Executable file
62
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/irq.c
Executable file
@ -0,0 +1,62 @@
|
||||
#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));
|
||||
}
|
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/keyb.c
Executable file
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/keyb.c
Executable file
@ -0,0 +1,8 @@
|
||||
#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;
|
||||
}
|
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/line.c
Executable file
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/line.c
Executable file
@ -0,0 +1,9 @@
|
||||
#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));
|
||||
}
|
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/mpu401.c
Executable file
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/mpu401.c
Executable file
@ -0,0 +1,11 @@
|
||||
#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));
|
||||
}
|
7
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/param.c
Executable file
7
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/param.c
Executable file
@ -0,0 +1,7 @@
|
||||
#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];
|
50
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/pci.c
Executable file
50
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/pci.c
Executable file
@ -0,0 +1,50 @@
|
||||
#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)
|
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/pixel.c
Executable file
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/pixel.c
Executable file
@ -0,0 +1,6 @@
|
||||
#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));
|
||||
}
|
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/process.c
Executable file
8
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/process.c
Executable file
@ -0,0 +1,8 @@
|
||||
#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;
|
||||
}
|
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/screen.c
Executable file
9
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/screen.c
Executable file
@ -0,0 +1,9 @@
|
||||
#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;
|
||||
}
|
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/sound.c
Executable file
11
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/sound.c
Executable file
@ -0,0 +1,11 @@
|
||||
#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));
|
||||
}
|
16
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/systree.c
Executable file
16
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/systree.c
Executable file
@ -0,0 +1,16 @@
|
||||
#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;
|
||||
}
|
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/text.c
Executable file
6
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/text.c
Executable file
@ -0,0 +1,6 @@
|
||||
#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));
|
||||
}
|
12
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/thread.c
Executable file
12
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/thread.c
Executable file
@ -0,0 +1,12 @@
|
||||
#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;
|
||||
}
|
16
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/window.c
Executable file
16
contrib/sdk/sources/SDL-1.2.2_newlib/src/SYSCALL/src/window.c
Executable file
@ -0,0 +1,16 @@
|
||||
#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));
|
||||
}
|
114
contrib/sdk/sources/SDL-1.2.2_newlib/src/timer/dummy/SDL_systimer.c
Executable file
114
contrib/sdk/sources/SDL-1.2.2_newlib/src/timer/dummy/SDL_systimer.c
Executable file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_systimer.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
|
||||
#if _POSIX_THREAD_SYSCALL_SOFT
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if defined(DISABLE_THREADS) || defined(FORK_HACK)
|
||||
#define USE_ITIMER
|
||||
#endif
|
||||
|
||||
|
||||
/* The first ticks value of the application */
|
||||
//static struct timeval start;
|
||||
//static unsigned startlo,starthi;
|
||||
//static unsigned clockrate;
|
||||
static unsigned starttime;
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
// gettimeofday(&start, NULL);
|
||||
// __asm__ ("int $0x40" : "=a"(clockrate) : "a"(18),"b"(5));
|
||||
// __asm__ ("rdtsc" : "=a"(startlo),"=d"(starthi));
|
||||
__asm__ ("int $0x40" : "=a"(starttime) : "a"(26),"b"(9));
|
||||
}
|
||||
|
||||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
/* struct timeval now;
|
||||
Uint32 ticks;
|
||||
gettimeofday(&now, NULL);
|
||||
ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
|
||||
return(ticks);*/
|
||||
/*int res;
|
||||
__asm__ ("rdtsc\n\t"
|
||||
"sub (_startlo),%%eax\n\t"
|
||||
"sbb (_starthi),%%edx\n\t"
|
||||
"push %%eax\n\t"
|
||||
"mov %%edx,%%eax\n\t"
|
||||
"mov $1000,%%ecx\n\t"
|
||||
"mul %%ecx\n\t"
|
||||
"xchg (%%esp),%%eax\n\t"
|
||||
"mul %%ecx\n\t"
|
||||
"add %%edx,(%%esp)\n\t"
|
||||
"pop %%edx\n\t"
|
||||
"divl (_clockrate)\n\t" : "=a"(res));
|
||||
return res;*/
|
||||
unsigned curtime;
|
||||
__asm__ ("int $0x40" : "=a"(curtime) : "a"(26),"b"(9));
|
||||
return (curtime-starttime)*10;
|
||||
}
|
||||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
__menuet__delay100(ms);
|
||||
/* Uint32 start = SDL_GetTicks();
|
||||
do
|
||||
__asm__("int $0x40" :: "a"(68),"b"(1));
|
||||
while (SDL_GetTicks()-start < ms);*/
|
||||
}
|
||||
|
||||
int SDL_SYS_TimerInit(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int SDL_SYS_StartTimer(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void SDL_SYS_StopTimer(void)
|
||||
{
|
||||
}
|
244
contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetevents.c
Executable file
244
contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetevents.c
Executable file
@ -0,0 +1,244 @@
|
||||
#include<menuet/os.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "SDL.h"
|
||||
#include "SDL_sysevents.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_menuetvideo.h"
|
||||
|
||||
extern void MenuetOS_SDL_RepaintWnd(void);
|
||||
|
||||
void MenuetOS_InitOSKeymap(_THIS)
|
||||
{
|
||||
__asm__("int $0x40"::"a"(66),"b"(1),"c"(1));
|
||||
}
|
||||
|
||||
#define LSHIFT 1
|
||||
#define RSHIFT 2
|
||||
#define LCTRL 4
|
||||
#define RCTRL 8
|
||||
#define LALT 0x10
|
||||
#define RALT 0x20
|
||||
#define CAPS 0x40
|
||||
#define NUML 0x80
|
||||
#define SCRL 0x100
|
||||
|
||||
#define SHIFT (LSHIFT+RSHIFT)
|
||||
#define CTRL (LCTRL+RCTRL)
|
||||
#define ALT (LALT+RALT)
|
||||
|
||||
static SDLMod GetModState(void)
|
||||
{
|
||||
unsigned controlstate;
|
||||
__asm__("int $0x40":"=a"(controlstate):"a"(66),"b"(3));
|
||||
SDLMod res = 0;
|
||||
if (controlstate & LSHIFT)
|
||||
res |= KMOD_LSHIFT;
|
||||
if (controlstate & RSHIFT)
|
||||
res |= KMOD_RSHIFT;
|
||||
if (controlstate & LCTRL)
|
||||
res |= KMOD_LCTRL;
|
||||
if (controlstate & RCTRL)
|
||||
res |= KMOD_RCTRL;
|
||||
if (controlstate & LALT)
|
||||
res |= KMOD_LALT;
|
||||
if (controlstate & RALT)
|
||||
res |= KMOD_RALT;
|
||||
if (controlstate & CAPS)
|
||||
res |= KMOD_CAPS;
|
||||
if (controlstate & NUML)
|
||||
res |= KMOD_NUM;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*static __u8 scan2ascii(__u8 n,SDLMod mod)
|
||||
{
|
||||
__u8 layout[128];
|
||||
int layouttype;
|
||||
int bControlLayout = 0;
|
||||
if (mod & KMOD_ALT)
|
||||
layouttype = 3;
|
||||
else if (mod & KMOD_SHIFT)
|
||||
layouttype = 2;
|
||||
else
|
||||
{
|
||||
if (mod & KMOD_CTRL)
|
||||
bControlLayout = 1;
|
||||
layouttype = 1;
|
||||
}
|
||||
__asm__("int $0x40" :: "a"(26),"b"(2),"c"(layouttype),"d"(layout));
|
||||
__u8 res = layout[n];
|
||||
if (bControlLayout)
|
||||
res -= 0x60;
|
||||
return res;
|
||||
}*/
|
||||
static SDLKey sdlkeys[0x80] =
|
||||
{
|
||||
// 0x0*
|
||||
0, SDLK_ESCAPE, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6,
|
||||
SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS, SDLK_BACKSPACE, SDLK_TAB,
|
||||
// 0x1*
|
||||
SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i,
|
||||
SDLK_o, SDLK_p, SDLK_LEFTBRACKET, SDLK_RIGHTBRACKET, SDLK_RETURN, SDLK_LCTRL, SDLK_a, SDLK_s,
|
||||
// 0x2*
|
||||
SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_SEMICOLON,
|
||||
SDLK_QUOTE, SDLK_BACKQUOTE, SDLK_LSHIFT, SDLK_BACKSLASH, SDLK_z, SDLK_x, SDLK_c, SDLK_v,
|
||||
// 0x3*
|
||||
SDLK_b, SDLK_n, SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_RSHIFT, SDLK_KP_MULTIPLY,
|
||||
SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
|
||||
// 0x4*
|
||||
SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_NUMLOCK, SDLK_SCROLLOCK, SDLK_KP7,
|
||||
SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
|
||||
// 0x5*
|
||||
SDLK_KP2, SDLK_KP3, SDLK_KP0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11,
|
||||
SDLK_F12, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x6*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x7*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
static SDLKey sdlkeys_shift[0x80] =
|
||||
{
|
||||
// 0x0*
|
||||
0, SDLK_ESCAPE, SDLK_EXCLAIM, SDLK_AT, SDLK_HASH, SDLK_DOLLAR, '%', SDLK_CARET,
|
||||
SDLK_AMPERSAND, SDLK_ASTERISK, SDLK_LEFTPAREN, SDLK_RIGHTPAREN, SDLK_UNDERSCORE, SDLK_PLUS, SDLK_BACKSPACE, SDLK_TAB,
|
||||
// 0x1*
|
||||
SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i,
|
||||
SDLK_o, SDLK_p, '{', '}', SDLK_RETURN, SDLK_LCTRL, SDLK_a, SDLK_s,
|
||||
// 0x2*
|
||||
SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_COLON,
|
||||
SDLK_QUOTEDBL, '~', SDLK_LSHIFT, '|', SDLK_z, SDLK_x, SDLK_c, SDLK_v,
|
||||
// 0x3*
|
||||
SDLK_b, SDLK_n, SDLK_m, SDLK_LESS, SDLK_GREATER, SDLK_QUESTION, SDLK_RSHIFT, SDLK_KP_MULTIPLY,
|
||||
SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
|
||||
// 0x4*
|
||||
SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_NUMLOCK, SDLK_SCROLLOCK, SDLK_KP7,
|
||||
SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
|
||||
// 0x5*
|
||||
SDLK_KP2, SDLK_KP3, SDLK_KP0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11,
|
||||
SDLK_F12, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x6*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x7*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
static SDLKey sdlkeys_e0[0x80] =
|
||||
{
|
||||
// 0x0*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x1*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, SDLK_KP_ENTER, SDLK_RCTRL, 0, 0,
|
||||
// 0x2*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x3*
|
||||
0, 0, 0, 0, 0, SDLK_KP_DIVIDE, 0, SDLK_PRINT,
|
||||
SDLK_RALT, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x4*
|
||||
0, 0, 0, 0, 0, 0, 0, SDLK_HOME,
|
||||
SDLK_UP, SDLK_PAGEUP, 0, SDLK_LEFT, 0, SDLK_RIGHT, 0, SDLK_END,
|
||||
// 0x5*
|
||||
SDLK_DOWN, SDLK_PAGEDOWN, SDLK_INSERT, SDLK_DELETE, 0, 0, 0, 0,
|
||||
0, 0, 0, SDLK_LSUPER, SDLK_RSUPER, SDLK_MENU, 0, 0,
|
||||
// 0x6*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 0x7*
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
extern void KolibriOS_CheckMouseMode(_THIS);
|
||||
void MenuetOS_PumpEvents(_THIS)
|
||||
{
|
||||
int i;
|
||||
SDL_keysym key;
|
||||
static int ext_code=0;
|
||||
static __u8 old_mode=0;
|
||||
for (;;) {
|
||||
i=__menuet__check_for_event();
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
MenuetOS_SDL_RepaintWnd();
|
||||
break;
|
||||
case 2:
|
||||
key.scancode = __menuet__getkey();
|
||||
if (key.scancode == 0xE0 || key.scancode == 0xE1)
|
||||
{ext_code=key.scancode;break;}
|
||||
if (ext_code == 0xE1 && (key.scancode & 0x7F) == 0x1D) break;
|
||||
if (ext_code == 0xE1 && key.scancode == 0xC5) {ext_code=0;break;}
|
||||
key.mod = GetModState();
|
||||
if (ext_code == 0xE1) key.mod &= ~KMOD_CTRL;
|
||||
if (!(key.scancode&0x80))
|
||||
old_mode = key.mod;
|
||||
SDL_SetModState(key.mod);
|
||||
int code = (key.scancode & 0x80) ? SDL_RELEASED : SDL_PRESSED;
|
||||
key.scancode &= 0x7F;
|
||||
// key.sym = scan2ascii(key.scancode,key.mod);
|
||||
if (ext_code == 0xE1 && key.scancode == 0x45)
|
||||
key.sym = SDLK_PAUSE;
|
||||
else if (ext_code == 0xE0)
|
||||
key.sym = sdlkeys_e0[key.scancode];
|
||||
else if (old_mode & KMOD_SHIFT)
|
||||
key.sym = sdlkeys_shift[key.scancode];
|
||||
else
|
||||
key.sym = sdlkeys[key.scancode];
|
||||
ext_code = 0;
|
||||
if (!key.sym) break;
|
||||
SDL_PrivateKeyboard(code,&key);
|
||||
break;
|
||||
case 3:
|
||||
if(__menuet__get_button_id()==1) exit(0);
|
||||
break;
|
||||
case 6: {
|
||||
int __tmp,mx,my;
|
||||
static int oldmousestate = 0;
|
||||
__asm__("int $0x40":"=a"(__tmp):"a"(37),"b"(1));
|
||||
mx=(__tmp>>16);
|
||||
my=(__tmp&0xffff);
|
||||
if(mx>=0 && mx<this->hidden->win_size_x &&
|
||||
my>=0 && my<this->hidden->win_size_y || this->input_grab != SDL_GRAB_OFF)
|
||||
{
|
||||
if (this->input_grab != SDL_GRAB_OFF)
|
||||
{
|
||||
int dx=mx-this->hidden->win_size_x/2;
|
||||
int dy=my-this->hidden->win_size_y/2;
|
||||
if (dx||dy)
|
||||
{
|
||||
SDL_PrivateMouseMotion(0,1,dx,dy);
|
||||
KolibriOS_CheckMouseMode(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
SDL_PrivateMouseMotion(0,0,mx,my);
|
||||
__asm__("int $0x40":"=a"(__tmp):"a"(37),"b"(2));
|
||||
if ((__tmp^oldmousestate)&1) {
|
||||
if(__tmp&1)
|
||||
{
|
||||
SDL_PrivateMouseButton(SDL_PRESSED,SDL_BUTTON_LMASK,0,0);
|
||||
} else {
|
||||
SDL_PrivateMouseButton(SDL_RELEASED,SDL_BUTTON_LMASK,0,0);
|
||||
} }
|
||||
if ((__tmp^oldmousestate)&2) {
|
||||
if(__tmp&2)
|
||||
{
|
||||
SDL_PrivateMouseButton(SDL_PRESSED,SDL_BUTTON_RMASK,0,0);
|
||||
} else {
|
||||
SDL_PrivateMouseButton(SDL_RELEASED,SDL_BUTTON_RMASK,0,0);
|
||||
} }
|
||||
oldmousestate = __tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
348
contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.c
Executable file
348
contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.c
Executable file
@ -0,0 +1,348 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <menuet/os.h>
|
||||
#include "SDL.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_menuetvideo.h"
|
||||
#include <string.h>
|
||||
|
||||
static SDL_VideoDevice * vm_suf=NULL;
|
||||
static int was_initialized=0;
|
||||
|
||||
static int has_null_cursor=0;
|
||||
static int null_cursor;
|
||||
|
||||
inline int get_skinh(void)
|
||||
{
|
||||
int res;
|
||||
__asm__ ("int $0x40" : "=a"(res) : "a"(48),"b"(4));
|
||||
return res;
|
||||
}
|
||||
|
||||
//#define KEEP_OBSOLETE_STYLE3
|
||||
|
||||
#ifdef KEEP_OBSOLETE_STYLE3
|
||||
static int IsStyle4Available=0;
|
||||
#endif
|
||||
|
||||
void MenuetOS_SDL_RepaintWnd(void)
|
||||
{
|
||||
__menuet__window_redraw(1);
|
||||
__menuet__define_window(1,1,vm_suf->hidden->win_size_x+9,vm_suf->hidden->win_size_y+get_skinh()+4,
|
||||
#ifdef KEEP_OBSOLETE_STYLE3
|
||||
IsStyle4Available?0x34000000:0x33000000
|
||||
#else
|
||||
0x34000000
|
||||
#endif
|
||||
,0,(int)vm_suf->hidden->__title);
|
||||
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
if(vm_suf && vm_suf->hidden->__video_buffer)
|
||||
__menuet__putimage(0,0,
|
||||
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y,
|
||||
vm_suf->hidden->__video_buffer);
|
||||
__menuet__window_redraw(2);
|
||||
}
|
||||
|
||||
static int MenuetOS_AllocHWSurface(_THIS,SDL_Surface * surface)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void MenuetOS_FreeHWSurface(_THIS,SDL_Surface * surface)
|
||||
{
|
||||
}
|
||||
|
||||
static int MenuetOS_LockHWSurface(_THIS,SDL_Surface * surface)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void MenuetOS_UnlockHWSurface(_THIS,SDL_Surface * surface)
|
||||
{
|
||||
}
|
||||
|
||||
static void MenuetOS_DirectUpdate(_THIS,int numrects,SDL_Rect * rects)
|
||||
{
|
||||
if(numrects)
|
||||
{
|
||||
__menuet__putimage(0,0,
|
||||
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y,
|
||||
this->hidden->__video_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
int MenuetOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MenuetOS_VideoQuit(_THIS)
|
||||
{
|
||||
if (has_null_cursor)
|
||||
{
|
||||
__asm__("int $0x40"::"a"(37),"b"(6),"c"(null_cursor));
|
||||
has_null_cursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuetOS_FinalQuit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MenuetOS_SetCaption(_THIS,const char * title,const char * icon)
|
||||
{
|
||||
this->hidden->__title=(char *)title;
|
||||
if(was_initialized) __asm__("int $0x40"::"a"(71),"b"(1),"c"(title));
|
||||
}
|
||||
|
||||
SDL_Surface * MenuetOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
|
||||
{
|
||||
int ly;
|
||||
char * lx;
|
||||
if(bpp!=24) return NULL;
|
||||
current->flags=flags;
|
||||
current->w=width;
|
||||
current->h=height;
|
||||
current->pitch=width*(bpp>>3);
|
||||
|
||||
char info[100];
|
||||
sprintf(info, "width = %d, height = %d, pitch = %d, bpp = %d\n", current->w, current->h, current->pitch, bpp);
|
||||
|
||||
void debug_board_write_byte(const char ch){
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:
|
||||
:"a"(63), "b"(1), "c"(ch));
|
||||
}
|
||||
|
||||
void debug_board_write_str(const char* str){
|
||||
while(*str)
|
||||
debug_board_write_byte(*str++);
|
||||
}
|
||||
|
||||
debug_board_write_str(info);
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
current->pixels=this->hidden->__video_buffer=realloc(this->hidden->__video_buffer,
|
||||
current->pitch*current->h);
|
||||
this->hidden->__lines=(unsigned char **)realloc(this->hidden->__lines,
|
||||
sizeof(unsigned char *)*current->h);
|
||||
|
||||
for(ly=0,lx=current->pixels;ly<current->h;ly++,lx+=current->pitch)
|
||||
this->hidden->__lines[ly]=lx;
|
||||
|
||||
this->UpdateRects=MenuetOS_DirectUpdate;
|
||||
this->hidden->win_size_x=width;
|
||||
this->hidden->win_size_y=height;
|
||||
vm_suf=this;
|
||||
if (was_initialized)
|
||||
{
|
||||
unsigned newheight = height+get_skinh()+4;
|
||||
unsigned newwidth = width+9;
|
||||
__asm__("int $0x40"::"a"(67),"b"(-1),"c"(-1),"d"(newwidth),"S"(newheight));
|
||||
}
|
||||
else
|
||||
{
|
||||
__menuet__set_bitfield_for_wanted_events(0x27);
|
||||
was_initialized=1;
|
||||
MenuetOS_SDL_RepaintWnd();
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/*static SDL_Rect video_mode[4];
|
||||
static SDL_Rect * SDL_modelist[4]={NULL,NULL,NULL,NULL};*/
|
||||
|
||||
static SDL_Rect ** MenuetOS_ListModes(_THIS,SDL_PixelFormat * fmt,Uint32 flags)
|
||||
{
|
||||
// return (&SDL_modelist[((fmt->BitsPerPixel+7)/8)-1]);
|
||||
if (fmt->BitsPerPixel==24)
|
||||
return (SDL_Rect**)-1;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int MenuetOS_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void MenuetOS_DeleteDevice(_THIS)
|
||||
{
|
||||
// free(this->hidden->__video_buffer); // it will be freed as current->pixels
|
||||
free(this->hidden->__lines);
|
||||
}
|
||||
|
||||
static int MenuetOS_VideoInit(_THIS,SDL_PixelFormat * vformat)
|
||||
{
|
||||
#ifdef KEEP_OBSOLETE_STYLE3
|
||||
char buf[16];
|
||||
__asm__("int $0x40"::"a"(18),"b"(13),"c"(buf));
|
||||
if (buf[5]=='K' && buf[6]=='o' && buf[7]=='l' && buf[8]=='i')
|
||||
/* kernels up to 0.7.0.0 do not support style 4 */;
|
||||
else if (*(unsigned*)(buf+5) >= 549)
|
||||
/* window style 4 was introduced in revision 549 */
|
||||
IsStyle4Available = 1;
|
||||
#endif
|
||||
vformat->BitsPerPixel=24;
|
||||
vformat->BytesPerPixel=3;
|
||||
this->info.wm_available=1;
|
||||
this->info.hw_available=0;
|
||||
this->info.video_mem=0x200000;
|
||||
/* video_mode[3].x=0;
|
||||
video_mode[3].y=0;
|
||||
video_mode[3].w=320;
|
||||
video_mode[3].h=200;
|
||||
video_mode[2].x=0;
|
||||
video_mode[2].y=0;
|
||||
video_mode[2].w=640;
|
||||
video_mode[2].h=400;
|
||||
video_mode[1].x=0;
|
||||
video_mode[1].y=0;
|
||||
video_mode[1].w=320;
|
||||
video_mode[1].h=240;
|
||||
video_mode[0].x=0;
|
||||
video_mode[0].y=0;
|
||||
video_mode[0].w=640;
|
||||
video_mode[0].h=480;
|
||||
SDL_modelist[2]=video_mode+0;*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int MenuetOS_FlipHWSurface(_THIS,SDL_Surface * surface)
|
||||
{
|
||||
__menuet__putimage(0,0,surface->w,surface->h,
|
||||
surface->pixels);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WMcursor* KolibriOS_CreateWMCursor(_THIS,
|
||||
Uint8* data, Uint8* mask, int w, int h, int hot_x, int hot_y)
|
||||
{
|
||||
int i,j;
|
||||
Uint32* cursor;
|
||||
WMcursor* res;
|
||||
|
||||
if (w>32 || h>32) return NULL;
|
||||
if (w%8 || h%8) return NULL;
|
||||
cursor = (Uint32*)malloc(32*32*4);
|
||||
if (!cursor) return NULL;
|
||||
for (i=0;i<32;i++)
|
||||
for (j=0;j<32;j++)
|
||||
{
|
||||
if (i>=h || j>=w)
|
||||
{
|
||||
cursor[i*32+j] = 0x00000000;
|
||||
continue;
|
||||
}
|
||||
if (mask[i*w/8+j/8] & (0x80>>(j&7)))
|
||||
cursor[i*32+j] = (data[i*w/8+j/8] & (0x80>>(j&7)))?0xFF000000:0xFFFFFFFF;
|
||||
else
|
||||
cursor[i*32+j] = 0x00000000;
|
||||
}
|
||||
__asm__ ("int $0x40" : "=a"(res) : "a"(37),"b"(4),
|
||||
"c"(cursor),"d"((hot_x<<24)+(hot_y<<16)+2));
|
||||
free(cursor);
|
||||
return res;
|
||||
}
|
||||
int KolibriOS_ShowWMCursor(_THIS,WMcursor*cursor)
|
||||
{
|
||||
if (!cursor)
|
||||
{
|
||||
if (!has_null_cursor)
|
||||
{
|
||||
unsigned* u = malloc(32*32*4);
|
||||
if (!u) return 1;
|
||||
memset(u,0,32*32*4);
|
||||
__asm__("int $0x40":"=a"(null_cursor):
|
||||
"a"(37),"b"(4),"c"(u),"d"(2));
|
||||
free(u);
|
||||
has_null_cursor = 1;
|
||||
}
|
||||
cursor = (WMcursor*)null_cursor;
|
||||
}
|
||||
__asm__("int $0x40" : : "a"(37),"b"(5),"c"(cursor));
|
||||
return 1;
|
||||
}
|
||||
void KolibriOS_FreeWMCursor(_THIS,WMcursor*cursor)
|
||||
{
|
||||
__asm__("int $0x40" : : "a"(37),"b"(6),"c"(cursor));
|
||||
}
|
||||
void KolibriOS_CheckMouseMode(_THIS)
|
||||
{
|
||||
if (this->input_grab == SDL_GRAB_OFF)
|
||||
return;
|
||||
struct process_table_entry buf;
|
||||
int res;
|
||||
__asm__ volatile("int $0x40" : "=a"(res): "a"(9), "b"(&buf), "c"(-1));
|
||||
if (res == buf.pos_in_windowing_stack)
|
||||
{
|
||||
int x = buf.winx_start + buf.client_left + this->hidden->win_size_x/2;
|
||||
int y = buf.winy_start + buf.client_top + this->hidden->win_size_y/2;
|
||||
__asm__("int $0x40" : : "a"(18),"b"(19),"c"(4),
|
||||
"d"(x*65536+y));
|
||||
}
|
||||
}
|
||||
|
||||
char def_title[] = "KolibriOS SDL App";
|
||||
static SDL_VideoDevice * MenuetOS_CreateDevice(int indx)
|
||||
{
|
||||
SDL_VideoDevice * dev;
|
||||
dev=(SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
|
||||
if(dev)
|
||||
{
|
||||
memset(dev,0,(sizeof *dev));
|
||||
dev->hidden = (struct SDL_PrivateVideoData *)malloc((sizeof *dev->hidden));
|
||||
}
|
||||
if((dev==NULL) || (dev->hidden==NULL))
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
if(dev)
|
||||
{
|
||||
free(dev);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
memset(dev->hidden,0,(sizeof *dev->hidden));
|
||||
dev->hidden->__title = def_title;
|
||||
dev->VideoInit=MenuetOS_VideoInit;
|
||||
dev->ListModes=MenuetOS_ListModes;
|
||||
dev->SetVideoMode=MenuetOS_SetVideoMode;
|
||||
dev->SetColors=MenuetOS_SetColors;
|
||||
dev->UpdateRects=NULL;
|
||||
dev->VideoQuit=MenuetOS_VideoQuit;
|
||||
dev->AllocHWSurface=MenuetOS_AllocHWSurface;
|
||||
dev->CheckHWBlit=NULL;
|
||||
dev->FillHWRect=NULL;
|
||||
dev->SetHWColorKey=NULL;
|
||||
dev->SetHWAlpha=NULL;
|
||||
dev->LockHWSurface=MenuetOS_LockHWSurface;
|
||||
dev->UnlockHWSurface=MenuetOS_UnlockHWSurface;
|
||||
dev->FlipHWSurface=MenuetOS_FlipHWSurface;
|
||||
dev->FreeHWSurface=MenuetOS_FreeHWSurface;
|
||||
dev->SetCaption=MenuetOS_SetCaption;
|
||||
dev->SetIcon=NULL;
|
||||
dev->IconifyWindow=NULL;
|
||||
dev->GrabInput=NULL;
|
||||
dev->GetWMInfo=NULL;
|
||||
dev->InitOSKeymap=MenuetOS_InitOSKeymap;
|
||||
dev->PumpEvents=MenuetOS_PumpEvents;
|
||||
dev->free=MenuetOS_DeleteDevice;
|
||||
dev->CreateWMCursor = KolibriOS_CreateWMCursor;
|
||||
dev->FreeWMCursor = KolibriOS_FreeWMCursor;
|
||||
dev->ShowWMCursor = KolibriOS_ShowWMCursor;
|
||||
dev->CheckMouseMode = KolibriOS_CheckMouseMode;
|
||||
return dev;
|
||||
}
|
||||
|
||||
VideoBootStrap mosvideo_bootstrab={
|
||||
"menuetos","MenuetOS Device Driver",
|
||||
MenuetOS_Available,MenuetOS_CreateDevice,
|
||||
};
|
20
contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.h
Executable file
20
contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.h
Executable file
@ -0,0 +1,20 @@
|
||||
#ifndef _SDL_menuetvideo_h
|
||||
#define _SDL_menuetvideo_h
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
|
||||
#define _THIS SDL_VideoDevice *this
|
||||
|
||||
struct SDL_PrivateVideoData {
|
||||
unsigned char * __video_buffer;
|
||||
char * __title;
|
||||
int win_size_x,win_size_y;
|
||||
int vx_ofs,vy_ofs;
|
||||
unsigned char** __lines;
|
||||
};
|
||||
|
||||
void MenuetOS_InitOSKeymap(_THIS);
|
||||
void MenuetOS_PumpEvents(_THIS);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user