Strange behavior DrawImage() in AROS (SOLVED)

aGGreSSor · 1469

aGGreSSor

  • Member
  • ***
    • Posts: 184
    • Karma: +25/-0
    • russian transit
on: November 05, 2020, 02:56:33 PM
I have compiled two versions of the classic example  on using the function ImageDraw() in Intuition: old from AmigaOS 3 and new for AmigaOS 4.

simpleimage.c work in AmigaOS 3:


but simpleimage.c don't work in AROS (AROS One and IcarOS)


simpleimage_os4.c work in AmigaOS 4:


I think I've already met this error 20 years ago, but then it was on a real amiga and it was about placing the image in the chip memory.
I went through all the memory type from exec/memory.h and didn't achieve the result..

Unfortunately, this prevents compilation of old good Workbench applications.
I would like to understand why this is happening. Source and executable files included.
« Last Edit: November 05, 2020, 04:22:23 PM by aGGreSSor »



deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #1 on: November 05, 2020, 03:19:07 PM
My first bet would be that it is endianess related. The image is collection of WORDs. Try flipping the bytes in each element of the array.



aGGreSSor

  • Member
  • ***
    • Posts: 184
    • Karma: +25/-0
    • russian transit
Reply #2 on: November 05, 2020, 04:21:21 PM
My first bet would be that it is endianess related. The image is collection of WORDs. Try flipping the bytes in each element of the array.
Oh, you are absolutely right!

I flipped the bytes:
Code: [Select]
#ifdef __AROS__       // little-endian (i386, x86_64)
WORD myImageData[] =
    {
    0xFFFF, 0x00FF,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0x00C0, 0x0003,
    0xFFFF, 0x00FF,
    };
#else                  // Big-endian (m68, ppc)
WORD myImageData[] =
    {
    0xFFFF, 0xFF00,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xC000, 0x0300,
    0xFFFF, 0xFF00,
    };
#endif

and got what I wanted:


Thank you!


Mazze

  • Junior Member
  • **
    • Posts: 88
    • Karma: +36/-0
Reply #3 on: December 25, 2020, 02:41:23 PM
I recommend
#if AROS_BIG_ENDIAN (#if, not #ifdef ! )
https://aros.sourceforge.io/documentation/developers/app-dev/portable.php#endianness

If you check for only for __AROS__ you'll get wrong endianess on 68k.



aGGreSSor

  • Member
  • ***
    • Posts: 184
    • Karma: +25/-0
    • russian transit
Reply #4 on: December 26, 2020, 01:23:13 AM
I recommend
#if AROS_BIG_ENDIAN (#if, not #ifdef ! )
https://aros.sourceforge.io/documentation/developers/app-dev/portable.php#endianness

If you check for only for __AROS__ you'll get wrong endianess on 68k.
Thank you! I didn't know that, I will take note.