Autor Thema: ChatGPT schreibt ein GEM-Programm  (Gelesen 2710 mal)

0 Mitglieder und 1 Gast betrachten dieses Thema.

Offline mfro

  • Benutzer
  • Beiträge: 1.637
ChatGPT schreibt ein GEM-Programm
« am: Di 10.01.2023, 13:22:02 »
ich finde das fast ein bißchen unheimlich...

Fast noch ein wenig unheimlicher finde ich, dass ChatGPT auch ein GEM-Programm in Ada schreibt, obwohl es meines Wissens nach nie einen Ada-Compiler (und schon gar kein GEM-Binding) für den ST gab:

with Ada.Text_IO; use Ada.Text_IO;
with System;
with Atari.AES;
with Atari.VDI;

procedure Main is
   -- AES and VDI handles
   WHandle : System.Address;
   VHandle : System.Address;

   -- AES and VDI parameters
   WSpec   : AES.WSpec;
   VSpec   : VDI.VSpec;

   -- AES and VDI workstations
   AES_Work : AES.Workstation_Type;
   VDI_Work : VDI.Workstation_Type;

   -- AES event buffer
   Event : AES.Event;

   -- Rectangle coordinates
   X1, Y1, X2, Y2 : Integer;
begin
   -- Initialize AES and VDI
   AES.Init;
   VDI.Init;

   -- Open a full-screen AES window
   WSpec.Kind        := AES.Wind_Full;
   WSpec.Title       := To_AES_String("My AES Window");
   WSpec.Handle      := System.Null_Address;
   WSpec.X, WSpec.Y  := 0, 0;
   WSpec.W, WSpec.H  := AES.Desktop_Width, AES.Desktop_Height;
   WSpec.KindOfWork  := AES.AES_Work;
   WHandle := AES.Open_Workstation(WSpec);
   AES_Work := AES.To_Workstation(WHandle);

   -- Open a VDI workstation for the AES window
   VSpec.Handle    := WHandle;
   VSpec.Device    := VDI.Screen;
   VSpec.Format    := VDI.Pixel;
   VSpec.Points    := AES.Desktop_Resolution;
   VSpec.Ratio     := VDI.Square;
   VHandle := VDI.Open_Workstation(VSpec);
   VDI_Work := VDI.To_Workstation(VHandle);

   -- Set the background color to black
   VDI.Background_Color(VDI_Work, VDI.Black);

   -- Draw a red rectangle in the middle of the window
   X1 := AES.Desktop_Width div 4;
   Y1 := AES.Desktop_Height div 4;
   X2 := AES.Desktop_Width * 3 div 4;
   Y2 := AES.Desktop_Height * 3 div 4;
   VDI.Rectangle(VDI_Work, X1, Y1, X2, Y2);
   VDI.Interior_Style(VDI_Work, VDI.Solid, VDI.Red);
   VDI.Draw_Filled(VDI_Work, 1, (X1, Y1, X2, Y2));
   
   -- Wait for the window to be closed
   loop
      AES.Get_Event(Event);
      exit when Event.Kind = AES.Wind_Closed;
   end loop;

   -- Close the AES and VDI workstations
   AES.Close_Workstation(WHandle);
   VDI.Close_Workstation(VHandle);

   -- Exit AES and VDI
   AES.Exit
« Letzte Änderung: Di 10.01.2023, 13:30:49 von mfro »
And remember: Beethoven wrote his first symphony in C

Offline Thorsten Otto

  • Benutzer
  • Beiträge: 1.248
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #1 am: Di 10.01.2023, 14:59:32 »
Lustig. Schon mal mit fortran oder Cobol versucht?

Komm leider momentan nicht auf die Seite, Server scheint überlastet zu sein.

Offline czietz

  • Benutzer
  • Beiträge: 3.570
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #2 am: Di 10.01.2023, 19:08:37 »
Ein Problem mit ChatGPT ist, dass es sehr selten sagt "tut mir leid, weiß ich nicht". Lieber fabuliert es sich eine gut klingende aber falsche Antwort zusammen. Siehe das folgende Beispiel. Zumindest in den GFA-Basic-Versionen, die ich kenne, gibt es keinen Befehl MESSAGE. (Eine Message-Box bekäme man mit ALERT.)



« Letzte Änderung: Di 10.01.2023, 19:09:13 von czietz »

Offline czietz

  • Benutzer
  • Beiträge: 3.570
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #3 am: Di 10.01.2023, 19:20:54 »
Oder das hier, an dem so ungefähr alles falsch ist.  :D

Offline Thorsten Otto

  • Benutzer
  • Beiträge: 1.248
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #4 am: Di 10.01.2023, 19:38:04 »
Vermutlich weiss es überhaupt nichts über GFA, und hat nur "Basic" gelesen. Zeilen-Nummern gibt es in GFA ja auch nicht.

Edit: wie es auf die merkwürdige Ideen mit rwabs kommt ist mir allerdings schleierhaft ;)
« Letzte Änderung: Di 10.01.2023, 19:40:41 von Thorsten Otto »

Offline gh-baden

  • Benutzer
  • Beiträge: 1.967
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #5 am: Di 10.01.2023, 23:44:13 »
Ein Problem mit ChatGPT ist, dass es sehr selten sagt "tut mir leid, weiß ich nicht".

