Keyboard controller

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Post by tobe »

I wrote a fast joystick 1 manager, it also manage 3 keyboard keys : Esc, Space and Return.
All you need to get the states is to read $FFFFFC02.b :)
I found a way to restore the keyboard contoller, so this time no need to reset !
I also wrote a ROM dumper and put a ROM image in the archive, the desassembly is in progress :)

http://atari.freemind-tobe.com/HD6301.ZIP
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.
earx
Captain Atari
Captain Atari
Posts: 353
Joined: Wed Aug 27, 2003 7:09 am

Post by earx »

tobe: that's great man! have you done some tests? is it responsive enough when you use poll the reg every vbl?
User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Post by tobe »

Yes it was tested, and the source contains an example, just an output of binary value from the reg.

The reg is updated more than 10 times/vbl.
Hard to compute because of the serial protocol, but the serial speed is locked at 7812.5 bits/s, it make 156.25 bits/frame @50hz, 130.21 @60hz.

Should be responsive enough ;)
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.
User avatar
unseenmenace
Atari God
Atari God
Posts: 1965
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Post by unseenmenace »

I know this is a really old topic but I have come up with a use for this kind of thing :)

Does anyone here (Tobe?) have the time to knock together a slightly modified version of Tobes excellent joystick manager for inclusion in Turrican? If its at all possible I'd like to add more buttons but keep the same idea of just outputting the 8-bit map of controls. The idea being that more than one key can set the same control bit.

This is what I had in mind:-

Bit - - Function - Keys/Buttons

Bit 0 - Up - - - - Joystick Up/Cursor Up
Bit 1 - Down - - Joystick Down/Cursor Down
Bit 2 - Left - - - Joystick Left/Cursor Left
Bit 3 - Right - - Joystick Right/Cursor Right
Bit 4 - Fire 1 - - Joystick Fire/Control
Bit 5 - Fire 2 - - Mouse Button 0/Space Bar
Bit 6 - Pause - - P/Help
Bit 7 - Quit - - - Escape

As you can probably tell the idea is to allow simultaneous joystick or keyboard control but the inclusion of the mouse button is to support a simple joystick socket modification I did on my STE that allows the use of 2 button Amiga joysticks or Mega Drive pads.
UNSEEN MENACE
Several STFM's, 4MB STE, 2MB TT with 1.2GB Hard Drive and 14MB Falcon with 540MB Hard Drive,
Lynx 2 and Jaguar with JagCD
Member of GamebaseST and AtariLegend team
Check out my website at http://unseenmenace.110mb.com
User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Post by tobe »

I think it's possible, but I don't have any spare time actually :(
Take a look at the source code, it should be easy to adapt it to your needs!
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.
User avatar
unseenmenace
Atari God
Atari God
Posts: 1965
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Post by unseenmenace »

Thanks for replying anyway. I'll use the one you did before for now since that will allow me to carry on coding with the same basic input method. I'll have a look at the code for it when I can and have a go at modifying it :)

Thanks for doing such an efficient controller routine in the first place though. It all helps to minimise the CPU usage for me :)
UNSEEN MENACE
Several STFM's, 4MB STE, 2MB TT with 1.2GB Hard Drive and 14MB Falcon with 540MB Hard Drive,
Lynx 2 and Jaguar with JagCD
Member of GamebaseST and AtariLegend team
Check out my website at http://unseenmenace.110mb.com
User avatar
SoLo2
Captain Atari
Captain Atari
Posts: 207
Joined: Wed Feb 04, 2004 4:09 am
Location: Spain
Contact:

Post by SoLo2 »

Incredible!

A full 8bit processor in
my Atari ST, and I didn't know...

Hope it had more RAM and was
easier to program, as it if were
a MegaDrive's Z80! :)

It could run Atari XL code!

Thanks to tobe and others for
this idea...
~~~~~~~~~~~~~~~~~~~~~~~~~~*~~~
The BITS Club http://bits.atari.org
User avatar
alien
Atari maniac
Atari maniac
Posts: 99
Joined: Sat May 01, 2004 4:01 am
Location: USA
Contact:

6301 coding

Post by alien »

Yup, ST CNX pioneered it. FWIW, I sold a 127 byte keyboard, joystick and mouse routine to ESAT software in 1991/1992. So you can get them all working. Takes a lot of work to fit it all into 128 bytes.
Alien / ST-Connexion
User avatar
SoLo2
Captain Atari
Captain Atari
Posts: 207
Joined: Wed Feb 04, 2004 4:09 am
Location: Spain
Contact:

Post by SoLo2 »

Hello!

As I have understood, it is very
slow to read/write to this processor's
128Bytes memory. Is this true?

Else it could be used for some
functions in a demo/intro... 8)

