$ gcc airainbow.c -o airainbow
airainbow.c: In function 'main':
airainbow.c:32: warning: assignment makes pointer from integer without a cast
airainbow.c:52: warning: assignment makes pointer from integer without a cast
/tmp/cc65VIBQ.o: In function `draw_rainbow':
airainbow.c:(.text+0x84): undefined reference to `SetRGB32'
airainbow.c:(.text+0x98): undefined reference to `WritePixel'
/tmp/cc65VIBQ.o: In function `main':
airainbow.c:(.text+0x13c): undefined reference to `OpenScreenTags'
airainbow.c:(.text+0x24c): undefined reference to `OpenWindowTags'
airainbow.c:(.text+0x294): undefined reference to `WaitPort'
airainbow.c:(.text+0x2a8): undefined reference to `GetMsg'
airainbow.c:(.text+0x2c0): undefined reference to `CloseWindow'
airainbow.c:(.text+0x2cc): undefined reference to `CloseScreen'
No, the IGraphics->SetRGB32() call is completely wrong. The arguments are struct ViewPort * (not struct RastPort *), uint32, uint32 (not float/double), uint32 (not float/double), uint32.
But even if you want to implement it in the slowest possible way, as ChatGTP did, you should use something like IGraphics->WriteRGBPixel(rp, x, y, (1<<16) | (1<<8) | 0); (which seems to be wrong as well since all pixels will have the same colour instead of a rainbow) instead of SetRGB32() + WritePixel().
@flash Additional bug from ChatGPT: You asked it to generate an AmigaOS source code with no version specified, but got an AmigaOS 3.0+ only one: SetRGB32() was added in AmigaOS 3.0, i.e. even without the bugs the source code isn't usable at all for AmigaOS 2.x and KickStart 1.x AmigaOS systems.
If ChatGPT would be much better for something like that, a good question to ask would be something like "Please port Google Chromium to AmigaOS 4.1, incl. a ReAction GUI and PowerPC JavaScript JIT compiler."
Edited by joerg on 2023/2/6 18:59:10 Edited by joerg on 2023/2/6 19:02:29 Edited by joerg on 2023/2/6 19:03:51 Edited by joerg on 2023/2/6 19:24:41 Edited by joerg on 2023/2/6 19:27:40 Edited by joerg on 2023/2/6 19:46:27
the missing includes are obvious. the SetRGB32 is wrong, it should use SetAPen(rp, pen), and if you are using pens you should Obtain and Release the Pen after. WritePixelColor() is obvious one to use on AmigaOS4.x.
GetMsg() should always be followed by ReplyMsg(), so the while loop is wrong.
Also I suggest waiting for Close Window Event, not just wait for any event, and try to empty the event queue. Technically its not 100% memory leek safe, as new events can be added before CloseWindow, but most Amiga programs have small mistakes like that.
you most likely want to open and close intuition and graphic library as well.
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.