frantOS - my first x86 bare metal project
frantOS - my first x86 bare metal project
A simple bare metal project.
frantOS display two bitmap images(with VGA palette), one as a background and the other one as a sprite sheet(animating it).
It contains some simple image manipulation functions, such as draw with subtract or draw by region.
Reading the keyboard by interrupt, you can make some graphical changes to the displaying video(drawing a square and changing its color)and save the video memory as a bmp on the primary ATA.
frantOS works in protected mode, it's compiled in 32bit, and was tested on a real 32bit machine. It implements interrupts in assembly and contain a little and simple ATA write driver. Hope you like it
Youtube video
https://www.youtube.com/watch?v=cCilnmk6WnE
Github source:
https://github.com/frangr/frantOS
frantOS display two bitmap images(with VGA palette), one as a background and the other one as a sprite sheet(animating it).
It contains some simple image manipulation functions, such as draw with subtract or draw by region.
Reading the keyboard by interrupt, you can make some graphical changes to the displaying video(drawing a square and changing its color)and save the video memory as a bmp on the primary ATA.
frantOS works in protected mode, it's compiled in 32bit, and was tested on a real 32bit machine. It implements interrupts in assembly and contain a little and simple ATA write driver. Hope you like it
Youtube video
https://www.youtube.com/watch?v=cCilnmk6WnE
Github source:
https://github.com/frangr/frantOS
Re: frantOS - my first x86 bare metal project
Looks great! I will have to try it out.
Re: frantOS - my first x86 bare metal project
Looks great. Seems more like a game engine than an OS. But since I like OSs and game engines both, I don't care! One could write a game for your OS. Did I mention that it looks great?
EDIT: I read your Readme and it says it's not a OS. Shouldn't you rename it then? Anyway, it's a cool bare metal program. I think I will put a similar game engine on my OS TODO list.
Was it hard to edit the walking animation of the sprite?
Greetings
Peter
EDIT: I read your Readme and it says it's not a OS. Shouldn't you rename it then? Anyway, it's a cool bare metal program. I think I will put a similar game engine on my OS TODO list.
Was it hard to edit the walking animation of the sprite?
Greetings
Peter
Re: frantOS - my first x86 bare metal project
Glad you like it!nexos wrote:Looks great! I will have to try it out.
Thank you Peter!PeterX wrote:Looks great. Seems more like a game engine than an OS. But since I like OSs and game engines both, I don't care! One could write a game for your OS. Did I mention that it looks great?
EDIT: I read your Readme and it says it's not a OS. Shouldn't you rename it then? Anyway, it's a cool bare metal program. I think I will put a similar game engine on my OS TODO list.
Was it hard to edit the walking animation of the sprite?
Greetings
Peter
Yeah, I should rename it. I called my project like that because it sounded good with my nickname("franto")... any suggestion is accepted
The hard part was parsing the bitmap. Not the header, but parsing the pixel map. For some reason the bitmap file start storing the pixels backwards(first pixel in the map is the last one in the image). So you need to parse the data as "pixel[width*height]--". But when an image is backward, it become mirrored too. So you have to parse data as '(pixel[width*height] - width)++' and then subtract width*2 when it reach the end. This is not so difficult, but it become so when you have to select an image by region. Go to see function "draw_bmp_region" in the main.cpp to see the struggle lol
Anyway, I had some troubles in writing the ATA write code. when called more than once(in things like cycles or just calling it more than once), it would not write, or write gibberish. This lasted until I put a "cache flush" command in the driver (or at least this was my impression, I have to test if it's actually the cache flush that resolve the problem).
Code: Select all
void ATA_write(uint32_t LBA, uint8_t sec_n, uint16_t* data_buffer)
{
uint8_t bt = LBA >> 24 | 0xE0;
out(0x1F6, bt);
uint8_t delay = in(0x1F7);
delay = in(0x1F7);
delay = in(0x1F7);
delay = in(0x1F7);
out(0x1F2, sec_n); //number of sectors to write
out(0x1F3, LBA);
out(0x1F4, LBA >> 8);
out(0x1F5, LBA >> 16);
out(0x1F7, 0x30); //read with retry = 0x20, write with retry = 0x30
//clear_screen(3);
//servicing
while( (in(0x1F7) & 0x8) == 0 ) {}
for(int i=0; i<sec_n*256; i++)
outw(0x1F0, data_buffer[i]);
out(0x1F7, 0xE7); //cache flush
return;
}
This is where I saw the cache flush code. Line 0302
(sorry for the long post, and sorry if there is some grammar error too, english is not my first language)
-
- Member
- Posts: 425
- Joined: Tue Apr 03, 2018 2:44 am
Re: frantOS - my first x86 bare metal project
Cache flush gets mentioned in:frantog wrote: Anyway, I had some troubles in writing the ATA write code. when called more than once(in things like cycles or just calling it more than once), it would not write, or write gibberish. This lasted until I put a "cache flush" command in the driver (or at least this was my impression, I have to test if it's actually the cache flush that resolve the problem).
This is not mentioned in the ATA read/write sectors osdev wiki page. It should? Or I'm the only one to have encountered this problem? Let me know.
This is where I saw the cache flush code. Line 0302
https://wiki.osdev.org/ATA_PIO_Mode#Cache_Flush
The various ATA pages are a bit hap-hazard, but I found the above one easiest to follow so far. My ATA driver is based largely on this page, but I found it hard going.
Re: frantOS - my first x86 bare metal project
Here some name suggestions:
"frantoengine"
"frantogfx"
"frantostic"
Greetings
Peter
"frantoengine"
"frantogfx"
"frantostic"
Greetings
Peter
-
- Posts: 15
- Joined: Fri Jul 17, 2020 12:43 pm
- Libera.chat IRC: argonaquila
- Location: Paraguay
- Contact:
Re: frantOS - my first x86 bare metal project
I posted email to you so you can check it. This is my impression to you after my failure.
Prendre soin de sa sante www.viagrasansordonnancefr.com pharmacie de Paris
Re: frantOS - my first x86 bare metal project
Please mind your manners. You've made all the classic mistakes an OSdev-wannabe could make. There's nothing wrong with that if you are able to learn from those. Unlike you, the OP has already shown he can write code, has solid understanding of CPU modes and bare metal interfaces, and he did not asked others to write an OS for them.ArgonAquila wrote:I posted email to you so you can check it. This is my impression to you after my failure.
Cheers,
bzt
-
- Posts: 15
- Joined: Fri Jul 17, 2020 12:43 pm
- Libera.chat IRC: argonaquila
- Location: Paraguay
- Contact:
Re: frantOS - my first x86 bare metal project
I understand dude. I am 17 but learned how to not to be dickhead while making project.bzt wrote:Please mind your manners. You've made all the classic mistakes an OSdev-wannabe could make. There's nothing wrong with that if you are able to learn from those. Unlike you, the OP has already shown he can write code, has solid understanding of CPU modes and bare metal interfaces, and he did not asked others to write an OS for them.ArgonAquila wrote:I posted email to you so you can check it. This is my impression to you after my failure.
Cheers,
bzt
I am such a dickhead that ashamed myself that I lost my OS project.
Prendre soin de sa sante www.viagrasansordonnancefr.com pharmacie de Paris
-
- Posts: 15
- Joined: Fri Jul 17, 2020 12:43 pm
- Libera.chat IRC: argonaquila
- Location: Paraguay
- Contact:
Re: frantOS - my first x86 bare metal project
Also this is not classic mistake. I am the first guy who made this biggest mistake that no developer never forgives.bzt wrote:Please mind your manners. You've made all the classic mistakes an OSdev-wannabe could make. There's nothing wrong with that if you are able to learn from those. Unlike you, the OP has already shown he can write code, has solid understanding of CPU modes and bare metal interfaces, and he did not asked others to write an OS for them.ArgonAquila wrote:I posted email to you so you can check it. This is my impression to you after my failure.
Cheers,
bzt
THE FIRST TIME IN PROGRAMMING COMMUNITY.
Prendre soin de sa sante www.viagrasansordonnancefr.com pharmacie de Paris