PDA

Click to See Complete Forum and Search --> : when to start writting my own os


abdul
Jul 31st, 2001, 01:54 AM
I am learnig asm at this time. Do you know how much should I learn asm and then start writting my own os. I want to work more with C\C++ than asm.

Knight_Vision
Jul 31st, 2001, 10:43 AM
I'll put it to you this way, If your going to be learning on your own, your better off KNOWING assembly. TRUST ME ON THIS!!!

Makeing a Bootstrap is not the easiest thing in the world in C/C++... Also, you would need to make sure you create RAW BIN files and it's tough to do in C/C++. UNLESS you know how to do it. I don't.

I know assembly, so makeing the OS in ASM is much easier to me.

Knight

ChimpFace9000
Jul 31st, 2001, 11:04 AM
Knight, have you ever written your own os? I tried but the only info i could find was on bootstraps, so i never get past that. I would love to write a small one with basic features just to learn.

Knight_Vision
Jul 31st, 2001, 11:10 AM
Funny you ask that.. Yes, I am in the middle of my own OS. In fact, if you goto not only my website, but www.stengineer.com you will see that a bunch of us are making a WHOLE new computer based off of my OS. It's called LOS, or LCARS Operating System. You know those panels you see on Star Trek? Well, LOS is based off of that look and feel. We have PDFs and Manuals written up on the subject. We are working toward the same goal. To have a computer that will plug into the net but with beauty and style.. LOL

So in answer to your question, YES, I am making my OWN OS.. ;)

In fact, on my website, if you download BOTH of my BOOTSTRAPS 1 and 2, you can then compile both of them. The first one just sets up for the boot-signature. The second file is called by the first and then executed. It's a simple interface, but it will give you something to play with if you need. The LCARS OS however, will NOT have that interface. It's not been released to the public yet.

You can get a windows version of what it will look like at www.stengineer.com though. STEngineer owns the site, I used to be a part of LCARS Technology, but I decided to branch out on my own.. I hope this answers your question..

pskyboy
Aug 10th, 2001, 09:06 AM
Hey guys

I must say don't we all want to write our own O/S's i to have started out on the epic journey of writing my own OS.

Here's some info you may find usefull

1. http://www.nondot.org/sabre/os/articles a bloody good website that covers almost everything on O/S's a very good starting point.

2. Operating Systems... ISBN 0-13-638677-b this book covers the basics of operating systems and uses examples from minix. This book is recommended by most people when starting to leran about or write OS's.

Knight_Vision
Aug 11th, 2001, 07:21 AM
I been to that site many times. I use it like a bible. However, if you want to create a GOOD OS you have to create it in NASM first. Then you can port over to C or create your own C compiler. I know its a lot of work, but if you want your OS to be good, you have to do this. That is the one thing that site doesn't show you. I had to figure out all of this on my own. ALSO there are mistakes at that site. For example, it says in one tutorial that the starting memory address is 7C00:000 while another one says it's 0000:7C000 and still another one says 0000:07C0. So wich is it? Well, after some research I found that it's 0000:07C0. But unless you had someone to show you, you would have not known and your code would end up buggy.

Like I said, it's a greate site, but watch out for the errors.

abdul
Aug 11th, 2001, 10:21 AM
Yes, it''s a good site but I need a web site that teaches you how to make a "hello world!" OS. and then it start with the mouse support and other ****...

Knight_Vision
Aug 13th, 2001, 07:52 AM
If you goto my site, I have a BOOTSTRAP tutorial 2 I think it is called, that will boot up with a message. Then it hangs. You can just change the string to "Hello World!" if you want.. LOL

Either way, it works. ALSO, I JUST added some really neat routines to my site to make your life a lot easier. Things from PRINT to LOCATE.. Just like in BASIC. :)

The mouse support is not done yet. I have source code on my site for a Mouse driver, but it's still buggy. You can compile it and even try to move your mouse in a program. But your computer will hang do to a stack overflow. It will force you to reboot. However, once I solve this glitch, it will be a fully functional mouse driver that can be ported over to any OS.

I hope my info here helps you out.. :)

abdul
Aug 13th, 2001, 09:40 AM
I just checked your site out and I really like the way you typed the code (lots of commentsLD)

Thanks a lot but just one question:

How much you write your code in asm and then write everything else in C\C++?

Knight_Vision
Aug 15th, 2001, 10:16 AM
This is the way i'm doing it. I am writting the foundation of the OS in Assembly. That's everything from the bootstrap, to the FAT table. Once those two are done, I am working on my own compiler. This compiler will be in BASIC first. Then I will make sure it can handle ANSI-C code. I'm not going the C++ route.

Eitherway, my interface will be simple to create. All that really needs to be done is the actual code behind it if you ever write software for my OS.

I beleive in the KISS method.. "Keep It Simple Stupid"
:)

Warmaster199
Sep 13th, 2001, 05:32 PM
Knight Vision, do you remember CTOS? I am implementing FAT and EXT2 into it. I need memory management and kernel... I got multi-threading as well.

parksie
Sep 13th, 2001, 06:03 PM
Originally posted by Knight_Vision
Then I will make sure it can handle ANSI-C code. I'm not going the C++ route.I wholeheartedly agree :)

C is much easier to write so that it coexists with asm code :) Less junk inserted by the compiler :D

Knight_Vision
Sep 14th, 2001, 11:59 AM
Warmaster199 - Hell yea, I remember you son.. How you been man? I have loved making an OS. So yours is going good? Just need a Kernal ehh? Yea, I know the feeling. You do know how to branch into upper memory corrrect? If so, then it's a matter of splicing the time of what each program will need so that you can multi-task it. Remember, EXEs in DOS are setup so that the EXE can tell the OS how many 64K segments are going to be needed. Think of an EXE as a multitasker. (I know it's not). But it jumps from one segment to another and almost simultaniously. Ok, now make a Kernal that can handle Multiple segments at once. In otherwords, think simple.

I know I know... Don't hit me.. LOL I try to explain and I sound like a lot of hot air.. but you know.. It sounds good in theory at least.. LOL

parksie
Sep 14th, 2001, 12:05 PM
Hang on...there's just one thing here I don't quite get.

If he's writing an OS, why does he need to implement segment:offset handling? Surely it would be better to kick the CPU into protected mode and then work from there?

Warmaster199
Sep 14th, 2001, 04:08 PM
I don't quite get protected mode... I need to do some research on that, but I do know that it's needed if I am to make the kernel 32-bit - And I am definitely going to have a 32-bit kernel!!! This thing is, I need a protected mode handler to be integrated into the kernel itself. I don't know how to do that, but I do know that I will be using Assembler for that - definitely. ASM is fast, small(compile size, HUGE amounts of code to do simple things), and is best for talking to the hardware. You probably think "This guy's nuts!", but I know what I am doing.

