Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
46 user(s) are online (20 user(s) are browsing Forums)

Members: 0
Guests: 46

more...

Headlines

 
  Register To Post  

ChatGPT and Amiga Os 4
Just popping in
Just popping in


See User information
Just asked to ChatGPT to generate code to draw a rainbow targeting Amiga OS4.

Here the exact question -> "Write a C program to draw a rainbow in a 24bit screen for Amiga OS computer"

I got following result (untested), any comment?

#include <graphics/gfx.h>
#include <intuition/intuition.h>

#define WIDTH 640
#define HEIGHT 480

void draw_rainbow(struct RastPort *rp)
{
    
int xyhue;
    for (
0HEIGHTy++)
    {
        for (
0WIDTHx++)
        {
            
hue 360;
            
SetRGB32(rphue1.01.00);
            
WritePixel(rpxy);
        }
    }
}

int main(void)
{
    
struct Window *window;
    
struct RastPort *rp;
    
struct Screen *screen;

    
screen OpenScreenTags(NULL,
                            
SA_Depth24,
                            
SA_WidthWIDTH,
                            
SA_HeightHEIGHT,
                            
SA_QuietTRUE,
                            
TAG_END);

    if (!
screen)
    {
        return 
1;
    }

    
window OpenWindowTags(NULL,
                            
WA_Left0,
                            
WA_Top0,
                            
WA_WidthWIDTH,
                            
WA_HeightHEIGHT,
                            
WA_NoCareRefreshTRUE,
                            
WA_ActivateTRUE,
                            
WA_RMBTrapTRUE,
                            
WA_CloseGadgetTRUE,
                            
WA_DragBarTRUE,
                            
WA_DepthGadgetTRUE,
                            
WA_Title, (ULONG)"Rainbow",
                            
WA_IDCMPIDCMP_CLOSEWINDOW,
                            
TAG_END);

    if (!
window)
    {
        return 
1;
    }

    
rp window->RPort;
    
draw_rainbow(rp);

    
WaitPort(window->UserPort);
    while (
GetMsg(window->UserPort))
        ;

    
CloseWindow(window);
    
CloseScreen(screen);

    return 
0;
}

Go to top
Re: ChatGPT and Amiga Os 4
Just can't stay away
Just can't stay away


See User information
@flash

gcc airainbow.-o airainbow
airainbow
.cIn function 'main':
airainbow.c:32warningassignment makes pointer from integer without a cast
airainbow
.c:52warningassignment makes pointer from integer without a cast
/tmp/cc65VIBQ.oIn function `draw_rainbow':
airainbow.c:(.text+0x84): undefined reference to 
`SetRGB32'
airainbow.c:(.text+0x98): undefined reference to `WritePixel'
/tmp/cc65VIBQ.oIn 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'

So, not quite there, but pretty impressive.

Best regards,

Niels

Go to top
Re: ChatGPT and Amiga Os 4
Just can't stay away
Just can't stay away


See User information
You asked it for Amiga OS computer and not for Amiga OS 4 computer.

Add inline4 headers and try to compile again.

It looks correct with quick look.

Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top
Re: ChatGPT and Amiga Os 4
Amigans Defender
Amigans Defender


See User information
@nbache

Yeah, the includes are wrong - should be proto/graphics and proto/intuition. WaitPort is in Exec which isn't even attempted to be included.

Go to top
Re: ChatGPT and Amiga Os 4
Just can't stay away
Just can't stay away


See User information
@TSK
Quote:
It looks correct with quick look.
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
Go to top
Re: ChatGPT and Amiga Os 4
Home away from home
Home away from home


See User information
@flash

It’s a starting point, the code is full of bugs.

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.
Go to top
Re: ChatGPT and Amiga Os 4
Home away from home
Home away from home


See User information
@nbache

Obviously, this needs the following line at top of the code, on AmigaOS4.1

#define __USE_INLINE__

or -D__USE_INLINE__ as command line argument.


Edited by LiveForIt on 2023/2/7 7:08:38
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: ChatGPT and Amiga Os 4
Just can't stay away
Just can't stay away


See User information
@LiveForIt (and others)

Yeah, I'm not really up to speed in development on Amiga, just thought I'd give it a quick go since I did have the SDK/compiler installed.

So please go ahead, the rest of you, if you like, and see if you can make it work .

Best regards,

Niels

Go to top
Re: ChatGPT and Amiga Os 4
Just popping in
Just popping in


See User information
try chatsonic is more powerful and accurate than chatGPT

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project