Monday, 18 September 2017

Hatari (esp. Mac) Keyboard Configuration

You may have discovered some difficulties using Hatari because the keyboard layout isn't the same as the real thing.  In particular you might need to type forward or backslash, or the underscore key, and these can be placed in the wrong location to the place you were expecting.  The problem I had was the underscore key couldn't be found anywhere which made typing any commands in SMS_QE (ql operating system?/basic) very difficult.

Here's an example keymap.txt file that helped me when my external microsoft USB keyboard was connected (as a US keyboard, with 'British' selected as the keyboard type (!!))..

# UNDERSCORE(dash) (s) or 12
45,12
# equals
61,13
# WORKS: THIS IS THE HASH. 'SDLK_BACKSLASH' (a) or 43
92,43
# The key to the left of number 1 // Some apps might benefit from mapping to 43 (key to the right of return) or to 96 (key to the left of Z)
# Many apps don't do anything with Atari key 96.
96,41
# Test atari key 96, Make the letter z do a 96:
122,96
# The programmers brackets (square and curly). Normal brackets are on shift 9 and 091,26
93,27
# DELETE (d) or 83
127,83
# Insert or 82
277,82
# Home
278,71
# End or ?temporary UNDO?
279,97

Unfortunately the macos seems to intercept the keys to the right of PrtScn/SysRq and is used to alter screen brightness.  Probably something in the System Preferences->Keyboard->Shortcuts->Display will let me fix that (F14 and F15 were mapped to Display/Increase display brightness).

If you don't like those keys doing what I've assigned them to do, then take a look at:
http://www.atarimuseum.com/computers/16bits/STINTERN.htm
or
http://retrospec.sgn.net/users/tomcat/miodrag/Atari_ST/Atari%20ST%20Internals.htm#KEYMAP
in particular the Keyboard Scancode Map.


Some things to note: An atari keyboard has hash to the right of the enter key, and there's an extra key between equals and backspace.  Worth looking at a photo.  Most applications don't use the UNDO key, but HELP is often mapped to something.

The numbers to the right of the comma are the ones that are in the picture, so eg; 30-33 correspond to ASDF.  So if you want to test eg; whether you've found the right key on your keyboard, change the second number to eg; 30 and then see whether pressing that key gets you an 'A' eg; in a 'create desktop icon' / 'install drive' dialog.  There are some characters that you can't use in a folder name that you might want to use when programming.. I haven't found a good 'keyboard test' program, but have used a couple of word processor / note taking accessories that have helped: EdHak's little brother 'Diary' by Craig Harvey.

Finding the meaning of the first number is more of a case of trial and error.  Some of the keys seem to be straightforward ascii, and come from the SDL library that was used to build Hatari.
For reference, this was with Hatari(en) version 1.9.0, ( running on Mac OS 10.11.6 ) which is a bit of an old one, as version 2.0.0 has been available since November 2016.

Hopefully this helps someone..

I've since then removed that US keyboard layout from my mac and re-identified the keyboard as the ISO/European one so have to repeat the process again.  This time round the MS keyboard has hash next to return and all the pictures on the keys do the correct thing on the mac.  So backslash is next to one shift key and forward slash is the one next to the other shift key (confused?)

