AMIGA alive

AMIGA alive
Showing posts with label amigaos. Show all posts
Showing posts with label amigaos. Show all posts

Friday, February 13, 2026

APTR is dead - long live APTR!

When browsing through AmigaOS developer documentation and C code, there's always a funny, interesting, sometimes enlightening little find.

It's just nice to see how it all ties together, and the changes made from one operating system (API) release to the next. Learning about the infrastructure of software, esp. over multiple versions, exposes some of the thinking process of the operating system developers. 

Sometimes, it also reveals long forgotten secrets. If you're a C coder using AmigaOS, chances are you've been using a datatype known as "APTR" somewhere in your code. It is used extensively throughout AmigaOS 1.3 Native Developer Kit (NDK) C include-files, and even more extensively throughout later NDK releases. 

And it turns out it's wrong!

From NDK 1.3 Includes exec/types.h:

typedef STRPTR      *APTR;      /* absolute memory pointer */

/* sigh.  APTR was misdefined, but compatibility rules.  Heres what it
 * should have been
 */
typedef ULONG       CPTR;       /* absolute memory pointer */

Yes, even the pros make a little mistake from time to time. Obviously, they kept compatibility, meaning they (and everybody else) kept using APTR, when it should be CPTR. 

Interestingly, in NDK 1.3 there is - a little - use of CPTR (in resources/filesysres.h, libraries/romboot_base.h, and libraries/expansion.h), but it has been half-removed (from libraries/romboot_base.h and libraries/expansion.h) and half-reintroduced (in dos/dosextens.h) with later NDK versions.

Chances are you've also been using datatypes SHORT and USHORT in your C code. Guess what: It's wrong, too! Here's another little snippet from NDK 1.3 exec/types.h that may clarify this further, long standing issue:

typedef short       WORD;       /* signed 16-bit quantity */
typedef unsigned short  UWORD;      /* unsigned 16-bit quantity */

...

/* For compatability only: (don't use in new code) */
typedef short       SHORT;      /* signed 16-bit quantity (WORD) */
typedef unsigned short  USHORT;     /* unsigned 16-bit quantity (UWORD) */

SHORT and USHORT are just backwards-compatable [sic] aliases for WORD and UWORD. 

Given the very non-volatile situation of AmigaOS development, both APTR and (U)SHORT won't give you a headache. APTR is used throughout the operating system, and will most likely never be replaced. CPTR is used only in less than a handful of cases - you'll probably never need it (and it has been moved to the "compatibility only" [sic] section of NDK 3.9 exec/types.h). (U)SHORT is deprecated since NDK 1.3, and hasn't been removed in later releases, so it's probably cemented into today's global AmigaOS code base, and will never be removed from the NDK.

So - lessons learned:

- use APTR, it's (not) correct

- (don't) use SHORT and USHORT

;-)

* * *

BONUS: 

Here's yet another nice, ancient compatibility [sic] snippet, from NDK 1.3 Includes libraries/dos.h, moved to dos/dos.h in NDK 3.9:

/* Relative position to Seek() */
#define OFFSET_BEGINNING    -1      /* relative to Begining Of File */

...

#define OFFSET_BEGINING     OFFSET_BEGINNING  /* ancient compatibility */

Thank you - one less typing error to worry about. :-)

Friday, November 8, 2024

A little odd: TAG_DONE and TAG_END

Sometimes one might get confused when to use TAG_DONE in AmigaOS C-code, and when to use TAG_END. The answer is very simple: They're one and the same. But it turns out there might be a little bit of an unknown story to these two widely used tokens.

TAG_DONE showed up before TAG_END, in NDK1.3, along with struct TagItem, but not as part of the system includes, and the TagItem system wasn't used in system functions.

Or was it? This is a section of code from the file Read-Me1.3/A2024Docs/OpenA2024.c, which is part of NDK1.3.

#define NONEWINCLUDES       1   /* don't have 1.3 includes yet  */

#if NONEWINCLUDES       /* Some additional definitions  */

/********** from intuition/screens.h ************/

#define NS_EXTENDED     0x1000  /* NewScreen.Extension is valid     */

struct TagItem
{
    ULONG   ti_Tag;     /* identifies the type of this item */
    ULONG   ti_Data;    /* type-specific data, can be a pointer */
};

/* ---- system tag values ----------------------------- */
#define TAG_DONE   (0L) /* terminates array of TagItems. ti_Data unused */
#define TAG_IGNORE (1L) /* ignore this item, not end of array       */
#define TAG_MORE   (2L) /* ti_Data is pointer to another array of TagItems
             * note that this tag terminates the current array
             */

Note the condition "#if NONEWINCLUDES". It looks as if these definitions were part of some "new includes" that weren't part of the distribution (yet?). 

There appears to be a nice little oddity here:

NS_EXTENDED (and TagItem) can't be found in intuition/screens.h, while other sections of the code (not shown here) can. The code contains a copy of NewScreen structure definition, only extended with an extra field, type TagItem pointer. It then creates an instance of that NewScreen structure, with type NS_EXTENDED, and calls OpenScreen() with that structure. There's no mentioning of NS_EXTENDED, or a TagItem pointer field in the Autodocs of OpenScreen() in this version of the NDK.

