Hello dear osdev community,
I just started getting into OS development yesterday.
I managed to do some TextMode stuff and now I want to move on to Graphics programming.
I managed to switch to the 13h VGA draw mode, but now I am facing some problems:
I can't access the Graphicsmemory using arrayindexing(?). I need to use pointerarithmetic, if I want to edit a pixel, which is pretty slow.
Also, if I try to calculate any pixel offset, and cast it to an pointer, it won't work, too. It shows either no colored pixel, or heavily offset pixel locations. Accessing them using pointerarithmetic works fine tho.
Am I missing something basic?
PS:
Sorry for the bad english, I am no native speaker
I attached an image of my code.
Can't access memory using arrayindexing.
Re: Can't access memory using arrayindexing.
It's better to post code as snippets and not as images.
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2
Educational Purpose Operating System - EPOS
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2
Educational Purpose Operating System - EPOS
Re: Can't access memory using arrayindexing.
Hi,
Is your colour a char, or an int ?
You have to decide and not have a pointer-to-char accepting int values .
Is your colour a char, or an int ?
You have to decide and not have a pointer-to-char accepting int values .
- MichaelFarthing
- Member
- Posts: 167
- Joined: Thu Mar 10, 2016 7:35 am
- Location: Lancaster, England, Disunited Kingdom
Re: Can't access memory using arrayindexing.
Well if your put pixel routine uses x for a row and y for a column then:
(a) you have not used y at all
(b) you have treated x as if it is a column
I'll leave it at that, because frankly progress with a project like this needs a bit* of sweat and determination to sort out things for yourself.
*I put 'a lot' originally - but hey - small beginnings.
(a) you have not used y at all
(b) you have treated x as if it is a column
I'll leave it at that, because frankly progress with a project like this needs a bit* of sweat and determination to sort out things for yourself.
*I put 'a lot' originally - but hey - small beginnings.
Re: Can't access memory using arrayindexing.
The linear buffer usage is pretty easy.
You need to know the width of the screen resolution and then simply can use modulo width to calculate the x pos and divide width to get y pos in the buffer.
You need to know the width of the screen resolution and then simply can use modulo width to calculate the x pos and divide width to get y pos in the buffer.
Re: Can't access memory using arrayindexing.
Guys, I know how to calculate the pixel position. it is just, if I use arrayindexing or calculating the adress, it doesn't work, but if I use pointer arithmetic it does :S
Re: Can't access memory using arrayindexing.
Pointer arithmetic and indexing is the same after compiling to a binary file.FabianB wrote:Guys, I know how to calculate the pixel position. it is just, if I use arrayindexing or calculating the adress, it doesn't work, but if I use pointer arithmetic it does :S
array[x] is just something along a macro and will be translated to *(array + x)
Therefore pointer arithmetics will produce the exact same opcodes as when using indexing and therefore it has the exact same speed.
Take a look at your binary file with a disassembler and maybe you spot something weird.