I tried this again today and it seems to be using the keymap.txt I've shown above.  The only confusion was I thought I'd lost the hash (#) key, but instead shift 3.  So that still means the key to the left of 1 is generating the same scan as key to the left of enter.  2b and 29 in hex is 41 and 43.  So one of the lines:
92,43
96,41
needs changing.  I'll set 92 to A (30) and 96 to Z (44) temporarily... do hatari preferences, select the keymap.txt file again (no reboot)... and the key to the left of 1 is generating a z. but the hash key is still doing backtick.  And the key to the left of z is generating 'A'.. oops.
So 92 needs to be 41. (ie; make our key to the left of 1
and 96 needs to be 96. (ie; make the key to the left of z generate the key to the left of z)
And putting that in makes the key to the left of 1
And then at some point you think you're going mad... so I set key 45 (underscore) to key 43 (the one to the right of enter)
and then both keys generated a forward-slash. (ie; the one next to enter)..
So I checked the config again..
And remapped 35 to 43

Here's the finished config...
# UNDERSCORE(dash) (s) or 12
45,12
# equals
61,13
# to the left of enter(35)
35,43
# between enter and backspace or to the left of 1
92,41
# to the left of z
96,96

Good luck.

addendum: You might find this page useful, it relates SDL keywords to key numbers..
https://www.apt-browse.org/browse/debian/wheezy/main/i386/libsdl1.2-dev/1.2.15-5/file/usr/include/SDL/SDL_keysym.h and seems to map to what I just did...

 SDLK_MINUS  = 45,
 SDLK_EQUALS  = 61,
 SDLK_HASH  = 35,
 SDLK_BACKSLASH  = 92,
 SDLK_BACKQUOTE  = 96,
 SDLK_LEFTBRACKET = 91,
 SDLK_RIGHTBRACKET = 93,
 SDLK_DELETE  = 127,
 SDLK_INSERT  = 277,
 SDLK_HOME  = 278,
 SDLK_END  = 279,

Friday, 5 May 2017

25/26 Years since... the Mega STE

2016 should have been all about the 25th anniversary of an Atari ST released that ran at 16mhz. Except that 1991 was a terrible time to be releasing computers. There was a huge amount of competition, and besides this 5 years earlier, someone had been there, done that and done it properly…

30 Years Ago... 

So, we go back in time to 1986/87.   Apple developed a computer that could run multiple monitors, in colour, at 16mhz, and not be slowed down by ram having to share memory with video or be accessed 16 bits at a time.   This was the Macintosh II (released March 2, 1987)

All about RAM and performance

So you’d think I could just type into google Mac II memory bandwidth and get the answer. Unfortunately not. The simple answer is its got a 16mhz processor that accesses memory in 32 bit chunks (ie; a true 32 internal and 32 external design). Unfortunately the cost was between $6-8000 for a fully functional system (1mb ram, 40mb hdd) possibly reducing to $3000 over time.. So it made sense where a business needed any of these features.

A nice summary of the system (Macword Macintosh II celebrates 25th anniversary)

A clear leader?

So you think that would be the end of it, Apple just need to keep stomping on the competition as this is still better than anything anyone else can produce.   Maybe reduce the price or number of slots, but keep everything else the same.  Moore’s law would let you develop the next generation (eg; 20, 25, 33 mhz) motherboards and cpu’s and sell them at the premium prices, and then advertise lower spec machines that come from the exact same production process.

Project Lower Cost (LC)

But instead they stomped on themselves and went to plenty of effort developing machines that were cheaper and less expandable.  One of these options was the Mac LC, released in October 1990 [introduced 1990.10.15 at $2,400], which had more colour than any Atari Mega STE without graphics card and cost $3000 (including hard drive and monitor).. Even cheaper was the Mac Classic II ($1900, 2mb ram, 40mb hdd), released in October 1991 which had no external monitor options (and resolution was limited to 512x342 in mono) which seems to have better performance than the LC.

A comparable Mega STE?

Realistically, the Mega STE wasn't released with additional graphics options and wasn’t well publicised* at the time of its announcement.  In theory I can claim it could have sold for £629 (no hdd)/£799 (1Mb) or £929 (£1149 including 12" mono monitor) and 48Mb hard drive (2Mb). (Its hard to find advertising for it in 1991 ... It seems to have been announced in 1990, and trickled into existence in 1991 and Atari printed an advert in November 1991)..
So the Mac classic II is probably about 25-30% more expensive for the same config with smaller screen and smaller hard drive.. released within 2 months of one another.
*Prices from 1st choice computers December 1991, Power Computing April 1992.

Next generation CPU

And then there’s the architecture differences.. The Mac LC used a 32 bit processor* on a 16 bit bus, but had separate vram (video memory), and so ran at 16MHz without cache. The Mega STE used a 68000 processor on a 16 bit bus, with a cache. Performance was close but not quite 2x the speed of a normal ST (with the cache enabled. With cache disabled, there was almost no noticeable increase in speed -- ST Review) so it’s hard to tell which one was actually slower from these descriptions..
But the cpu architecture, the separate video ram, will have meant that definitely the LC was faster even with descriptions such as “the 16 MHz 68020 based Macintosh II from 1987, with an identical processor, ran almost twice as fast as the Macintosh LC”

The advantages of the 68020 over 68000 are 32 bit ALU so 32 bit maths happens in less clock cycles and it has an instruction cache, so there is not as often a need to access ram to fetch after each instruction.   And the LC used the 68030 which has a memory management unit (MMU) which is also very important for running programs more reliably.
The consequences of these design choices can be summed up in one chart that shows that 68030 based macs all running at more than 2x the speed of any 68000 8Mhz traditional mac.
Speedometer 3.06 from low end mac [http://lowendmac.com/benchmarks/speedo3.shtml]
Macbench 2 results are more conservative, showing the slowest 2nd generation mac scoring 0.87 vs 0.37 for 8mhz machines. [https://web.archive.org/web/20020209223728/http://macspeedzone.com/archive/Comparison/oldmodels2.html]

Actual Atari Benchmarks

Of course that still leaves a couple of questions about speed which remain unanswered, - is an 8mhz Atari faster than an 8MHz mac and therefore could a 16MHz Atari be faster than a 15.6672MHz mac.  I don't think there's a simple answer to that, but from the architecture design discussed so far, I would say the same code doing cpu bound stuff (raytracing, spreadsheets) etc, you're only going to see the Macs win.
The operating system on the Mega STE might be enhanced for speed (eg; printing over parallel vs serial, text display enhancements like NVDI, potentially careful use of the blitter) but ultimately, its all trying to fight an uphill battle.

That's all for now.  I was going to add a video of someone else's take on the Mega STE and just to say its extremely compatible with existing STE applications and software and they later enhanced it with a new rom: the advanced TOS 2.06 and high density (1.44meg) disk drives.  The other thing the Mega STE has is a vme bus which gives extra graphics options.. which makes it very expandable. ok out!

This video by Dr Steve Bagley gives you a little idea of what they look like.