How to avoid switching to ug runtime on target?

This forum is dedicated to those who want support programming in ugBASIC.
Questo forum è dedicato a chi desidera supporto per programmare in ugBASIC.
Ce forum est dédié à ceux qui souhaitent prendre en charge la programmation en ugBASIC.
Post Reply
User avatar
skr
Posts: 5
Joined: Thu Dec 26, 2024 12:44 pm
Location: Southern Germany

How to avoid switching to ug runtime on target?

Post by skr »

Hi all, new guy here (you might know me from ABBUC) and trying a "quick start" with ugBasic (especially IDE)

The documentation is amazing, but overwhelming and so I ask here ;)

Target is Atari XL, and I want a simple Text output on the default text screen. This is my ugBasic code:

Code: Select all

SCREEN #2
PRINT "Hello ugBASIC"
It compiles, opens Altirra (Atari-Emulator) and shows the Atari Graphics 0 (Text) Screen for a moment and then switches to a black screen saying "ugBasic runtime version 1.16.5" and prompts me with a flashing cursor.

When I now enter "run", it prints "Hello ugBASIC", but on that black screen which I think is SCREEN #4.

Question: How do I run that simple program, so that it opens the text screen (Graphics 0, SCREEN #2) in Altirra and outputs the text there, instead of showing the ugBasic runtime?
spotlessmind1975
Site Admin
Posts: 191
Joined: Fri Oct 06, 2023 8:25 pm

Re: How to avoid switching to ug runtime on target?

Post by spotlessmind1975 »

Hi skr, and welcome! :D

First of all, thank you very much for your message, and for your intention to deepen ugBASIC, and its IDE!
skr wrote: Fri Dec 27, 2024 9:32 am It compiles, opens Altirra (Atari-Emulator) and shows the Atari Graphics 0 (Text) Screen for a moment and then switches to a black screen saying "ugBasic runtime version 1.16.5" and prompts me with a flashing cursor.
From the symptoms your program exhibits, it would appear that the runtime module required to participate in the 10 liner contest is active, but normally it should not be active. This mode is activated using the -1 option on the command line, which among other things activates a series of alternative features and deactivates some features, which cannot be used in that contest.

If you use the command line to compile, you should make sure that the -1 option is not present on the command line. If, as you suggest, you are using the IDE, you should make sure that the Build > "10 Liner" Contest option is unchecked, or that the Build > Include source code into executable option is unchecked, too.
skr wrote: Fri Dec 27, 2024 9:32 am Question: How do I run that simple program, so that it opens the text screen (Graphics 0, SCREEN #2) in Altirra and outputs the text there, instead of showing the ugBasic runtime?
The way you were doing it seems correct to me, and that's what I get on my IDE. As an additional thing, I would insert a CLS command to ensure that the screen is cleared, once the mode is changed. This is not done automatically, because it involves inserting additional code that may not be used. However, if you want to change this behavior, you can use the DEFINE CLS IMPLICIT directive (which, however, involves potentially more code).

This is my suggestion:

Code: Select all

SCREEN #2
CLS
PRINT "Hello ugBASIC"
Or:

Code: Select all

DEFINE CLS IMPLICIT
SCREEN #2
PRINT "Hello ugBASIC"
Let me know if this solves the problem.
User avatar
skr
Posts: 5
Joined: Thu Dec 26, 2024 12:44 pm
Location: Southern Germany

Re: How to avoid switching to ug runtime on target?

Post by skr »

spotlessmind1975 wrote: Fri Dec 27, 2024 9:49 am From the symptoms your program exhibits, it would appear that the runtime module required to participate in the 10 liner contest is active, but normally it should not be active.
Right, I wasn´t aware of it. Now it´s off. :)
If you use the command line to compile
I´m using IDE only, as cas was asking for it, and it looks interesting to me.
Let me know if this solves the problem.
No, it doesn´t. ;)

Unchecking the 10Liners option makes it executing the code (in Altirra) instead of going to the runtime, but still, it´s the wrong mode.
The text screen, Graphics 0 with white text on blue background, pops up but then there´s a black screen with the text printed on it, which seems not to be Graphics 0.
spotlessmind1975
Site Admin
Posts: 191
Joined: Fri Oct 06, 2023 8:25 pm

Re: How to avoid switching to ug runtime on target?

Post by spotlessmind1975 »