I do want to be able to run DOS executables using CTOS, so I'll need to organize the segments, like you said, Knight_Vision. I've got the source code to a DOS imitation called DOS-C and based on that info, I'll be able to set up the EXE header and such. I got the multitasking part ready... But right now, I gtg, cya

Warmaster199
Sep 27th, 2001, 04:38 PM
Ok, Knight_Vision, I got the Pre-Emptive multi-tasker code now! That's basically the core of the kernel. I just need a keyboard handler(I got the mouse covered - serial mice), need to check the FAT filesystem out, need segmenting and then, for the most part, I am finished the kernel.

The multi-tasker runs each thread for a clock tick on the timer. 18.2 clock ticks = 1 second. If also has support for "critical sections". These are good, because they can pause the tasker so that the current thread has all of the CPU's power. I got messaging as well: threads can send messages to eachother. Sort of like windows' SendMsg() API call.

parksie
Sep 27th, 2001, 04:42 PM
I'm not an OS developer, or even an asm programmer, but I just don't understand why you're coding segments? :confused:

Warmaster199
Sep 28th, 2001, 02:47 PM
Originally posted by parksie
I'm not an OS developer, or even an asm programmer, but I just don't understand why you're coding segments? :confused:

It's so that my OS will be able to run DOS programs. Sure, alot of them use the Int 21h vector, I'll need to emulate that as well.

parksie
Sep 28th, 2001, 04:28 PM
Ah. So your OS's memory model is flat by standard, but can run an emulation thread that interprets segments? :)

Warmaster199
Sep 28th, 2001, 05:29 PM
Yes, but that has to be incorporated into the code. Actually, If I wanted it to, it wouldn't have to use a thread. I'd put it in the kernel and if something really has to be done, I could put it in a critical section in the tasker. :cool:

parksie
Sep 29th, 2001, 04:51 PM
:cool:

I understand now, thanks :)

Warmaster199
Sep 29th, 2001, 05:38 PM
Any time! :cool:

Warmaster199
Sep 29th, 2001, 05:46 PM
Originally posted by abdul
I am learnig asm at this time. Do you know how much should I learn asm and then start writting my own os. I want to work more with C\C++ than asm.

Ha! About the beginning topic of this thread;

C/C++ are very good languages. ASM is good too, but mainly because it's the fastest running language running. A good thing about C/C++ is that you can incorporate ASM into it.

My advice is:
Learn C/C++ first to establish programming fundamentals and syntax. After that, start learning Assembly(ASM). I am just starting ASM, myself. It seems complex, but my background in other programming languages helps SIGNIFICANTLY.

It is VERY good if you comment. The analogy my teachers have told me is "Comment all of your code. That way, if you come back to it in a few months, you know exactly what's going on.". Also, if you plan to have a team of friends help you, it's good to comment as it helps them understand what you're trying to do.

C: /* This is a comment */
C++: // This is a comment
ASM: ; This is a comment

parksie
Sep 29th, 2001, 05:58 PM
Just out of completeness, /* */ is a valid C++ comment as well :)

Also, if you want to quickly exclude a large volume of code which may contain embedded /* */ comments, use this:#if 0
int func(void) {
/* This is a comment */
return 5;
}

#endifThis prevents nested comments, and the compiler will ignore everything up to the next #endif :)

ChimpFace9000
Sep 29th, 2001, 06:07 PM
Originally posted by Warmaster199
The analogy my teachers have told me is "Comment all of your code. That way, if you come back to it in a few months, you know exactly what's going on."
I dont think thats an analogy, just good advice.

Originally posted by Warmaster199
C: /* This is a comment */

/* */ Isnt a valid c comment. At least not really. Its probably in some c compilers though. I made that mistake before too.

parksie
Sep 29th, 2001, 06:08 PM
An empty comment is invalid? Hmmm didn't know that one :)

ChimpFace9000
Sep 29th, 2001, 07:43 PM
No i meant using /* and */ for comments in c is invalid.

transcendental
Sep 30th, 2001, 01:18 AM
Originally posted by ChimpFace9000
No i meant using /* and */ for comments in c is invalid.

/* Comments */ is for ANSI C.

// is for ANSI C++.

Some C/C++ compiler only allows these, according to your source code file extension. (*.c or *.cpp)

ChimpFace9000
Sep 30th, 2001, 02:54 AM
Oh yeah, your right, i had them backwards. I knew one of them wasnt valid for c. Thanks.

parksie
Sep 30th, 2001, 03:35 AM
C: /* */
C++: /* */
C++: //

That's the way the standards go ;)

Warmaster199
Oct 6th, 2001, 04:59 PM
Originally posted by Knight_Vision
...However, if you want to create a GOOD OS you have to create it in NASM first. Then you can port over to C or create your own C compiler. I know its a lot of work, but if you want your OS to be good, you have to do this.

Can't you just do make it with GCC? ( http://www.DJGPP.com - Click on Zip Picker). With GCC, you can include a VERY large amount of assembler. Many operating systems such as LINUX, SKYOS, Several other versions of UNIX, and even CTOS(My OS) made compiled with GCC(Gnu C Compiler - It also does C++!)

Warmaster199
Oct 8th, 2001, 04:20 PM
Okay, Check the attachment I sent... It's the CTOS boot sector and it comes with partcopy, so you can put it on a floppy... View the Readme file...

Knight_Vision
Nov 8th, 2001, 12:25 PM
Hey guy, you said in a message up there earier that you got the serial mouse to work in your OS? Is this true? And HOW did you do it? I have source code on how to talk to the PS/2 Port mouse, but my code is buggy, and I have had it for everyone to get, but no one has taken it and fixed it for me. Got any ideas on this? I cannot figure out where I went wrong.. I think I am seeing stars.. LOL

Here is my problem, my OS is on hold because I NEED the mouse to work for the OS to work. But since I can't get the mouse to work, i'm screwed... HEEEELLLPPPP!!!!


:)

Sorry, this is frustrating...

Warmaster199
Nov 8th, 2001, 05:46 PM
Ahhh... I am good! The driver is actually a simple C source. Simple in deed. All you have to do is constantly communicate with the mouse(Outputting / Inputting different ports) and get it to update certain variables... Then use the variables that you modify as the location for your cursor! It is so simple that you will hit yourself(I did when I saw it) once you figure it out... here: straight from CTOS. There are actually 2 files in the zip... mouse.c(the driver) and system.h. The code is messy, but CTOS isn't finished yet :(

This will be helpful :cool: :

ChimpFace9000
Nov 8th, 2001, 06:13 PM
This is off topic but Warmaster199 your signature totally sucks.