Does that mean that AmigaOS1.3 already had an (almost) undocumented feature, that would only be made (really) public with AmigaOS2?

TAG_END appears in NDK2.0, in new system include file utility/tagitem.h, as a clone of TAG_DONE, along with struct TagItem etc.:

NDK2.0-4/include/utility/tagitem.h

#define TAG_DONE   (0L) /* terminates array of TagItems. ti_Data unused */
#define TAG_END TAG_DONE

This NDK's version of intuition/screens.h also defines an ExtNewScreen structure that has the extra TagItem pointer field. 

Looking at the usage of TAG_DONE and TAG_END, across all files that are supplied with NDK2.0, there seems to be no preference. Maybe TAG_END was really just introduced to avoid interruptions in workflow, because many developers would intuitively think, and type, "end" instead of "done"?

Another tiny oddity is a change that appears in NDK3.1. It has a slightly different definition of TAG_END: It's still identical, but for some unexplainable reason, TAG_END isn't bound to TAG_DONE anymore. Instead, a comment explains why both use the same value.

Includes\&Libs/include_h/utility/tagitem.h

#define TAG_DONE (0L) /* terminates array of TagItems. ti_Data unused */
#define TAG_END (0L) /* synonym for TAG_DONE */

We'll probably never find out what happened, precisely.
But that's ok. Fortunately, TAG_DONE and TAG_END are either synonyms, or simply the same. ;-)



Sunday, June 26, 2022

AADevLog #4 - AROS and AmigaOS text editor

Publishing zx81paint on AmiNet led to me reviewing a lot of old C code, and creating an ASCII text editor is certainly an essential project for every C coder.

Actually it started a long time ago: In the late nineties, I was impressed by text editors like Microsoft's "Frontpage" and some MacOS programs, which were among the first to show "tabbed" documents, have integrated shell functions (e.g. recursive search), and some other features I hadn't seen before in GUI text editors. So my idea of a program called "proWEB" was born, an HTML editor with advanced functions like sophisticated TABLE creation, FRAME management, etc. Well, time has passed, web development has changed, my preferences have changed, operating systems have changed, and so on. But the idea of a great text editor, according to my personal taste, has remained. In it's first early incarnation for AmigaOS, "proWEB" didn't really get far. There was a second incarnation for AROS which got considerably further, but I was a bit over-ambitious, and under-educated in software architecture, so that one slowly but steadily came to a halt, too. 

Nowadays, having created a lot of smaller programs, slowly developing a usable concept of a program's architecture, and with some experience with C compilers (vbcc is my favourite) gained, I resurrected this old project again.

Among the first steps of resurrection was to find a nice short name you can easily type into your shell - so now "proWEB" has become: "reED", preferably spoken (and certainly typed in as) "reed", which is a reference to a) my name, b) editing, and c) Phragmites Australis. :-)

To my surprise it took me just a day to make all code adjustments from AROS' gcc to AmigaOS' vbcc, including lots of stylistic improvements, and I got a working executable. The code now doesn't use any special compiler features, and should work with gcc, probably SAS-C, etc. just as it does with vbcc. There were a couple of minor differences between AmigaOS and AROS that needed to be taken care of - for example my old AROS system used a font called "ttcourier" instead of "courier".

"reED" running on AmigaOS3.9 in 2022!

Looking at this old code from my "modern" perspective, it's quite a mess, a lot of things can be done much simpler. But "reED" is more sophisticated than I remembered: It has it's own GUI layout engine, it has a massive menu (which I use more like a notepad, many functions not yet implemented), uses ASL file requesters, it can edit multiple documents, it can mark/cut/copy/paste - and it has actual tabs with keyboard control! Colors might be a bit harsh, though. ;-)

I'm not sure if it makes any sense to devote lots of energy to this project - but it's a sort-of success even at the current stage of development. AmigaOS is great, AROS is great, and why not support both at the same time, it's really easy. (Well, gcc will do, but we still need an updated vbcc for AROS to make it perfect.) And in the end, AROS is just AmigaOS, so it just makes a lot of sense.

Let's see what other old (or new) stuff I can dig out from my harddrive... there are a couple of games I have to seriously review and rework...

Thanks for reading, stay healthy!

* * *

Click here for an overview of all AADevLog articles

Wednesday, December 22, 2021

AmigaOS 3.2.1 is out!

Great news from the operating system side of Amiga things: Hyperion has released AmigaOS update 3.2.1, for registered users, and for free.

In a press release published on 21st Dec. 2021 the availability of the first update to AmigaOS 3.2 was announced, along with a list of highlighted features:

  • Fixes to almost every single gadget and image class
  • Fix to clipboard.device that since AmigaOS 3.1.4 would not handle clips above 16KB in some cases
  • Important fix to locale.library that would convert signed values to unsigned
  • New IconEdit with support for colorful icons (like the “GlowIcons”)
  • TextEdit has gained an ARexx port per open document
  • ShowConfig had its GUI reworked, and can now make reports in AmigaGuide format
  • The RAM disk linking feature have been changed a bit so it seems more like AmigaOS 3.1.4 while still being copy on read as in AmigaOS 3.2
  • Dropping files on console will now activate the console window
  • The screen will no longer remain black if you start up without any attached drive
  • Eject menu item in Workbench 