Hi skr, and thank you for your feedback!
skr wrote: Fri Dec 27, 2024 11:30 am The text screen, Graphics 0 with white text on blue background, pops up but then there´s a black screen with the text printed on it, which seems not to be Graphics 0.
I checked again, but it seems to me that it is in ANTIC 2 mode (i.e. in Graphics Mode 0). If we take the assembly code that is generated, a 25-line Display List (DLI) is prepared, where each line is associated with the ANTIC 2 mode. The fact that it is black on white I think it depends on the default colors for that target (and, in general, they are the default colors on ugBASIC for other targets).

If you want, you can change them to the standard ones you can use this code:

Code: Select all

SCREEN #2
PEN $ca
PAPER $94
PRINT "Hello ugBASIC"
User avatar
skr
Posts: 5
Joined: Thu Dec 26, 2024 12:44 pm
Location: Southern Germany

Re: How to avoid switching to ug runtime on target?

Post by skr »

Thank you very much! That looks like it should. :)

When using Atari BASIC, the expected behaviour is to have those colors and actually the cursor on position 2 (POKE 82,2) instead of the very beginning of the line (POKE 82,0). So, using "SCREEN #2" does not translate to GRAPHICS 0 command, but creates the DisplayList. Not a big deal, but one might stumble over this.

Question: Can it be changed, that the command "GRAPHICS 0" translates to what is expected on the real hardware? Or should I figure out how to write a little reusable routine in ugBASIC to do so?

I´m just trying to keep things as straight forward as possible to make using ugBASIC as easy as possible.
Have you played Atari today?
spotlessmind1975
Site Admin
Posts: 191
Joined: Fri Oct 06, 2023 8:25 pm

Re: How to avoid switching to ug runtime on target?

Post by spotlessmind1975 »

skr wrote: Fri Dec 27, 2024 12:27 pm Thank you very much! That looks like it should.
Great! :D
skr wrote: Fri Dec 27, 2024 12:27 pm Question: Can it be changed, that the command "GRAPHICS 0" translates to what is expected on the real hardware? Or should I figure out how to write a little reusable routine in ugBASIC to do so?
If I understand the requirement correctly, you would like the behavior of ugBASIC to emulate, as much as possible, the behavior of ATARI BASIC. In that case you could use the compatibility mechanism already implemented with the TSB project. There is a directive called OPTION DIALECT, which allows you to change syntax and semantics to adapt it to that of a different BASIC. In this case, I would add support for ATARI BASIC.

I added a ticket about this:
Add support for ATARI BASIC dialect behaviours

I'll start with the instructions you kindly shared above, regarding the GRAPHICS command and the cursor position. Feel free to point out, here or in the ticket, any behaviors you think should be reported in the context of ugBASIC with the DIALECT option enabled.
skr wrote: Fri Dec 27, 2024 12:27 pm I´m just trying to keep things as straight forward as possible to make using ugBASIC as easy as possible.
Absolutely, I think it's the best way. The ugBASIC language lends itself quite well to adaptation, thanks to the adoption of the isomorphic paradigm. Consider that it is already 90% compatible with Commodore's BASIC V2 "out of the box", and with the Tuned Simons' BASIC using the DIALECT directive.
spotlessmind1975
Site Admin
Posts: 191
Joined: Fri Oct 06, 2023 8:25 pm

Re: How to avoid switching to ug runtime on target?

Post by spotlessmind1975 »

Hi skr!
skr wrote: Fri Dec 27, 2024 12:27 pm Question: Can it be changed, that the command "GRAPHICS 0" translates to what is expected on the real hardware? Or should I figure out how to write a little reusable routine in ugBASIC to do so?
In the beta version I just added some of the implementations that make ugBASIC more similar to ATARI BASIC. To download and activate the beta version with the IDE, you have to go to Build > Options and check Use BETA compiler checkbox. Then go to Configuration > Compilers and download the compiler for atarixl, clicking on the "beta" icon placed next to the name of the compiler for this target.

Now you can try to compile this code:

Code: Select all

OPTION DIALECT ATARI BASIC
GRAPHICS 0
PRINT "Hello ugBASIC"
PRINT "Hello ugBASIC"
PRINT "Hello ugBASIC"
PRINT "Hello ugBASIC"
You should obtain this:

Image

Let me know!
User avatar
skr
Posts: 5
Joined: Thu Dec 26, 2024 12:44 pm
Location: Southern Germany

Re: How to avoid switching to ug runtime on target?

Post by skr »

Wonderful, this works as expected. Many thanks. :)

Image
Post Reply