[Solved] put pixel to get pixel and gui scroll

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

[Solved] put pixel to get pixel and gui scroll

Post by Octacone »

Hey people!

I am working on my graphical terminal. I need some help with terminal scrolling.
1.I need to create a temporary buffer
2.I need to copy selected area of pixels from my main linear frame buffer to my temporary frame buffer.
3.I need to repaint the entire screen with back color.
4.I need to copy my temporary buffer back to my main frame buffer minus wanted Y coordinate.

Now my problems are:
1.How do I reverse engineer this method to get pixel method. So I want to get selected area of pixels from my frame buffer and copy that to another buffer.

Code: Select all

	unsigned location = (position.Y * screenWidthBGA * 4) + (position.X * 4);
	linearFrameBufferBGA[location + 0] = 0;
	linearFrameBufferBGA[location + 2] = color.R;
	linearFrameBufferBGA[location + 1] = color.G;
	linearFrameBufferBGA[location + 0] = color.B;
2.Once I get my get pixel method working how do I put all those pixels back minus wanted scroll up value?
Last edited by Octacone on Sun Aug 28, 2016 9:22 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

Also I have SSE2 enabled.
Working memory copy and memory set.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

I tried something like this and it didn't work.

Code: Select all

unsigned location = (10 * screenWidthBGA * 4) + (10 * 4);
		unsigned locationNew = (9 * screenWidthBGA * 4) + (9 * 4);
		char nfb = linearFrameBufferBGA[location];
		linearFrameBufferBGA[locationNew] = nfb;
Last edited by Octacone on Thu Aug 25, 2016 10:43 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

Topic.BringToFront();

It did but the pixel is blue instead of white.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

Anybody?? :cry:
Talking to myself in here.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: put pixel to get pixel and gui scroll

Post by Ch4ozz »

Save only the text and redraw the text when scrolling.
For some better scrolling smoothness you *might* add 2 buffers (or enlarge the main buffer) to store some pixels there. (Instead of text only)

What you need for scrolling buffers is called "memmove"

EDIT: Your code in post 1 looks wrong, one of the colors should actually be at offset 3 (I guess alpha)
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

Ch4ozz wrote:Save only the text and redraw the text when scrolling.
For some better scrolling smoothness you *might* add 2 buffers (or enlarge the main buffer) to store some pixels there. (Instead of text only)
What you need for scrolling buffers is called "memmove"

EDIT: Your code in post 1 looks wrong, one of the colors should actually be at offset 3 (I guess alpha)
Code from my first post works just fine, it weird because of BGA.
I just want to know how to get a pixel from one specific location, not set pixel but get that pixel from coordinates.
Memory move you say, are you referring to: (source, destination, size) memory function?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

Update: I have Memory Move function ready.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: put pixel to get pixel and gui scroll

Post by Ch4ozz »

octacone wrote:Code from my first post works just fine, it weird because of BGA.
I just want to know how to get a pixel from one specific location, not set pixel but get that pixel from coordinates.
Memory move you say, are you referring to: (source, destination, size) memory function?
Of course your code works fine, because the alpha part is never rendered and the CPU/GPU does not care what value it is.
Your alpha value never gets set and is therefore simply random trash (Usually 0 on VMs).

Memmove is a function which can copy memory into the same region your copying from.

Im using something along this to copy a region from Buffer 1 into Buffer 2:

Code: Select all

for(i = center_y; i < center_y + new_h; i++)
	blit(ctrl.buffer + (i*w*width + center_x*width), img_scaled->data + (i-center_y)*img_scaled->width*width + offset_x*width + offset_y*img_scaled->width*width, new_w*width);
blit() is a function like memcpy which also handles transparency
width is 4 bytes for 32 bit ARGB layout (4 colors)
center_x/y is the position where we copy into the new buffer
offset_x/y is the position we copy from
w/h is the width/height of the destination buffer
new_w/new_h is the width/height of the source buffer

@shmx
Already said that in first post but looks like octacone wants to copy memory that badly
Last edited by Ch4ozz on Thu Aug 25, 2016 11:34 am, edited 4 times in total.
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post by shmx »

Make emulation of a text video memory. When scrolling completely redraw all text in the window from the text memory from the desired position. This is a very simple and effective method. I do not recommend copying video memory for these purposes, it is not optimized for reading.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

shmx wrote:Make emulation of a text video memory. When scrolling completely redraw all text in the window from the text memory from the desired position. This is a very simple and effective method. I do not recommend copying video memory for these purposes, it is not optimized for reading.
How do I do that? I only have a single linear frame buffer that contains all the pixels. I need to get all the pixels and copy them to the same location but different y coordinate.
The problem is: getting pixels from selected region.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

Ch4ozz wrote:
octacone wrote:Code from my first post works just fine, it weird because of BGA.
I just want to know how to get a pixel from one specific location, not set pixel but get that pixel from coordinates.
Memory move you say, are you referring to: (source, destination, size) memory function?
Of course your code works fine, because the alpha part is never rendered and the CPU/GPU does not care what value it is.
Your alpha value never gets set and is therefore simply random trash (Usually 0 on VMs).

Memmove is a function which can copy memory into the same region your copying from.

Im using something along this to copy a region from Buffer 1 into Buffer 2:

Code: Select all

for(i = center_y; i < center_y + new_h; i++)
	blit(ctrl.buffer + (i*w*width + center_x*width), img_scaled->data + (i-center_y)*img_scaled->width*width + offset_x*width + offset_y*img_scaled->width*width, new_w*width);
blit() is a function like memcpy which also handles transparency
width is 4 bytes for 32 bit ARGB layout (4 colors)
center_x/y is the position where we copy into the new buffer
offset_x/y is the position we copy from
w/h is the width/height of the destination buffer
new_w/new_h is the width/height of the source buffer

@shmx
Already said that in first post but looks like octacone wants to copy memory that badly
I don't have "blit". That design does not fit. I still can't read pixels from my buffer. I need to read all the pixels from selected area and then copy them to the same buffer but different y coordinate.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post by shmx »

The terminal contains only text?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

shmx wrote:The terminal contains only text?
Terminal contains only pixels, I might add some graphics later to it.
In my case text == bitmap arrays == pixels.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post by shmx »

If only the text, then it is very simple.
Image
Last edited by shmx on Thu Aug 25, 2016 11:55 am, edited 2 times in total.
Post Reply