SoLo2
~~~~~~~~~~~~~~~~~~~~~~~~~~*~~~
The BITS Club http://bits.atari.org
User avatar
christos
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2479
Joined: Tue Apr 13, 2004 8:24 pm
Location: Greece

Post by christos »

Solo2 I believe it has been used in a demo, but I can't remember which one. Maybe one of the atari ST demo human databases can tell us which one...
User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Re: 6301 coding

Post by tobe »

alien wrote:Yup, ST CNX pioneered it.
Yes it's right, I just compiled and tried to translate a few docs and code sources.
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.
simonsunnyboy
Moderator
Moderator
Posts: 5239
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re:

Post by simonsunnyboy »

tobe wrote:I wrote a fast joystick 1 manager, it also manage 3 keyboard keys : Esc, Space and Return.
All you need to get the states is to read $FFFFFC02.b :)
I found a way to restore the keyboard contoller, so this time no need to reset !
I also wrote a ROM dumper and put a ROM image in the archive, the desassembly is in progress :)

http://atari.freemind-tobe.com/HD6301.ZIP
It's an old thread resurrected but I want to investigate if modern Hatari versions handle this routine. Unfortunately the download link is dead.
Tobe or anyone else, is this code still available?

I remember taking a look back then but I think I lost it over the years :(
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
Hippy Dave
Atari Super Hero
Atari Super Hero
Posts: 515
Joined: Sat Jan 10, 2009 5:40 am

Re: Keyboard controller

Post by Hippy Dave »

http://atari.sk/download/Hd6301.zip
Google found it for me. Hope it's good.
simonsunnyboy
Moderator
Moderator
Posts: 5239
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Keyboard controller

Post by simonsunnyboy »

It is the old version without the joystick and key polling, only the basic uploader and a sort of raster routine.

I'm looking for the routine with joystick data!
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
npomarede
Atari God
Atari God
Posts: 1346
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Keyboard controller

Post by npomarede »

Hello

Hatari doesn't emulate an HD6301 as it would run in an ST.
What I did in Hatari is to write some handlers to intercept the bytes sent to the ikbd's RAM as well as the execute command.

Then for every known/games demo I encountered, I disassembled the 6301 code to build a custom handler in Hatari that gives the same results : it returns the same bytes in fffc02 as the hd6301 would do if running the small program (but in a rather basic way, it would be much harder to emulate 6301 programs using some timers. "chaos ad" by dnt crew uses the 6301 to decrypt the 68000's code, it includes some timer code, but fortunatelly for Hatari, the timer result is not used in the final XOR :) )

Based on the CRC of the small programs uploaded to the ikdb's RAM, I associated the corresponding handlers to have the demos run as expected.

What this means is that if you upload some example programs to the IKBD, they will just be silently ignored, as it's quite unlikely they match the CRC of a known handler in Hatari (and this will lock the keyboard I guess).

AFAIK, Saint supports real hd6301 emulation (the complex part is not only emulating the hd6301, but correctly emulating all its ports and the ACIA's timings/registers)

Nicolas
Last edited by npomarede on Thu Jun 21, 2012 3:49 pm, edited 1 time in total.
simonsunnyboy
Moderator
Moderator
Posts: 5239
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Keyboard controller

Post by simonsunnyboy »

I see, my requesr is then useless. I thought there was more emulation of the IKBD done in Hatari by now. Well because of the huge task, no regrets.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
LaurentS
Captain Atari
Captain Atari
Posts: 288
Joined: Mon Jan 05, 2009 5:41 pm

Re: Keyboard controller

Post by LaurentS »

Hi,

I started to emulate the 6301 in Hatari last year (the source is still present in hatari's sources).
But, by lack of time, I stopped.

As Nicolas said, the hardest job is not to emulate the 6301 itself (my source may be quite close to it, there were a few instructions not coded and some tests to do), but to "link" it with hatari (timers, IO, ...)

If someone fells interrested to work on this for hatari, this would be a great progress.

Best regards

Laurent
User avatar
1st1
Atari Super Hero
Atari Super Hero
Posts: 885
Joined: Mon May 07, 2012 11:48 am

Re: Keyboard controller

Post by 1st1 »

Hello, you have the complete dissassembled source code of the IKBD chip? Do you see if it sets IO pin 37 to high, if caps lock is pressed, or if it does have some other handling with caps lock? Many of the circuit diagrams of the ST are containing a caps lock led in the keyboard, but it has not been realized in the PCB layout. Maybe it is possible to add it...? See related discussion in the neighbour forum http://forum.atari-home.de/index.php?topic=9720.20
Power without the Price. It's not a bug. It's a feature. _/|\_ATARI

1040STFM in PC-Tower (PAK68/2, OvrScn, 4 MB, 1GB SCSI, CD-ROM...) * 3x Falcon 030 * 3x TT030 * many 260 /520/1040ST(F)(M)(+) * 520/1040STE * many Mega ST * 2x Mega STE * Stacy * STBook * 2x SLM605 * 3x SLM804 * SMM804 * SH 204/205 * Megafile 30/44/60 * SF314 * SF354 * 5x Pofo * PC3 * ...
wheeel
Atariator
Atariator
Posts: 28
Joined: Thu Aug 30, 2007 12:11 pm

Re: Keyboard controller

Post by wheeel »

simonsunnyboy wrote:It is the old version without the joystick and key polling, only the basic uploader and a sort of raster routine.

I'm looking for the routine with joystick data!
I've attached what I think you are looking for here for posterity (sorry for being so late!):
You do not have the required permissions to view the files attached to this post.
User avatar
Orion_
Captain Atari
Captain Atari
Posts: 446
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Post by Orion_ »

a little note on this, I spend 2 days trying to send data inside the 6301 RAM, disassembling the 6301 ROM, trying to emulate it, etc... because my boot code was crashing ...
Finally I found out that the "MEMORY LOAD" function 0x20 of IKBD ROM, won't load any "0x00" value !!
So, if your boot code have a "0x00" value in it, it will be skipped by the memory upload function, generating a buggy code and crash...
So, that's why in tobe's code, he use the trick with "ldS $AF" where $AF always = 0 and $B0 = stack value, because ldS #$00NN won't work as this instruction contains a 0x00 !
Hope that helps ...
Last edited by Orion_ on Fri Oct 30, 2015 4:45 pm, edited 1 time in total.
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB
User avatar
Orion_
Captain Atari
Captain Atari
Posts: 446
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Post by Orion_ »

LaurentS wrote:Hi,
I started to emulate the 6301 in Hatari last year (the source is still present in hatari's sources).
But, by lack of time, I stopped.
Hey Laurent, I used your great 6301 emulator to try to find out how the IKBD ROM works, and I found some bugs inside your emulator, as I don't have knowledge of "mercurial" & fix the code directly in hatari svn, I post some bug correction here:

In Function: hd6301_jmp_ind

Code: Select all

//	value = hd6301_read_memory(addr);
	hd6301_reg_PC = addr;
In Function: hd6301_abx

Code: Select all

	hd6301_reg_X += (Uint16)hd6301_reg_B;	// B is added unsigned
Defines: "<< 1" was used, but the correct value for Z is "2", so, better use the define "hd6301_REG_CCR_Z" to avoid confusion/bugs

Code: Select all

#define HD6301_SET_Z8(a)	hd6301_reg_CCR |= (((Uint8)(a) == 0) << hd6301_REG_CCR_Z)
#define HD6301_SET_Z16(a)	hd6301_reg_CCR |= (((Uint16)(a) == 0) << hd6301_REG_CCR_Z)
There might be more bugs, I don't know, I stopped here :D
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB
User avatar
Orion_
Captain Atari
Captain Atari
Posts: 446
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Post by Orion_ »

I don't know if it is useful, nor if it is correct, but here is a disassembly of the 6301 ROM, with some comments on a few routines (IKBD command parsing, memory load/exec)
some comments might be wrong, I'm no hardware guru :D

Also, there is a typo in tobe's opcode documentation (typo also present in ST Mag doc)
Here are the correct opcode for pula/pulb

Code: Select all

|PULA| 32|   |   |   |   |   |......| SP+,A=(SP)                             |
|PULB| 33|   |   |   |   |   |......| SP+,B=(SP)                             |
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB
User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Keyboard controller

Post by Steven Seagal »

Hi,
I'm very interested in this chip too, and will try to merge your comments into this disassembly:

http://sourceforge.net/p/steemsse/code/ ... mented.txt

(my own comments aren't guaranteed correct either!)

And if you like debugging 6301 emu, there's a lot of code here:

http://sourceforge.net/p/steemsse/code/ ... arty/6301/
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse
User avatar
Orion_
Captain Atari
Captain Atari
Posts: 446
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Post by Orion_ »

You have done far more work on this than me :)
In fact I have only tested my code on Steem SSE, and the dump ram and 6301 trace functions helped me a lot to understand what was wrong with my code.
I have yet to try this on my STe, I need a new floppy drive (or a cosmosex hopefully)
Did you notice any other ROM version of the IKBD ? I will try to dump the one from my French STe as soon as I can.
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB
User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Keyboard controller

Post by Steven Seagal »

Orion_ wrote:You have done far more work on this than me :)
To be clear, it's based on 3rd party code, I did the integration in Steem.
In fact I have only tested my code on Steem SSE, and the dump ram and 6301 trace functions helped me a lot to understand what was wrong with my code.
Glad to know those Boiler options are useful for others. There's also a 6301 memory browser.
Did you notice any other ROM version of the IKBD ? I will try to dump the one from my French STe as soon as I can.
Nope, and your dump will be the same.
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse
Post Reply

Return to “Coding”