(classic) New target: Triumph Adler/Royal Alphatronic PC

Discussion about other targets
Post Reply
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

(classic) New target: Triumph Adler/Royal Alphatronic PC

Post by dom »

At the request of RobertK I've added Alphatronic PC support.

* Z80 @ 4 Mhz
* 64k RAM, 24k ROM + 4k chargen
* HD46505SP (aka mc6845) as CRTC

Although the machine has got 64k of RAM, I've not investigated the disc interface so we can't use all of it! As a result, z88dk is limited to generating 16k ROMpack cartridges.

In terms of support:

* Generic console
* Inkey keyboard driver

So text based programs should work okay. The native character set is exposed through the console so you can print "semi-graphics"

Planned:

* Lores graphics (I think 80x75) - the pixels will be uneven since the font is 8x10 pixels divided into 3 vertical pixels

Not working (on emulator):

* Switching to mode 1 should switch to 80 column mode, but mame doesn't seem to support it.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Lores graphics (80x75) have now been added
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Many, many thanks for this new target! I've got my game already running on it, only keyboard input is not fully working yet. For some reason, kbhit() and getch() work in the menu, but not inside the game loop. I assume that I will have to use in_inkey() instead.

P.S. To explain why I am interested in the Alphatronic PC: as a kid I saw it in a catalogue and dreamed of having one. It looked so cool, and from my dad's typewriter I knew that Triumph-Adler was a company that made only "serious business stuff". Fortunately I never got one, because I would have been *very* disappointed due to the lack of software and being absolutely the only kid in my area with that machine. :-)
Besides, it was very expensive compared to other computers of that era. I still own that catalogue, I will have to dig it out again.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

That's bizarre behaviour, it really shouldn't matter where they're called from! Can you share some source and I'll investigate.

On that target, kbit() ends up calling in_Inkey() in anycase. kbhit() internally uses a variable, so if that was overwritten with 0 every time round the loop then you'd see that behaviour - where does "kbhit_key" end up in the memory map? (Compile with -m)
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Here is a little test, first try it on the ZX81 to see to desired behaviour.

On the Alphatronic PC, it seems that kbhit() does not work when there is frequent printing (or plotting) inside the loop.

Code: Select all

// Compile with
// zcc +zx81 -startup=2 -o kbhittest_ZX81 -create-app kbhittest.c
// zcc +vg5k -lm -o kbhittest_vg5000 -create-app kbhittest.c
// zcc +aquarius -lm -o kbhittest_aquarius -create-app kbhittest.c
// zcc +alphatro -o kbhittest_alphatronic -create-app kbhittest.c

#include <stdio.h>

void main()
{ 
  char c;
  int exitLoop;
  printf("%c",12); // clear the screen
  printf("\nkbhit() test\n");

  printf("\n\nfirst loop\npress n, or x to exit loop\n\n");
  exitLoop=0;
  do
  {                
        if(kbhit())
        {
                c = getch();
                if (c=='n' || c=='N') printf("\nkey n pressed");
                if (c=='x' || c=='X') exitLoop=1;
        }        
  }
  while(exitLoop==0);

  printf("\n\nsecond loop\n\n");
  exitLoop=0;
  do
  {                
    printf("\npress n, or x to exit loop");
        if(kbhit())
        {
                c = getch();
                if (c=='n' || c=='N') printf("\nkey n pressed");
                if (c=='x' || c=='X') exitLoop=1;
        }        
  }
  while(exitLoop==0);

  printf("\n\ndone.");
  fgetc_cons();
  
  printf("%c",12); // clear the screen 
  return;
}
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Thanks for the snippet I think I understand what's going on - it's to do with key debounce.

There's a counter that decrements everytime in_GetKey() (which is called by getk() which is called by kbhit()) is called.

Thus it's only picking up a keypress every 256 calls to kbhit() which when you're printing on a screen isn't very often.

I'm not sure why it's working on the zx81 - it must have different initial debounce values, I'll need to investigate and tune the values.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Of course, the ZX81 will be using the result of the ROM scanner, not the inkey driver! That's why it works and why everything else doesn't!
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

I can only say that among all targets that my game supports, only the Alphatronic PC seems to be affected by this. Until the recent in_KeyPressed() additions I have been using kbhit() and getch() inside the game loop on all non-Sinclair targets, and with that problem keyboard control would not have been working, but it did work.

P.S. All other kbhit() targets support ANSI so there I include conio.h, but the Alphatronic target doesn't. Maybe this makes some difference.

P.P.S. In my test program you should add msleep(1000) before the second loop, because on some systems (e.g. Aquarius) the first x keypress would immediately end the second loop as well.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I think I fixed this issue in this change https://github.com/z88dk/z88dk/commit/3 ... 4cc4197db5 - it certainly worked on the Alphatronic. It's in the current nightly.

Most of the other targets you're using don't use in_Inkey() for kbhit() so weren't affected - it's only the new ones where I'm bypassing the firmware that had this problem.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

