x86-emulator and graphics
x86-emulator and graphics
I'm developing a small x86-emulator C. It will be written in C. I have problems with graphics. There will be support for different screen modes (for example VGA). What would be the best way to do this? Could I use the real VGA mode by calling the right interrupt and then use the os's own functions to print characters to screen?
Re:x86-emulator and graphics
What has the OS got to do with the emulator? An emulator emulates the hardware, you will have to write a BIOS to provide the real mode interrupts, the OS will expect the emulator to act like a real computer.
Re:x86-emulator and graphics
OK. My first post wasn't so good. I'll try explain again. The problem is how to provide those BIOS graphics functions. For example what is the best way to do the 80x25 graphic mode?
And with that OS thing I meant that could I use for example Linux's or Windows's own interrups to change to real VGA mode? Should it be better to make a new window and then do things in that window?
And with that OS thing I meant that could I use for example Linux's or Windows's own interrups to change to real VGA mode? Should it be better to make a new window and then do things in that window?
Re:x86-emulator and graphics
Bochs x86 Emulator
I would not run the emulator in full screen, I am not an expert on hardware but you'll have to somehow map the IO ports into data that you can give to the various host OS' functions to perform operations. In this case, the linear framebuffer should make this relatively easy (as it is just a raw bitmap that you can draw directly - although some bitshifting may be required). I can't be much more specific as I never tried to write an emulator (I couldn't be bothered implementing all the CPU instructions, then all the hardware behaviours...)
I would not run the emulator in full screen, I am not an expert on hardware but you'll have to somehow map the IO ports into data that you can give to the various host OS' functions to perform operations. In this case, the linear framebuffer should make this relatively easy (as it is just a raw bitmap that you can draw directly - although some bitshifting may be required). I can't be much more specific as I never tried to write an emulator (I couldn't be bothered implementing all the CPU instructions, then all the hardware behaviours...)
Re:x86-emulator and graphics
Thanks AR.
I also thought that running in full screen mode wouldn't be so good option. Of course it would be maybe a little bit faster than making it with windows. What would be the best way to do it with somekind of window? To do just one bitmap that I modify for example to print a char like Ar said? Then I just draw this bitmap to window.
What did you mean with that IO-port thing? I don't know did I understand it correctly because my english isn't so good.
I also thought that running in full screen mode wouldn't be so good option. Of course it would be maybe a little bit faster than making it with windows. What would be the best way to do it with somekind of window? To do just one bitmap that I modify for example to print a char like Ar said? Then I just draw this bitmap to window.
What did you mean with that IO-port thing? I don't know did I understand it correctly because my english isn't so good.
Re:x86-emulator and graphics
It sounds like you don't really know how the x86 architecture works, you will need an in depth understanding right down to just above the raw electronics (At the least; IO-Ports, Memory Mapped Devices, CPU instruction sets, PIT, [A]PIC, BIOS, POST, main Bus, Keyboards, PS/2 controllers, A20 gate, EGA/VGA and so on).
For a text framebuffer, the program will just write ASCII to the framebuffer, you then translate it into a font and render it on the window using the OS functions. For a graphical framebuffer the memory is stored in a linear/bank-switched chunk which can be translated to whatever colour depth the host OS wants and rendered directly.
For a text framebuffer, the program will just write ASCII to the framebuffer, you then translate it into a font and render it on the window using the OS functions. For a graphical framebuffer the memory is stored in a linear/bank-switched chunk which can be translated to whatever colour depth the host OS wants and rendered directly.
Re:x86-emulator and graphics
@AR: You can't run Bochs in full-screen mode unless you're in AmigaOS, right? So unless he's using AmigaOS, I doubt that's useful information.
Re:x86-emulator and graphics
@NotTheCHEAT: eh? He was the one who suggested running it in full screen, the emulated video card has a linear framebuffer, the virtual video card's linear framebuffer will need to translated into a Windows BITMAP then run through GDI to draw on the Window.
Re:x86-emulator and graphics
Thanks again AR.
I think that my knowledge about x86-architectur is at least good and if it isn't this can be good way to learn more about it. This won't be a big project. There won't be lots of features so I don't have know all about the x86-architectur. Only the things that I need in this project. My main project is still my own OS, but I don't want to use all my time to it. I'am just having fun. This isn't anything serious. My emulator won't probably never be as good as Bochs or anything another emulator, but it doesn't mind me.
Then back to my emulator's graphics. Maybe I'll use that method that AR told. What would be good library for GUI programming? I't should be quite simple, because I am not very familiar with programming things with GUI.
I think that my knowledge about x86-architectur is at least good and if it isn't this can be good way to learn more about it. This won't be a big project. There won't be lots of features so I don't have know all about the x86-architectur. Only the things that I need in this project. My main project is still my own OS, but I don't want to use all my time to it. I'am just having fun. This isn't anything serious. My emulator won't probably never be as good as Bochs or anything another emulator, but it doesn't mind me.
Then back to my emulator's graphics. Maybe I'll use that method that AR told. What would be good library for GUI programming? I't should be quite simple, because I am not very familiar with programming things with GUI.
Re:x86-emulator and graphics
So what you're working on is not a x86 emulator, but something different entirely. (To be an x86 emulator, it would have to emulate a x86, you see...)Jerkko wrote:
This won't be a big project. There won't be lots of features so I don't have know all about the x86-architectur. Only the things that I need in this project.
Perhaps you better explain to us what you want this "emulator" to do?
Every good solution is obvious once you've found it.
Re:x86-emulator and graphics
@Solar
Maybe I didn't explained it good. It will be x86-emulator or I hope so. It will emulate x86-architecture. It will first support only things that I need and the most important things. I'm doing it for my own use (because anyone else wouldn't use such a worse emulator). Then later if I want I can add support for more things. First thing is get my own small programs work in it and then make it support more and more abilities of x86-architecture. I don't know will it ever be a complete x86-emulator.
P.SMy explanations can be quite bad because I'm not so good in english. Sometimes it's hard to say what I wanted to say.
Maybe I didn't explained it good. It will be x86-emulator or I hope so. It will emulate x86-architecture. It will first support only things that I need and the most important things. I'm doing it for my own use (because anyone else wouldn't use such a worse emulator). Then later if I want I can add support for more things. First thing is get my own small programs work in it and then make it support more and more abilities of x86-architecture. I don't know will it ever be a complete x86-emulator.
P.SMy explanations can be quite bad because I'm not so good in english. Sometimes it's hard to say what I wanted to say.
Re:x86-emulator and graphics
If you are going to emulate the entire computer then you will need to understand all the stuff I listed, you can disregard the A20 gate if you are only going to allow <1MB RAM in real mode only though, the rest of the stuff is key to how an x86 works, if you can't understand them then you can't emulate them.
Re:x86-emulator and graphics
If your aim is to support only those parts you need (instead of emulating the real thing), what you're doing is writing a virtual machine that happens to "look" like a x86.
As for what's a good UI library... well... that depends on which OS you are using, which you didn't tell us so far...
Prime contenders are GTK, Qt, and wxWindows.
As for what's a good UI library... well... that depends on which OS you are using, which you didn't tell us so far...
Prime contenders are GTK, Qt, and wxWindows.
Every good solution is obvious once you've found it.
Re:x86-emulator and graphics
OK. So it's first it will be a virtual machine, but maybe later an emulator, when it supports all things in x86-architecture (am I right?).
Then about the UI. I am using Windows 98 (I know, it sucks), but I would be good if it would work in Linux too.
Then about the UI. I am using Windows 98 (I know, it sucks), but I would be good if it would work in Linux too.
Re:x86-emulator and graphics
Did you check any of the UI toolkits I mentioned? They are all more or less cross-platform...
Every good solution is obvious once you've found it.