Knight_Vision
Nov 9th, 2001, 02:27 PM
Warmaster - Thanks budd. I'll look at it when I get home.

Chimpface - You ok guy? You been really negative lately. First you dis BASIC, then you talk negativly about Warmaster's Sig.. What gives? It's not like you. You ok?

Don't get me wrong, I agree that he needs to change his sig, but it is HIS sig. So what should it matter to us what he does with it as long as it's within the rules of ettiquete.

Either way you feel, I hope things are ok for you...

Later

Warmaster199
Nov 9th, 2001, 03:12 PM
Originally posted by ChimpFace9000
This is off topic but Warmaster199 your signature totally sucks.

I know... A friend was making fun of Windows and said that to me and it stuck... Ah well... I think it's kind of lame as well... How's this?...

parksie
Nov 9th, 2001, 03:14 PM
There's no change :confused:

Warmaster199
Nov 10th, 2001, 07:51 AM
No change??? What? Change in what? Nevermind...

parksie
Nov 11th, 2001, 08:37 AM
Ok my mistake I read it before you'd changed it :p

Knight_Vision
Nov 22nd, 2001, 10:29 PM
Hey Warmaster199, I just checked out your bootstrap ZIP file. I looked at the code and all the comments in it. Don't forget to credit me for the turorial bootstrap that you obviously used in it ok guy? I mean hey, it's not everyday that I see my work in someone else's code.. LOL

On another note, I am sitting here trying to peace together CTOS. And for the life of me, I don't have all the peaces it seems. I have a bunch of icons and BMPs that your text files say will utilize it. I have the boot.bin (ASM file) that you altered from my bootstrap tutorial 1, and I have a mouse.c file. I looked it iver, I cannot figure out how to get it to work with your boot.bin file. I wanted to see your OS working with full mouse support. Is it ready yet? And can I have the source? I wanted to add something to it that I think you might like. LCARS. I wanted to see your work combined with mine.

Let me know what you think. I'm anxous to find out what your response if here..

Warmaster199
Nov 23rd, 2001, 02:44 PM
It is possible, but I haven't compiled it yet. It's just a whole mess of code. Individual parts work, but the thing has not been tested as a whole. I couldn't get GCC to work. As for that bootstrap file... It has changed a bit. It is supposed to load the start-up code which initializes 32-bit protected mode, loads the kernel, and then jumps to the kernel's address.

Right now, I don't think that I should open source it. I am planning to start a company in the future, and probably sell CTOS, as well as games and utilities for CTOS and Windows and such. And of course... No one except me has all of CTOS's code. There is about 3MBytes of PURE TYPED C CODE(with some ASM)!!!

The bootstrap file is actually quite simple now that I think about it. The only tutorial that I used was, I believe, your second one??? It just prints a message... Now the bootstrap prints the start message, sets up the BPB, DPB, and opens the next sector on the disk(startup code). I will put your name in the comment for the boot code... But right now, I really got to go(In a hurry)

Knight_Vision
Nov 24th, 2001, 12:15 PM
Well then could you do me one BIG favor then? I'll credit you for your work in my OS as well. I need a SIMPLE bootstrap that turns the mouse on and I can move the mouse around. Can you do that at least for me?

Thanks guy.

Knight Vision

Warmaster199
Nov 24th, 2001, 04:56 PM
That is ok. I do not need credit for your OS.

That code is in C. Isn't your OS in PURE assembler? You can't put C in assembler, but you can put ASM in C code. You need GNU C Compiler(GCC) for that code. To make it work, you need a put pixel function, and a set pixel function. Then, you need to call the mouseinterrupt function in that file every time you want to update the cursor and draw the mouse. The mouseinterrupt function automatically calls functions to copy the background, and draw the picture. When you do the mouse interrupt again, it places the previous background back in it's place(Clears the mouse cursor away), gets the next background where the mouse is to be drawn, then draws the pictures. It does that everytime you call it. This is basically what a mouse driver does, so you can call the file I gave you a mouse driver. The thing is, your OS will have to get a little more complicated. You will have to access the disk to load another cluster or two for more code space. There's actually some good tutorials for this on that www.nondot.org site.

Warmaster199
Nov 24th, 2001, 04:58 PM
Try to convert that code to assembler(Might be hard, but it'll be easier for you to implement because your code is assembler, right?)

Knight_Vision
Nov 26th, 2001, 10:54 AM
I went and got the GNU C compiler. If you send me the whole working code from bootstrap to mouse I'll compile it. Also, could you add the compiled BIN to the ZIP as well? That way I can see what it does BEFORE I compile the code on my end? In that way, i'll know if I compiled it wrong or something.

Thanks for your help. My code is in Pure assembler, but i'll port it over to C if I can just get the mouse going.

jayman32878
Jan 29th, 2002, 01:34 AM
Hey i have been reading all these posts and I am really getting interested in this OS creating. I have been wanting to know how it is structured and how to go about it for a long time. Right now all I know as far as programming is VB and very little C++. How do you program assembly. Could you give me some tips. Please email me


Jayman (jayman@ruralfree.net)

Thanks

Jayman

CornedBee
Jan 29th, 2002, 08:23 AM
Start with reading the FAQ here.
I would be more interested where I can find information on how an OS must be structured etc. Simply how to create a very simple OS (say just a prompt where the only working thing is an echo instruction).

Warmaster199
Jan 29th, 2002, 11:00 AM
I could make a simple command line like that in a maximum of 50 lines(C/C++).

I have basically done that, but in graphics mode(You need your own font!). All it does is get your input, then draw the corresponding font character on the screen in the specified area(It confines it like it's drawing to a window of some sort)

Here is what I was talking about above, but it's got a window drawn behind it and stuff some it looks good. It's 671 lines of C code(NOT INCLUDED - Classified CTOS System Console code). This is a lame start to what the real CTOS console will look like... With about 30 or so more lines I could use pointers and be independent of that BGI file included, but I'm a little lazy right now that it requires making offsets and stuff because 640x480x16 color is a 4-bit mode. I could do it in 320x240x256 in about 15 more lines, but this is just a simple test.

Description of CTOS windows: There are 2 different titlebars, each of which have an active and non-active (zorders taken into account). The small buttons in the top left of the windows are as follows: A blue triangle facing left for minimizing to the taskbar which is on the LEFT side on CTOS, A pin button(black) to pin/unpin the window to/from the VDesktop(Pin makes window follow desktop, un-pin makes window follow screen), a Maximize button(Full screen - black symbol), and a window close button(a red 'X')

Please check the following file: Extract into any directory, run constest.exe. Type and see what happens. Press [ESC] to quit.

CornedBee
Jan 29th, 2002, 03:37 PM
That's cool. Where did you learn to make such things?

pskyboy
Jan 29th, 2002, 04:54 PM
If you want to learn about OS structure a good book is

Operating Systems, Design and Implementation

ISBN:- 0-13-638677-6

Warmaster199
Jan 29th, 2002, 09:08 PM
Originally posted by CornedBee
That's cool. Where did you learn to make such things?

Where did I learn it? A few documents for the fonts, on the net but that's it. The docu's are just something I came across. Everything else is just my programming skill :). If only I knew enough assembler to do that in it...

CornedBee
Jan 30th, 2002, 07:48 AM
I actually mean where did you learn to write e.g. the OS loader? The "classified" part :)
Anything on the net? I'm interested, but not that interested that I would buy a book.