I can confirm that the keyboard problem ist now solved in the current nightly. Many thanks again!
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Thanks for the confirmation.

BTW, there's another target coming through that should work for your game as well. I'll also add graphics to the multi8 soon so that will good for you as well!
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

There is still one problem: could you please investigate why the 8 key is not working?

I haven't checked all keys, but among those used in my game all work except for 8.

Here is my updated kbhittest.c program.

Code: Select all

// Compile with
// zcc +zx81 -startup=2 -o kbhittest_ZX81 -create-app kbhittest.c
// zcc +vg5k -lm -o kbhittest_vg5000 -create-app kbhittest.c
// zcc +aquarius -lm -o kbhittest_aquarius -create-app kbhittest.c
// zcc +alphatro -o kbhittest_alphatronic -create-app kbhittest.c
// zcc +z9001 -lgfx9001 -o kbhittest_z9001 -create-app kbhittest.c

#include <stdio.h>

void main()
{ 
  char c;
  int exitLoop;
  printf("%c",12); // clear the screen
  printf("\nkbhit() test\n");

  printf("\n\nfirst loop\npress n / 5 / 8, or x to exit loop\n\n");
  exitLoop=0;
  do
  {                
        if(kbhit())
        {
                c = getch();
                if (c=='n' || c=='N') printf("\nkey n pressed");
                if (c=='5') printf("\nkey 5 pressed");
                if (c=='8') printf("\nkey 8 pressed");
                if (c=='x' || c=='X') exitLoop=1;
        }        
  }
  while(exitLoop==0);

  msleep(1000);  // Wait one second so that you don't press x also for the second loop
  
  printf("\n\nsecond loop\n\n");
  exitLoop=0;
  do
  {                
    printf("\npress n / 5 / 8, or x to exit loop");
        if(kbhit())
        {
                c = getch();
                if (c=='n' || c=='N') printf("\nkey n pressed");
                if (c=='5') printf("\nkey 5 pressed");
                if (c=='8') printf("\nkey 8 pressed");
                if (c=='x' || c=='X') exitLoop=1;
        }        
  }
  while(exitLoop==0);

  printf("\n\ndone.");
  fgetc_cons();
  
  printf("%c",12); // clear the screen 
  return;
}
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Oops, I just checked the keymap and the '8' key was being mapped to '0'. I think you should still have got '8' via the numeric keypad though.

Regardless, should be sorted in the next build.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by stefano »

you all probably read this other post, but I think it's useful to leave a link here

https://z88dk.org/forum/viewtopic.php?p=21058#p21058
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by RobertK »

RobertK wrote: Sun Dec 04, 2022 8:43 am On the Alphatronic, there seems to be a bug when using screen mode 1 in cartridge mode. The screen stays in 40 column mode, and every line feed gets doubled.
Could you please have a look at this? Attached is my grtest.c program and a batch file that creates both the 80x72 and 160x72 Alphatronic file.

With 80x72 it looks good:
Alphatronic_80x72.jpg

With 160x72 it looks like this:
Alphatronic_160x72.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by dom »

I've been scratching my head about this one, but then I looked at the top of this thread.

It looks like I never got it working, though WIDTH 80 in BASIC does work. So I guess I'll need to go digging a bit more.

Edit: Aha, I've got it, I need to drive the CRTC directly...
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by dom »

I've pushed a change to support switching to 80 column mode:
Screenshot 2023-05-30 at 20.21.17.png
It turns out the IO bit marked "80 column mode" doesn't actually do anything and the HD46505 needs to be poked manually to switch between widths.
You do not have the required permissions to view the files attached to this post.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by RobertK »

Very good, thank you! That makes Deepspace work on the Alphatronic. And the mono sprites perform very well.

Deepspace_Alphatronic_160x72.jpg

Is there a way to get rid of the blinking cursor? You can see it in the 160x72 grtest in the top left corner.
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by dom »

Of course there is, consider it done.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by RobertK »

Thank you.

One more thing (hopefully the last issue, then it should be perfect): I have discovered a bug in the draw() function in 160x72, that's the reason why the fuel bar doesn't show up in Deepspace. Drawb() seems to be working correctly.

Here is my Megatoll graphics test in 80x72 (with " || defined(__ALPHATRO__) " removed in line 20), this is what it should look like:
Megatoll_Alphatronic_80x72.jpg

And here is the result in 160x72, all horizontal lines and a few diagonal ones are missing:
Megatoll_Alphatronic_160x72.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by dom »

Thanks for the report, I fixed this one up a couple of days ago - my usual favourite issue of not changing the resolution that a few of the functions check against.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Re: (classic) New target: Triumph Adler/Royal Alphatronic PC

Post by RobertK »

Thanks, it's all fine now. I have now released the Alpahtronic version of Deepspace.

In addition to the ROM file, I have also included a CP/M disk image, Stefano has recently added the Alphatronic subtype.
Post Reply