Recent

Author Topic: Баги CYBERGRAPHICS AmigaOS 4.1  (Read 1437 times)

Smalovsky

  • Newbie
  • Posts: 2
Баги CYBERGRAPHICS AmigaOS 4.1
« on: September 18, 2023, 02:29:56 pm »
Попробовал использовать библиотеку сайберграфикс для FreePascal 3.2.2 for AmigaOS 4.1 PPC. У меня эмулятор амиги 4000 WinUAE с эмуляцией видеокарты Picasso4 на шине Zorro3  и ускорителя Cyberstorm с 126 МБ fast RAM и процессором 604e.
Я попробовал узнать характеристики видеорежимов с помощью листинга:
Code: Pascal  [Select][+][-]
  1. Program CGX_Test;
  2. uses  exec, sysutils, utility, intuition,agraphics,cybergraphics;
  3. var
  4.  
  5.         execlist:PList;
  6.         cybernode:PCyberModeNode;
  7.  
  8. begin
  9.  
  10.  
  11.  
  12.         execlist:=AllocCModeListTagList(nil);
  13.         if execlist <> nil then writeln('cyber');
  14.         cybernode:=PCyberModeNode(execlist^.lh_Head);
  15.         while cybernode<>nil do
  16.         begin
  17.                 writeln('Mode ',cybernode^.ModeText);
  18.                 writeln('Width ',cybernode^.Width);
  19.                 writeln('Height ',cybernode^.Height);
  20.                 writeln('Depth ',cybernode^.Depth);
  21.                 writeln();
  22.                 cybernode:=PCyberModeNode(cybernode^.Node.ln_Succ);
  23.         end;
  24.  
  25. end.
  26.  

Информация о видеорежимах содержит ошибки. Значения высоты, ширины, глубины цвета и другие поля перепутаны в записи типа TCyberModeNode.
Сделал небольшую коррекцию через указатель:

Code: Pascal  [Select][+][-]
  1. Program CGX_Test;
  2. uses  exec, sysutils, utility, intuition,agraphics,cybergraphics;
  3. var
  4.  
  5.         execlist:PList;
  6.         cybernode:PCyberModeNode;
  7.         p:^Word;
  8.  
  9. begin
  10.         execlist:=AllocCModeListTagList(nil);
  11.         if execlist <> nil then writeln('cyber');
  12.         cybernode:=PCyberModeNode(execlist^.lh_Head);
  13.         while cybernode<>nil do
  14.         begin
  15.                 writeln('Mode ',cybernode^.ModeText);
  16.                 p:=@cybernode^.Width;
  17.                  writeln('Width ',(p-1)^);
  18.                 // writeln('Width ',cybernode^.Width);
  19.                 p:=@cybernode^.Height;
  20.                  writeln('Height ',(p-1)^);
  21.                 //writeln('Height ',cybernode^.Height);
  22.                 p:=@cybernode^.Depth;
  23.                 writeln('Depth ',(p-1)^);
  24.                 //writeln('Depth ',cybernode^.Depth);
  25.                 writeln();
  26.                 cybernode:=PCyberModeNode(cybernode^.Node.ln_Succ);
  27.         end;
  28.  

Теперь вывело правильно ширину, высоту и глубину для видеорежимов. Другие поля я не трогал, но в них тоже напутано.

Как  и кому отправить мне этот баг?

Сам баг:
Неправильное выполнение функции AllocCModeListTagList. Функция возвращает список, элементы которого при приведении к типу указателя PCyberModeNode и получении записи типа TCyberModeNode  по этому указателю содержат неправильные значения( значения перепутаны для полей записи).
« Last Edit: September 20, 2023, 04:07:46 pm by Smalovsky »

AlexTP

  • Hero Member
  • *****
  • Posts: 2294
    • UVviewsoft
Re: Баги CHYBERGRAPHICS AmigaOS 4.1
« Reply #1 on: September 18, 2023, 04:55:52 pm »
исправьте заголовок поста. там опечатка в названии.

