atari-home.de - Foren
Software => Coding => Thema gestartet von: mfro am Di 10.01.2023, 13:22:02
-
ich finde das (https://www.atari-forum.com/viewtopic.php?t=42432) 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
-
Lustig. Schon mal mit fortran oder Cobol versucht?
Komm leider momentan nicht auf die Seite, Server scheint überlastet zu sein.
-
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.)
(https://forum.atari-home.de/index.php?action=dlattach;topic=17325.0;attach=32469;image)
-
Oder das hier, an dem so ungefähr alles falsch ist. :D
-
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 ;)
-
Ein Problem mit ChatGPT ist, dass es sehr selten sagt "tut mir leid, weiß ich nicht".
Richtig:
-
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:
write a gfa basic program for the atari st that displays a gem alert box
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?
-
Mit dem Rwabs() Bios-Aufruf ist es ähnlich: die AI braucht mehr Kontext.
write a program for the atari st that reads sector number 5 from the bios device 2 using the Rwabs() Bios system call
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.
-
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.
-
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:
-
Manche Abfragen lehnt ChatGPT auch einfach ab:
Mist. Hatte gehofft ich könnte einige grössere Projekte damit realisieren (lassen) :D