diff --git a/.project b/.project
new file mode 100644
index 0000000..164d965
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ Scratch
+
+
+
+
+
+
+
+
diff --git a/aibot/Makefile b/aibot/Makefile
new file mode 100644
index 0000000..8a745c1
--- /dev/null
+++ b/aibot/Makefile
@@ -0,0 +1,11 @@
+all: aibot mods
+
+aibot: src
+ (cd src;make)
+
+mods: modules
+ (cd modules;make)
+
+clean:
+ (cd src;make clean)
+ (cd modules;make clean)
diff --git a/aibot/include/aibot.h b/aibot/include/aibot.h
new file mode 100644
index 0000000..a717c77
--- /dev/null
+++ b/aibot/include/aibot.h
@@ -0,0 +1,25 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+char *GetField(char *newline,int);
+
+#define VERSION "v0.1"
diff --git a/aibot/include/irc.h b/aibot/include/irc.h
new file mode 100644
index 0000000..3de256e
--- /dev/null
+++ b/aibot/include/irc.h
@@ -0,0 +1,8 @@
+typedef struct ircStruct {
+ int socket;
+ char command[256];
+ char data[1024];
+ } IRCNode;
+
+
+typedef struct ircStruct *IRC;
diff --git a/aibot/include/socket.h b/aibot/include/socket.h
new file mode 100644
index 0000000..dbf0b42
--- /dev/null
+++ b/aibot/include/socket.h
@@ -0,0 +1,11 @@
+#include
+#include
+#include
+#include
+
+#define MAXBUFLENGTH 4096
+#define BUFFER_SIZE 1024
+
+int Connect(char *,int);
+int ReadSock(int,char *);
+int SendSock(int,const char *fmt, ...);
diff --git a/aibot/modules/Makefile b/aibot/modules/Makefile
new file mode 100644
index 0000000..80663dc
--- /dev/null
+++ b/aibot/modules/Makefile
@@ -0,0 +1,12 @@
+CC=gcc
+CFLAGS=-I./include
+
+all: example
+
+example: example.c
+ $(CC) -fPIC -c example.c
+ ld -Bshareable -o example.so example.o
+
+clean:
+ rm -fr *.so
+ rm -fr *.o
diff --git a/aibot/modules/example.c b/aibot/modules/example.c
new file mode 100644
index 0000000..5e57756
--- /dev/null
+++ b/aibot/modules/example.c
@@ -0,0 +1,7 @@
+#include
+
+char *Description(char *tmp) {
+ char description[512];
+ sprintf(description,"This is an example modules and this was passwd to it: [%s]",tmp);
+ return(description);
+ }
diff --git a/aibot/src/Makefile b/aibot/src/Makefile
new file mode 100644
index 0000000..c7f76aa
--- /dev/null
+++ b/aibot/src/Makefile
@@ -0,0 +1,22 @@
+CC=gcc
+CFLAGS=-I../include
+
+MODS=main.o socket.o irc.o
+
+all: aibot
+
+aibot: $(MODS)
+ $(CC) -o ../bot $(MODS)
+
+main.o: main.c
+ $(CC) $(CFLAGS) -c main.c
+
+socket.o: socket.c
+ $(CC) $(CFLAGS) -c socket.c
+
+irc.o: irc.c
+ $(CC) $(CFLAGS) -c irc.c
+clean:
+ rm -f *.o
+ rm -f ../*core
+ rm -f ../bot
diff --git a/aibot/src/main.c b/aibot/src/main.c
new file mode 100644
index 0000000..fa38978
--- /dev/null
+++ b/aibot/src/main.c
@@ -0,0 +1,45 @@
+#include "aibot.h"
+#include "socket.h"
+#include "irc.h"
+
+int main(int argc,char *argv[]) {
+ int s;
+ char *output;
+ IRC irc;
+ irc = (IRC) malloc (sizeof(IRCNode));
+ printf("Starting AI Bot\n");
+ irc->socket = Connect("irc.undernet.org",6667);
+ printf("Test: [%i]\n",s);
+ SendSock(irc->socket,"NICK PenisEnvy\nUSER PenisEnvy 0 0 UbieDubie\n");
+ SendSock(irc->socket,"JOIN #UbixOS\n");
+ while (1) {
+ if (ReadSock(irc->socket,output)) {
+ printf("%s\n",output);
+ IRCParse(output,irc);
+ if (!strcasecmp(irc->command,"PRIVMSG")) {
+ IRCPrivmsg(irc);
+ }
+ }
+ }
+ return(0);
+ }
+
+char *GetField(char *newline,int ch) {
+ static char *line = NULL;
+ char *end, *field;
+
+ if (newline)
+ line = newline;
+ if (line == NULL)
+ return(NULL);
+ field = line;
+ if ((end = (char *)index(line,ch)) == NULL) {
+ line = NULL;
+ if ((end = (char *)index(field,'\n')) == NULL)
+ end = field + strlen(field);
+ }
+ else
+ line = end + 1; *end = '\0';
+
+ return(field);
+ }
diff --git a/aibot/src/socket.c b/aibot/src/socket.c
new file mode 100644
index 0000000..cb390f4
--- /dev/null
+++ b/aibot/src/socket.c
@@ -0,0 +1,76 @@
+#include "aibot.h"
+#include "socket.h"
+
+int Connect(char *server,int port) {
+ char buf[1024];
+ struct hostent *hp;
+ struct sockaddr_in sin;
+ int s;
+ if ((hp=gethostbyname(server))==NULL) {
+ printf("conn() -- ERROR: Unknown hostname (%s)\n", server);
+ exit(1);
+ }
+ if ((s=socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ printf("conn() -- ERROR: Client: Socket\n");
+ }
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons(port);
+ bcopy(hp->h_addr, &sin.sin_addr, hp->h_length);
+ if (connect(s,(struct sockaddr *)&sin, sizeof(sin)) < 0) {
+ printf("conn() -- ERROR: Client: Connect\n");
+ exit(1);
+ }
+ return s;
+ }
+
+int SendSock(int socket, const char *fmt, ...) {
+ char *string;
+ va_list args;
+ string = malloc(MAXBUFLENGTH);
+ va_start(args, fmt);
+ vsnprintf(string, MAXBUFLENGTH, fmt, args);
+ va_end(args);
+ send(socket, string, strlen(string), 0);
+ return(strlen(string));
+}
+
+int ReadSock(int s,char *buf) {
+ char inc;
+ int bufnum, n;
+ fd_set fds;
+ struct timeval wait;
+ u_long btx = 0, brx = 0;
+
+ bufnum = 0;
+
+ if (s==-1)
+ {
+ return(-1);
+ }
+ wait.tv_sec = 0L;
+ wait.tv_usec = 2500L;
+ FD_ZERO(&fds);
+ FD_SET(s, &fds);
+ if (select(s+1, &fds, NULL, 0, &wait) > 0)
+ {
+ do
+ {
+ n = read(s, &inc, 1);
+ if (n == 0)
+ {
+ return -1;
+ }
+ if (bufnum < BUFFER_SIZE - 1 )
+ {
+ buf[bufnum++] = inc;
+ }
+ }
+ while (inc != '\n');
+ {
+ buf[bufnum] = '\0';
+ }
+ brx += bufnum;
+ return bufnum;
+ }
+ return 0;
+}
diff --git a/lockwasher/Makefile b/lockwasher/Makefile
new file mode 100644
index 0000000..8ac14b2
--- /dev/null
+++ b/lockwasher/Makefile
@@ -0,0 +1,36 @@
+# $Id: Makefile,v 1.2 2003/04/02 18:56:04 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+all: libc views libcpp depend bin kernel tools
+
+libc: src
+ (cd src/lib/libc;make)
+
+views: src
+ (cd src/lib/views;make)
+
+libcpp: src
+ (cd src/lib/libcpp;make)
+
+depend: src
+ (cd src/lib/ubix;make)
+
+bin: src
+ (cd src/bin;make)
+
+kernel: src
+ (cd src/sys;make)
+
+tools: src
+ (cd src/tools;make)
+
+install:
+ (cd src/sys;make install)
+
+clean:
+ (cd src/sys;make clean)
+ (cd src/lib/libc;make clean)
+ (cd src/bin;make clean)
+ (cd src/lib/ubix;make clean)
+ (cd src/lib/views;make clean)
+ (cd src/lib/libcpp;make clean)
diff --git a/lockwasher/README b/lockwasher/README
new file mode 100644
index 0000000..40ac8fd
--- /dev/null
+++ b/lockwasher/README
@@ -0,0 +1 @@
+This is the top level of the UbixOS CVS repository. Please see the file
LICENSE for copyright information.
The source tree map is as follows:
doc - contains most UbixOS documentation.
examples - example files
help - CLI Help Files
developer - developers handbook
FAQ - UbixOS FAQ
manual - user manual
src - contains all source files for UnixOS
bin
grayspace-misc(temporary)
lib
sys
tools
For information on source tree syncing please refer to:
\ No newline at end of file
diff --git a/lockwasher/UbixOS-Team b/lockwasher/UbixOS-Team
new file mode 100644
index 0000000..4a69c4d
--- /dev/null
+++ b/lockwasher/UbixOS-Team
@@ -0,0 +1,7 @@
+$Id: UbixOS-Team,v 1.2 2003/03/13 16:19:09 apwillia Exp $
+
+
+Christopher Olsen AKA Ubu Project Founder
+Patrick Williams AKA Patrick_W Design Architect
+Mark Iuzzolino AKA TCA Lead Gui Developer
+Jeff Leveille AKA grayspace Lead Multimedia Developer
diff --git a/lockwasher/lockwasher.kdevprj b/lockwasher/lockwasher.kdevprj
new file mode 100644
index 0000000..df1d368
--- /dev/null
+++ b/lockwasher/lockwasher.kdevprj
@@ -0,0 +1,1910 @@
+[./Authors]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./LICENSE]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./Makefile.am]
+files=./Authors,./LICENSE,./README,./UbixOS-Team,./lockwasher.kdevprj,
+sub_dirs=docs,src,
+type=normal
+
+[./README]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./UbixOS-Team]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./lockwasher.kdevprj]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[Config for BinMakefileAm]
+addcxxflags=
+bin_program=lockwasher
+cflags=
+cppflags=
+cxxflags=\s-O0
+ldadd=
+ldflags=\s
+libtool_dir=
+path_to_bin_program=.
+
+[General]
+AMChanged=false
+author=reddawg
+configure_args=\s--build=i386-linux --host=i386-linux --target=i386-linux\s
+dir_where_make_will_be_called=./
+email=reddawg@Laptop.DomainAtlantic.Com
+kdevprj_version=1.3
+lfv_open_groups=
+make_options=\s-j1 all install clean\s
+makefiles=./Makefile.am,docs/Makefile.am,docs/arch/Makefile.am,src/Makefile.am,src/bin/Makefile.am,src/bin/cat/Makefile.am,src/bin/ls/Makefile.am,src/bin/init/Makefile.am,src/bin/ld-dyn/Makefile.am,src/bin/login/Makefile.am,src/bin/pwd/Makefile.am,src/bin/shell/Makefile.am,src/bin/test/Makefile.am,src/grayspace-misc/Makefile.am,src/lib/Makefile.am,src/lib/libc/Makefile.am,src/lib/libc/generic/Makefile.am,src/lib/libc/include/Makefile.am,src/lib/libc/include/sys/Makefile.am,src/lib/libc/stdio/Makefile.am,src/lib/libc/stdlib/Makefile.am,src/lib/libc/string/Makefile.am,src/lib/libc/sys/Makefile.am,src/lib/ubix/Makefile.am,src/sys/Makefile.am,src/sys/boot/Makefile.am,src/sys/boot/boot2/Makefile.am,src/sys/boot/btx/Makefile.am,src/sys/boot/btx/btx/Makefile.am,src/sys/boot/btx/lib/Makefile.am,src/sys/boot/btx/btxldr/Makefile.am,src/sys/compile/Makefile.am,src/sys/deviceman/Makefile.am,src/sys/drivers/Makefile.am,src/sys/graphics/Makefile.am,src/sys/include/Makefile.am,src/sys/include/deviceman/Makefile.am,src/sys/include/drivers/Makefile.am,src/sys/include/misc/Makefile.am,src/sys/include/ubixfs/Makefile.am,src/sys/include/ubixos/Makefile.am,src/sys/include/version/Makefile.am,src/sys/include/vmm/Makefile.am,src/sys/init/Makefile.am,src/sys/kernel/Makefile.am,src/sys/misc/Makefile.am,src/sys/ubixfs/Makefile.am,src/sys/vmm/Makefile.am,src/tools/Makefile.am,Makefile.am,src/sys/sys/Makefile.am,src/sys/lib/Makefile.am,src/sys/include/lib/Makefile.am,src/sys/pci/Makefile.am,src/sys/include/sde/Makefile.am,src/sys/sde/Makefile.am,src/sys/isa/Makefile.am,src/sys/include/pci/Makefile.am,src/sys/ld/Makefile.am,src/sys/include/ld/Makefile.am
+modifyMakefiles=true
+project_name=lockwasher
+project_type=normal_empty
+short_info=
+sub_dir=
+version=
+version_control=CVS
+workspace=1
+
+[LFV Groups]
+GNU=AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,NEWS,
+Headers=*.h,*.hxx,*.hpp,*.H,
+Others=*,
+Sources=*.cpp,*.c,*.cc,*.C,*.cxx,*.ec,*.ecpp,*.lxx,*.l++,*.ll,*.l,
+Translations=*.ts,*.po,
+User Interface=*.ui,*.kdevdlg,*.rc,
+groups=Headers,Sources,GNU,Translations,User Interface,Others
+
+[LICENSE]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[Makefile.am]
+files=LICENSE,Makefile,README,UbixOS-Team,snapshot.txt
+sub_dirs=src
+type=normal
+
+[README]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[UbixOS-Team]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[docs/FAQ]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[docs/Makefile.am]
+files=docs/FAQ,docs/mailing-lists,
+sub_dirs=arch,
+type=normal
+
+[docs/arch/Makefile.am]
+files=docs/arch/scheduler,
+sub_dirs=
+type=normal
+
+[docs/arch/scheduler]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[docs/mailing-lists]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[snapshot.txt]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/Makefile.am]
+sub_dirs=bin,grayspace-misc,lib,sys,tools,
+type=normal
+
+[src/bin/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/Makefile.am]
+files=src/bin/Makefile
+sub_dirs=cat,ls,init,ld-dyn,login,pwd,shell,test,
+type=normal
+
+[src/bin/cat/Makefile.am]
+files=src/bin/cat/cat,src/bin/cat/main.c,
+sub_dirs=
+type=normal
+
+[src/bin/cat/cat]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/cat/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/init/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/init/Makefile.am]
+files=src/bin/init/init,src/bin/init/main.c,src/bin/init/Makefile
+sub_dirs=
+type=normal
+
+[src/bin/init/init]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/init/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/ld-dyn/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/ld-dyn/Makefile.am]
+files=src/bin/ld-dyn/ld-dyn,src/bin/ld-dyn/main.c,src/bin/ld-dyn/Makefile
+sub_dirs=
+type=normal
+
+[src/bin/ld-dyn/ld-dyn]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/ld-dyn/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/login/Makefile.am]
+files=src/bin/login/login,src/bin/login/main.c,
+sub_dirs=
+type=normal
+
+[src/bin/login/login]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/login/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/ls/Makefile.am]
+files=src/bin/ls/ls,src/bin/ls/main.c,
+sub_dirs=
+type=normal
+
+[src/bin/ls/ls]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/ls/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/pwd/Makefile.am]
+files=src/bin/pwd/main.c,src/bin/pwd/pwd,
+sub_dirs=
+type=normal
+
+[src/bin/pwd/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/pwd/pwd]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/shell/Makefile.am]
+files=src/bin/shell/commands.c,src/bin/shell/error.c,src/bin/shell/exec.c,src/bin/shell/input.c,src/bin/shell/main.c,src/bin/shell/shell,src/bin/shell/shell.h,
+sub_dirs=
+type=normal
+
+[src/bin/shell/commands.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/shell/error.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/shell/exec.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/shell/input.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/shell/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/shell/shell]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/shell/shell.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/bin/test/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/bin/test/Makefile.am]
+files=src/bin/test/main.c,src/bin/test/test,src/bin/test/Makefile
+sub_dirs=
+type=normal
+
+[src/bin/test/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/bin/test/test]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/grayspace-misc/Makefile.am]
+files=src/grayspace-misc/gsdefines.h,
+sub_dirs=
+type=normal
+
+[src/grayspace-misc/gsdefines.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/Makefile.am]
+sub_dirs=libc,ubix,
+type=normal
+
+[src/lib/libc/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/lib/libc/Makefile.am]
+files=src/lib/libc/Makefile
+sub_dirs=generic,include,stdio,stdlib,string,sys,
+type=normal
+
+[src/lib/libc/generic/Makefile.am]
+files=src/lib/libc/generic/getcwd.c,
+sub_dirs=
+type=normal
+
+[src/lib/libc/generic/getcwd.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/include/Makefile.am]
+files=src/lib/libc/include/stdarg.h,src/lib/libc/include/stdio.h,src/lib/libc/include/stdlib.h,src/lib/libc/include/string.h,src/lib/libc/include/unistd.h,
+sub_dirs=sys,
+type=normal
+
+[src/lib/libc/include/stdarg.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/include/stdio.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/include/stdlib.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/include/string.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/include/sys/Makefile.am]
+files=src/lib/libc/include/sys/types.h,src/lib/libc/include/sys/sys.h,
+sub_dirs=
+type=normal
+
+[src/lib/libc/include/sys/sys.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/include/sys/types.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/include/unistd.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/lib/libc/stdio/Makefile.am]
+files=src/lib/libc/stdio/fclose.c,src/lib/libc/stdio/fd.c,src/lib/libc/stdio/fgetc.c,src/lib/libc/stdio/fopen.c,src/lib/libc/stdio/fprintf.c,src/lib/libc/stdio/fread.c,src/lib/libc/stdio/fwrite.c,src/lib/libc/stdio/gets.c,src/lib/libc/stdio/printf.c,src/lib/libc/stdio/sprintf.c,src/lib/libc/stdio/vfprintf.c,src/lib/libc/stdio/vsprintf.c,
+sub_dirs=
+type=normal
+
+[src/lib/libc/stdio/fclose.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/fd.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/fgetc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/fopen.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/fprintf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/fread.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/fwrite.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/gets.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/printf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/sprintf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/vfprintf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdio/vsprintf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdlib/Makefile.am]
+files=src/lib/libc/stdlib/exit.c,src/lib/libc/stdlib/malloc.c,
+sub_dirs=
+type=normal
+
+[src/lib/libc/stdlib/exit.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/stdlib/malloc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/string/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/lib/libc/string/Makefile.am]
+files=src/lib/libc/string/memcmp.c,src/lib/libc/string/memcpy.c,src/lib/libc/string/memset.c,src/lib/libc/string/strlen.c,src/lib/libc/string/strtok.c,src/lib/libc/string/Makefile
+sub_dirs=
+type=static_library
+
+[src/lib/libc/string/memcmp.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/string/memcpy.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/string/memset.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/string/strlen.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/string/strtok.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/Makefile.am]
+files=src/lib/libc/sys/exec.c,src/lib/libc/sys/fork.c,src/lib/libc/sys/getpage.c,src/lib/libc/sys/getpid.c,src/lib/libc/sys/pidstatus.c,src/lib/libc/sys/setuid.c,src/lib/libc/sys/setgid.c,src/lib/libc/sys/getuid.c,src/lib/libc/sys/getgid.c,src/lib/libc/sys/getdrives.c
+sub_dirs=
+type=static_library
+
+[src/lib/libc/sys/exec.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/fork.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/getdrives.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/getgid.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/getpage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/getpid.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/getuid.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/pidstatus.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/setgid.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/libc/sys/setuid.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/lib/ubix/Makefile.am]
+files=src/lib/ubix/startup.c,
+sub_dirs=
+type=normal
+
+[src/lib/ubix/startup.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/Makefile.am]
+files=src/sys/Makefile
+sub_dirs=boot,compile,deviceman,drivers,graphics,include,init,kernel,misc,ubixfs,vmm,sys,lib,pci,sde,isa,ld
+type=normal
+
+[src/sys/boot/Makefile.am]
+sub_dirs=boot2,btx,
+type=normal
+
+[src/sys/boot/boot2/Makefile.am]
+files=src/sys/boot/boot2/boot1.s,src/sys/boot/boot2/boot2.c,src/sys/boot/boot2/lib.h,src/sys/boot/boot2/sio.s,src/sys/boot/boot2/test.c,src/sys/boot/boot2/ubixfs.h,
+sub_dirs=
+type=normal
+
+[src/sys/boot/boot2/boot1.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/boot/boot2/boot2.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/boot/boot2/lib.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/boot/boot2/sio.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/boot/boot2/test.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/boot/boot2/ubixfs.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/boot/btx/Makefile.am]
+sub_dirs=btx,lib,btxldr,
+type=normal
+
+[src/sys/boot/btx/btx/Makefile.am]
+files=src/sys/boot/btx/btx/btx.s,
+sub_dirs=
+type=normal
+
+[src/sys/boot/btx/btx/btx.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/boot/btx/btxldr/Makefile.am]
+files=src/sys/boot/btx/btxldr/btxldr.s,
+sub_dirs=
+type=normal
+
+[src/sys/boot/btx/btxldr/btxldr.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/boot/btx/lib/Makefile.am]
+files=src/sys/boot/btx/lib/btxcsu.s,src/sys/boot/btx/lib/btxsys.s,src/sys/boot/btx/lib/btxv86.h,src/sys/boot/btx/lib/btxv86.s,
+sub_dirs=
+type=normal
+
+[src/sys/boot/btx/lib/btxcsu.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/boot/btx/lib/btxsys.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/boot/btx/lib/btxv86.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/boot/btx/lib/btxv86.s]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/compile/Makefile.am]
+files=src/sys/compile/null.c,src/sys/compile/ubix.elf,
+sub_dirs=
+type=normal
+
+[src/sys/compile/null.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/compile/ubix.elf]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/deviceman/Makefile.am]
+files=src/sys/deviceman/bus_resources_portio.c,
+sub_dirs=
+type=normal
+
+[src/sys/deviceman/bus_resources_portio.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/8259.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/drivers/Makefile.am]
+files=src/sys/drivers/8259.c,src/sys/drivers/keyboard.c,src/sys/drivers/fdc.c,src/sys/drivers/pci_pio.c,src/sys/drivers/pit.c,src/sys/drivers/video.c,src/sys/drivers/hd.c,src/sys/drivers/drives.c,src/sys/drivers/lnc.c,src/sys/drivers/Makefile
+sub_dirs=
+type=static_library
+
+[src/sys/drivers/drives.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/fdc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/hd.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/keyboard.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/lnc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/pci_pio.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/pit.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/drivers/video.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/graphics/1.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/6X6.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/BLOCK.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/BOLD.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/Makefile.am]
+files=src/sys/graphics/6X6.DPF,src/sys/graphics/1.DPF,src/sys/graphics/BLOCK.DPF,src/sys/graphics/BOLD.DPF,src/sys/graphics/OLDENG.DPF,src/sys/graphics/PACMAN.DPF,src/sys/graphics/ROM8X8.DPF,src/sys/graphics/main.cpp,src/sys/graphics/objfont.cpp,src/sys/graphics/objfont.h,src/sys/graphics/objgfx,src/sys/graphics/objgfx30.cpp,src/sys/graphics/objgfx30.h,src/sys/graphics/testprog.cpp,
+sub_dirs=
+type=normal
+
+[src/sys/graphics/OLDENG.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/PACMAN.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/ROM8X8.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/main.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/graphics/objfont.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/graphics/objfont.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/graphics/objgfx]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/graphics/objgfx30.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/graphics/objgfx30.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/graphics/testprog.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/include/Makefile.am]
+files=src/sys/include/types.h,src/sys/include/config.h,src/sys/include/math.h,src/sys/include/stdarg.h
+sub_dirs=deviceman,drivers,misc,ubixfs,ubixos,version,vmm,lib,sde,pci,ld
+type=normal
+
+[src/sys/include/config.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/deviceman/Makefile.am]
+files=src/sys/include/deviceman/device.h,src/sys/include/deviceman/bus.h,src/sys/include/deviceman/bus_resources.h,src/sys/include/deviceman/bus_resources_portio.h,src/sys/include/deviceman/isapnp.h,
+sub_dirs=
+type=normal
+
+[src/sys/include/deviceman/bus.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/deviceman/bus_resources.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/deviceman/bus_resources_portio.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/deviceman/device.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/deviceman/isapnp.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/8259.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/Makefile.am]
+files=src/sys/include/drivers/keyboard.h,src/sys/include/drivers/8259.h,src/sys/include/drivers/fdc.h,src/sys/include/drivers/pci_pio.h,src/sys/include/drivers/video.h,src/sys/include/drivers/hd.h,src/sys/include/drivers/drives.h,src/sys/include/drivers/lnc.h,src/sys/include/drivers/pit.h
+sub_dirs=
+type=normal
+
+[src/sys/include/drivers/drives.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/fdc.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/hd.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/keyboard.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/lnc.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/pci_pio.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/pit.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/drivers/video.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ld/Makefile.am]
+files=src/sys/include/ld/ld.h
+sub_dirs=
+type=normal
+
+[src/sys/include/ld/ld.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/lib/Makefile.am]
+files=src/sys/include/lib/string.h,src/sys/include/lib/kmalloc.h,src/sys/include/lib/bioscall.h
+sub_dirs=
+type=normal
+
+[src/sys/include/lib/bioscall.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/lib/kmalloc.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/lib/string.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/math.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/misc/Makefile.am]
+files=src/sys/include/misc/kernel_string_pool.h,src/sys/include/misc/misc_bit_array.h,src/sys/include/misc/misc_string_conv.h,
+sub_dirs=
+type=normal
+
+[src/sys/include/misc/kernel_string_pool.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/misc/misc_bit_array.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/misc/misc_string_conv.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/pci/Makefile.am]
+files=src/sys/include/pci/pci.h
+sub_dirs=
+type=normal
+
+[src/sys/include/pci/pci.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/sde/Makefile.am]
+files=src/sys/include/sde/sde.h
+sub_dirs=
+type=normal
+
+[src/sys/include/sde/sde.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/stdarg.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/types.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixfs/Makefile.am]
+files=src/sys/include/ubixfs/ubixfs.h,src/sys/include/ubixfs/file.h,
+sub_dirs=
+type=normal
+
+[src/sys/include/ubixfs/file.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixfs/ubixfs.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/Makefile.am]
+files=src/sys/include/ubixos/a.out.h,src/sys/include/ubixos/bios32.h,src/sys/include/ubixos/dma.h,src/sys/include/ubixos/elf.h,src/sys/include/ubixos/exec.h,src/sys/include/ubixos/fork.h,src/sys/include/ubixos/gdt.h,src/sys/include/ubixos/idlethread.h,src/sys/include/ubixos/idt.h,src/sys/include/ubixos/io.h,src/sys/include/ubixos/kmalloc.h,src/sys/include/ubixos/panic.h,src/sys/include/ubixos/schedule.h,src/sys/include/ubixos/spinlock.h,src/sys/include/ubixos/syscall.h,src/sys/include/ubixos/syscalls.h,src/sys/include/ubixos/types.h,src/sys/include/ubixos/vitals.h,src/sys/include/ubixos/mount.h,src/sys/include/ubixos/fs.h,src/sys/include/ubixos/file.h,src/sys/include/ubixos/kpanic.h,src/sys/include/ubixos/libcpp.h,src/sys/include/ubixos/message.h,src/sys/include/ubixos/version.h,src/sys/include/ubixos/syserr.h
+sub_dirs=
+type=normal
+
+[src/sys/include/ubixos/a.out.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/bios32.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/dma.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/elf.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/exec.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/file.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/fork.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/fs.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/gdt.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/idlethread.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/idt.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/io.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/kmalloc.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/kpanic.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/libcpp.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/message.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/mount.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/panic.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/schedule.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/spinlock.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/syscall.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/syscalls.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/syserr.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/types.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/version.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/ubixos/vitals.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/version/Makefile.am]
+files=src/sys/include/version/version.h,
+sub_dirs=
+type=normal
+
+[src/sys/include/version/version.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/vmm/Makefile.am]
+files=src/sys/include/vmm/memory.h,src/sys/include/vmm/paging.h,
+sub_dirs=
+type=normal
+
+[src/sys/include/vmm/memory.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/include/vmm/paging.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/sys/init/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/init/Makefile.am]
+files=src/sys/init/main.c,src/sys/init/Makefile
+sub_dirs=
+type=normal
+
+[src/sys/init/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/isa/8259.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/isa/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/isa/Makefile.am]
+files=src/sys/isa/8259.c,src/sys/isa/atkbd.c,src/sys/isa/Makefile,src/sys/isa/fdc.c,src/sys/isa/pit.c
+sharedlib_LDFLAGS=-version-info 0:0:0
+sharedlib_rootname=isa
+sub_dirs=
+type=static_library
+
+[src/sys/isa/atkbd.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/isa/fdc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/isa/pit.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/kernel/Makefile.am]
+files=src/sys/kernel/bios32.c,src/sys/kernel/dma.c,src/sys/kernel/exec.c,src/sys/kernel/fork.c,src/sys/kernel/idlethread.c,src/sys/kernel/idt.c,src/sys/kernel/io.c,src/sys/kernel/kmalloc.c,src/sys/kernel/kprintf.c,src/sys/kernel/panic.c,src/sys/kernel/schedule.c,src/sys/kernel/spinlock.c,src/sys/kernel/syscall.c,src/sys/kernel/version.c,src/sys/kernel/vitals.c,src/sys/kernel/vsprintf.c,src/sys/kernel/kpanic.c,src/sys/kernel/Makefile,src/sys/kernel/mount.c,src/sys/kernel/fs.c,src/sys/kernel/file.c,src/sys/kernel/bioscall.c,src/sys/kernel/message.cc,src/sys/kernel/schedule.cc,src/sys/kernel/endtask.c,src/sys/kernel/syserr.c,src/sys/kernel/elf.c
+sub_dirs=
+type=static_library
+
+[src/sys/kernel/bios32.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/bioscall.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/dma.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/elf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/endtask.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/exec.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/file.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/fork.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/fs.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/idlethread.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/idt.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/io.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/kmalloc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/kpanic.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/kprintf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/message.cc]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/mount.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/panic.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/schedule.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/schedule.cc]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/spinlock.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/syscall.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/syserr.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/version.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/vitals.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/kernel/vsprintf.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/ld/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/ld/Makefile.am]
+files=src/sys/ld/Makefile,src/sys/ld/ld.c,src/sys/ld/loadlibrary.c
+sub_dirs=
+type=static_library
+
+[src/sys/ld/ld.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/ld/loadlibrary.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/lib/Makefile.am]
+files=src/sys/lib/string.c,src/sys/lib/strtok.c
+sharedlib_LDFLAGS=-version-info 0:0:0
+sharedlib_rootname=lib
+sub_dirs=
+type=static_library
+
+[src/sys/lib/string.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/lib/strtok.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/misc/Makefile.am]
+files=src/sys/misc/kernel_string_pool.c,src/sys/misc/misc_bit_array.c,src/sys/misc/misc_string_conv.c,
+sub_dirs=
+type=normal
+
+[src/sys/misc/kernel_string_pool.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/misc/misc_bit_array.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/misc/misc_string_conv.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/pci/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/pci/Makefile.am]
+files=src/sys/pci/hd.c,src/sys/pci/lnc.c,src/sys/pci/Makefile,src/sys/pci/pci.c
+sharedlib_LDFLAGS=-version-info 0:0:0
+sharedlib_rootname=pci
+sub_dirs=
+type=static_library
+
+[src/sys/pci/hd.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/pci/lnc.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/pci/pci.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sde/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/sde/Makefile.am]
+files=src/sys/sde/main.c,src/sys/sde/sde.cc,src/sys/sde/Makefile,src/sys/sde/ogDisplay_UbixOS.cc,src/sys/sde/main.cc
+sharedlib_LDFLAGS=-version-info 0:0:0
+sharedlib_rootname=sde
+sub_dirs=
+type=static_library
+
+[src/sys/sde/main.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sde/main.cc]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sde/ogDisplay_UbixOS.cc]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sde/sde.cc]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sys/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/sys/Makefile.am]
+files=src/sys/sys/dma.c,src/sys/sys/drives.c,src/sys/sys/idt.c,src/sys/sys/io.c,src/sys/sys/Makefile,src/sys/sys/video.c
+sharedlib_LDFLAGS=-version-info 0:0:0
+sharedlib_rootname=sys
+sub_dirs=
+type=static_library
+
+[src/sys/sys/dma.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sys/drives.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sys/idt.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sys/io.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/sys/video.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/ubixfs/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/ubixfs/Makefile.am]
+files=src/sys/ubixfs/file.c,src/sys/ubixfs/ubixfs.c,src/sys/ubixfs/Makefile
+sub_dirs=
+type=normal
+
+[src/sys/ubixfs/file.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/ubixfs/ubixfs.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/sys/vmm/Makefile.am]
+files=src/sys/vmm/memory.c,src/sys/vmm/paging.c,src/sys/vmm/Makefile,src/sys/vmm/clearvirtualpage.c,src/sys/vmm/doublefault.c,src/sys/vmm/getphysicaladdr.c,src/sys/vmm/freepage.c,src/sys/vmm/unmappage.c,src/sys/vmm/createvirtualspace.c,src/sys/vmm/copyvirtualspace.c,src/sys/vmm/setpageattributes.c,src/sys/vmm/getfreevirtualpage.c,src/sys/vmm/getfreekernelpage.c,src/sys/vmm/remappage.c,src/sys/vmm/getfreepage.c,src/sys/vmm/pagefault.c
+sub_dirs=
+type=static_library
+
+[src/sys/vmm/clearvirtualpage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/copyvirtualspace.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/createvirtualspace.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/doublefault.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/freepage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/getfreekernelpage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/getfreepage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/getfreevirtualpage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/getphysicaladdr.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/memory.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/pagefault.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/paging.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/remappage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/setpageattributes.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/sys/vmm/unmappage.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/tools/Makefile]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/tools/Makefile.am]
+files=src/tools/format,src/tools/format.c,src/tools/ubixfs.h,src/tools/userdb,src/tools/Makefile,src/tools/OLDENG.DPF,src/tools/PACMAN.DPF,src/tools/ROM8X14.DPF
+sub_dirs=
+type=normal
+
+[src/tools/OLDENG.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/tools/PACMAN.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/tools/ROM8X14.DPF]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/tools/format]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[src/tools/format.c]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[src/tools/ubixfs.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[src/tools/userdb]
+dist=true
+install=false
+install_location=
+type=DATA
diff --git a/lockwasher/lockwasher.kdevses b/lockwasher/lockwasher.kdevses
new file mode 100644
index 0000000..1c293a9
--- /dev/null
+++ b/lockwasher/lockwasher.kdevses
@@ -0,0 +1,7 @@
+
+
+
+ (Default)
+
+
+
diff --git a/lockwasher/snapshot.txt b/lockwasher/snapshot.txt
new file mode 100644
index 0000000..1729d34
--- /dev/null
+++ b/lockwasher/snapshot.txt
@@ -0,0 +1,25 @@
+Free Pages: [3505]
+Initializing System.
+Starting Login Daemon.
+
+UbixOS/IA-32 (devel.ubixos.com) (console)
+
+Login: root
+Password: ****
+Welcome to UbixOS
+This is an experimental kernel so it WILL crash and when
+it does please send us some info so we can fix it or
+if you have access to the source fix it and commit the
+changes.
+
+All reports can be sent to chris@domainatlantic.com
+
+�
+UbixOS: pwd@sys
+[0x8049354][0x804823A]
+[0x8049358][0x804824A]
+[0x804935C][0x804825A]
+memAddr: [0x8048264]
+[][0x0][printf][0x34][_DYNAMIC][0x9][__bss_start][0x42][getcwd][0x2D][_edata][0x
+3B][_GLOBAL_OFFSET_TABLE_][0x12][_end][0x4E][exit][0x28]Need To Code This
+UbixOS:
diff --git a/lockwasher/src/bin/Makefile b/lockwasher/src/bin/Makefile
new file mode 100644
index 0000000..da183ee
--- /dev/null
+++ b/lockwasher/src/bin/Makefile
@@ -0,0 +1,50 @@
+# $Id: Makefile,v 1.4 2003/04/27 00:45:15 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+all: init-bin login-bin shell-bin test-bin ls-bin pwd-bin cat-bin ld-dyn-bin de-bin muffin-bin goofball-bin
+
+init-bin: init
+ (cd init;make)
+
+login-bin: login
+ (cd login;make)
+
+shell-bin: shell
+ (cd shell;make)
+
+test-bin: test
+ (cd test;make)
+
+ls-bin: ls
+ (cd ls;make)
+
+pwd-bin: pwd
+ (cd pwd;make)
+
+cat-bin: cat
+ (cd cat;make)
+
+ld-dyn-bin: ld-dyn
+ (cd ld-dyn;make)
+
+de-bin: de
+ (cd de;make)
+
+muffin-bin: muffin
+ (cd muffin;make)
+
+goofball-bin: goofball
+ (cd goofball;make)
+
+clean:
+ (cd init;make clean)
+ (cd shell;make clean)
+ (cd test;make clean)
+ (cd ls;make clean)
+ (cd pwd;make clean)
+ (cd login;make clean)
+ (cd cat;make clean)
+ (cd ld-dyn;make clean)
+ (cd de;make clean)
+ (cd muffin;make clean)
+ (cd goofball;make clean)
diff --git a/lockwasher/src/bin/cat/Makefile b/lockwasher/src/bin/cat/Makefile
new file mode 100644
index 0000000..bfcb411
--- /dev/null
+++ b/lockwasher/src/bin/cat/Makefile
@@ -0,0 +1,53 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = cat
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+# $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+ ld -o $@ $(STARTUP) ../../lib/libc/libc.so $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/cat/main.c b/lockwasher/src/bin/cat/main.c
new file mode 100644
index 0000000..8bf7637
--- /dev/null
+++ b/lockwasher/src/bin/cat/main.c
@@ -0,0 +1,40 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+
+int main(int argc,char **argv) {
+ int i = 0x0;
+ FILE *fd;
+ fd = fopen("userdb","r");
+ for (i=0;i
+#include
+#include
+
+#define MAXPARTITIONS 4
+
+
+struct partStruct {
+ char active;
+ char startHd;
+ char startSec;
+ char startCyl;
+ char pType;
+ char endHd;
+ char endSec;
+ char endCyl;
+ long startLba;
+ long size;
+ };
+
+
+struct mbrStruct {
+ char code[446];
+ struct partStruct *parts;
+ char sig[2];
+ };
+
+struct driveInfo {
+ char hdSector[512];
+ char hdEnable;
+ char hdDev;
+ char hdFlags;
+ char hdShift;
+ long hdMask;
+ long hdMulti;
+ long hdPort;
+ long hdSize;
+ long hdCalc;
+ };
+
+struct driveDiskLabel {
+ uInt32 magicNum;
+ uInt32 magicNum2;
+ uInt16 driveType;
+ uInt16 numPartitions;
+ struct drivePartitions { //the partition table
+ uInt32 pSize; //number of sectors in partition
+ uInt32 pOffset; //starting sector
+ uInt32 pFsSize; //filesystem basic fragment size
+ uInt32 pBatSize; //BAT size
+ uInt8 pFsType; //filesystem type, see below
+ uInt8 pFrag; //filesystem fragments per block
+ } partitions[MAXPARTITIONS];
+ };
+
+struct driveDriver {
+ struct driveDriver *prev;
+ struct driveDriver *next;
+ struct driveDiskLabel *diskLabel;
+ int id;
+ struct driveInfo *driveInfoStruct;
+ char driveType;
+ void (*read)(void *,long,long,void *);
+ void (*write)(void *,long,long,void *);
+ void (*reset)(void *);
+ };
+
+int main(int argc,char **argv) {
+ int i = 0x0;
+ char *data = (char *)malloc(512);
+ char drive[32];
+ struct driveDriver *drives = 0x0,*tmpDrives = 0x0;
+ struct partStruct *parts = (struct partStruct *)malloc(64);
+ FILE *mbr,*hdDrive;
+ printf("UbixOS Disk Editor\n(C) 2003 Ubix Corp\n\n");
+ drives = getDrives();
+ while (1) {
+ printf("0) Show Disks\n");
+ printf("1) Quit\n");
+ gets(data);
+ switch (data[0]) {
+ case '0':
+ printf("Please Choose A Disk\n");
+ for (tmpDrives=drives;tmpDrives;tmpDrives=tmpDrives->next) {
+ printf("[%i][0x%X][%i]\n",tmpDrives->id,tmpDrives->driveType,((tmpDrives->driveInfoStruct->hdSize*512)/1024));
+ }
+ gets(data);
+ sprintf(drive,"drive%c@devfs",data[0]);
+ driveOpts:
+ printf("0) Install MBR\n");
+ printf("1) Show Partitions\n");
+ printf("3) Delete Partition\n");
+ printf("4) Add Partition\n");
+ gets(data);
+ switch (data[0]) {
+ case '0':
+ printf("Installing MBR\n");
+ mbr = fopen("mbr.img@sys","rb");
+ printf("[%s]\n",drive);
+ hdDrive = fopen(drive,"rb");
+ printf("[0x%X]\n",hdDrive);
+ fread(data,512,1,mbr);
+ fwrite(data,512,1,hdDrive);
+ fclose(mbr);
+ fclose(hdDrive);
+ break;
+ case '1':
+ hdDrive = fopen(drive,"rb");
+ printf("Going To Seek\n");
+ fseek(hdDrive,446,0);
+ printf("Done Seeking\n");
+ fread(parts,64,1,hdDrive);
+ for (i=0;i<4;i++) {
+ printf("Active Type Start C/H/S End C/H/S Start LBA Size\n");
+ printf("%i 0x%X %i/%i/%i %i/%i/%i 0x%X 0x%X\n",parts->active,(uInt8)parts->pType,parts->startCyl,parts->startHd,parts->startSec,parts->endCyl,parts->endHd,parts->endSec,parts->startLba,parts->size);
+ parts++;
+ }
+ fclose(hdDrive);
+ break;
+ default:
+ printf("Invalid Option\n");
+ goto driveOpts;
+ break;
+ }
+ break;
+ case '1':
+ return(0);
+ break;
+ default:
+ break;
+ }
+ }
+ return(0);
+ }
diff --git a/lockwasher/src/bin/goofball/Makefile b/lockwasher/src/bin/goofball/Makefile
new file mode 100644
index 0000000..bd14fba
--- /dev/null
+++ b/lockwasher/src/bin/goofball/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1 2003/04/27 00:45:15 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = goofball
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/goofball/main.c b/lockwasher/src/bin/goofball/main.c
new file mode 100644
index 0000000..92a7e91
--- /dev/null
+++ b/lockwasher/src/bin/goofball/main.c
@@ -0,0 +1,34 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.1 2003/04/27 12:37:25 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+
+int main() {
+ printf("Goofy Ball\n");
+ while (1) {
+ printf("GoofBall: [0x%X]\n",getpid());
+ }
+ return(0);
+ }
diff --git a/lockwasher/src/bin/init/Makefile b/lockwasher/src/bin/init/Makefile
new file mode 100644
index 0000000..e0cad8a
--- /dev/null
+++ b/lockwasher/src/bin/init/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = init
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o ${CFLAGS} $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/init/main.c b/lockwasher/src/bin/init/main.c
new file mode 100644
index 0000000..161bd47
--- /dev/null
+++ b/lockwasher/src/bin/init/main.c
@@ -0,0 +1,57 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.11 2003/04/24 05:16:28 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+
+int main(int argc,char **argv) {
+ int i=0;
+ if (getpid() != 1) {
+ printf("Sorry This Program Must Be Started By The Kernel!!!!\n");
+ exit(1);
+ }
+ if ((getuid() != 0) && (getgid() != 0)) {
+ printf("Sorry The System Must Start This As Root.\n");
+ exit(1);
+ }
+ printf("Initializing System.\n");
+ startup:
+ i = fork();
+ if (0 == i) {
+ printf("Starting Login Daemon.\n");
+ exec("login@sys",0x0,0x0);
+ printf("Error Starting System\n");
+ exit(0);
+ }
+ else {
+ while (pidStatus(i)) {
+ sched_yield();
+ //asm("nop");
+ }
+ goto startup;
+ }
+ return(0);
+ }
diff --git a/lockwasher/src/bin/ld-dyn/Makefile b/lockwasher/src/bin/ld-dyn/Makefile
new file mode 100644
index 0000000..163656c
--- /dev/null
+++ b/lockwasher/src/bin/ld-dyn/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:59 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = ld-dyn
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/ld-dyn/main.c b/lockwasher/src/bin/ld-dyn/main.c
new file mode 100644
index 0000000..1fe24c2
--- /dev/null
+++ b/lockwasher/src/bin/ld-dyn/main.c
@@ -0,0 +1,38 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.1.1.1 2003/01/12 00:19:59 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+//#include "../../sys/include/ubixos/elf.h"
+
+int main(int argc,char **argv) {
+ /*
+ elfHeader *eHeader = 0x0;
+ elfProgramheader *ePheader = 0x0;
+ elfSectionheader *eSheader = 0x0;
+ elfPltInfo *pltInfo = 0x0;
+ elfDynsym *dynSym = 0x0;
+ */
+ return(0);
+ }
diff --git a/lockwasher/src/bin/login/Makefile b/lockwasher/src/bin/login/Makefile
new file mode 100644
index 0000000..c2be029
--- /dev/null
+++ b/lockwasher/src/bin/login/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:59 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = login
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/login/main.c b/lockwasher/src/bin/login/main.c
new file mode 100644
index 0000000..927d208
--- /dev/null
+++ b/lockwasher/src/bin/login/main.c
@@ -0,0 +1,119 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.19 2003/04/24 05:16:28 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+struct passwd {
+ char username[32];
+ char password[32];
+ int uid;
+ int gid;
+ char shell[128];
+ char realname[256];
+ };
+
+static char *pgets(char *string) {
+ int count=0,ch=0;
+ while (1) {
+ ch = fgetc(stdin);
+ if(ch == 10) {
+ printf("\n");
+ break;
+ }
+ else if(ch == 8 && count > 0) count-=2;
+ else if(ch == 0) count--;
+ else string[count] = ch;
+ if (ch != 8) printf("*");
+ count ++;
+ }
+ string[count] = '\0';
+ return(string);
+ }
+
+int main() {
+ FILE *fd;
+ int shellPid = 0,i = 0x0;
+ char userName[32];
+ char passWord[32];
+ char *data2 = 0x0;
+ struct passwd *data = 0x0;
+ if ((getuid() != 0) && (getgid() != 0)) {
+ printf("This Application Must Be Run As Root.\n");
+ exit(1);
+ }
+ data = (struct passwd *)malloc(4096);
+ if (!(fd = fopen("userdb@sys","r"))) {
+ printf("Error Opening File");
+ memcpy(data[0].username,"root",4);
+ memcpy(data[0].password,"user",4);
+ memcpy(data[0].shell,"shell@sys", 10);
+ }
+ else {
+ fread(data,4096,1,fd);
+ fclose(fd);
+ }
+ data2 = (char *)malloc(256);
+ printf("\nUbixOS/IA-32 (devel.ubixos.com) (console)\n\n");
+ login:
+ printf("Login: ");
+ gets((char *)&userName);
+ printf("Password: ");
+ pgets((char *)&passWord);
+ for (i=0x0;i<(4096/sizeof(struct passwd));i++) {
+ if (0x0 == memcmp(userName,data[i].username,4)) {
+ if (0x0 == memcmp(passWord,data[i].password,4)) {
+ shellPid = fork();
+ if (!shellPid) {
+ if (setuid(data[i].uid) != 0x0) {
+ printf("Set UID Failed\n");
+ }
+ if (setgid(data[i].gid) != 0x0) {
+ printf("Set GID Failed\n");
+ }
+ if ((fd = fopen("motd@sys","r")) == 0x0) {
+ printf("No MOTD");
+ }
+ else {
+ fread(data2,256,1,fd);
+ printf("%s\n",data2);
+ }
+ fclose(fd);
+ exec(data[i].shell,0x0,0x0);
+ }
+ else {
+ while (pidStatus(shellPid)) sched_yield();
+ goto login;
+ }
+ }
+ }
+ }
+ printf("Login Incorrect!\n");
+ goto login;
+ exit(1);
+ }
+
diff --git a/lockwasher/src/bin/ls/Makefile b/lockwasher/src/bin/ls/Makefile
new file mode 100644
index 0000000..ab9a7ce
--- /dev/null
+++ b/lockwasher/src/bin/ls/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:57 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = ls
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/ls/main.c b/lockwasher/src/bin/ls/main.c
new file mode 100644
index 0000000..50219d5
--- /dev/null
+++ b/lockwasher/src/bin/ls/main.c
@@ -0,0 +1,103 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.4 2003/04/24 05:16:28 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+#define permRead 0x8
+#define permWrite 0x4
+#define permExecute 0x2
+#define permHidden 0x1
+
+
+//UbixFS Directory Entry
+struct directoryEntry {
+ uLong startCluster; //Starting Cluster Of File
+ uLong size; //Size Of File
+ uLong creationDate; //Date Created
+ uLong lastModified; //Date Last Modified
+ uLong uid; //UID Of Owner
+ uLong gid; //GID Of Owner
+ uShort attributes; //Files Attributes
+ uShort permissions; //Files Permissions
+ char fileName[256]; //File Name
+ };
+
+int main(int argc,char **argv) {
+ int i = 0x0,x = 0x0,tmpPerms = 0x0;
+ char *pwd = (char *)malloc(256);
+ char *permsData = (char *)malloc(13);
+ FILE *fd;
+ struct directoryEntry *dirEntry = 0x0;
+ if (argv[1] == 0x0) {
+ if ((fd = fopen(":","rb")) == 0x0) {
+ printf("Error Reading Directory\n");
+ exit(1);
+ }
+ }
+ else {
+ if ((fd = fopen(argv[1],"rb")) == 0x0) {
+ printf("Error Reading Directory\n");
+ exit(1);
+ }
+ }
+ dirEntry = (struct directoryEntry *)malloc(fd->size);
+ fread(dirEntry,fd->size,1,fd);
+ if (!fclose(fd)) {
+ printf("Error Closing Directory\n");
+ }
+ pwd[0] = '/';
+ for (i=0;i<(fd->size/sizeof(struct directoryEntry));i++) {
+ if ((dirEntry[i].fileName[0] > 0) && (dirEntry[i].fileName[0] != ':')) {
+ for (x=0;x<12;x++) {
+ permsData[x] = '-';
+ }
+ if (dirEntry[i].attributes == 0x800) {
+ permsData[0] = 'F';
+ }
+ if (dirEntry[i].attributes == 0x8000) {
+ permsData[0] = 'D';
+ }
+ tmpPerms = ((dirEntry[i].permissions & 0xF00) >> 8);
+ if ((tmpPerms & permRead) == permRead) permsData[1] = 'R';
+ if ((tmpPerms & permWrite) == permWrite) permsData[2] = 'W';
+ if ((tmpPerms & permExecute) == permExecute) permsData[3] = 'E';
+ if ((tmpPerms & permHidden) == permHidden) permsData[4] = 'H';
+ tmpPerms = ((dirEntry[i].permissions & 0x0F0) >> 4);
+ if ((tmpPerms & permRead) == permRead) permsData[5] = 'R';
+ if ((tmpPerms & permWrite) == permWrite) permsData[6] = 'W';
+ if ((tmpPerms & permExecute) == permExecute) permsData[7] = 'E';
+ if ((tmpPerms & permHidden) == permHidden) permsData[8] = 'H';
+ tmpPerms = ((dirEntry[i].permissions & 0x00F) >> 0);
+ if ((tmpPerms & permRead) == permRead) permsData[9] = 'R';
+ if ((tmpPerms & permWrite) == permWrite) permsData[10] = 'W';
+ if ((tmpPerms & permExecute) == permExecute) permsData[11] = 'E';
+ if ((tmpPerms & permHidden) == permHidden) permsData[12] = 'H';
+ printf("%s %i %i %i %s\n",permsData,(int)dirEntry[i].uid,(int)dirEntry[i].gid,(int)dirEntry[i].size,dirEntry[i].fileName);
+ }
+ }
+ for (i=0;i
+#include
+#include
+extern "C" {
+#include
+#include
+}
+
+int main() {
+ bool result;
+ ogBitFont * font = new ogBitFont();
+ vWindow * window = new vWindow();
+ printf("[%i]\n",window->vCreate());
+ window->ogClear(window->ogRGB(0,0,255));
+ if (window->ogGetPixel(0,0) == window->ogRGB(0,0,255))
+ printf("ogClear worked\n");
+ if (window->ogGetPixel(-1,-1) == window->ogRGB(0,0,255))
+ printf("problem with ogRGB!!!!!\n");
+
+ result = font->load("PACMAN.DPF");
+ printf("Font Loaded: [0x%X]\n",(int)result);
+ font->setFGColor(0,255,0);
+ font->setBGColor(255,0,0);
+
+ printf("Muffin!\n");
+ printf("Command 1\n");
+ window->vSDECommand(1);
+ printf("Command 3\n");
+ window->vSDECommand(3);
+ printf("Load Font\n");
+ font->putString(*window,0x0,0x0,"this is a test");
+ window->vSDECommand(3);
+ window->vSDECommand(4);
+ return(0);
+ }
diff --git a/lockwasher/src/bin/pwd/Makefile b/lockwasher/src/bin/pwd/Makefile
new file mode 100644
index 0000000..df6d3b8
--- /dev/null
+++ b/lockwasher/src/bin/pwd/Makefile
@@ -0,0 +1,53 @@
+# $Id: Makefile,v 1.2 2003/05/04 13:20:15 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = pwd
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+#LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o
+LIBRARIES = ../../lib/libc/libc.so
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/pwd/main.c b/lockwasher/src/bin/pwd/main.c
new file mode 100644
index 0000000..74e24c1
--- /dev/null
+++ b/lockwasher/src/bin/pwd/main.c
@@ -0,0 +1,32 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.2 2003/04/20 12:11:29 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+
+int main() {
+ char cwd[1024];
+ exit(printf("%s\n",getcwd(cwd,1024)));
+ return(0);
+ }
diff --git a/lockwasher/src/bin/shell/Makefile b/lockwasher/src/bin/shell/Makefile
new file mode 100644
index 0000000..a317ea0
--- /dev/null
+++ b/lockwasher/src/bin/shell/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:58 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = shell
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o error.o commands.o exec.o input.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/shell/commands.c b/lockwasher/src/bin/shell/commands.c
new file mode 100644
index 0000000..68468ff
--- /dev/null
+++ b/lockwasher/src/bin/shell/commands.c
@@ -0,0 +1,72 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: commands.c,v 1.4 2003/05/11 23:37:07 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include "shell.h"
+
+int commands(inputBuffer *data) {
+ int cPid = 0x0,i = 0x0;
+ if (0 == memcmp(data->args->arg, "uname", 5)) {
+ printf("UbixOS v0.87 " __DATE__" " __TIME__ " \n");
+ return(1);
+ }
+ else if (0 == memcmp(data->args->arg, "exit", 4)) {
+ exit(1);
+ }
+ else if (0 == memcmp(data->args->arg, "mypid", 5)) {
+ printf("My Pid: [%i]\n",getpid());
+ return(1);
+ }
+ else if (memcmp(data->args->arg,"stress", 6) == 0) {
+ while (1) {
+ cPid = fork();
+ printf("Pid: [%i]\n",cPid);
+ if (!cPid) {
+ exec("test",data->argc,data->argv);
+ exit(1);
+ }
+ else {
+ while (pidStatus(cPid));
+ }
+
+ }
+ }
+ else if (memcmp(data->args->arg,"echo",4) == 0) {
+ for (i=1;iargc;i++) {
+ printf("%s ",data->argv[i]);
+ }
+ printf("\n");
+ }
+ else if (memcmp(data->args->arg,"about",5) == 0) {
+ printf("UbixOS Shell v0.99 (C) 2002\n");
+ printf("Base Command Line Interface\n");
+ }
+ else {
+ return(0);
+ }
+ return(1);
+ }
diff --git a/lockwasher/src/bin/shell/error.c b/lockwasher/src/bin/shell/error.c
new file mode 100644
index 0000000..1a1355c
--- /dev/null
+++ b/lockwasher/src/bin/shell/error.c
@@ -0,0 +1,30 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: error.c,v 1.1.1.1 2003/01/12 00:19:58 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+void error(int errorCode,char *errorMsg) {
+ printf("ERROR: #%i Message: %s\n", errorCode, errorMsg);
+ exit(errorCode);
+ }
diff --git a/lockwasher/src/bin/shell/exec.c b/lockwasher/src/bin/shell/exec.c
new file mode 100644
index 0000000..b0557aa
--- /dev/null
+++ b/lockwasher/src/bin/shell/exec.c
@@ -0,0 +1,47 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: exec.c,v 1.4 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include "shell.h"
+
+void sched_yield();
+
+void execProgram(inputBuffer *data) {
+ int cPid = 0x0;
+ cPid = fork();
+ if (!cPid) {
+ if (exec(data->argv[0],data->argc,data->argv) == 0) {
+ printf("%s: Command Not Found.\n",data->argv[0]);
+ }
+ exit(1);
+ }
+ else {
+ if (data->bg == 0x0) {
+ while (pidStatus(cPid))
+ sched_yield();
+ }
+ }
+ }
diff --git a/lockwasher/src/bin/shell/input.c b/lockwasher/src/bin/shell/input.c
new file mode 100644
index 0000000..53568a0
--- /dev/null
+++ b/lockwasher/src/bin/shell/input.c
@@ -0,0 +1,58 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: input.c,v 1.3 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include "shell.h"
+
+void parseInput(inputBuffer *buffer,char *data) {
+ int i = 0x0;
+ struct argsStruct *tmpArgs = 0x0;
+
+ while (data[0] == ' ') {
+ data++;
+ }
+ buffer->args = (struct argsStruct *)malloc(sizeof(struct argsStruct));
+ tmpArgs = buffer->args;
+ while(data != 0x0) {
+ tmpArgs->arg = strtok(data," ");
+ data = strtok(NULL,"\n");
+ if (tmpArgs->arg[0] == '&') {
+ buffer->bg = 0x1;
+ }
+ else {
+ buffer->argc++;
+ if (data != 0x0) {
+ tmpArgs->next = (struct argsStruct *)malloc(sizeof(struct argsStruct));
+ }
+ tmpArgs = tmpArgs->next;
+ }
+ }
+ buffer->argv = (char *)malloc(4*buffer->argc);
+ tmpArgs = buffer->args;
+ for (i=0;iargc;i++) {
+ buffer->argv[i] = tmpArgs->arg;
+ tmpArgs = tmpArgs->next;
+ }
+ }
diff --git a/lockwasher/src/bin/shell/main.c b/lockwasher/src/bin/shell/main.c
new file mode 100644
index 0000000..4afec69
--- /dev/null
+++ b/lockwasher/src/bin/shell/main.c
@@ -0,0 +1,47 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.2 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include "shell.h"
+
+int main() {
+ unsigned char buffer[256],*data;
+ inputBuffer *inBuf = (inputBuffer *)malloc(sizeof(inputBuffer));
+ while (1) {
+ printf("UbixOS: ");
+ gets((char *)&buffer);
+ data = (uChar *)&buffer;
+ parseInput(inBuf,data);
+ if (inBuf->args->arg != 0x0) {
+ if (!commands(inBuf)) execProgram(inBuf);
+ }
+ inBuf->argc = 0x0;
+ inBuf->args = 0x0;
+ inBuf->bg = 0x0;
+ }
+ exit(0);
+ }
diff --git a/lockwasher/src/bin/shell/shell.h b/lockwasher/src/bin/shell/shell.h
new file mode 100644
index 0000000..c07a0e8
--- /dev/null
+++ b/lockwasher/src/bin/shell/shell.h
@@ -0,0 +1,17 @@
+#include
+
+struct argsStruct {
+ struct argsStruct *next;
+ char *arg;
+ };
+
+typedef struct {
+ int argc;
+ char **argv;
+ uInt8 bg;
+ struct argsStruct *args;
+ } inputBuffer;
+
+void parseInput(inputBuffer *,char *);
+int commands(inputBuffer *);
+void execProgram(inputBuffer *);
diff --git a/lockwasher/src/bin/test/Makefile b/lockwasher/src/bin/test/Makefile
new file mode 100644
index 0000000..3eb6538
--- /dev/null
+++ b/lockwasher/src/bin/test/Makefile
@@ -0,0 +1,52 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:19:58 reddawg Exp $
+# Application Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Compiler Flags
+CFLAGS = -I../../lib/libc/include -fno-builtin
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = test
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = main.o
+
+#Libraries
+LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o
+
+#Startup File
+STARTUP = ../../lib/ubix/startup.o
+
+# Link The Binary
+$(BINARY) : $(OBJS)
+ $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(CFLAGS) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean Up The junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/bin/test/main.c b/lockwasher/src/bin/test/main.c
new file mode 100644
index 0000000..e3f404f
--- /dev/null
+++ b/lockwasher/src/bin/test/main.c
@@ -0,0 +1,55 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: main.c,v 1.12 2003/05/11 23:37:07 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+
+void sched_yield();
+
+int main() {
+ int i = 0,x = 0,cPid = 0;
+ printf("This Is A Test Program\n");
+ printf("My PID Is : [%i]\n",getpid());
+ printf("I'm Now Going To Fork Myself And See If This Causes A Memory Leak\n");
+ for (i=0;i<=100;i++) {
+ cPid = fork();
+ if (!cPid) {
+ printf("Child Pid: [%i]\n",getpid());
+ for (x=0;x<=5;x++) {
+ printf("[%i]",x);
+ }
+ printf("\n");
+ while (malloc(4096*100000) != 0x0);
+ exit(1);
+ }
+ else {
+ printf("Parent Pid: [%i]\n",getpid());
+ while (pidStatus(cPid)) sched_yield();
+ }
+ }
+ printf("Testing Complete\n");
+ exit(0); //OK HERE IS THE BUG MUST CHECK STACK POINTERS
+ return(0);
+ }
diff --git a/lockwasher/src/lib/libc/Makefile b/lockwasher/src/lib/libc/Makefile
new file mode 100644
index 0000000..f1a591d
--- /dev/null
+++ b/lockwasher/src/lib/libc/Makefile
@@ -0,0 +1,61 @@
+# $Id: Makefile,v 1.6 2003/05/04 13:20:15 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS =
+
+#Sub Sections
+SUBS = ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o ./math/*.o ./quad/*.o ./generic/*.o
+
+#Output
+OUTPUT = libc.so
+
+lib.so: $(OBJS)
+ (cd stdio;make)
+ (cd stdlib;make)
+ (cd math;make)
+ (cd quad;make)
+ (cd sys;make)
+ (cd string;make)
+ (cd generic;make)
+# $(LD) -o $(OUTPUT) $(OBJS) ./stdio/*.o ./sys/*.o ./string/*.o ./stdlib/*.o
+ $(GCC) -nostdlib -shared -Wl,-soname,libc.so -o $(OUTPUT) $(OBJS) $(SUBS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -nostdinc -O -I./include -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -nostdinc -O -I./include -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -nostdinc -O -I./include -c $<
+
+.c.s:
+ $(GCC) -Wall -nostdinc -O -I./include -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -nostdinc -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
+ (cd stdio;make clean)
+ (cd sys;make clean)
+ (cd stdlib;make clean)
+ (cd generic;make clean)
+ (cd string;make clean)
+ (cd math;make clean)
+ (cd quad;make clean)
diff --git a/lockwasher/src/lib/libc/generic/Makefile b/lockwasher/src/lib/libc/generic/Makefile
new file mode 100644
index 0000000..f86df45
--- /dev/null
+++ b/lockwasher/src/lib/libc/generic/Makefile
@@ -0,0 +1,42 @@
+# $Id: Makefile,v 1.2 2003/03/13 02:02:33 apwillia Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = getcwd.o
+#Output
+OUTPUT = libc.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $<
+
+.c.s:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/generic/getcwd.c b/lockwasher/src/lib/libc/generic/getcwd.c
new file mode 100644
index 0000000..599b7e1
--- /dev/null
+++ b/lockwasher/src/lib/libc/generic/getcwd.c
@@ -0,0 +1,30 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: getcwd.c,v 1.2 2003/04/20 12:11:30 reddawg Exp $
+
+**************************************************************************************/
+
+char *getcwd(char *cwd) {
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (26),"b" (cwd)
+ );
+ return(cwd);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/include/math.h b/lockwasher/src/lib/libc/include/math.h
new file mode 100644
index 0000000..2435391
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/math.h
@@ -0,0 +1,2 @@
+double sqrt(double val);
+double atan(double val);
diff --git a/lockwasher/src/lib/libc/include/quad.h b/lockwasher/src/lib/libc/include/quad.h
new file mode 100644
index 0000000..4f65864
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/quad.h
@@ -0,0 +1,4 @@
+#include
+
+quad_t __divdi3(quad_t a,quad_t b);
+u_quad_t __udivdi3(u_quad_t a,u_quad_t b);
diff --git a/lockwasher/src/lib/libc/include/stdarg.h b/lockwasher/src/lib/libc/include/stdarg.h
new file mode 100644
index 0000000..4d76835
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/stdarg.h
@@ -0,0 +1,34 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: stdarg.h,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _STDARG_H
+#define _STDARG_H
+
+typedef char *vaList;
+
+#define _vaSize(TYPE) (((sizeof(TYPE) + sizeof(int) -1) / sizeof(int)) * sizeof(int))
+#define vaStart(AP, LASTARG) (AP=((vaList)&(LASTARG) + _vaSize(LASTARG)))
+#define vaEnd(AP)
+#define vaArg(AP, TYPE) (AP += _vaSize(TYPE), *((TYPE *)(AP - _vaSize(TYPE))))
+
+#endif
diff --git a/lockwasher/src/lib/libc/include/stdio.h b/lockwasher/src/lib/libc/include/stdio.h
new file mode 100644
index 0000000..5dc9ab2
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/stdio.h
@@ -0,0 +1,65 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: stdio.h,v 1.4 2003/04/24 05:16:28 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _STDIO_H
+#define _STDIO_H
+
+#include
+#include
+
+/* Type Definitions */
+
+typedef struct fileDescriptor {
+ uLong fd;
+ uInt32 size;
+ } FILE;
+
+/* Definitions */
+
+extern FILE fdTable[];
+
+#define stdin (&fdTable[0])
+#define stdout (&fdTable[1])
+#define stderr (&fdTable[2])
+
+#define SEEK_SET 0
+
+/* Functions Definitions */
+
+int fprintf(FILE *, const char *,...);
+int printf(const char *,...);
+int vfprintf(FILE *,const char *,vaList args);
+int vsprintf(char *buf,const char *fmt,vaList args);
+FILE *fopen(const char *,const char *);
+int fwrite(const void *ptr,int size,int nmemb,FILE *fd);
+int fgetc(FILE *fd);
+
+//New Functions Listed From Here On Till I'm Done Writing A libc
+int sprintf(char *string, const char *format, ...);
+char *gets(char *string);
+size_t fread(void *pointer,size_t size,size_t count, FILE *stream);
+int fclose(FILE *fp);
+int fseek(FILE *,long offset,int whence);
+
+#endif
+
diff --git a/lockwasher/src/lib/libc/include/stdlib.h b/lockwasher/src/lib/libc/include/stdlib.h
new file mode 100644
index 0000000..5992cf5
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/stdlib.h
@@ -0,0 +1,34 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: stdlib.h,v 1.3 2003/04/02 20:27:47 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#include
+
+void exit(int);
+void *malloc(uInt len);
+void free(void *);
+int abs(int val);
+
+#endif
diff --git a/lockwasher/src/lib/libc/include/string.h b/lockwasher/src/lib/libc/include/string.h
new file mode 100644
index 0000000..5e8827d
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/string.h
@@ -0,0 +1,38 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: string.h,v 1.2 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _STRING_H
+#define _STRING_H
+
+#include
+
+extern void * memcpy(void *, const void *, size_t);
+extern void * memset(void *, int, size_t);
+extern int memcmp(const void *, const void *, size_t);
+
+extern int strlen(const char *);
+
+char *strtok(char *str, const char *sep);
+char *strtok_r(char *str, const char *sep, char **last);
+
+#endif
diff --git a/lockwasher/src/lib/libc/include/sys/sched.h b/lockwasher/src/lib/libc/include/sys/sched.h
new file mode 100644
index 0000000..5e85737
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/sys/sched.h
@@ -0,0 +1,7 @@
+#ifndef _SCHED_H
+#define _SCHED_H
+
+int sched_yield();
+
+#endif
+
diff --git a/lockwasher/src/lib/libc/include/sys/sys.h b/lockwasher/src/lib/libc/include/sys/sys.h
new file mode 100644
index 0000000..4f3c0dd
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/sys/sys.h
@@ -0,0 +1,32 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: sys.h,v 1.4 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _SYS_H
+#define _SYS_H
+
+int exec(char *,int argc,char **argv);
+int pidStatus(int pid);
+void *getPage(int count);
+void *getDrives();
+
+#endif
diff --git a/lockwasher/src/lib/libc/include/sys/types.h b/lockwasher/src/lib/libc/include/sys/types.h
new file mode 100644
index 0000000..7d673ce
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/sys/types.h
@@ -0,0 +1,49 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: types.h,v 1.4 2003/04/02 20:27:47 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+typedef unsigned short uShort;
+typedef unsigned long uLong;
+typedef unsigned char uChar;
+typedef unsigned int uInt;
+typedef unsigned long size_t;
+typedef int pid_t;
+
+typedef unsigned char uInt8;
+typedef unsigned short uInt16;
+typedef unsigned long uInt32;
+
+typedef long long int quad_t;
+typedef unsigned long long int u_quad_t;
+
+#ifndef NULL
+#define NULL 0x0
+#endif
+
+#ifndef NOBOOL
+typedef enum { FALSE=0,TRUE=1 } bool;
+#endif
+
+#endif
diff --git a/lockwasher/src/lib/libc/include/unistd.h b/lockwasher/src/lib/libc/include/unistd.h
new file mode 100644
index 0000000..19f7c57
--- /dev/null
+++ b/lockwasher/src/lib/libc/include/unistd.h
@@ -0,0 +1,39 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: unistd.h,v 1.2 2003/03/31 15:23:07 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _UNISTD_H
+#define _UNISTD_H
+
+#include
+
+uShort getpid(void);
+pid_t fork();
+
+//New Functions Added Belong Under Here
+char *getcwd(char *buffer,uLong size);
+int setuid(int);
+int setgid(int);
+int getuid(void);
+int getgid(void);
+
+#endif
diff --git a/lockwasher/src/lib/libc/math/Makefile b/lockwasher/src/lib/libc/math/Makefile
new file mode 100644
index 0000000..a6bcb13
--- /dev/null
+++ b/lockwasher/src/lib/libc/math/Makefile
@@ -0,0 +1,42 @@
+# $Id: Makefile,v 1.1 2003/04/02 20:27:47 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = atan.o sqrt.o
+#Output
+OUTPUT = libc.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $<
+
+.c.s:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/math/atan.c b/lockwasher/src/lib/libc/math/atan.c
new file mode 100644
index 0000000..ee59158
--- /dev/null
+++ b/lockwasher/src/lib/libc/math/atan.c
@@ -0,0 +1,5 @@
+#include
+
+double atan(double val) {
+ return(val);
+ }
diff --git a/lockwasher/src/lib/libc/math/sqrt.c b/lockwasher/src/lib/libc/math/sqrt.c
new file mode 100644
index 0000000..581e032
--- /dev/null
+++ b/lockwasher/src/lib/libc/math/sqrt.c
@@ -0,0 +1,5 @@
+#include
+
+double sqrt(double val) {
+ return(val);
+ }
diff --git a/lockwasher/src/lib/libc/quad/Makefile b/lockwasher/src/lib/libc/quad/Makefile
new file mode 100644
index 0000000..cdf9ba8
--- /dev/null
+++ b/lockwasher/src/lib/libc/quad/Makefile
@@ -0,0 +1,42 @@
+# $Id: Makefile,v 1.1 2003/04/02 20:28:25 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = udivdi3.o divdi3.o
+#Output
+OUTPUT = libc.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $<
+
+.c.s:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/quad/divdi3.c b/lockwasher/src/lib/libc/quad/divdi3.c
new file mode 100644
index 0000000..914b0be
--- /dev/null
+++ b/lockwasher/src/lib/libc/quad/divdi3.c
@@ -0,0 +1,17 @@
+#include
+
+quad_t __divdi3(quad_t a,quad_t b) {
+ u_quad_t ua = 0x0, ub = 0x0, uq = 0x0;
+ int neg;
+
+ if (a < 0)
+ ua = -(u_quad_t)a, neg = 1;
+ else
+ ua = a, neg = 0;
+ if (b < 0)
+ ub = -(u_quad_t)b, neg ^= 1;
+ else
+ ub = b;
+// uq = __qdivrem(ua, ub, (u_quad_t *)0);
+ return (neg ? -uq : uq);
+}
diff --git a/lockwasher/src/lib/libc/quad/qdivrem.c b/lockwasher/src/lib/libc/quad/qdivrem.c
new file mode 100644
index 0000000..0fa5cb8
--- /dev/null
+++ b/lockwasher/src/lib/libc/quad/qdivrem.c
@@ -0,0 +1,199 @@
+#include
+
+u_quad_t
+__qdivrem(uq, vq, arq)
+ u_quad_t uq, vq, *arq;
+{
+ union uu tmp;
+ digit *u, *v, *q;
+ register digit v1, v2;
+ u_long qhat, rhat, t;
+ int m, n, d, j, i;
+ digit uspace[5], vspace[5], qspace[5];
+
+ /*
+ * Take care of special cases: divide by zero, and u < v.
+ */
+ if (vq == 0) {
+ /* divide by zero. */
+ static volatile const unsigned int zero = 0;
+
+ tmp.ul[H] = tmp.ul[L] = 1 / zero;
+ if (arq)
+ *arq = uq;
+ return (tmp.q);
+ }
+ if (uq < vq) {
+ if (arq)
+ *arq = uq;
+ return (0);
+ }
+ u = &uspace[0];
+ v = &vspace[0];
+ q = &qspace[0];
+
+ /*
+ * Break dividend and divisor into digits in base B, then
+ * count leading zeros to determine m and n. When done, we
+ * will have:
+ * u = (u[1]u[2]...u[m+n]) sub B
+ * v = (v[1]v[2]...v[n]) sub B
+ * v[1] != 0
+ * 1 < n <= 4 (if n = 1, we use a different division algorithm)
+ * m >= 0 (otherwise u < v, which we already checked)
+ * m + n = 4
+ * and thus
+ * m = 4 - n <= 2
+ */
+ tmp.uq = uq;
+ u[0] = 0;
+ u[1] = HHALF(tmp.ul[H]);
+ u[2] = LHALF(tmp.ul[H]);
+ u[3] = HHALF(tmp.ul[L]);
+ u[4] = LHALF(tmp.ul[L]);
+ tmp.uq = vq;
+ v[1] = HHALF(tmp.ul[H]);
+ v[2] = LHALF(tmp.ul[H]);
+ v[3] = HHALF(tmp.ul[L]);
+ v[4] = LHALF(tmp.ul[L]);
+ for (n = 4; v[1] == 0; v++) {
+ if (--n == 1) {
+ u_long rbj; /* r*B+u[j] (not root boy jim) */
+ digit q1, q2, q3, q4;
+
+ /*
+ * Change of plan, per exercise 16.
+ * r = 0;
+ * for j = 1..4:
+ * q[j] = floor((r*B + u[j]) / v),
+ * r = (r*B + u[j]) % v;
+ * We unroll this completely here.
+ */
+ t = v[2]; /* nonzero, by definition */
+ q1 = u[1] / t;
+ rbj = COMBINE(u[1] % t, u[2]);
+ q2 = rbj / t;
+ rbj = COMBINE(rbj % t, u[3]);
+ q3 = rbj / t;
+ rbj = COMBINE(rbj % t, u[4]);
+ q4 = rbj / t;
+ if (arq)
+ *arq = rbj % t;
+ tmp.ul[H] = COMBINE(q1, q2);
+ tmp.ul[L] = COMBINE(q3, q4);
+ return (tmp.q);
+ }
+ }
+
+ /*
+ * By adjusting q once we determine m, we can guarantee that
+ * there is a complete four-digit quotient at &qspace[1] when
+ * we finally stop.
+ */
+ for (m = 4 - n; u[1] == 0; u++)
+ m--;
+ for (i = 4 - m; --i >= 0;)
+ q[i] = 0;
+ q += 4 - m;
+
+ /*
+ * Here we run Program D, translated from MIX to C and acquiring
+ * a few minor changes.
+ *
+ * D1: choose multiplier 1 << d to ensure v[1] >= B/2.
+ */
+ d = 0;
+ for (t = v[1]; t < B / 2; t <<= 1)
+ d++;
+ if (d > 0) {
+ shl(&u[0], m + n, d); /* u <<= d */
+ shl(&v[1], n - 1, d); /* v <<= d */
+ }
+ /*
+ * D2: j = 0.
+ */
+ j = 0;
+ v1 = v[1]; /* for D3 -- note that v[1..n] are constant */
+ v2 = v[2]; /* for D3 */
+ do {
+ register digit uj0, uj1, uj2;
+
+ /*
+ * D3: Calculate qhat (\^q, in TeX notation).
+ * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and
+ * let rhat = (u[j]*B + u[j+1]) mod v[1].
+ * While rhat < B and v[2]*qhat > rhat*B+u[j+2],
+ * decrement qhat and increase rhat correspondingly.
+ * Note that if rhat >= B, v[2]*qhat < rhat*B.
+ */
+ uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */
+ uj1 = u[j + 1]; /* for D3 only */
+ uj2 = u[j + 2]; /* for D3 only */
+ if (uj0 == v1) {
+ qhat = B;
+ rhat = uj1;
+ goto qhat_too_big;
+ } else {
+ u_long n = COMBINE(uj0, uj1);
+ qhat = n / v1;
+ rhat = n % v1;
+ }
+ while (v2 * qhat > COMBINE(rhat, uj2)) {
+ qhat_too_big:
+ qhat--;
+ if ((rhat += v1) >= B)
+ break;
+ }
+ /*
+ * D4: Multiply and subtract.
+ * The variable `t' holds any borrows across the loop.
+ * We split this up so that we do not require v[0] = 0,
+ * and to eliminate a final special case.
+ */
+ for (t = 0, i = n; i > 0; i--) {
+ t = u[i + j] - v[i] * qhat - t;
+ u[i + j] = LHALF(t);
+ t = (B - HHALF(t)) & (B - 1);
+ }
+ t = u[j] - t;
+ u[j] = LHALF(t);
+ /*
+ * D5: test remainder.
+ * There is a borrow if and only if HHALF(t) is nonzero;
+ * in that (rare) case, qhat was too large (by exactly 1).
+ * Fix it by adding v[1..n] to u[j..j+n].
+ */
+ if (HHALF(t)) {
+ qhat--;
+ for (t = 0, i = n; i > 0; i--) { /* D6: add back. */
+ t += u[i + j] + v[i];
+ u[i + j] = LHALF(t);
+ t = HHALF(t);
+ }
+ u[j] = LHALF(u[j] + t);
+ }
+ q[j] = qhat;
+ } while (++j <= m); /* D7: loop on j. */
+
+ /*
+ * If caller wants the remainder, we have to calculate it as
+ * u[m..m+n] >> d (this is at most n digits and thus fits in
+ * u[m+1..m+n], but we may need more source digits).
+ */
+ if (arq) {
+ if (d) {
+ for (i = m + n; i > m; --i)
+ u[i] = (u[i] >> d) |
+ LHALF(u[i - 1] << (HALF_BITS - d));
+ u[i] = 0;
+ }
+ tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
+ tmp.ul[L] = COMBINE(uspace[3], uspace[4]);
+ *arq = tmp.q;
+ }
+
+ tmp.ul[H] = COMBINE(qspace[1], qspace[2]);
+ tmp.ul[L] = COMBINE(qspace[3], qspace[4]);
+ return (tmp.q);
+}
+
diff --git a/lockwasher/src/lib/libc/quad/udivdi3.c b/lockwasher/src/lib/libc/quad/udivdi3.c
new file mode 100644
index 0000000..4c9908d
--- /dev/null
+++ b/lockwasher/src/lib/libc/quad/udivdi3.c
@@ -0,0 +1,7 @@
+#include
+
+u_quad_t __udivdi3(u_quad_t a,u_quad_t b) {
+
+ //return (__qdivrem(a, b, (u_quad_t *)0));
+ return(0);
+}
diff --git a/lockwasher/src/lib/libc/stdio/Makefile b/lockwasher/src/lib/libc/stdio/Makefile
new file mode 100644
index 0000000..8670aca
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/Makefile
@@ -0,0 +1,42 @@
+# $Id: Makefile,v 1.2 2003/04/02 19:42:50 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = fseek.o printf.o vsprintf.o fd.o vfprintf.o fopen.o fread.o fwrite.o fgetc.o sprintf.o gets.o fclose.o
+#Output
+OUTPUT = libc.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -c $<
+
+.c.s:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) $(CFLAGS) -Wall -nostdlib -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/stdio/fclose.c b/lockwasher/src/lib/libc/stdio/fclose.c
new file mode 100644
index 0000000..6519b05
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fclose.c
@@ -0,0 +1,35 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fclose.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+int fclose(FILE *fp) {
+ int status = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (10),"b" (fp),"c" (&status)
+ );
+ return(status);
+ }
+
diff --git a/lockwasher/src/lib/libc/stdio/fd.c b/lockwasher/src/lib/libc/stdio/fd.c
new file mode 100644
index 0000000..6b2c4bb
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fd.c
@@ -0,0 +1,32 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fd.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#include
+
+FILE fdTable[3] = {
+ {0}, /* stdin */
+ {1}, /* stdout */
+ {2} /* stderr */
+ };
+
+
diff --git a/lockwasher/src/lib/libc/stdio/fgetc.c b/lockwasher/src/lib/libc/stdio/fgetc.c
new file mode 100644
index 0000000..84f9872
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fgetc.c
@@ -0,0 +1,34 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fgetc.c,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int fgetc(FILE *fd) {
+ volatile int ch = 0;
+ asm(
+ "int %0"
+ :
+ : "i" (0x80),"a" (5),"b" (&ch),"c" (fd)
+ );
+ return(ch);
+ }
diff --git a/lockwasher/src/lib/libc/stdio/fopen.c b/lockwasher/src/lib/libc/stdio/fopen.c
new file mode 100644
index 0000000..72042b5
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fopen.c
@@ -0,0 +1,36 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fopen.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+FILE *fopen(const char *file,const char *mode) {
+ FILE *fp = malloc(sizeof(FILE));
+ fp->fd = -1;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (8),"b" (file),"c" (mode),"d" (fp)
+ );
+ //printf("\0",fp->fd);
+ return((FILE *)fp);
+ }
diff --git a/lockwasher/src/lib/libc/stdio/fprintf.c b/lockwasher/src/lib/libc/stdio/fprintf.c
new file mode 100644
index 0000000..233046d
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fprintf.c
@@ -0,0 +1,31 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fprintf.c,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $
+
+**************************************************************************************/
+
+int fprintf(FILE *fp, const char *fmt, ...) {
+ int retVal;
+ vaList ap;
+ vaStart(ap, fmt);
+ retVal = vfprintf(fp, fmt, ap);
+ vaEnd(ap);
+ return(retVal);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/stdio/fread.c b/lockwasher/src/lib/libc/stdio/fread.c
new file mode 100644
index 0000000..6a15a8b
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fread.c
@@ -0,0 +1,33 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fread.c,v 1.4 2003/03/27 13:30:43 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+size_t fread(void *pointer,size_t size,size_t count, FILE *stream) {
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (22),"b" (pointer),"c" (size * count),"d" (stream)
+ );
+ return(count);
+ }
+
diff --git a/lockwasher/src/lib/libc/stdio/fseek.c b/lockwasher/src/lib/libc/stdio/fseek.c
new file mode 100644
index 0000000..e4b5ad2
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fseek.c
@@ -0,0 +1,32 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fseek.c,v 1.2 2003/05/01 12:30:02 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int fseek(FILE *fd,long offset,int whence) {
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (27),"b" (fd),"c" (offset),"d" (whence)
+ );
+ return(offset+whence);
+ }
diff --git a/lockwasher/src/lib/libc/stdio/fwrite.c b/lockwasher/src/lib/libc/stdio/fwrite.c
new file mode 100644
index 0000000..f537f6a
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/fwrite.c
@@ -0,0 +1,35 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fwrite.c,v 1.5 2003/05/01 12:30:02 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int fwrite(const void *ptr,int size,int nmemb,FILE *fd) {
+ int retVal = size;
+ asm(
+ "int %0"
+ :
+ : "i" (0x80),"a" (23),"b" (ptr),"c" (size*nmemb),"d" (fd)
+ );
+ return(retVal);
+ }
+
diff --git a/lockwasher/src/lib/libc/stdio/gets.c b/lockwasher/src/lib/libc/stdio/gets.c
new file mode 100644
index 0000000..9f8d35c
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/gets.c
@@ -0,0 +1,43 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: gets.c,v 1.3 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+char *gets(char *string) {
+ int count=0,ch=0;
+ while (1) {
+ ch = fgetc(stdin);
+ if(ch == 10) {
+ printf("\n");
+ break;
+ }
+ else if(ch == 8 && count > 0) count-=2;
+ else if(ch == 0) count--;
+ else string[count] = ch;
+ if (ch != 8) printf("%c",ch);
+ count ++;
+ }
+ string[count] = '\0';
+ return(string);
+ }
+
diff --git a/lockwasher/src/lib/libc/stdio/printf.c b/lockwasher/src/lib/libc/stdio/printf.c
new file mode 100644
index 0000000..dd85c7e
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/printf.c
@@ -0,0 +1,36 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: printf.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+int printf(char const *fmt, ...) {
+ int retVal;
+ vaList ap;
+ vaStart(ap, fmt);
+ retVal = vfprintf(stdin, fmt, ap);
+ vaEnd(ap);
+ return(retVal);
+ }
+
+
diff --git a/lockwasher/src/lib/libc/stdio/sprintf.c b/lockwasher/src/lib/libc/stdio/sprintf.c
new file mode 100644
index 0000000..9f5c969
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/sprintf.c
@@ -0,0 +1,34 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: sprintf.c,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#include
+
+int sprintf(char *string, const char *format, ...) {
+ vaList args;
+ int retVal = 0x0;
+ vaStart(args, format);
+ retVal = vsprintf(string,format,args);
+ vaEnd(args)
+ return(retVal);
+ }
+
diff --git a/lockwasher/src/lib/libc/stdio/vfprintf.c b/lockwasher/src/lib/libc/stdio/vfprintf.c
new file mode 100644
index 0000000..193694e
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/vfprintf.c
@@ -0,0 +1,37 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: vfprintf.c,v 1.3 2003/05/01 12:30:02 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+int vfprintf(FILE *fd,const char *fmt,vaList args) {
+ int retVal = 0;
+ char data[1024];
+ retVal = vsprintf(data,fmt,args);
+ asm(
+ "int %0"
+ :
+ : "i" (0x80),"a" (23),"b" (data),"c" (sizeof(data)),"d" (fd)
+ );
+ return(retVal);
+ }
diff --git a/lockwasher/src/lib/libc/stdio/vsprintf.c b/lockwasher/src/lib/libc/stdio/vsprintf.c
new file mode 100644
index 0000000..8754780
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdio/vsprintf.c
@@ -0,0 +1,241 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are prohibited.
+
+ $Id: vsprintf.c,v 1.1.1.1 2003/01/12 00:20:02 reddawg Exp $
+
+**************************************************************************************/
+
+/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
+/*
+ * Wirzenius wrote this portably, Torvalds fucked it up :-)
+ */
+
+#include
+#include
+
+/* we use this so that we can do without the ctype library */
+#define is_digit(c) ((c) >= '0' && (c) <= '9')
+
+static int skip_atoi(const char **s)
+{
+ int i=0;
+
+ while (is_digit(**s))
+ i = i*10 + *((*s)++) - '0';
+ return i;
+}
+
+#define ZEROPAD 1 /* pad with zero */
+#define SIGN 2 /* unsigned/signed long */
+#define PLUS 4 /* show plus */
+#define SPACE 8 /* space if plus */
+#define LEFT 16 /* left justified */
+#define SPECIAL 32 /* 0x */
+#define SMALL 64 /* use 'abcdef' instead of 'ABCDEF' */
+
+#define do_div(n,base) ({ \
+int __res; \
+__asm__("divl %4":"=a" (n),"=d" (__res):"0" (n),"1" (0),"r" (base)); \
+__res; })
+
+static char * number(char * str, int num, int base, int size, int precision
+ ,int type)
+{
+ char c,sign,tmp[36];
+ const char *digits="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ int i;
+
+ if (type&SMALL) digits="0123456789abcdefghijklmnopqrstuvwxyz";
+ if (type&LEFT) type &= ~ZEROPAD;
+ if (base<2 || base>36)
+ return 0;
+ c = (type & ZEROPAD) ? '0' : ' ' ;
+ if (type&SIGN && num<0) {
+ sign='-';
+ num = -num;
+ } else
+ sign=(type&PLUS) ? '+' : ((type&SPACE) ? ' ' : 0);
+ if (sign) size--;
+ if (type&SPECIAL) {
+ if (base==16) { size -= 2; }
+ else if (base==8) { size--; }
+ }
+ i=0;
+ if (num==0)
+ tmp[i++]='0';
+ else while (num!=0)
+ tmp[i++]=digits[do_div(num,base)];
+ if (i>precision) precision=i;
+ size -= precision;
+ if (!(type&(ZEROPAD+LEFT)))
+ while(size-->0)
+ *str++ = ' ';
+ if (sign)
+ *str++ = sign;
+ if (type&SPECIAL) {
+ if (base==8) {
+ *str++ = '0';
+ }
+ else if (base==16) {
+ *str++ = '0';
+ *str++ = digits[33];
+ }
+ }
+ if (!(type&LEFT))
+ while(size-->0)
+ *str++ = c;
+ while(i0)
+ *str++ = tmp[i];
+ while(size-->0)
+ *str++ = ' ';
+ return str;
+}
+
+int vsprintf(char *buf, const char *fmt, vaList args)
+{
+ int len;
+ int i;
+ char * str;
+ char *s;
+ int *ip;
+
+ int flags; /* flags to number() */
+
+ int field_width; /* width of output field */
+ int precision; /* min. # of digits for integers; max
+ number of chars for from string */
+ int qualifier; /* 'h', 'l', or 'L' for integer fields */
+
+ for (str=buf ; *fmt ; ++fmt) {
+ if (*fmt != '%') {
+ *str++ = *fmt;
+ continue;
+ }
+
+ /* process flags */
+ flags = 0;
+ repeat:
+ ++fmt; /* this also skips first '%' */
+ switch (*fmt) {
+ case '-': flags |= LEFT; goto repeat;
+ case '+': flags |= PLUS; goto repeat;
+ case ' ': flags |= SPACE; goto repeat;
+ case '#': flags |= SPECIAL; goto repeat;
+ case '0': flags |= ZEROPAD; goto repeat;
+ }
+
+ /* get field width */
+ field_width = -1;
+ if (is_digit(*fmt))
+ field_width = skip_atoi(&fmt);
+ else if (*fmt == '*') {
+ /* it's the next argument */
+ field_width = vaArg(args, int);
+ if (field_width < 0) {
+ field_width = -field_width;
+ flags |= LEFT;
+ }
+ }
+
+ /* get the precision */
+ precision = -1;
+ if (*fmt == '.') {
+ ++fmt;
+ if (is_digit(*fmt))
+ precision = skip_atoi(&fmt);
+ else if (*fmt == '*') {
+ /* it's the next argument */
+ precision = vaArg(args, int);
+ }
+ if (precision < 0)
+ precision = 0;
+ }
+
+ /* get the conversion qualifier */
+ qualifier = -1;
+ if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
+ qualifier = *fmt;
+ ++fmt;
+ }
+
+ switch (*fmt) {
+ case 'c':
+ if (!(flags & LEFT))
+ while (--field_width > 0)
+ *str++ = ' ';
+ *str++ = (unsigned char) vaArg(args, int);
+ while (--field_width > 0)
+ *str++ = ' ';
+ break;
+
+ case 's':
+ s = vaArg(args, char *);
+ len = strlen(s);
+ if (precision < 0)
+ precision = len;
+ else if (len > precision)
+ len = precision;
+
+ if (!(flags & LEFT))
+ while (len < field_width--)
+ *str++ = ' ';
+ for (i = 0; i < len; ++i)
+ *str++ = *s++;
+ while (len < field_width--)
+ *str++ = ' ';
+ break;
+
+ case 'o':
+ str = number(str, vaArg(args, unsigned long), 8,
+ field_width, precision, flags);
+ break;
+
+ case 'p':
+ if (field_width == -1) {
+ field_width = 8;
+ flags |= ZEROPAD;
+ }
+ str = number(str,
+ (unsigned long) vaArg(args, void *), 16,
+ field_width, precision, flags);
+ break;
+
+ case 'x':
+ flags |= SMALL;
+ case 'X':
+ str = number(str, vaArg(args, unsigned long), 16,
+ field_width, precision, flags);
+ break;
+
+ case 'd':
+ case 'i':
+ flags |= SIGN;
+ case 'u':
+ str = number(str, vaArg(args, unsigned long), 10,
+ field_width, precision, flags);
+ break;
+
+ case 'n':
+ ip = vaArg(args, int *);
+ *ip = (str - buf);
+ break;
+
+ default:
+ if (*fmt != '%')
+ *str++ = '%';
+ if (*fmt)
+ *str++ = *fmt;
+ else
+ --fmt;
+ break;
+ }
+ }
+ *str = '\0';
+ return str-buf;
+}
diff --git a/lockwasher/src/lib/libc/stdlib/Makefile b/lockwasher/src/lib/libc/stdlib/Makefile
new file mode 100644
index 0000000..81b47bb
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdlib/Makefile
@@ -0,0 +1,43 @@
+# $Id: Makefile,v 1.2 2003/04/02 20:27:47 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+CFLAGS = -fno-builtin
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = abs.o exit.o malloc.o
+#Output
+OUTPUT = libc.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall ${CFLAGS} -nostdinc -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall ${CFLAGS} -nostdinc -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall ${CFLAGS} -nostdinc -O -I../include -c $<
+
+.c.s:
+ $(GCC) -Wall ${CFLAGS} -nostdinc -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall ${CFLAGS} -nostdinc -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/stdlib/abs.c b/lockwasher/src/lib/libc/stdlib/abs.c
new file mode 100644
index 0000000..a008c42
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdlib/abs.c
@@ -0,0 +1,5 @@
+#include
+
+int abs(int val) {
+ return(val>0?val:-val);
+ }
diff --git a/lockwasher/src/lib/libc/stdlib/exit.c b/lockwasher/src/lib/libc/stdlib/exit.c
new file mode 100644
index 0000000..3dcb83b
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdlib/exit.c
@@ -0,0 +1,31 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: exit.c,v 1.1.1.1 2003/01/12 00:20:01 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+void exit(int status) {
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (2),"b" (status)
+ );
+ }
diff --git a/lockwasher/src/lib/libc/stdlib/malloc.c b/lockwasher/src/lib/libc/stdlib/malloc.c
new file mode 100644
index 0000000..c0f0621
--- /dev/null
+++ b/lockwasher/src/lib/libc/stdlib/malloc.c
@@ -0,0 +1,203 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: malloc.c,v 1.8 2003/04/16 07:21:11 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+
+struct memDescriptor {
+ struct memDescriptor *prev; //4
+ struct memDescriptor *next; //4
+ void *baseAddr; //4
+ unsigned long limit; //4
+ unsigned char status; //1
+ char reserved[15]; //15
+ };
+
+struct memDescriptor *kernDesc = 0x0;
+struct memDescriptor *freeKernDesc = 0x0;
+struct memDescriptor *emptyKernDesc = 0x0;
+
+void insertFreeDesc(struct memDescriptor *freeDesc);
+
+void initMalloc() {
+ int i=0;
+ struct memDescriptor *tmpDesc1 = 0x0;
+ struct memDescriptor *tmpDesc2 = 0x0;
+ emptyKernDesc = (struct memDescriptor *)getPage(1);
+ tmpDesc1 = emptyKernDesc;
+ tmpDesc1->prev = 0x0;
+ for (i=1;i<((4096/sizeof(struct memDescriptor)));i++) {
+ tmpDesc2 = &emptyKernDesc[i];
+ tmpDesc2->prev = tmpDesc1;
+ tmpDesc1->next = tmpDesc2;
+ tmpDesc1 = tmpDesc2;
+ }
+ tmpDesc1->next = 0x0;
+ //Return
+ return;
+ }
+
+void *getEmptyDesc() {
+ struct memDescriptor *tmpDesc = emptyKernDesc;
+ if (tmpDesc != 0x0) {
+ emptyKernDesc = tmpDesc->next;
+ emptyKernDesc->prev = 0x0;
+ tmpDesc->next = 0x0;
+ tmpDesc->prev = 0x0;
+ return(tmpDesc);
+ }
+ printf("Error Finding Empty Descriptor!\n");
+ return(0x0);
+ }
+
+void *malloc(uInt len) {
+ struct memDescriptor *tmpDesc1 = 0x0;
+ struct memDescriptor *tmpDesc2 = 0x0;
+ //If Kernel Descriptor Is NULL Initialize Malloc
+ if (emptyKernDesc == 0x0) {
+ initMalloc();
+ }
+ len = (len + 15) & 0xFFFFFFF0;
+ for (tmpDesc1 = freeKernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) {
+ if (tmpDesc1->limit >= len) {
+ tmpDesc1->status = 0x1;
+ if (tmpDesc1->prev != 0x0) {
+ tmpDesc1->prev->next = tmpDesc1->next;
+ tmpDesc1->next->prev = tmpDesc1->prev;
+ }
+ else {
+ freeKernDesc = tmpDesc1->next;
+ freeKernDesc->prev = 0x0;
+ }
+ tmpDesc1->prev = 0x0;
+ tmpDesc1->next = kernDesc;
+ kernDesc->prev = tmpDesc1;
+ kernDesc = tmpDesc1;
+ if (tmpDesc1->limit > (len + 16)) {
+ tmpDesc2 = getEmptyDesc();
+ tmpDesc2->limit = tmpDesc1->limit - len;
+ tmpDesc1->limit = len;
+ tmpDesc2->baseAddr = tmpDesc1->baseAddr + len;
+ tmpDesc2->status = 0x0;
+ insertFreeDesc(tmpDesc2);
+ }
+ return(tmpDesc1->baseAddr);
+ }
+ }
+ tmpDesc1 = getEmptyDesc();
+ if (tmpDesc1 != 0x0) {
+ tmpDesc1->baseAddr = (struct memDescriptor *)getPage((len+4095)/4096);
+ tmpDesc1->limit = len;
+ tmpDesc1->status = 0x1;
+ tmpDesc1->next = kernDesc;
+ tmpDesc1->prev = 0x0;
+ if (kernDesc != 0x0) {
+ kernDesc->prev = tmpDesc1;
+ }
+ kernDesc = tmpDesc1;
+ if ((len/4096) > 0) {
+ tmpDesc2 = getEmptyDesc();
+ tmpDesc2->status = 0x0;
+ tmpDesc2->baseAddr = tmpDesc1->baseAddr + tmpDesc1->limit;
+ tmpDesc2->limit = ((len + 4095)/4096)*4096 - tmpDesc1->limit;
+ insertFreeDesc(tmpDesc2);
+ }
+ /*
+ printf("[0x");
+ printf("%X",tmpDesc1->baseAddr);
+ printf("]\n");
+ */
+ return(tmpDesc1->baseAddr);
+ }
+ //Return Null If Unable To Malloc
+ return(0x0);
+ }
+
+void free(void *baseAddr) {
+ long *data = 0x0;
+ long i = 0x0;
+ struct memDescriptor *tmpDesc1 = 0x0;
+ struct memDescriptor *tmpDesc2 = 0x0;
+
+ if (baseAddr == 0x0) {
+ return;
+ }
+ for (tmpDesc1=kernDesc;tmpDesc1;tmpDesc1=tmpDesc1->next) {
+ if (tmpDesc1->baseAddr == baseAddr) {
+ tmpDesc1->status = 0x0;
+ if (tmpDesc1->prev) {
+ tmpDesc2 = tmpDesc1->prev;
+ tmpDesc2->next = tmpDesc1->next;
+ }
+ if (tmpDesc1->next) {
+ tmpDesc2 = tmpDesc1->next;
+ if (tmpDesc2) {
+ tmpDesc2->prev = tmpDesc1->prev;
+ }
+ }
+ if ((kernDesc == tmpDesc1) && (tmpDesc1->prev)) {
+ kernDesc = tmpDesc1->prev;
+ }
+ else {
+ kernDesc = tmpDesc1->next;
+ }
+ insertFreeDesc(tmpDesc1);
+ data = baseAddr;
+ for (i=0;i < (tmpDesc1->limit/4);i++) {
+ data[i] = 0x0;
+ }
+ return;
+ }
+ }
+ printf("Error Freeing User Descriptor! [0x%X]\n",(unsigned int) baseAddr);
+ return;
+ }
+
+void insertFreeDesc(struct memDescriptor *freeDesc) {
+ struct memDescriptor *tmpDesc;
+ freeDesc->status = 0x0;
+ if (freeKernDesc != 0x0) {
+ for (tmpDesc=freeKernDesc;tmpDesc;tmpDesc=tmpDesc->next) {
+ if ((freeDesc->limit >= tmpDesc->limit) && (!tmpDesc->next)) {
+ tmpDesc->next = freeDesc;
+ freeDesc->prev = tmpDesc;
+ freeDesc->next = 0x0;
+ return;
+ }
+ else if ((freeDesc->limit >= tmpDesc->limit) && (freeDesc->limit <= tmpDesc->next->limit)) {
+ freeDesc->next = tmpDesc->next;
+ freeDesc->prev = tmpDesc;
+ tmpDesc->next->prev = freeDesc;
+ tmpDesc->next = freeDesc;
+ return;
+ }
+ }
+ }
+ else {
+ freeDesc->prev = 0x0;
+ freeDesc->next = 0x0;
+ freeKernDesc = freeDesc;
+ }
+ return;
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/string/Makefile b/lockwasher/src/lib/libc/string/Makefile
new file mode 100644
index 0000000..baced8c
--- /dev/null
+++ b/lockwasher/src/lib/libc/string/Makefile
@@ -0,0 +1,42 @@
+# $Id: Makefile,v 1.2 2003/04/23 21:42:34 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = strtok.o memcpy.o memset.o memcmp.o strlen.o
+#Output
+OUTPUT = libc.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) $(CFLAGS) -Wall -nostdinc -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) $(CFLAGS) -Wall -nostdinc -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) $(CFLAGS) -Wall -nostdinc -O -I../include -c $<
+
+.c.s:
+ $(GCC) $(CFLAGS) -Wall -nostdinc -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) $(CFLAGS) -Wall -nostdinc -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/string/memcmp.c b/lockwasher/src/lib/libc/string/memcmp.c
new file mode 100644
index 0000000..266e2c2
--- /dev/null
+++ b/lockwasher/src/lib/libc/string/memcmp.c
@@ -0,0 +1,28 @@
+#include
+#include
+
+int memcmp(const void * dst, const void * src, size_t length)
+{
+ size_t x = length >> 2;
+ size_t y = length & 0xf;
+ size_t i;
+
+ for (i = 0; i < x; i++)
+ {
+ if (((unsigned long *)dst)[i] > ((unsigned long *)src)[i])
+ return 1;
+ if (((unsigned long *)dst)[i] < ((unsigned long *)src)[i])
+ return -1;
+ }
+
+ for (i = 0; i < y; i++)
+ {
+ if (((char *) dst)[length-y+i] > ((char *) src)[length-y+i])
+ return 1;
+ if (((char *) dst)[length-y+i] < ((char *) src)[length-y+i])
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/lockwasher/src/lib/libc/string/memcpy.c b/lockwasher/src/lib/libc/string/memcpy.c
new file mode 100644
index 0000000..e57ba1b
--- /dev/null
+++ b/lockwasher/src/lib/libc/string/memcpy.c
@@ -0,0 +1,18 @@
+#include
+#include
+
+void * memcpy(void * dst, const void * src, size_t length)
+{
+ size_t x = length >> 2;
+ size_t y = length & 0xf;
+ size_t i;
+
+ for (i = 0; i < x; i++)
+ ((unsigned long *)dst)[i] = ((unsigned long *)src)[i];
+
+ for (i = 0; i < y; i++)
+ ((char *) dst)[length-y+i] = ((char *) src)[length-y+i];
+
+ return dst;
+}
+
diff --git a/lockwasher/src/lib/libc/string/memset.c b/lockwasher/src/lib/libc/string/memset.c
new file mode 100644
index 0000000..1acfbd6
--- /dev/null
+++ b/lockwasher/src/lib/libc/string/memset.c
@@ -0,0 +1,20 @@
+#include
+#include
+
+void * memset(void * dst, int c, size_t length)
+{
+ size_t x = length >> 2;
+ size_t y = length & 0xf;
+ size_t i;
+
+ unsigned int newC = (c << 24) | (c << 16) | (c << 8) | (c);
+
+ for (i = 0; i < x; i++)
+ ((unsigned long *)dst)[i] = newC;
+
+ for (i = 0; i < y; i++)
+ ((char *) dst)[length-y+i] = c;
+
+ return dst;
+}
+
diff --git a/lockwasher/src/lib/libc/string/strlen.c b/lockwasher/src/lib/libc/string/strlen.c
new file mode 100644
index 0000000..4febfa7
--- /dev/null
+++ b/lockwasher/src/lib/libc/string/strlen.c
@@ -0,0 +1,16 @@
+#include
+#include
+
+int strlen(const char * string)
+{
+ int i = 0;
+
+ while (1)
+ {
+ if (string[i] == '\0')
+ return i;
+ i++;
+ }
+
+ return 0;
+}
diff --git a/lockwasher/src/lib/libc/string/strtok.c b/lockwasher/src/lib/libc/string/strtok.c
new file mode 100644
index 0000000..da83be4
--- /dev/null
+++ b/lockwasher/src/lib/libc/string/strtok.c
@@ -0,0 +1,71 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: strtok.c,v 1.1 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+
+char *strtok_r(char *s, const char *delim, char **last) {
+ char *spanp;
+ int c, sc;
+ char *tok;
+
+ if ((s == NULL) && ((s = *last) == NULL)) {
+ return(NULL);
+ }
+
+cont:
+ c = *s++;
+ for (spanp = (char *)delim; (sc = *spanp++) != 0; ) {
+ if (c == sc) {
+ goto cont;
+ }
+ }
+ if (c == 0) {
+ *last = NULL;
+ return(NULL);
+ }
+ tok = s - 1;
+
+ for (;;) {
+ c = *s++;
+ spanp = (char *)delim;
+ do {
+ if ((sc = *spanp++) == c) {
+ if (c == 0) {
+ s = NULL;
+ }
+ else {
+ char *w = s - 1;
+ *w = '\0';
+ }
+ *last = s;
+ return(tok);
+ }
+ } while (sc != 0);
+ }
+ }
+
+char *strtok(char *s, const char *delim) {
+ static char *last;
+ return (strtok_r(s, delim, &last));
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/sys/Makefile b/lockwasher/src/lib/libc/sys/Makefile
new file mode 100644
index 0000000..76a955c
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/Makefile
@@ -0,0 +1,43 @@
+# $Id: Makefile,v 1.5 2003/04/18 05:35:24 reddawg Exp $
+# The System Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld -Bshareable
+AR = ar
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = getdrives.o setuid.o setgid.o getuid.o getgid.o exec.o getpid.o fork.o pidstatus.o getpage.o sched.o
+
+#Output
+OUTPUT = sys.so
+
+$(OUTPUT): $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) ${CFLAGS} -Wall -nostdinc -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) ${CFLAGS} -Wall -nostdinc -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) ${CFLAGS} -Wall -nostdinc -O -I../include -c $<
+
+.c.s:
+ $(GCC) ${CFLAGS} -Wall -nostdinc -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) ${CFLAGS} -Wall -nostdinc -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(OUTPUT)
diff --git a/lockwasher/src/lib/libc/sys/exec.c b/lockwasher/src/lib/libc/sys/exec.c
new file mode 100644
index 0000000..9ed33e5
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/exec.c
@@ -0,0 +1,31 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: exec.c,v 1.5 2003/04/24 05:19:30 reddawg Exp $
+
+**************************************************************************************/
+
+int exec(char *file,int argc,char **argv) {
+ int status = 0x1;
+ asm(
+ "int %0 \n"
+ : : "i" (0x80),"a" (3),"b" (argc),"c" (argv),"d" (file)
+ );
+ return(status);
+ }
diff --git a/lockwasher/src/lib/libc/sys/fork.c b/lockwasher/src/lib/libc/sys/fork.c
new file mode 100644
index 0000000..55ef7a8
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/fork.c
@@ -0,0 +1,46 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fork.c,v 1.4 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#include
+
+pid_t fork() {
+ pid_t pid = 0x0;
+ asm(
+ "pushl %%eax\n"
+ "pushl %%ecx\n"
+ "movl $4,%%eax\n"
+ "push %%ss\n"
+ "movl %%esp,%%ecx\n"
+ "sub $4,%%ecx\n"
+ "pushl %%ecx\n"
+ "int $0x80 \n"
+ "popl %%esp\n"
+ "pop %%ax\n"
+ "popl %%ecx\n"
+ "popl %%eax\n"
+ :
+ : "b" (&pid)
+ );
+ return(pid);
+ }
+
diff --git a/lockwasher/src/lib/libc/sys/getdrives.c b/lockwasher/src/lib/libc/sys/getdrives.c
new file mode 100644
index 0000000..76ed8e4
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/getdrives.c
@@ -0,0 +1,11 @@
+#include
+
+
+void *getDrives() {
+ uInt32 ptr = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (45),"b" (&ptr)
+ );
+ return((void *)ptr);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/sys/getgid.c b/lockwasher/src/lib/libc/sys/getgid.c
new file mode 100644
index 0000000..b98f8e3
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/getgid.c
@@ -0,0 +1,33 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: getgid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int getgid(void) {
+ int gid = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (32),"b" (&gid)
+ );
+ return(gid);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/sys/getpage.c b/lockwasher/src/lib/libc/sys/getpage.c
new file mode 100644
index 0000000..b5c87bd
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/getpage.c
@@ -0,0 +1,31 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: getpage.c,v 1.2 2003/04/02 21:45:44 reddawg Exp $
+
+**************************************************************************************/
+
+void *getPage(int count) {
+ long pageAddr = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (7),"b" (&pageAddr),"c" (count)
+ );
+ return((void *)pageAddr);
+ }
diff --git a/lockwasher/src/lib/libc/sys/getpid.c b/lockwasher/src/lib/libc/sys/getpid.c
new file mode 100644
index 0000000..2e13bdc
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/getpid.c
@@ -0,0 +1,34 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: getpid.c,v 1.3 2003/03/20 02:45:13 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int getpid(void) {
+ int pid = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (1),"b" (&pid)
+ );
+ return(pid);
+ }
+
diff --git a/lockwasher/src/lib/libc/sys/getuid.c b/lockwasher/src/lib/libc/sys/getuid.c
new file mode 100644
index 0000000..3ff64c9
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/getuid.c
@@ -0,0 +1,33 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: getuid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int getuid(void) {
+ int uid = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (31),"b" (&uid)
+ );
+ return(uid);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/sys/pidstatus.c b/lockwasher/src/lib/libc/sys/pidstatus.c
new file mode 100644
index 0000000..3835e85
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/pidstatus.c
@@ -0,0 +1,32 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: pidstatus.c,v 1.1.1.1 2003/01/12 00:20:00 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int pidStatus(int pid) {
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (6),"b" (&pid)
+ );
+ return(pid);
+ }
diff --git a/lockwasher/src/lib/libc/sys/sched.c b/lockwasher/src/lib/libc/sys/sched.c
new file mode 100644
index 0000000..7e53359
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/sched.c
@@ -0,0 +1,13 @@
+
+#include
+
+int sched_yield(void)
+{
+ int return_val = 0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (11)
+ );
+ return return_val;
+}
+
diff --git a/lockwasher/src/lib/libc/sys/setgid.c b/lockwasher/src/lib/libc/sys/setgid.c
new file mode 100644
index 0000000..555e6af
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/setgid.c
@@ -0,0 +1,33 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: setgid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int setgid(int gid) {
+ int status = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (34),"b" (gid),"c" (&status)
+ );
+ return(status);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libc/sys/setuid.c b/lockwasher/src/lib/libc/sys/setuid.c
new file mode 100644
index 0000000..27f9168
--- /dev/null
+++ b/lockwasher/src/lib/libc/sys/setuid.c
@@ -0,0 +1,33 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: setuid.c,v 1.1 2003/03/31 15:23:08 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+
+int setuid(int uid) {
+ int status = 0x0;
+ asm(
+ "int %0\n"
+ : : "i" (0x80),"a" (33),"b" (uid),"c" (&status)
+ );
+ return(status);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/lib/libcpp/Makefile b/lockwasher/src/lib/libcpp/Makefile
new file mode 100644
index 0000000..8e8007b
--- /dev/null
+++ b/lockwasher/src/lib/libcpp/Makefile
@@ -0,0 +1,42 @@
+# (C) 2002 The UbixOS Project
+# $Id: Makefile,v 1.1 2003/04/02 18:56:04 reddawg Exp $
+
+CFLAGS = -fno-builtin
+
+# Compiler
+CC = gcc
+CPP = g++
+
+
+# Linker
+LINKER = ld
+
+# Remove
+REMOVE = rm -fr
+
+# Objects
+OBJS = libcpp.o
+
+#Include
+
+INCLUDE = -I./include -I../libc/include
+
+all: $(OBJS)
+
+# Compile Types
+.cpp.o:
+ $(CPP) ${CFLAGS} -Wall -DNOBOOL -fno-rtti -fno-exceptions -g -c $(INCLUDE) -o $@ $<
+.cc.o:
+ $(CPP) ${CFLAGS} -Wall -DNOBOOL -fno-rtti -fno-exceptions -fomit-frame-pointer -O $(INCLUDE) -c -o $@ $<
+.cc.s:
+ $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $<
+.c.o:
+ $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O $(INCLUDE) -c -o $@ $<
+.c.s:
+ $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $<
+.S.o:
+ $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS)
diff --git a/lockwasher/src/lib/libcpp/include/libcpp.h b/lockwasher/src/lib/libcpp/include/libcpp.h
new file mode 100644
index 0000000..78f02c8
--- /dev/null
+++ b/lockwasher/src/lib/libcpp/include/libcpp.h
@@ -0,0 +1,9 @@
+#ifndef __LIBCPP_H
+#define __LIBCPP_H
+
+void * operator new(unsigned size);
+void operator delete(void * ptr);
+void * operator new[](unsigned size);
+void operator delete[](void * ptr);
+
+#endif
diff --git a/lockwasher/src/lib/libcpp/libcpp.cc b/lockwasher/src/lib/libcpp/libcpp.cc
new file mode 100644
index 0000000..b5084a9
--- /dev/null
+++ b/lockwasher/src/lib/libcpp/libcpp.cc
@@ -0,0 +1,33 @@
+extern "C"
+{
+#include
+void __pure_virtual() { while(1); }
+void __cxa_pure_virtual() { while(1); }
+}
+
+#include
+
+void * operator new[](unsigned size)
+{
+ return malloc(size);
+}
+
+void operator delete[](void * ptr)
+{
+ free(ptr);
+
+ return;
+}
+
+void * operator new(unsigned size)
+{
+ return malloc(size);
+}
+
+void operator delete(void * ptr)
+{
+ free(ptr);
+
+ return;
+}
+
diff --git a/lockwasher/src/lib/ubix/Makefile b/lockwasher/src/lib/ubix/Makefile
new file mode 100644
index 0000000..f559a68
--- /dev/null
+++ b/lockwasher/src/lib/ubix/Makefile
@@ -0,0 +1,42 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:20:02 reddawg Exp $
+# Kernel Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = none
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = startup.o
+
+# Make the Binary
+$(BINARY) : $(OBJS)
+
+# Compile the source files
+.cc.o:
+ $(G++) -Wall -fomit-frame-pointer -O -I../libc/include -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O -I../libc/include -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O -I../libc/include -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O -I../libc/include -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY)
diff --git a/lockwasher/src/lib/ubix/startup.c b/lockwasher/src/lib/ubix/startup.c
new file mode 100644
index 0000000..c47bb0a
--- /dev/null
+++ b/lockwasher/src/lib/ubix/startup.c
@@ -0,0 +1,35 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: startup.c,v 1.3 2003/04/23 21:42:34 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+
+extern int main();
+
+void _start(int argc,char **argv) {
+ //int argc = args[0];
+ //char **argv = args[1];
+ char **env = 0x0;
+ exit(main(argc,argv,env));
+ }
diff --git a/lockwasher/src/lib/views/1.DPF b/lockwasher/src/lib/views/1.DPF
new file mode 100644
index 0000000..a02b207
--- /dev/null
+++ b/lockwasher/src/lib/views/1.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/6X6.DPF b/lockwasher/src/lib/views/6X6.DPF
new file mode 100644
index 0000000..bf94b27
--- /dev/null
+++ b/lockwasher/src/lib/views/6X6.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/8X14.DPF b/lockwasher/src/lib/views/8X14.DPF
new file mode 100644
index 0000000..63690a6
--- /dev/null
+++ b/lockwasher/src/lib/views/8X14.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/BLOCK.DPF b/lockwasher/src/lib/views/BLOCK.DPF
new file mode 100644
index 0000000..12f39f7
--- /dev/null
+++ b/lockwasher/src/lib/views/BLOCK.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/BOLD.DPF b/lockwasher/src/lib/views/BOLD.DPF
new file mode 100644
index 0000000..20800b5
--- /dev/null
+++ b/lockwasher/src/lib/views/BOLD.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/BOLD1.DPF b/lockwasher/src/lib/views/BOLD1.DPF
new file mode 100644
index 0000000..fa3e96e
--- /dev/null
+++ b/lockwasher/src/lib/views/BOLD1.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/BROADWAY.DPF b/lockwasher/src/lib/views/BROADWAY.DPF
new file mode 100644
index 0000000..5a524b4
--- /dev/null
+++ b/lockwasher/src/lib/views/BROADWAY.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/COURIER.DPF b/lockwasher/src/lib/views/COURIER.DPF
new file mode 100644
index 0000000..00058b2
--- /dev/null
+++ b/lockwasher/src/lib/views/COURIER.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/CYBER.DPF b/lockwasher/src/lib/views/CYBER.DPF
new file mode 100644
index 0000000..3c4c755
--- /dev/null
+++ b/lockwasher/src/lib/views/CYBER.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/DOTTIE.DPF b/lockwasher/src/lib/views/DOTTIE.DPF
new file mode 100644
index 0000000..2a1828e
--- /dev/null
+++ b/lockwasher/src/lib/views/DOTTIE.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/DP.DPF b/lockwasher/src/lib/views/DP.DPF
new file mode 100644
index 0000000..c3efc73
--- /dev/null
+++ b/lockwasher/src/lib/views/DP.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/FUTURE.DPF b/lockwasher/src/lib/views/FUTURE.DPF
new file mode 100644
index 0000000..baf934d
--- /dev/null
+++ b/lockwasher/src/lib/views/FUTURE.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ITALIC.DPF b/lockwasher/src/lib/views/ITALIC.DPF
new file mode 100644
index 0000000..3f853c6
--- /dev/null
+++ b/lockwasher/src/lib/views/ITALIC.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/KAP.DPF b/lockwasher/src/lib/views/KAP.DPF
new file mode 100644
index 0000000..5913c19
--- /dev/null
+++ b/lockwasher/src/lib/views/KAP.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/LCD.DPF b/lockwasher/src/lib/views/LCD.DPF
new file mode 100644
index 0000000..acfa45c
--- /dev/null
+++ b/lockwasher/src/lib/views/LCD.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/Makefile b/lockwasher/src/lib/views/Makefile
new file mode 100644
index 0000000..e86bc56
--- /dev/null
+++ b/lockwasher/src/lib/views/Makefile
@@ -0,0 +1,46 @@
+# $Id: Makefile,v 1.9 2003/04/13 14:25:19 flameshadow Exp $
+# Kernel Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = g++
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = objgfx
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = objgfx30.o ogFont.o ogSprite.o ogBlit.o vWidget.o vWindow.o
+
+#Include
+INCLUDE = -I./include -I../../lib/libc/include -I../../lib/libcpp/include
+
+# Link the binary
+$(BINARY) : $(OBJS)
+# $(G++) -o $@ $(OBJS)
+
+# Compile the source files
+.cpp.o:
+ $(G++) -Wall -g -fno-builtin -fno-rtti -fno-exceptions -DNOBOOL $(INCLUDE) -c -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O $(INCLUDE) -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O $(INCLUDE) -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY) *.core
diff --git a/lockwasher/src/lib/views/NORMAL.DPF b/lockwasher/src/lib/views/NORMAL.DPF
new file mode 100644
index 0000000..9284622
--- /dev/null
+++ b/lockwasher/src/lib/views/NORMAL.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/NORMAL1.DPF b/lockwasher/src/lib/views/NORMAL1.DPF
new file mode 100644
index 0000000..c7c1829
--- /dev/null
+++ b/lockwasher/src/lib/views/NORMAL1.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/OLDENG.DPF b/lockwasher/src/lib/views/OLDENG.DPF
new file mode 100644
index 0000000..e542aca
--- /dev/null
+++ b/lockwasher/src/lib/views/OLDENG.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/PACMAN.DPF b/lockwasher/src/lib/views/PACMAN.DPF
new file mode 100644
index 0000000..4db8522
--- /dev/null
+++ b/lockwasher/src/lib/views/PACMAN.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/PIGFONT.DPF b/lockwasher/src/lib/views/PIGFONT.DPF
new file mode 100644
index 0000000..8a75a62
--- /dev/null
+++ b/lockwasher/src/lib/views/PIGFONT.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ROM8X14.DPF b/lockwasher/src/lib/views/ROM8X14.DPF
new file mode 100644
index 0000000..376a5ef
--- /dev/null
+++ b/lockwasher/src/lib/views/ROM8X14.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ROM8X16.DPF b/lockwasher/src/lib/views/ROM8X16.DPF
new file mode 100644
index 0000000..dfb28b2
--- /dev/null
+++ b/lockwasher/src/lib/views/ROM8X16.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ROM8X8.DPF b/lockwasher/src/lib/views/ROM8X8.DPF
new file mode 100644
index 0000000..b65b08d
--- /dev/null
+++ b/lockwasher/src/lib/views/ROM8X8.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ROMAN.DPF b/lockwasher/src/lib/views/ROMAN.DPF
new file mode 100644
index 0000000..85dcd69
--- /dev/null
+++ b/lockwasher/src/lib/views/ROMAN.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ROMAN1.DPF b/lockwasher/src/lib/views/ROMAN1.DPF
new file mode 100644
index 0000000..19dc135
--- /dev/null
+++ b/lockwasher/src/lib/views/ROMAN1.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/ROMAN2.DPF b/lockwasher/src/lib/views/ROMAN2.DPF
new file mode 100644
index 0000000..81ac9d3
--- /dev/null
+++ b/lockwasher/src/lib/views/ROMAN2.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/SCRIPT.DPF b/lockwasher/src/lib/views/SCRIPT.DPF
new file mode 100644
index 0000000..8adf710
--- /dev/null
+++ b/lockwasher/src/lib/views/SCRIPT.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/SPECIAL.DPF b/lockwasher/src/lib/views/SPECIAL.DPF
new file mode 100644
index 0000000..7c34d5e
--- /dev/null
+++ b/lockwasher/src/lib/views/SPECIAL.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/SPECIAL1.DPF b/lockwasher/src/lib/views/SPECIAL1.DPF
new file mode 100644
index 0000000..fdb0f86
--- /dev/null
+++ b/lockwasher/src/lib/views/SPECIAL1.DPF
Binary files differ
diff --git a/lockwasher/src/lib/views/defpal.inc b/lockwasher/src/lib/views/defpal.inc
new file mode 100644
index 0000000..fdddf0e
--- /dev/null
+++ b/lockwasher/src/lib/views/defpal.inc
@@ -0,0 +1,259 @@
+const
+ ogRGBA DEFAULT_PALETTE[256] =
+ {{0,0,0,0}, // 0
+ {0,0,170,0},
+ {0,170,0,0},
+ {0,170,170,0}, // 3
+ {170,0,0,0},
+ {170,0,170,0},
+ {170,85,0,0},
+ {170,170,170,0}, // 7
+ {85,85,85,0},
+ {85,85,255,0},
+ {85,255,85,0},
+ {85,255,255,0}, // 11
+ {255,85,85,0},
+ {255,85,255,0},
+ {255,255,85,0},
+ {255,255,255,0}, //15
+ {16,16,16,0}, // 16
+ {32,32,32,0},
+ {48,48,48,0},
+ {64,64,64,0},
+ {80,80,80,0},
+ {96,96,96,0},
+ {112,112,112,0},
+ {128,128,128,0},
+ {144,144,144,0},
+ {160,160,160,0},
+ {176,176,176,0},
+ {192,192,192,0},
+ {208,208,208,0},
+ {224,224,224,0},
+ {240,240,240,0},
+ {255,255,255,0}, //31
+ {59,0,0,0}, // 32
+ {79,0,0,0},
+ {103,0,0,0},
+ {123,0,0,0},
+ {143,7,7,0},
+ {167,7,7,0},
+ {187,11,11,0},
+ {211,15,15,0},
+ {231,19,19,0},
+ {255,27,27,0},
+ {255,59,59,0},
+ {255,91,91,0},
+ {255,119,119,0},
+ {255,151,151,0},
+ {255,183,183,0},
+ {255,215,215,0},
+ {55,55,0,0}, // 48
+ {71,71,0,0},
+ {87,87,0,0},
+ {103,103,7,0},
+ {119,119,7,0},
+ {135,135,11,0},
+ {155,155,19,0},
+ {171,171,23,0},
+ {187,187,31,0},
+ {203,203,35,0},
+ {219,219,43,0},
+ {239,239,59,0},
+ {255,255,63,0},
+ {255,255,127,0},
+ {255,255,187,0},
+ {255,255,255,0},
+ {0,43,0,0}, // 64
+ {0,63,0,0},
+ {0,83,0,0},
+ {0,103,0,0},
+ {7,127,7,0},
+ {7,147,7,0},
+ {11,167,11,0},
+ {15,187,15,0},
+ {19,211,19,0},
+ {27,231,27,0},
+ {59,235,59,0},
+ {91,239,91,0},
+ {127,239,127,0},
+ {159,243,159,0},
+ {195,247,195,0},
+ {231,251,231,0},
+ {0,55,55,0}, // 80
+ {0,71,71,0},
+ {0,87,87,0},
+ {7,103,103,0},
+ {7,119,119,0},
+ {11,135,135,0},
+ {19,155,155,0},
+ {23,171,171,0},
+ {31,187,187,0},
+ {35,203,203,0},
+ {43,219,219,0},
+ {51,235,235,0},
+ {63,255,255,0},
+ {127,255,255,0},
+ {187,255,255,0},
+ {255,255,255,0},
+ {15,15,55,0}, // 96
+ {19,19,79,0},
+ {27,27,103,0},
+ {31,31,127,0},
+ {35,35,155,0},
+ {39,39,179,0},
+ {43,43,203,0},
+ {47,47,227,0},
+ {51,51,255,0},
+ {71,71,255,0},
+ {91,91,255,0},
+ {111,111,255,0},
+ {131,131,255,0},
+ {151,151,255,0},
+ {175,175,255,0},
+ {195,195,255,0},
+ {59,51,59,0}, // 112
+ {79,63,79,0},
+ {103,71,103,0},
+ {123,75,123,0},
+ {143,75,143,0},
+ {167,71,167,0},
+ {187,67,187,0},
+ {211,55,211,0},
+ {231,43,231,0},
+ {255,27,255,0},
+ {255,59,255,0},
+ {255,91,255,0},
+ {255,119,255,0},
+ {255,151,255,0},
+ {255,183,255,0},
+ {255,215,255,0},
+ {59,51,59,0}, // 128
+ {71,59,71,0},
+ {83,71,83,0},
+ {95,83,95,0},
+ {111,95,111,0},
+ {123,103,123,0},
+ {135,115,135,0},
+ {147,127,147,0},
+ {163,139,163,0},
+ {175,151,175,0},
+ {187,159,187,0},
+ {203,171,203,0},
+ {215,183,215,0},
+ {227,191,227,0},
+ {239,203,239,0},
+ {255,215,255,0},
+ {55,27,27,0}, // 144
+ {71,35,35,0},
+ {91,43,43,0},
+ {107,55,55,0},
+ {127,67,67,0},
+ {143,75,75,0},
+ {163,87,87,0},
+ {179,99,99,0},
+ {199,111,111,0},
+ {203,127,127,0},
+ {211,139,139,0},
+ {219,159,159,0},
+ {223,175,175,0},
+ {231,191,191,0},
+ {239,211,211,0},
+ {247,231,231,0},
+ {91,63,27,0}, // 160
+ {111,75,31,0},
+ {127,87,39,0},
+ {147,103,43,0},
+ {167,115,51,0},
+ {187,127,55,0},
+ {207,139,63,0},
+ {227,155,67,0},
+ {247,167,75,0},
+ {247,175,95,0},
+ {247,183,119,0},
+ {247,195,139,0},
+ {247,203,159,0},
+ {247,215,183,0},
+ {247,227,203,0},
+ {251,239,227,0},
+ {63,63,31,0}, // 176
+ {75,75,35,0},
+ {87,87,43,0},
+ {99,99,51,0},
+ {115,115,55,0},
+ {127,127,63,0},
+ {139,139,67,0},
+ {151,151,75,0},
+ {167,167,83,0},
+ {175,175,95,0},
+ {183,183,107,0},
+ {191,191,123,0},
+ {203,203,139,0},
+ {211,211,159,0},
+ {219,219,175,0},
+ {231,231,195,0},
+ {27,59,47,0}, // 192
+ {31,75,59,0},
+ {39,87,67,0},
+ {47,103,79,0},
+ {55,119,91,0},
+ {59,135,99,0},
+ {67,151,111,0},
+ {71,167,119,0},
+ {79,183,127,0},
+ {87,199,139,0},
+ {91,215,147,0},
+ {99,231,155,0},
+ {127,235,183,0},
+ {163,239,211,0},
+ {195,243,231,0},
+ {231,251,247,0},
+ {23,55,55,0}, // 208
+ {31,71,71,0},
+ {39,87,87,0},
+ {47,103,103,0},
+ {55,119,119,0},
+ {67,139,139,0},
+ {75,155,155,0},
+ {87,171,171,0},
+ {99,187,187,0},
+ {111,203,203,0},
+ {123,223,223,0},
+ {143,227,227,0},
+ {163,231,231,0},
+ {183,235,235,0},
+ {203,239,239,0},
+ {227,247,247,0},
+ {39,39,79,0}, // 224
+ {47,47,91,0},
+ {55,55,107,0},
+ {63,63,123,0},
+ {71,71,139,0},
+ {79,79,151,0},
+ {87,87,167,0},
+ {99,99,183,0},
+ {107,107,199,0},
+ {123,123,203,0},
+ {139,139,211,0},
+ {155,155,219,0},
+ {171,171,223,0},
+ {187,187,231,0},
+ {207,207,239,0},
+ {227,227,247,0},
+ {63,27,63,0}, // 240
+ {75,31,75,0},
+ {91,39,91,0},
+ {103,47,103,0},
+ {119,51,119,0},
+ {131,59,131,0},
+ {147,67,147,0},
+ {163,75,163,0},
+ {175,83,175,0},
+ {191,91,191,0},
+ {199,107,199,0},
+ {207,127,207,0},
+ {215,147,215,0},
+ {223,171,223,0},
+ {231,195,231,0},
+ {243,219,243,0}};
+
diff --git a/lockwasher/src/lib/views/include/objgfx30.h b/lockwasher/src/lib/views/include/objgfx30.h
new file mode 100644
index 0000000..2d13c63
--- /dev/null
+++ b/lockwasher/src/lib/views/include/objgfx30.h
@@ -0,0 +1,148 @@
+/**************************************************************
+$Id: objgfx30.h,v 1.7 2003/04/09 05:54:02 flameshadow Exp $
+**************************************************************/
+
+#ifndef OBJGFX30_H
+#define OBJGFX30_H
+
+#include // for NULL, true, false
+
+#define ogVERSION 3.0;
+
+typedef signed char int8;
+typedef signed short int int16;
+typedef signed long int int32;
+typedef signed long long int int64;
+typedef unsigned char uInt8;
+typedef unsigned short int uInt16;
+typedef unsigned long int uInt32;
+typedef unsigned long long int uInt64;
+
+enum ogDataState { ogNONE, ogOWNER, ogALIASING };
+
+struct ogRGB {
+ uInt8 red;
+ uInt8 green;
+ uInt8 blue;
+};
+
+struct ogRGBA {
+ uInt8 red;
+ uInt8 green;
+ uInt8 blue;
+ uInt8 alpha;
+};
+
+struct ogPoint {
+ int32 x;
+ int32 y;
+};
+
+typedef
+ struct ogPixelFmt {
+ uInt8 BPP;
+ uInt8 redFieldPosition;
+ uInt8 greenFieldPosition;
+ uInt8 blueFieldPosition;
+ uInt8 alphaFieldPosition;
+ uInt8 redMaskSize;
+ uInt8 greenMaskSize;
+ uInt8 blueMaskSize;
+ uInt8 alphaMaskSize;
+ };
+
+// Default pixel formats
+
+const ogPixelFmt OG_NULL_PIXFMT = { 0, 0,0,0,0,0,0,0,0};
+const ogPixelFmt OG_PIXFMT_8BPP = { 8, 0,0,0,0,0,0,0,0};
+const ogPixelFmt OG_PIXFMT_15BPP = {15, 10,5,0,15,5,5,5,1};
+const ogPixelFmt OG_PIXFMT_16BPP = {16, 11,5,0,0,5,6,5,0};
+const ogPixelFmt OG_PIXFMT_24BPP = {24, 16,8,0,0,8,8,8,0};
+const ogPixelFmt OG_PIXFMT_32BPP = {32, 16,8,0,24,8,8,8,8};
+const ogPixelFmt OG_MAC_PIXFMT_16BPP = {16, 8,4,0,12,4,4,4,4};
+
+class ogSurface {
+ protected:
+ float version;
+ void* buffer;
+ uInt32* lineOfs;
+ ogRGBA* pal;
+ ogSurface* owner;
+ uInt32 xRes, yRes;
+ uInt32 maxX, maxY;
+ uInt32 bSize; // buffer size (in bytes)
+ uInt32 lSize; // LineOfs size (in bytes)
+ uInt32 transparentColor;
+ ogDataState dataState;
+ uInt32 BPP; // bits per pixel
+ uInt32 redFieldPosition;
+ uInt32 greenFieldPosition;
+ uInt32 blueFieldPosition;
+ uInt32 alphaFieldPosition;
+ uInt32 redShifter;
+ uInt32 greenShifter;
+ uInt32 blueShifter;
+ uInt32 alphaShifter;
+ bool antiAlias;
+ bool clipLine(int32&, int32&, int32&, int32&);
+ virtual void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32);
+ virtual uInt32 rawGetPixel(uInt32, uInt32);
+ virtual void rawSetPixel(uInt32, uInt32, uInt32);
+ void aaRawLine(uInt32, uInt32, uInt32, uInt32, uInt32);
+ public:
+ ogSurface(void);
+ virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32);
+ virtual bool ogAvail(void);
+ void ogArc(int32, int32, uInt32, uInt32, uInt32, uInt32);
+ void ogBSpline(uInt32, ogPoint*, uInt32, uInt32);
+ void ogCircle(int32, int32, uInt32, uInt32);
+ virtual void ogClear(uInt32);
+ virtual bool ogClone(ogSurface&);
+ void ogCopy(ogSurface&);
+ void ogCopyBuf(int32, int32,
+ ogSurface&, int32, int32, int32, int32);
+ virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32);
+ virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32);
+ void ogCopyPal(ogSurface&);
+ virtual bool ogCreate(uInt32, uInt32, ogPixelFmt);
+ void ogCubicBezierCurve(int32, int32, int32, int32,
+ int32, int32, int32, int32, uInt32, uInt32);
+ void ogCurve(int32,int32, int32,int32, int32,int32, uInt32, uInt32);
+ void ogFillCircle(int32, int32, uInt32, uInt32);
+// void ogFillConvexPolygon(uInt32, ogPoint*, uInt32);
+ void ogFillPolygon(uInt32, ogPoint*, uInt32);
+ void ogFillRect(int32, int32, int32, int32, uInt32);
+ void ogFillTriangle(int32,int32, int32,int32, int32,int32, uInt32);
+ bool ogGetAntiAlias(void) const { return antiAlias; }
+ uInt8 ogGetBPP(void) const { return BPP; }
+ ogDataState ogGetDataState(void) const { return dataState; }
+ uInt32 ogGetMaxX(void) const { return maxX; }
+ uInt32 ogGetMaxY(void) const { return maxY; }
+ void ogGetPixFmt(ogPixelFmt&);
+ virtual uInt32 ogGetPixel(int32, int32);
+ virtual void * ogGetPtr(uInt32, uInt32);
+ uInt32 ogGetTransparentColor(void) { return transparentColor; }
+ void ogHFlip(void);
+ virtual void ogHLine(int32, int32, int32, uInt32);
+ void ogLine(int32, int32, int32, int32, uInt32);
+ virtual bool ogLoadPal(const char *);
+ void ogPolygon(uInt32, ogPoint*, uInt32);
+ void ogRect(int32, int32, int32, int32, uInt32);
+ uInt32 ogRGB(uInt8, uInt8, uInt8);
+ bool ogSavePal(const char *);
+ void ogScale(ogSurface&);
+ void ogScaleBuf(int32, int32, int32, int32,
+ ogSurface&, int32, int32, int32, int32);
+ bool ogSetAntiAlias(bool);
+ virtual void ogSetPixel(int32, int32, uInt32);
+ virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8);
+ uInt32 ogSetTransparentColor(uInt32);
+ void ogSpline(uInt32, ogPoint*, uInt32, uInt32);
+ void ogTriangle(int32, int32, int32, int32, int32, int32, uInt32);
+ void ogUnpackRGB(uInt32, uInt8&, uInt8&, uInt8&);
+ virtual void ogVFlip(void);
+ virtual void ogVLine(int32, int32, int32, uInt32);
+ virtual ~ogSurface(void);
+}; // ogSurface
+
+#endif
diff --git a/lockwasher/src/lib/views/include/ogBlit.h b/lockwasher/src/lib/views/include/ogBlit.h
new file mode 100644
index 0000000..7788ae0
--- /dev/null
+++ b/lockwasher/src/lib/views/include/ogBlit.h
@@ -0,0 +1,28 @@
+#ifndef OGBLIT_H
+#define OGBLIT_H
+
+#include "ogSprite.h"
+
+class ogBlit: public ogSprite {
+ protected:
+ uInt8 * blitMask;
+ uInt32 blitMaskSize;
+ uInt32 totalPixCount;
+ int32 startX, startY;
+ int32 endX, endY;
+
+ void blitSize(ogSurface&, int32, int32, int32, int32);
+ void getBlitMask(ogSurface&, int32, int32);
+ public:
+ ogBlit(void);
+ virtual void get(ogSurface&, int32, int32, int32, int32);
+ void getBlitWithMask(ogSurface&, int32, int32);
+ uInt32 getBlitMaskSize(void) { return blitMaskSize; }
+ virtual uInt32 getSize(void);
+ virtual bool loadFrom(const char *, uInt32);
+ virtual void put(ogSurface&, int32, int32);
+ virtual bool saveTo(const char *, int32);
+ virtual ~ogBlit(void);
+}; // ogBlit
+
+#endif
diff --git a/lockwasher/src/lib/views/include/ogDisplay_UbixOS.h b/lockwasher/src/lib/views/include/ogDisplay_UbixOS.h
new file mode 100644
index 0000000..4e301de
--- /dev/null
+++ b/lockwasher/src/lib/views/include/ogDisplay_UbixOS.h
@@ -0,0 +1,80 @@
+#ifndef OGDISPLAY_UBIXOS_H
+#define OGDISPLAY_UBIXOS_H
+
+#include "objgfx30.h"
+
+struct ogMode_Rec {
+ uInt16 ModeAttributes __attribute__((packed));
+ uInt8 WindowAFlags __attribute__((packed));
+ uInt8 WindowBFlags __attribute__((packed));
+ uInt16 Granularity __attribute__((packed));
+ uInt16 WindowSize __attribute__((packed));
+ uInt16 WindowASeg __attribute__((packed));
+ uInt16 WindowBSeg __attribute__((packed));
+ void* BankSwitch __attribute__((packed));
+ uInt16 BytesPerLine __attribute__((packed));
+ uInt16 xRes __attribute__((packed));
+ uInt16 yRes __attribute__((packed));
+ uInt8 CharWidth __attribute__((packed));
+ uInt8 CharHeight __attribute__((packed));
+ uInt8 NumBitPlanes __attribute__((packed));
+ uInt8 BitsPerPixel __attribute__((packed));
+ uInt8 NumberOfBanks __attribute__((packed));
+ uInt8 MemoryModel __attribute__((packed));
+ uInt8 BankSize __attribute__((packed));
+ uInt8 NumOfImagePages __attribute__((packed));
+ uInt8 Reserved __attribute__((packed));
+ // Direct colour fields (required for Direct/6 and YUV/7 memory models
+ uInt8 RedMaskSize __attribute__((packed));
+ uInt8 RedFieldPosition __attribute__((packed));
+ uInt8 GreenMaskSize __attribute__((packed));
+ uInt8 GreenFieldPosition __attribute__((packed));
+ uInt8 BlueMaskSize __attribute__((packed));
+ uInt8 BlueFieldPosition __attribute__((packed));
+ uInt8 AlphaMaskSize __attribute__((packed));
+ uInt8 AlphaFieldPosition __attribute__((packed));
+ uInt8 DirectColourMode __attribute__((packed));
+ // VESA 2.0 specific fields
+ uInt32 physBasePtr __attribute__((packed));
+ void* OffScreenMemOffset __attribute__((packed));
+ uInt16 OffScreenMemSize __attribute__((packed));
+ uInt8 paddington[461] __attribute__((packed));
+};
+
+struct ogVESA_Rec {
+ char VBESignature[4] __attribute__((packed));
+ uInt8 minVersion __attribute__((packed));
+ uInt8 majVersion __attribute__((packed));
+ uInt32 OEMStringPtr __attribute__((packed));
+ uInt32 Capabilities __attribute__((packed));
+ uInt32 VideoModePtr __attribute__((packed));
+ uInt16 TotalMemory __attribute__((packed));
+ // VESA 2.0 specific fields
+ uInt16 OEMSoftwareRev __attribute__((packed));
+ uInt32 OEMVendorNamePtr __attribute__((packed));
+ uInt32 OEMProductNamePtr __attribute__((packed));
+ uInt32 OEMProductRevPtr __attribute__((packed));
+ uInt8 paddington[474] __attribute__((packed));
+};
+
+class ogDisplay_UbixOS : public ogSurface {
+ protected:
+ ogVESA_Rec* VESARec;
+ ogMode_Rec* modeRec;
+ uInt16 findMode(uInt32, uInt32, uInt32);
+ void getModeInfo(uInt16);
+ void getVESAInfo(void);
+ void setMode(uInt16);
+ void setPal(void);
+ public:
+ ogDisplay_UbixOS(void);
+ virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32);
+ virtual bool ogClone(ogSurface&);
+ virtual void ogCopyPal(ogSurface&);
+ virtual bool ogCreate(uInt32, uInt32, ogPixelFmt);
+ virtual bool ogLoadPal(const char *);
+ virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8);
+ virtual ~ogDisplay_UbixOS(void);
+}; // ogDisplay_UbixOS
+
+#endif
diff --git a/lockwasher/src/lib/views/include/ogDisplay_VESA.h b/lockwasher/src/lib/views/include/ogDisplay_VESA.h
new file mode 100644
index 0000000..69c8de3
--- /dev/null
+++ b/lockwasher/src/lib/views/include/ogDisplay_VESA.h
@@ -0,0 +1,95 @@
+#ifndef OGDISPLAY_VESA_H
+#define OGDISPLAY_VESA_H
+
+#include "objgfx30.h"
+
+struct ogMode_Rec {
+ uInt16 ModeAttributes __attribute__((packed));
+ uInt8 WindowAFlags __attribute__((packed));
+ uInt8 WindowBFlags __attribute__((packed));
+ uInt16 Granularity __attribute__((packed));
+ uInt16 WindowSize __attribute__((packed));
+ uInt16 WindowASeg __attribute__((packed));
+ uInt16 WindowBSeg __attribute__((packed));
+ void* BankSwitch __attribute__((packed));
+ uInt16 BytesPerLine __attribute__((packed));
+ uInt16 xRes __attribute__((packed));
+ uInt16 yRes __attribute__((packed));
+ uInt8 CharWidth __attribute__((packed));
+ uInt8 CharHeight __attribute__((packed));
+ uInt8 NumBitPlanes __attribute__((packed));
+ uInt8 BitsPerPixel __attribute__((packed));
+ uInt8 NumberOfBanks __attribute__((packed));
+ uInt8 MemoryModel __attribute__((packed));
+ uInt8 BankSize __attribute__((packed));
+ uInt8 NumOfImagePages __attribute__((packed));
+ uInt8 Reserved __attribute__((packed));
+ // Direct colour fields (required for Direct/6 and YUV/7 memory models
+ uInt8 RedMaskSize __attribute__((packed));
+ uInt8 RedFieldPosition __attribute__((packed));
+ uInt8 GreenMaskSize __attribute__((packed));
+ uInt8 GreenFieldPosition __attribute__((packed));
+ uInt8 BlueMaskSize __attribute__((packed));
+ uInt8 BlueFieldPosition __attribute__((packed));
+ uInt8 AlphaMaskSize __attribute__((packed));
+ uInt8 AlphaFieldPosition __attribute__((packed));
+ uInt8 DirectColourMode __attribute__((packed));
+ // VESA 2.0 specific fields
+ uInt32 physBasePtr __attribute__((packed));
+ void* OffScreenMemOffset __attribute__((packed));
+ uInt16 OffScreenMemSize __attribute__((packed));
+ uInt8 paddington[461] __attribute__((packed));
+};
+
+struct ogVESA_Rec {
+ char VBESignature[4] __attribute__((packed));
+ uInt8 minVersion __attribute__((packed));
+ uInt8 majVersion __attribute__((packed));
+ uInt32 OEMStringPtr __attribute__((packed));
+ uInt32 Capabilities __attribute__((packed));
+ uInt32 VideoModePtr __attribute__((packed));
+ uInt16 TotalMemory __attribute__((packed));
+ // VESA 2.0 specific fields
+ uInt16 OEMSoftwareRev __attribute__((packed));
+ uInt32 OEMVendorNamePtr __attribute__((packed));
+ uInt32 OEMProductNamePtr __attribute__((packed));
+ uInt32 OEMProductRevPtr __attribute__((packed));
+ uInt8 paddington[474] __attribute__((packed));
+};
+
+class ogDisplay_VESA : public ogSurface {
+ protected:
+ uInt16 ScreenSelector;
+ ogVESA_Rec* VESARec;
+ ogMode_Rec* modeRec;
+ bool InGraphics;
+ uInt16 findMode(uInt32, uInt32, uInt32);
+ void getModeInfo(uInt16);
+ void getVESAInfo(void);
+ void setMode(uInt16);
+ virtual uInt32 rawGetPixel(uInt32, uInt32);
+ virtual void rawSetPixel(uInt32, uInt32, uInt32);
+ virtual void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32);
+ void setPal(void);
+ public:
+ ogDisplay_VESA(void);
+ virtual bool ogAvail(void);
+ virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32);
+ virtual void ogClear(uInt32);
+ virtual bool ogClone(ogSurface&);
+ virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32);
+ virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32);
+ virtual void ogCopyPal(ogSurface&);
+ virtual bool ogCreate(uInt32, uInt32, ogPixelFmt);
+ virtual uInt32 ogGetPixel(int32, int32);
+ virtual void * ogGetPtr(uInt32, uInt32);
+ virtual void ogHLine(int32, int32, int32, uInt32);
+ virtual bool ogLoadPal(const char *);
+ virtual void ogSetPixel(int32, int32, uInt32);
+ virtual void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8);
+ virtual void ogVFlip(void);
+ virtual void ogVLine(int32, int32, int32, uInt32);
+ virtual ~ogDisplay_VESA(void);
+}; // ogDisplay_VESA
+
+#endif
diff --git a/lockwasher/src/lib/views/include/ogFont.h b/lockwasher/src/lib/views/include/ogFont.h
new file mode 100644
index 0000000..d060b33
--- /dev/null
+++ b/lockwasher/src/lib/views/include/ogFont.h
@@ -0,0 +1,55 @@
+#ifndef OGFONT_H
+#define OGFONT_H
+
+#include "objgfx30.h"
+
+#define LeftText 0
+#define CenterText 1
+#define RightText 2
+#define BottomText 0
+#define TopText 2
+
+typedef
+ struct {
+ char ID[3];
+ uInt8 version;
+ uInt8 width, height;
+ uInt8 numOfChars;
+ uInt8 startingChar;
+ uInt8 colourType;
+ uInt8 paddington[7];
+ } ogDPFHeader;
+
+class ogBitFont {
+ protected:
+ uInt32 fontDataIdx[256];
+ uInt32 charWidthTable[256];
+ uInt32 charHeightTable[256];
+ void * fontData;
+ uInt32 fontDataSize;
+ ogRGB BGColour;
+ ogRGB FGColour;
+ uInt8 width, height;
+ uInt16 numOfChars;
+ uInt8 startingChar;
+
+ public:
+ ogBitFont();
+ void putChar(ogSurface&, int32, int32, const char);
+ void putString(ogSurface&, int32, int32, const char *);
+ void setBGColor(uInt8, uInt8, uInt8);
+ void setFGColor(uInt8, uInt8, uInt8);
+ uInt32 getWidth(void) const { return width; };
+ uInt32 getHeight(void) const { return height; };
+ bool loadFrom(const char *, uInt32);
+ bool saveTo(const char *, int32);
+ void centerTextX(ogSurface&, int32, const char *);
+ void justifyText(ogSurface&, uInt8, uInt8, const char *);
+ bool load(const char *);
+ bool save(const char *);
+ uInt32 textHeight(const char *) const { return height; };
+ uInt32 textWidth(const char *);
+ ~ogBitFont(void);
+}; // ogBitFont
+
+#endif
diff --git a/lockwasher/src/lib/views/include/ogSprite.h b/lockwasher/src/lib/views/include/ogSprite.h
new file mode 100644
index 0000000..3e3315f
--- /dev/null
+++ b/lockwasher/src/lib/views/include/ogSprite.h
@@ -0,0 +1,39 @@
+#ifndef OGSPRITE_H
+#define OGSPRITE_H
+
+#include "objgfx30.h"
+
+class ogSprite {
+ protected:
+ void * image;
+ uInt32 imageSize;
+ ogRGBA* pal;
+ uInt32 width, height;
+ uInt32 bitDepth; // make this 32-bit just for alignment purposes
+ uInt32 RFP;
+ uInt32 GFP;
+ uInt32 BFP;
+ uInt32 AFP;
+ uInt32 RShift;
+ uInt32 GShift;
+ uInt32 BShift;
+ uInt32 AShift;
+ uInt32 tColour; // original transparent colour
+ uInt32 getPixel(void *);
+ void setPixel(void *, uInt32);
+ void unpackRGB(uInt32, uInt8&, uInt8&, uInt8&);
+ public:
+ ogSprite(void);
+ void get(ogSurface&, int32, int32, int32, int32);
+ uInt32 getHeight(void) { return height; }
+ uInt32 getSize(void);
+ uInt32 getWidth(void) { return width; }
+ bool load(const char *);
+ virtual bool loadFrom(const char *, uInt32);
+ virtual void put(ogSurface&, int32, int32);
+ bool save(const char *);
+ virtual bool saveTo(const char *, int32);
+ virtual ~ogSprite(void);
+
+}; // ogSprite
+#endif
diff --git a/lockwasher/src/lib/views/include/vWidget.h b/lockwasher/src/lib/views/include/vWidget.h
new file mode 100644
index 0000000..7a15dc5
--- /dev/null
+++ b/lockwasher/src/lib/views/include/vWidget.h
@@ -0,0 +1,17 @@
+#ifndef VWIDGET_H
+#define VWIDGET_H
+
+#include "objgfx30.h"
+
+class vWidget : public ogSurface {
+ protected:
+ bool active;
+ public:
+ vWidget(void) { active = true; }
+ virtual void vDraw(void) = 0;
+ virtual bool vGetActive(void) const { return active; }
+ virtual bool vSetActive(bool);
+ virtual bool vCreate(void) = 0;
+};
+
+#endif
diff --git a/lockwasher/src/lib/views/include/vWindow.h b/lockwasher/src/lib/views/include/vWindow.h
new file mode 100644
index 0000000..3218261
--- /dev/null
+++ b/lockwasher/src/lib/views/include/vWindow.h
@@ -0,0 +1,19 @@
+#ifndef VWINDOW_H
+#define VWINDOW_H
+
+#include
+#include
+#include "vWidget.h"
+
+class vWindow : public vWidget {
+ protected:
+ ogSurface * realWindow;
+ ogBitFont * titleFont;
+ public:
+ vWindow(void);
+ virtual void vDraw(void) { return; }
+ virtual bool vCreate(void);
+ void vSDECommand(uInt32);
+ virtual ~vWindow(void);
+};
+#endif
diff --git a/lockwasher/src/lib/views/main.cpp b/lockwasher/src/lib/views/main.cpp
new file mode 100644
index 0000000..5bca6db
--- /dev/null
+++ b/lockwasher/src/lib/views/main.cpp
@@ -0,0 +1,483 @@
+/**********************************************************************
+will add copyright bs later
+
+$Id: main.cpp,v 1.2 2003/04/02 19:23:21 flameshadow Exp $
+**********************************************************************/
+
+#include "objgfx30.h"
+#include "ogFont.h"
+#include "ogSprite.h"
+#include "ogBlit.h"
+// #include "ogDisplay_VESA.h"
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+void testSetPixel(ogSurface& buf) {
+ uInt32 xx,yy;
+ buf.ogClear(buf.ogRGB(0,255,0));
+ for (yy = 0; yy<=buf.ogGetMaxY(); yy++)
+ for (xx = 0; xx<=buf.ogGetMaxX(); xx++)
+ buf.ogSetPixel(xx,yy,xx*yy);
+ getc(stdin);
+ return;
+} // testSetPixel
+
+void testRect(ogSurface& buf) {
+ uInt32 count;
+ if (buf.ogGetBPP()==8)
+ for (count=0; count<1000; count++)
+ buf.ogRect(buf.ogGetMaxX() / 2 - count, buf.ogGetMaxY() / 2 - count,
+ buf.ogGetMaxX() / 2 + count, buf.ogGetMaxY() / 2 + count,
+ count);
+ else
+ for (count=0; count<1000; count++)
+ buf.ogRect(buf.ogGetMaxX() / 2 - count, buf.ogGetMaxY() / 2 - count,
+ buf.ogGetMaxX() / 2 + count, buf.ogGetMaxY() / 2 + count,
+ buf.ogRGB(count,count,count));
+ getc(stdin);
+ return;
+} // testRect
+
+void testLine(ogSurface & buf) {
+ uInt32 count;
+ uInt32 colour;
+ buf.ogClear(0);
+ if (buf.ogGetBPP()==8)
+ for (count=0; count<(buf.ogGetMaxX()+1); count+=2) {
+ buf.ogLine(count,0,buf.ogGetMaxX()-count,buf.ogGetMaxY(),count);
+ } // for
+ else {
+ colour = 255;
+ for (count = 0; count < (buf.ogGetMaxX()+1)/2; count+=4) {
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ buf.ogGetMaxX()/2-count,buf.ogGetMaxY(),
+ buf.ogRGB(colour,colour,colour));
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ buf.ogGetMaxX()/2+count,buf.ogGetMaxY(),
+ buf.ogRGB(colour,colour,colour));
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ buf.ogGetMaxX()/2-count,0,
+ buf.ogRGB(0,colour,0));
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ buf.ogGetMaxX()/2+count,0,
+ buf.ogRGB(0,colour,0));
+
+ --colour;
+ } // for
+
+ colour = 255;
+ for (count = 0; count < (buf.ogGetMaxY()+1)/2; count+=4) {
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ 0, buf.ogGetMaxY()/2-count,
+ buf.ogRGB(colour,0,0));
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ 0, buf.ogGetMaxY()/2+count,
+ buf.ogRGB(colour,0,0));
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ buf.ogGetMaxX(), buf.ogGetMaxY()/2-count,
+ buf.ogRGB(0,0,colour));
+ buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2,
+ buf.ogGetMaxX(), buf.ogGetMaxY()/2+count,
+ buf.ogRGB(0,0,colour));
+ --colour;
+ } // for
+ } // else
+ getc(stdin);
+ return;
+} // testLine
+
+void testClear(ogSurface & buf) {
+ uInt32 count;
+ if (buf.ogGetBPP()==8)
+ for (count=0; count<256; count++)
+ buf.ogClear(count);
+ else {
+ for (count=0; count<256; count+=8)
+ buf.ogClear(buf.ogRGB(count,0,0));
+ for (count=0; count<256; count+=8)
+ buf.ogClear(buf.ogRGB(0,count,0));
+ for (count=0; count<256; count+=8)
+ buf.ogClear(buf.ogRGB(0,0,count));
+ for (count=0; count<256; count+=8)
+ buf.ogClear(buf.ogRGB(count,count,count));
+ } // else
+ getc(stdin);
+ return;
+} // testClear
+
+void testCircle(ogSurface & buf) {
+ uInt32 count;
+ if (buf.ogGetBPP()==8)
+ for (count=0; count<1000; count++)
+ buf.ogCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2, count, count);
+ else
+ for (count=0; count<1000; count++)
+ buf.ogCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2,count,buf.ogRGB(count,0,count));
+ getc(stdin);
+} // testCircle
+
+void testVFlip(ogSurface & buf) {
+ buf.ogVFlip();
+ getc(stdin);
+ return;
+} // testVFlip
+
+void testHFlip(ogSurface & buf) {
+ buf.ogHFlip();
+ getc(stdin);
+ return;
+} // testHFlip
+
+void testArc(ogSurface & buf) {
+ uInt32 radius;
+ uInt32 mid_x, mid_y;
+ mid_x = buf.ogGetMaxX()/2;
+ mid_y = buf.ogGetMaxY()/2;
+ if (buf.ogGetBPP()==8) {
+ for (radius = 1; radius <9; radius++) {
+ buf.ogArc(mid_x, mid_y, radius*10, 0, 90, radius*15);
+ buf.ogArc(mid_x, mid_y, radius*10, 180,270, 249-(radius-1)*16);
+ } // for
+ } else {
+ for (radius = 1; radius <255; radius++) {
+ buf.ogArc(mid_x, mid_y, radius, 0, 90, buf.ogRGB(radius,radius,0));
+ buf.ogArc(mid_x, mid_y, radius, 180,270,buf.ogRGB(0,255-radius,255-radius));
+ } // for
+ } // else
+ getchar();
+ return;
+} // testArc
+
+void testCubicBezierCurve(ogSurface & buf) {
+ buf.ogCubicBezierCurve(100, 100,
+ 300,50,
+ 400,120,
+ 350,300,
+ 25, buf.ogRGB(255,255,255));
+ getchar();
+ return;
+} // testCubicBezierCurve
+
+void testCurve(ogSurface & buf) {
+ buf.ogCurve(10,10,100,30,35,160,20,buf.ogRGB(255,255,255));
+ getchar();
+ return;
+} // testCurve
+void testSprite(ogSurface & buf) {
+ uInt32 count;
+ uInt32 w,h;
+ ogSprite * sprite = NULL;
+ sprite = new ogSprite();
+
+ buf.ogClear(0);
+ testLine(buf);
+ if (buf.ogGetBPP()==8)
+ sprite->get(buf,
+ buf.ogGetMaxX()/2-80,buf.ogGetMaxY()/2-80,
+ buf.ogGetMaxX()/2+80,buf.ogGetMaxY()/2+80);
+ else
+ sprite->get(buf,
+ buf.ogGetMaxX()/2-150,buf.ogGetMaxY()/2-150,
+ buf.ogGetMaxX()/2+150,buf.ogGetMaxY()/2+150);
+
+ sprite->save("test.spr");
+ delete sprite;
+ sprite = new ogSprite();
+ sprite->load("test.spr");
+ w = sprite->getWidth()/2;
+ h = sprite->getHeight()/2;
+ buf.ogClear(0);
+ sprite->put(buf,-10000,-10000); // test *really* off the screen
+ sprite->put(buf,10000,10000); // test *really* off the screen
+
+ sprite->put(buf,buf.ogGetMaxX()/2-w,buf.ogGetMaxY()/2-h);
+ sprite->put(buf,-w,-h);
+ sprite->put(buf,buf.ogGetMaxX()/2-w,-h);
+ sprite->put(buf,buf.ogGetMaxX()-w,-h);
+ sprite->put(buf,-w,buf.ogGetMaxY()/2-h);
+ sprite->put(buf,buf.ogGetMaxX()-w,buf.ogGetMaxY()/2-h);
+ sprite->put(buf,-w,buf.ogGetMaxY()-h);
+ sprite->put(buf,buf.ogGetMaxX()/2-w,buf.ogGetMaxY()-h);
+ sprite->put(buf,buf.ogGetMaxX()-w,buf.ogGetMaxY()-h);
+ getc(stdin);
+ for (count = 0; count < 256; count++) {
+ sprite->put(buf,random() % (buf.ogGetMaxX()+sprite->getWidth()) - sprite->getWidth(),
+ random() % (buf.ogGetMaxY()+sprite->getHeight()) - sprite->getHeight());
+ } // for
+ delete sprite;
+ getc(stdin);
+ return;
+} // testSprite
+
+void testBlit(ogSurface & buf) {
+ int32 xx, yy, count;
+ ogBlit * blit = NULL;
+ blit = new ogBlit();
+ buf.ogClear(0);
+ for (xx= 0; xx<= 20; xx++) {
+ buf.ogLine(128,0,128-xx*6,255,buf.ogRGB(255,255,255));
+ buf.ogLine(128,0,128+xx*6,255,buf.ogRGB(255,255,255));
+ buf.ogLine(128,255,128-xx*6,0,buf.ogRGB(255,255,255));
+ buf.ogLine(128,255,128+xx*6,0,buf.ogRGB(255,255,255));
+ } // for
+
+ buf.ogFillCircle(128,128,60,buf.ogRGB(255,255,255));
+ blit->get(buf,0,0,255,255);
+ for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++)
+ for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++)
+ buf.ogSetPixel(xx,yy,xx*yy);
+ blit->save("test.blt");
+ delete blit;
+ blit = new ogBlit();
+ blit->load("test.blt");
+
+ blit->put(buf,-10000,-10000); // test *really* off the screen
+ blit->put(buf,10000,10000); // test *really* off the screen
+
+ blit->put(buf,-128,-128);
+ blit->put(buf,buf.ogGetMaxX()/2-128,-128);
+ blit->put(buf,buf.ogGetMaxX()-128,-128);
+ blit->put(buf,-128,buf.ogGetMaxY()/2-128);
+ blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128);
+ blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()/2-128);
+ blit->put(buf,-128,buf.ogGetMaxY()-128);
+ blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()-128);
+ blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()-128);
+
+ getc(stdin);
+ buf.ogClear(0);
+ for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++)
+ for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++)
+ buf.ogSetPixel(xx,yy,xx*yy);
+ blit->getBlitWithMask(buf,
+ buf.ogGetMaxX()/2-blit->getWidth(),
+ buf.ogGetMaxY()/2-blit->getHeight());
+ buf.ogClear(0);
+ blit->put(buf,-10000,-10000); // test *really* off the screen
+ blit->put(buf,10000,10000); // test *really* off the screen
+
+ blit->put(buf,-128,-128);
+ blit->put(buf,buf.ogGetMaxX()/2-128,-128);
+ blit->put(buf,buf.ogGetMaxX()-128,-128);
+ blit->put(buf,-128,buf.ogGetMaxY()/2-128);
+ blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128);
+ blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()/2-128);
+ blit->put(buf,-128,buf.ogGetMaxY()-128);
+ blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()-128);
+ blit->put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()-128);
+
+ getc(stdin);
+ for (count = 0; count < 1000; count++) {
+ blit->put(buf,random() % (buf.ogGetMaxX()+blit->getWidth()) - blit->getWidth(),
+ random() % (buf.ogGetMaxY()+blit->getHeight()) - blit->getHeight());
+ } // for
+ getc(stdin);
+ for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++)
+ for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++)
+ buf.ogSetPixel(xx,yy,xx*yy);
+
+ blit->getBlitWithMask(buf,buf.ogGetMaxX()/2,buf.ogGetMaxY()-128);
+ buf.ogClear(buf.ogRGB(128,128,128));
+ blit->put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128);
+ getc(stdin);
+ delete blit;
+
+ return;
+} // testBlit
+
+void
+testBlit2(ogSurface & buf) {
+ ogBlit * blit = new ogBlit();
+ ogSurface * buf2 = new ogSurface();
+ ogSurface * blitsource = new ogSurface();
+ uInt32 xx,yy,count,colour;
+ buf.ogClear(0);
+ buf2->ogClone(buf);
+ blitsource->ogClone(buf);
+
+ colour = 255;
+ for (count = 0; count < (buf2->ogGetMaxX()+1)/2; count+=4) {
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ buf2->ogGetMaxX()/2-count,buf2->ogGetMaxY(),
+ buf2->ogRGB(colour,colour,colour));
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ buf2->ogGetMaxX()/2+count,buf2->ogGetMaxY(),
+ buf2->ogRGB(colour,colour,colour));
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ buf2->ogGetMaxX()/2-count,0,
+ buf2->ogRGB(0,colour,0));
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ buf2->ogGetMaxX()/2+count,0,
+ buf2->ogRGB(0,colour,0));
+ --colour;
+ } // for
+
+ colour = 255;
+ for (count = 0; count < (buf.ogGetMaxY()+1)/2; count+=4) {
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ 0, buf2->ogGetMaxY()/2-count,
+ buf2->ogRGB(colour,0,0));
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ 0, buf2->ogGetMaxY()/2+count,
+ buf2->ogRGB(colour,0,0));
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ buf2->ogGetMaxX(), buf2->ogGetMaxY()/2-count,
+ buf2->ogRGB(0,0,colour));
+ buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2,
+ buf2->ogGetMaxX(), buf2->ogGetMaxY()/2+count,
+ buf2->ogRGB(0,0,colour));
+ --colour;
+ } // for
+ for (yy = 0; yy<=buf2->ogGetMaxY(); yy++)
+ for (xx = 0; xx<=buf2->ogGetMaxX(); xx++)
+ buf2->ogSetPixel(xx,yy,xx*yy);
+ for (count = 0; count<200; count++)
+ blitsource->ogFillCircle(random() % blitsource->ogGetMaxX(), random() % blitsource->ogGetMaxY(),
+ random() % 35+1,blitsource->ogRGB(255,255,255));
+
+ blit->get(*blitsource,0,0,blitsource->ogGetMaxX(),blitsource->ogGetMaxY());
+ blit->save("bigblit.blt");
+ delete blit;
+ blit = new ogBlit;
+ blit->load("bigblit.blt");
+ for (count = 0; count<=256; count+=4) {
+ for (yy = 0; yy<=buf2->ogGetMaxY(); yy++)
+ for (xx = 0; xx<=buf2->ogGetMaxX(); xx++)
+ buf2->ogSetPixel(xx,yy,xx*yy*count);
+
+ blit->getBlitWithMask(*buf2,0,0);
+ blit->put(buf,0,0);
+ } // for
+
+ getc(stdin);
+ delete blitsource;
+ delete buf2;
+ delete blit;
+ return;
+} // testBlit2
+
+void
+testBlit3(ogSurface & buf) {
+ int32 count;
+ ogBlit * blit = NULL;
+ ogSurface * buf2 = NULL;
+ buf2 = new ogSurface();
+ blit = new ogBlit();
+ buf.ogClear(0);
+ buf.ogFillCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2,14,buf.ogRGB(255,255,255));
+ blit->get(buf,buf.ogGetMaxX()/2-20,buf.ogGetMaxY()/2-20,
+ buf.ogGetMaxX()/2+20,buf.ogGetMaxY()/2+20);
+ blit->put(buf,0,0);
+ for (count=0; count<(int32)buf.ogGetMaxX(); count++)
+ buf.ogLine(count,0,count,buf.ogGetMaxY(),count);
+ buf2->ogClone(buf);
+ blit->getBlitWithMask(*buf2,10,10);
+ buf.ogClear(buf.ogRGB(63,63,63));
+ for (count=-40; count<(int32)buf.ogGetMaxX()+10; count++) {
+ blit->getBlitWithMask(*buf2,count,buf2->ogGetMaxY()/2-20);
+ blit->put(buf,count,buf.ogGetMaxY()/2-20);
+ blit->getBlitWithMask(*buf2,buf2->ogGetMaxX()/2-20,count);
+ blit->put(buf,buf.ogGetMaxX()/2-20,count);
+ }
+ getc(stdin);
+ delete blit;
+ return;
+} // testBlit3
+
+void
+testSaveLoadPal(ogSurface & buf) {
+ uInt32 count;
+ testRect(buf);
+ for (count=0; count<256; count++)
+ buf.ogSetRGBPalette(count,count,count,count);
+ if (buf.ogSavePal("test.pal")==false) cout << "ogSavePal() failed" << endl;
+ for (count=0; count<256; count++)
+ buf.ogSetRGBPalette(count,0,0,0);
+ if (buf.ogLoadPal("test.pal")==false) cout << "ogLoadPal() failed" << endl;
+ testRect(buf);
+} // testSaveLoadPal
+
+void
+testPolygon(ogSurface & buf) {
+ ogPoint points[16];
+ uInt32 count;
+ buf.ogClear(0);
+ for (count=0; count<16; count++) {
+ points[count].x = random() % buf.ogGetMaxX();
+ points[count].y = random() % buf.ogGetMaxY();
+ } // for
+ buf.ogFillPolygon(16, points, buf.ogRGB(random() & 255,random() & 255,random() & 255));
+ getc(stdin);
+ return;
+} // testPolygon
+
+void
+testSpline(ogSurface & buf) {
+ ogPoint points[8];
+ uInt32 i;
+ for (i=0; i<8; i++) {
+ points[i].x = random() % buf.ogGetMaxX();
+ points[i].y = random() % buf.ogGetMaxY();
+ } // for
+ buf.ogClear(0);
+ buf.ogPolygon(8, points, buf.ogRGB(22,229,52));
+ buf.ogSpline(8, points, 24, buf.ogRGB(64,64,255));
+ buf.ogBSpline(8, points, 24, buf.ogRGB(255,128,128));
+ getchar();
+ return;
+} // testSpline
+
+void
+testFont(ogSurface &buf) {
+ ogBitFont* font = NULL;
+ int32 xx, yy;
+ unsigned char ch;
+ font = new ogBitFont();
+ font->load("script.DPF");
+ ch = '\0';
+ for (yy = 0; yy < 16; yy++)
+ for (xx = 0; xx < 16; xx++)
+ font->putChar(buf,xx*font->getWidth(),yy*font->getHeight(),ch++);
+
+ font->justifyText(buf,CenterText,CenterText,"Hello world");
+ getchar();
+ delete font;
+} // testFont
+
+int main() {
+ ogSurface* buf = NULL;
+ ogSurface* screen = NULL;
+ buf = new ogSurface();
+// screen = new ogDisplay_VESA();
+ screen = new ogSurface();
+// buf->ogCreate(640,480,OG_PIXFMT_32BPP);
+ screen->ogCreate(800,600,OG_PIXFMT_32BPP);
+ srandom(time(NULL));
+
+ testFont(*screen);
+/* testRect(*screen);
+ testCircle(*screen);
+ testLine(*screen);
+ testVFlip(*screen);
+ testHFlip(*screen);
+ testArc(*screen);
+ testSetPixel(*screen);
+ testClear(*screen);
+ testSprite(*screen);
+ testBlit(*screen);
+ */
+// testBlit2(*screen);
+// testBlit3(*screen); // special test for 320x200x8bpp
+// testSaveLoadPal(*screen); // use an 8bpp mode
+/* testPolygon(*screen);
+ testCurve(*screen);
+ testSpline(*screen);
+ */
+ delete buf;
+// delete screen;
+ return(0);
+}
diff --git a/lockwasher/src/lib/views/objgfx30.cpp b/lockwasher/src/lib/views/objgfx30.cpp
new file mode 100644
index 0000000..7153df0
--- /dev/null
+++ b/lockwasher/src/lib/views/objgfx30.cpp
@@ -0,0 +1,2847 @@
+/*******************************************************
+$Id: objgfx30.cpp,v 1.9 2003/04/16 06:07:49 flameshadow Exp $
+*******************************************************/
+
+extern "C" {
+ #include
+ #include
+ #include // for stuff in fileExists
+ #include
+ }
+
+#include
+#include "defpal.inc"
+
+using namespace std;
+// #include "../ubixos-home/src/sys/include/ubixos/types.h"
+
+#define ROUND(f) (int)((f) + ((f) > 0 ? 0.5 : -0.5))
+
+struct ogHLine {
+ int32 xStart;
+ int32 xEnd;
+};
+
+struct ogHLineList {
+ int32 length;
+ int32 yStart;
+ int32 * xLeft;
+ int32 * xRight;
+};
+
+struct ogPointListHeader {
+ int32 length;
+ ogPoint * PointPtr;
+};
+
+struct ogEdgeState {
+ ogEdgeState* nextEdge;
+ int32 x;
+ int32 startY;
+ int32 wholePixelXMove;
+ int32 xDirection;
+ int32 errorTerm;
+ int32 errorTermAdjUp;
+ int32 errorTermAdjDown;
+ int32 count;
+};
+
+class ogEdgeTable {
+ public:
+ ogEdgeState * globalEdges;
+ ogEdgeState * activeEdges;
+ ogEdgeTable(void) { globalEdges = activeEdges = NULL; return; }
+ void advanceAET(void);
+ void buildGET(uInt32 numPoints, ogPoint * polyPoints);
+ void moveXSortedToAET(int32 yToMove);
+ void scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour);
+ void xSortAET(void);
+ ~ogEdgeTable(void);
+}; // ogEdgeState
+
+void
+ogEdgeTable::advanceAET(void) {
+ ogEdgeState * currentEdge;
+ ogEdgeState ** currentEdgePtr;
+
+ currentEdgePtr = &activeEdges;
+ currentEdge = activeEdges;
+ while (currentEdge!=NULL) {
+ currentEdge->count--;
+ if (currentEdge->count==0) {
+ // this edge is finished, so remove it from the AET
+ *currentEdgePtr = currentEdge->nextEdge;
+ } else {
+ // advance the edge's x coord by minimum move
+ currentEdge->x += currentEdge->wholePixelXMove;
+ // determine whether it's time for X to advance one extra
+ currentEdge->errorTerm += currentEdge->errorTermAdjUp;
+ if (currentEdge->errorTerm>0) {
+ currentEdge->x += currentEdge->xDirection;
+ currentEdge->errorTerm -= currentEdge->errorTermAdjDown;
+ } // if
+ currentEdgePtr = ¤tEdge->nextEdge;
+ } // else
+ currentEdge = *currentEdgePtr;
+ } // while
+ return;
+} // ogEdgeTable::advanceAET
+
+void
+ogEdgeTable::buildGET(uInt32 numPoints, ogPoint * polyPoints) {
+ int32 i, x1, y1, x2, y2, deltaX, deltaY, width, tmp;
+ ogEdgeState * newEdgePtr;
+ ogEdgeState * followingEdge;
+ ogEdgeState ** followingEdgeLink;
+
+ /* Creates a GET in the buffer pointed to by NextFreeEdgeStruc from
+ * the vertex list. Edge endpoints are flipped, if necessary, to
+ * guarantee all edges go top to bottom. The GET is sorted primarily
+ * by ascending Y start coordinate, and secondarily by ascending X
+ * start coordinate within edges with common Y coordinates }
+ */
+
+ // Scan through the vertex list and put all non-0-height edges into
+ // the GET, sorted by increasing Y start coordinate}
+ for (i = 0; i<(int32)numPoints; i++) {
+ // calculate the edge height and width
+ x1 = polyPoints[i].x;
+ y1 = polyPoints[i].y;
+ if (i==0) {
+ // wrap back around to the end of the list
+ x2 = polyPoints[numPoints-1].x;
+ y2 = polyPoints[numPoints-1].y;
+ } else {
+ x2 = polyPoints[i-1].x;
+ y2 = polyPoints[i-1].y;
+ } // else i!=0
+ if (y1>y2) {
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
+ } // if y1>y2
+ // skip if this can't ever be an active edge (has 0 height)
+ deltaY = y2-y1;
+ if (deltaY!=0) {
+ newEdgePtr = new ogEdgeState;
+ newEdgePtr->xDirection = ((deltaX = x2-x1) > 0) ? 1 : -1;
+ width = abs(deltaX);
+ newEdgePtr->x = x1;
+ newEdgePtr->startY = y1;
+ newEdgePtr->count = newEdgePtr->errorTermAdjDown = deltaY;
+ newEdgePtr->errorTerm = (deltaX >= 0) ? 0 : 1-deltaY;
+ if (deltaY>=width) {
+ newEdgePtr->wholePixelXMove = 0;
+ newEdgePtr->errorTermAdjUp = width;
+ } else {
+ newEdgePtr->wholePixelXMove = (width / deltaY) * newEdgePtr->xDirection;
+ newEdgePtr->errorTermAdjUp = width % deltaY;
+ } // else
+ followingEdgeLink = &globalEdges;
+ while (true) {
+ followingEdge = *followingEdgeLink;
+ if ((followingEdge == NULL) ||
+ (followingEdge->startY >= y1) ||
+ ((followingEdge->startY == y1) &&
+ (followingEdge->x>=x1))) {
+ newEdgePtr->nextEdge = followingEdge;
+ *followingEdgeLink = newEdgePtr;
+ break;
+ } // if
+ followingEdgeLink = &followingEdge->nextEdge;
+ } // while
+ } // if deltaY!=0)
+ } // for
+ return;
+} // ogEdgeTable::buildGET
+
+void
+ogEdgeTable::moveXSortedToAET(int32 yToMove) {
+ ogEdgeState * AETEdge;
+ ogEdgeState * tempEdge;
+ ogEdgeState ** AETEdgePtr;
+ int32 currentX;
+
+ /* The GET is Y sorted. Any edges that start at the desired Y
+ * coordinate will be first in the GET, so we'll move edges from
+ * the GET to AET until the first edge left in the GET is no
+ * longer at the desired Y coordinate. Also, the GET is X sorted
+ * within each Y cordinate, so each successive edge we add to the
+ * AET is guaranteed to belong later in the AET than the one just
+ * added.
+ */
+ AETEdgePtr = &activeEdges;
+ while ((globalEdges!=NULL) && (globalEdges->startY==yToMove)) {
+ currentX = globalEdges->x;
+ // link the new edge into the AET so that the AET is still
+ // sorted by X coordinate
+ while (true) {
+ AETEdge = *AETEdgePtr;
+ if ((AETEdge==NULL) || (AETEdge->x>=currentX)) {
+ tempEdge = globalEdges->nextEdge;
+ *AETEdgePtr = globalEdges;
+ globalEdges->nextEdge = AETEdge;
+ AETEdgePtr = &globalEdges->nextEdge;
+ globalEdges = tempEdge;
+ break;
+ } else AETEdgePtr = &AETEdge->nextEdge;
+ } // while true
+ } // while globalEdges!=NULL and globalEdges->startY==yToMove
+ return;
+} // ogEdgeTable::moveXSortedToAET
+
+void
+ogEdgeTable::scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour) {
+ ogEdgeState * currentEdge;
+ int32 leftX;
+
+ /* Scan through the AET, drawing line segments as each pair of edge
+ * crossings is encountered. The nearest pixel on or to the right
+ * of the left edges is drawn, and the nearest pixel to the left
+ * of but not on right edges is drawn
+ */
+ currentEdge = activeEdges;
+ while (currentEdge!=NULL) {
+ leftX = currentEdge->x;
+ currentEdge = currentEdge->nextEdge;
+ if (currentEdge!=NULL) {
+ if (leftX!=currentEdge->x)
+ destObject.ogHLine(leftX, currentEdge->x-1, yToScan, colour);
+ currentEdge = currentEdge->nextEdge;
+ } // if currentEdge != NULL
+ } // while
+ return;
+} // ogEdgeTable::scanOutAET
+
+void
+ogEdgeTable::xSortAET(void) {
+ ogEdgeState * currentEdge;
+ ogEdgeState * tempEdge;
+ ogEdgeState ** currentEdgePtr;
+ bool swapOccurred;
+ if (activeEdges==NULL) return;
+ do {
+ swapOccurred = false;
+ currentEdgePtr = &activeEdges;
+ currentEdge = activeEdges;
+ while (currentEdge->nextEdge!=NULL) {
+ if (currentEdge->x > currentEdge->nextEdge->x) {
+ // the second edge has a lower x than the first
+ // swap them in the AET
+ tempEdge = currentEdge->nextEdge->nextEdge;
+ *currentEdgePtr = currentEdge->nextEdge;
+ currentEdge->nextEdge->nextEdge = currentEdge;
+ currentEdge->nextEdge = tempEdge;
+ swapOccurred = true;
+ } // if
+ currentEdgePtr = &((*currentEdgePtr)->nextEdge);
+ currentEdge = *currentEdgePtr;
+ } // while
+ } while (swapOccurred);
+ return;
+} // ogEdgeTable::xSortAET
+
+ogEdgeTable::~ogEdgeTable(void) {
+ ogEdgeState * edge;
+ ogEdgeState * tmpEdge;
+ tmpEdge = globalEdges;
+ // first walk the global edges and delete any non-null nodes
+ while (tmpEdge!=NULL) {
+ edge = tmpEdge;
+ tmpEdge = edge->nextEdge;
+ delete edge;
+ } // while
+ tmpEdge = activeEdges;
+ // next walk the activeEdges and delete any non-null nodes. Note that this should
+ // always be null
+ while (tmpEdge!=NULL) {
+ edge = tmpEdge;
+ tmpEdge = edge->nextEdge;
+ delete edge;
+ } // while
+ return;
+} // ogEdgeTable::~ogEdgeTable
+
+static bool
+fileExists(const char *file)
+{
+ FILE *f = fopen(file, "r");
+ if (!f)
+ return false;
+ fclose(f);
+ return true;
+}
+
+static int32 calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3);
+
+// ogSurface constructor
+ogSurface::ogSurface(void) {
+ version = ogVERSION;
+ dataState = ogNONE;
+ buffer = NULL;
+ lineOfs = NULL;
+ pal = NULL;
+ xRes = 0;
+ yRes = 0;
+ maxX = 0;
+ maxY = 0;
+ bSize = 0;
+ lSize = 0;
+ transparentColor = 0;
+ BPP = 0;
+ redShifter = 0;
+ greenShifter = 0;
+ blueShifter = 0;
+ alphaShifter = 0;
+ redFieldPosition = 0;
+ greenFieldPosition = 0;
+ blueFieldPosition = 0;
+ alphaFieldPosition = 0;
+ antiAlias = true;
+ return;
+} // ogSurface::ogSurface
+
+void
+ogSurface::aaRawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) {
+ /*
+ * aaRawLine
+ *
+ * private method
+ *
+ * draws an unclipped anti-aliased line from (x1,y1) to (x2,y2) using colour
+ *
+ */
+ uInt32 erradj, erracc;
+ uInt32 erracctmp, intshift, wgt, wgtcompmask;
+ int32 dx, dy, tmp, xDir, i;
+ uInt32 ct[32];
+ uInt8 r,g,b;
+ uInt8 orig_r, orig_g, orig_b;
+
+ if (y1 > y2) {
+ tmp= y1;
+ y1 = y2;
+ y2 = tmp;
+
+ tmp= x1;
+ x1 = x2;
+ x2 = tmp;
+ } // if
+
+ ogUnpackRGB(colour, orig_r, orig_g, orig_b);
+
+ for (i=0; i<32; i++) {
+ r = (i*orig_r) / 31;
+ g = (i*orig_g) / 31;
+ b = (i*orig_b) / 31;
+ ct[31-i] = ogRGB(r,g,b);
+ } // for
+
+ ogSetPixel(x1,y1,colour);
+
+ dx = (x2-x1);
+ if (dx>=0) xDir=1; else xDir=-1;
+ dx = abs(dx);
+ dy = (y2 - y1);
+
+ if (dy==0) {
+ ogHLine(x1,x2,y1,colour);
+ return;
+ }
+
+ if (dx==0) {
+ ogVLine(x1,y1,y2,colour);
+ return;
+ }
+
+ // this is incomplete.. diagonal lines don't travel through the
+ // center of pixels exactly
+ if (dx==dy) {
+ for (; dy != 0; dy--) {
+ x1+=xDir;
+ y1++;
+ ogSetPixel(x1,y1,colour);
+ } // for
+ return;
+ } // if dx==dy
+
+ erracc = 0;
+ intshift = 32-5;
+ wgtcompmask = 31;
+ if (dy>dx) {
+ /* y-major. Calculate 32-bit fixed point fractional part of a pixel that
+ * X advances every time Y advances 1 pixel, truncating the result so that
+ * we won't overrun the endpoint along the X axis
+ */
+ erradj = ((unsigned long long) dx << 32) / (unsigned long long)dy;
+ while (--dy) {
+ erracctmp = erracc;
+ erracc += erradj;
+ if (erracc <= erracctmp) x1 += xDir;
+ y1++; // y-major so always advance Y
+ /* the nbits most significant bits of erracc give us the intensity
+ * weighting for this pixel, and the complement of the weighting for
+ * the paired pixel.
+ */
+ wgt = erracc >> intshift;
+ ogSetPixel(x1, y1, ct[wgt]);
+ ogSetPixel(x1+xDir, y1, ct[wgt^wgtcompmask]);
+ } // while
+ } else {
+ /* x-major line. Calculate 32-bit fixed-point fractional part of a pixel
+ * that Y advances each time X advances 1 pixel, truncating the result so
+ * that we won't overrun the endpoint along the X axis.
+ */
+ erradj = ((unsigned long long)dy << 32) / (unsigned long long)dx;
+ // draw all pixels other than the first and last
+ while (--dx) {
+ erracctmp = erracc;
+ erracc += erradj;
+ if (erracc <= erracctmp) y1++;
+ x1 += xDir; // x-major so always advance X
+ /* the nbits most significant bits of erracc give us the intensity
+ * weighting for this pixel, and the complement of the weighting for
+ * the paired pixel.
+ */
+ wgt = erracc >> intshift;
+ ogSetPixel(x1, y1, ct[wgt]);
+ ogSetPixel(x1, y1+1, ct[wgt^wgtcompmask]);
+ } // while
+ } // else
+ ogSetPixel(x2,y2,colour);
+ return;
+} // ogSurface::aaRawLine
+
+uInt32
+ogSurface::rawGetPixel(uInt32 x, uInt32 y) {
+ uInt32 result;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " mov %%eax, %0 \n" // mov result, eax
+ : "=m" (result)
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x) // , "m" (result) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size
+ " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size
+ " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // edx,word ptr [edi]
+ " xor %%eax, %%eax \n"
+ " mov 2(%%edi), %%al \n" // mov al, [edi+2]
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov (%%edi), %%ax \n" // mov ax, [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " mov (%%edi),%%eax \n" // eax,word ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ } // switch
+ return result;
+} // ogSurface::rawGetPixel
+
+void
+ogSurface::rawSetPixel(uInt32 x, uInt32 y, uInt32 colour) {
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%eax, (%%edi) \n" // mov [edi], eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ } // switch
+ return;
+} // ogSurface::rawSetPixel
+
+bool
+ogSurface::clipLine(int32& x1, int32& y1, int32& x2, int32& y2) {
+ /*
+ * clipLine()
+ *
+ * private method
+ *
+ * clips a line to (0,0),(maxX,maxY); returns true if
+ * the line segment is in bounds, false if none of the line segment is
+ * on the screen. Uses HJI's line clipping algorithm.
+ */
+
+ int32 tx1, ty1, tx2, ty2;
+ int32 OutCode;
+ uInt32 AndResult, OrResult;
+ AndResult = 15;
+ OrResult = 0;
+ OutCode = 0;
+ if (x1<0) OutCode+=8;
+ if (x1>(int32)maxX) OutCode+=4;
+ if (y1<0) OutCode+=2;
+ if (y1>(int32)maxY) OutCode++;
+
+ AndResult &= OutCode;
+ OrResult |= OutCode;
+ OutCode = 0;
+
+ if (x2<0) OutCode+=8;
+ if (x2>(int32)maxX) OutCode+=4;
+ if (y2<0) OutCode+=2;
+ if (y2>(int32)maxY) OutCode++;
+
+ AndResult &= OutCode;
+ OrResult |= OutCode;
+
+ if (AndResult>0) return false;
+ if (OrResult==0) return true;
+
+ // some clipping is required here.
+
+ tx1 = x1;
+ ty1 = y1;
+ tx2 = x2;
+ ty2 = y2;
+
+ if (x1<0) {
+ ty1 = (x2*y1-x1*y2) / (x2-x1);
+ tx1 = 0;
+ } // if
+ else
+ if (x2<0) {
+ ty2 = (x2*y1-x1*y2) / (x2-x1);
+ tx2 = 0;
+ } // elseif
+
+ if (x1>(int32)maxX) {
+ ty1 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1);
+ tx1 = maxX;
+ } // if
+ else
+ if (x2>(int32)maxX) {
+ ty2 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1);
+ tx2 = maxX;
+ } // elseif
+
+ if (((ty1<0) && (ty2<0)) ||
+ ((ty1>(int32)maxY) && (ty2>(int32)maxY))) return false;
+
+ if (ty1<0) {
+ tx1 = (x1*y2-x2*y1) / (y2-y1);
+ ty1 = 0;
+ } // if
+ else
+ if (ty2<0) {
+ tx2 = (x1*y2-x2*y1) / (y2-y1);
+ ty2 = 0;
+ } // elseif
+
+ if (ty1>(int32)maxY) {
+ tx1 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1);
+ ty1 = maxY;
+ } // if
+ else
+ if (ty2>(int32)maxY) {
+ tx2 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1);
+ ty2 = maxY;
+ } // elseif
+
+ if (((uInt32)tx1>maxX) || ((uInt32)tx2>maxX)) return false;
+
+ x1 = tx1;
+ y1 = ty1;
+ x2 = tx2;
+ y2 = ty2;
+
+ return true;
+} // ogSurface::clipLine
+
+void
+ogSurface::rawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) {
+ /*
+ * ogSurface::rawLine()
+ *
+ * private method; draws an unclipped line from (x1,y1) to (x2,y2)
+ *
+ */
+ int32 tc;
+ if (!ogAvail()) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive8 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive8: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive8 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive8: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater8 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop8: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone8 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY8 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY8: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop8 \n"
+
+"rlyGreater8: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop8: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone8 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX8 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX8: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop8 \n"
+"rlDone8: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+x1), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+x2), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive16 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive16: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive16 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive16: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater16 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop16: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone16 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY16 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY16: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop16 \n"
+
+"rlyGreater16: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop16: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone16 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX16 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX16: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop16 \n"
+"rlDone16: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 1)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 1)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive24 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive24: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive24 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive24: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater24 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop24: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone24 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY24 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY24: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop24 \n"
+
+"rlyGreater24: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop24: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone24 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX24 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX24: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop24 \n"
+"rlDone24: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1*3)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2*3)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive32 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive32: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive32 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive32: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater32 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop32: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone32 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY32 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY32: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop32 \n"
+
+"rlyGreater32: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop32: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone32 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX32 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX32: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop32 \n"
+"rlDone32: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 2)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 2)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ } // switch
+ return;
+} // ogSurface::rawLine
+
+bool
+ogSurface::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) {
+ uInt32 tmp;
+ if (dataState==ogOWNER) return false;
+
+ if (x2> 3));
+ lineOfs=((uInt32 *)SrcObject.lineOfs)+y1;
+ pal = SrcObject.pal;
+ xRes = SrcObject.xRes;
+ yRes = SrcObject.yRes;
+ maxX = (x2-x1);
+ maxY = (y2-y1);
+ bSize = 0;
+ lSize = 0;
+ transparentColor = SrcObject.transparentColor;
+ dataState = ogALIASING;
+ BPP = SrcObject.BPP;
+ // For 8bpp modes the next part doesn't matter
+ redFieldPosition = SrcObject.redFieldPosition;
+ greenFieldPosition = SrcObject.greenFieldPosition;
+ blueFieldPosition = SrcObject.blueFieldPosition;
+ alphaFieldPosition = SrcObject.alphaFieldPosition;
+ // The next part is only used by 15/16bpp
+ redShifter = SrcObject.redShifter;
+ greenShifter = SrcObject.greenShifter;
+ blueShifter = SrcObject.blueShifter;
+ alphaShifter = SrcObject.alphaShifter;
+
+ antiAlias = SrcObject.antiAlias;
+
+ return true;
+} // ogSurface::ogAlias
+
+void
+ogSurface::ogArc(int32 x_center, int32 y_center, uInt32 radius,
+ uInt32 s_angle, uInt32 e_angle, uInt32 colour) {
+ int32 p;
+ uInt32 x, y, tmp;
+ double alpha;
+
+ if (radius==0) {
+ ogSetPixel(x_center, y_center, colour);
+ return;
+ } // if
+
+ s_angle%=361;
+ e_angle%=361;
+
+ if (s_angle>e_angle) {
+ tmp = s_angle;
+ s_angle = e_angle;
+ e_angle = tmp;
+ } // if
+
+ x = 0;
+ y = radius;
+ p = 3-2*radius;
+
+ while (x<=y) {
+ alpha = (180.0/3.14159265358979)*atan((double)x/(double)y);
+ if ((alpha>=s_angle) && (alpha<=e_angle))
+ ogSetPixel(x_center-x, y_center-y, colour);
+ if ((90-alpha>=s_angle) && (90-alpha<=e_angle))
+ ogSetPixel(x_center-y, y_center-x, colour);
+ if ((90+alpha>=s_angle) && (90+alpha<=e_angle))
+ ogSetPixel(x_center-y, y_center+x,colour);
+ if ((180-alpha>=s_angle) && (180-alpha<=e_angle))
+ ogSetPixel(x_center-x, y_center+y,colour);
+ if ((180+alpha>=s_angle) && (180+alpha<=e_angle))
+ ogSetPixel(x_center+x, y_center+y,colour);
+ if ((270-alpha>=s_angle) && (270-alpha<=e_angle))
+ ogSetPixel(x_center+y, y_center+x,colour);
+ if ((270+alpha>=s_angle) && (270+alpha<=e_angle))
+ ogSetPixel(x_center+y, y_center-x,colour);
+ if ((360-alpha>=s_angle) && (360-alpha<=e_angle))
+ ogSetPixel(x_center+x, y_center-y,colour);
+ if (p<0)
+ p+=4*x+6;
+ else {
+ p+=4*(x-y)+10;
+ --y;
+ }
+ ++x;
+ } // while
+ return;
+} // ogSurface::ogArc
+
+bool
+ogSurface::ogAvail(void) {
+ return ((buffer!=NULL) && (lineOfs!=NULL));
+} // ogSurface::ogAvail
+
+static int32
+calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3) {
+ float mu2, mu3;
+ mu2 = mu*mu;
+ mu3 = mu2*mu;
+ return (int32)(0.5f+(1.0/6.0)*(mu3*(-p0+3.0*p1-3.0*p2+p3)+
+ mu2*(3.0*p0-6.0*p1+3.0*p2)+
+ mu*(-3.0*p0+3.0*p2)+(p0+4.0*p1+p2)));
+} // calculate
+
+
+void
+ogSurface::ogBSpline(uInt32 numPoints, ogPoint* points, uInt32 segments,
+ uInt32 colour) {
+ float mu, mudelta;
+ int32 x1,y1,x2,y2;
+ uInt32 n,h;
+ if (points==NULL) return;
+ if ((numPoints<4) || (numPoints>4096) || (segments==0)) return;
+ mudelta = 1.0/segments;
+ for (n=3; n=0) {
+ ogSetPixel(x_center+x,y_center+y,colour);
+ ogSetPixel(x_center+x,y_center-y,colour);
+ ogSetPixel(x_center-x,y_center+y,colour);
+ ogSetPixel(x_center-x,y_center-y,colour);
+ if (d + y > 0) {
+ y--;
+ d -= 2*y+1;
+ } // if
+ if (x > d) {
+ x++;
+ d += 2*x+1;
+ } // if
+ } // while
+ return;
+} // ogSurface::ogCircle
+
+void
+ogSurface::ogClear(uInt32 colour) {
+ uInt32 height = 0;
+ if (!ogAvail()) return;
+ __asm__ __volatile__("cld\n");
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxY)
+ " inc %%ebx \n" // inc ebx (maxX)
+ " sub %%edx, %%esi \n" // sub esi, edx
+ " mov %%al, %%ah \n" // mov ah, al
+ " mov %%ax, %%cx \n" // mov cx, ax
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov %%cx, %%ax \n" // mov ax, cx
+ "loop8: \n"
+ " push %%edx \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " and $3, %%edx \n" // and edx, 3
+ " shr $2, %%ecx \n" // shr ecx, 2
+ " rep \n"
+ " stosl \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " rep \n"
+ " stosb \n"
+ " pop %%edx \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop8 \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX) // %4, %5
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " sub %%edx, %%esi \n" // sub esi, edx
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%ax, %%cx \n" // mov cx, ax
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov %%cx, %%ax \n" // mov ax, cx
+ "loop16: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " rep \n"
+ " stosl \n"
+ " jnc noc16 \n"
+ " stosw \n"
+ "noc16: \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop16 \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX) // %4, %5
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%ebx, %6 \n" // mov height, ebx
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%eax, %%ebx \n" // mov ebx, eax
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " shr $16, %%ebx \n" // shr ebx, 16
+ "oloop24: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ "iloop24: \n"
+ " mov %%ax,(%%edi) \n" // mov [edi],ax
+ " movb %%bl,2(%%edi) \n" // mov [edi+2],bl
+ " add $3, %%edi \n" // add edi, 3
+ " dec %%ecx \n" // dec ecx
+ " jnz iloop24 \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " decl %6 \n" // dec height
+ " jnz oloop24 \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX), // %4, %5
+ "m" (height) // %6
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " shl $2, %%ecx \n" // shl ecx, 2
+ " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size
+ "loop32: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " rep \n"
+ " stosl \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop32 \n"
+
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX) // %4, %5
+ );
+ } // switch
+ return;
+} // ogSurface::ogClear
+
+bool
+ogSurface::ogClone(ogSurface& SrcObject) {
+ bool created;
+ ogPixelFmt pixfmt;
+ if (SrcObject.dataState==ogNONE) return false;
+ SrcObject.ogGetPixFmt(pixfmt);
+ created = ogCreate(SrcObject.maxX+1,SrcObject.maxY+1,pixfmt);
+ if (!created) return false;
+ transparentColor = SrcObject.transparentColor;
+ antiAlias = SrcObject.antiAlias;
+ ogCopyPal(SrcObject);
+ ogCopy(SrcObject);
+ return true;
+} // ogSurface::ogClone
+
+void
+ogSurface::ogCopy(ogSurface& SrcObject) {
+ uInt32 count, xCount, yCount;
+ uInt32 xx, yy;
+ uInt8 r, g, b;
+ void * srcPtr;
+
+ if (!ogAvail()) return;
+ if (!SrcObject.ogAvail()) return;
+
+ xCount = SrcObject.maxX+1;
+ if (xCount>maxX+1) xCount=maxX+1;
+ yCount = SrcObject.maxY+1;
+ if (yCount>maxY+1) yCount=maxY+1;
+ if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) ||
+ (blueShifter!=SrcObject.blueShifter) ||
+ (greenShifter!=SrcObject.greenShifter)) {
+ for (yy=0; yy> 3); // adjust for bpp
+ for (count=0; count(int32)maxX) || (dY1>(int32)maxY)) return;
+
+ // if any of the source buffer is out of bounds then do nothing
+ if (( (uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) ||
+ ( (uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return;
+
+ if (sX1>sX2) {
+ xx = sX1;
+ sX1= sX2;
+ sX2= xx;
+ } // if
+
+ if (sY1>sY2) {
+ yy = sY1;
+ sY1= sY2;
+ sY2= yy;
+ } // if
+
+ xCount = abs(sX2-sX1)+1;
+ yCount = abs(sY2-sY1)+1;
+
+ if (dX1+xCount>(int32)maxX+1) xCount=maxX-dX1+1;
+ if (dY1+yCount>(int32)maxY+1) yCount=maxY-dY1+1;
+
+ if (dX1<0) {
+ xCount += dX1;
+ sX1 -= dX1;
+ dX1 = 0;
+ } // if
+
+ if (dY1<0) {
+ yCount += dY1;
+ sY1 -= dY1;
+ dY1 = 0;
+ } // if
+
+ if ((dX1+xCount<0) || (dY1+yCount<0)) return;
+
+ if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) ||
+ (blueShifter!=SrcObject.blueShifter) ||
+ (greenShifter!=SrcObject.greenShifter)) {
+ if (SrcObject.BPP==8) {
+ for (xx=0; xx<256; xx++)
+ pixmap[xx] = ogRGB(SrcObject.pal[xx].red,
+ SrcObject.pal[xx].green,
+ SrcObject.pal[xx].blue);
+ for (yy=0; yy<=yCount-1; yy++)
+ for (xx=0; xx<=xCount-1; xx++)
+ rawSetPixel(dX1+xx,dY1+yy,
+ pixmap[SrcObject.ogGetPixel(sX1+xx,sY1+yy)]);
+ } // if SrcObject->bpp
+ else
+ {
+ for (yy=0; yy<=yCount-1; yy++)
+ for (xx=0; xx<=xCount-1; xx++) {
+ SrcObject.ogUnpackRGB(SrcObject.ogGetPixel(sX1+xx,sY1+yy),r,g,b);
+ rawSetPixel(dX1+xx,dY1+yy,ogRGB(r,g,b));
+ } // for
+ } // else
+ } // if
+ else
+ {
+ xCount *= (BPP+7) >> 3;
+ for (count=0; count> 3), // dest
+ src, // src
+ size); // size
+
+ return;
+} // ogSurface::ogCopyLineTo
+
+void
+ogSurface::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dst, uInt32 size) {
+ /*
+ * ogCopyLineFrom()
+ *
+ * Inputs:
+ *
+ * sx - Source X of the target buffer
+ * sy - Source Y of the target buffer
+ * dest - where to put it
+ * size - size in bytes *NOT* pixels
+ *
+ * Copies a run of pixels (of the same format) to (x,y) of a buffer
+ *
+ * This method is required because of the different implementations of
+ * copying a run of pixels to a buffer
+ *
+ * WARNING!!! This does *NO* error checking. It is assumed that you've
+ * done all of that. ogCopyLineTo and ogCopyLineFrom are the only
+ * methods that don't check to make sure you're hosing things. Don't
+ * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!!
+ */
+ memcpy( dst, // dest
+ (uInt8*)buffer+lineOfs[sy]+sx*((BPP+7) >> 3), // src
+ size); // size
+
+ return;
+} // ogSurface::ogCopyLineFrom
+
+void
+ogSurface::ogCopyPal(ogSurface& SrcObject) {
+ if (SrcObject.pal==NULL) return;
+ if (pal==NULL) pal = new ogRGBA[256];
+ if (pal==NULL) return;
+ memcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256);
+ return;
+} // ogSurface::ogCopyPal
+
+bool
+ogSurface::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixformat) {
+ /*
+ * ogSurface::ogCreate()
+ * Allocates memory for a buffer of size _xRes by _yRes with
+ * the pixel format defined in _pixformat. Allocates memory
+ * for pal and lineOfs.
+ */
+ uInt32 yy;
+ if (dataState==ogOWNER) {
+ free(buffer);
+ delete [] lineOfs;
+ delete [] pal;
+ } // if datastate
+ BPP = _pixformat.BPP;
+ bSize=_xRes*_yRes*((BPP+7) >> 3);
+ buffer = malloc(bSize);
+ if (buffer==NULL) return false;
+ memset(buffer,0,bSize);
+ lSize = _yRes*sizeof(uInt32);
+ lineOfs = new uInt32[_yRes];
+ if (lineOfs == NULL) return false;
+ pal = new ogRGBA[256];
+ if (pal == NULL) return false;
+ // copy the default palette into the buffer
+ memcpy(pal,DEFAULT_PALETTE,sizeof(ogRGBA)*256);
+ maxX=_xRes-1;
+ xRes=_xRes*((BPP+7) >> 3);
+ maxY=_yRes-1;
+ yRes=_yRes;
+ lineOfs[0]=0;
+ for (yy=1; yy<=maxY; yy++)
+ lineOfs[yy]=lineOfs[yy-1]+xRes;
+ dataState = ogOWNER;
+ // For 8bpp modes the next part doesn't matter
+ redFieldPosition=_pixformat.redFieldPosition;
+ greenFieldPosition=_pixformat.greenFieldPosition;
+ blueFieldPosition=_pixformat.blueFieldPosition;
+ alphaFieldPosition=_pixformat.alphaFieldPosition;
+ // The next part is only used by 15/16hpp
+ redShifter=8-_pixformat.redMaskSize;
+ greenShifter=8-_pixformat.greenMaskSize;
+ blueShifter=8-_pixformat.blueMaskSize;
+ alphaShifter=8-_pixformat.alphaMaskSize;
+
+ // Turn anti aliasing off by default for 8bpp modes
+ antiAlias = (BPP>8);
+ owner = this;
+ return true;
+} // ogSurface::ogCreate
+
+void
+ogSurface::ogCubicBezierCurve(int32 x1, int32 y1, int32 x2, int32 y2,
+ int32 x3, int32 y3, int32 x4, int32 y4,
+ uInt32 segments, uInt32 colour) {
+ float tX1, tY1, tX2, tY2, tX3, tY3, mu, mu2, mu3, mudelta;
+ int32 xStart, yStart, xEnd, yEnd;
+ uInt32 n;
+ if (segments<1) return;
+ if (segments>128) segments=128;
+
+ mudelta = 1.0/segments;
+ mu = mudelta;
+ tX1 =-x1+3*x2-3*x3+x4;
+ tY1 =-y1+3*y2-3*y3+y4;
+ tX2 =3*x1-6*x2+3*x3;
+ tY2 =3*y1-6*y2+3*y3;
+ tX3 =-3*x1+3*x2;
+ tY3 =-3*y1+3*y2;
+
+ xStart = x1;
+ yStart = y1;
+
+ for (n=1; n128) segments=128;
+ x2 = (x2*2)-((x1+x3)/2);
+ y2 = (y2*2)-((y1+y3)/2);
+
+ ex = ((int64)(x2-x1) << 17) / segments;
+ ey = ((int64)(y2-y1) << 17) / (long long)segments;
+ fx = ((int64)(x3-(2*x2)+x1) << 16) / (segments*segments);
+ fy = ((int64)(y3-(2*y2)+y1) << 16) / (long long)(segments*segments);
+
+ while (--segments>0) {
+ t1=x3;
+ t2=y3;
+ x3=((int64)((fx*segments+ex)*segments) / 65536L)+x1;
+ y3=((int64)((fy*segments+ey)*segments) / 65536L)+y1;
+ ogLine(t1, t2, x3, y3, colour);
+ } // while
+ ogLine(x3,y3,x1,y1,colour);
+ return;
+
+} // ogSurface::ogCurve
+
+void
+ogSurface::ogFillCircle(int32 x_center, int32 y_center,
+ uInt32 radius, uInt32 colour) {
+ int32 x, y, d;
+ x = 0;
+ y = radius;
+ d = 2*(1-radius);
+ while (y>=0) {
+ ogHLine(x_center-x, x_center+x, y_center-y, colour);
+ ogHLine(x_center-x, x_center+x, y_center+y, colour);
+ if (d+y>0) {
+ y--;
+ d-=2*y+1;
+ }
+ if (x>d) {
+ x++;
+ d+=2*x+1;
+ }
+ } // while
+ return;
+} // ogSurface::ogFillCircle
+
+#if 0
+!-/* Scan converts an edge from (X1,Y1) to (X2,Y2), not including the
+!- * point at (X2,Y2). This avoids overlapping the end of one line with
+!- * the start of the next, and causes the bottom scan line of the
+!- * polygon not to be drawn. If SkipFirst != 0, the point at (X1,Y1)
+!- * isn't drawn. For each scan line, the pixel closest to the scanned
+!- * line without being to the left of the scanned line is chosen
+!- */
+!-static void index_forward(int32 & index, uInt32 numPoints) {
+!- index = (index + 1) % numPoints;
+!- return;
+!-} // index_forward
+!-
+!-static void index_backward(int32 & index, uInt32 numPoints) {
+!- index = (index - 1 + numPoints) % numPoints;
+!- return;
+!-} // index_forward
+!-
+!-static void index_move(int32 & index, uInt32 numPoints, int32 direction) {
+!- if (direction > 0)
+!- index_forward(index, numPoints);
+!- else
+!- index_backward(index, numPoints);
+!- return;
+!-} // index_move
+!-
+!-static void scanEdge(int32 x1, int32 y1, int32 x2, int32 y2,
+!- uInt32 & eIdx, int32 * xList) {
+!- int32 y, deltaX, deltaY;
+!- float inverseSlope;
+!-
+!- deltaX = x2 - x1;
+!- deltaY = y2 - y1;
+!- if (deltaY <= 0) return;
+!- inverseSlope = deltaX / deltaY;
+!-
+!- // Store the X coordinate of the pixel closest to but not to the
+!- // left of the line for each Y coordinate between Y1 and Y2, not
+!- // including Y2
+!- y = y1;
+!- do {
+!- xList[eIdx] = x1+ (int32)(0.5f+((y-y1)*inverseSlope));
+!- y++;
+!- eIdx++;
+!- } while (y maxPointY) {
+!- maxIndex = i;
+!- maxPointY = polyPoints[i].y; // new bottom
+!- } // else if
+!- } // for
+!-
+!- if (minPointY == maxPointY) return;
+!-
+!- // scan in ascending order to find the last top-edge point
+!- minIndexR = minIndexL;
+!- while (polyPoints[minIndexR].y == minPointY) index_forward(minIndexR, numPoints);
+!- index_backward(minIndexR, numPoints); // back up to last top-edge point
+!-
+!- // now scan in descending order to find the first top-edge point
+!- while (polyPoints[minIndexL].y == minPointY) index_backward(minIndexL, numPoints);
+!- index_forward(minIndexL, numPoints);
+!-
+!- // figure out which direction through the vertex list from the top
+!- // vertex is the left edge and which is the right
+!- leftEdgeDir = -1;
+!-
+!- topIsFlat = (polyPoints[minIndexL].x==polyPoints[minIndexR].x) ? 0 : 1;
+!- if (topIsFlat==1) {
+!- if (polyPoints[minIndexL].x > polyPoints[minIndexR].x) {
+!- leftEdgeDir = 1;
+!- temp = minIndexL;
+!- minIndexL = minIndexR;
+!- minIndexR = temp;
+!- }
+!- } else {
+!- // Point to the downward end of the first line of each of the
+!- // two edges down from the top
+!- nextIndex = minIndexR;
+!- index_forward(nextIndex, numPoints);
+!- prevIndex = minIndexL;
+!- index_forward(prevIndex, numPoints);
+!-
+!- deltaXN = polyPoints[nextIndex].x - polyPoints[minIndexL].x;
+!- deltaYN = polyPoints[nextIndex].y - polyPoints[minIndexL].y;
+!- deltaXP = polyPoints[prevIndex].x - polyPoints[minIndexL].x;
+!- deltaYP = polyPoints[prevIndex].y - polyPoints[minIndexL].y;
+!- if (deltaXN * deltaYP - deltaYN * deltaXP < 0) {
+!- leftEdgeDir = 1;
+!- temp = minIndexL;
+!- minIndexL = minIndexR;
+!- minIndexR = temp;
+!- } // if
+!- } // else
+!-
+!- /* Set the # of scan lines in the polygon, skipping the bottom edge
+!- * and also skipping the top vertex if the top isn't flat because
+!- * in that case the top vertex has a right edge component, and set
+!- * the top scan line to draw, which is likewise the second line of
+!- * the polygon unles the top if flat
+!- */
+!-
+!- workingHLineList.length = maxPointY - minPointY;
+!- if (workingHLineList.length <= 0) return;
+!- workingHLineList.yStart = minPointY;
+!-
+!- // get memory in which to srote the line list we generate
+!- workingHLineList.xLeft = workingHLineList.xRight = NULL;
+!- if ((workingHLineList.xLeft = new int32[workingHLineList.length]) == NULL) return;
+!- if ((workingHLineList.xRight = new int32[workingHLineList.length]) == NULL) {
+!- delete workingHLineList.xLeft;
+!- return;
+!- }
+!- memset(workingHLineList.xLeft,0,workingHLineList.length*sizeof(int32));
+!- memset(workingHLineList.xRight,0,workingHLineList.length*sizeof(int32));
+!-
+!- // scan the left edge and store the boundary points int he list
+!- // Initial pointer for storing scan converted left-edge coords
+!- edgePointIdx = 0;
+!-
+!- // start from the top of the left edge
+!- curIndex = prevIndex = minIndexL;
+!-
+!- do {
+!- index_move(curIndex, numPoints, leftEdgeDir);
+!- scanEdge(polyPoints[prevIndex].x,
+!- polyPoints[prevIndex].y,
+!- polyPoints[curIndex].x,
+!- polyPoints[curIndex].y,
+!- edgePointIdx,
+!- workingHLineList.xLeft);
+!- prevIndex = curIndex;
+!- } while (curIndex != maxIndex);
+!-
+!- edgePointIdx = 0;
+!- curIndex = prevIndex = minIndexR;
+!- // Scan convert the right edge, top to bottom. X coordinates are
+!- // adjusted 1 to the left, effectively causing scan conversion of
+!- // the nearest points to the left of but not exactly on the edge }
+!- do {
+!- index_move(curIndex, numPoints, -leftEdgeDir);
+!- scanEdge(polyPoints[prevIndex].x,
+!- polyPoints[prevIndex].y,
+!- polyPoints[curIndex].x,
+!- polyPoints[curIndex].y,
+!- edgePointIdx,
+!- workingHLineList.xRight);
+!- prevIndex = curIndex;
+!- } while (curIndex != maxIndex);
+!-
+!- ogPolygon(numPoints, polyPoints, colour);
+!-
+!- for (i = 0; i < workingHLineList.length; i++) {
+!- ogHLine(workingHLineList.xLeft[i], workingHLineList.xRight[i],
+!- workingHLineList.yStart+i, colour);
+!- } // for
+!-
+!- ogPolygon(numPoints, polyPoints, colour);
+!-
+!- delete workingHLineList.xLeft;
+!- delete workingHLineList.xRight;
+!-
+!- return;
+!-} // ogSurface::ogFillConvexPolygon
+#endif
+
+void
+ogSurface::ogFillPolygon(uInt32 numPoints, ogPoint* polyPoints, uInt32 colour) {
+ ogEdgeTable * edges;
+ int32 currentY;
+
+ if (numPoints<3) return;
+/* if (numPoints==3) {
+ * ogFillConvexPolygon(numPoints, polyPoints, colour);
+ * return;
+ * } // if
+ */
+ ogPolygon(numPoints, polyPoints, colour);
+ edges = new ogEdgeTable();
+ edges->buildGET(numPoints, polyPoints);
+ currentY = edges->globalEdges->startY;
+ while ((edges->globalEdges!=NULL) || (edges->activeEdges!=NULL)) {
+ edges->moveXSortedToAET(currentY);
+ edges->scanOutAET(*this, currentY, colour);
+ edges->advanceAET();
+ edges->xSortAET();
+ currentY++;
+ if (currentY>(int32)maxY) break; // if we've gone past the bottom, stop
+ } // while
+ delete edges;
+ return;
+} // ogSurface::ogFillPolygon
+
+void
+ogSurface::ogFillRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) {
+ int32 yy,tmp;
+
+ if (x2(int32)maxY)) return;
+ if (y1<0) y1=0;
+ if (y2>(int32)maxY) y2=maxY;
+ for (yy=y1; yy<=y2; yy++)
+ ogHLine(x1,x2,yy,colour);
+} // ogSurface::ogFillRect
+
+void ogSurface::ogFillTriangle(int32 x1, int32 y1, int32 x2, int32 y2,
+ int32 x3, int32 y3, uInt32 colour) {
+ ogPoint Points[3];
+ Points[0].x = x1;
+ Points[0].y = y1;
+ Points[1].x = x2;
+ Points[1].y = y2;
+ Points[2].x = x3;
+ Points[2].y = y3;
+// ogFillConvexPolygon(3,Points,colour);
+ ogFillPolygon(3,Points,colour);
+ return;
+} // ogSurface::ogFillTriangle
+
+void
+ogSurface::ogGetPixFmt(ogPixelFmt& pixfmt) {
+ pixfmt.BPP=BPP;
+ pixfmt.redFieldPosition=redFieldPosition;
+ pixfmt.greenFieldPosition=greenFieldPosition;
+ pixfmt.blueFieldPosition=blueFieldPosition;
+ pixfmt.alphaFieldPosition=alphaFieldPosition;
+ pixfmt.redMaskSize=8-redShifter;
+ pixfmt.greenMaskSize=8-greenShifter;
+ pixfmt.blueMaskSize=8-blueShifter;
+ pixfmt.alphaMaskSize=8-alphaShifter;
+ return;
+} // ogSurface::ogGetPixFmt
+
+uInt32
+ogSurface::ogGetPixel(int32 x, int32 y) {
+ uInt32 result;
+ if (!ogAvail()) return transparentColor;
+
+ if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return transparentColor;
+
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " mov %%eax, %0 \n" // mov result, eax
+ : "=m" (result)
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x) // , "m" (result) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size
+ " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size
+ " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // edx,word ptr [edi]
+ " xor %%eax, %%eax \n"
+ " mov 2(%%edi), %%al \n" // mov al, [edi+2]
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov (%%edi), %%ax \n" // mov ax, [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " mov (%%edi),%%eax \n" // eax,word ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ } // switch
+ return result;
+} // ogSurface::ogGetPixel
+
+void *
+ogSurface::ogGetPtr(uInt32 x, uInt32 y) {
+// return (ogAvail() ? ( (uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)) ) : NULL );
+ return ((uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)));
+} // ogSurface::ogGetPtr
+
+void
+ogSurface::ogHFlip(void) {
+ void * tmpBuf1;
+ void * tmpBuf2;
+ uInt32 xWidth, count;
+ if (!ogAvail()) return;
+ xWidth = (maxX+1)*((BPP+7) >> 3);
+ tmpBuf1 = malloc(xWidth);
+ tmpBuf2 = malloc(xWidth);
+ if ((tmpBuf1!=NULL) && (tmpBuf2!=NULL))
+ for (count=0; count<=(maxY/2); count++) {
+ ogCopyLineFrom(0,count,tmpBuf1,xWidth);
+ ogCopyLineFrom(0,maxY-count,tmpBuf2,xWidth);
+ ogCopyLineTo(0,maxY-count,tmpBuf1,xWidth);
+ ogCopyLineTo(0,count,tmpBuf2,xWidth);
+// memcpy(tmpBuf,((uInt8*)buffer+lineOfs[count]),xWidth);
+// memcpy(((uInt8*)buffer+lineOfs[count]),
+// ((uInt8*)buffer+lineOfs[maxY-count]),
+// xWidth);
+// memcpy(((uInt8*)buffer+lineOfs[maxY-count]),tmpBuf,xWidth);
+ } // for
+ free(tmpBuf2);
+ free(tmpBuf1);
+ return;
+} // ogSurface::ogHFlip
+
+void
+ogSurface::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) {
+ int32 tmp;
+
+ if (!ogAvail()) return;
+ if ((uInt32)y>maxY) return;
+ if (x1>x2) {
+ tmp= x1;
+ x1 = x2;
+ x2 = tmp;
+ } // if
+ if (x1<0) x1 = 0;
+ if (x2>(int32)maxX) x2=maxX;
+ if (x2> redShifter) << redFieldPosition |
+ (green >> greenShifter) << greenFieldPosition |
+ (blue >> blueShifter) << blueFieldPosition;
+ break;
+ case 24:
+ case 32:
+ colour = ( (red << redFieldPosition) |
+ (green << greenFieldPosition) |
+ (blue << blueFieldPosition) );
+ } // switch
+ //asm("": "=a" (lastclr));
+ return colour;
+} // ogSurface::ogRGB
+
+bool
+ogSurface::ogSavePal(const char *palfile) {
+ FILE * f;
+ uInt32 lresult;
+ if (pal==NULL) return false;
+ if ((f = fopen(palfile, "wb"))==NULL) return false;
+ lresult = fwrite(pal,sizeof(ogRGBA),256,f);
+ fclose(f);
+ return (lresult == 256);
+} // ogSurface::ogSavePal
+
+void
+ogSurface::ogScale(ogSurface& SrcObject) {
+ ogScaleBuf(0,0,maxX,maxY,SrcObject,0,0,SrcObject.maxX,SrcObject.maxY);
+ return;
+} // ogSurface::ogScale
+
+void
+ogSurface::ogScaleBuf(int32 dX1, int32 dY1, int32 dX2, int32 dY2,
+ ogSurface& SrcObject,
+ int32 sX1, int32 sY1, int32 sX2, int32 sY2) {
+
+ uInt32 sWidth, dWidth;
+ uInt32 sHeight, dHeight;
+ int32 sx, sy, xx, yy;
+ uInt32 xInc, yInc;
+ uInt32 origdX1, origdY1;
+ ogPixelFmt pixFmt;
+ ogSurface * tmpBuf;
+ ogSurface * sBuf;
+ ogSurface * dBuf;
+ bool doCopyBuf;
+ uInt8 scaleBPP;
+
+ origdX1 = origdY1 = 0; // to keep the compiler from generating a warning
+
+ if (!ogAvail()) return;
+ if (!SrcObject.ogAvail()) return;
+
+ if (sX1>sX2) {
+ xx = sX1;
+ sX1= sX2;
+ sX2= xx;
+ }
+
+ if (sY1>sY2) {
+ yy = sY1;
+ sY1= sY2;
+ sY2= yy;
+ }
+
+ // if any part of the source falls outside the buffer then don't do anything
+
+ if (((uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) ||
+ ((uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return;
+
+ if (dX1>dX2) {
+ xx = dX1;
+ dX1= dX1;
+ dX2= xx;
+ }
+
+ if (dY1>dY2) {
+ yy = dY1;
+ dY1= dY2;
+ dY2= yy;
+ }
+
+ dWidth = (dX2-dX1)+1;
+ if (dWidth<=0) return;
+
+ dHeight = (dY2-dY1)+1;
+ if (dHeight<=0) return;
+
+ sWidth = (sX2-sX1)+1;
+ sHeight = (sY2-sY1)+1;
+
+ // convert into 16:16 fixed point ratio
+ xInc = (sWidth << 16) / dWidth;
+ yInc = (sHeight << 16) / dHeight;
+
+ if (dX2>(int32)maxX) {
+ xx = (xInc*(dX1-maxX)) >> 16;
+ sX1 -= xx;
+ sWidth -= xx;
+ dWidth -= (dX1-maxX);
+ dX1 = maxX;
+ }
+
+ if (dY2>(int32)maxY) {
+ yy = (yInc*(dY2-maxY)) >> 16;
+ sY2 -= yy;
+ sHeight -= yy;
+ dHeight -= (dY2-maxY);
+ dY2 = maxY;
+ }
+
+ if (dX1<0) {
+ xx = (xInc*(-dX1)) >> 16;
+ sX1 += xx;
+ sWidth -= xx;
+ dWidth += dX1;
+ dX1 = 0;
+ }
+
+ if (dY1<0) {
+ yy = (yInc*(-dY1)) >> 16;
+ sY1 += yy;
+ sHeight -= yy;
+ dHeight += dY1;
+ dY1 = 0;
+ }
+
+ if ((dWidth<=0) || (dHeight<=0)) return;
+ if ((sWidth<=0) || (sHeight<=0)) return;
+
+ // Do a quick check to see if the scale is 1:1 .. in that case just copy
+ // the image
+
+ if ((dWidth==sWidth) && (dHeight==sHeight)) {
+ ogCopyBuf(dX1,dY1,SrcObject,sX1,sY1,sX2,sY2);
+ return;
+ }
+
+ tmpBuf = NULL;
+
+ /*
+ * Alright.. this is how we're going to optimize the case of different
+ * pixel formats. We are going to use copyBuf() to automagically do
+ * the conversion for us using tmpBuf. Here's how it works:
+ * If the source buffer is smaller than the dest buffer (ie, we're making
+ * something bigger) we will convert the source buffer first into the dest
+ * buffer's pixel format. Then we do the scaling.
+ * If the source buffer is larger than the dest buffer (ie, we're making
+ * something smaller) we will scale first and then use copyBuf to do
+ * the conversion.
+ * This method puts the onus of conversion on the copyBuf() function which,
+ * while not excessively fast, does the job.
+ * The case in which the source and dest are the same size is handled above.
+ *
+ */
+
+ if ( (BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) ||
+ (blueShifter!=SrcObject.blueShifter) ||
+ (greenShifter!=SrcObject.greenShifter)) {
+ tmpBuf = new ogSurface();
+ if (tmpBuf==NULL) return;
+ if (sWidth*sHeight*((SrcObject.BPP+7)>>3)<=dWidth*dHeight*((BPP+7)>>3)) {
+ // if the number of pixels in the source buffer is less than the
+ // number of pixels in the dest buffer then...
+ ogGetPixFmt(pixFmt);
+ if (tmpBuf->ogCreate(sWidth,sHeight,pixFmt)==false) return;
+ tmpBuf->ogCopyPal(SrcObject);
+ tmpBuf->ogCopyBuf(0,0,SrcObject,sX1,sY1,sX2,sY2);
+ sX2 -= sX1;
+ sY2 -= sY1;
+ sX1 = 0;
+ sY1 = 0;
+ sBuf = tmpBuf;
+ dBuf = this;
+ doCopyBuf = false; // do we do a copyBuf later?
+ scaleBPP = BPP;
+ } else {
+ SrcObject.ogGetPixFmt(pixFmt);
+ if (tmpBuf->ogCreate(dWidth,dHeight,pixFmt)==false) return;
+// tmpBuf->ogCopyPal(&this);
+ origdX1 = dX1;
+ origdY1 = dY1;
+ dX1 = 0;
+ dY1 = 0;
+ dX2 = tmpBuf->maxX;
+ dY2 = tmpBuf->maxY;
+ sBuf = &SrcObject;
+ dBuf = tmpBuf;
+ doCopyBuf = true;
+ scaleBPP = SrcObject.BPP;
+ } // else
+ } else {
+ // pixel formats are identical
+ sBuf = &SrcObject;
+ dBuf = this;
+ doCopyBuf = false;
+ scaleBPP = BPP;
+ } // else
+
+ sy = sY1 << 16;
+
+ for (yy = dY1; yy <=dY2; yy++) {
+ sx = 0;
+ for (xx = dX1; xx <= dX2; xx++) {
+ dBuf->rawSetPixel(xx,yy,sBuf->rawGetPixel(sX1+(sx >> 16),(sy>>16)));
+ sx+=xInc;
+ } // for xx
+ sy += yInc;
+ } // for yy
+
+ if ((doCopyBuf) && (tmpBuf!=NULL))
+ ogCopyBuf(origdX1,origdY1,*tmpBuf,0,0,tmpBuf->maxX,tmpBuf->maxY);
+ delete tmpBuf;
+ return;
+} // ogSurface::ogScaleBuf
+
+bool
+ogSurface::ogSetAntiAlias(bool _AntiAlias) {
+ bool tmp;
+ tmp = antiAlias;
+ antiAlias = _AntiAlias;
+ return tmp;
+} // ogSurface::ogSetAntiAlias
+
+void
+ogSurface::ogSetPixel(int32 x, int32 y, uInt32 colour) {
+ if (!ogAvail()) return;
+// if ((buffer==NULL) || (lineOfs==NULL)) return;
+ if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4]
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " mov %3, %%eax \n" // mov eax, colour
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (colour) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%eax, (%%edi) \n" // mov [edi], eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ } // switch
+ return;
+} // ogSurface::ogSetPixel
+
+void
+ogSurface::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) {
+ if (pal==NULL) return;
+ pal[colour].red = red;
+ pal[colour].green = green;
+ pal[colour].blue = blue;
+ return;
+} // ogSurface::ogSetRGBPalette
+
+uInt32
+ogSurface::ogSetTransparentColor(uInt32 colour) {
+ uInt32 tmp;
+ tmp = transparentColor;
+ transparentColor = colour;
+ return tmp;
+} // ogSurface::ogSetTransparentColor
+
+static double f(double g) { return g*g*g-g; }
+
+void
+ogSurface::ogSpline(uInt32 numPoints, ogPoint* points, uInt32 segments,
+ uInt32 colour) {
+ int32 i, oldY, oldX, x, y, j;
+ float part, t, xx, yy, tmp;
+ float * zc;
+ float * dx;
+ float * dy;
+ float * u;
+ float * wndX1;
+ float * wndY1;
+ float * px;
+ float * py;
+
+ bool runOnce;
+ if ((numPoints<2) || (points==NULL)) return;
+ zc = new float[numPoints];
+ dx = new float[numPoints];
+ dy = new float[numPoints];
+ u = new float[numPoints];
+ wndX1 = new float[numPoints];
+ wndY1 = new float[numPoints];
+ px = new float[numPoints];
+ py = new float[numPoints];
+ if ((zc==NULL) || (dx==NULL) || (dy==NULL) || (wndX1==NULL) ||
+ (wndY1==NULL) || (px==NULL) || (py==NULL)) goto safeexit;
+
+ for (i = 0; (uInt32)i0; i--) {
+ py[i] = (wndY1[i]-u[i]*py[i+1])/dy[i];
+ px[i] = (wndX1[i]-u[i]*px[i+1])/dx[i];
+ } // for
+
+ for (i = 0; (uInt32)i < numPoints-1; i++) {
+ for (j = 0; (uInt32)j <= segments; j++) {
+ part = zc[i]-(((zc[i]-zc[i+1])/segments)*j);
+ t = (part-zc[i])/u[i];
+ part = t * points[i+1].y +
+ (1.0-t)*points[i].y +
+ u[i] * u[i] * ( f(t) * py[i+1] + f(1.0-t) * py[i]) /6.0;
+// y = Round(part);
+ y = ROUND(part+0.5f);
+ part = zc[i]-(((zc[i]-zc[i+1])/segments)*j);
+ t = (part-zc[i])/u[i];
+ part = t*points[i+1].x+(1.0-t)*points[i].x+u[i]*u[i]*(f(t)*px[i+1]+
+ f(1.0-t)*px[i])/6.0;
+
+// x = Round(part);
+ x = ROUND(part+0.5f);
+ if (runOnce) ogLine(oldX, oldY, x, y, colour); else runOnce = true;
+ oldX = x;
+ oldY = y;
+ } // for j
+ } // for i
+safeexit:
+ delete [] py;
+ delete [] px;
+ delete [] wndY1;
+ delete [] wndX1;
+ delete [] u;
+ delete [] dy;
+ delete [] dx;
+ delete [] zc;
+
+ return;
+} // ogSurface::ogSpline
+
+
+void
+ogSurface::ogTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3,
+ uInt32 colour) {
+ ogLine(x1,y1,x2,y2,colour);
+ ogLine(x2,y2,x3,y3,colour);
+ ogLine(x3,y3,x1,y1,colour);
+ return;
+} // ogSurface::ogTriangle
+
+void
+ogSurface::ogUnpackRGB(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) {
+ switch (BPP) {
+ case 8:
+ if (pal==NULL) {
+ red = 0;
+ green = 0;
+ blue = 0;
+ return;
+ }
+ if (colour>255) colour &= 255;
+ red = pal[colour].red;
+ green = pal[colour].green;
+ blue = pal[colour].blue;
+ break;
+ case 15:
+ case 16:
+ red = ((colour >> redFieldPosition) << redShifter);
+ green = ((colour >> greenFieldPosition) << greenShifter);
+ blue = ((colour >> blueFieldPosition) << blueShifter);
+ if ((red) && (redShifter)) red+=(1 << redShifter)-1;
+ if ((green) && (greenShifter)) green+=(1 << greenShifter)-1;
+ if ((blue) && (blueShifter)) blue+=(1 << blueShifter)-1;
+ break;
+ case 24:
+ case 32:
+ red = colour >> redFieldPosition;
+ green = colour >> greenFieldPosition;
+ blue = colour >> blueFieldPosition;
+ break;
+ default:
+ red = 0;
+ green = 0;
+ blue = 0;
+ }
+ return;
+} // ogSurface::ogUnpackRGB
+
+void
+ogSurface::ogVFlip(void) {
+ if (!ogAvail()) return;
+// if ((buffer==NULL) || (lineOfs==NULL)) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf8lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf8lop2: \n"
+ " mov (%%edi),%%al \n" // mov al, [edi]
+ " mov (%%esi),%%ah \n" // mov ah, [esi]
+ " mov %%al,(%%esi) \n" // mov [esi], al
+ " mov %%ah,(%%edi) \n" // mov [edi], ah
+ " inc %%edi \n" // inc edi
+ " dec %%esi \n" // dec esi
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf8lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf8lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1
+ "b" (xRes), "d" (maxY+1) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf16lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf16lop2: \n"
+ " mov (%%edi),%%ax \n" // mov ax, [edi]
+ " mov (%%esi),%%cx \n" // mov cx, [esi]
+ " mov %%ax,(%%esi) \n" // mov [esi], ax
+ " mov %%cx,(%%edi) \n" // mov [edi], cx
+ " add $2, %%edi \n" // add edi, 2
+ " sub $2, %%esi \n" // sub esi, 2
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf16lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf16lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1
+ "b" (xRes), "d" (maxY+1) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf24lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf24lop2: \n"
+ " mov (%%edi),%%ax \n" // mov ax, [edi]
+ " mov 2(%%edi),%%dl \n" // mov dl, [edi+2]
+ " mov (%%esi),%%cx \n" // mov cx, [esi]
+ " mov 2(%%esi),%%dh \n" // mov dh, [esi+2]
+ " mov %%ax,(%%esi) \n" // mov [esi], ax
+ " mov %%dl,2(%%esi) \n" // mov [esi+2], dl
+ " mov %%cx,(%%edi) \n" // mov [edi], cx
+ " mov %%dh,2(%%edi) \n" // mov [edi+2], dh
+ " add $3, %%edi \n" // add edi, 3
+ " sub $3, %%esi \n" // sub esi, 3
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf24lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " decl %3 \n" // dec height
+ " jnz vf24lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1
+ "b" (xRes), "m" (maxY+1) // %2, %3
+ );
+ break;
+
+ case 32:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf32lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf32lop2: \n"
+ " mov (%%edi),%%eax \n" // mov eax, [edi]
+ " mov (%%esi),%%ecx \n" // mov ecx, [esi]
+ " mov %%eax,(%%esi) \n" // mov [esi], eax
+ " mov %%ecx,(%%edi) \n" // mov [edi], ecx
+ " add $4, %%edi \n" // add edi, 4
+ " sub $4, %%esi \n" // sub esi, 4
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf32lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf32lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1
+ "b" (xRes), "d" (maxY+1) // %2, %3
+ );
+
+ } // switch
+ return;
+} // ogSurface::ogVFlip
+
+void
+ogSurface::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) {
+ int32 tmp;
+ if (!ogAvail()) return;
+ if ((uInt32)x>maxX) return;
+ if (y1>y2) {
+ tmp= y1;
+ y1 = y2;
+ y2 = tmp;
+ } // if
+ if (y1<0) y1 = 0;
+ if (y2>(int32)maxY) y2 = maxY;
+ if (y2
+#include
+ #include
+ }
+#include "objgfx30.h"
+#include "ogBlit.h"
+
+static bool
+fileExists(const char *file)
+{
+ FILE *f = fopen(file, "r");
+ if (!f)
+ return false;
+ fclose(f);
+ return true;
+}
+
+ogBlit::ogBlit(void) {
+ blitMask = NULL;
+ blitMaskSize = 0;
+ totalPixCount = 0;
+ startX = 0;
+ startY = 0;
+ endX = 0;
+ endY = 0;
+ return;
+} // ogBlit::ogBlit
+
+void
+ogBlit::blitSize(ogSurface& SrcObject, int32 x1, int32 y1, int32 x2, int32 y2) {
+ int32 x,y;
+ uInt8 zerocount;
+ uInt8 pixcount;
+ uInt32 bm;
+ bool inZeros;
+ bool found;
+
+ // first free the image data or the blitMask data if we already have some
+
+ free(image);
+ delete [] blitMask;
+ image = NULL;
+ blitMask = NULL;
+ imageSize = 0;
+ blitMaskSize = 0;
+ bm = (bitDepth+7) >> 3;
+ tColour = SrcObject.ogGetTransparentColor();
+
+ startX = x1;
+ startY = y1;
+ endX = x2;
+ endY = y2;
+
+ // start by locating the left-most non-transparent pixel in the region defined
+ // by (x1,y1) to (x2,y2)
+ found = false;
+ while ((!found) && (startX<=x2)) {
+ for (y=y1; y<=y2; y++)
+ found |= (SrcObject.ogGetPixel(startX,y)!=tColour);
+ if (!found) startX++;
+ } // while
+ // now we look for the top-most non-transparent pixel in the regsion defined by
+ // (StartX,y1) to (x2,y2)
+ found = false;
+ while ((!found) && (startY<=y2)) {
+ for (x=startX; x<=x2; x++)
+ found |= (SrcObject.ogGetPixel(x,startY)!=tColour);
+ if (!found) startY++;
+ } // while
+ found = false;
+ while ((!found) && (endX>=startX)) {
+ for (y=startY; y<=y2; y++)
+ found |= (SrcObject.ogGetPixel(endX,y)!=tColour);
+ if (!found) endX--;
+ } // while
+ found = false;
+ while ((!found) && (endY>=startY)) {
+ for (x=startX; x<=endX; x++)
+ found |= (SrcObject.ogGetPixel(x,endY)!=tColour);
+ if (!found) endY--;
+ } // while
+
+ for (y = startY; y <= endY; y++) {
+ zerocount = 0;
+ blitMaskSize++; // save room for xlcount
+ x = startX;
+ inZeros = (SrcObject.ogGetPixel(x,y)==tColour);
+ while (x<=endX) {
+ switch (inZeros) {
+ case true:
+ zerocount = 0; // How many zeros?
+ while ((x<=endX) && (SrcObject.ogGetPixel(x,y)==tColour)) {
+ x++;
+ if (zerocount == 255) {
+ zerocount = 0;
+ blitMaskSize += 2;
+ } else zerocount++;
+ } // while
+ inZeros = false;
+ break; // case true
+ case false:
+ pixcount = 0;
+ blitMaskSize += 2;
+ do {
+ x++;
+ if (pixcount == 255) {
+ blitMaskSize += 2;
+ pixcount = 0;
+ } else pixcount++;
+ totalPixCount++;
+ imageSize += bm;
+ } while ((x<=endX) && (SrcObject.ogGetPixel(x,y)!=tColour));
+ inZeros = true;
+ break; // case false
+ } // switch
+ } // while
+ } // for
+
+ startX -= x1;
+ startY -= y1;
+ endX -= x1;
+ endY -= y1;
+
+ blitMask = new uInt8[blitMaskSize]; //(uInt8 *)malloc(blitMaskSize);
+// memset(blitMask,0,blitMaskSize);
+ return;
+} // ogBlit::blitSize
+
+void
+ogBlit::getBlitMask(ogSurface& SrcObject, int32 x1, int32 y1) {
+ uInt8 * blitMaskPtr;
+ uInt8 * lineCountPtr;
+ uInt32 bm;
+ int32 x,y;
+ bool inZeros;
+ uInt8 pixCount, zeroCount;
+
+ if (blitMask==NULL) return;
+ blitMaskPtr = blitMask;
+ bm = (bitDepth+7) >> 3;
+// This is done elsewhere tColour = SrcObject.ogGetTransparentColor();
+
+ for (y = y1+startY; y <= y1+endY; y++) {
+ zeroCount = 0;
+ lineCountPtr = blitMaskPtr;
+ *lineCountPtr = 0;
+ blitMaskPtr++;
+ x = x1+startX;
+ inZeros = (SrcObject.ogGetPixel(x,y)==tColour);
+ while (x<=x1+endX) {
+ switch (inZeros) {
+ case true:
+ zeroCount = 0;
+ while ((x<=x1+endX) && (SrcObject.ogGetPixel(x,y)==tColour)) {
+ x++;
+ if (zeroCount == 255) {
+ (*lineCountPtr)++;
+ *blitMaskPtr = 255; // offset
+ blitMaskPtr++; // increment to next byte
+ *blitMaskPtr = 0; // runcount
+ blitMaskPtr++; // increment to next byte
+ *blitMaskPtr = 0; // offset
+ zeroCount = 0;
+ } else zeroCount++;
+ } // while
+ inZeros = false; // we are no longer in zeros}
+ break; // case true
+ case false:
+ (*lineCountPtr)++;
+ *blitMaskPtr = zeroCount;
+ blitMaskPtr++;
+ *blitMaskPtr = 0;
+ pixCount = 0;
+ do {
+ x++;
+ if (pixCount == 255) {
+ (*lineCountPtr)++;
+ *blitMaskPtr = 255; // runcount
+ blitMaskPtr++; // advance pointer
+ *blitMaskPtr = 0; // offset to next run
+ blitMaskPtr++; // advance pointer
+ *blitMaskPtr = 0; // next run count (incremented below)
+ pixCount = 0;
+ } else pixCount++;
+ (*blitMaskPtr)++;
+ } while ((x<=(x1+endX)) &&
+ (SrcObject.ogGetPixel(x,y)!=tColour));
+ blitMaskPtr++;
+ inZeros = true; // set inZeros to true to toggle
+ break; // case false
+ } // switch
+ } // while
+ } // for
+ return;
+} // ogBlit::getBlitMask
+
+void
+ogBlit::get(ogSurface& SrcObject, int32 x1, int32 y1, int32 x2, int32 y2) {
+ int32 tmp;
+ ogPixelFmt pixfmt;
+
+ if (x1 > x2) {
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ } // if
+
+ if (y1 > y2) {
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
+ } // if
+
+ width = (x2-x1)+1;
+ height = (y2-y1)+1;
+
+ SrcObject.ogGetPixFmt(pixfmt);
+
+ bitDepth = pixfmt.BPP;
+ RFP = pixfmt.redFieldPosition;
+ GFP = pixfmt.greenFieldPosition;
+ BFP = pixfmt.blueFieldPosition;
+ AFP = pixfmt.alphaFieldPosition;
+ RShift = 8-pixfmt.redMaskSize;
+ GShift = 8-pixfmt.greenMaskSize;
+ BShift = 8-pixfmt.blueMaskSize;
+ AShift = 8-pixfmt.alphaMaskSize;
+
+ if (bitDepth == 8) {
+ if (pal==NULL) pal = new ogRGBA[256];
+ for (tmp=0; tmp<256; tmp++)
+ SrcObject.ogUnpackRGB(tmp,pal[tmp].red, pal[tmp].green, pal[tmp].blue);
+// memcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256);
+ } // if
+
+ blitSize(SrcObject, x1, y1, x2, y2);
+ getBlitMask(SrcObject, x1, y1);
+ getBlitWithMask(SrcObject, x1, y1);
+ return;
+} // ogBlit::get()
+
+void
+ogBlit::getBlitWithMask(ogSurface& SrcObject, int32 x, int32 y) {
+ /*
+ * getBlitWithMask
+ *
+ * Retrieves the data portion of a blit using a predefined mask and
+ * stores the data in the Image pointer. If the source buffer is
+ * a different pixel format, we will adjust the image pointer
+ * to accommodate the new data and update the pixel format. The put()
+ * function will adjust the pixels to the dest buffer as needed.
+ * Before calling this routine, you must call getBlitMask.
+ */
+
+ int32 sx, sy;
+ uInt8 lineCount, offset, pixCount;
+ uInt32 nsy, ney; // new start y, new end y
+ uInt8 * blitMaskPtr;
+ void * imagePtr;
+ uInt32 distToEdge, bm, xRight, count;
+ ogPixelFmt pixfmt;
+
+ // can we draw anything?
+ if (blitMask==NULL) return;
+ // see if the blit is outside the buffer
+ if ( (x+startX > (int32)SrcObject.ogGetMaxX()) || (x+endX<0) ||
+ (y+startY > (int32)SrcObject.ogGetMaxY()) || (y+endY<0)) return;
+ blitMaskPtr = blitMask;
+
+ // first check to see if the pixel format we get the blitmask from is
+ // different than what we're dealing with now.
+ SrcObject.ogGetPixFmt(pixfmt);
+ if ( (bitDepth!=pixfmt.BPP) ||
+ (RFP!=pixfmt.redFieldPosition) ||
+ (GFP!=pixfmt.greenFieldPosition) ||
+ (BFP!=pixfmt.blueFieldPosition) ) {
+ if (image!=NULL) free(image);
+ image = NULL;
+ imageSize = 0;
+ bitDepth = pixfmt.BPP;
+ RFP = pixfmt.redFieldPosition;
+ GFP = pixfmt.greenFieldPosition;
+ BFP = pixfmt.blueFieldPosition;
+ AFP = pixfmt.alphaFieldPosition;
+ RShift = 8-pixfmt.redMaskSize;
+ GShift = 8-pixfmt.greenMaskSize;
+ BShift = 8-pixfmt.blueMaskSize;
+ AShift = 8-pixfmt.alphaMaskSize;
+ } // if
+
+ bm = (bitDepth+7) >> 3; // bit multiplier
+
+ if (image==NULL) {
+ imageSize = totalPixCount*bm;
+ image = malloc(imageSize);
+ } // if
+ imagePtr = image;
+
+ // If any part of the blit data is out of bounds, we need to fill it with the
+ // transparent colour
+ if ((x+startX<0) || (x+endX>(int32)SrcObject.ogGetMaxX()) ||
+ (y+startY<0) || (y+endY>(int32)SrcObject.ogGetMaxY())) {
+ for (count=0; count0) {
+ blitMaskPtr++;
+ pixCount = *blitMaskPtr;
+ blitMaskPtr++;
+ if (pixCount>0) (uInt8 *)imagePtr+=pixCount*bm;
+ lineCount--;
+ } // while
+ } // for sy
+ } // if
+
+ // Now do clipping on the bottom edge. This is easy.
+ if (y+endY>(int32)SrcObject.ogGetMaxY())
+ ney = (SrcObject.ogGetMaxY()-y);
+ else
+ ney = endY;
+
+ for (sy = nsy; (uInt32)sy <= ney; sy++) {
+ sx = x+startX;
+ lineCount = *blitMaskPtr;
+ blitMaskPtr++;
+ while (lineCount>0) {
+ offset = *blitMaskPtr;
+ blitMaskPtr++;
+ sx += offset;
+ pixCount = *blitMaskPtr;
+ blitMaskPtr++;
+ if (pixCount>0) {
+ if (sx<=(int32)SrcObject.ogGetMaxX()) {
+ if ((sx<0) && (sx+pixCount>0)) {
+ pixCount += sx; // remember, sx is negative
+ (uInt8*)imagePtr -= sx*bm; // remember, sx is negative
+ sx=0;
+ } // if sx<0 && sx+pixcount>0
+
+ if (sx+pixCount>(int32)SrcObject.ogGetMaxX()+1) {
+ distToEdge = (SrcObject.ogGetMaxX()-sx)+1;
+ xRight = (pixCount - distToEdge)*bm;
+ pixCount = distToEdge;
+ } else xRight = 0; // if sx+pixCount>MaxX
+
+ if (sx>=0)
+ SrcObject.ogCopyLineFrom(sx,y+sy,imagePtr,pixCount*bm);
+// memcpy(imagePtr, // dest
+// ((uInt8*)SrcObject.Buffer+SrcObject.LineOfs[y+sy]+sx*bm),
+// pixCount*bm);
+ (uInt8*)imagePtr += xRight;
+ } // if sx <= MaxX
+ sx += pixCount;
+ (uInt8*)imagePtr += pixCount*bm;
+ } // if pixCount>0
+ lineCount--;
+ } // while
+ } // for
+
+ return;
+} // ogBlit::getBlitWithMask
+
+uInt32
+ogBlit::getSize(void) {
+ return ogSprite::getSize() +
+ sizeof(totalPixCount) +
+ sizeof(blitMaskSize) +
+ blitMaskSize +
+ sizeof(startX) +
+ sizeof(startY) +
+ sizeof(endX) +
+ sizeof(endY);
+} // ogBlit::getSize
+
+bool
+ogBlit::loadFrom(const char * filename, uInt32 offset) {
+ FILE * infile;
+ uInt32 lresult, tresult, totSize;
+ uInt32 tmpSize;
+ char header_ident[4];
+
+ if (fileExists(filename)==false) return false;
+ if ((infile = fopen(filename,"rb"))==NULL) return false;
+ fseek(infile, offset, SEEK_SET);
+
+ // for now just free up the previous image. This will be changed
+ // later so it doesn't affect the current image (if any) if there
+ // is a failure loading
+
+ free(image);
+ delete [] pal;
+ delete [] blitMask;
+ imageSize = 0;
+ blitMaskSize = 0;
+
+ tresult = 0; // total bytes we've read in so far
+
+ lresult = fread(header_ident, sizeof(header_ident), 1, infile);
+ tresult += lresult*sizeof(header_ident);
+ if ((header_ident[0]!='B') ||
+ (header_ident[1]!='L') ||
+ (header_ident[2]!='T') ||
+ (header_ident[3]!=(char)0x1A)) {
+ fclose(infile);
+ return false;
+ }
+ lresult = fread(&totSize, sizeof(totSize), 1, infile);
+ tresult += lresult*sizeof(totSize);
+
+ lresult = fread(&width, sizeof(width), 1, infile);
+ tresult += lresult*sizeof(width);
+
+ lresult = fread(&height, sizeof(height), 1, infile);
+ tresult += lresult*sizeof(height);
+
+ lresult = fread(&bitDepth, sizeof(bitDepth), 1, infile);
+ tresult += lresult*sizeof(bitDepth);
+
+ lresult = fread(&RFP, sizeof(RFP), 1, infile);
+ tresult += lresult*sizeof(RFP);
+
+ lresult = fread(&GFP, sizeof(GFP), 1, infile);
+ tresult += lresult*sizeof(GFP);
+
+ lresult = fread(&BFP, sizeof(BFP), 1, infile);
+ tresult += lresult*sizeof(BFP);
+
+ lresult = fread(&AFP, sizeof(AFP), 1, infile);
+ tresult += lresult*sizeof(AFP);
+
+ lresult = fread(&RShift, sizeof(RShift), 1, infile);
+ tresult += lresult*sizeof(RShift);
+
+ lresult = fread(&GShift, sizeof(GShift), 1, infile);
+ tresult += lresult*sizeof(GShift);
+
+ lresult = fread(&BShift, sizeof(BShift), 1, infile);
+ tresult += lresult*sizeof(BShift);
+
+ lresult = fread(&AShift, sizeof(AShift), 1, infile);
+ tresult += lresult*sizeof(AShift);
+
+ lresult = fread(&tColour, sizeof(tColour), 1, infile);
+ tresult += lresult*sizeof(tColour);
+
+ lresult = fread(&totalPixCount, sizeof(totalPixCount), 1, infile);
+ tresult += lresult*sizeof(totalPixCount);
+
+ lresult = fread(&startX, sizeof(startX), 1, infile);
+ tresult += lresult*sizeof(startX);
+
+ lresult = fread(&startY, sizeof(startY), 1, infile);
+ tresult += lresult*sizeof(startY);
+
+ lresult = fread(&endX, sizeof(endX), 1, infile);
+ tresult += lresult*sizeof(endX);
+
+ lresult = fread(&endY, sizeof(endY), 1, infile);
+ tresult += lresult*sizeof(endY);
+
+ lresult = fread(&blitMaskSize, sizeof(blitMaskSize), 1, infile);
+ tresult += lresult*sizeof(blitMaskSize);
+
+ lresult = fread(&imageSize, sizeof(imageSize), 1, infile);
+ tresult += lresult*sizeof(imageSize);
+
+ blitMask = new uInt8[blitMaskSize];
+ if (blitMask == NULL) {
+ fclose(infile);
+ return false;
+ }
+
+ image = malloc(imageSize);
+ if (image == NULL) {
+ fclose(infile);
+ return false;
+ }
+
+ // read in the blit mask
+ lresult = fread(blitMask, blitMaskSize, 1, infile);
+ tresult += lresult*blitMaskSize;
+
+ // read in the image data
+ // it's possible that if we start saving only blit masks this section will be
+ // blank
+ lresult = fread(image, 1, imageSize, infile);
+ tresult += lresult;
+
+ if (bitDepth==8) {
+ // 8bpp sprites have palettes
+ if (pal==NULL) pal = new ogRGBA[256];
+ if (pal==NULL) {
+ fclose(infile);
+ return false;
+ } // if pal==NULL
+ lresult = fread(&tmpSize, sizeof(tmpSize), 1, infile);
+ tresult += lresult*sizeof(tmpSize);
+ if (tmpSize>sizeof(ogRGBA)*256) {
+ fclose(infile);
+ return false;
+ }
+ lresult = fread(pal, tmpSize, 1, infile);
+ tresult += lresult*tmpSize;
+ } // if bitDepth == 8
+
+ fclose(infile);
+ return (tresult == totSize);
+} // ogBlit::loadFrom
+
+void
+ogBlit::put(ogSurface& DestObject, int32 x, int32 y) {
+ int32 sx, sy;
+ uInt32 nsy, ney;
+ uInt8 lineCount, offset, pixCount;
+ uInt8* blitMaskPtr;
+ void * imagePtr;
+ uInt32 distToEdge, bm, xRight, xx;
+ uInt8 r, g, b;
+ ogPixelFmt pixfmt;
+
+ // can we draw anything?
+ if ((blitMask==NULL) || (image==NULL)) return;
+ if (DestObject.ogAvail()==false) return;
+ // see if the blit is oustide the buffer
+ if ( ((x+startX)>(int32)DestObject.ogGetMaxX()) ||
+ ((y+startY)>(int32)DestObject.ogGetMaxY()) ||
+ ((x+endX)<0) || ((y+endY)<0) ) return;
+
+ blitMaskPtr = blitMask;
+ imagePtr = image;
+
+ bm = (bitDepth+7) >> 3;
+
+ // first do clipping on the top edge
+ nsy = startY;
+ if (y+startY<0) {
+ /*
+ * If we're here then part of the blit is above the top edge of the
+ * buffer. The distance to the top of the buffer is abs(y+startY).
+ * So, we need to loop through the blit geometry and advance the
+ * relative pointers (BlitMaskPtr and ImagePtr)
+ */
+ for (sy = (y+startY); sy<0; sy++) {
+ nsy++;
+ lineCount = *blitMaskPtr;
+ blitMaskPtr++;
+ while (lineCount>0) {
+ blitMaskPtr++;
+ pixCount = *blitMaskPtr;
+ blitMaskPtr++;
+ if (pixCount>0) (uInt8 *)imagePtr+=pixCount*bm;
+ lineCount--;
+ } // while
+ } // for sy
+ } // if
+
+ // Now do clipping on the bottom edge. This is easy
+ // y is guaranteed to be >=0
+ if (y+endY>(int32)DestObject.ogGetMaxY())
+ ney = (DestObject.ogGetMaxY()-y);
+ else
+ ney = endY;
+
+ DestObject.ogGetPixFmt(pixfmt);
+
+ if ( (pixfmt.BPP != bitDepth) ||
+ (pixfmt.redFieldPosition != RFP) ||
+ (pixfmt.greenFieldPosition != GFP) ||
+ (pixfmt.blueFieldPosition != BFP)) {
+ for (sy = nsy; (uInt32)sy <= ney; sy++) {
+ sx = x+startX;
+ lineCount = *blitMaskPtr;
+ blitMaskPtr++;
+ while (lineCount>0) {
+ offset = *blitMaskPtr;
+ blitMaskPtr++;
+ sx += offset;
+ pixCount = *blitMaskPtr;
+ blitMaskPtr++;
+ if (pixCount>0) {
+ if (sx<=(int32)DestObject.ogGetMaxX()) {
+ if ((sx<0) && (sx+(int32)pixCount>0)) {
+ pixCount += sx; // remember, sx is negative
+ (uInt8*)imagePtr -= sx*bm; // remember, sx is negative
+ sx = 0;
+ } // if sx<0 && sx+pixCount>0
+ if (sx+pixCount>(int32)DestObject.ogGetMaxX()) {
+ distToEdge = (DestObject.ogGetMaxX()-sx)+1;
+ xRight = (pixCount-distToEdge)*bm;
+ pixCount = distToEdge;
+ } else xRight = 0; // if sx+pixCount>MaxX
+ if (sx>=0)
+ for (xx=0; xx0) {
+ offset = *blitMaskPtr;
+ blitMaskPtr++;
+ sx += offset;
+ pixCount = *blitMaskPtr;
+ blitMaskPtr++;
+ if (pixCount>0) {
+ if (sx<=(int32)DestObject.ogGetMaxX()) {
+ if ((sx<0) && (sx+pixCount>0)) {
+ pixCount += sx; // remember, sx is negative
+ (uInt8*)imagePtr -= sx*bm; // remember, sx is negative
+ sx = 0;
+ } // if sx<0 && sx+pixCount>0
+
+ if (sx+pixCount>(int32)DestObject.ogGetMaxX()+1) {
+ distToEdge = (DestObject.ogGetMaxX()-sx)+1;
+ xRight = (pixCount - distToEdge)*bm;
+ pixCount = distToEdge;
+ } else xRight = 0; // if sx+pixCount>MaxX
+
+ if (sx>=0)
+ DestObject.ogCopyLineTo(sx,y+sy,imagePtr,pixCount*bm);
+// memcpy( ((uInt8*)DestObject.Buffer+DestObject.LineOfs[y+sy]+sx*bm),
+// imagePtr,
+// pixCount*bm);
+ (uInt8*)imagePtr += xRight;
+ } // if sx <= MaxX
+ sx += pixCount;
+ (uInt8*)imagePtr += pixCount*bm;
+ } // if pixCount>0
+ lineCount--;
+ } // while
+ } // for
+ } // else
+
+ return;
+} // ogBlit::put
+bool
+ogBlit::saveTo(const char * filename, int32 offset) {
+ /*
+ * saveTo
+ *
+ * saves a blit to disk. If the file doesn't exit then we will create
+ * a new one (doing this will ignore any specified offset). If the file
+ * exists, we will seek to the specified offset and place the bitmap there.
+ * If offset is -1, then we seek to the end of the file.
+ *
+ * This function will fail on files larger than 2GB.
+ *
+ */
+ FILE * outfile = NULL;
+ char header_ident[4];
+ uInt32 tmpSize;
+
+ if (image==NULL) return false;
+ if ((bitDepth==8) && (pal==NULL)) return false;
+
+ if (fileExists(filename)==false) { // file doesn't exist
+ if ((outfile = fopen(filename,"wb")) == NULL) return false;
+ } else {
+ // file exists. Now we check to see where we put it
+ if (offset==-1) {
+ if ((outfile = fopen(filename, "ab")) == NULL) return false;
+ } else {
+ // we have an existing file and an offset to place the data
+ if ((outfile = fopen(filename, "wb")) == NULL) return false;
+ if (offset!=0) fseek(outfile, offset, SEEK_SET);
+ } // else
+ } // else
+
+ tmpSize = getSize();
+
+ header_ident[0] = 'B';
+ header_ident[1] = 'L';
+ header_ident[2] = 'T';
+ header_ident[3] = (char)0x1A; // EOF marker
+
+ // we store exactly how bit this sucker is inside the header. This includes
+ // the header information before it, and the size itself
+ fwrite(header_ident, sizeof(header_ident), 1, outfile);
+
+ fwrite(&tmpSize, sizeof(tmpSize), 1, outfile);
+ fwrite(&width, sizeof(width), 1, outfile);
+ fwrite(&height, sizeof(height), 1, outfile);
+ fwrite(&bitDepth, sizeof(bitDepth), 1, outfile);
+
+ fwrite(&RFP, sizeof(RFP), 1, outfile);
+ fwrite(&GFP, sizeof(GFP), 1, outfile);
+ fwrite(&BFP, sizeof(BFP), 1, outfile);
+ fwrite(&AFP, sizeof(AFP), 1, outfile);
+
+ fwrite(&RShift, sizeof(RShift), 1, outfile);
+ fwrite(&GShift, sizeof(GShift), 1, outfile);
+ fwrite(&BShift, sizeof(BShift), 1, outfile);
+ fwrite(&AShift, sizeof(AShift), 1, outfile);
+
+ fwrite(&tColour, sizeof(tColour), 1, outfile);
+ fwrite(&totalPixCount, sizeof(totalPixCount), 1, outfile);
+
+ fwrite(&startX, sizeof(startX), 1, outfile);
+ fwrite(&startY, sizeof(startY), 1, outfile);
+ fwrite(&endX, sizeof(endX), 1, outfile);
+ fwrite(&endY, sizeof(endY), 1, outfile);
+
+ fwrite(&blitMaskSize, sizeof(blitMaskSize), 1, outfile);
+ fwrite(&imageSize, sizeof(imageSize), 1, outfile);
+
+ fwrite(blitMask, blitMaskSize, 1, outfile);
+ fwrite(image, 1, imageSize, outfile);
+
+ if (bitDepth == 8) {
+ tmpSize = sizeof(ogRGBA)*256;
+ fwrite(&tmpSize, sizeof(tmpSize), 1, outfile);
+ fwrite(pal, sizeof(ogRGBA), 256, outfile);
+ } // if bitDepth == 8
+
+ fclose(outfile);
+ return true;
+} // ogBlit::saveTo
+
+ogBlit::~ogBlit(void) {
+ delete [] blitMask;
+ blitMask = NULL;
+ blitMaskSize = 0;
+ return;
+} // ogBlit::~ogBlit
+
diff --git a/lockwasher/src/lib/views/ogDisplay_VESA.cpp b/lockwasher/src/lib/views/ogDisplay_VESA.cpp
new file mode 100644
index 0000000..5ea4a53
--- /dev/null
+++ b/lockwasher/src/lib/views/ogDisplay_VESA.cpp
@@ -0,0 +1,1531 @@
+#include "objgfx30.h"
+#include "defpal.inc"
+#include "ogDisplay_VESA.h"
+#include // for __tb
+#include
+#include
+#include
+#include
+#include
+
+/*
+ *
+ * ogDisplay methods
+ *
+ */
+
+void InitVESAMode(uInt16 mode) {
+ __dpmi_regs regs;
+ regs.x.ax=0x4f02;
+ regs.x.bx=mode;
+ __dpmi_int(0x10, ®s);
+ return;
+}
+
+ogDisplay_VESA::ogDisplay_VESA(void) {
+ InGraphics = false;
+ VESARec = new ogVESA_Rec;
+ modeRec = new ogMode_Rec;
+ getVESAInfo();
+
+ ScreenSelector = __dpmi_allocate_ldt_descriptors(1);
+
+ return;
+} // ogDisplay_VESA::ogDisplay_VESA
+
+uInt32
+ogDisplay_VESA::rawGetPixel(uInt32 x, uInt32 y) {
+ uInt32 result;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size
+ " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size
+ " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size
+ " add %%esi, %%edi \n" // add edi, esi
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4]
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " xor %%eax, %%eax \n"
+ " mov 2(%%edi), %%al \n" // mov al, [edi+2]
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov (%%edi), %%ax \n" // mov ax, [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size}
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4]
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " mov (%%edi),%%eax \n" // eax,word ptr [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ } // switch
+ return result;
+} // TScreen::rawGetPixel
+
+void
+ogDisplay_VESA::rawSetPixel(uInt32 x, uInt32 y, uInt32 colour) {
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4]
+ " push %%ds \n" // push ds
+ " mov %%dx, %%ds \n" // mov ds, dx
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), // %2, %3
+ "d" (ScreenSelector) // %4
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " push %%ds \n" // push ds
+ " mov %%dx, %%ds \n" // mov ds, dx
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], al
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), // %2, %3
+ "d" (ScreenSelector) // %4
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ // " add (%%esi,%%ebx,4),%%edi \n" // add edi, [esi + ebx * 4]
+ " push %%ds \n" // push ds
+ " mov %%dx, %%ds \n" // mov ds, dx
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), // %2, %3
+ "d" (ScreenSelector) // %4
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " push %%ds \n" // push ds
+ " mov %%dx, %%ds \n" // mov ds, dx
+
+ " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%eax, (%%edi) \n" // mov [edi], eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), // %2, %3
+ "d" (ScreenSelector) // %4
+ );
+ } // switch
+ return;
+} // ogDisplay_VESA::rawSetPixel
+
+void
+ogDisplay_VESA::rawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) {
+ /*
+ * ogDisplay_VESA::rawLine()
+ *
+ * private method; draws an unclipped line from (x1,y1) to (x2,y2)
+ *
+ */
+ int32 tc;
+ if (!ogAvail()) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%cx, %%ds \n" // mov ds, cx
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive8 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive8: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive8 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive8: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater8 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop8: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone8 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY8 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY8: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop8 \n"
+
+"rlyGreater8: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop8: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone8 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX8 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX8: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop8 \n"
+"rlDone8: \n"
+ " pop %%ds \n" // pop ds
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+x1), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+x2), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc), "c" (ScreenSelector) // %6, %7
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%cx, %%ds \n" // mov ds, cx
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive16 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive16: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive16 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive16: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater16 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop16: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone16 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY16 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY16: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop16 \n"
+
+"rlyGreater16: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop16: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone16 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX16 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX16: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop16 \n"
+"rlDone16: \n"
+ " pop %%ds \n" // pop ds
+
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 1)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 1)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc), "c" (ScreenSelector) // %6, %7
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%cx, %%ds \n" // mov ds, cx
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive24 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive24: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive24 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive24: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater24 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop24: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone24 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY24 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY24: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop24 \n"
+
+"rlyGreater24: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop24: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone24 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX24 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX24: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop24 \n"
+"rlDone24: \n"
+ " pop %%ds \n" // pop ds
+
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1*3)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2*3)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc), "c" (ScreenSelector) // %6, %7
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%cx, %%ds \n" // mov ds, cx
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive32 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive32: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive32 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive32: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater32 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop32: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone32 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY32 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY32: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop32 \n"
+
+"rlyGreater32: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop32: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone32 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX32 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX32: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop32 \n"
+"rlDone32: \n"
+ " pop %%ds \n" // pop ds
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 2)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 2)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc), "c" (ScreenSelector) // %6, %7
+ );
+ break;
+ } // switch
+ return;
+} // ogDisplay_VESA::rawLine
+
+bool
+ogDisplay_VESA::ogAvail(void) {
+ return ( ((ScreenSelector!=0) || (buffer!=NULL)) && (lineOfs!=NULL));
+} // ogDisplay_VESA::ogAvail
+
+void
+ogDisplay_VESA::getModeInfo(uInt16 mode) {
+ __dpmi_regs regs;
+ memset(modeRec, 0,sizeof(struct ogMode_Rec));
+ memset(®s, 0, sizeof(regs));
+ dosmemput(modeRec, sizeof(struct ogMode_Rec), __tb);
+
+ int ofs, seg;
+
+ seg = __tb; // __tb is a buffer located in "dos memory". This buffer
+ ofs = __tb; // is used because the vesa driver cannot acces memory
+ // above 1 MB (your program is most likely to be located above 1MB).
+
+ ofs &= 0xffff; // Make a real pointer (segment:offse = 16:16)
+ seg &= 0xffff0000; // from the address of the buffer.
+ seg >>= 4;
+
+ regs.x.ax = 0x4f01; // Get the modeinfo of a certain vesa video mode,
+ // this is a structure which contains.
+ regs.x.cx = mode; // information needed by other functions below.
+ regs.x.es = seg;
+ regs.x.di = ofs;
+ __dpmi_int(0x10, ®s);
+
+ dosmemget(__tb,sizeof(struct ogMode_Rec),modeRec); // This info is located in dos memory, so
+ // it has to be moved to your program's
+ // addres space.
+ return;
+
+} // ogDisplay_VESA::getModeInfo
+
+void
+ogDisplay_VESA::getVESAInfo(void) {
+ unsigned int seg, ofs;
+ __dpmi_regs regs;
+ if (VESARec==NULL) VESARec = new ogVESA_Rec;
+ if (VESARec==NULL) return;
+
+ memset(VESARec,0,sizeof(struct ogVESA_Rec));
+ memset(®s, 0, sizeof(regs));
+ VESARec->VBESignature[0] = 'V'; // First off initialize the structure.
+ VESARec->VBESignature[1] = 'B';
+ VESARec->VBESignature[2] = 'E';
+ VESARec->VBESignature[3] = '2';
+
+ /*
+
+ Because VBE funtions operate in real mode, we first have to move the
+ initialized structure to real-mode address space, so the structure can
+ be filled by the vesa function in real mode.
+
+ */
+ dosmemput(VESARec, sizeof(struct ogVESA_Rec), __tb);
+
+
+ seg = __tb; // Calculate real mode addres of the buffer.
+ ofs = __tb;
+ ofs &= 0xffff;
+ seg &= 0xffff0000;
+ seg >>= 4;
+
+ regs.x.ax = 0x4F00;
+ regs.x.es = seg;
+ regs.x.di = ofs;
+
+ __dpmi_int(0x10, ®s); // Get vesa info.
+
+ dosmemget(__tb, sizeof(struct ogVESA_Rec), VESARec); // Move the structure back to
+
+ VESARec->OEMStringPtr = (VESARec->OEMStringPtr & 0xFFFF) +
+ ((VESARec->OEMStringPtr & 0xFFFF0000) >> 12);
+ VESARec->OEMVendorNamePtr= (VESARec->OEMVendorNamePtr& 0xFFFF) +
+ ((VESARec->OEMVendorNamePtr& 0xFFFF0000) >> 12);
+ VESARec->OEMProductNamePtr= (VESARec->OEMProductNamePtr& 0xFFFF) +
+ ((VESARec->OEMProductNamePtr& 0xFFFF0000) >> 12);
+ VESARec->OEMProductRevPtr= (VESARec->OEMProductRevPtr& 0xFFFF) +
+ ((VESARec->OEMProductRevPtr& 0xFFFF0000) >> 12);
+ VESARec->VideoModePtr = ((VESARec->VideoModePtr & 0xFFFF0000) >> 12) +
+ (VESARec->VideoModePtr & 0xFFFF);
+
+ return;
+} // ogDisplay_VESA::getVESAInfo
+
+uInt16
+ogDisplay_VESA::findMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) {
+ uInt16 mode;
+
+ if ((_xRes==320) && (_yRes==200) && (_BPP==8)) return 0x13;
+
+// if ((VESARec==NULL) || (VESARec->VideoModePtr==NULL)) return 0;
+ if (modeRec==NULL) return 0;
+ for (mode = 0x100; mode < 0x1FF; mode++) {
+ getModeInfo(mode);
+ if ((modeRec->xRes>=_xRes) && (modeRec->yRes>=_yRes) &&
+ (modeRec->BitsPerPixel==_BPP))
+ return mode;
+ }
+
+ return 0;
+} // ogDisplay_VESA::findMode
+
+void
+ogDisplay_VESA::setMode(uInt16 mode) {
+ uInt32 size, count;
+ __dpmi_meminfo mem_info;
+
+ if (mode==0x13) {
+
+ xRes = 320;
+ yRes = 200;
+ maxX = 319;
+ maxY = 199;
+ BPP = 8;
+
+ redFieldPosition = 0;
+ greenFieldPosition = 0;
+ blueFieldPosition = 0;
+ alphaFieldPosition = 0;
+
+ redShifter = 0;
+ greenShifter = 0;
+ blueShifter = 0;
+ alphaFieldPosition = 0;
+
+ mem_info.address = 0xA0000;
+ mem_info.size = 64000;
+ size = 63999;
+ buffer = NULL;
+ __dpmi_physical_address_mapping(&mem_info);
+ __dpmi_set_segment_base_address(ScreenSelector, mem_info.address);
+ __dpmi_set_segment_limit(ScreenSelector,size);
+ __dpmi_set_descriptor_access_rights(ScreenSelector, 0x40F3);
+
+ } else {
+ buffer = NULL;
+ mode |= 0x4000; // attempt lfb
+ getModeInfo(mode);
+ if (modeRec->physBasePtr == 0) return;
+ size = modeRec->yRes*modeRec->BytesPerLine;
+
+ xRes = modeRec->BytesPerLine;
+ yRes = modeRec->yRes;
+ maxX = modeRec->xRes-1;
+ maxY = yRes-1;
+
+ redFieldPosition = modeRec->RedFieldPosition;
+ greenFieldPosition = modeRec->GreenFieldPosition;
+ blueFieldPosition = modeRec->BlueFieldPosition;
+
+ redShifter = 8-modeRec->RedMaskSize;
+ greenShifter = 8-modeRec->GreenMaskSize;
+ blueShifter = 8-modeRec->BlueMaskSize;
+
+ BPP = modeRec->BitsPerPixel;
+
+ mem_info.address = modeRec->physBasePtr;
+ mem_info.size = size;
+ size = ((size+4095) >> 12);
+ __dpmi_physical_address_mapping(&mem_info);
+ __dpmi_set_segment_base_address(ScreenSelector, mem_info.address);
+ __dpmi_set_segment_limit(ScreenSelector,size);
+ __dpmi_set_descriptor_access_rights(ScreenSelector, 0xC0F3);
+ } // else
+
+ owner = this;
+ dataState = ogALIASING;
+ InGraphics = true;
+
+ if ((lineOfs!=NULL) && (lSize!=0)) delete [] lineOfs;
+ lSize = yRes*sizeof(uInt32);
+ lineOfs = new uInt32[yRes];;
+ if (lineOfs == NULL) return;
+ lineOfs[0] = 0;
+ for (count=1; count8);
+ if (BPP==8) setPal();
+ ogClear(0);
+ return;
+} // ogDisplay_VESA::setMode
+
+void
+ogDisplay_VESA::setPal(void) {
+ uInt32 c;
+ if (BPP!=8) return;
+ outportb(0x3c8,0);
+ for (c=0; c<256; c++) {
+ outportb(0x3c9,pal[c].red >> 2);
+ outportb(0x3c9,pal[c].green >> 2);
+ outportb(0x3c9,pal[c].blue >> 2);
+ } // for
+ return;
+} // ogDisplay_VESA::setPal
+
+bool
+ogDisplay_VESA::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) {
+ return false;
+} // ogDisplay_VESA::ogAlias
+
+void
+ogDisplay_VESA::ogClear(uInt32 colour) {
+ uInt32 height;
+ if (!ogAvail()) return;
+ __asm__ __volatile__("cld\n");
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " push %%es \n" // push es
+ " mov %6, %%ax \n" // mov ax, ScreenSelector
+ " mov %%ax, %%es \n" // mov es, ax
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxY)
+ " inc %%ebx \n" // inc ebx (maxX)
+ " mov %5, %%eax \n" // mov eax, colour
+ " sub %%edx, %%esi \n" // sub esi, edx
+ " mov %%al, %%ah \n" // mov ah, al
+ " mov %%ax, %%cx \n" // mov cx, ax
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov %%cx, %%ax \n" // mov ax, cx
+ "loop8: \n"
+ " push %%edx \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " and $3, %%edx \n" // and edx, 3
+ " shr $2, %%ecx \n" // shr ecx, 2
+ " rep \n"
+ " stosl \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " rep \n"
+ " stosb \n"
+ " pop %%edx \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop8 \n"
+ " pop %%es \n" // pop es
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4
+ "m" (colour), "m" (ScreenSelector) // %5, %6
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " push %%es \n" // push es
+ " mov %6, %%ax \n" // mov ax, ScreenSelector
+ " mov %%ax, %%es \n" // mov es, ax
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " sub %%edx, %%esi \n" // sub esi, edx
+ " mov %5, %%eax \n" // mov eax, colour
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%ax, %%cx \n" // mov cx, ax
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov %%cx, %%ax \n" // mov ax, cx
+ "loop16: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " rep \n"
+ " stosl \n"
+ " jnc noc16 \n"
+ " stosw \n"
+ "noc16: \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop16 \n"
+ " pop %%es \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4
+ "m" (colour), "m" (ScreenSelector) // %5, %6
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " push %%es \n" // push es
+ " mov %7, %%ax \n" // mov ax, ScreenSelector
+ " mov %%ax, %%es \n" // mov es, ax
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " mov %5, %%eax \n" // mov eax, colour
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%ebx, %6 \n" // mov height, ebx
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%eax, %%ebx \n" // mov ebx, eax
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " shr $16, %%ebx \n" // shr ebx, 16
+ "oloop24: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ "iloop24: \n"
+ " mov %%ax,(%%edi) \n" // mov [edi],ax
+ " movb %%bl,2(%%edi) \n" // mov [edi+2],bl
+ " add $3, %%edi \n" // add edi, 3
+ " dec %%ecx \n" // dec ecx
+ " jnz iloop24 \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " decl %6 \n" // dec height
+ " jnz oloop24 \n"
+ " pop %%es \n" // pop es
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4
+ "m" (colour), "m" (height), // %5, %6
+ "m" (ScreenSelector) // %7
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " push %%es \n" // push es
+ " mov %6, %%ax \n" // mov ax, ScreenSelector
+ " mov %%ax, %%es \n" // mov es, ax
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " shl $2, %%ecx \n" // shl ecx, 2
+ " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size
+ "loop32: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " rep \n"
+ " stosl \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop32 \n"
+ " pop %%es \n" // pop es
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4
+ "m" (colour), "m" (ScreenSelector) // %5, %6
+ );
+ break;
+ } // switch
+ return;
+} // ogDisplay_VESA::ogClear
+
+void
+ogDisplay_VESA::ogCopyLineTo(uInt32 dx, uInt32 dy, const void * src,
+ uInt32 size) {
+ /*
+ * ogCopyLineTo()
+ *
+ * Inputs:
+ *
+ * dx - Destination X of the target buffer
+ * dy - Destination Y of the target buffer
+ * src - buffer to copy
+ * size - size in bytes *NOT* pixels
+ *
+ * Copies a run of pixels (of the same format) to (x,y) of a buffer
+ *
+ * This method is required because of the different implementations of
+ * copying a run of pixels to a buffer
+ *
+ * WARNING!!! This does *NO* error checking. It is assumed that you've
+ * done all of that. ogCopyLineTo and ogCopyLineFrom are the only
+ * methods that don't check to make sure you're hosing things. Don't
+ * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!!
+ */
+ movedata(_my_ds(),(uInt32)src,
+ ScreenSelector,(uInt32)((uInt8*)buffer+(lineOfs[dy]+dx*( (BPP+7) >> 3) ) ),
+ size);
+
+ return;
+} // ogSurface::ogCopyLineTo
+
+void
+ogDisplay_VESA::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dest, uInt32 size) {
+ /*
+ * ogCopyLineFrom()
+ *
+ * Inputs:
+ *
+ * sx - Source X of the target buffer
+ * sy - Source Y of the target buffer
+ * dest - where to put it
+ * size - size in bytes *NOT* pixels
+ *
+ * Copies a run of pixels (of the same format) to (x,y) of a buffer
+ *
+ * This method is required because of the different implementations of
+ * copying a run of pixels to a buffer
+ *
+ * WARNING!!! This does *NO* error checking. It is assumed that you've
+ * done all of that. ogCopyLineTo and ogCopyLineFrom are the only
+ * methods that don't check to make sure you're hosing things. Don't
+ * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!!
+ */
+ movedata(ScreenSelector,(uInt32)((uInt8*)buffer+(lineOfs[sy]+sx*( (BPP+7) >> 3) ) ),
+ _my_ds(),(uInt32)dest,
+ size);
+
+ return;
+} // ogDisplay_VESA::ogCopyLineFrom
+
+bool
+ogDisplay_VESA::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) {
+ uInt16 mode;
+ mode = findMode(_xRes, _yRes, _pixFormat.BPP);
+ if ((mode == 0) && ((_pixFormat.BPP==24) || (_pixFormat.BPP==32))) {
+ if (_pixFormat.BPP==24) _pixFormat.BPP=32; else _pixFormat.BPP=24;
+ mode=findMode(_xRes,_yRes,_pixFormat.BPP);
+ } // if
+ if (mode!=0) setMode(mode);
+ return (mode!=0);
+} // ogDisplay_VESA::ogCreate
+
+bool
+ogDisplay_VESA::ogClone(ogSurface& SrcObject) {
+ return false;
+} // ogDisplay_VESA::ogClone
+
+void
+ogDisplay_VESA::ogCopyPal(ogSurface& SrcObject) {
+ ogSurface::ogCopyPal(SrcObject);
+ setPal();
+ return;
+} // ogDisplay_VESA::ogCopyPal
+
+uInt32
+ogDisplay_VESA::ogGetPixel(int32 x, int32 y) {
+ uInt32 result;
+ if (!ogAvail()) return transparentColor;
+ if (((uInt32)x>maxX) || ((uInt32)y>maxY))
+ return transparentColor;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size
+ " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size
+ " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size
+ " add %%esi, %%edi \n" // add edi, esi
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4]
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " xor %%eax, %%eax \n"
+ " mov 2(%%edi), %%al \n" // mov al, [edi+2]
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov (%%edi), %%ax \n" // mov ax, [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax (ScreenSelector)
+ " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size}
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4]
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " mov (%%edi),%%eax \n" // eax,word ptr [edi]
+ " mov %%eax, %4 \n" // mov result, eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "a" (ScreenSelector), "c" (x), "m" (result) // %2, %3, %4
+ );
+ } // switch
+ return result;
+} // TScreen::ogGetPixel
+
+void *
+ogDisplay_VESA::ogGetPtr(uInt32 x, uInt32 y) {
+ return NULL;
+} // ogDisplay_VESA::ogGetPtr
+
+void
+ogDisplay_VESA::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) {
+ int32 tmp;
+
+ if (!ogAvail()) return;
+ if ((uInt32)y>maxY) return;
+ if (x1>x2) {
+ tmp= x1;
+ x1 = x2;
+ x2 = tmp;
+ } // if
+ if (x1<0) x1 = 0;
+ if (x2>(int32)maxX) x2=maxX;
+ if (x2maxX) || ((uInt32)y>maxY)) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " push %%ds \n"
+ " mov %4, %%dx \n"
+ " mov %%dx, %%ds \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%ds\n"
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " push %%ds \n"
+ " mov %4, %%dx \n"
+ " mov %%dx, %%ds \n"
+
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " mov %3, %%eax \n" // mov eax, colour
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], al
+ " pop %%ds\n"
+
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " push %%ds \n" // push ds
+ " mov %4, %%dx \n" // mov dx, ScreenSelector
+ " mov %%dx, %%ds \n" // mov ds, dx
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " push %%ds \n" // push ds
+ " mov %4, %%dx \n" // mov dx, ScreenSelector
+ " mov %%dx, %%ds \n" // mov ds, dx
+ " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%ds \n" // pop ds
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour), "m" (ScreenSelector) // %2, %3, %4
+ );
+ } // switch
+ return;
+} // ogDisplay_VESA::ogSetPixel
+
+void
+ogDisplay_VESA::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) {
+ if (pal==NULL) return;
+ ogSurface::ogSetRGBPalette(colour,red,green,blue);
+ outportb(0x3c8,colour);
+ outportb(0x3c9,red >> 2);
+ outportb(0x3c9,green >> 2);
+ outportb(0x3c9,blue >> 2);
+
+ return;
+} // ogDisplay_VESA::ogSetRGBPalette
+
+void
+ogDisplay_VESA::ogVFlip(void) {
+ if (!ogAvail()) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf8lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf8lop2: \n"
+ " mov (%%edi),%%al \n" // mov al, [edi]
+ " mov (%%esi),%%ah \n" // mov ah, [esi]
+ " mov %%al,(%%esi) \n" // mov [esi], al
+ " mov %%ah,(%%edi) \n" // mov [edi], ah
+ " inc %%edi \n" // inc edi
+ " dec %%esi \n" // dec esi
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf8lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf8lop \n"
+ " pop %%ds \n" // pop ds
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1
+ "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf16lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf16lop2: \n"
+ " mov (%%edi),%%ax \n" // mov ax, [edi]
+ " mov (%%esi),%%cx \n" // mov cx, [esi]
+ " mov %%ax,(%%esi) \n" // mov [esi], ax
+ " mov %%cx,(%%edi) \n" // mov [edi], cx
+ " add $2, %%edi \n" // add edi, 2
+ " sub $2, %%esi \n" // sub esi, 2
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf16lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf16lop \n"
+ " pop %%ds \n" // pop ds
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1
+ "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf24lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf24lop2: \n"
+ " mov (%%edi),%%ax \n" // mov ax, [edi]
+ " mov 2(%%edi),%%dl \n" // mov dl, [edi+2]
+ " mov (%%esi),%%cx \n" // mov cx, [esi]
+ " mov 2(%%esi),%%dh \n" // mov dh, [esi+2]
+ " mov %%ax,(%%esi) \n" // mov [esi], ax
+ " mov %%dl,2(%%esi) \n" // mov [esi+2], dl
+ " mov %%cx,(%%edi) \n" // mov [edi], cx
+ " mov %%dh,2(%%edi) \n" // mov [edi+2], dh
+ " add $3, %%edi \n" // add edi, 3
+ " sub $3, %%esi \n" // sub esi, 3
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf24lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " decl %3 \n" // dec height
+ " jnz vf24lop \n"
+ " pop %%ds \n" // pop ds
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1
+ "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4
+ );
+ break;
+
+ case 32:
+ __asm__ __volatile__(
+ " push %%ds \n" // push ds
+ " mov %%ax, %%ds \n" // mov ds, ax
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf32lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf32lop2: \n"
+ " mov (%%edi),%%eax \n" // mov eax, [edi]
+ " mov (%%esi),%%ecx \n" // mov ecx, [esi]
+ " mov %%eax,(%%esi) \n" // mov [esi], eax
+ " mov %%ecx,(%%edi) \n" // mov [edi], ecx
+ " add $4, %%edi \n" // add edi, 4
+ " sub $4, %%esi \n" // sub esi, 4
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf32lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf32lop \n"
+ " pop %%ds \n" // pop ds
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1
+ "b" (xRes), "d" (maxY+1), "a" (ScreenSelector) // %2, %3, %4
+ );
+
+ } // switch
+ return;
+} // ogDisplay_VESA::ogVFlip
+
+void
+ogDisplay_VESA::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) {
+ int32 tmp;
+ if (!ogAvail()) return;
+ if ((uInt32)x>maxX) return;
+ if (y1>y2) {
+ tmp= y1;
+ y1 = y2;
+ y2 = tmp;
+ } // if
+ if (y1<0) y1 = 0;
+ if (y2>(int32)maxY) y2 = maxY;
+ if (y2
+ #include
+ #include
+ }
+#include "ogFont.h"
+#include "objgfx30.h"
+
+ogBitFont::ogBitFont(void) {
+ memset(fontDataIdx,0,sizeof(fontDataIdx));
+ memset(charWidthTable,0,sizeof(charWidthTable));
+ memset(charHeightTable,0,sizeof(charHeightTable));
+ fontData = NULL;
+ fontDataSize = 0;
+ width = 0;
+ height = 0;
+ numOfChars = 0;
+ startingChar = 0;
+ BGColour.red = 0;
+ BGColour.green = 0;
+ BGColour.blue = 0;
+ FGColour.red = 255;
+ FGColour.green = 255;
+ FGColour.blue = 255;
+ return;
+} // ogBitFont::ogBitFont
+
+void
+ogBitFont::centerTextX(ogSurface& buf, int32 y, const char * TextString ) {
+ int32 x;
+ x = ((buf.ogGetMaxX()+1)-textWidth(TextString)) / 2;
+ putString(buf,x,y,TextString);
+ return;
+} // ogBitFont::centerTextX
+
+void
+ogBitFont::justifyText(ogSurface& buf, uInt8 horiz, uInt8 vert, const char * textString) {
+ uInt32 x,y;
+ if (textString==NULL) return;
+ switch (horiz) {
+ case LeftText:
+ x = 0;
+ break;
+ case CenterText:
+ x = ((buf.ogGetMaxX())-textWidth(textString)) / 2;
+ break;
+ case RightText:
+ x = (buf.ogGetMaxX())-textWidth(textString);
+ break;
+ default:
+ return;
+ } // switch
+
+ switch (vert) {
+ case TopText:
+ y = 0;
+ break;
+ case CenterText:
+ y = ((buf.ogGetMaxY())-height) / 2;
+ break;
+ case BottomText:
+ y = (buf.ogGetMaxY())-height;
+ default:
+ return;
+ } // switch
+ putString(buf,x,y,textString);
+ return;
+} // ogBitFont::justifyText
+
+bool
+ogBitFont::load(const char* fontFile) {
+ return loadFrom(fontFile,0);
+} // ogBitFont::Load
+
+bool
+ogBitFont::save(const char* fontFile) {
+ return saveTo(fontFile,0);
+} // ogBitFont::save
+
+uInt32
+ogBitFont::textWidth(const char * textString) {
+ uInt32 size=0;
+ if (textString==NULL) return 0;
+ while (*textString)
+ size+=charWidthTable[(uInt8)*(textString++)];
+ return size;
+} // ogBitFont::textWidth
+
+void
+ogBitFont::setBGColor(uInt8 r, uInt8 g, uInt8 b) {
+ BGColour.red = r;
+ BGColour.green = g;
+ BGColour.blue = b;
+ return;
+} // ogBitFont::setBGColor
+
+void
+ogBitFont::setFGColor(uInt8 r, uInt8 g, uInt8 b) {
+ FGColour.red = r;
+ FGColour.green = g;
+ FGColour.blue = b;
+ return;
+} // ogBitFont::setFGColor
+
+void
+ogBitFont::putString(ogSurface& buf, int32 x, int32 y, const char * textString) {
+ char ch;
+ if (fontData==NULL) return;
+ if (textString==NULL) return;
+ if (buf.ogAvail()==false) return;
+ buf.ogFillRect(x,y,x+textWidth(textString)-1,y+textHeight(textString)-1,
+ buf.ogRGB(BGColour.red, BGColour.green, BGColour.blue));
+ while (*textString) {
+ ch = *textString++;
+ putChar(buf, x, y, ch);
+ x+=charWidthTable[(uInt8)ch];
+ } // while
+} // ogBitFont::putString
+
+void
+ogBitFont::putChar(ogSurface& buf, int32 x, int32 y, const char ch) {
+ uInt32 xx, xcount, ycount;
+ uInt8 * offset;
+ uInt8 bits = 0;
+ uInt32 colour;
+ if (fontData==NULL) return;
+ if (buf.ogAvail()==false) return;
+ if (charWidthTable[(uInt8)ch]!=0) {
+ colour = buf.ogRGB(FGColour.red,FGColour.green,FGColour.blue);
+ offset=(uInt8 *)(fontData);
+ offset+=fontDataIdx[(uInt8)ch];
+ for (ycount = 0; ycount<=(uInt32)(height-1); ycount++) {
+ xcount = charWidthTable[(uInt8)ch];
+ xx = 0;
+ do {
+ if ((xx & 7)==0) bits = *(offset++);
+ if (bits & 128)
+ buf.ogSetPixel(x+xx,y+ycount,colour);
+ bits+=bits;
+ xx++;
+ } while (--xcount);
+ } // for
+ } // if
+} // ogBitFont::putChar
+
+bool
+ogBitFont::loadFrom(const char * fontFile, uInt32 offset) {
+ FILE * infile;
+ ogDPFHeader header;
+ uInt32 lresult, size;
+ free(fontData);
+ infile = fopen(fontFile,"rb");
+ fseek(infile,offset,SEEK_SET);
+ lresult = fread(&header,sizeof(header),1,infile);
+ width = header.width;
+ height = header.height;
+ numOfChars = header.numOfChars;
+ if (numOfChars==0) numOfChars = 256;
+ startingChar = header.startingChar;
+
+ memset(fontDataIdx,0,sizeof(fontDataIdx));
+ memset(charWidthTable,0,sizeof(charWidthTable));
+ memset(charHeightTable,0,sizeof(charHeightTable));
+
+ size = ((width+7) / 8)*height;
+ fontDataSize = size*numOfChars;
+
+ for (int tmp=startingChar; tmp<=startingChar+numOfChars-1; tmp++) {
+ charWidthTable[tmp]=width;
+ charHeightTable[tmp]=height;
+ fontDataIdx[tmp]=(size*(tmp-startingChar));
+ } // for
+ fontData = malloc(fontDataSize);
+ lresult = fread(fontData,1,fontDataSize,infile);
+ fclose(infile);
+ return true;
+} // ogBitFont::loadFrom
+
+bool
+ogBitFont::saveTo(const char *, int32) {
+ return false;
+} // ogBitFont::saveTo
+
+ogBitFont::~ogBitFont(void) {
+ if (fontDataSize) free(fontData);
+ return;
+} // ogBitFont::~ogBitFont
+
+
diff --git a/lockwasher/src/lib/views/ogSprite.cpp b/lockwasher/src/lib/views/ogSprite.cpp
new file mode 100644
index 0000000..42e87a6
--- /dev/null
+++ b/lockwasher/src/lib/views/ogSprite.cpp
@@ -0,0 +1,552 @@
+extern "C" {
+#include
+#include
+#include
+ }
+#include "objgfx30.h"
+#include "ogSprite.h"
+
+static bool
+fileExists(const char *file)
+{
+ FILE *f = fopen(file, "r");
+ if (!f)
+ return false;
+ fclose(f);
+ return true;
+}
+
+ogSprite::ogSprite(void) {
+ image = NULL;
+ pal = NULL;
+ imageSize = 0;
+ width = 0;
+ height = 0;
+ bitDepth = 0;
+ RFP = 0;
+ GFP = 0;
+ BFP = 0;
+ AFP = 0;
+ RShift = 0;
+ GShift = 0;
+ BShift = 0;
+ AShift = 0;
+ tColour = 0;
+ return;
+} // ogSprite
+
+void
+ogSprite::get(ogSurface& SrcObject, int32 x1, int32 y1, int32 x2, int32 y2) {
+ ogPixelFmt pixfmt;
+ uInt32 xx,yy,xOfs,yOfs;
+ uInt32 rx1, ry1, rx2, ry2;
+ uInt32 xCount, yCount, count;
+ void *p;
+ uInt32 bm; // bit multiplier
+ uInt32 MaxX, MaxY;
+
+ if (SrcObject.ogAvail()==false) return;
+
+ free(image);
+ free(pal);
+
+ MaxX = SrcObject.ogGetMaxX();
+ MaxY = SrcObject.ogGetMaxY();
+ tColour = SrcObject.ogGetTransparentColor();
+
+ SrcObject.ogGetPixFmt(pixfmt);
+
+ bitDepth = pixfmt.BPP;
+ RFP = pixfmt.redFieldPosition;
+ GFP = pixfmt.greenFieldPosition;
+ BFP = pixfmt.blueFieldPosition;
+ AFP = pixfmt.alphaFieldPosition;
+ RShift = 8-pixfmt.redMaskSize;
+ GShift = 8-pixfmt.greenMaskSize;
+ BShift = 8-pixfmt.blueMaskSize;
+ AShift = 8-pixfmt.alphaMaskSize;
+
+ if (bitDepth==8) {
+ if (pal==NULL) pal = new ogRGBA[256];
+ if (pal==NULL) return;
+ for (count=0; count<256; count++)
+ SrcObject.ogUnpackRGB(count,pal[count].red, pal[count].green, pal[count].blue);
+// memcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256);
+ } // if
+
+ bm = ((bitDepth+7) >> 3);
+
+ if (x1>x2) {
+ xx = x1;
+ x1 = x2;
+ x2 = xx;
+ } // if
+
+ if (y1>y2) {
+ yy = y1;
+ y1 = y2;
+ y2 = yy;
+ } // if
+
+ xCount = abs(x2-x1)+1;
+ yCount = abs(y2-y1)+1;
+ width = xCount;
+ height = yCount;
+ imageSize = xCount*yCount*bm;
+ image = malloc(imageSize);
+ p = image;
+
+ if ( ((uInt32)x1>MaxX) || ((uInt32)y1>MaxY) ||
+ ((uInt32)x2>MaxX) || ((uInt32)y2>MaxY) ) {
+ for (count=0; count(int32)MaxX) {
+ xCount -= MaxX-x2+1;
+ rx2 = MaxX;
+ } else rx2 = x2;
+
+ if (y2>(int32)MaxY) {
+ yCount -= MaxY-y2+1;
+ ry2=MaxY;
+ } else ry2 = y2;
+
+ xCount *= bm;
+// rx1 *= bm;
+ for (yy=0; yysizeof(ogRGBA)*256) {
+ fclose(infile);
+ return false;
+ }
+ lresult = fread(pal, tmpSize, 1, infile);
+ tresult += lresult*tmpSize;
+ } // if bitDepth == 8
+
+ fclose(infile);
+ return (tresult == totSize);
+} // ogSprite::loadFrom;
+
+void
+ogSprite::put(ogSurface& DestObject, int32 x, int32 y) {
+ uInt32 xx, yy, bm;
+ int32 xCount, yCount;
+ uInt32 yOfs;
+ uInt32 xLeft, xRight;
+ int32 MaxX, MaxY;
+ void * p;
+ uInt8 r,g,b;
+ ogPixelFmt pixfmt;
+
+ if (image==NULL) return;
+ if (DestObject.ogAvail()==false) return;
+
+ MaxX = DestObject.ogGetMaxX();
+ MaxY = DestObject.ogGetMaxY();
+
+ xCount = width;
+ yCount = height;
+ bm = (bitDepth+7) >> 3;
+
+ // check to see if the image is totally off the screen
+ if ((x+xCount<0) || (y+yCount<0) || (x>(int32)MaxX) || (y>(int32)MaxY)) return;
+
+ p = image;
+ if (y<0) {
+ yOfs = abs(y)*xCount*bm;
+ yCount+=y;
+ y=0;
+ } else yOfs=0;
+
+ if (x<0) {
+ xLeft = abs(x)*bm;
+ xCount += x;
+ x = 0;
+ } else xLeft = 0;
+
+ if (x+xCount > MaxX) {
+ xRight = (xCount - (MaxX-x+1))*bm;
+ xCount = (MaxX-x)+1;
+ } else xRight = 0;
+
+ if ((y+yCount)>MaxY) yCount = (MaxY-y)+1;
+
+ DestObject.ogGetPixFmt(pixfmt);
+
+ (uInt8 *)p += yOfs;
+
+ if ((pixfmt.BPP!=bitDepth) ||
+ (pixfmt.redFieldPosition!=RFP) ||
+ (pixfmt.greenFieldPosition!=GFP) ||
+ (pixfmt.blueFieldPosition!=BFP)) {
+ for (yy=0; yy<(uInt32)yCount; yy++) {
+ (uInt8 *)p += xLeft;
+ for (xx=0; xx<(uInt32)xCount; xx++) {
+ unpackRGB(getPixel(p),r,g,b);
+ (uInt8 *)p += bm;
+ DestObject.ogSetPixel(x+xx,y+yy,DestObject.ogRGB(r,g,b));
+ } // for
+ (uInt8 *)p += xRight;
+ } // for
+ } // if
+ else { // pixel formats match
+ xCount *= bm;
+// x *= (pixfmt.BPP+7) >> 3;
+ for (yy=0; yy<(uInt32)yCount; yy++) {
+ (uInt8 *)p += xLeft;
+ DestObject.ogCopyLineTo(x,y+yy,p,xCount);
+// memcpy((uInt8 *)DestObject.Buffer+DestObject.LineOfs[y+yy]+x,p,xCount);
+ (uInt8 *)p += xCount;
+ (uInt8 *)p += xRight;
+ } // for
+ } // else
+ return;
+} // ogSurface::put
+
+bool
+ogSprite::save(const char * filename) {
+ return saveTo(filename,0);
+} // ogSprite::save
+
+bool
+ogSprite::saveTo(const char * filename, int32 offset) {
+ /*
+ * saveTo
+ *
+ * saves a bitmap to disk. If the file doesn't exit then we will create
+ * a new one (doing this will ignore any specified offset). If the file
+ * exists, we will seek to the specified offset and place the bitmap there.
+ * If offset is -1, then we seek to the end of the file.
+ *
+ * This function will fail on files larger than 2GB.
+ *
+ */
+ FILE * outfile = NULL;
+ char header_ident[4];
+ uInt32 tmpSize;
+
+ if (image==NULL) return false;
+ if ((bitDepth==8) && (pal==NULL)) return false;
+
+ if (fileExists(filename)==false) { // file doesn't exist
+ if ((outfile = fopen(filename,"wb")) == NULL) return false;
+ } else {
+ // file exists. Now we check to see where we put it
+ if (offset==-1) {
+ if ((outfile = fopen(filename, "ab")) == NULL) return false;
+ } else {
+ // we have an existing file and an offset to place the data
+ if ((outfile = fopen(filename, "wb")) == NULL) return false;
+ if (offset!=0) fseek(outfile, offset, SEEK_SET);
+ } // else
+ } // else
+ header_ident[0] = 'S';
+ header_ident[1] = 'P';
+ header_ident[2] = 'R';
+ header_ident[3] = (char)0x1A; // EOF marker
+
+ // we store exactly how bit this sucker is inside the header. This includes
+ // the header information before it, and the size itself
+ tmpSize = getSize();
+ fwrite(header_ident, sizeof(header_ident), 1, outfile);
+
+ fwrite(&tmpSize, sizeof(tmpSize), 1, outfile);
+ fwrite(&width, sizeof(width), 1, outfile);
+ fwrite(&height, sizeof(height), 1, outfile);
+ fwrite(&bitDepth, sizeof(bitDepth), 1, outfile);
+
+ fwrite(&RFP, sizeof(RFP), 1, outfile);
+ fwrite(&GFP, sizeof(GFP), 1, outfile);
+ fwrite(&BFP, sizeof(BFP), 1, outfile);
+ fwrite(&AFP, sizeof(AFP), 1, outfile);
+
+ fwrite(&RShift, sizeof(RShift), 1, outfile);
+ fwrite(&GShift, sizeof(GShift), 1, outfile);
+ fwrite(&BShift, sizeof(BShift), 1, outfile);
+ fwrite(&AShift, sizeof(AShift), 1, outfile);
+
+ fwrite(&imageSize, sizeof(imageSize), 1, outfile);
+ fwrite(image, imageSize, 1, outfile);
+
+ if (bitDepth == 8) {
+ tmpSize = sizeof(ogRGBA)*256;
+ fwrite(&tmpSize, sizeof(tmpSize), 1, outfile);
+ fwrite(pal, sizeof(ogRGBA), 256, outfile);
+ } // if bitDepth == 8
+
+ fclose(outfile);
+ return true;
+} // ogSprite::saveTo
+
+void
+ogSprite::unpackRGB(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) {
+ switch (bitDepth) {
+ case 8:
+ if (colour>255) colour&=255;
+ if (pal==NULL) return;
+ red=pal[colour].red;
+ green=pal[colour].green;
+ blue=pal[colour].blue;
+ break;
+ case 15:
+ case 16:
+ red = (uInt8)(colour >> RFP) << RShift;
+ green = (uInt8)(colour >> GFP) << GShift;
+ blue = (uInt8)(colour >> BFP) << BShift;
+ if ((red!=0) && (RShift!=0)) red+=(1 << RShift)-1;
+ if ((green!=0) && (GShift!=0)) green+=(1 << GShift)-1;
+ if ((blue!=0) && (BShift!=0)) blue+=(1 << BShift)-1;
+ break;
+ case 24:
+ case 32:
+ red = (uInt8)(colour >> RFP);
+ green = (uInt8)(colour >> GFP);
+ blue = (uInt8)(colour >> BFP);
+ break;
+ default:
+ red = 0;
+ green = 0;
+ blue = 0;
+ break;
+ } // switch
+ return;
+} // ogSprite::unpackRGB
+
+ogSprite::~ogSprite(void) {
+ free(image);
+ delete [] pal;
+ image = NULL;
+ pal = NULL;
+ imageSize = 0;
+ width = 0;
+ height = 0;
+ bitDepth = 0;
+ RFP = 0;
+ GFP = 0;
+ BFP = 0;
+ AFP = 0;
+ RShift = 0;
+ GShift = 0;
+ BShift = 0;
+ AShift = 0;
+ tColour = 0;
+ return;
+} // ogSprite::~ogSprite
+
+
diff --git a/lockwasher/src/lib/views/rh_opt.gdt b/lockwasher/src/lib/views/rh_opt.gdt
new file mode 100644
index 0000000..84e5d6a
--- /dev/null
+++ b/lockwasher/src/lib/views/rh_opt.gdt
Binary files differ
diff --git a/lockwasher/src/lib/views/rh_opt.gpr b/lockwasher/src/lib/views/rh_opt.gpr
new file mode 100644
index 0000000..5353ab1
--- /dev/null
+++ b/lockwasher/src/lib/views/rh_opt.gpr
Binary files differ
diff --git a/lockwasher/src/lib/views/rh_opt.mak b/lockwasher/src/lib/views/rh_opt.mak
new file mode 100644
index 0000000..1d41e21
--- /dev/null
+++ b/lockwasher/src/lib/views/rh_opt.mak
@@ -0,0 +1,356 @@
+# This file is automatically generated by RHIDE 1.4.9
+# created from within RHIDE
+FLAGS_FOR_SUBPROJECTS=RHIDE_OS_="$(RHIDE_OS_)" CFLAGS="$(CFLAGS)"\
+ CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)"
+RHIDE_OS=$(RHIDE_OS_)
+ifeq ($(strip $(RHIDE_OS)),)
+ifneq ($(strip $(DJDIR)),)
+RHIDE_OS_:=DJGPP
+else
+RHIDE_OS_:=$(patsubst CYGWIN%,CYGWIN,$(shell uname))
+endif
+endif
+
+INCLUDE_DIRS=
+LIB_DIRS=
+C_DEBUG_FLAGS=
+C_OPT_FLAGS=-O4
+C_WARN_FLAGS=-pedantic -Wmain -Wparentheses -Wreturn-type -Wuninitialized\
+ -Wall -W -Wpointer-arith -Wmissing-prototypes -Wredundant-decls
+C_C_LANG_FLAGS=
+C_CXX_LANG_FLAGS=
+C_P_LANG_FLAGS=
+C_FPC_LANG_FLAGS=
+C_F_LANG_FLAGS=
+C_ADA_LANG_FLAGS=
+LIBS=
+LD_EXTRA_FLAGS=-g
+C_EXTRA_FLAGS=-Wno-long-long
+LOCAL_OPT=$(subst ___~~~___, ,$(subst $(notdir $<)___,,$(filter $(notdir\
+ $<)___%,$(LOCAL_OPTIONS))))
+
+OBJFILES=main.o objgfx30.o ogBlit.o ogDisplay_VESA.o ogFont.o ogSprite.o
+ALL_OBJFILES=main.o objgfx30.o ogBlit.o ogDisplay_VESA.o ogFont.o\
+ ogSprite.o
+LIBRARIES=
+SOURCE_NAME=$<
+OUTFILE=$@
+SPECIAL_CFLAGS=
+SPECIAL_LDFLAGS=
+PROG_ARGS=
+SRC_DIRS=
+WUC=
+EDITORS=
+MAIN_TARGET=objgfx.exe
+PROJECT_ITEMS=main.cpp objgfx30.cpp ogBlit.cpp ogDisplay_VESA.cpp\
+ ogFont.cpp ogSprite.cpp
+DEFAULT_MASK=*.cpp
+RHIDE_BIN_DIR=c:/djgpp/bin
+PASCAL_TYPE=GPC
+GET_HOME=$(HOME)
+CLEAN_FILES=$(MAIN_TARGET) $(OBJFILES)
+RHIDE_GCC=gcc
+RHIDE_AS=gcc
+RHIDE_GXX=gcc
+RHIDE_GPC=gpc
+RHIDE_FPC=ppc386
+RHIDE_AR=ar
+RHIDE_LD=gcc
+RHIDE_G77=g77
+RHIDE_NASM=nasm
+RHIDE_LD_PASCAL=gpc
+RHIDE_LD_FPC=$(RHIDE_FPC) -E+
+RHIDE_GNATBIND=gnatbind
+RHIDE_RM=rm
+RHIDE_ARFLAGS=rcs
+RHIDE_TYPED_LIBS.f=g2c m
+RHIDE_TYPED_LIBS.for=$(RHIDE_TYPED_LIBS.f)
+RHIDE_TYPED_LIBS.F=$(RHIDE_TYPED_LIBS.f)
+RHIDE_TYPED_LIBS.fpp=$(RHIDE_TYPED_LIBS.f)
+RHIDE_TYPED_LIBS_GPC=gpc m
+RHIDE_TYPED_LIBS_FPC=fpc
+RHIDE_TYPED_LIBS.p=$(RHIDE_TYPED_LIBS_$(PASCAL_TYPE))
+RHIDE_TYPED_LIBS.pas=$(RHIDE_TYPED_LIBS.p)
+RHIDE_TYPED_LIBS.pp=$(RHIDE_TYPED_LIBS_FPC)
+RHIDE_TYPED_LIBS_$(RHIDE_OS).cc=stdc++
+RHIDE_TYPED_LIBS_DJGPP.cc=stdcxx m
+RHIDE_TYPED_LIBS_DJGPP.cc=stdcxx m
+RHIDE_TYPED_LIBS.cc=$(RHIDE_TYPED_LIBS_$(RHIDE_OS).cc)
+RHIDE_TYPED_LIBS.cpp=$(RHIDE_TYPED_LIBS.cc)
+RHIDE_TYPED_LIBS.cxx=$(RHIDE_TYPED_LIBS.cc)
+RHIDE_TYPED_LIBS.C=$(RHIDE_TYPED_LIBS.cc)
+RHIDE_TYPED_LIBS.ii=$(RHIDE_TYPED_LIBS.cc)
+RHIDE_TYPED_LIBS.l=fl
+RHIDE_TYPED_LIBS.m=objc
+RHIDE_TYPED_LIBS.adb=gnat
+RHIDE_TYPED_LIBS_SUFFIXES=$(sort $(foreach item,$(PROJECT_ITEMS),$(suffix\
+ $(item))))
+RHIDE_TYPED_LIBS=$(foreach\
+ suff,$(RHIDE_TYPED_LIBS_SUFFIXES),$(RHIDE_TYPED_LIBS$(suff)))
+RHIDE_INCLUDES=$(SPECIAL_CFLAGS) $(addprefix -I,$(INCLUDE_DIRS))
+RHIDE_LIBDIRS=$(addprefix -L,$(LIB_DIRS))
+RHIDE_LIBS=$(addprefix -l,$(LIBS) $(RHIDE_TYPED_LIBS) $(RHIDE_OS_LIBS))
+RHIDE_LDFLAGS=$(SPECIAL_LDFLAGS) $(addprefix -Xlinker ,$(LD_EXTRA_FLAGS))
+RHIDE_NASM_TARGET_DJGPP=coff
+RHIDE_NASM_TARGET_Linux=elf
+RHIDE_NASM_TARGET=$(RHIDE_NASM_TARGET_$(RHIDE_OS))
+RHIDE_COMPILE_NASM=$(RHIDE_NASM) -f $(RHIDE_NASM_TARGET) $(LOCAL_OPT) -o\
+ $(OUTFILE) $(SOURCE_NAME)
+RHIDE_COMPILE_FORTRAN=$(RHIDE_G77) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_F_LANG_FLAGS) $(C_EXTRA_FLAGS)\
+ $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_COMPILE_FORTRAN_FORCE=$(RHIDE_G77) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_F_LANG_FLAGS) $(C_EXTRA_FLAGS)\
+ -x f77 $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_COMPILE_C=$(RHIDE_GCC) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS) $(C_EXTRA_FLAGS)\
+ $(RHIDE_OS_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(LOCAL_OPT) -c\
+ $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_COMPILE_C_FORCE=$(RHIDE_GCC) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS) $(C_EXTRA_FLAGS)\
+ -x c $(RHIDE_OS_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(LOCAL_OPT) -c\
+ $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_COMPILE_CC=$(RHIDE_GXX) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS)\
+ $(C_CXX_LANG_FLAGS) $(C_EXTRA_FLAGS) $(RHIDE_OS_CXXFLAGS)\
+ $(CPPFLAGS) $(CXXFLAGS) $(LOCAL_OPT) -c $(SOURCE_NAME) -o\
+ $(OUTFILE)
+RHIDE_COMPILE_CC_FORCE=$(RHIDE_GXX) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS)\
+ $(C_CXX_LANG_FLAGS) $(C_EXTRA_FLAGS) $(RHIDE_OS_CXXFLAGS)\
+ $(CPPFLAGS) $(CXXFLAGS) -x c++ $(LOCAL_OPT) -c $(SOURCE_NAME) -o\
+ $(OUTFILE)
+RHIDE_COMPILE_ASM=$(RHIDE_AS) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_EXTRA_FLAGS) $(LOCAL_OPT) -c\
+ $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_COMPILE_ASM_FORCE=$(RHIDE_AS) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_EXTRA_FLAGS) -x assembler\
+ $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_GPC_FLAGS=$(RHIDE_INCLUDES) $(C_DEBUG_FLAGS) $(C_OPT_FLAGS)\
+ $(C_WARN_FLAGS) $(C_P_LANG_FLAGS) $(C_EXTRA_FLAGS)
+RHIDE_COMPILE_GPC=$(RHIDE_GPC) $(RHIDE_GPC_FLAGS) $(LOCAL_OPT) -c\
+ $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_COMPILE_GPC_FORCE=$(RHIDE_GPC) $(RHIDE_GPC_FLAGS) -x pascal\
+ $(LOCAL_OPT) -c $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_FPC_FLAGS=$(C_FPC_LANG_FLAGS) $(LOCAL_OPT) $(addprefix\
+ -Up,$(INCLUDE_DIRS)) $(C_EXTRA_FLAGS)
+RHIDE_COMPILE_FPC=$(RHIDE_FPC) $(RHIDE_FPC_FLAGS) -E- $(SOURCE_NAME)
+RHIDE_COMPILE_FPC_FORCE=$(RHIDE_FPC) $(RHIDE_FPC_FLAGS) -B -E-\
+ $(SOURCE_NAME)
+RHIDE_COMPILE_LINK=$(RHIDE_LD) $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS) -o\
+ $(OUTFILE) $(OBJFILES) $(LIBRARIES) $(LDFLAGS) $(RHIDE_LDFLAGS)\
+ $(RHIDE_LIBS)
+RHIDE_COMPILE_LINK_GPC=$(RHIDE_LD_PASCAL) $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS)\
+ -o $(OUTFILE) $(OBJFILES) $(LIBRARIES) $(RHIDE_LDFLAGS) $(LDFLAGS)\
+ $(RHIDE_LIBS)
+RHIDE_COMPILE_LINK_GPC_AUTOMAKE=$(RHIDE_LD_PASCAL) $(RHIDE_LIBDIRS) -o\
+ $(OUTFILE) --automake $(RHIDE_GPC_FLAGS) $(SOURCE_NAME)\
+ $(LIBRARIES) $(LDFLAGS) $(RHIDE_LDFLAGS) $(RHIDE_LIBS)
+RHIDE_COMPILE_PASCAL=$(RHIDE_COMPILE_$(PASCAL_TYPE))
+RHIDE_COMPILE_PASCAL_FORCE=$(RHIDE_COMPILE_$(PASCAL_TYPE)_FORCE)
+RHIDE_COMPILE_LINK_PASCAL_AUTOMAKE=$(RHIDE_COMPILE_LINK_$(PASCAL_TYPE)_AUTOMAKE)
+RHIDE_COMPILE_LINK_PASCAL=$(RHIDE_COMPILE_LINK_$(PASCAL_TYPE))
+RHIDE_FPC_LIBDIRS_$(RHIDE_OS)=/usr/local/lib /usr/lib /lib
+RHIDE_FPC_LIBDIRS_DJGPP=/usr/local/lib /usr/lib /lib
+RHIDE_FPC_LIBDIRS_DJGPP=$(DJDIR)/lib
+RHIDE_FPC_LIBDIRS=$(RHIDE_FPC_LIBDIRS_$(RHIDE_OS))
+RHIDE_FPC_LINK_FLAGS_$(RHIDE_OS)=$(RHIDE_LIBDIRS) $(addprefix\
+ -L,$(RHIDE_FPC_LIBDIRS))
+RHIDE_FPC_LINK_FLAGS_DJGPP=$(RHIDE_LIBDIRS) $(addprefix\
+ -L,$(RHIDE_FPC_LIBDIRS))
+RHIDE_FPC_LINK_FLAGS_DJGPP=-O coff-go32-exe $(RHIDE_LIBDIRS) $(addprefix\
+ -L,$(RHIDE_FPC_LIBDIRS))
+RHIDE_FPC_LINK_FLAGS=$(RHIDE_FPC_LINK_FLAGS_$(RHIDE_OS))
+RHIDE_COMPILE_LINK_FPC=echo 'separate linking for FPK is not supported.\
+ Please define a main source file in Project/Primary file.' 1>&2
+RHIDE_COMPILE_LINK_FPC_AUTOMAKE=$(RHIDE_FPC) -o$(OUTFILE) $(SOURCE_NAME)\
+ $(RHIDE_FPC_FLAGS) -E+
+RHIDE_COMPILE_ARCHIVE=$(RHIDE_AR) $(RHIDE_ARFLAGS) $(OUTFILE)\
+ $(ALL_OBJFILES)
+RHIDE_COMPILE_ADA=$(RHIDE_GCC) $(RHIDE_INCLUDES) $(C_DEBUG_FLAGS)\
+ $(C_OPT_FLAGS) $(C_WARN_FLAGS) $(C_C_LANG_FLAGS) $(C_EXTRA_FLAGS)\
+ $(LOCAL_OPT) $(C_ADA_LANG_FLAGS) $(RHIDE_OS_CFLAGS) $(CPPFLAGS)\
+ $(CFLAGS) -c $(SOURCE_NAME) -o $(OUTFILE)
+RHIDE_ADA_BIND_FILE=$(addprefix _,$(setsuffix .c,$(OUTFILE)))
+RHIDE_COMPILE_LINK_ADA_BIND=$(RHIDE_GNATBIND) -o $(RHIDE_ADA_BIND_FILE)\
+ $(setsuffix .ali,$(OUTFILE))
+RHIDE_COMPILE_LINK_ADA_LINK=$(RHIDE_LD) $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS) -o\
+ $(OUTFILE) $(RHIDE_ADA_BIND_FILE) $(OBJFILES) $(LIBRARIES)\
+ $(LDFLAGS) $(RHIDE_LDFLAGS) $(RHIDE_LIBS)
+_RHIDE_COMPILE_LINK_ADA=$(RHIDE_COMPILE_LINK_ADA_BIND);\
+ $(RHIDE_COMPILE_LINK_ADA_LINK); $(RHIDE_RM)\
+ $(RHIDE_ADA_BIND_FILE)
+RHIDE_COMPILE_LINK_ADA=gnatbl $(RHIDE_LIBDIRS) $(C_EXTRA_FLAGS) -o\
+ $(OUTFILE) $(setsuffix .ali,$(OUTFILE)) $(LIBRARIES) $(LDFLAGS) \
+ $(RHIDE_LDFLAGS) $(RHIDE_LIBS)
+RHIDE_COMPILE.c.o=$(RHIDE_COMPILE_C)
+RHIDE_COMPILE.cc.o=$(RHIDE_COMPILE_CC)
+RHIDE_COMPILE.p.o=$(RHIDE_COMPILE_PASCAL)
+RHIDE_COMPILE.pas.o=$(RHIDE_COMPILE.p.o)
+RHIDE_COMPILE.pp.o=$(RHIDE_COMPILE_FPC)
+RHIDE_COMPILE.pas.s.GPC=$(subst -c $(SOURCE_NAME),-S\
+ $(SOURCE_NAME),$(RHIDE_COMPILE_GPC))
+RHIDE_COMPILE.pas.s.FPC=$(RHIDE_COMPILE_FPC) -a -s
+RHIDE_COMPILE.pas.s=$(RHIDE_COMPILE.pas.s.$(PASCAL_TYPE))
+RHIDE_COMPILE.f.o=$(RHIDE_COMPILE_FORTRAN)
+RHIDE_COMPILE.nsm.o=$(RHIDE_COMPILE_NASM)
+RHIDE_COMPILE.s.o=$(RHIDE_COMPILE_ASM)
+RHIDE_COMPILE.c.s=$(subst -c $(SOURCE_NAME),-S\
+ $(SOURCE_NAME),$(RHIDE_COMPILE_C))
+RHIDE_COMPILE.c.i=$(subst -c $(SOURCE_NAME),-E\
+ $(SOURCE_NAME),$(RHIDE_COMPILE_C))
+RHIDE_COMPILE.i.s=$(RHIDE_COMPILE.c.s)
+RHIDE_COMPILE.cc.s=$(subst -c $(SOURCE_NAME),-S\
+ $(SOURCE_NAME),$(RHIDE_COMPILE_CC))
+RHIDE_COMPILE.cc.ii=$(subst -c $(SOURCE_NAME),-E\
+ $(SOURCE_NAME),$(RHIDE_COMPILE_CC))
+RHIDE_COMPILE.ii.s=$(RHIDE_COMPILE.cc.s)
+RHIDE_COMPILE.cpp.o=$(RHIDE_COMPILE.cc.o)
+RHIDE_COMPILE.cxx.o=$(RHIDE_COMPILE.cc.o)
+RHIDE_COMPILE.C.o=$(RHIDE_COMPILE.cc.o)
+RHIDE_COMPILE.pas.o=$(RHIDE_COMPILE.p.o)
+RHIDE_COMPILE.for.o=$(RHIDE_COMPILE.f.o)
+RHIDE_COMPILE.F.o=$(RHIDE_COMPILE.f.o)
+RHIDE_COMPILE.fpp.o=$(RHIDE_COMPILE.f.o)
+RHIDE_COMPILE.asm.o=$(RHIDE_COMPILE.nsm.o)
+RHIDE_COMPILE.cpp.s=$(RHIDE_COMPILE.cc.s)
+RHIDE_COMPILE.cxx.s=$(RHIDE_COMPILE.cc.s)
+RHIDE_COMPILE.C.s=$(RHIDE_COMPILE.cc.s)
+RHIDE_COMPILE.cpp.ii=$(RHIDE_COMPILE.cc.ii)
+RHIDE_COMPILE.cxx.ii=$(RHIDE_COMPILE.cc.ii)
+RHIDE_COMPILE.C.ii=$(RHIDE_COMPILE.cc.ii)
+RHIDE_COMPILE.adb.o=$(RHIDE_COMPILE_ADA)
+RHIDE_FSDB=fsdb $(OUTFILE) $(addprefix -p ,$(SRC_DIRS)) $(PROG_ARGS)
+RHIDE_GDB=gdb $(OUTFILE) $(addprefix -d ,$(SRC_DIRS))
+DEFAULT_GREP_MASK=*.[cfhmnps]*
+RHIDE_GREP=grep -n $(prompt arguments for GREP,$(WUC) $(DEFAULT_GREP_MASK))
+RHIDE_GPROF=gprof $(OUTFILE)
+RHIDE_RLOG=$(shell rlog -R $(rlog_arg))
+RHIDE_CO=$(shell co -q $(co_arg))
+RHIDE_STANDARD_INCLUDES_$(RHIDE_OS)=$(addprefix /usr/,include include/sys\
+ include/g++ include/g++/std)
+RHIDE_STANDARD_INCLUDES_DJGPP=$(addprefix /usr/,include include/sys\
+ include/g++ include/g++/std)
+RHIDE_STANDARD_INCLUDES_DJGPP=$(addprefix $(DJDIR)/,include include/sys\
+ lang/cxx lang/cxx/std)
+RHIDE_STANDARD_INCLUDES=$(RHIDE_STANDARD_INCLUDES_$(RHIDE_OS))
+RHIDE_CONFIG_DIRS_$(RHIDE_OS)=/usr/local/share/rhide /usr/share/rhide \
+ /local/share/rhide /share/rhide
+RHIDE_CONFIG_DIRS_DJGPP=/usr/local/share/rhide /usr/share/rhide \
+ /local/share/rhide /share/rhide
+RHIDE_CONFIG_DIRS_DJGPP=$(DJDIR)/share/rhide
+RHIDE_CONFIG_DIRS_COMMON=$(RHIDE_CONFIG_DIRS_$(RHIDE_OS))\
+ $(RHIDE_BIN_DIR)/../share/rhide
+RHIDE_CONFIG_DIRS=. $(RHIDE_SHARE) $(GET_HOME) $(RHIDE_CONFIG_DIRS_COMMON)\
+ $(addsuffix /SET,$(RHIDE_CONFIG_DIRS_COMMON)) $(SET_FILES)
+RHIDE_PATH_SEPARATOR_$(RHIDE_OS)=:
+RHIDE_PATH_SEPARATOR_DJGPP=:
+RHIDE_PATH_SEPARATOR_DJGPP=;
+RHIDE_PATH_SEPARATOR=$(RHIDE_PATH_SEPARATOR_$(RHIDE_OS))
+RHIDE_EMPTY=
+RHIDE_SPACE=$(RHIDE_EMPTY) $(RHIDE_EMPTY)
+RHIDE_TYPED_LIBS_DJGPP.cc=stdcxx m
+RHIDE_TYPED_LIBS_DJGPP.cxx=stdcxx m
+RHIDE_TYPED_LIBS_DJGPP.cpp=stdcxx m
+RHIDE_TYPED_LIBS.f=g2c m
+%.o: %.c
+ $(RHIDE_COMPILE.c.o)
+%.o: %.i
+ $(RHIDE_COMPILE_C)
+%.o: %.cc
+ $(RHIDE_COMPILE.cc.o)
+%.o: %.cpp
+ $(RHIDE_COMPILE.cpp.o)
+%.o: %.cxx
+ $(RHIDE_COMPILE.cxx.o)
+%.o: %.C
+ $(RHIDE_COMPILE.C.o)
+%.o: %.ii
+ $(RHIDE_COMPILE_CC)
+%.o: %.s
+ $(RHIDE_COMPILE.s.o)
+%.o: %.S
+ $(RHIDE_COMPILE_ASM)
+%.s: %.c
+ $(RHIDE_COMPILE.c.s)
+%.s: %.i
+ $(RHIDE_COMPILE.i.s)
+%.s: %.cc
+ $(RHIDE_COMPILE.cc.s)
+%.s: %.cpp
+ $(RHIDE_COMPILE.cpp.s)
+%.s: %.cxx
+ $(RHIDE_COMPILE.cxx.s)
+%.s: %.C
+ $(RHIDE_COMPILE.C.s)
+%.o: %.pas
+ $(RHIDE_COMPILE.pas.o)
+%.o: %.p
+ $(RHIDE_COMPILE.p.o)
+%.o: %.pp
+ $(RHIDE_COMPILE.pp.o)
+%.s: %.pas
+ $(RHIDE_COMPILE.pas.s)
+%.o: %.m
+ $(RHIDE_COMPILE_OBJC)
+%.o: %.f
+ $(RHIDE_COMPILE.f.o)
+%.o: %.for
+ $(RHIDE_COMPILE.for.o)
+%.o: %.F
+ $(RHIDE_COMPILE.F.o)
+%.o: %.fpp
+ $(RHIDE_COMPILE.fpp.o)
+%.o: %.asm
+ $(RHIDE_COMPILE.asm.o)
+%.o: %.nsm
+ $(RHIDE_COMPILE.nsm.o)
+%.o: %.adb
+ $(RHIDE_COMPILE.adb.o)
+%.i: %.c
+ $(RHIDE_COMPILE.c.i)
+%.s: %.c
+ $(RHIDE_COMPILE.c.s)
+%.ii: %.cc
+ $(RHIDE_COMPILE.cc.ii)
+%.s: %.cc
+ $(RHIDE_COMPILE.cc.s)
+%.ii: %.cpp
+ $(RHIDE_COMPILE.cpp.ii)
+%.s: %.cpp
+ $(RHIDE_COMPILE.cpp.s)
+%.ii: %.cxx
+ $(RHIDE_COMPILE.cxx.ii)
+%.s: %.cxx
+ $(RHIDE_COMPILE.cxx.s)
+%.ii: %.C
+ $(RHIDE_COMPILE.C.ii)
+%.s: %.C
+ $(RHIDE_COMPILE.C.s)
+clean::
+ rm -f $(CLEAN_FILES)
+DEPS_0= main.o objgfx30.o ogBlit.o ogDisplay_VESA.o ogFont.o ogSprite.o
+NO_LINK=
+LINK_FILES=$(filter-out $(NO_LINK),$(DEPS_0))
+objgfx.exe:: $(DEPS_0)
+ $(RHIDE_COMPILE_LINK)
+DEPS_1=main.cpp
+main.o:: $(DEPS_1)
+ $(RHIDE_COMPILE.cpp.o)
+DEPS_2=objgfx30.cpp
+objgfx30.o:: $(DEPS_2)
+ $(RHIDE_COMPILE.cpp.o)
+DEPS_3=ogBlit.cpp
+ogBlit.o:: $(DEPS_3)
+ $(RHIDE_COMPILE.cpp.o)
+DEPS_4=ogDisplay_VESA.cpp
+ogDisplay_VESA.o:: $(DEPS_4)
+ $(RHIDE_COMPILE.cpp.o)
+DEPS_5=ogFont.cpp
+ogFont.o:: $(DEPS_5)
+ $(RHIDE_COMPILE.cpp.o)
+DEPS_6=ogSprite.cpp
+ogSprite.o:: $(DEPS_6)
+ $(RHIDE_COMPILE.cpp.o)
+all:: objgfx.exe
+
\ No newline at end of file
diff --git a/lockwasher/src/lib/views/vWidget.cpp b/lockwasher/src/lib/views/vWidget.cpp
new file mode 100644
index 0000000..e285642
--- /dev/null
+++ b/lockwasher/src/lib/views/vWidget.cpp
@@ -0,0 +1,9 @@
+#include
+
+bool
+vWidget::vSetActive(bool _active) {
+ bool result = active;
+ active = _active;
+ return result;
+} // vWidget::vSetActive
+
diff --git a/lockwasher/src/lib/views/vWindow.cpp b/lockwasher/src/lib/views/vWindow.cpp
new file mode 100644
index 0000000..894bb57
--- /dev/null
+++ b/lockwasher/src/lib/views/vWindow.cpp
@@ -0,0 +1,42 @@
+#include "objgfx30.h"
+#include "vWindow.h"
+
+vWindow::vWindow(void) {
+ realWindow = new ogSurface();
+ titleFont = new ogBitFont();
+ return;
+} // vWindow::vWindow
+
+bool
+vWindow::vCreate(void) {
+ if (realWindow->ogCreate(400,400,OG_PIXFMT_32BPP) == false) return false;
+ if (ogAlias(*realWindow, // window
+ 0, 0, // [x1, y1]
+ realWindow->ogGetMaxX(), realWindow->ogGetMaxY()) // [x2, y2]
+ == false) return false;
+ return true;
+} // vWindow::vCreate
+
+void
+vWindow::vSDECommand(uInt32 command) {
+ asm(
+ "int %0"
+ :
+ : "i" (0x80),"a" (40),"b" (command),"c" (realWindow)
+ );
+ return;
+} // vWindow::vSDECommand
+
+vWindow::~vWindow() {
+ delete realWindow;
+ delete titleFont;
+ return;
+} // vWindow::~vWindow
+
+/*
+ogSurface -> vWidget -> vWindow
+ | \------> vButton
+ |
+ |
+ -- ogDisplay_UbixOS -> SDE
+*/
diff --git a/lockwasher/src/sys/Makefile b/lockwasher/src/sys/Makefile
new file mode 100644
index 0000000..a0181ad
--- /dev/null
+++ b/lockwasher/src/sys/Makefile
@@ -0,0 +1,71 @@
+# $Id: Makefile,v 1.11 2003/05/04 13:20:15 reddawg Exp $
+# Kernel Makefile (C) 2002 The UbixOS Project
+
+all: boot-code init-code kernel-code isa-code pci-code sys-code vmm-code devfs-code ubixfs-code lib-code sde-code graphics-code ld-code kernel-img
+
+boot-code: boot
+ (cd boot;make)
+
+init-code: init
+ (cd init;make)
+
+kernel-code: kernel
+ (cd kernel;make)
+
+isa-code: isa
+ (cd isa;make)
+
+pci-code: pci
+ (cd pci;make)
+
+sys-code: sys
+ (cd sys;make)
+
+vmm-code: vmm
+ (cd vmm;make)
+
+ubixfs-code: ubixfs
+ (cd ubixfs;make)
+
+devfs-code: devfs
+ (cd devfs;make)
+
+graphics-code: graphics
+ (cd graphics;make)
+
+ld-code: ld
+ (cd ld;make)
+
+lib-code: lib
+ (cd lib;make)
+
+sde-code: sde
+ (cd sde;make)
+
+kernel-img: compile
+ (/bin/echo "/* " > ./compile/null.c)
+ (date >> ./compile/null.c)
+ (echo $user >> ./compile/null.c)
+ (/bin/echo " */" >> ./compile/null.c)
+ (cd compile;make)
+
+install:
+ (cd boot;make install)
+ (cd ../tools/;make format-dsk)
+
+clean:
+ (cd boot;make clean)
+ (cd init;make clean)
+ (cd isa;make clean)
+ (cd pci;make clean)
+ (cd sys;make clean)
+ (cd kernel;make clean)
+ (cd compile;make clean)
+ (cd vmm;make clean)
+ (cd devfs;make clean)
+ (cd ubixfs;make clean)
+ (cd graphics;make clean)
+ (cd lib;make clean)
+ (cd sde;make clean)
+ (cd ld;make clean)
+ (cd ../tools/;make clean)
diff --git a/lockwasher/src/sys/boot/Makefile b/lockwasher/src/sys/boot/Makefile
new file mode 100644
index 0000000..4252c13
--- /dev/null
+++ b/lockwasher/src/sys/boot/Makefile
@@ -0,0 +1,10 @@
+# $Id: Makefile,v 1.1.1.1 2003/01/12 00:20:07 reddawg Exp $
+
+FDDEVICE = "/dev/fd0"
+#FDDEVICE = /dev/fd1
+all:
+
+install:
+
+clean:
+ (rm -f writeimg format bootsec *.core boot2/test)
diff --git a/lockwasher/src/sys/boot/Makefile.inc b/lockwasher/src/sys/boot/Makefile.inc
new file mode 100644
index 0000000..e3011be
--- /dev/null
+++ b/lockwasher/src/sys/boot/Makefile.inc
@@ -0,0 +1,6 @@
+# Common defines for all of /sys/boot/i386/
+#
+# $FreeBSD: src/sys/boot/i386/Makefile.inc,v 1.1.2.2 2000/12/28 12:04:04 ps Exp $
+
+LOADER_ADDRESS?= 0x200000
+CFLAGS+= -mpreferred-stack-boundary=2
diff --git a/lockwasher/src/sys/boot/boot2/Makefile b/lockwasher/src/sys/boot/boot2/Makefile
new file mode 100644
index 0000000..cd404d1
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/Makefile
@@ -0,0 +1,87 @@
+# $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.16.2.5 2002/08/07 16:31:53 ru Exp $
+
+PROG= boot2
+NOMAN=
+STRIP=
+BINDIR?= /boot
+BINMODE= 444
+CLEANFILES+= boot1 boot1.out boot1.o \
+ boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
+ sio.o
+
+NM?= nm
+
+# A value of 0x80 enables LBA support.
+B1FLAGS= 0x80
+
+BOOT_COMCONSOLE_PORT?= 0x3f8
+BOOT_COMCONSOLE_SPEED?= 9600
+B2SIOFMT?= 0x3
+
+.if exists(${.OBJDIR}/../btx)
+BTX= ${.OBJDIR}/../btx
+.else
+BTX= ${.CURDIR}/../btx
+.endif
+
+ORG1= 0x7c00
+ORG2= 0x1000
+
+CFLAGS= -elf -I${.CURDIR}/../btx/lib -I. \
+ -Os -fno-builtin -fforce-addr -fdata-sections \
+ -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
+ -mpreferred-stack-boundary=2 \
+ -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
+ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
+ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
+
+LDFLAGS=-nostdlib -static -N
+
+all: boot1 boot2
+
+boot1: boot1.out
+ objcopy -S -O binary boot1.out ${.TARGET}
+
+boot1.out: boot1.o
+ ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
+
+boot1.o: boot1.s
+ ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET}
+
+boot2.h: boot1.out
+ ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
+ { x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \
+ ORG1=`printf "%d" ${ORG1}` > boot2.h
+
+boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
+ btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
+ -o boot2.ld -P 1 boot2.bin
+ @ls -l boot2.ld | awk '{ x = 7680 - $$5; \
+ print x " bytes available"; if (x < 0) exit 1 }'
+ dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
+
+boot2.ldr:
+ dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
+
+boot2.bin: boot2.out
+ objcopy -S -O binary boot2.out ${.TARGET}
+
+boot2.out: boot2.o sio.o
+ ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
+ ${BTX}/lib/crt0.o boot2.o sio.o
+
+boot2.o: boot2.h
+
+sio.o: sio.s
+ ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
+ --defsym SIOFMT=${B2SIOFMT} \
+ --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
+ ${.IMPSRC} -o ${.TARGET}
+
+install:
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ boot1 ${DESTDIR}${BINDIR}/boot1
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ boot2 ${DESTDIR}${BINDIR}/boot2
+
+.include
diff --git a/lockwasher/src/sys/boot/boot2/boot1.s b/lockwasher/src/sys/boot/boot2/boot1.s
new file mode 100644
index 0000000..20d6fb0
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/boot1.s
@@ -0,0 +1,364 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $Id: boot1.s,v 1.3 2003/03/05 02:55:45 reddawg Exp $
+
+# Memory Locations
+ .set MEM_REL,0x700 # Relocation address
+ .set MEM_ARG,0x900 # Arguments
+ .set MEM_ORG,0x7c00 # Origin
+ .set MEM_BUF,0x8c00 # Load area
+ .set MEM_BTX,0x9000 # BTX start
+ .set MEM_JMP,0x9010 # BTX entry point
+ .set MEM_USR,0xa000 # Client start
+ .set BDA_BOOT,0x472 # Boot howto flag
+
+# Partition Constants
+ .set PRT_OFF,0x1be # Partition offset
+ .set PRT_NUM,0x4 # Partitions
+ .set PRT_UBX,0x2A # Partition type
+
+# Flag Bits
+ .set FL_PACKET,0x80 # Packet mode
+
+# Misc. Constants
+ .set SIZ_PAG,0x1000 # Page size
+ .set SIZ_SEC,0x200 # Sector size
+
+ .globl start
+ .globl xread
+ .code16
+
+start: jmp main # Start recognizably
+
+# This is the start of a standard BIOS Parameter Block (BPB). Most bootable
+# FAT disks have this at the start of their MBR. While normal BIOS's will
+# work fine without this section, IBM's El Torito emulation "fixes" up the
+# BPB by writing into the memory copy of the MBR. Rather than have data
+# written into our xread routine, we'll define a BPB to work around it.
+# The data marked with (T) indicates a field required for a ThinkPad to
+# recognize the disk and (W) indicates fields written from IBM BIOS code.
+# The use of the BPB is based on what OpenBSD and NetBSD implemented in
+# their boot code but the required fields were determined by trial and error.
+#
+# Note: If additional space is needed in boot1, one solution would be to
+# move the "prompt" message data (below) to replace the OEM ID.
+
+ .org 0x03, 0x00
+oemid: .space 0x08, 0x00 # OEM ID
+
+ .org 0x0b, 0x00
+bpb: .word 512 # sector size (T)
+ .byte 0 # sectors/clustor
+ .word 0 # reserved sectors
+ .byte 0 # number of FATs
+ .word 0 # root entries
+ .word 0 # small sectors
+ .byte 0 # media type (W)
+ .word 0 # sectors/fat
+ .word 18 # sectors per track (T)
+ .word 2 # number of heads (T)
+ .long 0 # hidden sectors (W)
+ .long 0 # large sectors
+
+ .org 0x24, 0x00
+ebpb: .byte 0 # BIOS physical drive number (W)
+
+ .org 0x25,0x90
+#
+# Trampoline used by boot2 to call read to read data from the disk via
+# the BIOS. Call with:
+#
+# %cx:%ax - long - LBA to read in
+# %es:(%bx) - caddr_t - buffer to read data into
+# %dl - byte - drive to read from
+# %dh - byte - num sectors to read
+#
+
+xread: push %ss # Address
+ pop %ds # data
+#
+# Setup an EDD disk packet and pass it to read
+#
+xread.1: # Starting
+ pushl $0x0 # absolute
+ push %cx # block
+ push %ax # number
+ push %es # Address of
+ push %bx # transfer buffer
+ xor %ax,%ax # Number of
+ movb %dh,%al # blocks to
+ push %ax # transfer
+ push $0x10 # Size of packet
+ mov %sp,%bp # Packet pointer
+ callw read # Read from disk
+ lea 0x10(%bp),%sp # Clear stack
+ lret # To far caller
+#
+# Load the rest of boot2 and BTX up, copy the parts to the right locations,
+# and start it all up.
+#
+
+#
+# Setup the segment registers to flat addressing (segment 0) and setup the
+# stack to end just below the start of our code.
+#
+main:
+#mov $0x4f02,%ax
+#mov $0x4103,%bx
+#int $0x10
+ cld # String ops inc
+ xor %cx,%cx # Zero
+ mov %cx,%es # Address
+ mov %cx,%ds # data
+ mov %cx,%ss # Set up
+ mov $start,%sp # stack
+#
+# Relocate ourself to MEM_REL. Since %cx == 0, the inc %ch sets
+# %cx == 0x100.
+#
+ mov %sp,%si # Source
+ mov $MEM_REL,%di # Destination
+ incb %ch # Word count
+ rep # Copy
+ movsw # code
+#
+# If we are on a hard drive, then load the MBR and look for the first
+# UbixOS slice. We use the fake partition entry below that points to
+# the MBR when we call nread. The first pass looks for the first active
+# UbixOS slice. The second pass looks for the first non-active UbixOS
+# slice if the first one fails.
+#
+ mov $part4,%si # Partition
+ cmpb $0x80,%dl # Hard drive?
+ jb main.4 # No
+ movb $0x1,%dh # Block count
+ callw nread # Read MBR
+ mov $0x1,%cx # Two passes
+main.1: mov $MEM_BUF+PRT_OFF,%si # Partition table
+ movb $0x1,%dh # Partition
+main.2: cmpb $PRT_UBX,0x4(%si) # Our partition type?
+ jne main.3 # No
+ jcxz main.5 # If second pass
+ testb $0x80,(%si) # Active?
+ jnz main.5 # Yes
+main.3: add $0x10,%si # Next entry
+ incb %dh # Partition
+ cmpb $0x1+PRT_NUM,%dh # In table?
+ jb main.2 # Yes
+ dec %cx # Do two
+ jcxz main.1 # passes
+#
+# If we get here, we didn't find any UbixOS slices at all, so print an
+# error message and die.
+#
+#Ubu mov $msg_part,%si # Message
+ jmp error # Error
+#
+# Floppies use partition 0 of drive 0.
+#
+main.4: xor %dx,%dx # Partition:drive
+#
+# Ok, we have a slice and drive in %dx now, so use that to locate and load
+# boot2. %si references the start of the slice we are looking for, so go
+# ahead and load up the first 16 sectors (boot1 + boot2) from that. When
+# we read it in, we conveniently use 0x8c00 as our transfer buffer. Thus,
+# boot1 ends up at 0x8c00, and boot2 starts at 0x8c00 + 0x200 = 0x8e00.
+# The first part of boot2 is the disklabel, which is 0x200 bytes long.
+# The second part is BTX, which is thus loaded into 0x9000, which is where
+# it also runs from. The boot2.bin binary starts right after the end of
+# BTX, so we have to figure out where the start of it is and then move the
+# binary to 0xb000. Normally, BTX clients start at MEM_USR, or 0xa000, but
+# when we use btxld create boot2, we use an entry point of 0x1000. That
+# entry point is relative to MEM_USR; thus boot2.bin starts at 0xb000.
+#
+main.5: mov %dx,MEM_ARG # Save args
+ movb $0x10,%dh # Sector count
+ callw nread # Read disk
+ mov $MEM_BTX,%bx # BTX
+ mov 0xa(%bx),%si # Get BTX length and set
+ add %bx,%si # %si to start of boot2.bin
+ mov $MEM_USR+SIZ_PAG,%di # Client page 1
+ mov $MEM_BTX+0xe*SIZ_SEC,%cx # Byte
+ sub %si,%cx # count
+ rep # Relocate
+ movsb # client
+ sub %di,%cx # Byte count
+ xorb %al,%al # Zero assumed bss from
+ rep # the end of boot2.bin
+ stosb # up to 0x10000
+ callw seta20 # Enable A20
+ jmp start+MEM_JMP-MEM_ORG # Start BTX
+#
+# Enable A20 so we can access memory above 1 meg.
+#
+seta20: cli # Disable interrupts
+seta20.1: inb $0x64,%al # Get status
+ testb $0x2,%al # Busy?
+ jnz seta20.1 # Yes
+ movb $0xd1,%al # Command: Write
+ outb %al,$0x64 # output port
+seta20.2: inb $0x64,%al # Get status
+ testb $0x2,%al # Busy?
+ jnz seta20.2 # Yes
+ movb $0xdf,%al # Enable
+ outb %al,$0x60 # A20
+ sti # Enable interrupts
+ retw # To caller
+#
+# Trampoline used to call read from within boot1.
+#
+nread: mov $MEM_BUF,%bx # Transfer buffer
+ mov 0x8(%si),%ax # Get
+ mov 0xa(%si),%cx # LBA
+ push %cs # Read from
+ callw xread.1 # disk
+ jnc return # If success, return
+ mov $msg_read,%si # Otherwise, set the error
+ # message and fall through to
+ # the error routine
+#
+# Print out the error message pointed to by %ds:(%si) followed
+# by a prompt, wait for a keypress, and then reboot the machine.
+#
+error: callw putstr # Display message
+# UBU mov $prompt,%si # Display
+ callw putstr # prompt
+ xorb %ah,%ah # BIOS: Get
+ int $0x16 # keypress
+ movw $0x1234, BDA_BOOT # Do a warm boot
+ ljmp $0xffff,$0x0 # reboot the machine
+#
+# Display a null-terminated string using the BIOS output.
+#
+putstr.0: mov $0x7,%bx # Page:attribute
+ movb $0xe,%ah # BIOS: Display
+ int $0x10 # character
+putstr: lodsb # Get char
+ testb %al,%al # End of string?
+ jne putstr.0 # No
+
+#
+# Overused return code. ereturn is used to return an error from the
+# read function. Since we assume putstr succeeds, we (ab)use the
+# same code when we return from putstr.
+#
+ereturn: movb $0x1,%ah # Invalid
+ stc # argument
+return: retw # To caller
+#
+# Reads sectors from the disk. If EDD is enabled, then check if it is
+# installed and use it if it is. If it is not installed or not enabled, then
+# fall back to using CHS. Since we use a LBA, if we are using CHS, we have to
+# fetch the drive parameters from the BIOS and divide it out ourselves.
+# Call with:
+#
+# %dl - byte - drive number
+# stack - 10 bytes - EDD Packet
+#
+read: push %dx # Save
+ movb $0x8,%ah # BIOS: Get drive
+ int $0x13 # parameters
+ movb %dh,%ch # Max head number
+ pop %dx # Restore
+ jc return # If error
+ andb $0x3f,%cl # Sectors per track
+ jz ereturn # If zero
+ cli # Disable interrupts
+ mov 0x8(%bp),%eax # Get LBA
+ push %dx # Save
+ movzbl %cl,%ebx # Divide by
+ xor %edx,%edx # sectors
+ div %ebx # per track
+ movb %ch,%bl # Max head number
+ movb %dl,%ch # Sector number
+ inc %bx # Divide by
+ xorb %dl,%dl # number
+ div %ebx # of heads
+ movb %dl,%bh # Head number
+ pop %dx # Restore
+ cmpl $0x3ff,%eax # Cylinder number supportable?
+ sti # Enable interrupts
+ ja read.7 # No, try EDD
+ xchgb %al,%ah # Set up cylinder
+ rorb $0x2,%al # number
+ orb %ch,%al # Merge
+ inc %ax # sector
+ xchg %ax,%cx # number
+ movb %bh,%dh # Head number
+ subb %ah,%al # Sectors this track
+ mov 0x2(%bp),%ah # Blocks to read
+ cmpb %ah,%al # To read
+ jb read.2 # this
+ movb %ah,%al # track
+read.2: mov $0x5,%di # Try count
+read.3: les 0x4(%bp),%bx # Transfer buffer
+ push %ax # Save
+ movb $0x2,%ah # BIOS: Read
+ int $0x13 # from disk
+ pop %bx # Restore
+ jnc read.4 # If success
+ dec %di # Retry?
+ jz read.6 # No
+ xorb %ah,%ah # BIOS: Reset
+ int $0x13 # disk system
+ xchg %bx,%ax # Block count
+ jmp read.3 # Continue
+read.4: movzbw %bl,%ax # Sectors read
+ add %ax,0x8(%bp) # Adjust
+ jnc read.5 # LBA,
+ incw 0xa(%bp) # transfer
+read.5: shlb %bl # buffer
+ add %bl,0x5(%bp) # pointer,
+ sub %al,0x2(%bp) # block count
+ ja read # If not done
+read.6: retw # To caller
+read.7: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
+ jz ereturn # No, so return an error
+ mov $0xbeba,%bx # Magic
+ push %dx # Save
+ movb $0x41,%ah # BIOS: Check
+ int $0x13 # extensions present
+ pop %dx # Restore
+ jc return # If error, return an error
+ cmp $0xbabe,%bx # Magic?
+ jne ereturn # No, so return an error
+ testb $0x1,%cl # Packet interface?
+ jz ereturn # No, so return an error
+ mov %bp,%si # Disk packet
+ movb $0x42,%ah # BIOS: Extended
+ int $0x13 # read
+ retw # To caller
+
+# Messages
+
+msg_read: .asciz "Read"
+msg_part: .asciz "Boot"
+
+prompt: .asciz " error\r\n"
+
+flags: .byte FLAGS # Flags
+
+ .org PRT_OFF,0x90
+
+# Partition table
+
+ .fill 0x30,0x1,0x0
+part4: .byte 0x80, 0x00, 0x01, 0x00
+ .byte 0x2A, 0xff, 0xff, 0xff
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x50, 0xc3, 0x00, 0x00 # 50000 sectors long, bleh
+
+ .word 0xbabe # Magic number
diff --git a/lockwasher/src/sys/boot/boot2/boot2.c b/lockwasher/src/sys/boot/boot2/boot2.c
new file mode 100644
index 0000000..013b416
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/boot2.c
@@ -0,0 +1,878 @@
+/*
+ * Copyright (c) 1998 Robert Nordier
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are freely
+ * permitted provided that the above copyright notice and this
+ * paragraph and the following disclaimer are duplicated in all
+ * such forms.
+ *
+ * This software is provided "AS IS" and without any express or
+ * implied warranties, including, without limitation, the implied
+ * warranties of merchantability and fitness for a particular
+ * purpose.
+ */
+
+/*
+ * $ID: src/sys/boot/i386/boot2/boot2.c,v 1.28.2.6 2002/03/31 18:12:50 pb Exp $
+ */
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+#include
+
+#include
+
+#include "boot2.h"
+#include "lib.h"
+#include "ubixfs.h"
+
+#define RBX_ASKNAME 0x0 /* -a */
+#define RBX_SINGLE 0x1 /* -s */
+#define RBX_DFLTROOT 0x5 /* -r */
+#define RBX_KDB 0x6 /* -d */
+#define RBX_CONFIG 0xa /* -c */
+#define RBX_VERBOSE 0xb /* -v */
+#define RBX_SERIAL 0xc /* -h */
+#define RBX_CDROM 0xd /* -C */
+#define RBX_GDB 0xf /* -g */
+#define RBX_DUAL 0x1d /* -D */
+#define RBX_PROBEKBD 0x1e /* -P */
+#define RBX_NOINTR 0x1f /* -n */
+
+#define RBX_MASK 0xffff
+
+#define PATH_CONFIG "/boot.config"
+#define PATH_BOOT3 "/boot/loader"
+#define PATH_KERNEL "/ubix.elf"
+
+#define ARGS 0x900
+#define NOPT 12
+#define BSIZEMAX 16384
+#define NDEV 5
+#define MEM_BASE 0x12
+#define MEM_EXT 0x15
+#define V86_CY(x) ((x) & 1)
+#define V86_ZR(x) ((x) & 0x40)
+
+#define DRV_HARD 0x80
+#define DRV_MASK 0x7f
+
+#define TYPE_AD 0
+#define TYPE_WD 1
+#define TYPE_WFD 2
+#define TYPE_FD 3
+#define TYPE_DA 4
+
+extern uint32_t _end;
+
+struct blockAllocationTableEntry *BAT = 0x0;
+struct directoryEntry *rootDir = 0x0;
+
+static const char optstr[NOPT] = "DhaCcdgnPrsv";
+static const unsigned char flags[NOPT] = {
+ RBX_DUAL,
+ RBX_SERIAL,
+ RBX_ASKNAME,
+ RBX_CDROM,
+ RBX_CONFIG,
+ RBX_KDB,
+ RBX_GDB,
+ RBX_NOINTR,
+ RBX_PROBEKBD,
+ RBX_DFLTROOT,
+ RBX_SINGLE,
+ RBX_VERBOSE
+};
+
+static const char *const dev_nm[] = {"ad", "wd", " ", "fd", "da"};
+static const unsigned dev_maj[] = {30, 0, 1, 2, 4};
+
+static struct dsk {
+ unsigned drive;
+ unsigned type;
+ unsigned unit;
+ unsigned slice;
+ unsigned part;
+ unsigned start;
+ int init;
+ int meta;
+} dsk;
+static char cmd[512];
+static char kname[1024];
+static uint32_t opts;
+static struct bootinfo bootinfo;
+static int ls;
+static uint32_t fs_off;
+static uint8_t ioctrl = 0x1;
+
+void exit(int);
+static void load(const char *);
+static int parse(char *);
+static ino_t lookup(const char *);
+static int xfsread(const char *, void *, size_t);
+static ssize_t fsread(const char *, void *, size_t);
+static int dskread(void *, unsigned, unsigned);
+static int printf(const char *,...);
+static int putchar(int);
+static void *memcpy(void *, const void *, size_t);
+static void *malloc(size_t);
+static uint32_t memsize(int);
+static int drvread(void *, unsigned, unsigned);
+static int keyhit(unsigned);
+static int xputc(int);
+static int xgetc(int);
+static int getc(int);
+
+//My Functions
+static void initUbixFS(void);
+
+static inline void readfile(const char *fname, void *buf, size_t size) {
+ fs_off = 0;
+ fsread(fname,buf,size);
+ /*
+ ino_t ino;
+ if ((ino = lookup(fname)))
+ fsread(ino, buf, size);
+ */
+ }
+
+static inline int
+strcmp(const char *s1, const char *s2)
+{
+ for (; *s1 == *s2 && *s1; s1++, s2++);
+ return (u_char)*s1 - (u_char)*s2;
+}
+
+static inline int
+fsfind(const char *name, ino_t * ino)
+{
+ char buf[DEV_BSIZE];
+ struct dirent *d;
+ char *s;
+ ssize_t n;
+ fs_off = 0;
+ while ((n = fsread(name, buf, DEV_BSIZE)) > 0)
+ for (s = buf; s < buf + DEV_BSIZE;) {
+ d = (void *)s;
+ if (ls)
+ printf("%s ", d->d_name);
+ else if (!strcmp(name, d->d_name)) {
+ *ino = d->d_fileno;
+ return d->d_type;
+ }
+ s += d->d_reclen;
+ }
+ if (n != -1 && ls)
+ putchar('\n');
+ return 0;
+}
+
+static inline int
+getchar(void)
+{
+ int c;
+
+ c = xgetc(0);
+ if (c == '\r')
+ c = '\n';
+ return c;
+}
+
+static inline void
+getstr(char *str, int size)
+{
+ char *s;
+ int c;
+
+ s = str;
+ do {
+ switch (c = getchar()) {
+ case 0:
+ break;
+ case '\b':
+ case '\177':
+ if (s > str) {
+ s--;
+ putchar('\b');
+ putchar(' ');
+ } else
+ c = 0;
+ break;
+ case '\n':
+ *s = 0;
+ break;
+ default:
+ if (s - str < size - 1)
+ *s++ = c;
+ }
+ if (c)
+ putchar(c);
+ } while (c != '\n');
+}
+
+static inline uint32_t
+drvinfo(int drive)
+{
+ v86.addr = 0x13;
+ v86.eax = 0x800;
+ v86.edx = DRV_HARD + drive;
+ v86int();
+ if (V86_CY(v86.efl))
+ return 0x4f010f;
+ return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
+ (v86.edx & 0xff00) | (v86.ecx & 0x3f);
+}
+
+static inline void
+putc(int c)
+{
+ v86.addr = 0x10;
+ v86.eax = 0xe00 | (c & 0xff);
+ v86.ebx = 0x7;
+ v86int();
+}
+
+static void initUbixFS() {
+ BAT = (struct blockAllocationTableEntry *)malloc(4096);
+ rootDir = (struct directoryEntry *)malloc(4096);
+ dskread(BAT,0,8);
+ dskread(rootDir,8,8);
+ }
+
+int
+main(void)
+{
+ int autoboot, i;
+
+ v86.ctl = V86_FLAGS;
+ dsk.drive = *(uint8_t *)PTOV(ARGS);
+ dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
+ dsk.unit = dsk.drive & DRV_MASK;
+ dsk.slice = *(uint8_t *)PTOV(ARGS + 1) + 1;
+ bootinfo.bi_version = BOOTINFO_VERSION;
+ bootinfo.bi_size = sizeof(bootinfo);
+ bootinfo.bi_basemem = memsize(MEM_BASE);
+ bootinfo.bi_extmem = memsize(MEM_EXT);
+ bootinfo.bi_memsizes_valid++;
+ for (i = 0; i < N_BIOS_GEOM; i++)
+ bootinfo.bi_bios_geom[i] = drvinfo(i);
+ autoboot = 2;
+
+ //Initialize UbixFS
+ initUbixFS();
+
+ readfile(PATH_CONFIG, cmd, sizeof(cmd));
+ if (*cmd) {
+ printf("%s: %s", PATH_CONFIG, cmd);
+ if (parse(cmd))
+ autoboot = 0;
+ *cmd = 0;
+ }
+ if (autoboot && !*kname) {
+ if (autoboot == 2) {
+ memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+ if (!keyhit(0x37)) {
+ load(kname);
+ autoboot = 1;
+ }
+ }
+ if (autoboot == 1)
+ memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
+ }
+ for (;;) {
+ printf(" \n>> UbixOS/i386 BOOT\n"
+ "Default: %u:%s(%u,%c)%s\n"
+ "boot: ",
+ dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
+ 'a' + dsk.part, kname);
+ if (ioctrl & 0x2)
+ sio_flush();
+ if (!autoboot || keyhit(0x5a))
+ getstr(cmd, sizeof(cmd));
+ else
+ putchar('\n');
+ autoboot = 0;
+ if (parse(cmd))
+ putchar('\a');
+ else
+ load(kname);
+ }
+}
+
+/* XXX - Needed for btxld to link the boot2 binary; do not remove. */
+void
+exit(int x)
+{
+}
+
+static void
+load(const char *fname)
+{
+ union {
+ struct exec ex;
+ Elf32_Ehdr eh;
+ } hdr;
+ Elf32_Phdr ep[2];
+ Elf32_Shdr es[2];
+ caddr_t p;
+ ino_t ino;
+ uint32_t addr, x;
+ int fmt, i, j;
+ fs_off = 0;
+ /*
+ if (!(ino = lookup(fname))) {
+ if (!ls)
+ printf("No %s\n", fname);
+ return;
+ }
+ */
+ if (xfsread(fname, &hdr, sizeof(hdr)))
+ return;
+ if (N_GETMAGIC(hdr.ex) == ZMAGIC)
+ fmt = 0;
+ else if (IS_ELF(hdr.eh))
+ fmt = 1;
+ else {
+ printf("Invalid %s\n", "format");
+ return;
+ }
+ if (fmt == 0) {
+ addr = hdr.ex.a_entry & 0xffffff;
+ p = PTOV(addr);
+ fs_off = PAGE_SIZE;
+ if (xfsread(fname, p, hdr.ex.a_text))
+ return;
+ p += roundup2(hdr.ex.a_text, PAGE_SIZE);
+ if (xfsread(fname, p, hdr.ex.a_data))
+ return;
+ p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
+ bootinfo.bi_symtab = VTOP(p);
+ memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
+ p += sizeof(hdr.ex.a_syms);
+ if (hdr.ex.a_syms) {
+ if (xfsread(fname, p, hdr.ex.a_syms))
+ return;
+ p += hdr.ex.a_syms;
+ if (xfsread(fname, p, sizeof(int)))
+ return;
+ x = *(uint32_t *)p;
+ p += sizeof(int);
+ x -= sizeof(int);
+ if (xfsread(fname, p, x))
+ return;
+ p += x;
+ }
+ } else {
+ fs_off = hdr.eh.e_phoff;
+ for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
+ if (xfsread(fname, ep + j, sizeof(ep[0])))
+ return;
+ if (ep[j].p_type == PT_LOAD)
+ j++;
+ }
+ for (i = 0; i < 2; i++) {
+ p = PTOV(ep[i].p_paddr & 0xffffff);
+ fs_off = ep[i].p_offset;
+ if (xfsread(fname, p, ep[i].p_filesz))
+ return;
+ }
+ p += roundup2(ep[1].p_memsz, PAGE_SIZE);
+ bootinfo.bi_symtab = VTOP(p);
+ if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) {
+ fs_off = hdr.eh.e_shoff + sizeof(es[0]) *
+ (hdr.eh.e_shstrndx + 1);
+ if (xfsread(fname, &es, sizeof(es)))
+ return;
+ for (i = 0; i < 2; i++) {
+ memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
+ p += sizeof(es[i].sh_size);
+ fs_off = es[i].sh_offset;
+ if (xfsread(fname, p, es[i].sh_size))
+ return;
+ p += es[i].sh_size;
+ }
+ }
+ addr = hdr.eh.e_entry & 0xffffff;
+ }
+ bootinfo.bi_esymtab = VTOP(p);
+ bootinfo.bi_kernelname = VTOP(fname);
+ bootinfo.bi_bios_dev = dsk.drive;
+ __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
+ MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
+ 0, 0, 0, VTOP(&bootinfo));
+}
+
+static int
+parse(char *arg)
+{
+ char *p, *q;
+ int drv, c, i;
+
+ while ((c = *arg++)) {
+ if (c == ' ' || c == '\t' || c == '\n')
+ continue;
+ for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
+ if (*p)
+ *p++ = 0;
+ if (c == '-') {
+ while ((c = *arg++)) {
+ for (i = 0; c != optstr[i]; i++)
+ if (i == NOPT - 1)
+ return -1;
+ opts ^= 1 << flags[i];
+ }
+ if (opts & 1 << RBX_PROBEKBD) {
+ i = *(uint8_t *)PTOV(0x496) & 0x10;
+ printf("Keyboard: %s\n", i ? "yes" : "no");
+ if (!i)
+ opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
+ opts &= ~(1 << RBX_PROBEKBD);
+ }
+ ioctrl = opts & 1 << RBX_DUAL ? 0x3 :
+ opts & 1 << RBX_SERIAL ? 0x2 : 0x1;
+ if (ioctrl & 0x2)
+ sio_init();
+ } else {
+ for (q = arg--; *q && *q != '('; q++);
+ if (*q) {
+ drv = -1;
+ if (arg[1] == ':') {
+ if (*arg < '0' || *arg > '9')
+ return -1;
+ drv = *arg - '0';
+ arg += 2;
+ }
+ if (q - arg != 2)
+ return -1;
+ for (i = 0; arg[0] != dev_nm[i][0] ||
+ arg[1] != dev_nm[i][1]; i++)
+ if (i == NDEV - 1)
+ return -1;
+ dsk.type = i;
+ arg += 3;
+ if (arg[1] != ',' || *arg < '0' || *arg > '9')
+ return -1;
+ dsk.unit = *arg - '0';
+ arg += 2;
+ dsk.slice = WHOLE_DISK_SLICE;
+ if (arg[1] == ',') {
+ if (*arg < '0' || *arg > '0' + NDOSPART)
+ return -1;
+ if ((dsk.slice = *arg - '0'))
+ dsk.slice++;
+ arg += 2;
+ }
+ if (arg[1] != ')' || *arg < 'a' || *arg > 'p')
+ return -1;
+ dsk.part = *arg - 'a';
+ arg += 2;
+ if (drv == -1)
+ drv = dsk.unit;
+ dsk.drive = (dsk.type == TYPE_WD ||
+ dsk.type == TYPE_AD ||
+ dsk.type == TYPE_DA ? DRV_HARD : 0) + drv;
+ dsk.meta = 0;
+ fsread(0, NULL, 0);
+ }
+ if ((i = p - arg - !*(p - 1))) {
+ if (i >= sizeof(kname))
+ return -1;
+ memcpy(kname, arg, i + 1);
+ }
+ }
+ arg = p;
+ }
+ return 0;
+}
+
+static ino_t
+lookup(const char *path)
+{
+ char name[MAXNAMLEN + 1];
+ const char *s;
+ ino_t ino;
+ ssize_t n;
+ int dt;
+
+ ino = ROOTINO;
+ dt = DT_DIR;
+ for (;;) {
+ if (*path == '/')
+ path++;
+ if (!*path)
+ break;
+ for (s = path; *s && *s != '/'; s++);
+ if ((n = s - path) > MAXNAMLEN)
+ return 0;
+ ls = *path == '?' && n == 1 && !*s;
+ memcpy(name, path, n);
+ name[n] = 0;
+ if ((dt = fsfind(name, &ino)) <= 0)
+ break;
+ path = s;
+ }
+ return dt == DT_REG ? ino : 0;
+}
+static int
+xfsread(const char *fname, void *buf, size_t nbyte)
+{
+ if (fsread(fname, buf, nbyte) != nbyte) {
+// printf("Invalid %s\n", "format");
+ return -1;
+ }
+ return 0;
+}
+
+/* FSREAD */
+static ssize_t fsread(const char *fname, void *buf, size_t nbyte) {
+ int i = 0x0,x = 0x0,block = 0x0,bOffset = 0x0,offset = 0x0,lb = -1;
+ int fBlock = -1;
+ char *buffer = 0x0;
+ char *buffer2 = 0x0;
+ struct directoryEntry *tmpDir = 0x0;
+ tmpDir = rootDir;
+ if (*fname == '/') { fname++; }
+ for (i=0;i<=(4096/sizeof(struct directoryEntry));i++) {
+ if (!strcmp(tmpDir[i].fileName,fname)) {
+ fBlock = tmpDir[i].startCluster;
+ break;
+ }
+ }
+ if (fBlock == -1) {
+ nbyte = 0;
+ return(nbyte);
+ }
+ buffer = malloc(4096);
+ buffer2 = buf;
+ offset = fs_off;
+ if (offset < 0) {
+ printf("Error!!!\n");
+ offset = 0;
+ }
+ for (i=0;i> DEV_BSHIFT;
+ dsk.meta++;
+ }
+ if (!inode)
+ return 0;
+ if (inomap != inode) {
+ if (dskread(blkbuf, fsbtodb(&fs, ino_to_fsba(&fs, inode)),
+ fsblks))
+ return -1;
+ din = ((struct dinode *)blkbuf)[inode % INOPB(&fs)];
+ inomap = inode;
+ fs_off = 0;
+ blkmap = indmap = 0;
+ }
+ s = buf;
+ if (nbyte > (n = din.di_size - fs_off))
+ nbyte = n;
+ nb = nbyte;
+ while (nb) {
+ lbn = lblkno(&fs, fs_off);
+ if (lbn < NDADDR)
+ addr = din.di_db[lbn];
+ else {
+ if (indmap != din.di_ib[0]) {
+ if (!indbuf)
+ indbuf = malloc(BSIZEMAX);
+ if (dskread(indbuf, fsbtodb(&fs, din.di_ib[0]),
+ fsblks))
+ return -1;
+ indmap = din.di_ib[0];
+ }
+ addr = indbuf[(lbn - NDADDR) % NINDIR(&fs)];
+ }
+ n = dblksize(&fs, &din, lbn);
+ if (blkmap != addr) {
+ if (dskread(blkbuf, fsbtodb(&fs, addr), n >> DEV_BSHIFT))
+ return -1;
+ blkmap = addr;
+ }
+ off = blkoff(&fs, fs_off);
+ n -= off;
+ if (n > nb)
+ n = nb;
+ memcpy(s, blkbuf + off, n);
+ s += n;
+ fs_off += n;
+ nb -= n;
+ }
+ return nbyte;
+}
+*/
+
+static int
+dskread(void *buf, unsigned lba, unsigned nblk)
+{
+ static char *sec;
+ struct dos_partition *dp;
+ struct ubixDiskLabel *d;
+ unsigned sl, i;
+
+ if (!dsk.meta) {
+ if (!sec)
+ sec = malloc(DEV_BSIZE);
+ dsk.start = 0;
+ if (drvread(sec, DOSBBSECTOR, 1))
+ return -1;
+ dp = (void *)(sec + DOSPARTOFF);
+ sl = dsk.slice;
+ if (sl < BASE_SLICE) {
+ for (i = 0; i < NDOSPART; i++)
+ if (dp[i].dp_typ == DOSPTYP_UBX &&
+ (dp[i].dp_flag & 0x80 || sl < BASE_SLICE)) {
+ sl = BASE_SLICE + i;
+ if (dp[i].dp_flag & 0x80 ||
+ dsk.slice == COMPATIBILITY_SLICE)
+ break;
+ }
+ if (dsk.slice == WHOLE_DISK_SLICE)
+ dsk.slice = sl;
+ }
+ if (sl != WHOLE_DISK_SLICE) {
+ if (sl != COMPATIBILITY_SLICE)
+ dp += sl - BASE_SLICE;
+ if (dp->dp_typ != DOSPTYP_UBX) {
+ printf("Invalid %s\n", "slice");
+ return -1;
+ }
+ dsk.start = dp->dp_start;
+ }
+ if (drvread(sec, dsk.start + LABELSECTOR, 1))
+ return -1;
+ d = (void *)(sec + LABELOFFSET);
+ if (d->magicNum != UBIXDISKMAGIC || d->magicNum2 != UBIXDISKMAGIC) {
+ if (dsk.part != RAW_PART) {
+ printf("Invalid %s\n", "label");
+ return -1;
+ }
+ } else {
+ if (!dsk.init) {
+ if (d->driveType == DTYPE_SCSI)
+ dsk.type = TYPE_DA;
+ dsk.init++;
+ }
+ if (dsk.part >= d->numPartitions ||
+ !d->partitions[dsk.part].p_size) {
+ printf("Invalid %s\n", "partition");
+ return -1;
+ }
+ dsk.start = d->partitions[dsk.part].p_offset;
+ }
+ }
+ return drvread(buf, dsk.start + lba, nblk);
+}
+
+static int
+printf(const char *fmt,...)
+{
+ static const char digits[16] = "0123456789abcdef";
+ va_list ap;
+ char buf[10];
+ char *s;
+ unsigned r, u;
+ int c;
+
+ va_start(ap, fmt);
+ while ((c = *fmt++)) {
+ if (c == '%') {
+ c = *fmt++;
+ switch (c) {
+ case 'c':
+ putchar(va_arg(ap, int));
+ continue;
+ case 's':
+ for (s = va_arg(ap, char *); *s; s++)
+ putchar(*s);
+ continue;
+ case 'u':
+ case 'x':
+ r = c == 'u' ? 10U : 16U;
+ u = va_arg(ap, unsigned);
+ s = buf;
+ do
+ *s++ = digits[u % r];
+ while (u /= r);
+ while (--s >= buf)
+ putchar(*s);
+ continue;
+ }
+ }
+ putchar(c);
+ }
+ va_end(ap);
+ return 0;
+}
+
+static int
+putchar(int c)
+{
+ if (c == '\n')
+ xputc('\r');
+ return xputc(c);
+}
+
+static void *
+memcpy(void *dst, const void *src, size_t size)
+{
+ const char *s;
+ char *d;
+
+ for (d = dst, s = src; size; size--)
+ *d++ = *s++;
+ return dst;
+}
+
+static void *
+malloc(size_t size)
+{
+ static uint32_t next;
+ void *p;
+
+ if (!next)
+ next = roundup2(__base + _end, 0x10000) - __base;
+ p = (void *)next;
+ next += size;
+ return p;
+}
+
+static uint32_t
+memsize(int type)
+{
+ v86.addr = type;
+ v86.eax = 0x8800;
+ v86int();
+ return v86.eax;
+}
+
+static int
+drvread(void *buf, unsigned lba, unsigned nblk)
+{
+ static unsigned c = 0x2d5c7c2f;
+
+ printf("%c\b", c = c << 8 | c >> 24);
+ v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
+ v86.addr = XREADORG; /* call to xread in boot1 */
+ v86.es = VTOPSEG(buf);
+ v86.eax = lba;
+ v86.ebx = VTOPOFF(buf);
+ v86.ecx = lba >> 16;
+ v86.edx = nblk << 8 | dsk.drive;
+ v86int();
+ v86.ctl = V86_FLAGS;
+ if (V86_CY(v86.efl)) {
+ printf("Disk error 0x%x (lba=0x%x)\n", v86.eax >> 8 & 0xff,
+ lba);
+ return -1;
+ }
+ return 0;
+}
+
+static int
+keyhit(unsigned ticks)
+{
+ uint32_t t0, t1;
+
+ if (opts & 1 << RBX_NOINTR)
+ return 0;
+ t0 = 0;
+ for (;;) {
+ if (xgetc(1))
+ return 1;
+ t1 = *(uint32_t *)PTOV(0x46c);
+ if (!t0)
+ t0 = t1;
+ if (t1 < t0 || t1 >= t0 + ticks)
+ return 0;
+ }
+}
+
+static int
+xputc(int c)
+{
+ if (ioctrl & 0x1)
+ putc(c);
+ if (ioctrl & 0x2)
+ sio_putc(c);
+ return c;
+}
+
+static int
+xgetc(int fn)
+{
+ if (opts & 1 << RBX_NOINTR)
+ return 0;
+ for (;;) {
+ if (ioctrl & 0x1 && getc(1))
+ return fn ? 1 : getc(0);
+ if (ioctrl & 0x2 && sio_ischar())
+ return fn ? 1 : sio_getc();
+ if (fn)
+ return 0;
+ }
+}
+
+static int
+getc(int fn)
+{
+ v86.addr = 0x16;
+ v86.eax = fn << 8;
+ v86int();
+ return fn == 0 ? v86.eax & 0xff : !V86_ZR(v86.efl);
+}
diff --git a/lockwasher/src/sys/boot/boot2/lib.h b/lockwasher/src/sys/boot/boot2/lib.h
new file mode 100644
index 0000000..44d1f10
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/lib.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 1998 Robert Nordier
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are freely
+ * permitted provided that the above copyright notice and this
+ * paragraph and the following disclaimer are duplicated in all
+ * such forms.
+ *
+ * This software is provided "AS IS" and without any express or
+ * implied warranties, including, without limitation, the implied
+ * warranties of merchantability and fitness for a particular
+ * purpose.
+ */
+
+/*
+ * $FreeBSD: src/sys/boot/i386/boot2/lib.h,v 1.2 1999/08/28 00:40:02 peter Exp $
+ */
+
+void sio_init(void);
+void sio_flush(void);
+void sio_putc(int);
+int sio_getc(void);
+int sio_ischar(void);
diff --git a/lockwasher/src/sys/boot/boot2/sio.s b/lockwasher/src/sys/boot/boot2/sio.s
new file mode 100644
index 0000000..1e8da20
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/sio.s
@@ -0,0 +1,80 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $FreeBSD: src/sys/boot/i386/boot2/sio.s,v 1.4 1999/08/28 00:40:02 peter Exp $
+
+ .set SIO_PRT,SIOPRT # Base port
+ .set SIO_FMT,SIOFMT # 8N1
+ .set SIO_DIV,(115200/SIOSPD) # 115200 / SPD
+
+ .globl sio_init
+ .globl sio_flush
+ .globl sio_putc
+ .globl sio_getc
+ .globl sio_ischar
+
+# void sio_init(void)
+
+sio_init: movw $SIO_PRT+0x3,%dx # Data format reg
+ movb $SIO_FMT|0x80,%al # Set format
+ outb %al,(%dx) # and DLAB
+ pushl %edx # Save
+ subb $0x3,%dl # Divisor latch reg
+ movw $SIO_DIV,%ax # Set
+ outw %ax,(%dx) # BPS
+ popl %edx # Restore
+ movb $SIO_FMT,%al # Clear
+ outb %al,(%dx) # DLAB
+ incl %edx # Modem control reg
+ movb $0x3,%al # Set RTS,
+ outb %al,(%dx) # DTR
+ incl %edx # Line status reg
+
+# void sio_flush(void)
+
+sio_flush.0: call sio_getc.1 # Get character
+sio_flush: call sio_ischar # Check for character
+ jnz sio_flush.0 # Till none
+ ret # To caller
+
+# void sio_putc(int c)
+
+sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg
+ xor %ecx,%ecx # Timeout
+ movb $0x40,%ch # counter
+sio_putc.1: inb (%dx),%al # Transmitter
+ testb $0x20,%al # buffer empty?
+ loopz sio_putc.1 # No
+ jz sio_putc.2 # If timeout
+ movb 0x4(%esp,1),%al # Get character
+ subb $0x5,%dl # Transmitter hold reg
+ outb %al,(%dx) # Write character
+sio_putc.2: ret $0x4 # To caller
+
+# int sio_getc(void)
+
+sio_getc: call sio_ischar # Character available?
+ jz sio_getc # No
+sio_getc.1: subb $0x5,%dl # Receiver buffer reg
+ inb (%dx),%al # Read character
+ ret # To caller
+
+# int sio_ischar(void)
+
+sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register
+ xorl %eax,%eax # Zero
+ inb (%dx),%al # Received data
+ andb $0x1,%al # ready?
+ ret # To caller
diff --git a/lockwasher/src/sys/boot/boot2/test.c b/lockwasher/src/sys/boot/boot2/test.c
new file mode 100644
index 0000000..3cb1c85
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/test.c
@@ -0,0 +1,24 @@
+#include
+#include
+
+#include "ubixfs.h"
+
+int main() {
+ FILE *fd;
+ struct ubixDiskLabel *d = (struct ubixDiskLabel *)malloc(512);
+ printf("Building Disk Label\n");
+ d->magicNum = UBIXDISKMAGIC;
+ d->magicNum2 = UBIXDISKMAGIC;
+ d->numPartitions = 2;
+ d->partitions[0].p_size = 2000;
+ d->partitions[0].p_offset = 50;
+ d->partitions[0].p_fstype = 0x24;
+ d->partitions[0].p_bsize = 0x8;
+ d->partitions[1].p_size = 2000;
+ d->partitions[1].p_offset = 1000;
+ d->partitions[1].p_fstype = 0x24;
+ d->partitions[1].p_bsize = 0x8;
+ fd = fopen("/dev/fd0","wb");
+ fseek(fd,512,0);
+ fwrite(d,512,1,fd);
+ }
diff --git a/lockwasher/src/sys/boot/boot2/ubixfs.h b/lockwasher/src/sys/boot/boot2/ubixfs.h
new file mode 100644
index 0000000..4c558d1
--- /dev/null
+++ b/lockwasher/src/sys/boot/boot2/ubixfs.h
@@ -0,0 +1,44 @@
+#define DOSPTYP_UBX 0x2A /* UbixFS partition type */
+#define UBIXDISKMAGIC ((u_int32_t)0x45) /* The disk magic number */
+#define MAXUBIXPARTITIONS 16
+#define UBIXFSMAGIC ((u_int32_t)0x69) /* The File System Magic Number */
+
+typedef unsigned long uLong;
+typedef unsigned short uShort;
+
+
+struct ubixDiskLabel {
+ u_int32_t magicNum;
+ u_int32_t magicNum2;
+ u_int16_t driveType;
+ u_int16_t numPartitions;
+ struct ubixPartitions { /* the partition table */
+ u_int32_t p_size; /* number of sectors in partition */
+ u_int32_t p_offset; /* starting sector */
+ u_int32_t p_fsize; /* filesystem basic fragment size */
+ u_int32_t p_bsize; /* BAT size */
+ u_int8_t p_fstype; /* filesystem type, see below */
+ u_int8_t p_frag; /* filesystem fragments per block */
+ } partitions[MAXUBIXPARTITIONS];
+ };
+
+//Block Allocation Table Entry
+struct blockAllocationTableEntry {
+ long attributes; //Block Attributes
+ long realSector; //Real Sector
+ long nextBlock; //Sector Of Next Block
+ long reserved; //Reserved
+ };
+
+
+struct directoryEntry {
+ uLong startCluster; //Starting Cluster Of File
+ uLong size; //Size Of File
+ uLong creationDate; //Date Created
+ uLong lastModified; //Date Last Modified
+ uLong uid; //UID Of Owner
+ uLong gid; //GID Of Owner
+ uShort attributes; //Files Attributes
+ uShort permissions; //Files Permissions
+ char fileName[256]; //File Name
+ };
diff --git a/lockwasher/src/sys/boot/btx/Makefile b/lockwasher/src/sys/boot/btx/Makefile
new file mode 100644
index 0000000..9a65f19
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD: src/sys/boot/i386/btx/Makefile,v 1.6 1999/08/28 00:40:03 peter Exp $
+
+SUBDIR= btx btxldr lib
+
+.include
diff --git a/lockwasher/src/sys/boot/btx/btx/Makefile b/lockwasher/src/sys/boot/btx/btx/Makefile
new file mode 100644
index 0000000..cdefb50
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/btx/Makefile
@@ -0,0 +1,36 @@
+# $FreeBSD: src/sys/boot/i386/btx/btx/Makefile,v 1.7.2.2 2000/12/28 12:08:22 ps Exp $
+
+M4?= m4
+
+.if defined(PAGING)
+M4FLAGS+= -DPAGING
+.endif
+
+.if defined(BOOT_BTX_NOHANG)
+BOOT_BTX_FLAGS=0x1
+.else
+BOOT_BTX_FLAGS=0x0
+.endif
+
+AFLAGS+= --defsym BTX_FLAGS=${BOOT_BTX_FLAGS}
+
+ORG= 0x9000
+
+all: btx
+
+btx: btx.o
+.if ${OBJFORMAT} == aout
+ ${LD} -nostdlib -N -s -T ${ORG} -o btx.out btx.o
+ dd if=btx.out of=${.TARGET} ibs=32 skip=1
+.else
+ ${LD} -N -e start -Ttext ${ORG} -o btx.out btx.o
+ objcopy -S -O binary btx.out ${.TARGET}
+.endif
+
+btx.o: btx.s
+ (cd ${.CURDIR}; ${M4} ${M4FLAGS} btx.s) | \
+ ${AS} ${AFLAGS} -o ${.TARGET}
+
+CLEANFILES+= btx btx.out btx.o
+
+.include
diff --git a/lockwasher/src/sys/boot/btx/btx/btx.s b/lockwasher/src/sys/boot/btx/btx/btx.s
new file mode 100644
index 0000000..0bcf0a9
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/btx/btx.s
@@ -0,0 +1,1080 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $FreeBSD: src/sys/boot/i386/btx/btx/btx.s,v 1.15.2.4 2000/12/28 12:08:22 ps Exp $
+
+#
+# Memory layout.
+#
+ .set MEM_BTX,0x1000 # Start of BTX memory
+ .set MEM_ESP0,0x1800 # Supervisor stack
+ .set MEM_BUF,0x1800 # Scratch buffer
+ .set MEM_ESP1,0x1e00 # Link stack
+ .set MEM_IDT,0x1e00 # IDT
+ .set MEM_TSS,0x1f98 # TSS
+ .set MEM_MAP,0x2000 # I/O bit map
+ .set MEM_DIR,0x4000 # Page directory
+ .set MEM_TBL,0x5000 # Page tables
+ .set MEM_ORG,0x9000 # BTX code
+ .set MEM_USR,0xa000 # Start of user memory
+#
+# Paging control.
+#
+ .set PAG_SIZ,0x1000 # Page size
+ .set PAG_CNT,0x1000 # Pages to map
+#
+# Segment selectors.
+#
+ .set SEL_SCODE,0x8 # Supervisor code
+ .set SEL_SDATA,0x10 # Supervisor data
+ .set SEL_RCODE,0x18 # Real mode code
+ .set SEL_RDATA,0x20 # Real mode data
+ .set SEL_UCODE,0x28|3 # User code
+ .set SEL_UDATA,0x30|3 # User data
+ .set SEL_TSS,0x38 # TSS
+#
+# Task state segment fields.
+#
+ .set TSS_ESP0,0x4 # PL 0 ESP
+ .set TSS_SS0,0x8 # PL 0 SS
+ .set TSS_ESP1,0xc # PL 1 ESP
+ .set TSS_MAP,0x66 # I/O bit map base
+#
+# System calls.
+#
+ .set SYS_EXIT,0x0 # Exit
+ .set SYS_EXEC,0x1 # Exec
+#
+# V86 constants.
+#
+ .set V86_FLG,0x208eff # V86 flag mask
+ .set V86_STK,0x400 # V86 stack allowance
+#
+# Dump format control bytes.
+#
+ .set DMP_X16,0x1 # Word
+ .set DMP_X32,0x2 # Long
+ .set DMP_MEM,0x4 # Memory
+ .set DMP_EOL,0x8 # End of line
+#
+# Screen defaults and assumptions.
+#
+ .set SCR_MAT,0x7 # Mode/attribute
+ .set SCR_COL,0x50 # Columns per row
+ .set SCR_ROW,0x19 # Rows per screen
+#
+# BIOS Data Area locations.
+#
+ .set BDA_MEM,0x413 # Free memory
+ .set BDA_KEYFLAGS,0x417 # Keyboard shift-state flags
+ .set BDA_SCR,0x449 # Video mode
+ .set BDA_POS,0x450 # Cursor position
+ .set BDA_BOOT,0x472 # Boot howto flag
+#
+# Derivations, for brevity.
+#
+ .set _ESP0H,MEM_ESP0>>0x8 # Byte 1 of ESP0
+ .set _ESP1H,MEM_ESP1>>0x8 # Byte 1 of ESP1
+ .set _TSSIO,MEM_MAP-MEM_TSS # TSS I/O base
+ .set _TSSLM,MEM_DIR-MEM_TSS-1 # TSS limit
+ .set _IDTLM,MEM_TSS-MEM_IDT-1 # IDT limit
+#
+# Code segment.
+#
+ .globl start
+ .code16
+start: # Start of code
+#
+# BTX header.
+#
+btx_hdr: .byte 0xeb # Machine ID
+ .byte 0xe # Header size
+ .ascii "BTX" # Magic
+ .byte 0x1 # Major version
+ .byte 0x1 # Minor version
+ .byte BTX_FLAGS # Flags
+ .word PAG_CNT-MEM_ORG>>0xc # Paging control
+ .word break-start # Text size
+ .long 0x0 # Entry address
+#
+# Initialization routine.
+#
+init: cli # Disable interrupts
+ xor %ax,%ax # Zero/segment
+ mov %ax,%ss # Set up
+ mov $MEM_ESP0,%sp # stack
+ mov %ax,%es # Address
+ mov %ax,%ds # data
+ pushl $0x2 # Clear
+ popfl # flags
+#
+# Initialize memory.
+#
+ mov $MEM_IDT,%di # Memory to initialize
+ mov $(MEM_ORG-MEM_IDT)/2,%cx # Words to zero
+ push %di # Save
+ rep # Zero-fill
+ stosw # memory
+ pop %di # Restore
+#
+# Create IDT.
+#
+ mov $idtctl,%si # Control string
+init.1: lodsb # Get entry
+ cbw # count
+ xchg %ax,%cx # as word
+ jcxz init.4 # If done
+ lodsb # Get segment
+ xchg %ax,%dx # P:DPL:type
+ lodsw # Get control
+ xchg %ax,%bx # set
+ lodsw # Get handler offset
+ mov $SEL_SCODE,%dh # Segment selector
+init.2: shr %bx # Handle this int?
+ jnc init.3 # No
+ mov %ax,(%di) # Set handler offset
+ mov %dh,0x2(%di) # and selector
+ mov %dl,0x5(%di) # Set P:DPL:type
+ add $0x4,%ax # Next handler
+init.3: lea 0x8(%di),%di # Next entry
+ loop init.2 # Till set done
+ jmp init.1 # Continue
+#
+# Initialize TSS.
+#
+init.4: movb $_ESP0H,TSS_ESP0+1(%di) # Set ESP0
+ movb $SEL_SDATA,TSS_SS0(%di) # Set SS0
+ movb $_ESP1H,TSS_ESP1+1(%di) # Set ESP1
+ movb $_TSSIO,TSS_MAP(%di) # Set I/O bit map base
+ifdef(`PAGING',`
+#
+# Create page directory.
+#
+ xor %edx,%edx # Page
+ mov $PAG_SIZ>>0x8,%dh # size
+ xor %eax,%eax # Zero
+ mov $MEM_DIR,%di # Page directory
+ mov $PAG_CNT>>0xa,%cl # Entries
+ mov $MEM_TBL|0x7,%ax # First entry
+init.5: stosl # Write entry
+ add %dx,%ax # To next
+ loop init.5 # Till done
+#
+# Create page tables.
+#
+ mov $MEM_TBL,%di # Page table
+ mov $PAG_CNT>>0x8,%ch # Entries
+ xor %ax,%ax # Start address
+init.6: mov $0x7,%al # Set U:W:P flags
+ cmp btx_hdr+0x8,%cx # Standard user page?
+ jb init.7 # Yes
+ cmp $PAG_CNT-MEM_BTX>>0xc,%cx # BTX memory?
+ jae init.7 # No or first page
+ and $~0x2,%al # Clear W flag
+ cmp $PAG_CNT-MEM_USR>>0xc,%cx # User page zero?
+ jne init.7 # No
+ testb $0x80,btx_hdr+0x7 # Unmap it?
+ jz init.7 # No
+ and $~0x1,%al # Clear P flag
+init.7: stosl # Set entry
+ add %edx,%eax # Next address
+ loop init.6 # Till done
+')
+#
+# Bring up the system.
+#
+ mov $0x2820,%bx # Set protected mode
+ callw setpic # IRQ offsets
+ lidt idtdesc # Set IDT
+ifdef(`PAGING',`
+ xor %eax,%eax # Set base
+ mov $MEM_DIR>>0x8,%ah # of page
+ mov %eax,%cr3 # directory
+')
+ lgdt gdtdesc # Set GDT
+ mov %cr0,%eax # Switch to protected
+ifdef(`PAGING',`
+ or $0x80000001,%eax # mode and enable paging
+',`
+ or $0x01,%eax # mode
+')
+ mov %eax,%cr0 #
+ ljmp $SEL_SCODE,$init.8 # To 32-bit code
+ .code32
+init.8: xorl %ecx,%ecx # Zero
+ movb $SEL_SDATA,%cl # To 32-bit
+ movw %cx,%ss # stack
+#
+# Launch user task.
+#
+ movb $SEL_TSS,%cl # Set task
+ ltr %cx # register
+ movl $MEM_USR,%edx # User base address
+ movzwl %ss:BDA_MEM,%eax # Get free memory
+ shll $0xa,%eax # To bytes
+ subl $0x1000,%eax # Less arg space
+ subl %edx,%eax # Less base
+ movb $SEL_UDATA,%cl # User data selector
+ pushl %ecx # Set SS
+ pushl %eax # Set ESP
+ push $0x202 # Set flags (IF set)
+ push $SEL_UCODE # Set CS
+ pushl btx_hdr+0xc # Set EIP
+ pushl %ecx # Set GS
+ pushl %ecx # Set FS
+ pushl %ecx # Set DS
+ pushl %ecx # Set ES
+ pushl %edx # Set EAX
+ movb $0x7,%cl # Set remaining
+init.9: push $0x0 # general
+ loop init.9 # registers
+ popa # and initialize
+ popl %es # Initialize
+ popl %ds # user
+ popl %fs # segment
+ popl %gs # registers
+ iret # To user mode
+#
+# Exit routine.
+#
+exit: cli # Disable interrupts
+ movl $MEM_ESP0,%esp # Clear stack
+#
+# Turn off paging.
+#
+ movl %cr0,%eax # Get CR0
+ifdef(`PAGING',`
+ andl $~0x80000000,%eax # Disable
+ movl %eax,%cr0 # paging
+')
+ xorl %ecx,%ecx # Zero
+ifdef(`PAGING',`
+ movl %ecx,%cr3 # Flush TLB
+')
+#
+# To 16 bits.
+#
+ ljmpw $SEL_RCODE,$exit.1 # Reload CS
+ .code16
+exit.1: mov $SEL_RDATA,%cl # 16-bit selector
+ mov %cx,%ss # Reload SS
+ mov %cx,%ds # Load
+ mov %cx,%es # remaining
+ mov %cx,%fs # segment
+ mov %cx,%gs # registers
+#
+# To real-address mode.
+#
+ dec %ax # Switch to
+ mov %eax,%cr0 # real mode
+ ljmp $0x0,$exit.2 # Reload CS
+exit.2: xor %ax,%ax # Real mode segment
+ mov %ax,%ss # Reload SS
+ mov %ax,%ds # Address data
+ mov $0x7008,%bx # Set real mode
+ callw setpic # IRQ offsets
+ lidt ivtdesc # Set IVT
+#
+# Reboot or await reset.
+#
+ sti # Enable interrupts
+ testb $0x1,btx_hdr+0x7 # Reboot?
+exit.3: jz exit.3 # No
+ movw $0x1234, BDA_BOOT # Do a warm boot
+ ljmp $0xffff,$0x0 # reboot the machine
+#
+# Set IRQ offsets by reprogramming 8259A PICs.
+#
+setpic: in $0x21,%al # Save master
+ push %ax # IMR
+ in $0xa1,%al # Save slave
+ push %ax # IMR
+ movb $0x11,%al # ICW1 to
+ outb %al,$0x20 # master,
+ outb %al,$0xa0 # slave
+ movb %bl,%al # ICW2 to
+ outb %al,$0x21 # master
+ movb %bh,%al # ICW2 to
+ outb %al,$0xa1 # slave
+ movb $0x4,%al # ICW3 to
+ outb %al,$0x21 # master
+ movb $0x2,%al # ICW3 to
+ outb %al,$0xa1 # slave
+ movb $0x1,%al # ICW4 to
+ outb %al,$0x21 # master,
+ outb %al,$0xa1 # slave
+ pop %ax # Restore slave
+ outb %al,$0xa1 # IMR
+ pop %ax # Restore master
+ outb %al,$0x21 # IMR
+ retw # To caller
+ .code32
+#
+# Initiate return from V86 mode to user mode.
+#
+inthlt: hlt # To supervisor mode
+#
+# Exception jump table.
+#
+intx00: push $0x0 # Int 0x0: #DE
+ jmp ex_noc # Divide error
+ push $0x1 # Int 0x1: #DB
+ jmp ex_noc # Debug
+ push $0x3 # Int 0x3: #BP
+ jmp ex_noc # Breakpoint
+ push $0x4 # Int 0x4: #OF
+ jmp ex_noc # Overflow
+ push $0x5 # Int 0x5: #BR
+ jmp ex_noc # BOUND range exceeded
+ push $0x6 # Int 0x6: #UD
+ jmp ex_noc # Invalid opcode
+ push $0x7 # Int 0x7: #NM
+ jmp ex_noc # Device not available
+ push $0x8 # Int 0x8: #DF
+ jmp except # Double fault
+ push $0xa # Int 0xa: #TS
+ jmp except # Invalid TSS
+ push $0xb # Int 0xb: #NP
+ jmp except # Segment not present
+ push $0xc # Int 0xc: #SS
+ jmp except # Stack segment fault
+ push $0xd # Int 0xd: #GP
+ jmp ex_v86 # General protection
+ push $0xe # Int 0xe: #PF
+ jmp except # Page fault
+intx10: push $0x10 # Int 0x10: #MF
+ jmp ex_noc # Floating-point error
+#
+# Handle #GP exception.
+#
+ex_v86: testb $0x2,0x12(%esp,1) # V86 mode?
+ jz except # No
+ jmp v86mon # To monitor
+#
+# Save a zero error code.
+#
+ex_noc: pushl (%esp,1) # Duplicate int no
+ movb $0x0,0x4(%esp,1) # Fake error code
+#
+# Handle exception.
+#
+except: cld # String ops inc
+ pushl %ds # Save
+ pushl %es # most
+ pusha # registers
+ movb $0x6,%al # Push loop count
+ testb $0x2,0x3a(%esp,1) # V86 mode?
+ jnz except.1 # Yes
+ pushl %gs # Set GS
+ pushl %fs # Set FS
+ pushl %ds # Set DS
+ pushl %es # Set ES
+ movb $0x2,%al # Push loop count
+ cmpw $SEL_SCODE,0x44(%esp,1) # Supervisor mode?
+ jne except.1 # No
+ pushl %ss # Set SS
+ leal 0x50(%esp,1),%eax # Set
+ pushl %eax # ESP
+ jmp except.2 # Join common code
+except.1: pushl 0x50(%esp,1) # Set GS, FS, DS, ES
+ decb %al # (if V86 mode), and
+ jne except.1 # SS, ESP
+except.2: push $SEL_SDATA # Set up
+ popl %ds # to
+ pushl %ds # address
+ popl %es # data
+ movl %esp,%ebx # Stack frame
+ movl $dmpfmt,%esi # Dump format string
+ movl $MEM_BUF,%edi # Buffer
+ pushl %edi # Dump to
+ call dump # buffer
+ popl %esi # and
+ call putstr # display
+ leal 0x18(%esp,1),%esp # Discard frame
+ popa # Restore
+ popl %es # registers
+ popl %ds # saved
+ cmpb $0x3,(%esp,1) # Breakpoint?
+ je except.3 # Yes
+ jmp exit # Exit
+except.3: leal 0x8(%esp,1),%esp # Discard err, int no
+ iret # From interrupt
+#
+# Return to user mode from V86 mode.
+#
+intrtn: cld # String ops inc
+ pushl %ds # Address
+ popl %es # data
+ leal 0x3c(%ebp),%edx # V86 Segment registers
+ movl MEM_TSS+TSS_ESP1,%esi # Link stack pointer
+ lodsl # INT_V86 args pointer
+ movl %esi,%ebx # Saved exception frame
+ testl %eax,%eax # INT_V86 args?
+ jz intrtn.2 # No
+ movl $MEM_USR,%edi # User base
+ movl 0x1c(%esi),%ebx # User ESP
+ movl %eax,(%edi,%ebx,1) # Restore to user stack
+ leal 0x8(%edi,%eax,1),%edi # Arg segment registers
+ testb $0x4,-0x6(%edi) # Return flags?
+ jz intrtn.1 # No
+ movl 0x30(%ebp),%eax # Get V86 flags
+ movw %ax,0x18(%esi) # Set user flags
+intrtn.1: leal 0x10(%esi),%ebx # Saved exception frame
+ xchgl %edx,%esi # Segment registers
+ movb $0x4,%cl # Update seg regs
+ rep # in INT_V86
+ movsl # args
+intrtn.2: movl %edx,%esi # Segment registers
+ leal 0x28(%ebp),%edi # Set up seg
+ movb $0x4,%cl # regs for
+ rep # later
+ movsl # pop
+ movl %ebx,%esi # Restore exception
+ movb $0x5,%cl # frame to
+ rep # supervisor
+ movsl # stack
+ movl %esi,MEM_TSS+TSS_ESP1 # Link stack pointer
+ popa # Restore
+ leal 0x8(%esp,1),%esp # Discard err, int no
+ popl %es # Restore
+ popl %ds # user
+ popl %fs # segment
+ popl %gs # registers
+ iret # To user mode
+#
+# V86 monitor.
+#
+v86mon: cld # String ops inc
+ pushl $SEL_SDATA # Set up for
+ popl %ds # flat addressing
+ pusha # Save registers
+ movl %esp,%ebp # Address stack frame
+ movzwl 0x2c(%ebp),%edi # Load V86 CS
+ shll $0x4,%edi # To linear
+ movl 0x28(%ebp),%esi # Load V86 IP
+ addl %edi,%esi # Code pointer
+ xorl %ecx,%ecx # Zero
+ movb $0x2,%cl # 16-bit operands
+ xorl %eax,%eax # Zero
+v86mon.1: lodsb # Get opcode
+ cmpb $0x66,%al # Operand size prefix?
+ jne v86mon.2 # No
+ movb $0x4,%cl # 32-bit operands
+ jmp v86mon.1 # Continue
+v86mon.2: cmpb $0xf4,%al # HLT?
+ jne v86mon.3 # No
+ cmpl $inthlt+0x1,%esi # Is inthlt?
+ jne v86mon.7 # No (ignore)
+ jmp intrtn # Return to user mode
+v86mon.3: cmpb $0xf,%al # Prefixed instruction?
+ jne v86mon.4 # No
+ cmpb $0x09,(%esi) # Is it a WBINVD?
+ je v86wbinvd # Yes
+ cmpb $0x30,(%esi) # Is it a WRMSR?
+ je v86wrmsr # Yes
+ cmpb $0x32,(%esi) # Is it a RDMSR?
+ je v86rdmsr # Yes
+ cmpb $0x20,(%esi) # Is this a
+ jne v86mon.4 # MOV EAX,CR0
+ cmpb $0xc0,0x1(%esi) # instruction?
+ je v86mov # Yes
+v86mon.4: cmpb $0xfa,%al # CLI?
+ je v86cli # Yes
+ cmpb $0xfb,%al # STI?
+ je v86sti # Yes
+ movzwl 0x38(%ebp),%ebx # Load V86 SS
+ shll $0x4,%ebx # To offset
+ pushl %ebx # Save
+ addl 0x34(%ebp),%ebx # Add V86 SP
+ movl 0x30(%ebp),%edx # Load V86 flags
+ cmpb $0x9c,%al # PUSHF/PUSHFD?
+ je v86pushf # Yes
+ cmpb $0x9d,%al # POPF/POPFD?
+ je v86popf # Yes
+ cmpb $0xcd,%al # INT imm8?
+ je v86intn # Yes
+ cmpb $0xcf,%al # IRET/IRETD?
+ je v86iret # Yes
+ popl %ebx # Restore
+ popa # Restore
+ jmp except # Handle exception
+v86mon.5: movl %edx,0x30(%ebp) # Save V86 flags
+v86mon.6: popl %edx # V86 SS adjustment
+ subl %edx,%ebx # Save V86
+ movl %ebx,0x34(%ebp) # SP
+v86mon.7: subl %edi,%esi # From linear
+ movl %esi,0x28(%ebp) # Save V86 IP
+ popa # Restore
+ leal 0x8(%esp,1),%esp # Discard int no, error
+ iret # To V86 mode
+#
+# Emulate MOV EAX,CR0.
+#
+v86mov: movl %cr0,%eax # CR0 to
+ movl %eax,0x1c(%ebp) # saved EAX
+ incl %esi # Adjust IP
+#
+# Return from emulating a 0x0f prefixed instruction
+#
+v86preret: incl %esi # Adjust IP
+ jmp v86mon.7 # Finish up
+#
+# Emulate WBINVD
+#
+v86wbinvd: wbinvd # Write back and invalidate
+ # cache
+ jmp v86preret # Finish up
+#
+# Emulate WRMSR
+#
+v86wrmsr: movl 0x18(%ebp),%ecx # Get user's %ecx (MSR to write)
+ movl 0x14(%ebp),%edx # Load the value
+ movl 0x1c(%ebp),%eax # to write
+ wrmsr # Write MSR
+ jmp v86preret # Finish up
+#
+# Emulate RDMSR
+#
+v86rdmsr: movl 0x18(%ebp),%ecx # MSR to read
+ rdmsr # Read the MSR
+ movl %eax,0x1c(%ebp) # Return the value of
+ movl %edx,0x14(%ebp) # the MSR to the user
+ jmp v86preret # Finish up
+#
+# Emulate CLI.
+#
+v86cli: andb $~0x2,0x31(%ebp) # Clear IF
+ jmp v86mon.7 # Finish up
+#
+# Emulate STI.
+#
+v86sti: orb $0x2,0x31(%ebp) # Set IF
+ jmp v86mon.7 # Finish up
+#
+# Emulate PUSHF/PUSHFD.
+#
+v86pushf: subl %ecx,%ebx # Adjust SP
+ cmpb $0x4,%cl # 32-bit
+ je v86pushf.1 # Yes
+ data16 # 16-bit
+v86pushf.1: movl %edx,(%ebx) # Save flags
+ jmp v86mon.6 # Finish up
+#
+# Emulate IRET/IRETD.
+#
+v86iret: movzwl (%ebx),%esi # Load V86 IP
+ movzwl 0x2(%ebx),%edi # Load V86 CS
+ leal 0x4(%ebx),%ebx # Adjust SP
+ movl %edi,0x2c(%ebp) # Save V86 CS
+ xorl %edi,%edi # No ESI adjustment
+#
+# Emulate POPF/POPFD (and remainder of IRET/IRETD).
+#
+v86popf: cmpb $0x4,%cl # 32-bit?
+ je v86popf.1 # Yes
+ movl %edx,%eax # Initialize
+ data16 # 16-bit
+v86popf.1: movl (%ebx),%eax # Load flags
+ addl %ecx,%ebx # Adjust SP
+ andl $V86_FLG,%eax # Merge
+ andl $~V86_FLG,%edx # the
+ orl %eax,%edx # flags
+ jmp v86mon.5 # Finish up
+#
+# trap int 15, function 87
+# reads %es:%si from saved registers on stack to find a GDT containing
+# source and destination locations
+# reads count of words from saved %cx
+# returns success by setting %ah to 0
+#
+int15_87: pushl %eax # Save
+ pushl %ebx # some information
+ pushl %esi # onto the stack.
+ pushl %edi
+ xorl %eax,%eax # clean EAX
+ xorl %ebx,%ebx # clean EBX
+ movl 0x4(%ebp),%esi # Get user's ESI
+ movl 0x3C(%ebp),%ebx # store ES
+ movw %si,%ax # store SI
+ shll $0x4,%ebx # Make it a seg.
+ addl %eax,%ebx # ebx=(es<<4)+si
+ movb 0x14(%ebx),%al # Grab the
+ movb 0x17(%ebx),%ah # necessary
+ shll $0x10,%eax # information
+ movw 0x12(%ebx),%ax # from
+ movl %eax,%esi # the
+ movb 0x1c(%ebx),%al # GDT in order to
+ movb 0x1f(%ebx),%ah # have %esi offset
+ shll $0x10,%eax # of source and %edi
+ movw 0x1a(%ebx),%ax # of destination.
+ movl %eax,%edi
+ pushl %ds # Make:
+ popl %es # es = ds
+ pushl %ecx # stash ECX
+ xorl %ecx,%ecx # highw of ECX is clear
+ movw 0x18(%ebp),%cx # Get user's ECX
+ shll $0x1,%ecx # Convert from num words to num
+ # bytes
+ rep # repeat...
+ movsb # perform copy.
+ popl %ecx # Restore
+ popl %edi
+ popl %esi # previous
+ popl %ebx # register
+ popl %eax # values.
+ movb $0x0,0x1d(%ebp) # set ah = 0 to indicate
+ # success
+ andb $0xfe,%dl # clear CF
+ jmp v86mon.5 # Finish up
+
+#
+# Reboot the machine by setting the reboot flag and exiting
+#
+reboot: orb $0x1,btx_hdr+0x7 # Set the reboot flag
+ jmp exit # Terminate BTX and reboot
+
+#
+# Emulate INT imm8... also make sure to check if it's int 15/87
+#
+v86intn: lodsb # Get int no
+ cmpb $0x19,%al # is it int 19?
+ je reboot # yes, reboot the machine
+ cmpb $0x15,%al # is it int 15?
+ jne v86intn.3 # no, skip parse
+ pushl %eax # stash EAX
+ movl 0x1c(%ebp),%eax # user's saved EAX
+ cmpb $0x87,%ah # is it the memcpy subfunction?
+ jne v86intn.1 # no, keep checking
+ popl %eax # get the stack straight
+ jmp int15_87 # it's our cue
+v86intn.1: cmpw $0x4f53,%ax # is it the delete key callout?
+ jne v86intn.2 # no, handle the int normally
+ movb BDA_KEYFLAGS,%al # get the shift key state
+ andb $0xc,%al # mask off just Ctrl and Alt
+ cmpb $0xc,%al # are both Ctrl and Alt down?
+ jne v86intn.2 # no, handle the int normally
+ popl %eax # restore EAX
+ jmp reboot # reboot the machine
+v86intn.2: popl %eax # restore EAX
+v86intn.3: subl %edi,%esi # From
+ shrl $0x4,%edi # linear
+ movw %dx,-0x2(%ebx) # Save flags
+ movw %di,-0x4(%ebx) # Save CS
+ leal -0x6(%ebx),%ebx # Adjust SP
+ movw %si,(%ebx) # Save IP
+ shll $0x2,%eax # Scale
+ movzwl (%eax),%esi # Load IP
+ movzwl 0x2(%eax),%edi # Load CS
+ movl %edi,0x2c(%ebp) # Save CS
+ xorl %edi,%edi # No ESI adjustment
+ andb $~0x1,%dh # Clear TF
+ jmp v86mon.5 # Finish up
+#
+# Hardware interrupt jump table.
+#
+intx20: push $0x8 # Int 0x20: IRQ0
+ jmp int_hw # V86 int 0x8
+ push $0x9 # Int 0x21: IRQ1
+ jmp int_hw # V86 int 0x9
+ push $0xa # Int 0x22: IRQ2
+ jmp int_hw # V86 int 0xa
+ push $0xb # Int 0x23: IRQ3
+ jmp int_hw # V86 int 0xb
+ push $0xc # Int 0x24: IRQ4
+ jmp int_hw # V86 int 0xc
+ push $0xd # Int 0x25: IRQ5
+ jmp int_hw # V86 int 0xd
+ push $0xe # Int 0x26: IRQ6
+ jmp int_hw # V86 int 0xe
+ push $0xf # Int 0x27: IRQ7
+ jmp int_hw # V86 int 0xf
+ push $0x70 # Int 0x28: IRQ8
+ jmp int_hw # V86 int 0x70
+ push $0x71 # Int 0x29: IRQ9
+ jmp int_hw # V86 int 0x71
+ push $0x72 # Int 0x2a: IRQ10
+ jmp int_hw # V86 int 0x72
+ push $0x73 # Int 0x2b: IRQ11
+ jmp int_hw # V86 int 0x73
+ push $0x74 # Int 0x2c: IRQ12
+ jmp int_hw # V86 int 0x74
+ push $0x75 # Int 0x2d: IRQ13
+ jmp int_hw # V86 int 0x75
+ push $0x76 # Int 0x2e: IRQ14
+ jmp int_hw # V86 int 0x76
+ push $0x77 # Int 0x2f: IRQ15
+ jmp int_hw # V86 int 0x77
+#
+# Reflect hardware interrupts.
+#
+int_hw: testb $0x2,0xe(%esp,1) # V86 mode?
+ jz intusr # No
+ pushl $SEL_SDATA # Address
+ popl %ds # data
+ xchgl %eax,(%esp,1) # Swap EAX, int no
+ pushl %ebp # Address
+ movl %esp,%ebp # stack frame
+ pushl %ebx # Save
+ shll $0x2,%eax # Get int
+ movl (%eax),%eax # vector
+ subl $0x6,0x14(%ebp) # Adjust V86 ESP
+ movzwl 0x18(%ebp),%ebx # V86 SS
+ shll $0x4,%ebx # * 0x10
+ addl 0x14(%ebp),%ebx # + V86 ESP
+ xchgw %ax,0x8(%ebp) # Swap V86 IP
+ rorl $0x10,%eax # Swap words
+ xchgw %ax,0xc(%ebp) # Swap V86 CS
+ roll $0x10,%eax # Swap words
+ movl %eax,(%ebx) # CS:IP for IRET
+ movl 0x10(%ebp),%eax # V86 flags
+ movw %ax,0x4(%ebx) # Flags for IRET
+ andb $~0x3,0x11(%ebp) # Clear IF, TF
+ popl %ebx # Restore
+ popl %ebp # saved
+ popl %eax # registers
+ iret # To V86 mode
+#
+# Invoke V86 interrupt from user mode, with arguments.
+#
+intx31: stc # Have btx_v86
+ pushl %eax # Missing int no
+#
+# Invoke V86 interrupt from user mode.
+#
+intusr: std # String ops dec
+ pushl %eax # Expand
+ pushl %eax # stack
+ pushl %eax # frame
+ pusha # Save
+ pushl %gs # Save
+ movl %esp,%eax # seg regs
+ pushl %fs # and
+ pushl %ds # point
+ pushl %es # to them
+ push $SEL_SDATA # Set up
+ popl %ds # to
+ pushl %ds # address
+ popl %es # data
+ movl $MEM_USR,%ebx # User base
+ movl %ebx,%edx # address
+ jc intusr.1 # If btx_v86
+ xorl %edx,%edx # Control flags
+ xorl %ebp,%ebp # btx_v86 pointer
+intusr.1: leal 0x50(%esp,1),%esi # Base of frame
+ pushl %esi # Save
+ addl -0x4(%esi),%ebx # User ESP
+ movl MEM_TSS+TSS_ESP1,%edi # Link stack pointer
+ leal -0x4(%edi),%edi # Adjust for push
+ xorl %ecx,%ecx # Zero
+ movb $0x5,%cl # Push exception
+ rep # frame on
+ movsl # link stack
+ xchgl %eax,%esi # Saved seg regs
+ movl 0x40(%esp,1),%eax # Get int no
+ testl %edx,%edx # Have btx_v86?
+ jz intusr.2 # No
+ movl (%ebx),%ebp # btx_v86 pointer
+ movb $0x4,%cl # Count
+ addl %ecx,%ebx # Adjust for pop
+ rep # Push saved seg regs
+ movsl # on link stack
+ addl %ebp,%edx # Flatten btx_v86 ptr
+ leal 0x14(%edx),%esi # Seg regs pointer
+ movl 0x4(%edx),%eax # Get int no/address
+ movzwl 0x2(%edx),%edx # Get control flags
+intusr.2: movl %ebp,(%edi) # Push btx_v86 and
+ movl %edi,MEM_TSS+TSS_ESP1 # save link stack ptr
+ popl %edi # Base of frame
+ xchgl %eax,%ebp # Save intno/address
+ movl 0x48(%esp,1),%eax # Get flags
+ testb $0x2,%dl # Simulate CALLF?
+ jnz intusr.3 # Yes
+ decl %ebx # Push flags
+ decl %ebx # on V86
+ movw %ax,(%ebx) # stack
+intusr.3: movb $0x4,%cl # Count
+ subl %ecx,%ebx # Push return address
+ movl $inthlt,(%ebx) # on V86 stack
+ rep # Copy seg regs to
+ movsl # exception frame
+ xchgl %eax,%ecx # Save flags
+ movl %ebx,%eax # User ESP
+ subl $V86_STK,%eax # Less bytes
+ ja intusr.4 # to
+ xorl %eax,%eax # keep
+intusr.4: shrl $0x4,%eax # Gives segment
+ stosl # Set SS
+ shll $0x4,%eax # To bytes
+ xchgl %eax,%ebx # Swap
+ subl %ebx,%eax # Gives offset
+ stosl # Set ESP
+ xchgl %eax,%ecx # Get flags
+ btsl $0x11,%eax # Set VM
+ andb $~0x1,%ah # Clear TF
+ stosl # Set EFL
+ xchgl %eax,%ebp # Get int no/address
+ testb $0x1,%dl # Address?
+ jnz intusr.5 # Yes
+ shll $0x2,%eax # Scale
+ movl (%eax),%eax # Load int vector
+intusr.5: movl %eax,%ecx # Save
+ shrl $0x10,%eax # Gives segment
+ stosl # Set CS
+ movw %cx,%ax # Restore
+ stosl # Set EIP
+ leal 0x10(%esp,1),%esp # Discard seg regs
+ popa # Restore
+ iret # To V86 mode
+#
+# System Call.
+#
+intx30: cmpl $SYS_EXEC,%eax # Exec system call?
+ jne intx30.1 # No
+ pushl %ss # Set up
+ popl %es # all
+ pushl %es # segment
+ popl %ds # registers
+ pushl %ds # for the
+ popl %fs # program
+ pushl %fs # we're
+ popl %gs # invoking
+ movl $MEM_USR,%eax # User base address
+ addl 0xc(%esp,1),%eax # Change to user
+ leal 0x4(%eax),%esp # stack
+ifdef(`PAGING',`
+ movl %cr0,%eax # Turn
+ andl $~0x80000000,%eax # off
+ movl %eax,%cr0 # paging
+ xorl %eax,%eax # Flush
+ movl %eax,%cr3 # TLB
+')
+ popl %eax # Call
+ call *%eax # program
+intx30.1: incb %ss:btx_hdr+0x7 # Flag reboot
+ jmp exit # Exit
+#
+# Dump structure [EBX] to [EDI], using format string [ESI].
+#
+dump.0: stosb # Save char
+dump: lodsb # Load char
+ testb %al,%al # End of string?
+ jz dump.10 # Yes
+ testb $0x80,%al # Control?
+ jz dump.0 # No
+ movb %al,%ch # Save control
+ movb $'=',%al # Append
+ stosb # '='
+ lodsb # Get offset
+ pushl %esi # Save
+ movsbl %al,%esi # To
+ addl %ebx,%esi # pointer
+ testb $DMP_X16,%ch # Dump word?
+ jz dump.1 # No
+ lodsw # Get and
+ call hex16 # dump it
+dump.1: testb $DMP_X32,%ch # Dump long?
+ jz dump.2 # No
+ lodsl # Get and
+ call hex32 # dump it
+dump.2: testb $DMP_MEM,%ch # Dump memory?
+ jz dump.8 # No
+ pushl %ds # Save
+ testb $0x2,0x52(%ebx) # V86 mode?
+ jnz dump.3 # Yes
+ verr 0x4(%esi) # Readable selector?
+ jnz dump.3 # No
+ ldsl (%esi),%esi # Load pointer
+ jmp dump.4 # Join common code
+dump.3: lodsl # Set offset
+ xchgl %eax,%edx # Save
+ lodsl # Get segment
+ shll $0x4,%eax # * 0x10
+ addl %edx,%eax # + offset
+ xchgl %eax,%esi # Set pointer
+dump.4: movb $0x10,%cl # Bytes to dump
+dump.5: lodsb # Get byte and
+ call hex8 # dump it
+ decb %cl # Keep count
+ jz dump.7 # If done
+ movb $'-',%al # Separator
+ cmpb $0x8,%cl # Half way?
+ je dump.6 # Yes
+ movb $' ',%al # Use space
+dump.6: stosb # Save separator
+ jmp dump.5 # Continue
+dump.7: popl %ds # Restore
+dump.8: popl %esi # Restore
+ movb $0xa,%al # Line feed
+ testb $DMP_EOL,%ch # End of line?
+ jnz dump.9 # Yes
+ movb $' ',%al # Use spaces
+ stosb # Save one
+dump.9: jmp dump.0 # Continue
+dump.10: stosb # Terminate string
+ ret # To caller
+#
+# Convert EAX, AX, or AL to hex, saving the result to [EDI].
+#
+hex32: pushl %eax # Save
+ shrl $0x10,%eax # Do upper
+ call hex16 # 16
+ popl %eax # Restore
+hex16: call hex16.1 # Do upper 8
+hex16.1: xchgb %ah,%al # Save/restore
+hex8: pushl %eax # Save
+ shrb $0x4,%al # Do upper
+ call hex8.1 # 4
+ popl %eax # Restore
+hex8.1: andb $0xf,%al # Get lower 4
+ cmpb $0xa,%al # Convert
+ sbbb $0x69,%al # to hex
+ das # digit
+ orb $0x20,%al # To lower case
+ stosb # Save char
+ ret # (Recursive)
+#
+# Output zero-terminated string [ESI] to the console.
+#
+putstr.0: call putchr # Output char
+putstr: lodsb # Load char
+ testb %al,%al # End of string?
+ jnz putstr.0 # No
+ ret # To caller
+#
+# Output character AL to the console.
+#
+putchr: pusha # Save
+ xorl %ecx,%ecx # Zero for loops
+ movb $SCR_MAT,%ah # Mode/attribute
+ movl $BDA_POS,%ebx # BDA pointer
+ movw (%ebx),%dx # Cursor position
+ movl $0xb8000,%edi # Regen buffer (color)
+ cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
+ jne putchr.1 # No
+ xorw %di,%di # Regen buffer (mono)
+putchr.1: cmpb $0xa,%al # New line?
+ je putchr.2 # Yes
+ xchgl %eax,%ecx # Save char
+ movb $SCR_COL,%al # Columns per row
+ mulb %dh # * row position
+ addb %dl,%al # + column
+ adcb $0x0,%ah # position
+ shll %eax # * 2
+ xchgl %eax,%ecx # Swap char, offset
+ movw %ax,(%edi,%ecx,1) # Write attr:char
+ incl %edx # Bump cursor
+ cmpb $SCR_COL,%dl # Beyond row?
+ jb putchr.3 # No
+putchr.2: xorb %dl,%dl # Zero column
+ incb %dh # Bump row
+putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
+ jb putchr.4 # No
+ leal 2*SCR_COL(%edi),%esi # New top line
+ movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
+ rep # Scroll
+ movsl # screen
+ movb $' ',%al # Space
+ movb $SCR_COL,%cl # Columns to clear
+ rep # Clear
+ stosw # line
+ movb $SCR_ROW-1,%dh # Bottom line
+putchr.4: movw %dx,(%ebx) # Update position
+ popa # Restore
+ ret # To caller
+
+ .p2align 4
+#
+# Global descriptor table.
+#
+gdt: .word 0x0,0x0,0x0,0x0 # Null entry
+ .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
+ .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
+ .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
+ .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
+ .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE
+ .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA
+ .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS
+gdt.1:
+#
+# Pseudo-descriptors.
+#
+gdtdesc: .word gdt.1-gdt-1,gdt,0x0 # GDT
+idtdesc: .word _IDTLM,MEM_IDT,0x0 # IDT
+ivtdesc: .word 0x400-0x0-1,0x0,0x0 # IVT
+#
+# IDT construction control string.
+#
+idtctl: .byte 0x10, 0x8e # Int 0x0-0xf
+ .word 0x7dfb,intx00 # (exceptions)
+ .byte 0x10, 0x8e # Int 0x10
+ .word 0x1, intx10 # (exception)
+ .byte 0x10, 0x8e # Int 0x20-0x2f
+ .word 0xffff,intx20 # (hardware)
+ .byte 0x1, 0xee # int 0x30
+ .word 0x1, intx30 # (system call)
+ .byte 0x2, 0xee # Int 0x31-0x32
+ .word 0x1, intx31 # (V86, null)
+ .byte 0x0 # End of string
+#
+# Dump format string.
+#
+dmpfmt: .byte '\n' # "\n"
+ .ascii "int" # "int="
+ .byte 0x80|DMP_X32, 0x40 # "00000000 "
+ .ascii "err" # "err="
+ .byte 0x80|DMP_X32, 0x44 # "00000000 "
+ .ascii "efl" # "efl="
+ .byte 0x80|DMP_X32, 0x50 # "00000000 "
+ .ascii "eip" # "eip="
+ .byte 0x80|DMP_X32|DMP_EOL,0x48 # "00000000\n"
+ .ascii "eax" # "eax="
+ .byte 0x80|DMP_X32, 0x34 # "00000000 "
+ .ascii "ebx" # "ebx="
+ .byte 0x80|DMP_X32, 0x28 # "00000000 "
+ .ascii "ecx" # "ecx="
+ .byte 0x80|DMP_X32, 0x30 # "00000000 "
+ .ascii "edx" # "edx="
+ .byte 0x80|DMP_X32|DMP_EOL,0x2c # "00000000\n"
+ .ascii "esi" # "esi="
+ .byte 0x80|DMP_X32, 0x1c # "00000000 "
+ .ascii "edi" # "edi="
+ .byte 0x80|DMP_X32, 0x18 # "00000000 "
+ .ascii "ebp" # "ebp="
+ .byte 0x80|DMP_X32, 0x20 # "00000000 "
+ .ascii "esp" # "esp="
+ .byte 0x80|DMP_X32|DMP_EOL,0x0 # "00000000\n"
+ .ascii "cs" # "cs="
+ .byte 0x80|DMP_X16, 0x4c # "0000 "
+ .ascii "ds" # "ds="
+ .byte 0x80|DMP_X16, 0xc # "0000 "
+ .ascii "es" # "es="
+ .byte 0x80|DMP_X16, 0x8 # "0000 "
+ .ascii " " # " "
+ .ascii "fs" # "fs="
+ .byte 0x80|DMP_X16, 0x10 # "0000 "
+ .ascii "gs" # "gs="
+ .byte 0x80|DMP_X16, 0x14 # "0000 "
+ .ascii "ss" # "ss="
+ .byte 0x80|DMP_X16|DMP_EOL,0x4 # "0000\n"
+ .ascii "cs:eip" # "cs:eip="
+ .byte 0x80|DMP_MEM|DMP_EOL,0x48 # "00 00 ... 00 00\n"
+ .ascii "ss:esp" # "ss:esp="
+ .byte 0x80|DMP_MEM|DMP_EOL,0x0 # "00 00 ... 00 00\n"
+ .asciz "BTX halted" # End
+#
+# End of BTX memory.
+#
+ .p2align 4
+break:
diff --git a/lockwasher/src/sys/boot/btx/btxldr/Makefile b/lockwasher/src/sys/boot/btx/btxldr/Makefile
new file mode 100644
index 0000000..d421cd5
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/btxldr/Makefile
@@ -0,0 +1,28 @@
+# $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.7.2.1 2000/04/15 03:09:41 ps Exp $
+
+M4?= m4
+M4FLAGS+= -DLOADER_ADDRESS=${LOADER_ADDRESS}
+
+.if defined(BTXLDR_VERBOSE)
+M4FLAGS+= -DBTXLDR_VERBOSE
+.endif
+
+all: btxldr
+
+btxldr: btxldr.o
+.if ${OBJFORMAT} == aout
+ ${LD} -nostdlib -N -s -T ${LOADER_ADDRESS} -o btxldr.out btxldr.o
+ dd if=btxldr.out of=${.TARGET} ibs=32 skip=1
+.else
+ ${LD} -N -e start -Ttext ${LOADER_ADDRESS} -o btxldr.out btxldr.o
+ objcopy -S -O binary btxldr.out ${.TARGET}
+.endif
+
+btxldr.o: btxldr.s
+ (cd ${.CURDIR}; ${M4} ${M4FLAGS} btxldr.s ) | \
+ ${AS} ${AFLAGS} -o ${.TARGET}
+
+CLEANFILES+= btxldr btxldr.out btxldr.o
+
+.include <${.CURDIR}/../../Makefile.inc>
+.include
diff --git a/lockwasher/src/sys/boot/btx/btxldr/btxldr.s b/lockwasher/src/sys/boot/btx/btxldr/btxldr.s
new file mode 100644
index 0000000..3604c5d
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/btxldr/btxldr.s
@@ -0,0 +1,396 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $FreeBSD: src/sys/boot/i386/btx/btxldr/btxldr.s,v 1.8.2.2 2000/07/06 23:04:29 obrien Exp $
+
+#
+# Prototype BTX loader program, written in a couple of hours. The
+# real thing should probably be more flexible, and in C.
+#
+
+#
+# Memory locations.
+#
+ .set MEM_STUB,0x600 # Real mode stub
+ .set MEM_ESP,0x1000 # New stack pointer
+ .set MEM_TBL,0x5000 # BTX page tables
+ .set MEM_ENTRY,0x9010 # BTX entry point
+ .set MEM_DATA,start+0x1000 # Data segment
+#
+# Segment selectors.
+#
+ .set SEL_SCODE,0x8 # 4GB code
+ .set SEL_SDATA,0x10 # 4GB data
+ .set SEL_RCODE,0x18 # 64K code
+ .set SEL_RDATA,0x20 # 64K data
+#
+# Paging constants.
+#
+ .set PAG_SIZ,0x1000 # Page size
+ .set PAG_ENT,0x4 # Page entry size
+#
+# Screen constants.
+#
+ .set SCR_MAT,0x7 # Mode/attribute
+ .set SCR_COL,0x50 # Columns per row
+ .set SCR_ROW,0x19 # Rows per screen
+#
+# BIOS Data Area locations.
+#
+ .set BDA_MEM,0x413 # Free memory
+ .set BDA_SCR,0x449 # Video mode
+ .set BDA_POS,0x450 # Cursor position
+#
+# Required by aout gas inadequacy.
+#
+ .set SIZ_STUB,0x1a # Size of stub
+#
+# We expect to be loaded by boot2 at the origin defined in ./Makefile.
+#
+ .globl start
+#
+# BTX program loader for ELF clients.
+#
+start: cld # String ops inc
+ movl $m_logo,%esi # Identify
+ call putstr # ourselves
+ movzwl BDA_MEM,%eax # Get base memory
+ shll $0xa,%eax # in bytes
+ movl %eax,%ebp # Base of user stack
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_mem,%esi # Display
+ call hexout # amount of
+ call putstr # base memory
+')
+ lgdt gdtdesc # Load new GDT
+#
+# Relocate caller's arguments.
+#
+ifdef('BTXLDR_VERBOSE',`
+ movl $m_esp,%esi # Display
+ movl %esp,%eax # caller
+ call hexout # stack
+ call putstr # pointer
+ movl $m_args,%esi # Format string
+ leal 0x4(%esp,1),%ebx # First argument
+ movl $0x6,%ecx # Count
+start.1: movl (%ebx),%eax # Get argument and
+ addl $0x4,%ebx # bump pointer
+ call hexout # Display it
+ loop start.1 # Till done
+ call putstr # End message
+')
+ movl $0x48,%ecx # Allocate space
+ subl %ecx,%ebp # for bootinfo
+ movl 0x18(%esp,1),%esi # Source: bootinfo
+ cmpl $0x0, %esi # If the bootinfo pointer
+ je start_null_bi # is null, don't copy it
+ movl %ebp,%edi # Destination
+ rep # Copy
+ movsb # it
+ movl %ebp,0x18(%esp,1) # Update pointer
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_rel_bi,%esi # Display
+ movl %ebp,%eax # bootinfo
+ call hexout # relocation
+ call putstr # message
+')
+start_null_bi: movl $0x18,%ecx # Allocate space
+ subl %ecx,%ebp # for arguments
+ leal 0x4(%esp,1),%esi # Source
+ movl %ebp,%edi # Destination
+ rep # Copy
+ movsb # them
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_rel_args,%esi # Display
+ movl %ebp,%eax # argument
+ call hexout # relocation
+ call putstr # message
+')
+#
+# Set up BTX kernel.
+#
+ movl $MEM_ESP,%esp # Set up new stack
+ movl $MEM_DATA,%ebx # Data segment
+ movl $m_vers,%esi # Display BTX
+ call putstr # version message
+ movb 0x5(%ebx),%al # Get major version
+ addb $'0',%al # Display
+ call putchr # it
+ movb $'.',%al # And a
+ call putchr # dot
+ movb 0x6(%ebx),%al # Get minor
+ xorb %ah,%ah # version
+ movb $0xa,%dl # Divide
+ divb %dl,%al # by 10
+ addb $'0',%al # Display
+ call putchr # tens
+ movb %ah,%al # Get units
+ addb $'0',%al # Display
+ call putchr # units
+ call putstr # End message
+ movl %ebx,%esi # BTX image
+ movzwl 0x8(%ebx),%edi # Compute
+ orl $PAG_SIZ/PAG_ENT-1,%edi # the
+ incl %edi # BTX
+ shll $0x2,%edi # load
+ addl $MEM_TBL,%edi # address
+ pushl %edi # Save load address
+ movzwl 0xa(%ebx),%ecx # Image size
+ifdef(`BTXLDR_VERBOSE',`
+ pushl %ecx # Save image size
+')
+ rep # Relocate
+ movsb # BTX
+ movl %esi,%ebx # Keep place
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_rel_btx,%esi # Restore
+ popl %eax # parameters
+ call hexout # and
+')
+ popl %ebp # display
+ifdef(`BTXLDR_VERBOSE',`
+ movl %ebp,%eax # the
+ call hexout # relocation
+ call putstr # message
+')
+ addl $PAG_SIZ,%ebp # Display
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_base,%esi # the
+ movl %ebp,%eax # user
+ call hexout # base
+ call putstr # address
+')
+#
+# Set up ELF-format client program.
+#
+ cmpl $0x464c457f,(%ebx) # ELF magic number?
+ je start.3 # Yes
+ movl $e_fmt,%esi # Display error
+ call putstr # message
+start.2: jmp start.2 # Hang
+start.3:
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_elf,%esi # Display ELF
+ call putstr # message
+ movl $m_segs,%esi # Format string
+')
+ movl $0x2,%edi # Segment count
+ movl 0x1c(%ebx),%edx # Get e_phoff
+ addl %ebx,%edx # To pointer
+ movzwl 0x2c(%ebx),%ecx # Get e_phnum
+start.4: cmpl $0x1,(%edx) # Is p_type PT_LOAD?
+ jne start.6 # No
+ifdef(`BTXLDR_VERBOSE',`
+ movl 0x4(%edx),%eax # Display
+ call hexout # p_offset
+ movl 0x8(%edx),%eax # Display
+ call hexout # p_vaddr
+ movl 0x10(%edx),%eax # Display
+ call hexout # p_filesz
+ movl 0x14(%edx),%eax # Display
+ call hexout # p_memsz
+ call putstr # End message
+')
+ pushl %esi # Save
+ pushl %edi # working
+ pushl %ecx # registers
+ movl 0x4(%edx),%esi # Get p_offset
+ addl %ebx,%esi # as pointer
+ movl 0x8(%edx),%edi # Get p_vaddr
+ addl %ebp,%edi # as pointer
+ movl 0x10(%edx),%ecx # Get p_filesz
+ rep # Set up
+ movsb # segment
+ movl 0x14(%edx),%ecx # Any bytes
+ subl 0x10(%edx),%ecx # to zero?
+ jz start.5 # No
+ xorb %al,%al # Then
+ rep # zero
+ stosb # them
+start.5: popl %ecx # Restore
+ popl %edi # working
+ popl %esi # registers
+ decl %edi # Segments to do
+ je start.7 # If none
+start.6: addl $0x20,%edx # To next entry
+ loop start.4 # Till done
+start.7:
+ifdef(`BTXLDR_VERBOSE',`
+ movl $m_done,%esi # Display done
+ call putstr # message
+')
+ movl $start.8,%esi # Real mode stub
+ movl $MEM_STUB,%edi # Destination
+ movl $start.9-start.8,%ecx # Size
+ rep # Relocate
+ movsb # it
+ ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code
+ .code16
+start.8: xorw %ax,%ax # Data
+ movb $SEL_RDATA,%al # selector
+ movw %ax,%ss # Reload SS
+ movw %ax,%ds # Reset
+ movw %ax,%es # other
+ movw %ax,%fs # segment
+ movw %ax,%gs # limits
+ movl %cr0,%eax # Switch to
+ decw %ax # real
+ movl %eax,%cr0 # mode
+ ljmp $0,$MEM_ENTRY # Jump to BTX entry point
+start.9:
+ .code32
+#
+# Output message [ESI] followed by EAX in hex.
+#
+hexout: pushl %eax # Save
+ call putstr # Display message
+ popl %eax # Restore
+ pushl %esi # Save
+ pushl %edi # caller's
+ movl $buf,%edi # Buffer
+ pushl %edi # Save
+ call hex32 # To hex
+ xorb %al,%al # Terminate
+ stosb # string
+ popl %esi # Restore
+hexout.1: lodsb # Get a char
+ cmpb $'0',%al # Leading zero?
+ je hexout.1 # Yes
+ testb %al,%al # End of string?
+ jne hexout.2 # No
+ decl %esi # Undo
+hexout.2: decl %esi # Adjust for inc
+ call putstr # Display hex
+ popl %edi # Restore
+ popl %esi # caller's
+ ret # To caller
+#
+# Output zero-terminated string [ESI] to the console.
+#
+putstr.0: call putchr # Output char
+putstr: lodsb # Load char
+ testb %al,%al # End of string?
+ jne putstr.0 # No
+ ret # To caller
+#
+# Output character AL to the console.
+#
+putchr: pusha # Save
+ xorl %ecx,%ecx # Zero for loops
+ movb $SCR_MAT,%ah # Mode/attribute
+ movl $BDA_POS,%ebx # BDA pointer
+ movw (%ebx),%dx # Cursor position
+ movl $0xb8000,%edi # Regen buffer (color)
+ cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
+ jne putchr.1 # No
+ xorw %di,%di # Regen buffer (mono)
+putchr.1: cmpb $0xa,%al # New line?
+ je putchr.2 # Yes
+ xchgl %eax,%ecx # Save char
+ movb $SCR_COL,%al # Columns per row
+ mulb %dh # * row position
+ addb %dl,%al # + column
+ adcb $0x0,%ah # position
+ shll %eax # * 2
+ xchgl %eax,%ecx # Swap char, offset
+ movw %ax,(%edi,%ecx,1) # Write attr:char
+ incl %edx # Bump cursor
+ cmpb $SCR_COL,%dl # Beyond row?
+ jb putchr.3 # No
+putchr.2: xorb %dl,%dl # Zero column
+ incb %dh # Bump row
+putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
+ jb putchr.4 # No
+ leal 2*SCR_COL(%edi),%esi # New top line
+ movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
+ rep # Scroll
+ movsl # screen
+ movb $' ',%al # Space
+ movb $SCR_COL,%cl # Columns to clear
+ rep # Clear
+ stosw # line
+ movb $SCR_ROW-1,%dh # Bottom line
+putchr.4: movw %dx,(%ebx) # Update position
+ popa # Restore
+ ret # To caller
+#
+# Convert EAX, AX, or AL to hex, saving the result to [EDI].
+#
+hex32: pushl %eax # Save
+ shrl $0x10,%eax # Do upper
+ call hex16 # 16
+ popl %eax # Restore
+hex16: call hex16.1 # Do upper 8
+hex16.1: xchgb %ah,%al # Save/restore
+hex8: pushl %eax # Save
+ shrb $0x4,%al # Do upper
+ call hex8.1 # 4
+ popl %eax # Restore
+hex8.1: andb $0xf,%al # Get lower 4
+ cmpb $0xa,%al # Convert
+ sbbb $0x69,%al # to hex
+ das # digit
+ orb $0x20,%al # To lower case
+ stosb # Save char
+ ret # (Recursive)
+
+ .data
+ .p2align 4
+#
+# Global descriptor table.
+#
+gdt: .word 0x0,0x0,0x0,0x0 # Null entry
+ .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
+ .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
+ .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
+ .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
+gdt.1:
+gdtdesc: .word gdt.1-gdt-1 # Limit
+ .long gdt # Base
+#
+# Messages.
+#
+m_logo: .asciz " \nBTX loader 1.00 "
+m_vers: .asciz "BTX version is \0\n"
+e_fmt: .asciz "Error: Client format not supported\n"
+ifdef(`BTXLDR_VERBOSE',`
+m_mem: .asciz "Starting in protected mode (base mem=\0)\n"
+m_esp: .asciz "Arguments passed (esp=\0):\n"
+m_args: .asciz"\n"
+m_rel_bi: .asciz "Relocated bootinfo (size=48) to \0\n"
+m_rel_args: .asciz "Relocated arguments (size=18) to \0\n"
+m_rel_btx: .asciz "Relocated kernel (size=\0) to \0\n"
+m_base: .asciz "Client base address is \0\n"
+m_elf: .asciz "Client format is ELF\n"
+m_segs: .asciz "text segment: offset="
+ .asciz " vaddr="
+ .asciz " filesz="
+ .asciz " memsz=\0\n"
+ .asciz "data segment: offset="
+ .asciz " vaddr="
+ .asciz " filesz="
+ .asciz " memsz=\0\n"
+m_done: .asciz "Loading complete\n"
+')
+#
+# Uninitialized data area.
+#
+buf: # Scratch buffer
diff --git a/lockwasher/src/sys/boot/btx/lib/Makefile b/lockwasher/src/sys/boot/btx/lib/Makefile
new file mode 100644
index 0000000..c993e57
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/lib/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.3.2.1 2002/07/19 18:46:28 ru Exp $
+
+OBJS= btxcsu.o btxsys.o btxv86.o
+AFLAGS+= -elf
+LDFLAGS+= -elf
+CLEANFILES+= crt0.o ${OBJS}
+
+all: crt0.o
+
+crt0.o: ${OBJS}
+ ${LD} ${LDFLAGS} -i -o ${.TARGET} ${OBJS}
+
+.include
+
+.s.o:
+ ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
diff --git a/lockwasher/src/sys/boot/btx/lib/btxcsu.s b/lockwasher/src/sys/boot/btx/lib/btxcsu.s
new file mode 100644
index 0000000..119fda6
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/lib/btxcsu.s
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $
+
+#
+# BTX C startup code (ELF).
+#
+
+#
+# Globals.
+#
+ .global _start
+#
+# Constants.
+#
+ .set ARGADJ,0xfa0 # Argument adjustment
+#
+# Client entry point.
+#
+_start: movl %eax,__base # Set base address
+ movl %esp,%eax # Set
+ addl $ARGADJ,%eax # argument
+ movl %eax,__args # pointer
+ call main # Invoke client main()
+ call exit # Invoke client exit()
+#
+# Data.
+#
+ .comm __base,4 # Client base address
+ .comm __args,4 # Client arguments
diff --git a/lockwasher/src/sys/boot/btx/lib/btxsys.s b/lockwasher/src/sys/boot/btx/lib/btxsys.s
new file mode 100644
index 0000000..6bca740
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/lib/btxsys.s
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $
+
+#
+# BTX system calls.
+#
+
+#
+# Globals.
+#
+ .global __exit
+ .global __exec
+#
+# Constants.
+#
+ .set INT_SYS,0x30 # Interrupt number
+#
+# System call: exit
+#
+__exit: xorl %eax,%eax # BTX system
+ int $INT_SYS # call 0x0
+#
+# System call: exec
+#
+__exec: movl $0x1,%eax # BTX system
+ int $INT_SYS # call 0x1
diff --git a/lockwasher/src/sys/boot/btx/lib/btxv86.h b/lockwasher/src/sys/boot/btx/lib/btxv86.h
new file mode 100644
index 0000000..1ef0712
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/lib/btxv86.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1998 Robert Nordier
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are freely
+ * permitted provided that the above copyright notice and this
+ * paragraph and the following disclaimer are duplicated in all
+ * such forms.
+ *
+ * This software is provided "AS IS" and without any express or
+ * implied warranties, including, without limitation, the implied
+ * warranties of merchantability and fitness for a particular
+ * purpose.
+ */
+
+/*
+ * $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.h,v 1.5 1999/08/28 00:40:08 peter Exp $
+ */
+
+#ifndef _BTXV86_H_
+#define _BTXV86_H_
+
+#include
+
+#define V86_ADDR 0x10000 /* Segment:offset address */
+#define V86_CALLF 0x20000 /* Emulate far call */
+#define V86_FLAGS 0x40000 /* Return flags */
+
+struct __v86 {
+ uint32_t ctl; /* Control flags */
+ uint32_t addr; /* Interrupt number or address */
+ uint32_t es; /* V86 ES register */
+ uint32_t ds; /* V86 DS register */
+ uint32_t fs; /* V86 FS register */
+ uint32_t gs; /* V86 GS register */
+ uint32_t eax; /* V86 EAX register */
+ uint32_t ecx; /* V86 ECX register */
+ uint32_t edx; /* V86 EDX register */
+ uint32_t ebx; /* V86 EBX register */
+ uint32_t efl; /* V86 eflags register */
+ uint32_t ebp; /* V86 EBP register */
+ uint32_t esi; /* V86 ESI register */
+ uint32_t edi; /* V86 EDI register */
+};
+
+extern struct __v86 __v86; /* V86 interface structure */
+void __v86int(void);
+
+#define v86 __v86
+#define v86int __v86int
+
+extern u_int32_t __base;
+extern u_int32_t __args;
+
+#define PTOV(pa) ((caddr_t)(pa) - __base)
+#define VTOP(va) ((vm_offset_t)(va) + __base)
+#define VTOPSEG(va) (u_int16_t)(VTOP((caddr_t)va) >> 4)
+#define VTOPOFF(va) (u_int16_t)(VTOP((caddr_t)va) & 0xf)
+
+void __exit(int) __attribute__((__noreturn__));
+void __exec(caddr_t, ...);
+
+#endif /* !_BTXV86_H_ */
diff --git a/lockwasher/src/sys/boot/btx/lib/btxv86.s b/lockwasher/src/sys/boot/btx/lib/btxv86.s
new file mode 100644
index 0000000..6d6af19
--- /dev/null
+++ b/lockwasher/src/sys/boot/btx/lib/btxv86.s
@@ -0,0 +1,85 @@
+#
+# Copyright (c) 1998 Robert Nordier
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms are freely
+# permitted provided that the above copyright notice and this
+# paragraph and the following disclaimer are duplicated in all
+# such forms.
+#
+# This software is provided "AS IS" and without any express or
+# implied warranties, including, without limitation, the implied
+# warranties of merchantability and fitness for a particular
+# purpose.
+#
+
+# $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $
+
+#
+# BTX V86 interface.
+#
+
+#
+# Globals.
+#
+ .global __v86int
+#
+# Fields in V86 interface structure.
+#
+ .set V86_CTL,0x0 # Control flags
+ .set V86_ADDR,0x4 # Int number/address
+ .set V86_ES,0x8 # V86 ES
+ .set V86_DS,0xc # V86 DS
+ .set V86_FS,0x10 # V86 FS
+ .set V86_GS,0x14 # V86 GS
+ .set V86_EAX,0x18 # V86 EAX
+ .set V86_ECX,0x1c # V86 ECX
+ .set V86_EDX,0x20 # V86 EDX
+ .set V86_EBX,0x24 # V86 EBX
+ .set V86_EFL,0x28 # V86 eflags
+ .set V86_EBP,0x2c # V86 EBP
+ .set V86_ESI,0x30 # V86 ESI
+ .set V86_EDI,0x34 # V86 EDI
+#
+# Other constants.
+#
+ .set INT_V86,0x31 # Interrupt number
+ .set SIZ_V86,0x38 # Size of V86 structure
+#
+# V86 interface function.
+#
+__v86int: popl __v86ret # Save return address
+ pushl $__v86 # Push pointer
+ call __v86_swap # Load V86 registers
+ int $INT_V86 # To BTX
+ call __v86_swap # Load user registers
+ addl $0x4,%esp # Discard pointer
+ pushl __v86ret # Restore return address
+ ret # To user
+#
+# Swap V86 and user registers.
+#
+__v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP
+ xchgl %eax,V86_EAX(%ebp) # Swap EAX
+ xchgl %ecx,V86_ECX(%ebp) # Swap ECX
+ xchgl %edx,V86_EDX(%ebp) # Swap EDX
+ xchgl %ebx,V86_EBX(%ebp) # Swap EBX
+ pushl %eax # Save
+ pushf # Put eflags
+ popl %eax # in EAX
+ xchgl %eax,V86_EFL(%ebp) # Swap
+ pushl %eax # Put EAX
+ popf # in eflags
+ movl 0x8(%esp,1),%eax # Load EBP
+ xchgl %eax,V86_EBP(%ebp) # Swap
+ movl %eax,0x8(%esp,1) # Save EBP
+ popl %eax # Restore
+ xchgl %esi,V86_ESI(%ebp) # Swap ESI
+ xchgl %edi,V86_EDI(%ebp) # Swap EDI
+ xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP
+ ret # To caller
+#
+# V86 interface structure.
+#
+ .comm __v86,SIZ_V86
+ .comm __v86ret,4
diff --git a/lockwasher/src/sys/compile/Makefile b/lockwasher/src/sys/compile/Makefile
new file mode 100644
index 0000000..e0499c3
--- /dev/null
+++ b/lockwasher/src/sys/compile/Makefile
@@ -0,0 +1,45 @@
+# $Id: Makefile,v 1.10 2003/05/04 13:20:15 reddawg Exp $
+# Kernel Makefile (C) 2002 The UbixOS Project
+
+CFLAGS = -fno-builtin
+
+#Compiler
+GCC = gcc
+G++ = gcc
+
+#Linker
+LD = ld
+
+#Kernel File Name
+KERNEL = ubix.elf
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = null.o
+
+# Link the kernel statically with fixed text+data address @1M
+$(KERNEL) : $(OBJS)
+ $(LD) -nobuiltin -o $@ $(OBJS) ../init/*.o ../kernel/*.o ../isa/*.o ../pci/*.o ../sys/*.o ../vmm/*.o ../ubixfs/*.o ../devfs/*.o ../lib/*.o ../sde/*.o ../graphics/*.o ../ld/*.o -Ttext 0x30000
+ /usr/bin/strip $@
+
+# Compile the source files
+.cc.o:
+ $(G++) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $<
+
+.cc.s:
+ $(G++) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) ${CFLAGS} -Wall -O -I../include -c -o $@ $<
+
+.c.s:
+ $(GCC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(KERNEL) null.c
diff --git a/lockwasher/src/sys/devfs/Makefile b/lockwasher/src/sys/devfs/Makefile
new file mode 100644
index 0000000..777f242
--- /dev/null
+++ b/lockwasher/src/sys/devfs/Makefile
@@ -0,0 +1,36 @@
+# (C) 2002 The UbixOS Project
+# $Id: Makefile,v 1.1 2003/04/27 12:37:25 reddawg Exp $
+
+CFLAGS = -fno-builtin
+
+# Compiler
+CC = gcc
+CPP = g++
+
+
+# Linker
+LINKER = ld
+
+# Remove
+REMOVE = rm -fr
+
+# Objects
+OBJS = devfs.o
+
+all: $(OBJS)
+
+# Compile Types
+.cc.o:
+ $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $<
+.cc.s:
+ $(CPP) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $<
+.c.o:
+ $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -c -o $@ $<
+.c.s:
+ $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -O -I../include -S -o $@ $<
+.S.o:
+ $(CC) ${CFLAGS} -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS)
diff --git a/lockwasher/src/sys/devfs/devfs.c b/lockwasher/src/sys/devfs/devfs.c
new file mode 100644
index 0000000..bbc12cd
--- /dev/null
+++ b/lockwasher/src/sys/devfs/devfs.c
@@ -0,0 +1,185 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: devfs.c,v 1.3 2003/05/04 13:20:15 reddawg Exp $
+
+**************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+int sprintf(char *buf,const char *fmt, ...); //TEMP
+
+int enableDevFS() {
+ //Add DevFS i will
+ if (!addFs(1,initDevFS,readDevFS,writeDevFS,openFileDevFS,0x0,0x0,0x0,0x0)) {
+ sysErr(systemErr,"Unable To Enable DevFS");
+ return(0);
+ }
+ //Return
+ mount(0x0,0x0,0x1,"devfs","rw"); // Mount Device File System
+ return(1);
+ }
+
+void initDevFS(struct mountPoints *mp) {
+ struct devFsInfo *fsInfo = 0x0;
+ mp->fsInfo = (struct devFsInfo *)kmalloc(sizeof(struct devFsInfo),-2);
+
+ fsInfo = mp->fsInfo;
+ fsInfo->deviceList = 0x0;
+
+ kprintf("DevFS Initialized\n");
+ //Return
+ return;
+ }
+
+int openFileDevFS(char *file,fileDescriptor *fd) {
+ struct devFsInfo *fsInfo = fd->mp->fsInfo;
+ struct devFsDevices *tmpDev = 0x0;
+ kprintf("Opening DevFS File [0x%X]\n",fsInfo->deviceList);
+ for (tmpDev = fsInfo->deviceList;tmpDev != 0x0;tmpDev = tmpDev->next) {
+ kprintf("[%s][%s]\n",tmpDev->devName,file);
+ if (kstrcmp(tmpDev->devName,file) == 0x0) {
+ switch (fd->mode) {
+ case 0:
+ case 1:
+ kprintf("Opened Device: [%s]\n",tmpDev->devName);
+ (void *)fd->start = tmpDev;
+ break;
+ default:
+ kprintf("Invalid File Mode\n");
+ return(0x0);
+ break;
+ }
+ return(0x1);
+ }
+ }
+ return(0x0);
+ }
+
+/************************************************************************
+
+Function: int readDevFS(fileDescriptor *fd,char *data,long offset,long size)
+Description: Read File Into Data
+Notes:
+
+************************************************************************/
+int readDevFS(fileDescriptor *fd,char *data,long offset,long size) {
+ int i = 0x0,x = 0x0;
+ uInt32 sectors = 0x0;
+ uInt16 diff = 0x0;
+ struct driveDriver *drive = 0x0;
+ struct devFsDevices *tmpDev = (void *)fd->start;
+
+ kprintf("[0x%X]\n",tmpDev->devMajor);
+ drive = findDrive(tmpDev->devMajor);
+ kprintf("[0x%X][0x%X]\n",drive,drive->driveInfoStruct);
+
+
+ kprintf("Reading From Device: [%s]\n",fd->fileName);
+
+ sectors = ((size+511)/512);
+ diff = (offset - ((offset/512)*512));
+
+ for (i=0x0;iread(drive->driveInfoStruct,i + (offset/512),1,fd->buffer);
+ for (x=0x0;x<(size - (i*512));x++) {
+ if (diff > 0) {
+ data[x] = fd->buffer[x + diff];
+ }
+ else {
+ data[x] = fd->buffer[x];
+ }
+ }
+ diff = 0x0;
+ data += 512;
+ }
+
+ return(size);
+ }
+
+/************************************************************************
+
+Function: int writeDevFS(fileDescriptor *fd,char *data,long offset,long size)
+Description: Write Data Into File
+Notes:
+
+************************************************************************/
+int writeDevFS(fileDescriptor *fd,char *data,long offset,long size) {
+ int i = 0x0,x = 0x0;
+ struct driveDriver *drive = 0x0;
+ struct devFsDevices *tmpDev = (void *)fd->start;
+
+ kprintf("[0x%X]\n",tmpDev->devMajor);
+ drive = findDrive(tmpDev->devMajor);
+ kprintf("[0x%X][0x%X]\n",drive,drive->driveInfoStruct);
+
+ kprintf("Writing To Device: [%s]\n",fd->fileName);
+ for (i=0x0;i<((size+511)/512);i++) {
+ drive->read(drive->driveInfoStruct,i + (offset/512),1,fd->buffer);
+ for (x=0x0;((x < 512) && ((x + (i * 512)) < size));x++) {
+ fd->buffer[x] = data[x];
+ }
+ drive->write(drive->driveInfoStruct,i + (offset/512),1,fd->buffer);
+ data += 512;
+ }
+ return(size);
+ }
+
+
+int devFsMkNod(char *name,uInt8 type,uInt16 major,uInt16 minor) {
+ struct mountPoints *mp = 0x0;
+ struct devFsInfo *fsInfo = 0x0;
+ struct devFsDevices *tmpDev = 0x0;
+
+ mp = findMount("devfs");
+
+ if (mp == 0x0) {
+ kprintf("Error\n");
+ return(0x0);
+ }
+
+ fsInfo = mp->fsInfo;
+
+ tmpDev = (struct devFsDevices *)kmalloc(sizeof(struct devFsDevices),-2);
+
+ tmpDev->devType = type;
+ tmpDev->devMajor = major;
+ tmpDev->devMinor = minor;
+ sprintf(tmpDev->devName,name);
+ kprintf("tmpDev->devName: [%s]\n",tmpDev->devName);
+
+ tmpDev->next = fsInfo->deviceList;
+ tmpDev->prev = 0x0;
+ if (fsInfo->deviceList != 0x0) {
+ fsInfo->deviceList->prev = tmpDev;
+ }
+
+ fsInfo->deviceList = tmpDev;
+
+ return(0x1);
+ }
\ No newline at end of file
diff --git a/lockwasher/src/sys/graphics/Makefile b/lockwasher/src/sys/graphics/Makefile
new file mode 100644
index 0000000..459eba0
--- /dev/null
+++ b/lockwasher/src/sys/graphics/Makefile
@@ -0,0 +1,43 @@
+# $Id: Makefile,v 1.6 2003/04/03 01:26:33 reddawg Exp $
+# Kernel Makefile (C) 2002 The UbixOS Project
+
+
+#Compiler
+GCC = gcc
+G++ = g++
+
+#Linker
+LD = ld
+
+#Binary File Name
+BINARY = objgfx
+
+#Delete Program
+REMOVE = rm -f
+
+#Objects
+OBJS = objgfx30.o #objfont.o ogSprite.o ogBlit.o
+
+# Link the binary
+$(BINARY) : $(OBJS)
+# $(G++) -o $@ $(OBJS)
+
+# Compile the source files
+.cpp.o:
+ $(G++) -Wall -DNOBOOL -fno-rtti -fno-exceptions -g -c -I../include -o $@ $<
+
+.cc.s:
+ $(G++) -Wall -fomit-frame-pointer -O -I../include -S -o $@ $<
+
+.c.o:
+ $(GCC) -Wall -O -I../include -c -o $@ $<
+
+.c.s:
+ $(GCC) -Wall -fomit-frame-pointer -O -I../include -S -o $@ $<
+
+.S.o:
+ $(GCC) -Wall -fomit-frame-pointer -c -o $@ $<
+
+# Clean up the junk
+clean:
+ $(REMOVE) $(OBJS) $(BINARY) *.core
diff --git a/lockwasher/src/sys/graphics/objgfx30.cpp b/lockwasher/src/sys/graphics/objgfx30.cpp
new file mode 100644
index 0000000..fda1d83
--- /dev/null
+++ b/lockwasher/src/sys/graphics/objgfx30.cpp
@@ -0,0 +1,2858 @@
+/*******************************************************
+$Id: objgfx30.cpp,v 1.15 2003/04/16 06:07:22 flameshadow Exp $
+*******************************************************/
+
+extern "C" {
+ #include
+ #include
+ #include
+ #include
+ #include
+ }
+
+#include
+#include
+
+using namespace std;
+// #include "../ubixos-home/src/sys/include/ubixos/types.h"
+
+#define ROUND(f) (int)((f) + ((f) > 0 ? 0.5 : -0.5))
+
+struct ogHLine {
+ int32 xStart;
+ int32 xEnd;
+};
+
+struct ogHLineList {
+ int32 length;
+ int32 yStart;
+ int32 * xLeft;
+ int32 * xRight;
+};
+
+struct ogPointListHeader {
+ int32 length;
+ ogPoint * PointPtr;
+};
+
+struct ogEdgeState {
+ ogEdgeState* nextEdge;
+ int32 x;
+ int32 startY;
+ int32 wholePixelXMove;
+ int32 xDirection;
+ int32 errorTerm;
+ int32 errorTermAdjUp;
+ int32 errorTermAdjDown;
+ int32 count;
+};
+
+class ogEdgeTable {
+ public:
+ ogEdgeState * globalEdges;
+ ogEdgeState * activeEdges;
+ ogEdgeTable(void) { globalEdges = activeEdges = NULL; return; }
+ void advanceAET(void);
+ void buildGET(uInt32 numPoints, ogPoint * polyPoints);
+ void moveXSortedToAET(int32 yToMove);
+ void scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour);
+ void xSortAET(void);
+ ~ogEdgeTable(void);
+}; // ogEdgeState
+
+void
+ogEdgeTable::advanceAET(void) {
+ ogEdgeState * currentEdge;
+ ogEdgeState ** currentEdgePtr;
+
+ currentEdgePtr = &activeEdges;
+ currentEdge = activeEdges;
+ while (currentEdge!=NULL) {
+ currentEdge->count--;
+ if (currentEdge->count==0) {
+ // this edge is finished, so remove it from the AET
+ *currentEdgePtr = currentEdge->nextEdge;
+ } else {
+ // advance the edge's x coord by minimum move
+ currentEdge->x += currentEdge->wholePixelXMove;
+ // determine whether it's time for X to advance one extra
+ currentEdge->errorTerm += currentEdge->errorTermAdjUp;
+ if (currentEdge->errorTerm>0) {
+ currentEdge->x += currentEdge->xDirection;
+ currentEdge->errorTerm -= currentEdge->errorTermAdjDown;
+ } // if
+ currentEdgePtr = ¤tEdge->nextEdge;
+ } // else
+ currentEdge = *currentEdgePtr;
+ } // while
+ return;
+} // ogEdgeTable::advanceAET
+
+void
+ogEdgeTable::buildGET(uInt32 numPoints, ogPoint * polyPoints) {
+ int32 i, x1, y1, x2, y2, deltaX, deltaY, width, tmp;
+ ogEdgeState * newEdgePtr;
+ ogEdgeState * followingEdge;
+ ogEdgeState ** followingEdgeLink;
+
+ /* Creates a GET in the buffer pointed to by NextFreeEdgeStruc from
+ * the vertex list. Edge endpoints are flipped, if necessary, to
+ * guarantee all edges go top to bottom. The GET is sorted primarily
+ * by ascending Y start coordinate, and secondarily by ascending X
+ * start coordinate within edges with common Y coordinates }
+ */
+
+ // Scan through the vertex list and put all non-0-height edges into
+ // the GET, sorted by increasing Y start coordinate}
+ for (i = 0; i<(int32)numPoints; i++) {
+ // calculate the edge height and width
+ x1 = polyPoints[i].x;
+ y1 = polyPoints[i].y;
+ if (i==0) {
+ // wrap back around to the end of the list
+ x2 = polyPoints[numPoints-1].x;
+ y2 = polyPoints[numPoints-1].y;
+ } else {
+ x2 = polyPoints[i-1].x;
+ y2 = polyPoints[i-1].y;
+ } // else i!=0
+ if (y1>y2) {
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
+ } // if y1>y2
+ // skip if this can't ever be an active edge (has 0 height)
+ deltaY = y2-y1;
+ if (deltaY!=0) {
+ newEdgePtr = new ogEdgeState;
+ newEdgePtr->xDirection = ((deltaX = x2-x1) > 0) ? 1 : -1;
+ width = abs(deltaX);
+ newEdgePtr->x = x1;
+ newEdgePtr->startY = y1;
+ newEdgePtr->count = newEdgePtr->errorTermAdjDown = deltaY;
+ newEdgePtr->errorTerm = (deltaX >= 0) ? 0 : 1-deltaY;
+ if (deltaY>=width) {
+ newEdgePtr->wholePixelXMove = 0;
+ newEdgePtr->errorTermAdjUp = width;
+ } else {
+ newEdgePtr->wholePixelXMove = (width / deltaY) * newEdgePtr->xDirection;
+ newEdgePtr->errorTermAdjUp = width % deltaY;
+ } // else
+ followingEdgeLink = &globalEdges;
+ while (true) {
+ followingEdge = *followingEdgeLink;
+ if ((followingEdge == NULL) ||
+ (followingEdge->startY >= y1) ||
+ ((followingEdge->startY == y1) &&
+ (followingEdge->x>=x1))) {
+ newEdgePtr->nextEdge = followingEdge;
+ *followingEdgeLink = newEdgePtr;
+ break;
+ } // if
+ followingEdgeLink = &followingEdge->nextEdge;
+ } // while
+ } // if deltaY!=0)
+ } // for
+ return;
+} // ogEdgeTable::buildGET
+
+void
+ogEdgeTable::moveXSortedToAET(int32 yToMove) {
+ ogEdgeState * AETEdge;
+ ogEdgeState * tempEdge;
+ ogEdgeState ** AETEdgePtr;
+ int32 currentX;
+
+ /* The GET is Y sorted. Any edges that start at the desired Y
+ * coordinate will be first in the GET, so we'll move edges from
+ * the GET to AET until the first edge left in the GET is no
+ * longer at the desired Y coordinate. Also, the GET is X sorted
+ * within each Y cordinate, so each successive edge we add to the
+ * AET is guaranteed to belong later in the AET than the one just
+ * added.
+ */
+ AETEdgePtr = &activeEdges;
+ while ((globalEdges!=NULL) && (globalEdges->startY==yToMove)) {
+ currentX = globalEdges->x;
+ // link the new edge into the AET so that the AET is still
+ // sorted by X coordinate
+ while (true) {
+ AETEdge = *AETEdgePtr;
+ if ((AETEdge==NULL) || (AETEdge->x>=currentX)) {
+ tempEdge = globalEdges->nextEdge;
+ *AETEdgePtr = globalEdges;
+ globalEdges->nextEdge = AETEdge;
+ AETEdgePtr = &globalEdges->nextEdge;
+ globalEdges = tempEdge;
+ break;
+ } else AETEdgePtr = &AETEdge->nextEdge;
+ } // while true
+ } // while globalEdges!=NULL and globalEdges->startY==yToMove
+ return;
+} // ogEdgeTable::moveXSortedToAET
+
+void
+ogEdgeTable::scanOutAET(ogSurface & destObject, int32 yToScan, uInt32 colour) {
+ ogEdgeState * currentEdge;
+ int32 leftX;
+
+ /* Scan through the AET, drawing line segments as each pair of edge
+ * crossings is encountered. The nearest pixel on or to the right
+ * of the left edges is drawn, and the nearest pixel to the left
+ * of but not on right edges is drawn
+ */
+ currentEdge = activeEdges;
+ while (currentEdge!=NULL) {
+ leftX = currentEdge->x;
+ currentEdge = currentEdge->nextEdge;
+ if (currentEdge!=NULL) {
+ if (leftX!=currentEdge->x)
+ destObject.ogHLine(leftX, currentEdge->x-1, yToScan, colour);
+ currentEdge = currentEdge->nextEdge;
+ } // if currentEdge != NULL
+ } // while
+ return;
+} // ogEdgeTable::scanOutAET
+
+void
+ogEdgeTable::xSortAET(void) {
+ ogEdgeState * currentEdge;
+ ogEdgeState * tempEdge;
+ ogEdgeState ** currentEdgePtr;
+ bool swapOccurred;
+ if (activeEdges==NULL) return;
+ do {
+ swapOccurred = false;
+ currentEdgePtr = &activeEdges;
+ currentEdge = activeEdges;
+ while (currentEdge->nextEdge!=NULL) {
+ if (currentEdge->x > currentEdge->nextEdge->x) {
+ // the second edge has a lower x than the first
+ // swap them in the AET
+ tempEdge = currentEdge->nextEdge->nextEdge;
+ *currentEdgePtr = currentEdge->nextEdge;
+ currentEdge->nextEdge->nextEdge = currentEdge;
+ currentEdge->nextEdge = tempEdge;
+ swapOccurred = true;
+ } // if
+ currentEdgePtr = &((*currentEdgePtr)->nextEdge);
+ currentEdge = *currentEdgePtr;
+ } // while
+ } while (swapOccurred);
+ return;
+} // ogEdgeTable::xSortAET
+
+ogEdgeTable::~ogEdgeTable(void) {
+ ogEdgeState * edge;
+ ogEdgeState * tmpEdge;
+ tmpEdge = globalEdges;
+ // first walk the global edges and delete any non-null nodes
+ while (tmpEdge!=NULL) {
+ edge = tmpEdge;
+ tmpEdge = edge->nextEdge;
+ delete edge;
+ } // while
+ tmpEdge = activeEdges;
+ // next walk the activeEdges and delete any non-null nodes. Note that this should
+ // always be null
+ while (tmpEdge!=NULL) {
+ edge = tmpEdge;
+ tmpEdge = edge->nextEdge;
+ delete edge;
+ } // while
+ return;
+} // ogEdgeTable::~ogEdgeTable
+
+static bool
+fileExists(const char *file)
+{
+ fileDescriptor *f = fopen(file, "r");
+ if (!f)
+ return false;
+ fclose(f);
+ return true;
+}
+
+static int32 calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3);
+
+// ogSurface constructor
+ogSurface::ogSurface(void) {
+ version = ogVERSION;
+ dataState = ogNONE;
+ buffer = NULL;
+ lineOfs = NULL;
+ pal = NULL;
+ xRes = 0;
+ yRes = 0;
+ maxX = 0;
+ maxY = 0;
+ bSize = 0;
+ lSize = 0;
+ transparentColor = 0;
+ BPP = 0;
+ redShifter = 0;
+ greenShifter = 0;
+ blueShifter = 0;
+ alphaShifter = 0;
+ redFieldPosition = 0;
+ greenFieldPosition = 0;
+ blueFieldPosition = 0;
+ alphaFieldPosition = 0;
+ antiAlias = true;
+ return;
+} // ogSurface::ogSurface
+
+void
+ogSurface::aaRawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) {
+ /*
+ * aaRawLine
+ *
+ * private method
+ *
+ * draws an unclipped anti-aliased line from (x1,y1) to (x2,y2) using colour
+ *
+ */
+ uInt32 erradj, erracc;
+ uInt32 erracctmp, intshift, wgt, wgtcompmask;
+ int32 dx, dy, tmp, xDir, i;
+ uInt32 ct[32];
+ uInt8 r,g,b;
+ uInt8 orig_r, orig_g, orig_b;
+
+ if (y1 > y2) {
+ tmp= y1;
+ y1 = y2;
+ y2 = tmp;
+
+ tmp= x1;
+ x1 = x2;
+ x2 = tmp;
+ } // if
+
+ ogUnpackRGB(colour, orig_r, orig_g, orig_b);
+
+ for (i=0; i<32; i++) {
+ r = (i*orig_r) / 31;
+ g = (i*orig_g) / 31;
+ b = (i*orig_b) / 31;
+ ct[31-i] = ogRGB(r,g,b);
+ } // for
+
+ ogSetPixel(x1,y1,colour);
+
+ dx = (x2-x1);
+ if (dx>=0) xDir=1; else xDir=-1;
+ dx = abs(dx);
+ dy = (y2 - y1);
+
+ if (dy==0) {
+ ogHLine(x1,x2,y1,colour);
+ return;
+ }
+
+ if (dx==0) {
+ ogVLine(x1,y1,y2,colour);
+ return;
+ }
+
+ // this is incomplete.. diagonal lines don't travel through the
+ // center of pixels exactly
+ if (dx==dy) {
+ for (; dy != 0; dy--) {
+ x1+=xDir;
+ y1++;
+ ogSetPixel(x1,y1,colour);
+ } // for
+ return;
+ } // if dx==dy
+
+ erracc = 0;
+ intshift = 32-5;
+ wgtcompmask = 31;
+ if (dy>dx) {
+ /* y-major. Calculate 32-bit fixed point fractional part of a pixel that
+ * X advances every time Y advances 1 pixel, truncating the result so that
+ * we won't overrun the endpoint along the X axis
+ */
+ erradj = ((unsigned long long) dx << 32) / (unsigned long long)dy;
+ while (--dy) {
+ erracctmp = erracc;
+ erracc += erradj;
+ if (erracc <= erracctmp) x1 += xDir;
+ y1++; // y-major so always advance Y
+ /* the nbits most significant bits of erracc give us the intensity
+ * weighting for this pixel, and the complement of the weighting for
+ * the paired pixel.
+ */
+ wgt = erracc >> intshift;
+ ogSetPixel(x1, y1, ct[wgt]);
+ ogSetPixel(x1+xDir, y1, ct[wgt^wgtcompmask]);
+ } // while
+ } else {
+ /* x-major line. Calculate 32-bit fixed-point fractional part of a pixel
+ * that Y advances each time X advances 1 pixel, truncating the result so
+ * that we won't overrun the endpoint along the X axis.
+ */
+ erradj = ((unsigned long long)dy << 32) / (unsigned long long)dx;
+ // draw all pixels other than the first and last
+ while (--dx) {
+ erracctmp = erracc;
+ erracc += erradj;
+ if (erracc <= erracctmp) y1++;
+ x1 += xDir; // x-major so always advance X
+ /* the nbits most significant bits of erracc give us the intensity
+ * weighting for this pixel, and the complement of the weighting for
+ * the paired pixel.
+ */
+ wgt = erracc >> intshift;
+ ogSetPixel(x1, y1, ct[wgt]);
+ ogSetPixel(x1, y1+1, ct[wgt^wgtcompmask]);
+ } // while
+ } // else
+ ogSetPixel(x2,y2,colour);
+ return;
+} // ogSurface::aaRawLine
+
+uInt32
+ogSurface::rawGetPixel(uInt32 x, uInt32 y) {
+ uInt32 result;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " mov %%eax, %0 \n" // mov result, eax
+ : "=m" (result)
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x) // , "m" (result) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size
+ " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size
+ " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // edx,word ptr [edi]
+ " xor %%eax, %%eax \n"
+ " mov 2(%%edi), %%al \n" // mov al, [edi+2]
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov (%%edi), %%ax \n" // mov ax, [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " mov (%%edi),%%eax \n" // eax,word ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ } // switch
+ return result;
+} // ogSurface::rawGetPixel
+
+void
+ogSurface::rawSetPixel(uInt32 x, uInt32 y, uInt32 colour) {
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%eax, (%%edi) \n" // mov [edi], eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ } // switch
+ return;
+} // ogSurface::rawSetPixel
+
+bool
+ogSurface::clipLine(int32& x1, int32& y1, int32& x2, int32& y2) {
+ /*
+ * clipLine()
+ *
+ * private method
+ *
+ * clips a line to (0,0),(maxX,maxY); returns true if
+ * the line segment is in bounds, false if none of the line segment is
+ * on the screen. Uses HJI's line clipping algorithm.
+ */
+
+ int32 tx1, ty1, tx2, ty2;
+ int32 OutCode;
+ uInt32 AndResult, OrResult;
+ AndResult = 15;
+ OrResult = 0;
+ OutCode = 0;
+ if (x1<0) OutCode+=8;
+ if (x1>(int32)maxX) OutCode+=4;
+ if (y1<0) OutCode+=2;
+ if (y1>(int32)maxY) OutCode++;
+
+ AndResult &= OutCode;
+ OrResult |= OutCode;
+ OutCode = 0;
+
+ if (x2<0) OutCode+=8;
+ if (x2>(int32)maxX) OutCode+=4;
+ if (y2<0) OutCode+=2;
+ if (y2>(int32)maxY) OutCode++;
+
+ AndResult &= OutCode;
+ OrResult |= OutCode;
+
+ if (AndResult>0) return false;
+ if (OrResult==0) return true;
+
+ // some clipping is required here.
+
+ tx1 = x1;
+ ty1 = y1;
+ tx2 = x2;
+ ty2 = y2;
+
+ if (x1<0) {
+ ty1 = (x2*y1-x1*y2) / (x2-x1);
+ tx1 = 0;
+ } // if
+ else
+ if (x2<0) {
+ ty2 = (x2*y1-x1*y2) / (x2-x1);
+ tx2 = 0;
+ } // elseif
+
+ if (x1>(int32)maxX) {
+ ty1 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1);
+ tx1 = maxX;
+ } // if
+ else
+ if (x2>(int32)maxX) {
+ ty2 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1);
+ tx2 = maxX;
+ } // elseif
+
+ if (((ty1<0) && (ty2<0)) ||
+ ((ty1>(int32)maxY) && (ty2>(int32)maxY))) return false;
+
+ if (ty1<0) {
+ tx1 = (x1*y2-x2*y1) / (y2-y1);
+ ty1 = 0;
+ } // if
+ else
+ if (ty2<0) {
+ tx2 = (x1*y2-x2*y1) / (y2-y1);
+ ty2 = 0;
+ } // elseif
+
+ if (ty1>(int32)maxY) {
+ tx1 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1);
+ ty1 = maxY;
+ } // if
+ else
+ if (ty2>(int32)maxY) {
+ tx2 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1);
+ ty2 = maxY;
+ } // elseif
+
+ if (((uInt32)tx1>maxX) || ((uInt32)tx2>maxX)) return false;
+
+ x1 = tx1;
+ y1 = ty1;
+ x2 = tx2;
+ y2 = ty2;
+
+ return true;
+} // ogSurface::clipLine
+
+void
+ogSurface::rawLine(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2, uInt32 colour) {
+ /*
+ * ogSurface::rawLine()
+ *
+ * private method; draws an unclipped line from (x1,y1) to (x2,y2)
+ *
+ */
+ int32 tc;
+ if (!ogAvail()) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive8 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive8: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive8 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive8: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater8 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop8: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone8 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY8 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY8: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop8 \n"
+
+"rlyGreater8: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop8: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone8 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX8 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX8: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop8 \n"
+"rlDone8: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+x1), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+x2), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive16 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive16: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive16 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive16: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater16 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop16: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone16 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY16 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY16: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop16 \n"
+
+"rlyGreater16: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop16: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone16 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX16 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX16: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop16 \n"
+"rlDone16: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 1)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 1)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive24 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive24: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive24 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive24: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater24 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop24: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone24 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY24 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY24: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop24 \n"
+
+"rlyGreater24: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop24: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone24 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX24 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX24: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop24 \n"
+"rlDone24: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1*3)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2*3)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " mov $1, %%ecx \n" // mov ecx, 1
+ " bt $15, %%eax \n" // bt eax, 15
+ " jnc rlxPositive32 \n"
+ " or $-1, %%ecx \n" // or ecx, -1
+ " neg %%eax \n" // neg eax
+"rlxPositive32: \n"
+ " add %%eax, %%eax \n" // add eax, eax
+ " bt $15, %%ebx \n" // bt ebx, 15
+ " jnc rlyPositive32 \n"
+ " neg %%edx \n" // neg edx
+ " neg %%ebx \n" // neg ebx
+"rlyPositive32: \n"
+ " add %%ebx, %%ebx \n" // add ebx, ebx
+
+ " cmp %%ebx, %%eax \n" // cmp eax, ebx
+ " jle rlyGreater32 \n"
+ " push %%ecx \n" // push ecx
+ " mov %%eax, %%ecx \n" // mov ecx, eax
+ " mov %%ebx, %6 \n" // mov tc, ebx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n" // pop ecx
+"rlxTop32: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone32 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddY32 \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " sub %%eax, %6 \n" // sub tc, eax
+"rlNoAddY32: \n"
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ebx, %6 \n" // add tc, ebx
+ " jmp rlxTop32 \n"
+
+"rlyGreater32: \n"
+ " push %%ecx \n" // push ecx
+ " mov %%ebx, %%ecx \n" // mov ecx, ebx
+ " mov %%eax, %6 \n" // mov tc, eax
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " sub %%ecx, %6 \n" // sub tc, ecx
+ " pop %%ecx \n"
+"rlyTop32: \n"
+ " push %%eax \n" // push eax
+ " mov %5, %%eax \n" // mov eax, colour
+ " mov %%eax, (%%edi)\n" // mov [edi], eax
+ " pop %%eax \n" // pop eax
+ " cmp %%edi, %%esi \n" // cmp esi, edi
+ " je rlDone32 \n"
+ " cmp $0, %6 \n" // cmp tc, 0
+ " jl rlNoAddX32 \n"
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx - pix size
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " sub %%ebx, %6 \n" // sub tc, ebx
+"rlNoAddX32: \n"
+ " add %%edx, %%edi \n" // add edi, edx
+ " add %%eax, %6 \n" // add tc, eax
+ " jmp rlyTop32 \n"
+"rlDone32: \n"
+ :
+ : "D" ((uInt8 *)buffer+lineOfs[y1]+(x1 << 2)), // %0
+ "S" ((uInt8 *)buffer+lineOfs[y2]+(x2 << 2)), // %1
+ "a" (x2-x1), "b" (y2-y1), // %2, %3
+ "d" (xRes), "m" (colour), // %4, %5
+ "m" (tc) // %6
+ );
+ break;
+ } // switch
+ return;
+} // ogSurface::rawLine
+
+bool
+ogSurface::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) {
+ uInt32 tmp;
+ if (dataState==ogOWNER) return false;
+
+ if (x2> 3));
+ lineOfs=((uInt32 *)SrcObject.lineOfs)+y1;
+ pal = SrcObject.pal;
+ xRes = SrcObject.xRes;
+ yRes = SrcObject.yRes;
+ maxX = (x2-x1);
+ maxY = (y2-y1);
+ bSize = 0;
+ lSize = 0;
+ transparentColor = SrcObject.transparentColor;
+ dataState = ogALIASING;
+ BPP = SrcObject.BPP;
+ // For 8bpp modes the next part doesn't matter
+ redFieldPosition = SrcObject.redFieldPosition;
+ greenFieldPosition = SrcObject.greenFieldPosition;
+ blueFieldPosition = SrcObject.blueFieldPosition;
+ alphaFieldPosition = SrcObject.alphaFieldPosition;
+ // The next part is only used by 15/16bpp
+ redShifter = SrcObject.redShifter;
+ greenShifter = SrcObject.greenShifter;
+ blueShifter = SrcObject.blueShifter;
+ alphaShifter = SrcObject.alphaShifter;
+
+ antiAlias = SrcObject.antiAlias;
+
+ return true;
+} // ogSurface::ogAlias
+
+void
+ogSurface::ogArc(int32 x_center, int32 y_center, uInt32 radius,
+ uInt32 s_angle, uInt32 e_angle, uInt32 colour) {
+ int32 p;
+ uInt32 x, y, tmp;
+ double alpha;
+
+ if (radius==0) {
+ ogSetPixel(x_center, y_center, colour);
+ return;
+ } // if
+
+ s_angle%=361;
+ e_angle%=361;
+
+ if (s_angle>e_angle) {
+ tmp = s_angle;
+ s_angle = e_angle;
+ e_angle = tmp;
+ } // if
+
+ x = 0;
+ y = radius;
+ p = 3-2*radius;
+
+ while (x<=y) {
+ alpha = (180.0/3.14159265358979)*atan((double)x/(double)y);
+ if ((alpha>=s_angle) && (alpha<=e_angle))
+ ogSetPixel(x_center-x, y_center-y, colour);
+ if ((90-alpha>=s_angle) && (90-alpha<=e_angle))
+ ogSetPixel(x_center-y, y_center-x, colour);
+ if ((90+alpha>=s_angle) && (90+alpha<=e_angle))
+ ogSetPixel(x_center-y, y_center+x,colour);
+ if ((180-alpha>=s_angle) && (180-alpha<=e_angle))
+ ogSetPixel(x_center-x, y_center+y,colour);
+ if ((180+alpha>=s_angle) && (180+alpha<=e_angle))
+ ogSetPixel(x_center+x, y_center+y,colour);
+ if ((270-alpha>=s_angle) && (270-alpha<=e_angle))
+ ogSetPixel(x_center+y, y_center+x,colour);
+ if ((270+alpha>=s_angle) && (270+alpha<=e_angle))
+ ogSetPixel(x_center+y, y_center-x,colour);
+ if ((360-alpha>=s_angle) && (360-alpha<=e_angle))
+ ogSetPixel(x_center+x, y_center-y,colour);
+ if (p<0)
+ p+=4*x+6;
+ else {
+ p+=4*(x-y)+10;
+ --y;
+ }
+ ++x;
+ } // while
+ return;
+} // ogSurface::ogArc
+
+bool
+ogSurface::ogAvail(void) {
+ return ((buffer!=NULL) && (lineOfs!=NULL));
+} // ogSurface::ogAvail
+
+static int32
+calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3) {
+ float mu2, mu3;
+ mu2 = mu*mu;
+ mu3 = mu2*mu;
+ return (int32)(0.5f+(1.0/6.0)*(mu3*(-p0+3.0*p1-3.0*p2+p3)+
+ mu2*(3.0*p0-6.0*p1+3.0*p2)+
+ mu*(-3.0*p0+3.0*p2)+(p0+4.0*p1+p2)));
+} // calculate
+
+
+void
+ogSurface::ogBSpline(uInt32 numPoints, ogPoint* points, uInt32 segments,
+ uInt32 colour) {
+ float mu, mudelta;
+ int32 x1,y1,x2,y2;
+ uInt32 n,h;
+ if (points==NULL) return;
+ if ((numPoints<4) || (numPoints>4096) || (segments==0)) return;
+ mudelta = 1.0/segments;
+ for (n=3; n=0) {
+ ogSetPixel(x_center+x,y_center+y,colour);
+ ogSetPixel(x_center+x,y_center-y,colour);
+ ogSetPixel(x_center-x,y_center+y,colour);
+ ogSetPixel(x_center-x,y_center-y,colour);
+ if (d + y > 0) {
+ y--;
+ d -= 2*y+1;
+ } // if
+ if (x > d) {
+ x++;
+ d += 2*x+1;
+ } // if
+ } // while
+ return;
+} // ogSurface::ogCircle
+
+void
+ogSurface::ogClear(uInt32 colour) {
+ uInt32 height = 0;
+ if (!ogAvail()) return;
+ __asm__ __volatile__("cld\n");
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxY)
+ " inc %%ebx \n" // inc ebx (maxX)
+ " sub %%edx, %%esi \n" // sub esi, edx
+ " mov %%al, %%ah \n" // mov ah, al
+ " mov %%ax, %%cx \n" // mov cx, ax
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov %%cx, %%ax \n" // mov ax, cx
+ "loop8: \n"
+ " push %%edx \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " and $3, %%edx \n" // and edx, 3
+ " shr $2, %%ecx \n" // shr ecx, 2
+ " rep \n"
+ " stosl \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " rep \n"
+ " stosb \n"
+ " pop %%edx \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop8 \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX) // %4, %5
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " sub %%edx, %%esi \n" // sub esi, edx
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%ax, %%cx \n" // mov cx, ax
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov %%cx, %%ax \n" // mov ax, cx
+ "loop16: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " shr $1, %%ecx \n" // shr ecx, 1
+ " rep \n"
+ " stosl \n"
+ " jnc noc16 \n"
+ " stosw \n"
+ "noc16: \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop16 \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX) // %4, %5
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%ebx, %6 \n" // mov height, ebx
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " mov %%eax, %%ebx \n" // mov ebx, eax
+ " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size
+ " shr $16, %%ebx \n" // shr ebx, 16
+ "oloop24: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ "iloop24: \n"
+ " mov %%ax,(%%edi) \n" // mov [edi],ax
+ " movb %%bl,2(%%edi) \n" // mov [edi+2],bl
+ " add $3, %%edi \n" // add edi, 3
+ " dec %%ecx \n" // dec ecx
+ " jnz iloop24 \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " decl %6 \n" // dec height
+ " jnz oloop24 \n"
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX), // %4, %5
+ "m" (height) // %6
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+
+ " add (%%esi), %%edi \n" // add edi, [esi]
+ " mov %%ecx, %%esi \n" // mov esi, ecx
+ " inc %%edx \n" // inc edx (maxX)
+ " inc %%ebx \n" // inc ebx (maxY)
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " shl $2, %%ecx \n" // shl ecx, 2
+ " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size
+ "loop32: \n"
+ " mov %%edx, %%ecx \n" // mov ecx, edx
+ " rep \n"
+ " stosl \n"
+ " add %%esi, %%edi \n" // add edi, esi
+ " dec %%ebx \n"
+ " jnz loop32 \n"
+
+ :
+ : "D" (buffer), "S" (lineOfs), // %0, %1
+ "a" (colour), "b" (maxY), // %2, %3
+ "c" (xRes), "d" (maxX) // %4, %5
+ );
+ } // switch
+ return;
+} // ogSurface::ogClear
+
+bool
+ogSurface::ogClone(ogSurface& SrcObject) {
+ bool created;
+ ogPixelFmt pixfmt;
+ if (SrcObject.dataState==ogNONE) return false;
+ SrcObject.ogGetPixFmt(pixfmt);
+ created = ogCreate(SrcObject.maxX+1,SrcObject.maxY+1,pixfmt);
+ if (!created) return false;
+ transparentColor = SrcObject.transparentColor;
+ antiAlias = SrcObject.antiAlias;
+ ogCopyPal(SrcObject);
+ ogCopy(SrcObject);
+ return true;
+} // ogSurface::ogClone
+
+void
+ogSurface::ogCopy(ogSurface& SrcObject) {
+ uInt32 count, xCount, yCount;
+ uInt32 xx, yy;
+ uInt8 r, g, b;
+ void * srcPtr;
+
+ if (!ogAvail()) return;
+ if (!SrcObject.ogAvail()) return;
+
+ xCount = SrcObject.maxX+1;
+ if (xCount>maxX+1) xCount=maxX+1;
+ yCount = SrcObject.maxY+1;
+ if (yCount>maxY+1) yCount=maxY+1;
+ if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) ||
+ (blueShifter!=SrcObject.blueShifter) ||
+ (greenShifter!=SrcObject.greenShifter)) {
+ for (yy=0; yy> 3); // adjust for bpp
+ for (count=0; count(int32)maxX) || (dY1>(int32)maxY)) return;
+
+ // if any of the source buffer is out of bounds then do nothing
+ if (( (uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) ||
+ ( (uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return;
+
+ if (sX1>sX2) {
+ xx = sX1;
+ sX1= sX2;
+ sX2= xx;
+ } // if
+
+ if (sY1>sY2) {
+ yy = sY1;
+ sY1= sY2;
+ sY2= yy;
+ } // if
+
+ xCount = abs(sX2-sX1)+1;
+ yCount = abs(sY2-sY1)+1;
+
+ if (dX1+xCount>(int32)maxX+1) xCount=maxX-dX1+1;
+ if (dY1+yCount>(int32)maxY+1) yCount=maxY-dY1+1;
+
+ if (dX1<0) {
+ xCount += dX1;
+ sX1 -= dX1;
+ dX1 = 0;
+ } // if
+
+ if (dY1<0) {
+ yCount += dY1;
+ sY1 -= dY1;
+ dY1 = 0;
+ } // if
+
+ if ((dX1+xCount<0) || (dY1+yCount<0)) return;
+
+ if ((BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) ||
+ (blueShifter!=SrcObject.blueShifter) ||
+ (greenShifter!=SrcObject.greenShifter)) {
+ if (SrcObject.BPP==8) {
+ for (xx=0; xx<256; xx++)
+ pixmap[xx] = ogRGB(SrcObject.pal[xx].red,
+ SrcObject.pal[xx].green,
+ SrcObject.pal[xx].blue);
+ for (yy=0; yy<=yCount-1; yy++)
+ for (xx=0; xx<=xCount-1; xx++)
+ rawSetPixel(dX1+xx,dY1+yy,
+ pixmap[SrcObject.ogGetPixel(sX1+xx,sY1+yy)]);
+ } // if SrcObject->bpp
+ else
+ {
+ for (yy=0; yy<=yCount-1; yy++)
+ for (xx=0; xx<=xCount-1; xx++) {
+ SrcObject.ogUnpackRGB(SrcObject.ogGetPixel(sX1+xx,sY1+yy),r,g,b);
+ rawSetPixel(dX1+xx,dY1+yy,ogRGB(r,g,b));
+ } // for
+ } // else
+ } // if
+ else
+ {
+ xCount *= (BPP+7) >> 3;
+ for (count=0; count> 3), // dest
+ src, // src
+ size); // size
+
+ return;
+} // ogSurface::ogCopyLineTo
+
+void
+ogSurface::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dst, uInt32 size) {
+ /*
+ * ogCopyLineFrom()
+ *
+ * Inputs:
+ *
+ * sx - Source X of the target buffer
+ * sy - Source Y of the target buffer
+ * dest - where to put it
+ * size - size in bytes *NOT* pixels
+ *
+ * Copies a run of pixels (of the same format) to (x,y) of a buffer
+ *
+ * This method is required because of the different implementations of
+ * copying a run of pixels to a buffer
+ *
+ * WARNING!!! This does *NO* error checking. It is assumed that you've
+ * done all of that. ogCopyLineTo and ogCopyLineFrom are the only
+ * methods that don't check to make sure you're hosing things. Don't
+ * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!!
+ */
+ kmemcpy( dst, // dest
+ (uInt8*)buffer+lineOfs[sy]+sx*((BPP+7) >> 3), // src
+ size); // size
+
+ return;
+} // ogSurface::ogCopyLineFrom
+
+void
+ogSurface::ogCopyPal(ogSurface& SrcObject) {
+ if (SrcObject.pal==NULL) return;
+ if (pal==NULL) pal = new ogRGBA[256];
+ if (pal==NULL) return;
+ kmemcpy(pal, SrcObject.pal, sizeof(ogRGBA)*256);
+ return;
+} // ogSurface::ogCopyPal
+
+bool
+ogSurface::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixformat) {
+ /*
+ * ogSurface::ogCreate()
+ * Allocates memory for a buffer of size _xRes by _yRes with
+ * the pixel format defined in _pixformat. Allocates memory
+ * for pal and lineOfs.
+ */
+ uInt32 yy;
+ if (dataState==ogOWNER) {
+ kfree(buffer);
+ delete [] lineOfs;
+ delete [] pal;
+ } // if datastate
+ BPP = _pixformat.BPP;
+ bSize=_xRes*_yRes*((BPP+7) >> 3);
+ buffer = kmalloc(bSize,-2);
+ if (buffer==NULL) return false;
+ kmemset(buffer,0,bSize);
+ lSize = _yRes*sizeof(uInt32);
+ lineOfs = new uInt32[_yRes];
+ if (lineOfs == NULL) return false;
+ pal = new ogRGBA[256];
+ if (pal == NULL) return false;
+ // copy the default palette into the buffer
+ kmemcpy(pal,DEFAULT_PALETTE,sizeof(ogRGBA)*256);
+ maxX=_xRes-1;
+ xRes=_xRes*((BPP+7) >> 3);
+ maxY=_yRes-1;
+ yRes=_yRes;
+ lineOfs[0]=0;
+ for (yy=1; yy<=maxY; yy++)
+ lineOfs[yy]=lineOfs[yy-1]+xRes;
+ dataState = ogOWNER;
+ // For 8bpp modes the next part doesn't matter
+ redFieldPosition=_pixformat.redFieldPosition;
+ greenFieldPosition=_pixformat.greenFieldPosition;
+ blueFieldPosition=_pixformat.blueFieldPosition;
+ alphaFieldPosition=_pixformat.alphaFieldPosition;
+ // The next part is only used by 15/16hpp
+ redShifter=8-_pixformat.redMaskSize;
+ greenShifter=8-_pixformat.greenMaskSize;
+ blueShifter=8-_pixformat.blueMaskSize;
+ alphaShifter=8-_pixformat.alphaMaskSize;
+
+ // Turn anti aliasing off by default for 8bpp modes
+ antiAlias = (BPP>8);
+ owner = this;
+ return true;
+} // ogSurface::ogCreate
+
+void
+ogSurface::ogCubicBezierCurve(int32 x1, int32 y1, int32 x2, int32 y2,
+ int32 x3, int32 y3, int32 x4, int32 y4,
+ uInt32 segments, uInt32 colour) {
+ float tX1, tY1, tX2, tY2, tX3, tY3, mu, mu2, mu3, mudelta;
+ int32 xStart, yStart, xEnd, yEnd;
+ uInt32 n;
+ if (segments<1) return;
+ if (segments>128) segments=128;
+
+ mudelta = 1.0/segments;
+ mu = mudelta;
+ tX1 =-x1+3*x2-3*x3+x4;
+ tY1 =-y1+3*y2-3*y3+y4;
+ tX2 =3*x1-6*x2+3*x3;
+ tY2 =3*y1-6*y2+3*y3;
+ tX3 =-3*x1+3*x2;
+ tY3 =-3*y1+3*y2;
+
+ xStart = x1;
+ yStart = y1;
+
+ for (n=1; n128) segments=128;
+ x2 = (x2*2)-((x1+x3)/2);
+ y2 = (y2*2)-((y1+y3)/2);
+
+ ex = ((int64)(x2-x1) << 17) / segments;
+ ey = ((int64)(y2-y1) << 17) / (long long)segments;
+ fx = ((int64)(x3-(2*x2)+x1) << 16) / (segments*segments);
+ fy = ((int64)(y3-(2*y2)+y1) << 16) / (long long)(segments*segments);
+
+ while (--segments>0) {
+ t1=x3;
+ t2=y3;
+ x3=((int64)((fx*segments+ex)*segments) / 65536L)+x1;
+ y3=((int64)((fy*segments+ey)*segments) / 65536L)+y1;
+ ogLine(t1, t2, x3, y3, colour);
+ } // while
+ ogLine(x3,y3,x1,y1,colour);
+ return;
+
+} // ogSurface::ogCurve
+
+void
+ogSurface::ogFillCircle(int32 x_center, int32 y_center,
+ uInt32 radius, uInt32 colour) {
+ int32 x, y, d;
+ x = 0;
+ y = radius;
+ d = 2*(1-radius);
+ while (y>=0) {
+ ogHLine(x_center-x, x_center+x, y_center-y, colour);
+ ogHLine(x_center-x, x_center+x, y_center+y, colour);
+ if (d+y>0) {
+ y--;
+ d-=2*y+1;
+ }
+ if (x>d) {
+ x++;
+ d+=2*x+1;
+ }
+ } // while
+ return;
+} // ogSurface::ogFillCircle
+
+#if 0
+!-/* Scan converts an edge from (X1,Y1) to (X2,Y2), not including the
+!- * point at (X2,Y2). This avoids overlapping the end of one line with
+!- * the start of the next, and causes the bottom scan line of the
+!- * polygon not to be drawn. If SkipFirst != 0, the point at (X1,Y1)
+!- * isn't drawn. For each scan line, the pixel closest to the scanned
+!- * line without being to the left of the scanned line is chosen
+!- */
+!-static void index_forward(int32 & index, uInt32 numPoints) {
+!- index = (index + 1) % numPoints;
+!- return;
+!-} // index_forward
+!-
+!-static void index_backward(int32 & index, uInt32 numPoints) {
+!- index = (index - 1 + numPoints) % numPoints;
+!- return;
+!-} // index_forward
+!-
+!-static void index_move(int32 & index, uInt32 numPoints, int32 direction) {
+!- if (direction > 0)
+!- index_forward(index, numPoints);
+!- else
+!- index_backward(index, numPoints);
+!- return;
+!-} // index_move
+!-
+!-static void scanEdge(int32 x1, int32 y1, int32 x2, int32 y2,
+!- uInt32 & eIdx, int32 * xList) {
+!- int32 y, deltaX, deltaY;
+!- float inverseSlope;
+!-
+!- deltaX = x2 - x1;
+!- deltaY = y2 - y1;
+!- if (deltaY <= 0) return;
+!- inverseSlope = deltaX / deltaY;
+!-
+!- // Store the X coordinate of the pixel closest to but not to the
+!- // left of the line for each Y coordinate between Y1 and Y2, not
+!- // including Y2
+!- y = y1;
+!- do {
+!- xList[eIdx] = x1+ (int32)(0.5f+((y-y1)*inverseSlope));
+!- y++;
+!- eIdx++;
+!- } while (y maxPointY) {
+!- maxIndex = i;
+!- maxPointY = polyPoints[i].y; // new bottom
+!- } // else if
+!- } // for
+!-
+!- if (minPointY == maxPointY) return;
+!-
+!- // scan in ascending order to find the last top-edge point
+!- minIndexR = minIndexL;
+!- while (polyPoints[minIndexR].y == minPointY) index_forward(minIndexR, numPoints);
+!- index_backward(minIndexR, numPoints); // back up to last top-edge point
+!-
+!- // now scan in descending order to find the first top-edge point
+!- while (polyPoints[minIndexL].y == minPointY) index_backward(minIndexL, numPoints);
+!- index_forward(minIndexL, numPoints);
+!-
+!- // figure out which direction through the vertex list from the top
+!- // vertex is the left edge and which is the right
+!- leftEdgeDir = -1;
+!-
+!- topIsFlat = (polyPoints[minIndexL].x==polyPoints[minIndexR].x) ? 0 : 1;
+!- if (topIsFlat==1) {
+!- if (polyPoints[minIndexL].x > polyPoints[minIndexR].x) {
+!- leftEdgeDir = 1;
+!- temp = minIndexL;
+!- minIndexL = minIndexR;
+!- minIndexR = temp;
+!- }
+!- } else {
+!- // Point to the downward end of the first line of each of the
+!- // two edges down from the top
+!- nextIndex = minIndexR;
+!- index_forward(nextIndex, numPoints);
+!- prevIndex = minIndexL;
+!- index_forward(prevIndex, numPoints);
+!-
+!- deltaXN = polyPoints[nextIndex].x - polyPoints[minIndexL].x;
+!- deltaYN = polyPoints[nextIndex].y - polyPoints[minIndexL].y;
+!- deltaXP = polyPoints[prevIndex].x - polyPoints[minIndexL].x;
+!- deltaYP = polyPoints[prevIndex].y - polyPoints[minIndexL].y;
+!- if (deltaXN * deltaYP - deltaYN * deltaXP < 0) {
+!- leftEdgeDir = 1;
+!- temp = minIndexL;
+!- minIndexL = minIndexR;
+!- minIndexR = temp;
+!- } // if
+!- } // else
+!-
+!- /* Set the # of scan lines in the polygon, skipping the bottom edge
+!- * and also skipping the top vertex if the top isn't flat because
+!- * in that case the top vertex has a right edge component, and set
+!- * the top scan line to draw, which is likewise the second line of
+!- * the polygon unles the top if flat
+!- */
+!-
+!- workingHLineList.length = maxPointY - minPointY;
+!- if (workingHLineList.length <= 0) return;
+!- workingHLineList.yStart = minPointY;
+!-
+!- // get memory in which to srote the line list we generate
+!- workingHLineList.xLeft = workingHLineList.xRight = NULL;
+!- if ((workingHLineList.xLeft = new int32[workingHLineList.length]) == NULL) return;
+!- if ((workingHLineList.xRight = new int32[workingHLineList.length]) == NULL) {
+!- delete workingHLineList.xLeft;
+!- return;
+!- }
+!- kmemset(workingHLineList.xLeft,0,workingHLineList.length*sizeof(int32));
+!- kmemset(workingHLineList.xRight,0,workingHLineList.length*sizeof(int32));
+!-
+!- // scan the left edge and store the boundary points int he list
+!- // Initial pointer for storing scan converted left-edge coords
+!- edgePointIdx = 0;
+!-
+!- // start from the top of the left edge
+!- curIndex = prevIndex = minIndexL;
+!-
+!- do {
+!- index_move(curIndex, numPoints, leftEdgeDir);
+!- scanEdge(polyPoints[prevIndex].x,
+!- polyPoints[prevIndex].y,
+!- polyPoints[curIndex].x,
+!- polyPoints[curIndex].y,
+!- edgePointIdx,
+!- workingHLineList.xLeft);
+!- prevIndex = curIndex;
+!- } while (curIndex != maxIndex);
+!-
+!- edgePointIdx = 0;
+!- curIndex = prevIndex = minIndexR;
+!- // Scan convert the right edge, top to bottom. X coordinates are
+!- // adjusted 1 to the left, effectively causing scan conversion of
+!- // the nearest points to the left of but not exactly on the edge }
+!- do {
+!- index_move(curIndex, numPoints, -leftEdgeDir);
+!- scanEdge(polyPoints[prevIndex].x,
+!- polyPoints[prevIndex].y,
+!- polyPoints[curIndex].x,
+!- polyPoints[curIndex].y,
+!- edgePointIdx,
+!- workingHLineList.xRight);
+!- prevIndex = curIndex;
+!- } while (curIndex != maxIndex);
+!-
+!- ogPolygon(numPoints, polyPoints, colour);
+!-
+!- for (i = 0; i < workingHLineList.length; i++) {
+!- ogHLine(workingHLineList.xLeft[i], workingHLineList.xRight[i],
+!- workingHLineList.yStart+i, colour);
+!- } // for
+!-
+!- ogPolygon(numPoints, polyPoints, colour);
+!-
+!- delete workingHLineList.xLeft;
+!- delete workingHLineList.xRight;
+!-
+!- return;
+!-} // ogSurface::ogFillConvexPolygon
+#endif
+
+void
+ogSurface::ogFillPolygon(uInt32 numPoints, ogPoint* polyPoints, uInt32 colour) {
+ ogEdgeTable * edges;
+ int32 currentY;
+
+ if (numPoints<3) return;
+/* if (numPoints==3) {
+ * ogFillConvexPolygon(numPoints, polyPoints, colour);
+ * return;
+ * } // if
+ */
+ ogPolygon(numPoints, polyPoints, colour);
+ edges = new ogEdgeTable();
+ edges->buildGET(numPoints, polyPoints);
+ currentY = edges->globalEdges->startY;
+ while ((edges->globalEdges!=NULL) || (edges->activeEdges!=NULL)) {
+ edges->moveXSortedToAET(currentY);
+ edges->scanOutAET(*this, currentY, colour);
+ edges->advanceAET();
+ edges->xSortAET();
+ currentY++;
+ if (currentY>(int32)maxY) break; // if we've gone past the bottom, stop
+ } // while
+ delete edges;
+ return;
+} // ogSurface::ogFillPolygon
+
+void
+ogSurface::ogFillRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) {
+ int32 yy,tmp;
+
+ if (x2(int32)maxY)) return;
+ if (y1<0) y1=0;
+ if (y2>(int32)maxY) y2=maxY;
+ for (yy=y1; yy<=y2; yy++)
+ ogHLine(x1,x2,yy,colour);
+} // ogSurface::ogFillRect
+
+void ogSurface::ogFillTriangle(int32 x1, int32 y1, int32 x2, int32 y2,
+ int32 x3, int32 y3, uInt32 colour) {
+ ogPoint Points[3];
+ Points[0].x = x1;
+ Points[0].y = y1;
+ Points[1].x = x2;
+ Points[1].y = y2;
+ Points[2].x = x3;
+ Points[2].y = y3;
+// ogFillConvexPolygon(3,Points,colour);
+ ogFillPolygon(3,Points,colour);
+ return;
+} // ogSurface::ogFillTriangle
+
+void
+ogSurface::ogGetPixFmt(ogPixelFmt& pixfmt) {
+ pixfmt.BPP=BPP;
+ pixfmt.redFieldPosition=redFieldPosition;
+ pixfmt.greenFieldPosition=greenFieldPosition;
+ pixfmt.blueFieldPosition=blueFieldPosition;
+ pixfmt.alphaFieldPosition=alphaFieldPosition;
+ pixfmt.redMaskSize=8-redShifter;
+ pixfmt.greenMaskSize=8-greenShifter;
+ pixfmt.blueMaskSize=8-blueShifter;
+ pixfmt.alphaMaskSize=8-alphaShifter;
+ return;
+} // ogSurface::ogGetPixFmt
+
+uInt32
+ogSurface::ogGetPixel(int32 x, int32 y) {
+ uInt32 result;
+ if (!ogAvail()) return transparentColor;
+
+ if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return transparentColor;
+
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi]
+ " mov %%eax, %0 \n" // mov result, eax
+ : "=m" (result)
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x) // , "m" (result) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size
+ " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size
+ " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " movzwl (%%edi),%%eax \n" // edx,word ptr [edi]
+ " xor %%eax, %%eax \n"
+ " mov 2(%%edi), %%al \n" // mov al, [edi+2]
+ " shl $16, %%eax \n" // shl eax, 16
+ " mov (%%edi), %%ax \n" // mov ax, [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " mov (%%edi),%%eax \n" // eax,word ptr [edi]
+ " mov %%eax, %3 \n" // mov result, eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (result) // %2, %3
+ );
+ } // switch
+ return result;
+} // ogSurface::ogGetPixel
+
+void *
+ogSurface::ogGetPtr(uInt32 x, uInt32 y) {
+// return (ogAvail() ? ( (uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)) ) : NULL );
+ return ((uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)));
+} // ogSurface::ogGetPtr
+
+void
+ogSurface::ogHFlip(void) {
+ void * tmpBuf1;
+ void * tmpBuf2;
+ uInt32 xWidth, count;
+ if (!ogAvail()) return;
+ xWidth = (maxX+1)*((BPP+7) >> 3);
+ tmpBuf1 = kmalloc(xWidth,-2);
+ tmpBuf2 = kmalloc(xWidth,-2);
+ if ((tmpBuf1!=NULL) && (tmpBuf2!=NULL))
+ for (count=0; count<=(maxY/2); count++) {
+ ogCopyLineFrom(0,count,tmpBuf1,xWidth);
+ ogCopyLineFrom(0,maxY-count,tmpBuf2,xWidth);
+ ogCopyLineTo(0,maxY-count,tmpBuf1,xWidth);
+ ogCopyLineTo(0,count,tmpBuf2,xWidth);
+// kmemcpy(tmpBuf,((uInt8*)buffer+lineOfs[count]),xWidth);
+// kmemcpy(((uInt8*)buffer+lineOfs[count]),
+// ((uInt8*)buffer+lineOfs[maxY-count]),
+// xWidth);
+// kmemcpy(((uInt8*)buffer+lineOfs[maxY-count]),tmpBuf,xWidth);
+ } // for
+ kfree(tmpBuf2);
+ kfree(tmpBuf1);
+ return;
+} // ogSurface::ogHFlip
+
+void
+ogSurface::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) {
+ int32 tmp;
+
+ if (!ogAvail()) return;
+ if ((uInt32)y>maxY) return;
+ if (x1>x2) {
+ tmp= x1;
+ x1 = x2;
+ x2 = tmp;
+ } // if
+ if (x1<0) x1 = 0;
+ if (x2>(int32)maxX) x2=maxX;
+ if (x2> redShifter) << redFieldPosition |
+ (green >> greenShifter) << greenFieldPosition |
+ (blue >> blueShifter) << blueFieldPosition;
+ break;
+ case 24:
+ case 32:
+ colour = ( (red << redFieldPosition) |
+ (green << greenFieldPosition) |
+ (blue << blueFieldPosition) );
+ } // switch
+ //asm("": "=a" (lastclr));
+ return colour;
+} // ogSurface::ogRGB
+
+bool
+ogSurface::ogSavePal(const char *palfile) {
+ fileDescriptor * f;
+ uInt32 lresult;
+ if (pal==NULL) return false;
+ if ((f = fopen(palfile, "wb"))==NULL) return false;
+ lresult = fwrite(pal,sizeof(ogRGBA),256,f);
+ fclose(f);
+ return (lresult == 256);
+} // ogSurface::ogSavePal
+
+void
+ogSurface::ogScale(ogSurface& SrcObject) {
+ ogScaleBuf(0,0,maxX,maxY,SrcObject,0,0,SrcObject.maxX,SrcObject.maxY);
+ return;
+} // ogSurface::ogScale
+
+void
+ogSurface::ogScaleBuf(int32 dX1, int32 dY1, int32 dX2, int32 dY2,
+ ogSurface& SrcObject,
+ int32 sX1, int32 sY1, int32 sX2, int32 sY2) {
+
+ uInt32 sWidth, dWidth;
+ uInt32 sHeight, dHeight;
+ int32 sx, sy, xx, yy;
+ uInt32 xInc, yInc;
+ uInt32 origdX1, origdY1;
+ ogPixelFmt pixFmt;
+ ogSurface * tmpBuf;
+ ogSurface * sBuf;
+ ogSurface * dBuf;
+ bool doCopyBuf;
+ uInt8 scaleBPP;
+
+ origdX1 = origdY1 = 0; // to keep the compiler from generating a warning
+
+ if (!ogAvail()) return;
+ if (!SrcObject.ogAvail()) return;
+
+ if (sX1>sX2) {
+ xx = sX1;
+ sX1= sX2;
+ sX2= xx;
+ }
+
+ if (sY1>sY2) {
+ yy = sY1;
+ sY1= sY2;
+ sY2= yy;
+ }
+
+ // if any part of the source falls outside the buffer then don't do anything
+
+ if (((uInt32)sX1>SrcObject.maxX) || ((uInt32)sX2>SrcObject.maxX) ||
+ ((uInt32)sY1>SrcObject.maxY) || ((uInt32)sY2>SrcObject.maxY)) return;
+
+ if (dX1>dX2) {
+ xx = dX1;
+ dX1= dX1;
+ dX2= xx;
+ }
+
+ if (dY1>dY2) {
+ yy = dY1;
+ dY1= dY2;
+ dY2= yy;
+ }
+
+ dWidth = (dX2-dX1)+1;
+ if (dWidth<=0) return;
+
+ dHeight = (dY2-dY1)+1;
+ if (dHeight<=0) return;
+
+ sWidth = (sX2-sX1)+1;
+ sHeight = (sY2-sY1)+1;
+
+ // convert into 16:16 fixed point ratio
+ xInc = (sWidth << 16) / dWidth;
+ yInc = (sHeight << 16) / dHeight;
+
+ if (dX2>(int32)maxX) {
+ xx = (xInc*(dX1-maxX)) >> 16;
+ sX1 -= xx;
+ sWidth -= xx;
+ dWidth -= (dX1-maxX);
+ dX1 = maxX;
+ }
+
+ if (dY2>(int32)maxY) {
+ yy = (yInc*(dY2-maxY)) >> 16;
+ sY2 -= yy;
+ sHeight -= yy;
+ dHeight -= (dY2-maxY);
+ dY2 = maxY;
+ }
+
+ if (dX1<0) {
+ xx = (xInc*(-dX1)) >> 16;
+ sX1 += xx;
+ sWidth -= xx;
+ dWidth += dX1;
+ dX1 = 0;
+ }
+
+ if (dY1<0) {
+ yy = (yInc*(-dY1)) >> 16;
+ sY1 += yy;
+ sHeight -= yy;
+ dHeight += dY1;
+ dY1 = 0;
+ }
+
+ if ((dWidth<=0) || (dHeight<=0)) return;
+ if ((sWidth<=0) || (sHeight<=0)) return;
+
+ // Do a quick check to see if the scale is 1:1 .. in that case just copy
+ // the image
+
+ if ((dWidth==sWidth) && (dHeight==sHeight)) {
+ ogCopyBuf(dX1,dY1,SrcObject,sX1,sY1,sX2,sY2);
+ return;
+ }
+
+ tmpBuf = NULL;
+
+ /*
+ * Alright.. this is how we're going to optimize the case of different
+ * pixel formats. We are going to use copyBuf() to automagically do
+ * the conversion for us using tmpBuf. Here's how it works:
+ * If the source buffer is smaller than the dest buffer (ie, we're making
+ * something bigger) we will convert the source buffer first into the dest
+ * buffer's pixel format. Then we do the scaling.
+ * If the source buffer is larger than the dest buffer (ie, we're making
+ * something smaller) we will scale first and then use copyBuf to do
+ * the conversion.
+ * This method puts the onus of conversion on the copyBuf() function which,
+ * while not excessively fast, does the job.
+ * The case in which the source and dest are the same size is handled above.
+ *
+ */
+
+ if ( (BPP!=SrcObject.BPP) || (redShifter!=SrcObject.redShifter) ||
+ (blueShifter!=SrcObject.blueShifter) ||
+ (greenShifter!=SrcObject.greenShifter)) {
+ tmpBuf = new ogSurface();
+ if (tmpBuf==NULL) return;
+ if (sWidth*sHeight*((SrcObject.BPP+7)>>3)<=dWidth*dHeight*((BPP+7)>>3)) {
+ // if the number of pixels in the source buffer is less than the
+ // number of pixels in the dest buffer then...
+ ogGetPixFmt(pixFmt);
+ if (tmpBuf->ogCreate(sWidth,sHeight,pixFmt)==false) return;
+ tmpBuf->ogCopyPal(SrcObject);
+ tmpBuf->ogCopyBuf(0,0,SrcObject,sX1,sY1,sX2,sY2);
+ sX2 -= sX1;
+ sY2 -= sY1;
+ sX1 = 0;
+ sY1 = 0;
+ sBuf = tmpBuf;
+ dBuf = this;
+ doCopyBuf = false; // do we do a copyBuf later?
+ scaleBPP = BPP;
+ } else {
+ SrcObject.ogGetPixFmt(pixFmt);
+ if (tmpBuf->ogCreate(dWidth,dHeight,pixFmt)==false) return;
+// tmpBuf->ogCopyPal(&this);
+ origdX1 = dX1;
+ origdY1 = dY1;
+ dX1 = 0;
+ dY1 = 0;
+ dX2 = tmpBuf->maxX;
+ dY2 = tmpBuf->maxY;
+ sBuf = &SrcObject;
+ dBuf = tmpBuf;
+ doCopyBuf = true;
+ scaleBPP = SrcObject.BPP;
+ } // else
+ } else {
+ // pixel formats are identical
+ sBuf = &SrcObject;
+ dBuf = this;
+ doCopyBuf = false;
+ scaleBPP = BPP;
+ } // else
+
+ sy = sY1 << 16;
+
+ for (yy = dY1; yy <=dY2; yy++) {
+ sx = 0;
+ for (xx = dX1; xx <= dX2; xx++) {
+ dBuf->rawSetPixel(xx,yy,sBuf->rawGetPixel(sX1+(sx >> 16),(sy>>16)));
+ sx+=xInc;
+ } // for xx
+ sy += yInc;
+ } // for yy
+
+ if ((doCopyBuf) && (tmpBuf!=NULL))
+ ogCopyBuf(origdX1,origdY1,*tmpBuf,0,0,tmpBuf->maxX,tmpBuf->maxY);
+ delete tmpBuf;
+ return;
+} // ogSurface::ogScaleBuf
+
+void
+ogSurface::ogSendSDE(uInt32 command) {
+ asm(
+ "int %0"
+ :
+ : "i" (0x80),"a" (40),"b" (command),"c" (this)
+ );
+ return;
+} // ogSurface::ogSendSDE
+
+bool
+ogSurface::ogSetAntiAlias(bool _AntiAlias) {
+ bool tmp;
+ tmp = antiAlias;
+ antiAlias = _AntiAlias;
+ return tmp;
+} // ogSurface::ogSetAntiAlias
+
+void
+ogSurface::ogSetPixel(int32 x, int32 y, uInt32 colour) {
+ if (!ogAvail()) return;
+// if ((buffer==NULL) || (lineOfs==NULL)) return;
+ if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4]
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%al, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " mov %3, %%eax \n" // mov eax, colour
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "m" (colour) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size}
+ // { Draw the pixel }
+ " mov %%ax, (%%edi) \n" // mov [edi], ax
+ " shr $16, %%eax \n" // shr eax, 16
+ " mov %%al, 2(%%edi)\n" // mov [edi+2],al
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ break;
+ case 32:
+ __asm__ __volatile__(
+ // { Calculate offset, prepare the pixel to be drawn }
+ " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size}
+ " add %%esi, %%edi \n" // add edi, esi
+ " add %%ecx, %%edi \n" // add edi, ecx
+ // { Draw the pixel }
+ " mov %%eax, (%%edi) \n" // mov [edi], eax
+ :
+ : "D" (buffer), "S" (lineOfs[y]), // %0, %1
+ "c" (x), "a" (colour) // %2, %3
+ );
+ } // switch
+ return;
+} // ogSurface::ogSetPixel
+
+void
+ogSurface::ogSetRGBPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) {
+ if (pal==NULL) return;
+ pal[colour].red = red;
+ pal[colour].green = green;
+ pal[colour].blue = blue;
+ return;
+} // ogSurface::ogSetRGBPalette
+
+uInt32
+ogSurface::ogSetTransparentColor(uInt32 colour) {
+ uInt32 tmp;
+ tmp = transparentColor;
+ transparentColor = colour;
+ return tmp;
+} // ogSurface::ogSetTransparentColor
+
+static double f(double g) { return g*g*g-g; }
+
+void
+ogSurface::ogSpline(uInt32 numPoints, ogPoint* points, uInt32 segments,
+ uInt32 colour) {
+ int32 i, oldY, oldX, x, y, j;
+ float part, t, xx, yy, tmp;
+ float * zc;
+ float * dx;
+ float * dy;
+ float * u;
+ float * wndX1;
+ float * wndY1;
+ float * px;
+ float * py;
+
+ bool runOnce;
+ if ((numPoints<2) || (points==NULL)) return;
+ zc = new float[numPoints];
+ dx = new float[numPoints];
+ dy = new float[numPoints];
+ u = new float[numPoints];
+ wndX1 = new float[numPoints];
+ wndY1 = new float[numPoints];
+ px = new float[numPoints];
+ py = new float[numPoints];
+ if ((zc==NULL) || (dx==NULL) || (dy==NULL) || (wndX1==NULL) ||
+ (wndY1==NULL) || (px==NULL) || (py==NULL)) goto safeexit;
+
+ for (i = 0; (uInt32)i0; i--) {
+ py[i] = (wndY1[i]-u[i]*py[i+1])/dy[i];
+ px[i] = (wndX1[i]-u[i]*px[i+1])/dx[i];
+ } // for
+
+ for (i = 0; (uInt32)i < numPoints-1; i++) {
+ for (j = 0; (uInt32)j <= segments; j++) {
+ part = zc[i]-(((zc[i]-zc[i+1])/segments)*j);
+ t = (part-zc[i])/u[i];
+ part = t * points[i+1].y +
+ (1.0-t)*points[i].y +
+ u[i] * u[i] * ( f(t) * py[i+1] + f(1.0-t) * py[i]) /6.0;
+// y = Round(part);
+ y = ROUND(part+0.5f);
+ part = zc[i]-(((zc[i]-zc[i+1])/segments)*j);
+ t = (part-zc[i])/u[i];
+ part = t*points[i+1].x+(1.0-t)*points[i].x+u[i]*u[i]*(f(t)*px[i+1]+
+ f(1.0-t)*px[i])/6.0;
+
+// x = Round(part);
+ x = ROUND(part+0.5f);
+ if (runOnce) ogLine(oldX, oldY, x, y, colour); else runOnce = true;
+ oldX = x;
+ oldY = y;
+ } // for j
+ } // for i
+safeexit:
+ delete [] py;
+ delete [] px;
+ delete [] wndY1;
+ delete [] wndX1;
+ delete [] u;
+ delete [] dy;
+ delete [] dx;
+ delete [] zc;
+
+ return;
+} // ogSurface::ogSpline
+
+
+void
+ogSurface::ogTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3,
+ uInt32 colour) {
+ ogLine(x1,y1,x2,y2,colour);
+ ogLine(x2,y2,x3,y3,colour);
+ ogLine(x3,y3,x1,y1,colour);
+ return;
+} // ogSurface::ogTriangle
+
+void
+ogSurface::ogUnpackRGB(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) {
+ switch (BPP) {
+ case 8:
+ if (pal==NULL) {
+ red = 0;
+ green = 0;
+ blue = 0;
+ return;
+ }
+ if (colour>255) colour &= 255;
+ red = pal[colour].red;
+ green = pal[colour].green;
+ blue = pal[colour].blue;
+ break;
+ case 15:
+ case 16:
+ red = ((colour >> redFieldPosition) << redShifter);
+ green = ((colour >> greenFieldPosition) << greenShifter);
+ blue = ((colour >> blueFieldPosition) << blueShifter);
+ if ((red) && (redShifter)) red+=(1 << redShifter)-1;
+ if ((green) && (greenShifter)) green+=(1 << greenShifter)-1;
+ if ((blue) && (blueShifter)) blue+=(1 << blueShifter)-1;
+ break;
+ case 24:
+ case 32:
+ red = colour >> redFieldPosition;
+ green = colour >> greenFieldPosition;
+ blue = colour >> blueFieldPosition;
+ break;
+ default:
+ red = 0;
+ green = 0;
+ blue = 0;
+ }
+ return;
+} // ogSurface::ogUnpackRGB
+
+void
+ogSurface::ogVFlip(void) {
+ if (!ogAvail()) return;
+// if ((buffer==NULL) || (lineOfs==NULL)) return;
+ switch (BPP) {
+ case 8:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf8lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf8lop2: \n"
+ " mov (%%edi),%%al \n" // mov al, [edi]
+ " mov (%%esi),%%ah \n" // mov ah, [esi]
+ " mov %%al,(%%esi) \n" // mov [esi], al
+ " mov %%ah,(%%edi) \n" // mov [edi], ah
+ " inc %%edi \n" // inc edi
+ " dec %%esi \n" // dec esi
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf8lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf8lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1
+ "b" (xRes), "d" (maxY+1) // %2, %3
+ );
+ break;
+ case 15:
+ case 16:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf16lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf16lop2: \n"
+ " mov (%%edi),%%ax \n" // mov ax, [edi]
+ " mov (%%esi),%%cx \n" // mov cx, [esi]
+ " mov %%ax,(%%esi) \n" // mov [esi], ax
+ " mov %%cx,(%%edi) \n" // mov [edi], cx
+ " add $2, %%edi \n" // add edi, 2
+ " sub $2, %%esi \n" // sub esi, 2
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf16lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf16lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1
+ "b" (xRes), "d" (maxY+1) // %2, %3
+ );
+ break;
+ case 24:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf24lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf24lop2: \n"
+ " mov (%%edi),%%ax \n" // mov ax, [edi]
+ " mov 2(%%edi),%%dl \n" // mov dl, [edi+2]
+ " mov (%%esi),%%cx \n" // mov cx, [esi]
+ " mov 2(%%esi),%%dh \n" // mov dh, [esi+2]
+ " mov %%ax,(%%esi) \n" // mov [esi], ax
+ " mov %%dl,2(%%esi) \n" // mov [esi+2], dl
+ " mov %%cx,(%%edi) \n" // mov [edi], cx
+ " mov %%dh,2(%%edi) \n" // mov [edi+2], dh
+ " add $3, %%edi \n" // add edi, 3
+ " sub $3, %%esi \n" // sub esi, 3
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf24lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " decl %3 \n" // dec height
+ " jnz vf24lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1
+ "b" (xRes), "m" (maxY+1) // %2, %3
+ );
+ break;
+
+ case 32:
+ __asm__ __volatile__(
+ " add %%edi, %%esi \n" // add esi, edi
+ "vf32lop: \n"
+ " push %%esi \n" // push esi
+ " push %%edi \n" // push edi
+ "vf32lop2: \n"
+ " mov (%%edi),%%eax \n" // mov eax, [edi]
+ " mov (%%esi),%%ecx \n" // mov ecx, [esi]
+ " mov %%eax,(%%esi) \n" // mov [esi], eax
+ " mov %%ecx,(%%edi) \n" // mov [edi], ecx
+ " add $4, %%edi \n" // add edi, 4
+ " sub $4, %%esi \n" // sub esi, 4
+ " cmp %%esi, %%edi \n" // cmp edi, esi
+ " jbe vf32lop2 \n"
+ " pop %%edi \n" // pop edi
+ " pop %%esi \n" // pop esi
+ " add %%ebx, %%esi \n" // add esi, ebx
+ " add %%ebx, %%edi \n" // add edi, ebx
+ " dec %%edx \n"
+ " jnz vf32lop \n"
+ :
+ : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1
+ "b" (xRes), "d" (maxY+1) // %2, %3
+ );
+
+ } // switch
+ return;
+} // ogSurface::ogVFlip
+
+void
+ogSurface::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) {
+ int32 tmp;
+ if (!ogAvail()) return;
+ if ((uInt32)x>maxX) return;
+ if (y1>y2) {
+ tmp= y1;
+ y1 = y2;
+ y2 = tmp;
+ } // if
+ if (y1<0) y1 = 0;
+ if (y2>(int32)maxY) y2 = maxY;
+ if (y2
+#include
+#include
+
+struct devFsDevices {
+ struct devFsDevices *next;
+ struct devFsDevices *prev;
+ uInt8 devType;
+ uInt16 devMajor;
+ uInt16 devMinor;
+ char devName[32];
+ };
+
+struct devFsInfo {
+ struct devFsDevices *deviceList;
+ };
+
+int openFileDevFS(char *file,fileDescriptor *fd);
+void initDevFS(struct mountPoints *mp);
+int enableDevFS();
+int readDevFS(fileDescriptor *fd,char *data,long offset,long size);
+int writeDevFS(fileDescriptor *fd,char *data,long offset,long size);
+int devFsMkNod(char *name,uInt8 type,uInt16 major,uInt16 minor);
+
+#endif
diff --git a/lockwasher/src/sys/include/deviceman/bus.h b/lockwasher/src/sys/include/deviceman/bus.h
new file mode 100644
index 0000000..b5384dd
--- /dev/null
+++ b/lockwasher/src/sys/include/deviceman/bus.h
@@ -0,0 +1,20 @@
+/*
+ "bus.h"
+
+ created by: grayspace aka J. Leveille
+ for: UbixOS Project
+ date: May 11, 2002
+
+ purpose: master header file for all things BUS related
+
+ $Id: bus.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $
+*/
+
+#ifndef _BUS_H
+#define _BUS_H
+
+#include "bus_resources.h"
+
+
+
+#endif /* _BUS_H */
\ No newline at end of file
diff --git a/lockwasher/src/sys/include/deviceman/bus_resources.h b/lockwasher/src/sys/include/deviceman/bus_resources.h
new file mode 100644
index 0000000..9485941
--- /dev/null
+++ b/lockwasher/src/sys/include/deviceman/bus_resources.h
@@ -0,0 +1,266 @@
+/*
+ "bus_resources.h"
+
+ created by: grayspace aka J. Leveille
+ for: UbixOS Project
+ date: May 12, 2002
+
+ purpose: master header file for bus resource management
+
+ $Id: bus_resources.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $
+*/
+
+#ifndef _BUS_RESOURCES_H
+#define _BUS_RESOURCES_H
+
+/* Intel 32-bit architecture */
+#if TCPU_IA32
+
+/* DMA channels */
+#define MIN_DMA_CHANNEL (0)
+#define MAX_DMA_CHANNEL (7)
+#define NUM_DMA_CHANNELS (MAX_DMA_CHANNEL - MIN_DMA_CHANNEL - 1)
+
+/* IRQs */
+#define MIN_IRQ (0)
+#define MAX_IRQ (15)
+#define NUM_IRQS (MAX_IRQ - MIN_IRQ - 1)
+
+/* Port IO Range */
+#define MIN_PORTIO_ADDR (0)
+#define MAX_PORTIO_ADDR (1023)
+#define MAXBITS_PORTIO_ADDR (10)
+
+/* Memory Range */
+#define MIN_MEMIO_ADDR (0)
+#define MAX_MEMIO_ADDR (0xFFFFFFFF)
+#define MAXBITS_MEMIO_ADDR (32)
+
+/* NOTE: 'BI_' denotes roughly something related to BUS info */
+
+/* for building/use-with device-info/bus-resource-info structures */
+#define BI_NUMBITS_IRQS (4)
+#define BI_NUMBITS_DMA_CHANNELS (3)
+#define BI_IRQ_BIT (0)
+#define BI_DMA_CHANNEL_BIT (BI_IRQ_BIT + BI_NUMBITS_IRQS)
+
+#define BI_IRQ_MASK\
+ MAKEMASK_GS( BI_NUMBITS_IRQS, BI_IRQ_BIT )
+#define BI_DMA_CHANNEL_MASK\
+ MAKEMASK_GS( BI_NUMBITS_DMA_CHANNELS, BI_DMA_CHANNEL_BIT )
+
+#define BI_NUMBITS_PORTIO_BASEADDR (16)
+#define BI_NUMBITS_PORTIO_OVERADDR (16)
+#define BI_PORTIO_BASEADDR_BIT (0)
+#define BI_PORTIO_OVERADDR_BIT ( BI_PORTIO_BASEADDR_BIT\
+ + BI_NUMBITS_PORTIO_BASEADDR )
+#define BI_PORTIO_BASEADDR_MASK\
+ MAKEMASK_GS( BI_NUMBITS_PORTIO_BASEADDR, BI_PORTIO_BASEADDR_BIT )
+#define BI_PORTIO_OVERADDR_MASK\
+ MAKEMASK_GS( BI_NUMBITS_PORTIO_OVERADDR, BI_PORTIO_OVERADDR_BIT )
+
+/* maximum number of DMAs and IRQs a device can use
+ NOTE: *must* be same */
+#define BI_MAX_DMAANDIRQS (2)
+#define BI_MAX_DMAS (BI_MAX_DMAANDIRQS)
+#define BI_MAX_IRQS (BI_MAX_DMAANDIRQS)
+
+/* maximum number of Port IO ranges a device can use */
+#define BI_MAX_PORTIO_RANGES (4)
+
+/* maximum number of Memory IO ranges a device can use */
+#define BI_MAX_MEMIO_RANGES (4)
+
+/* structure for storing a device's bus resources */
+typedef struct tagBUS_RESOURCES
+{
+ /* DMA and IRQ info */
+ BYTEg a_dmairq[BI_MAX_DMAANDIRQS];
+
+ /*
+ bits [0,1] number of IRQs used
+ bits [2,3] number of DMA channels used
+ bits [4,7] number of port IO ranges used
+ */
+ BYTEg resource_counts1;
+
+ /*
+ bits [0,3] number of memory ranges used
+ bits [4,7] ???
+ */
+ BYTEg resource_counts2;
+
+ /* Port IO Ranges */
+ DWORDg a_portiorange[BI_MAX_PORTIO_RANGES];
+
+ /* Memory IO Ranges */
+ DWORDg a_memiorange_base[BI_MAX_MEMIO_RANGES];
+ DWORDg a_memiorange_last[BI_MAX_MEMIO_RANGES];
+}
+BUS_RESOURCES;
+
+/* NOTE: 'BUS_RES' denotes interface functions/macros on
+ the 'BUS_RESOURCES' structure */
+
+#if (BI_IRQ_BIT == 0)
+ /* get IRQ 'idx' from resource description 'br' */
+ #define BUS_RES_GETIRQ( br, idx ) ((br).a_dmairq[(idx)]&BI_IRQ_MASK)
+
+ /* set IRQ 'idx' in resource description 'br' to 'irq' */
+ #define BUS_RES_SETIRQ( br, idx, irq )\
+ (br).a_dmairq[(idx)] &= BI_IRQ_MASK;\
+ (br).a_dmairq[(idx)] |= (irq)
+#else
+ /* get IRQ 'idx' from resource description 'br' */
+ #define BUS_RES_GETIRQ( br, idx )\
+ GETBITVAL_GS( (br).a_dmairq[(idx)], BI_IRQ_MASK, BI_IRQ_BIT )
+
+ /* set IRQ 'idx' in resource description 'br' to 'irq' */
+ #define BUS_RES_SETIRQ( br, idx, irq )\
+ SETBITVAL_FAST_GS( (br).a_dmairq[(idx)],\
+ BI_IRQ_MASK,\
+ BI_IRQ_BIT,\
+ (irq) )
+#endif
+
+/* get DMA 'idx' from resource description 'br' */
+#define BUS_RES_GETDMA( br, idx )\
+ GETBITVAL_GS( (br).a_dmairq[(idx)], BI_DMA_MASK, BI_DMA_BIT )
+
+/* set DMA 'idx' in resource description 'br' to 'dma' */
+#define BUS_RES_SETDMA( br, idx, dma )\
+ SETBITVAL_FAST_GS( (br).a_dmairq[(idx)],\
+ BI_DMA_MASK,\
+ BI_DMA_BIT,\
+ (dma) )
+
+#if (BI_PORTIO_BASEADDR_BIT == 0) && (BI_PORTIO_OVERADDR_BIT == BI_NUMBITS_PORTIO_BASEADDR )
+ /* get port IO base address 'idx' from resource description 'br' */
+ #define BUS_RES_GETPORTIOBASE( br, idx )\
+ ((br).a_portiorange[(idx)]&BI_PORTIO_BASEADDR_MASK)
+
+ /* get port IO 'over' address 'idx' from resource description 'br' */
+ #define BUS_RES_GETPORTIOOVER( br, idx )\
+ ((br).a_portiorange[(idx)]>>BI_PORTIO_OVERADDR_BIT)
+
+ /* get port IO range 'idx' from resource description 'br'
+ into 'baseaddr_o' and 'overaddr_o' */
+ #define BUS_RES_GETPORTIORANGE( br, idx, baseaddr_o, overaddr_o )\
+ (baseaddr_o)\
+ = ((br).a_portiorange[(idx)] & BI_PORTIO_BASEADDR_MASK);\
+ (overaddr_o)\
+ = ((br).a_portiorange[(idx)] >> BI_PORTIO_OVERADDR_BIT)
+
+ /* set port IO range 'idx' in resource description 'br'
+ to 'baseaddr' and 'overaddr' */
+ #define BUS_RES_SETPORTIORANGE( br, idx, baseaddr, overaddr )\
+ ((br).a_portiorange[(idx)]\
+ = ((overaddr)<>2)
+/* set number of IRQs used/assigned-to device */
+#define BUS_RES_SETIRQSUSED( br, irqsused )\
+ (br).resource_counts1 &= ~0x0C;\
+ (br).resource_counts1 |= ((irqsused)<<2)
+
+/* get number of DMAs used/assigned-to device */
+#define BUS_RES_GETDMASUSED( br )\
+ ((br).resource_counts1 & 3)
+/* set number of DMAs used/assigned-to device */
+#define BUS_RES_SETDMASUSED( br, dmasused )\
+ (br).resource_counts1 &= ~3;\
+ (br).resource_counts1 |= (dmasused)
+
+/* get number of port IO ranges used/assigned-to device */
+#define BUS_RES_GETPORTIORANGESUSED( br )\
+ (((br).resource_counts1)>>4)
+/* get number of port IO ranges used/assigned-to device */
+#define BUS_RES_SETPORTIORANGESUSED( br, rangesused )\
+ (br).resource_counts1 &= 0x0F;\
+ (br).resource_counts1 |= ((rangesused)<<4)
+
+/* get number of port IO ranges used/assigned-to device */
+#define BUS_RES_GETMEMIORANGESUSED( br )\
+ (((br).resource_counts2) & 0x0F)
+/* get number of port IO ranges used/assigned-to device */
+#define BUS_RES_SETMEMIORANGESUSED( br, rangesused )\
+ (br).resource_counts2 &= 0xF0;\
+ (br).resource_counts2 |= (rangesused)
+
+#else /* #if TCPU_IA32 */
+
+#error unknown target CPU!!!
+
+#endif /* #if TCPU_??? */
+
+#include "bus_resources_portio.h"
+
+#endif /* _BUS_RESOURCES_H */
\ No newline at end of file
diff --git a/lockwasher/src/sys/include/deviceman/bus_resources_portio.h b/lockwasher/src/sys/include/deviceman/bus_resources_portio.h
new file mode 100644
index 0000000..82d417d
--- /dev/null
+++ b/lockwasher/src/sys/include/deviceman/bus_resources_portio.h
@@ -0,0 +1,47 @@
+/*
+ "bus_resources_portio.h"
+
+ created by: grayspace aka J. Leveille
+ for: UbixOS Project
+ date: May 12, 2002
+
+ purpose: for port IO resource management
+
+ $Id: bus_resources_portio.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $
+*/
+
+#ifndef _BUS_RESOURCES_PORTIO_H
+#define _BUS_RESOURCES_PORTIO_H
+
+/* for managing port IO ranges */
+typedef struct tagBUS_PORTIO_POOL
+{
+ DWORDg a_addrs[(1<<(MAXBITS_PORTIO_ADDR-5))];
+}
+BUS_PORTIO_POOL;
+
+/* checks a range of port addresses
+ returns:
+ - 1 if the range is comptetely empty
+ - 0 otherwise */
+int BUS_PORTIO_CheckRange( BUS_PORTIO_POOL * p_bpp,
+ DWORDg baseaddr,
+ DWORDg overaddr );
+
+/* allocates a range of port addresses
+ returns:
+ - 1 on success
+ - 0 on failure */
+int BUS_PORTIO_AllocateRange( BUS_PORTIO_POOL * p_bpp,
+ DWORDg baseaddr,
+ DWORDg overaddr );
+
+/* frees a range of port addresses
+ returns:
+ - 1 if any port addresses in the range were allocated
+ - 0 otherwise */
+int BUS_PORTIO_FreeRange( BUS_PORTIO_POOL * p_bpp,
+ DWORDg baseaddr,
+ DWORDg overaddr );
+
+#endif /* _BUS_RESOURCES_PORTIO_H */
\ No newline at end of file
diff --git a/lockwasher/src/sys/include/deviceman/device.h b/lockwasher/src/sys/include/deviceman/device.h
new file mode 100644
index 0000000..19dd403
--- /dev/null
+++ b/lockwasher/src/sys/include/deviceman/device.h
@@ -0,0 +1,114 @@
+/*
+ "device.h"
+
+ created by: grayspace aka J. Leveille
+ for: UbixOS Project
+ date: May 11, 2002
+
+ purpose: master header file for all things device related
+
+ $Id: device.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $
+*/
+
+#ifndef _DEVICE_H
+#define _DEVICE_H
+
+// maximum length of a device's name
+#define MAX_DEVICE_NAMELEN (16)
+
+// maximum number of bus devices allowed
+#define MAX_BUS_DEVICES (16)
+
+/* device types (for now, only bus devices allowed) */
+#define DEVICE_TYPE_UNKNOWN (0)
+#define DEVICE_TYPE_BUS_ISA (1)
+#define DEVICE_TYPE_BUS_PCI (2)
+
+/* device classes */
+#define DEVICE_CLASS_GENERIC (0)
+#define DEVICE_CLASS_SOUND_DAC (1)
+#define DEVICE_CLASS_VIDEO (2)
+#define DEVICE_CLASS_NIC (3)
+#define DEVICE_CLASS_DISK_CTLR (4)
+#define DEVICE_CLASS_DISK (5)
+
+/* string names for devices classes
+ (for use in device list configuration files) */
+#define DEVICE_CLASS_GENERIC_IDSTR "GENERIC"
+#define DEVICE_CLASS_SOUND_DAC_IDSTR "SOUND_DAC"
+#define DEVICE_CLASS_VIDEO_IDSTR "VIDEO"
+#define DEVICE_CLASS_NIC_IDSTR "NIC"
+#define DEVICE_CLASS_DISK_CTLR_IDSTR "DISK_CTLR"
+#define DEVICE_CLASS_DISK_IDSTR "DISK"
+
+/* string names for devices classes
+ (for display to the user) */
+#define DEVICE_CLASS_GENERIC_NAME "Generic Device"
+#define DEVICE_CLASS_SOUND_DAC_NAME "Sound (Digital-Ananlog Output)"
+#define DEVICE_CLASS_VIDEO_NAME "Video Card"
+#define DEVICE_CLASS_NIC_NAME "Network Card"
+#define DEVICE_CLASS_DISK_CTLR_NAME "Disk Controller"
+#define DEVICE_CLASS_DISK_NAME "Disk Device"
+
+/* device ISR or pseudo ISR */
+typedef int (* DEVICE_ISR)( void * p );
+
+/* device IO routine */
+typedef int (* DEVICE_IO_RTN)( void * p );
+
+/* device control routine */
+typedef int (* DEVICE_CTRL_RTN)( void * p );
+
+/* ISA bus device structure */
+typedef struct tagDEVICE_ISA
+{
+ /* bus resources assigned to device */
+ BUS_RESOURCES br;
+
+ /* ISRs for device */
+ DEVICE_ISR * apfn_isr[BI_MAX_IRQS];
+
+ /* device IO routine (kernel/driver use only) */
+ DEVICE_IO_RTN pfn_io;
+
+ /* device control routine (kernel/driver use only) */
+ DEVICE_CTRL_RTN pfn_ctrl;
+}
+DEVICE_BUS_ISA;
+
+/* PCI bus device structure */
+/* TODO */
+typedef struct tagDEVICE_BUS_PCI
+{
+ int dummy;
+}
+DEVICE_BUS_PCI;
+
+/* bus device structure */
+typedef union tagDEVICE_BUS
+{
+ DEVICE_BUS_ISA isa;
+ DEVICE_BUS_PCI pci;
+}
+DEVICE_BUS;
+
+/* device structure */
+typedef struct tagDEVICE
+{
+ /* type of device */
+ BYTEg type;
+
+ /* pointer to actual device specific structure */
+ void * p;
+}
+DEVICE;
+
+/* global kernel structure for device information */
+typedef struct tagDEVICES
+{
+ /* bus devices */
+ DEVICE a_isa[MAX_BUS_DEVICES];
+}
+DEVICES;
+
+#endif /* _DEVICE_H */
\ No newline at end of file
diff --git a/lockwasher/src/sys/include/deviceman/isapnp.h b/lockwasher/src/sys/include/deviceman/isapnp.h
new file mode 100644
index 0000000..a1fea0f
--- /dev/null
+++ b/lockwasher/src/sys/include/deviceman/isapnp.h
@@ -0,0 +1,86 @@
+/*
+ "isapnp.h"
+
+ created by: grayspace aka J. Leveille
+ for: UbixOS Project
+ date: May 12, 2002
+
+ Purpose: ISA PNP support
+
+ $Id: isapnp.h,v 1.1.1.1 2003/01/12 00:20:19 reddawg Exp $
+*/
+
+#ifndef _ISAPNP_H
+#define _ISAPNP_H
+
+#include "misc_string_conv.h"
+
+/* structure for holding an ISA-PNP device ID */
+typedef struct tagISAPNP_ID
+{
+ WORDg text;
+ BYTEg a_hex[2];
+}
+ISAPNP_ID;
+
+/* structure for holding configuration file info about a
+ particular ISA-PNP device */
+typedef struct tagISAPNP_DEV_INFO
+{
+ /* 'class' of device */
+ BYTEg devclass;
+
+ /* device ID */
+ ISAPNP_ID id;
+
+ /* kernal string ID of description */
+ DWORDg descID;
+}
+ISAPNP_DEV_INFO;
+
+/* structure for holding device info database
+ NOTE: should be sorted by 'id' */
+typedef struct tagISAPNP_DEV_INFO_DB
+{
+ // pointer to infos
+ ISAPNP_DEV_INFO * p_infos;
+
+ // number of infos
+ int numinfos;
+}
+ISAPNP_DEV_INFO_DB;
+
+/* fill a 'ISAPNP_ID' struct from four bytes assumed to be in little endian
+ format */
+#define ISAPNP_ID_FROMBYTES( dst_id, p_bytes )\
+ (dst_id).text = (WORDg) (((DWORDg) (p_bytes)[1])<<8);\
+ (dst_id).text |= (WORDg) (p_bytes)[1]
+
+/*
+ NOTE:
+ - in 'id.text'
+ - bits [10,14] are first character - 64
+ - bits [5,9] are second character - 64
+ - bits [0,4] are third character - 64
+*/
+#define ISAPNP_ID_GETSTRING( p_dststr, id )\
+ (p_dststr)[0] = (((id).text >> 10)&0x1F) + 64;\
+ (p_dststr)[1] = (((id).text >> 5)&0x1F) + 64;\
+ (p_dststr)[2] = ((id).text&0x1F) + 64;\
+ HEX_GETSTRING_BYTE_NONULL( p_dst_str + 3, (id).a_hex[1] );\
+ HEX_GETSTRING_BYTE( p_dst_str + 5, (id).a_hex[0] )
+
+#define ACCESS_FUNC_PORT "movl %edx, $0x279\n\t"
+#define ACCESS_DATA_PORT "movl %edx, $0x2A9\n\t"
+#define FUNC_SETREADPORT "movb $0x00, %al\n\toutb %dx, %al\n\t"
+#define FUNC_ISOLATION "movb $0x01, %al\n\toutb %dx, %al\n\t"
+#define FUNC_CONFIGCONTROL "movb $0x02, %al\n\toutb %dx, %al\n\t"
+#define FUNC_WAKEUP "movb $0x03, %al\n\toutb %dx, %al\n\t"
+#define FUNC_RESOURCEDATA "movb $0x04, %al\n\toutb %dx, %al\n\t"
+#define FUNC_STATUS "movb $0x05, %al\n\toutb %dx, %al\n\t"
+#define FUNC_SETCARDNUM "movb $0x06, %al\n\toutb %dx, %al\n\t"
+#define FUNC_SETDEVICENUM "movb $0x07, %al\n\toutb %dx, %al\n\t"
+#define FUNC_ACTIVATEADDR "movb $0x1E, %al\n\toutb %dx, %al\n\t"
+#define FUNC_IORANGECHECK "movb $0x1F, %al\n\toutb %dx, %al\n\t"
+
+#endif // _ISAPNP_H
\ No newline at end of file
diff --git a/lockwasher/src/sys/include/isa/8259.h b/lockwasher/src/sys/include/isa/8259.h
new file mode 100644
index 0000000..8ee2ae5
--- /dev/null
+++ b/lockwasher/src/sys/include/isa/8259.h
@@ -0,0 +1,44 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: 8259.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#ifndef _8259_H
+#define _8259_H
+
+#define mPic 0x20 /* I/O for master PIC */
+#define mImr 0x21 /* I/O for master IMR */
+#define sPic 0xA0 /* I/O for slave PIC */
+#define sImr 0xA1 /* I/O for slace IMR */
+#define eoi 0x20 /* EOI command */
+#define icw1 0x11 /* Cascade, Edge triggered */
+#define icw4 0x01 /* 8088 mode */
+#define mVec 0x68 /* Vector for master */
+#define sVec 0x70 /* Vector for slave */
+#define ocw3Irr 0x0A /* Read IRR */
+#define ocw3Isr 0x0B /* Read ISR */
+
+void init8259();
+void enableIrq(unsigned short irqNo);
+void disableIrq(unsigned short irqNo);
+
+#endif
+
diff --git a/lockwasher/src/sys/include/isa/atkbd.h b/lockwasher/src/sys/include/isa/atkbd.h
new file mode 100644
index 0000000..ceeda4e
--- /dev/null
+++ b/lockwasher/src/sys/include/isa/atkbd.h
@@ -0,0 +1,40 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: atkbd.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#ifndef _KEYBOARD_H
+#define _KEYBOARD_H
+
+#define shiftKey 1
+#define controlKey 2
+#define altKey 4
+#define ledNumlock 2
+#define ledScrolllock 1
+#define ledCapslock 4
+
+void initKeyboard();
+void keyboardIsr();
+void keyboardHandler();
+void setLeds();
+
+#endif
+
diff --git a/lockwasher/src/sys/include/isa/fdc.h b/lockwasher/src/sys/include/isa/fdc.h
new file mode 100644
index 0000000..58e34cf
--- /dev/null
+++ b/lockwasher/src/sys/include/isa/fdc.h
@@ -0,0 +1,79 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: fdc.h,v 1.2 2003/03/13 00:29:44 apwillia Exp $
+
+**************************************************************************************/
+
+#ifndef _FDC_H
+#define _FDC_H
+
+#include
+
+typedef struct DrvGeom {
+ byte heads;
+ byte tracks;
+ byte spt;
+} drvGeom;
+
+
+#define fdcMsr (0x3f4)
+#define fdcData (0x3f5)
+#define fdcDir (0x3f7)
+#define fdcCcr (0x3f7)
+#define fdcDor (0x3f2)
+#define fdcDrs (0x3f4)
+
+#define cmdWrite (0xc5)
+#define cmdRead (0xe6)
+#define cmdSeek (0x0f)
+#define cmdSensei (0x08)
+#define cmdRecal (0x07)
+#define cmdSpecify (0x03)
+
+#define dg144Heads 2 /* heads per drive (1.44M) */
+#define dg144Tracks 80
+#define dg144Spt 18
+#define dg144Gap3rw 0x1b
+#define dg168Gap3rw 0x1c
+
+
+
+void initFloppy();
+void floppyIsr();
+void floppyIsrhndlr();
+void sendByte(int byte);
+int getByte();
+bool fdcRw(int block,byte *blockBuffer,bool read,unsigned long numSectors);
+void block2Hts(int block,int *head,int *track,int *sector);
+void motorOn(void);
+void motorOff(void);
+bool seek(int track);
+bool waitFdc(bool sensei);
+int getByte();
+void sendByte(int byte);
+void recalibrate(void);
+void reset(void);
+bool writeBlock(int block,byte *blockBuffer, unsigned long numSectors);
+bool readBlock(int block,byte *blockBuffer, unsigned long numSectors);
+void fdcWrite(void *info,long startSector,long sectorCount,void *baseAddr);
+void fdcRead(void *info,long startSector,long sectorCount,void *baseAddr);
+
+#endif
+
diff --git a/lockwasher/src/sys/include/isa/pit.h b/lockwasher/src/sys/include/isa/pit.h
new file mode 100644
index 0000000..13e5158
--- /dev/null
+++ b/lockwasher/src/sys/include/isa/pit.h
@@ -0,0 +1 @@
+void initPIT(int);
diff --git a/lockwasher/src/sys/include/ld/ld.h b/lockwasher/src/sys/include/ld/ld.h
new file mode 100644
index 0000000..d6d65c5
--- /dev/null
+++ b/lockwasher/src/sys/include/ld/ld.h
@@ -0,0 +1,38 @@
+/**************************************************************************************
+ Copyright (c) 2002 The UbixOS Project
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
+in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
+contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ $Id: ld.h,v 1.2 2003/05/07 05:03:37 reddawg Exp $
+
+**************************************************************************************/
+
+#ifndef _LD_H
+#define _LD_H
+
+#include
+
+typedef struct sharedLibS {
+ struct sharedLibS *next;
+ struct sharedLibS *prev;
+ void *baseAddr;
+ } sharedLib;
+
+void ld();
+void loadLibrary(char *);
+
+#endif
\ No newline at end of file
diff --git a/lockwasher/src/sys/include/lib/Alloc.h b/lockwasher/src/sys/include/lib/Alloc.h
new file mode 100644
index 0000000..de924dc
--- /dev/null
+++ b/lockwasher/src/sys/include/lib/Alloc.h
@@ -0,0 +1,65 @@
+#ifndef __CPP_ALLOC_H
+#define __CPP_ALLOC_H
+
+#ifdef __cplusplus
+
+#include
+
+class Alloc
+{
+ protected:
+ int alloc_size;
+
+ uint8_t flags;
+ void * chunks[8];
+
+ public:
+ Alloc();
+ Alloc(int);
+ ~Alloc();
+
+ void setSize(int);
+ void * allocate();
+ void deallocate(void *);
+
+ private:
+ void clear();
+
+};
+
+/*
+Alloc::Alloc() {
+ alloc_size = 0;
+ flags = 0x0;
+ for (int i = 0; i < 8; i++)
+ chunks[i] = (void *) 0x0;
+ };
+
+Alloc::Alloc(int size) {
+ Alloc();
+ alloc_size = size;
+ };
+
+Alloc::~Alloc() { clear(); }
+void Alloc::setSize(int size) { clear(); alloc_size = size; }
+
+void * Alloc::allocate() {
+ if (0 == alloc_size)
+ return NULL;
+ return kmalloc(alloc_size,-2);
+};
+
+void Alloc::deallocate(void * ptr) {
+ kfree(ptr);
+};
+
+void Alloc::clear() { return; };
+*/
+
+
+
+
+
+#endif
+
+#endif
diff --git a/lockwasher/src/sys/include/lib/Pair.h b/lockwasher/src/sys/include/lib/Pair.h
new file mode 100644
index 0000000..389d783
--- /dev/null
+++ b/lockwasher/src/sys/include/lib/Pair.h
@@ -0,0 +1,40 @@
+#ifndef __CPP_PAIR_H
+#define __CPP_PAIR_H
+
+#ifdef __cplusplus
+
+#include
+
+template class Pair
+{
+ protected:
+ A a;
+ B b;
+
+ public:
+ Pair() : a(), b() { };
+ Pair(const A & _a, const B & _b) : a(_a), b(_b) { };
+
+ ~Pair() { };
+
+ inline A & first() { return a; };
+ inline B & second() { return b; };
+
+ Pair & operator= (const Pair & right) {
+ this->first() = right.a;
+ this->second() = right.b;
+
+ return *this;
+ }
+
+ operator B() const
+ {
+ return b;
+ }
+};
+
+
+
+#endif
+
+#endif
diff --git a/lockwasher/src/sys/include/lib/Queue.h b/lockwasher/src/sys/include/lib/Queue.h
new file mode 100644
index 0000000..c6285b0
--- /dev/null
+++ b/lockwasher/src/sys/include/lib/Queue.h
@@ -0,0 +1,221 @@
+#ifndef __CPP_QUEUE_H
+#define __CPP_QUEUE_H
+
+#ifdef __cplusplus
+
+#include
+#include
+#include
+
+template class Queue
+{
+ public:
+
+ class Pair;
+
+ Queue();
+ ~Queue();
+
+ void insert(const int, const T &);
+ void insert(Pair