CornedBee
Jan 31st, 2002, 09:12 AM
But you're writing an OS and therefore you must somewhere have learned how to do it.

Warmaster199
Jan 31st, 2002, 10:42 AM
All it is is different numbers and address locations and signals. For the low-down stuff like outportb and inportb(Output and input to ports respectively), I found those in a file that comes with DJGPP the GNU C Compiler. Those are useful for writing / getting values from different ports on your computer whether it's a hard disk and a sound card. Alot of that information can be found on the links to sites that are given in this thread. A really good site for learning drawing algorythms is http://www.brackeen.com/home/vga

There you will find setting modes, drawing pixels, drawing lines, circles, etc... Another good site for finding information on the VESA video modes is http://www.VESA.org

Basically, the information your need is just port values and the meaning of information that you send to the ports.

DaoK
Feb 5th, 2002, 05:37 AM
I can crash the contest project when I press backspace about 100 times...

Warmaster199
Feb 6th, 2002, 06:51 AM
I see... I've got to fix that. But right now, I am almost finished adding IDE Hard Disk support. The code allows for up to 4 hard disk controllers, which means that you can have 8 IDE drives. Imagine 8x 100GByte drives... The problem is that my code MAY only support up to 8GBytes. I'll look into it later on today. As for that error you found, I know what the bug is, I'll fix it later when I start working on the GUI again (At least I'll make an effort to fix my bugs, unlike Microsoft :) )

numtel
Feb 6th, 2002, 11:15 PM
are there any commands for the console or just typing?

Warmaster199
Feb 7th, 2002, 07:17 AM
I coded that in about 30-45 minutes. I didn't include any commands yet, but I will AFTER I get the GUI running(Ability to move windows with the mouse, click buttons...). Most of that coding time is thinking on how to draw a good window and figuring out a way to use my font array.

To answer your question: No commands are supported yet. Why is everyone making such a big deal of this little thing? :D :rolleyes: I was just a simple report on what the O.S. will look like... Oh well :p