так как либа из поставки FPC, то отправлять это надо на FPC bugtracker, вот сюда
https://gitlab.com/freepascal.org/fpc/source/-/issues

нужен акаунт Гитхаб или Гитлаб.
нужен пост на английском.
« Last Edit: September 18, 2023, 04:57:57 pm by AlexTP »

TRon

  • Hero Member
  • *****
  • Posts: 1860
Re: Баги CYBERGRAPHICS AmigaOS 4.1
« Reply #2 on: September 18, 2023, 06:37:55 pm »
If you can wait a day with reporting it as a bug then I can have it verified. I believe you have a mistake in your code.

TRon

  • Hero Member
  • *****
  • Posts: 1860
Re: Баги CYBERGRAPHICS AmigaOS 4.1
« Reply #3 on: September 20, 2023, 12:15:32 am »
Sorry to say that I have managed to wreck my (custom) fs-uae installation before I was able to verify. Go ahead and report so that it won't be forgotten (I need time to set up fs-uae correctly for OS4 again).

Sorry for the inconvenience.

On a side note: the (original) code as presented should work (it does work for/on Amiga/AROS) but there are some minor nitpicking things such as the fact that the list is not traversed entirely correct (last entry is not a valid mode entry but a list end entry) and you forgot to free the allocated modelist.

At first glance it seems to me that one of the record fields is wrongly aligned (which is an RTL related issue if the case).

Smalovsky

  • Newbie
  • Posts: 2
Re: Баги CYBERGRAPHICS AmigaOS 4.1
« Reply #4 on: September 21, 2023, 03:36:37 pm »
Мне помогли с переводом. Попробую отослать на багтрейкер. Вот перевод первого сообщения:

Hi,

While using AmigaOS4 PPC OS (on WinUAE emulator emulating Amiga4000 with graphics card for me) and FreePascal 3.2.2 for AmigaOS4.1 i do have a problem when trying to use CyberGraphics library:

Firstly, i tried to get videomode's properties with this kind of code:

Code: Pascal  [Select][+][-]
  1. Program CGX_Test;
  2. uses  exec, sysutils, utility, intuition,agraphics,cybergraphics;
  3. var
  4.  
  5.         execlist:PList;
  6.         cybernode:PCyberModeNode;
  7.  
  8. begin
  9.  
  10.  
  11.  
  12.         execlist:=AllocCModeListTagList(nil);
  13.         if execlist <> nil then writeln('cyber');
  14.         cybernode:=PCyberModeNode(execlist^.lh_Head);
  15.         while cybernode<>nil do
  16.         begin
  17.                 writeln('Mode ',cybernode^.ModeText);
  18.                 writeln('Width ',cybernode^.Width);
  19.                 writeln('Height ',cybernode^.Height);
  20.                 writeln('Depth ',cybernode^.Depth);
  21.                 writeln();
  22.                 cybernode:=PCyberModeNode(cybernode^.Node.ln_Succ);
  23.         end;
  24.  
  25. end.
  26.  

But returned information contain bugs. Height, width, depth and other fields just messed around into TCyberModeNode. So i made a small modification via pointer:

Code: Pascal  [Select][+][-]
  1. Program CGX_Test;
  2. uses  exec, sysutils, utility, intuition,agraphics,cybergraphics;
  3. var
  4.  
  5.         execlist:PList;
  6.         cybernode:PCyberModeNode;
  7.         p:^Word;
  8.  
  9. begin
  10.         execlist:=AllocCModeListTagList(nil);
  11.         if execlist <> nil then writeln('cyber');
  12.         cybernode:=PCyberModeNode(execlist^.lh_Head);
  13.         while cybernode<>nil do
  14.         begin
  15.                 writeln('Mode ',cybernode^.ModeText);
  16.                 p:=@cybernode^.Width;
  17.                  writeln('Width ',(p-1)^);
  18.                 // writeln('Width ',cybernode^.Width);
  19.                 p:=@cybernode^.Height;
  20.                  writeln('Height ',(p-1)^);
  21.                 //writeln('Height ',cybernode^.Height);
  22.                 p:=@cybernode^.Depth;
  23.                 writeln('Depth ',(p-1)^);
  24.                 //writeln('Depth ',cybernode^.Depth);
  25.                 writeln();
  26.                 cybernode:=PCyberModeNode(cybernode^.Node.ln_Succ);
  27.         end;
  28. end.
  29.  

