My emu cross platform??

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Anes
Posts: 702
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

My emu cross platform??

Post by Anes »

Hi, so much time i didn't post to the forums.

Well, here i go:

Im deving my emu in Allegro 5 lib, i know i know, some other people would tell me SDL.

I have problems in linux. Allegro 5 for Windows uses Directx9. When i put a pixel in Windows everything is fine, since the stride or pitch is positive and its 1024 bytes (256 ARGB pixels). The thing that the same doesn't work well in linux since the stride is negative.

i can use in windows something like:

Code: Select all

void PutPixel(pixel32 pixel)
{
    *surface++ = pixel;
}
This way i dont need to worry about the stride in Windows, but how do i put a pixel with a negative stride as in ubuntu appears?
ANes
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: My emu cross platform??

Post by Dwedit »

The basic formula is "BaseAddress + Stride * Y + X * BytesPerPixel". That gives a result in bytes, and assumes that BaseAddress is a byte pointer.

This means that every time your Y coordinate changes, you need to recalculate your pointer. One way is to just run that formula again, the other way is to save what the start address of the scanline was, then add Stride to proceed to the next scanline.

Your pointers still increment to go to the right by 1 pixel.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Anes
Posts: 702
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: My emu cross platform??

Post by Anes »

Dwedit wrote: Mon Feb 21, 2022 9:11 am The basic formula is "BaseAddress + Stride * Y + X * BytesPerPixel". That gives a result in bytes, and assumes that BaseAddress is a byte pointer.

This means that every time your Y coordinate changes, you need to recalculate your pointer. One way is to just run that formula again, the other way is to save what the start address of the scanline was, then add Stride to proceed to the next scanline.

Your pointers still increment to go to the right by 1 pixel.
I figured out already. Thanks anyway
ANes
Post Reply