Richtig:

Wider dem Signaturspam!

Offline mfro

  • Benutzer
  • Beiträge: 1.637
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #6 am: Mi 11.01.2023, 08:00:13 »
Vermutlich weiss es überhaupt nichts über GFA, und hat nur "Basic" gelesen. Zeilen-Nummern gibt es in GFA ja auch nicht.

Douglas Adams hat schon gewusst, dass man die richtige Frage (und die Frage richtig) stellen muss:

Zitat
write a gfa basic program for the atari st that displays a gem alert box

Zitat
Here is an example program in GFA Basic for the Atari ST that displays a "GEM alert box":

' GFA Basic program for Atari ST
' Displays a GEM alert box

' Declare variables
DIM message$

' Set message to be displayed in the alert box
message$ = "This is a GEM alert box!"

' Display the alert box
ALERT message$
This program uses the built-in ALERT function to display a message in a GEM window. The message to be displayed is stored in the string variable message$, which is passed as a parameter to the ALERT function.

This code is an example of how GFA basic can be used to display an alert box on the Atari ST, however it depends on specific version of GFA basic and specific system setup.
It is good to have access to the documentation of the version of GFA basic that you are using to be sure of compatibility and to be able to troubleshoot.

Ich hab' mit GFA Basic nichts am Hut, aber das müsste so richtig sein, oder?
And remember: Beethoven wrote his first symphony in C

Offline mfro

  • Benutzer
  • Beiträge: 1.637
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #7 am: Mi 11.01.2023, 08:29:51 »
Mit dem Rwabs() Bios-Aufruf ist es ähnlich: die AI braucht mehr Kontext.

Zitat
write a program for the atari st that reads sector number 5 from the bios device 2 using the Rwabs() Bios system call
Zitat
The Atari ST operating system uses the BIOS (Basic Input/Output System) to interact with devices such as disk drives. To read sector number 5 from the BIOS device 2 using the Rwabs() BIOS system call, you can use the following program in assembly language:

    section code
    start:
        move.l    #2, d0           ; BIOS device number (2 = floppy drive)
        move.l    #5, d1           ; Sector number to read
        move.l    #1, d2           ; Number of sectors to read
        move.l    buffer, a1       ; Address of buffer to store data
        move.w    #512, d3         ; Number of bytes to read
        move.w    #0, d4           ; Read operation
        trap     #14              ; Rwabs() BIOS system call
        tst.w     d0              ; Check for errors
        bmi.s     error           ; Branch to error handler if negative status
        jmp.s     done           
    error:
        ; Handle error
    done:
        ; Continue execution
    section data
    buffer:
        rmb 512                   ; Reserve 512 bytes for the buffer
This program uses the Atari ST's Motorola 68000 assembly language and the BIOS system calls to access the BIOS.
It starts by loading the necessary parameters into registers. The device number is loaded into d0 (2=floppy drive), sector number is loaded into d1, number of sectors to read is loaded into d2 , address of buffer to store data is loaded into a1, number of bytes to read is loaded into d3, and the operation code is loaded into d4 (0 = read)

The trap #14 instruction is used to call the Rwabs() BIOS system call with these parameters, which will read the specified sector from the device and store it in the buffer. The contents of d0 will be updated with the status of the operation: if it's negative, it means an error has occurred. So the program check for errors using the tst.w d0 instruction and jumps to the error handl

Das ist immer noch nicht richtig (die Parameter sind verdreht, werden in Registern übergeben und die Stackkorrektur am Ende fehlt), aber schon deutlich näher dran. Ich habe auch vergessen, ein C-Programm zu verlangen und die AI hat von sich aus beschlossen, es mal in Assembler zu versuchen.
Offensichtlich muss man die richtige Antwort kennen, um die richtige Frage zu stellen.
« Letzte Änderung: Mi 11.01.2023, 08:31:33 von mfro »
And remember: Beethoven wrote his first symphony in C

Offline czietz

  • Benutzer
  • Beiträge: 3.570
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #8 am: Mi 11.01.2023, 08:37:14 »
Ich hab' mit GFA Basic nichts am Hut, aber das müsste so richtig sein, oder?

Nö. DIM braucht man für Arrays. ALERT hat noch weitere Parameter.


Offline MJaap

  • Benutzer
  • Beiträge: 1.558
  • ST-Computer
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #9 am: Mi 11.01.2023, 17:04:00 »
Bei mir kam folgendes Programm bei der GEM message box in GFA Basic on the Atari ST:

' Import the GEM library
BLOAD "GEM.LIB",R

' Declare the variables
DIM id$(3), wtitle$(20), wtext$(60)

' Define the message box text and title
wtitle$ = "My Message Box"
wtext$ = "Hello, World!"

' Open the message box
id$ = " "
FORM_CENTER(id$, 0, 0, wtitle$, wtext$)

Vielleicht Omikron? ;)

Manche Abfragen lehnt ChatGPT auch einfach ab:

Offline Thorsten Otto

  • Benutzer
  • Beiträge: 1.248
Re: ChatGPT schreibt ein GEM-Programm
« Antwort #10 am: Mi 11.01.2023, 17:14:50 »
Manche Abfragen lehnt ChatGPT auch einfach ab:

Mist.  Hatte gehofft ich könnte einige grössere Projekte damit realisieren (lassen) :D