Go to Hyperion's website to download the update:
https://www.hyperion-entertainment.com/index.php/downloads?view=files&parent=42

Additional sources:
http://amiga-news.de/de/news/AN-2021-12-00061-DE.html

Monday, August 16, 2021

IBrowse 2.5.5 released

IBrowse has received another update, increasing it's version number to 2.5.5.

According to the release announcement, not much has changed visually, this is a maintenance release primarily addressing bugs, but also bringing a couple of new features - here's a quick (incomplete) overview of the changes in version 2.5.5:

  • catalog translations updated (Danish, Italian, Norwegian, Polish, Spanish, Swedish)
  • improved cookie information display
  • added third-party cookie detection / blocking
  • added AmigaOS3.2 detection
  • performance improvements (memory management, JavaScript)
  • bugfixes to form submission (OS4), installation (OS4 with "Enhancer Software"), <EMBED> tag handling, resumed downloads

IBrowse 2.5.5 demo in 32 colors (imageset) on a 64 color WB screen

Ibrowse 2.5.5 demo displaying AmiNet.net

Go to IBrowse's homepage for more details, download, and purchase:
https://www.ibrowse-dev.net/news.php?id=1628931465

 

* * *

Note: The installer script from the demo archive seems to have some small bugs - read below on how to fix.

Bugs were encountered installing IBrowse 2.5.5 demo (downloaded 2021-08-15 from ibrowse-dev.net) on a Amiga 1200 / KS3.0 / WB3.1, choosing "68020-030" version in installer dialogue. Line numbers in the screenshots below might be slightly inaccurate (e.g. due to additional comments).

Error "GETENV: String too long!" is probably caused by a "getenv" that doesn't properly evaluate under AmigaOS3, you have to make a little change to this "if" statement (near line nr. 1640):


Error "Unterminated string literal" might be a quoted string that has to be properly terminated on the same line (near line nr. 1507):

...and it works! :-)

Fixed installer script completes installation!

Monday, July 8, 2019

AmigaOS 3.1.4.1 update released

Hyperion Entertainment CVBA show their commitment to AmigaOS: Today an update for AmigaOS 3.1.4 has been released, fixing some bugs, and adding some new features.

http://www.hyperion-entertainment.com/images/stories/OS3.1.4/005.png

According to Hyperion's press release (see "Sources" below) this update aims to improve user experience and adds more workarounds to improve compatibility with existing software.

It's mainly a bugfix update to AmigaOS 3.1.4, but there are also a couple of new features:
  • Danish and swedish translations
  • Setpatch updated
  • Audio.device compatibility improved
  • HDToolBox improved (default blocksize for large harddrives)
  • CrossDOS compatibility improved
The complete list of bug fixes is considerably longer, Hyperion says the change log is more than 260KB in size. Changes include: updates to CDFileSystem, intution support, audio device, Format, FastFileSystem, HDToolBox, Shell, several AmigaDOS commands, DiskDoctor, and more.

Go to Hyperion's download area for registered customers, and get your free update to AmigaOS 3.1.4.1:
http://www.hyperion-entertainment.com/index.php/downloads?view=files&parent=39


Sources:
http://www.hyperion-entertainment.com/index.php/news/1-latest-news/280
http://amiga-news.de/de/news/AN-2019-07-00016-DE.html

Thursday, July 19, 2018

WinUAE 4.0.1 is out

Famous Amiga emulator WinUAE has been updated to version 4.0.1, as always fixing numerous bugs, and adding new features.

The most advanced and best known Amiga emulator just got another update. No huge changes, mostly bugfixes, and some new features like adding emulation of the QuikPak 4060 accelerator board.

The "Win" in "WinUAE" of course stands for "Windows", but did you know WinUAE is also probably the best Amiga emulator for Linux? Yes, you can install "wine" on your Linux machine to run Windows applications, and WinUAE will work nicely with it.

Whatever hardware you want to run WinUAE on -
head over to http://www.winuae.net and grab your copy!


http://www.winuae.net/wp-content/uploads/2016/12/winuea_v10.png


Sources:
http://amiga-news.de/de/news/AN-2018-07-00028-DE.html
http://www.winuae.net/

Tuesday, July 11, 2017

Cloanto releases Amiga Forever 7


New features include the ability to autostart the PC into any Amiga configuration, enhanced PowerPC emulation support, custom content folders and playlists, and a "playerless" title playback, preview and editing experience.

As always, "Amiga Forever" probably is the most complete Amiga emulation distribution: includes official Amiga ROMs and operating system, latest versions of WinUAE and WinFellow, applications, games, demos, videos, one-click player interface, ... (depending on "Amiga Forever" version/edition)

https://www.amigaforever.com/gfx/nav/af-170x80-2x.gif


Sources:
https://www.amigaforever.com/
https://www.amigaforever.com/news-events/af-7/