nexos wrote:Looks great! I will have to try it out.
Glad you like it!
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
Thank you 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 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
(sorry for the long post, and sorry if there is some grammar error too, english is not my first language)