Ok, I gtg 2 school now (BTW, my programming teacher says that that console is amazing. Some of the code in there she didn't understand...)

numtel
Feb 7th, 2002, 09:02 AM
it does look cool, a little too much like windows but cool.

pskyboy
Feb 8th, 2002, 04:04 PM
Hey Guys

Though i would add something to the post. I amd trying to write an OS and so far have written a very basic bootloader and laid down the concepts behind my file system, memory managment and I/O allocation. Anyway what i was wondering is does anyone know where i can get a 64bit assembler and 64bit emulator that will run under windows as i want to develop a 64bit OS.

Peter

Warmaster199
Feb 8th, 2002, 07:36 PM
A 64-bit O.S.? Hmmm... You won't be able to run it on any Pentium chips... You'll need a chip made by SGI such as the R4000(The chip inside the N64). I believe that a SUN HyperSPARC is also a 64-bit CPU... You may possibly make your O.S. for the Macintosh G4 cube... But I think that's 128-bit... Oh well... good luck...

One last thing: a 64-bit emulator would be VERY SLOW. One for the N64(SGI R4000 - a SIMPLE 64-bit chip) needs a P3 @ 450MHz.

jian2587
Feb 16th, 2002, 10:59 AM
phew! I've been keeping up with this thread and I understand
nothing! I made a boostrap b4 but looks like its ant meets
elephant! You guyz are really good in ASM!
I bet u guyz could push down M$!

Anyway, I want to know how you guyz learn all this?
I keep on reading the tutorials but still not understand...

Warmaster199
Feb 16th, 2002, 02:34 PM
Au contraire(sp?)... I don't really know that much about assembler, I just know some of the syntax and some of the opcodes... But, I do know lots of things in C. My C++ teacher calls me the top in the class and some of the things I tell her in C++ she didn't even know was possible. Example:

struct xy{int x, int y}

struct xy myfunc(int x, int y)
{
struct xy temp;
xy.x = x, xy.y = y;
return xy;
}

She did not know that it is possible to return a structure from a function. I believe you can do this in ASM as well, but you have to say word x, word y(2 byte = one word). Long is double word... I think that some machines such as some MACs support quad words. Anyways, for CTOS, I got the some of the IDE interface ready. It should be able to identify the geometry of different drives and read and write to the drives. I can write to 4 different controller port for a total of 4 controllers or 8 IDE Hard disks. Today, I started looking up information on the FAT12/16/32 filesystems(FloppyDOS, HDDDOS, and HDDWINDOWs, respectively). I have already coded structures for holding the Boot Parameter Block, the FAT12/16 BPB at offset 36, the FAT32 BPB at offset 36, the FATInfo sector, and the 32byte Directory/file entries. These are just simple structures taken from a document taken from the OS heaven, http://www.nondot.org/sabre/os

All I have to do is load sectors using my hard disk routines and use the info from the BPB to access files by reading sectors at calculated offsets given by the FAT Info. It's not the most difficult thing to do, but it IS possible.

CornedBee
Feb 17th, 2002, 09:02 AM
I looked into that. Up to 12 bytes, the return value will be in ecx:edx:eax
After that the compiler automatically creates a storage area in the calling function's stack and passes a pointer to this area.

VBTZH
Feb 26th, 2002, 03:24 PM
I can only help people who have VB :(

Warmaster199
Feb 26th, 2002, 05:58 PM
VBTZH:

Learn C. It's a bit more difficult than VB (Actually it's more than a bit...), but you get pointers(direct memory access... Raw power and speed... <drool> ). Your programs will run faster(lots faster!), but they take longer to code... unless your a code guru like some people I know(I could POSSIBLY be a C Code guru). You can also hit the hardware directly and manipulate data quicker and easier.

Take it a bit further with assembler and then your programs run from 2 to 20 times faster than in C, and the executables are super small (A 'Hello world prog in C: 4KBytes. Hello world prog in ASM is about 100-150 BYTES). Some instructions are even faster! The big draw back of ASM is that it'll take a while for you to code, and you need lines upon lines just to display a bit of text... Basically, if you need tons of speed and need to do ultimate direct hardware access and are short on space(Bootsectors - big time! Short on space...), do it in ASM!

pskyboy
Mar 31st, 2002, 04:37 AM
Hey Guys

To all the people who have started writing OS's im curious what ideas have you come up with for memory managment. Have you just stuck to the standard shove a program in where theres space or have you com up with better ways of dealing with it.

I had an idea for memory managment put i think it would require big processor overhead. I was thinking though processors are getting ridiculously powerful now so this may not be a problem anymore. What do you guys think?

Basically my idea is to have a program stored all over memory anywhere there is free space to put a bit of it. This would allow for 100% memory usage the problem is whenever the program jumps or gets to the end of one of teh blocks the processor would have to check to make sure and then redirect the jmp or tell teh program where its next line of code is. Do you reckon this is worth implementing or would it just be too slow.


Peter

Warmaster199
Mar 31st, 2002, 10:08 AM
I don't really think that that method would be too efficient. Even with fast processors that we have today, they will be greatly slowed down because most of a processor's actions deal with memory accessing, whether it be adding or whatever, you still need to access memory. Having bits and pieces of a program lying all around your whole memory space is almost as bad as the FAT filesystem. Sorry to destroy your idea like that, it seems good at first(Good waste management), but analyse it and you will see the great dissadvantage(Possibiliy that a program could get lost, and great speed loss). One more thing, if you actually decide to implement this idea, look into "Garbage Collecting" algorythms for memory management.

One last thing of advice and then onto a big lecture: Use alot of malloc(), realloc(), and free(). If you didn't make these, then do it! These are important. Use malloc in your MM to make space for the programs, and use realloc for re-organizing to make more space. These are dynamic memory management techniques and are very important.

Think of memory as a type of filesystem(Hard disks are non-volatile, slow[not any more], magnetic storage). The programs are your 'files' in this analogy. You have tables and descriptors to tell the processor where everything is. But what will be faster? A filesystem that spreads files all over and fragments the data(FAT12/16/32 will do this alot - run defragmentor), or a filesystem that stores everything linearly(in a straight line and together) and rearrages data to resize the data(Such as EXT2[:)][extended FS v2] and my new filesystem ALFS[Advanced Lookup FS])?

My OS, CTOS, stores everything together in clumps(Blocks?). The memory manager has sort of a table to save information about the allocated data(Where and how big it is). It is possible to move the whole linked list or move just a section of it where there is more space for realloc()ing.

Actually, my memory management code DOES need work, I REALLY need to work on this(The mem.c file is about 13KB of code. The rest of the CTOS kernel takes up like 3MB. The MM code definitely needs a facelift :D ). I have the great idea, but it's just NOT FUN to implement. Later, I plan to make virtual memory and stuff using file. But, I need to get the rest of the kernel AND the filesystems up and running first off ;)

BTW: I hate DJGPP(GCC)! I can't get rhide to show any errors that I have. It just says "There were some errors" and that's it! Can ANYONE help me out? I'm going to have to do a heck of alot of debugging :(... :D :rolleyes:

pskyboy
Mar 31st, 2002, 10:21 AM
Yeah i here what your syaing but surely because memory isn't a rotational medium having the program all over memory shouldn't make a difference to access speed as it just has to address the next space and not rotate round to then read it off.


As for DJGPP doesn't it output the errors to a file i migth be wrong but i think it does.


Peter

Warmaster199
Mar 31st, 2002, 03:45 PM
Yeah... But it is slower. The processor needs to compute the next part of the program given the packet/block information that you have in your descriptor for the program. This could mean an extra memory read cycle and add / subtract cycle for EACH access. usually memory can be accessed once a clock cycle. The jumping CAN double the time needed to access SOME piece of program in memory(Moving to different packets that are computed).

One more thing: I didn't know that you even could rip up programs and put the parts into memory in totally different places. Oh well... maybe windows does it (that COULD explain some of the crashes[losing address locations and such])

Your method does sound like it could be a neat experimental thing. Code it up and see it. Make a timer for normal mem accesses, and a timer for your method. Move around huge quantities of memory then stop the timer(do for each method). If the time isn't vastly different, then try it for your OS :)

pskyboy
Apr 1st, 2002, 03:05 AM
Thats a very good point i completly forgot that the adress of the next bit would be stored in memory so would have to be accessed.

I might still code it up though it would be interesting to experiment and see what its like.


Peter

jian2587
Apr 2nd, 2002, 06:45 AM
Well, I've made a bootstrap.
Now I am starting the kernel from scratch.
I wanna start with file management.
How am I to create and access FAT32?
Then later on I'll just have to pass the ASCIIZ and the mode I am
opening it,ie text,binary,random...

Or any advice is also welcomed.

Warmaster199
Apr 2nd, 2002, 04:39 PM
FAT32... I need help with that as well... I sort of get some of it, but I don't exactly get how it all fits together. I think I'll review my documentation again. Go to...

http://nondot.org/sabre/os/filesystems

...and click on anything that deals with FAT12/16/32. When you make your code, don't just right away open the drive as a FAT, as you might get errors. First, open the partition table on the drive to see if it actually is a FAT drive. Here: code from...
CTOS/drivers/block/ide.c


void ata_partProbe(void)
{
struct partition part_entry;
unsigned char buffer[512], drive, part;
unsigned char lheads, heads, sects, Temp3;
unsigned int Temp, track, Temp2;
unsigned short offset, cyls;
unsigned char* cp;
unsigned int i;
unsigned char str[255];
unsigned int d_cyl, d_head, d_sec;

printk("IDE Disk Partition probe: ( )) <--- \n");

for(drive=0; drive < MAX_INTERFACES; drive++)
{
if (ide_interfaces[drive].detect == 0) continue;
if (ide_interfaces[drive].flags & ATA_FLG_ATAPI) continue;

/* load sector 0 (the partition table) - 1 block, 1 count - 512 Bytes */
Temp = ata_read(drive, 1, 1, Buffer);
if (Temp < 0) continue;

if (buffer[0x1FE] != 0x55 || buffer[0x1FF] != 0xAA)
{
error("Invalid parition table on IDE Hard Disk device %d! Recommend you format it",drive);
continue;
}
lheads = ide_interfaces[drive].max_head;
for (part=0; part < MAX_INTERFACES; part++)
{
offset = 0x1BE + 16 * part;
Temp=*(unsigned int *)(Buffer + Offset + 8);
if (Temp == 0) continue;
sects = Temp % ide_interfaces[drive].max_sec + 1;
track = Temp / ide_interfaces[drive].max_sec;
heads = track % lheads;
cyls = track / lheads;
Temp2=*(unsigned int *)(buffer + offset + 12);
Temp3=*(unsigned char *)(buffer + offset + 4);
switch (Temp3)
{
case 0x01: sprintf(str,"FAT12"); break;
case 0x04: sprintf(str,"FAT16"); break;
case 0x05: sprintf(str,"Extended"); break;
case 0x06: sprintf(str,"FAT16 >32MB"); break;
case 0x07: sprintf(str,"HPFS"); break;
case 0x0B: sprintf(str,"FAT32"); break;
case 0x0C: sprintf(str,"FAT32"); break;
case 0x0E: sprintf(str,"FAT16"); break;
}
printk("HDD%d%c: start LBA=%d, start CHS=%d:%d:%d, Size: %dMB %s", drive, 'a' + part, Temp, Cyls, Heads, Sects, Temp2 * 512/1024/1024, str);
drive_para [drive * 4 + 4 + part].start_block = Temp;
sprintf(str,"HDD%d%c",drive,'a' + part);
}
}
}


I condensed some of that code so that it's not too ugly(removed some comments). The code above basically checks all the IDE hard disks and asks them for their first sector(boot block) for the FS IDs. When making your boot block, be sure to include the FAT identifier table. I'll show you people the CTOS boot block as an attachment :)

