Joystick and keyboard input
Joystick and keyboard input
Hi there guys,
Does anyone happen to have some assembly programming reference material they got top of mind regarding reading and handling joystick and keyboard input for the QL? I havent looked into it just yet, but I reckoned just asking never hurt anyone.
I intend to handle joystick and keyboard input without using interrupts and without using the OS; I assuming this is possibe.
Does anyone happen to have some assembly programming reference material they got top of mind regarding reading and handling joystick and keyboard input for the QL? I havent looked into it just yet, but I reckoned just asking never hurt anyone.
I intend to handle joystick and keyboard input without using interrupts and without using the OS; I assuming this is possibe.
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: Joystick and keyboard input
I've never used joysticks, so I can't help you there. As for reading the keyboard, without the OS, good luck!
I am 99.9% certain that you will need to talk to the second processor, which might be the 8049 (can you tell I have a good grasp of these things?) to be able to read the keyboard.
There are some details here on doing so: http://qdosmsq.dunbar-it.co.uk/doku.php ... rap_1:hdop unfortunately, no examples at this time. I'll sort something out later.
Cheers,
Norm.
I am 99.9% certain that you will need to talk to the second processor, which might be the 8049 (can you tell I have a good grasp of these things?) to be able to read the keyboard.
There are some details here on doing so: http://qdosmsq.dunbar-it.co.uk/doku.php ... rap_1:hdop unfortunately, no examples at this time. I'll sort something out later.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Re: Joystick and keyboard input
Hi there! Thanks for the quick response! As you can perhaps tell, Im a complete noob to these things, but I am hoping that one could poll the hardware, rather than being interrupted by it
Re: Joystick and keyboard input
The joystick is (like the keyboard) handled by the 8049 - So, you need to talk to the coprocessor in order to get both.
In BASIC, you would check the joystick with the KEYROW command, joystick 1 is the same as keyrow 1 (cursor keys, ESC and ENTER - in principle, moving the joystick is the same as pressing a key, see QL Manual). Joystick 2 is the same as pressing F1-F5
In order to do the same thing in assembly, you prepare a message to the 8049, send it, receive the answer and evaluate what you got (note evaluation is not complete...).
note it's easy to hang the CoPro on the QL with a wrong command string - There's no such thing as error checking in the communications, so be careful!
In BASIC, you would check the joystick with the KEYROW command, joystick 1 is the same as keyrow 1 (cursor keys, ESC and ENTER - in principle, moving the joystick is the same as pressing a key, see QL Manual). Joystick 2 is the same as pressing F1-F5
In order to do the same thing in assembly, you prepare a message to the 8049, send it, receive the answer and evaluate what you got (note evaluation is not complete...).
note it's easy to hang the CoPro on the QL with a wrong command string - There's no such thing as error checking in the communications, so be careful!
Code: Select all
curLeft EQU 1 ; cursor or joystick 1 left
curUp EQU 2 ; cursor or joystick 1 up
escape EQU 3 ; Escape pressed
curRight EQU 4 ; cursor or joystick 1 right
space EQU 6 ; space or joystick 1 fire
curDown EQU 7 ; cursor or joystick 1 down
lea.l IPCCmd,a3
QDOSMT$ MT.IPCOM
btst.b #curLeft,d1
bne moveLeft
btst.b #curRight,d1 ....
rts
IPCCmd dc.l $09010000 ;IPC command
dc.l $00000102 ;9=kbd,1=4bits in,2=8bits out (set to read row 1)
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: Joystick and keyboard input
Hej, thanks for your reply! What does thetofro wrote:The joystick is (like the keyboard) handled by the 8049 - So, you need to talk to the coprocessor in order to get both.
In BASIC, you would check the joystick with the KEYROW command, joystick 1 is the same as keyrow 1 (cursor keys, ESC and ENTER - in principle, moving the joystick is the same as pressing a key, see QL Manual). Joystick 2 is the same as pressing F1-F5
In order to do the same thing in assembly, you prepare a message to the 8049, send it, receive the answer and evaluate what you got (note evaluation is not complete...).
note it's easy to hang the CoPro on the QL with a wrong command string - There's no such thing as error checking in the communications, so be careful!
Code: Select all
curLeft EQU 1 ; cursor or joystick 1 left curUp EQU 2 ; cursor or joystick 1 up escape EQU 3 ; Escape pressed curRight EQU 4 ; cursor or joystick 1 right space EQU 6 ; space or joystick 1 fire curDown EQU 7 ; cursor or joystick 1 down lea.l IPCCmd,a3 QDOSMT$ MT.IPCOM btst.b #curLeft,d1 bne moveLeft btst.b #curRight,d1 .... rts IPCCmd dc.l $09010000 ;IPC command dc.l $00000102 ;9=kbd,1=4bits in,2=8bits out (set to read row 1)
Code: Select all
QDOSMT$ MT.IPCOM
macro expand to, opcode or raw assembly wise?
Re: Joystick and keyboard input
You can replace the macro with
On Sinclair ROMs, you can call this even when interrupts and the OS are disabled. Communication with the IPC is very slow, so use sparingly.
Code: Select all
moveq #$11,d0
trap #1
-
- Font of All Knowledge
- Posts: 3975
- Joined: Mon Dec 20, 2010 11:40 am
- Location: Sunny Runcorn, Cheshire, UK
Re: Joystick and keyboard input
Hi,
Have a look at the QDOS Technical Manual:
http://www.dilwyn.me.uk/docs/manuals/qltm.pdf
or
SMSQ/E Reference Manual:
http://www.dilwyn.me.uk/docs/manuals/QD ... 20v4.5.pdf
give details for QDOS and SMSQ/E operating systems.
Have a look at the QDOS Technical Manual:
http://www.dilwyn.me.uk/docs/manuals/qltm.pdf
or
SMSQ/E Reference Manual:
http://www.dilwyn.me.uk/docs/manuals/QD ... 20v4.5.pdf
give details for QDOS and SMSQ/E operating systems.
Regards,
Derek
Derek
Re: Joystick and keyboard input
Well, I can very well understand that the docs are not really helpful on this specific question. The SMSQ/E manual unfortunately mentions the "joystick" term only exactly once in conjunction with SMS.HDOP, the Technical Manual not at all. What you need to know is really a mix of the SuperBASIC manual (where it is mentioned that joystick input maps to KEYROW and which rows are affected) and how to obtain a raw keyboard scan from assembly via MT.IPCOM (where the command string format is really only scarcely explained) and that MT.IPCOM is at all related to KEYROW.Derek_Stewart wrote:Hi,
Have a look at the QDOS Technical Manual:
http://www.dilwyn.me.uk/docs/manuals/qltm.pdf
or
SMSQ/E Reference Manual:
http://www.dilwyn.me.uk/docs/manuals/QD ... 20v4.5.pdf
give details for QDOS and SMSQ/E operating systems.
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: Joystick and keyboard input
Hi, thanks! Yes this is what I thought would be happening, but in the end, the trap would just execute code from rom again. Perhaps Im stepping on limbs here, but are there disassembled ROM listings floating around somewhere? A quick google brings me down to http://www.dilwyn.me.uk/qlrom/index.html but the first notated ROM dumps I downloaded didnt contain the actual asm listings . Alternatively I could step through the trap execution using the lovely QemuLator debugger; but having the disassembled roms in searchable text format always comes in handy.M68008 wrote:You can replace the macro with
On Sinclair ROMs, you can call this even when interrupts and the OS are disabled. Communication with the IPC is very slow, so use sparingly.Code: Select all
moveq #$11,d0 trap #1
Re: Joystick and keyboard input
Hmmm now I realize. Perhaps the disassembled listings are meant to be loaded in an actual native assembler which in turn shows it as text again, rather than saving it as ascii...spkr wrote:Hi, thanks! Yes this is what I thought would be happening, but in the end, the trap would just execute code from rom again. Perhaps Im stepping on limbs here, but are there disassembled ROM listings floating around somewhere? A quick google brings me down to http://www.dilwyn.me.uk/qlrom/index.html but the first notated ROM dumps I downloaded didnt contain the actual asm listings . Alternatively I could step through the trap execution using the lovely QemuLator debugger; but having the disassembled roms in searchable text format always comes in handy.M68008 wrote:You can replace the macro with
On Sinclair ROMs, you can call this even when interrupts and the OS are disabled. Communication with the IPC is very slow, so use sparingly.Code: Select all
moveq #$11,d0 trap #1