So then i have correct width, height and depth. Other fields i didn't touch, but they messed too.

To whom i should send a bug report ?

The bug itself are:

Wrong return of the AllocCModeListTagList(): Function return a list, elements of which when casting to a pointer type PCyberModeNode and returning of TCyberModeNode by this pointer contain wrong values (they just messed around in wrong fields).
« Last Edit: September 21, 2023, 03:50:47 pm by Smalovsky »

TRon

  • Hero Member
  • *****
  • Posts: 1860
Re: Баги CYBERGRAPHICS AmigaOS 4.1
« Reply #5 on: September 22, 2023, 06:40:22 am »
@Smalovsky:
I was able to confirm this issue for fpc 3.2.2. I have not checked if it is already fixed in fpc trunk (the default os alignment for records should usually take care of this)

It is indeed an alignment issue for the record structure TCyberModeNode in unit cybergraphics (OS4units).

In order to fix it you have to change that structure to a packed record.

Currently you can use two options to workaround the issue:
1: declare the fixed correct structure inside your program
2: copy the cybergraphics.pas header-file next to your project and in that copied file, fix the record structure. During compilation the compiler will then automatically pick up on the (modified/fixed) cybergraphics unit in your project directory first.

So for example, for using the workaround inside a project you could use:
Code: Pascal  [Select][+][-]
  1. program ListCGFXModes;
  2.  
  3. uses
  4.   exec, agraphics, cybergraphics;
  5.  
  6. type
  7.    PCyberModeNode = ^TCyberModeNode;
  8.    TCyberModeNode = packed record   // <--- make it a packed record
  9.      Node: TNode;
  10.      ModeText: array[0..DISPLAYNAMELEN - 1] of Char; // name for this mode
  11.      DisplayID: ULONG;                               // display id associated with the node
  12.      Width: UWORD;                                   // visible width
  13.      Height: UWORD;                                  // visible height
  14.      Depth: UWORD;                                   // display depth
  15.      DisplayTagList: PTagItem;                       // taglist with extended ModeID information
  16.    end;
  17.  
  18. procedure ListModes;
  19. var
  20.   nodeList: PList;
  21.   node: PNode;
  22.   cgxNode: PCyberModeNode absolute node;
  23. begin
  24.   nodeList := AllocCModeListTagList(nil);
  25.   if assigned(nodeList) then
  26.   begin
  27.     node := nodelist^.lh_head;
  28.     while assigned(node^.ln_succ) do
  29.     begin
  30.       write('Mode = '    , cgxNode^.ModeText);
  31.       write('  Width  = ', cgxNode^.Width);
  32.       write('  Height = ', cgxNode^.Height);
  33.       write('  Depth  = ', cgxNode^.Depth);
  34.       writeln;
  35.       node := node^.ln_succ;
  36.     end;
  37.     FreeCModeList(nodeList);
  38.   end
  39.   else
  40.     writeln('Unable to obtain CGFX Mode list');
  41. end;
  42.  
  43. begin
  44.   ListModes;
  45. end.
  46.  

Also note the use of a more correct way to travers the nodelist (for more information about exec lists and how to use them see here and in particular this) as well as freeing the allocated list.


As written by alextp, bugs can be reported at gitlab: https://gitlab.com/freepascal.org/fpc/source/-/issues

Sorry for me to keep corresponding in English, I meant no disrespect by doing so (I just can't read/write Russian and I do not like butchering my response by using a online translator). Thank you for reporting !
« Last Edit: September 22, 2023, 07:05:49 am by TRon »

 

TinyPortal © 2005-2018