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:

Postby tobe » Wed Jan 12, 2005 2:42 pm

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.

User avatar
earx
Captain Atari
Captain Atari
Posts: 353
Joined: Wed Aug 27, 2003 7:09 am

Postby earx » Wed Jan 12, 2005 4:06 pm

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:

Postby tobe » Wed Jan 12, 2005 4:26 pm

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: 1961
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Postby unseenmenace » Wed Sep 13, 2006 9:42 am

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:

Postby tobe » Wed Sep 27, 2006 11:16 am

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: 1961
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Postby unseenmenace » Mon Oct 02, 2006 7:13 am

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:

Postby SoLo2 » Sat Oct 21, 2006 3:29 am

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: 95
Joined: Sat May 01, 2004 4:01 am
Location: USA
Contact:

6301 coding

Postby alien » Tue Oct 24, 2006 6:26 pm

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:

Postby SoLo2 » Tue Oct 24, 2006 7:47 pm

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: 2455
Joined: Tue Apr 13, 2004 8:24 pm
Location: Greece
Contact:

Postby christos » Wed Oct 25, 2006 7:08 am

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

Postby tobe » Wed Oct 25, 2006 11:18 am

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.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5131
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re:

Postby simonsunnyboy » Tue Jun 19, 2012 5:11 pm

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

Postby Hippy Dave » Tue Jun 19, 2012 5:21 pm

http://atari.sk/download/Hd6301.zip
Google found it for me. Hope it's good.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5131
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Keyboard controller

Postby simonsunnyboy » Tue Jun 19, 2012 5:25 pm

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: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Keyboard controller

Postby npomarede » Wed Jun 20, 2012 9:39 pm

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.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5131
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Keyboard controller

Postby simonsunnyboy » Thu Jun 21, 2012 3:22 pm

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: 284
Joined: Mon Jan 05, 2009 5:41 pm

Re: Keyboard controller

Postby LaurentS » Fri Jun 22, 2012 1:53 pm

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: 850
Joined: Mon May 07, 2012 11:48 am

Re: Keyboard controller

Postby 1st1 » Sun Aug 05, 2012 6:09 am

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...) * 2x Falcon 030 32GB/14MB+ScrnBlstrIII * 2x TT030 73GB/20MB+Nova * 520/1040STFM * 520/1040STE * 260/520ST/+ * some Mega ST * 2x Mega STE 500MB/4MB+M.CoCo * Stacy * STBook * SLM605 * SLM804 * SLM605 * 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

Postby wheeel » Wed Sep 26, 2012 4:58 pm

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: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Postby Orion_ » Fri Oct 30, 2015 4:39 pm

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: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Postby Orion_ » Fri Oct 30, 2015 4:44 pm

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: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Postby Orion_ » Fri Oct 30, 2015 4:51 pm

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)                             |
You do not have the required permissions to view the files attached to this post.
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

Postby Steven Seagal » Sat Oct 31, 2015 8:46 am

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/HEAD/tree/trunk/steemsse/steem/doc/SSE/Atari%20ST%206301%20Rom%20disassemby%20commented.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/HEAD/tree/trunk/steemsse/3rdparty/6301/
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Keyboard controller

Postby Orion_ » Sat Oct 31, 2015 10:15 am

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

Postby Steven Seagal » Sat Oct 31, 2015 5:54 pm

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


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 7 guests