Have fun! (It's actually a "Stapled together" mess of boot blocks, but just take the table at the top of the file and use that.

jian2587
Apr 3rd, 2002, 06:27 AM
I'd like to use OUT...:)
I see your C code...
Shouldn't the first sector be the boot sector?
Why it is the partition table?
I thought it's after boot sector...

Warmaster199
Apr 3rd, 2002, 03:16 PM
The code reads block 1 (CHS = 0/0/0). This block the first sector and it contains the boot sector(AKA boot block). The drive's partition table is INSIDE the boot block's code.

jian2587
Apr 4th, 2002, 07:58 PM
Yes, I see what you mean.
I am not quite familiar with C codes, because I seldom use them,
though I know C fairly well.
Sometimes I feel C is more difficult than ASM. :)
I am no way good in FAT.
So, my naive thought is:I want to write couples functions that
will receive an ASCIIZ string and do all the hard stuffs.
Compatible with MS-DOS.

Uh,never mind. I'll check out www.freedos.org

Warmaster199
Jul 5th, 2002, 11:00 AM
New update for my OS. I have 8MBytes of stuff in total, 2.4MBytes are pure code for the OS - 2 years of data by just me(I haven't really worked too much on it the first 6 months and these last 6 months).

I have designed the GUI, but have not coded it(It's all on paper, in my head, and in bitmaps on my computer). This is going to be one big chore. Here comes another 150,000 lines of C code(The GUI) to double the size of my OS.

Check out these pictures I created (I already made algorythms to draw the alternating patterns on the windows - get a closer look). I like my ideas, WinXP looks like M$ collided with Fisher Price or something.

This is what CTOS will look like in possibly 2 or 3 years:

ChuckB
Jul 29th, 2002, 02:11 PM
Hi,
Interesting reading on this thread. I have a couple of big picture questions that are not so clear to me.

I understand the CPU calls an address that points to BIOS. BIOS does it stuff and then searches for Boot Record....

Now, when you folks develop a bootstrap, are you talking about programming the BIOS...or programming a bootable sector, MBR, etc. so that the CPU has someplace to go after BIOS program?

Do you test your OS on the PC you use to develop it?

I imagine you do something like this...using Windows/DOS, editor, compiler, you build operating system software and compile it....then you place it somewhere...boot disk? Then you do a warm boot and then test it. Is that right?

Please, I need to be clear on the basic process you folks follow. I understand software and hardware pretty well but I have not done this OS thing before.

Regards,
ChuckB

GuitarMan
Jul 30th, 2002, 04:15 PM
The first thing you generally do is program you Bootsector, this is the first sector on a disk. This is loaded at 0x07C0 in memory by the bios after it preforms its POST checks. It is the resposibility of the Bootsector to call the second stage of the bootloader or go ahead and load the full OS. It is quite possible to test your OS on your development PC but you really should get an old 486 or something to test it on. All you do (atleast untill you got a bootloader on a harddisk) is write the bootsector to a floppy disk using debug (the dos program) then copy the other files to disk (atleast if you are using a FAT filesystem).

ChuckB
Jul 31st, 2002, 02:38 PM
GuitarMan,

Your bootsector explanation makes sense to me.

Writing an OS has always been one of those mystical things to me. I have done a lot of relearning of assembler and reading various tutorials and now it doesn't seem all too incredible. Sigh! However, I have never done this. I am a pretty decent programmer in VB and C but somehow feel inadequate until I write an OS. :-)

Now, I understand that when BIOS read the bootsector and runs the bootloader, it loads IO.SYS which contains all sorts of hardware functions (interrupts)...then MSDOS.SYS for higher functions...CONFIG.SYS, COMMAND.COM and then AUTOEXEC.BAT. Does that sound right?

My goal would be to write a very simple OS that boots up off of a floppy disk and then displays a command prompt that allows me to type in anything...and all it does is echo what I have typed. Nothing more. Is that too complex?

To implement I would write a bootloader in the boot sector (I think that is where the loader is located). I can then write another program to monitor the keyboard and print to monitor. I could do this with BIOS interrupts and no DOS interrupts. Would this then qualify as an OS?

Is an MSDOS formatted floppy disk sufficient or do I have to define my own format level? If this is okay then I guess I need to be able to read the FAT from the bootloader to pull up the second program I mention above. Is that correct?

Does a bootloader only qualify as an OS?

Sorry for the simple questions but I am trying to put together the big flick in my mind.

Thanks. ChuckB

racing_fire
Aug 6th, 2002, 06:04 PM
Goto Planet-Source-Code (http://pscode.com) and search in C\C++. I've found some things, all of them have a bootstrap made in ASM and they use partcopy to put it in the first sector of a floppy.

Warmaster199
Aug 7th, 2002, 03:03 PM
Or, you could use this piece of code from my OS. It is a FAT12 boot sector that loads KERNEL.BIN from the floppy. It will search for the file until it finds it. If there is no kernel, it will tell you, then hang the system. I have included a simple kernel that displays a message and hangs.

ChuckB, you can use this minimal OS as a backbone for starting your OS. You don't need to change the boot file. To start off, download this file, then NASM. Extract the files from this zip some where. Format a floppy, then go into DOS prompt(in the folder) and type in "partcopy boot 0 200 -f0" to copy the boot file onto the floppy's boot sector. The partcopy numbers are all in hex. Edit kernel.asm and add what you need to so get input and then display it. Put it in a loop, then go to DOS and type "nasm kernel.asm". Rename kernel to kernel.bin, then copy the file to the root directory of the floppy. Shut off your PC, then turn it on with the floppy in the drive. Your OS should load(Whatever is in kernel.bin). Put out the disk when you are done and restart to get your windows back.

abdul
Aug 7th, 2002, 05:11 PM
I already asked this but got no response.
Warmaster, in your Kernel.asm file, it prints a message. I first moves the segment of your "startmessage" string to ax and then it moves it to ds (data segment). Here is how you're doing:

mov ax, 0x1000
mov ds, ax


Why can you do something like this (for NASM):

mov ax, seg startmessage
mov ds, ax


I already tried this sort of coding but NASM gives me an error on the line containing "seg". This works fine in TASM when I use "segment" instead of "seg".

Warmaster199
Aug 8th, 2002, 08:35 AM
I understand now what you're trying to say. There is an error in that because I had a start-up file that was supposed to be loaded and run inable to enable more than the 1MByte limit for the CTOS kernel to be loaded. The number should be 0x0050, not 0x1000. These are basically initializers to set the program's active segment. That are not needed for this particular KERNEL.ASM, but it is a good idea to have them for expansion. As soon as you declare a variable, the CPU will look in the previous segment. Therefore, you need to set an "active segment" (0x0050). The code to CALL the textprinter is just this:

mov si, message
call PrintStartup

Just make sure you have a string called message with a 0(NULL) as the last char(Be sure to have "PrintStartup" as well).

I hope that I have cleared this up :)

abdul
Aug 9th, 2002, 08:20 PM
Ok thanks, but how would you display another string? For example, if you declare another string called message2, how would you print it using its segment and offset?

DaNoVB
Aug 10th, 2002, 03:33 AM
I did not see the code, but however I think you should do

mov si,message
call PrintStartup
mov si,message2
call PrintStartup

This is how it worked in my very basic OS, in ASM, but however its now in C.

mmiill
Aug 10th, 2002, 05:28 AM
is that code available here,or something like that
im asking this becouse u are talking about some function ,and i dont know how everybody know names of your func,or maybe it is available just for specified person :D

and thaks ABDUL ,ive learnt somthing useful things from your program HIDEWINDOW .im useing it right now :D


:D :D :D :D :D :o :o :o :o :o

Warmaster199
Aug 10th, 2002, 10:22 AM
Originally posted by abdul
Ok thanks, but how would you display another string? For example, if you declare another string called message2, how would you print it using its segment and offset?

You would say:

mov si, message2
call PrintStartup

...to print message2. Remember to have a NULL(0) at the end of each string or this will hang your PC.

mmiill, the code is available at my post on the top of this page.

DaNoVB
Aug 10th, 2002, 12:28 PM
You're copying what I said :eek: Naughty boy! ;)

abdul
Aug 12th, 2002, 07:18 PM
Thanks, I understand it now. I see you're using a different interrupt instead of 21h and function 9h. I was trying to use 9h before which requires the the address of the string to be placed at DS:DX. I tried so using nasm but it said that binary format doesn't support this type of segment reference. Also when I try to include an external .inc file and then compile it to a binary file, it gives me an error saying that binary format doesn't support reference to an external file.
Weird because TASM lets me do all this pretty easily.

Warmaster199
Aug 15th, 2002, 12:05 AM
Geez... It took about 7 minutes just to load this "Reply to topic" page. NEVER EVER get Bell Sympatico High speed DSL. They say it's fast all the time? What a load of BS...

Anyways...
Dan, I didn't realize that you had already posted. I should check everything first before posting an answer.

I am designing my start-up module, known as STARTUP.BIN - It's the file the boot sector loads. STARTUP.BIN will be able to:
- Read FAT12/16/32
- Set the display to 640x480x256 color VESA
- Set the A20 address line(enable more than 1MByte of RAM)
- Load a startup bitmap and CPU logo bitmaps (according to detected CPU)
- Load KERNEL.BIN and a pmode disk driver for IDE or SCSI
- Initialize the GLD, IDT, LDT, and 32-bit Protected Mode
- Jump to the kernel
This whole file should be completely assembler. Total file size should need less than 1 segment (64KBytes). The bitmaps are separate files. This is VERY do-able. It should be done in a few months(with just me coding it). The FAT code is done, except for opening files and directories(The FAT manip. fncs. are ready), and read_sectors(d,s,*b); The FAT code is all in C, but my compiler can generate ASM code from the C code (BorlandC v3.1)

Read_sectors(); is giving me one big hassel. I have tried last night and all of today to get my computer to read the first sector into the correct buffer address. This is necessary for the FAT code to work. The buffer is always off by about 100-300 bytes and I have no idea why. I am embedding ASM code in my C code, and I think I am not passing the buffer's address correctly. I am using Int13h to read, but maybe I should use Int25h instead. This stupid/simple read_sectors(); is really annoying me. This should be very simple - someone tell me how to do it!!! :mad: :confused: :rolleyes: I will try using Int 25h. Tomarrow (thursday) is my last day on here for a while - gone for 3 days without a PC. I got to get me a laptop PC

Abdul, the reason I did not use Int 21h is because it's only supported by DOS. DOS installs that handler. Since we are making our own O.S.'es, we can't use that interrupt. Us people that are using Protected mode, We cannot call the BIOS while in Protected Mode (NO INTERRUPTS) except it we switch to V86 mode or back to real mode. Therefore, all loading of filesystem and disk drivers should be done BEFORE we enter protected mode or else we are stuck, lol (I found this out 2 days ago :p )

DaNoVB
Aug 15th, 2002, 02:43 AM
I read some tutorials, and I knew :D He, with its very much better OS than mine, didn't even know LOL!

CornedBee
Aug 19th, 2002, 06:54 AM
warmaster, you could post the function here and so we can look for errors - I don't know much about OSs, but quite a lot about ASM and C, and cooperation of the two.

Warmaster199
Aug 19th, 2002, 09:20 AM
I found that I can't use Int 25h because it's a DOS routine.

OK, here is the code. It's been brutally beaten and massacred, so I don't know if it's even a good start. It is possible that the error was just my BIOS on my old computer, but don't they ALL support Int 13h?

markman
Aug 19th, 2002, 03:33 PM
mega-tokyo.com/forum

jian2587
Aug 22nd, 2002, 06:29 AM
I found numerous FAT guides...
however, no way 4 me 2 understand it...
Pls anyone post codes on FAT, the foundation of FAT and creating
files and folders as well as managing them...
Compatible with MS-DOS...
Pls I need 2 know how...anyone?

Warmaster199
Aug 22nd, 2002, 10:47 AM
BY FAR the best document for describing FAT12/16/32 has to be this one (http://www.nondot.org/sabre/os/files/FileSystems/FatFormat.pdf). It tells you how to access each cluster based on the FAT table in the beginning of the drive, how to calculate the position of the table based on the boot sector, what the boot sector for a FAT system should look like... It's an amazing resource. I have used it for making my ALMOST complete FAT driver. All that's needed is a function to open/close files and directories. I could get that finished very soon.

Now, does anyone have a fix for my readsector problem? Or will I have to just go for assembler?

CornedBee
Aug 22nd, 2002, 11:26 AM
No apparent errors, I'll read about INT 13h tomorrow.
Just one thing: it says you should reset floppies between read attempts.

CornedBee
Sep 3rd, 2002, 07:14 AM
Have you tried reading out ah on return?

techyspecy
Sep 10th, 2002, 06:35 AM
Hey parskie,

I do not know what skill levels are required to do something like what you guys have talked about throughout this discussion, but i am well familiar with c,c++. Do not have any clue about ASM.

Can you guide me a little bit. Where should i start for learning ASM?

pskyboy
Sep 10th, 2002, 12:14 PM
Hey TechySpecy 0xLv6Tfl/AWwL+ZFnFx9IV0O81SaXnOT2ckdHfpsJ9
XVkarZ2BC4hMdXQqFwvlhxn8S9cVXUCFGfxpQdTdRUbaCFeE9oc4f+El4OgZ19TFvfVAcc72arOh
xYeTKX9WCXe+yHgbGHD8V5qj3fmuUmzCpH7Oz52rcrX22sQ8O5VLjYUgT7wCrsaZeoik4yPoBXo0
zmhZ/CGiXaoF/fTTOcpdCWO9xzCjZxryIsEAykzuszAVWgFtoMe456KgVN6i3mDJ0rGOT+TC9fDX
GUl3lG69QRKhxlF4fXGUkE3q7T4ppIz0490a/n9JQlKtz6ap8EjGd8ByoOBpZ09Rl43f5JO/bsYA
GrDhohBx5D4QStqdn14mvfvqsfYrdhdn7pXhJcKIOLkWIkWbxoTJ5ioAaG/3wSsmHBn7XbELFiev
nXUwj+b33DNP5mCoyB1AoKp+QVoECaURSTpmiNzCw+N2lwYiHy+gQTXTC9vLwwSOp4Wv9LoKbU3U
PYwmbmxzZFVWZ4JnCp6cSF2toRE/EQPmU8KVmldlWfsGBuudYgaa/pjg5ah+NzNKXRVwBVbShNMl
phCF8iLHbpQepSbtUIcnkNMNwWk86UzM/iI5yV+vO8ISZuok4vmw93y+CMsGzEhPtbNIOWPqNLAd
nvN8/kDyFx7gzjOG4XXNoP2hA2MX6TPbuGIptSqBKHL8RzwkaRRVhsmPUR2LUhzmYdiVu5+5sRR5
RFllTE7fS4S3GrHsuGuYJ/LUBb1aKzXxCrC9HKfX1reBmaVcqWoQVm+4Kr+1vevbOQ/0

techyspecy
Sep 10th, 2002, 03:06 PM
I need to learn ASM.

What is the best way?

abdul
Sep 10th, 2002, 03:42 PM
PC Assembly Programming does teach you Assembly language so follow the link that pskyboy posted or you can also read the book Art Of Assembly (very long...about 1500 pages). The good thing about PC Assembly Programming is that it also teaches you 32-bit programming (using 32-bit registers) and also puts in some C and tells you how to use Assembly in C and vise-versa.

DaNoVB
Sep 11th, 2002, 12:50 AM
Please note; art of assembly is for MASM

CornedBee
Sep 11th, 2002, 03:14 AM
There is a MASM version of AOA, but there also is a 16-bit version which doesn't use MASM.


BTW what happened to pskyboy's post?

DaNoVB
Sep 11th, 2002, 08:10 AM
Originally posted by CornedBee
There is a MASM version of AOA, but there also is a 16-bit version which doesn't use MASM.


BTW what happened to pskyboy's post?

Maybe an attack of madness :rolleyes:

Warmaster199
Oct 11th, 2002, 05:20 PM
...And now, here is my GUI(Window Manager) after working on it 7 days in school for an average of 30minutes a day during my programming class that I teach Grade 10's(I'm a peer tutor - I don't actually teach)

Currently, It (The Window Manager) can:
- Draw windows that have a border (that's it)
- Support up to 64 windows being active and up
- Support moving of windows
- Support switching of a window's z-order.

To use it, move the arrow key to move a little white dot(cursor). When over a window, press space to bring it to focus, then press space again to select it for moving. To release the window in the spot you want it, press space again. Press escape several times to quit... It does need to use double buffering to make it not flicker...

It is NOT complete, but this eventually WILL turn into my operating system's GUI! I am sorry, but I will NOT release source code :(

Updates to come when I get titlebars and window control boxes working(x, min, max)... and resizing...

(I just had to show you guys this)

DaNoVB
Oct 12th, 2002, 05:56 AM
The space doesnt work, I cant move the window...

CornedBee
Oct 12th, 2002, 06:08 AM
Wheeeeeeeeeeeeeeee.


Works only for the three windows in the top right corner. The others don't react. (Don't even exist, they disappear once you bring any other window to the front).

DaNoVB
Oct 12th, 2002, 06:10 AM
Aaaah now it works, but it damned flickering..im getting mad of it..

Warmaster199
Oct 12th, 2002, 10:02 AM
Originally posted by CornedBee
Wheeeeeeeeeeeeeeee.


Works only for the three windows in the top right corner. The others don't react. (Don't even exist, they disappear once you bring any other window to the front).

I know... Those were the drawing routines drawing stuff... The bland, dark grey square is actually clipped. By the routine's definition, it should have taken up half the screen, BUT: I gave it a rect to clip to... It only draws in that rect... I only use 2 actual CLib functions: Getch(), and Int86(); All the rest(About 20-30) are created by me. The other shapes clear as soon as you select one of the 3 windows for moving. What I do right now(inefficient like crazy) is clear the screen and then call drawgui() which redraws all windows (and later, calls all functions that are in a window's struct [controls :)])

I said that the WM supports 64 windows, but right now, I only created 3 windows. createwin(x,y,w,h,txt,type); is what I made the function (similar to windows - familiar to some). Createwin looks through all 64 windows and finds one which does not have the WMFLAGS_ACTIVE bit in window[handle].flags set. Once you understand how I did this, it's really quite amazing. That is only 500 lines of code... and it condenses to 8KBytes using PowerC compiler.

Email me if you want PowerC - fits on a floppy and runs off DOS in a command line...

The flickering WILL go away... when I optimize the code and get a double buffer added (which for some reason doesn't work :mad: )