ParanoidLittleMan Posted June 20, 2019 Share Posted June 20, 2019 Reading joystick, keyboard via TOS in simple way This is certainly part for which TOS documentation is not well done, some necessary details just missing from avalable Atari DOCs. So, there is XBIOS 34 function Kbdvbase, which will return in d0 address of structure: long midivec long vkbderr long wmiderr long statvec long mousevec long clockvec long joyvec * pos 24 long midisys long ikbdsys Those ending with 'vec' are vector addresses, and SW can put there own rutine to transfer current status of those input devices. Atari DOC s(and Atari ProfiBuch auch, pardon too) says only this: "Address of packets will be in a0 and on stack too. Rutine must end with rts, and last not longer than 1 mS." And that's just not enough to use it. Despite that it is really simple. So, here is working example: * Setting joystick monitoring rutine : move.w #34,-(sp) *Kbdvbase trap #14 addq.l #2,sp move.l d0,a1 lea 24(a1),a1 * Joystick vector move.l (a1),joymorg *Save original one (which is just an rts) - for restoring at PRG end move.l #moni,(a1) * put there address of own code to pick joystick state ******* moni * Joystick monitoring, very simple: * it is at joyvec address set with XBIOS 34 addq.l #1,a0 *a0 is odd move.w (a0),joyc * first byte is for joy 0, second for joy 1 rts It activates every time when some joystick action is performed. And during ACIA interrupt - that's why must be fast. SW can now simply read when want values at variable joyc . Of course, it can be done different - so, for instance that joystick interrupt initiates something immediately. But normal usage is just reading joyc periodically. Bits for joystick status: 7 - fire, 0 - down, 1 - up, 2 - left , 3 - right Active when bit is set. 1 Quote Link to comment Share on other sites More sharing options...
madaxe Posted June 22, 2019 Share Posted June 22, 2019 Nice stuff, thanks for sharing And about some code to read a .PI1 file and display it on the screen? Thanks in advance, José Mário aka MadAxe Quote Link to comment Share on other sites More sharing options...
ParanoidLittleMan Posted June 23, 2019 Author Share Posted June 23, 2019 OK, here is it is ASM, Devpac compatible: move.w #2,-(sp) * Get screen address trap #14 addq.l #2,sp move.l d0,a6 lea -100(a6),sp clr.w -(a7) pea picn(pc) move.w #$3D,-(a7) trap #1 addq.l #8,a7 move.w d0,d7 bmi exitu lea -34(a6),a6 pea (a6) pea 32034 move.w d7,-(a7) move.w #$3F,-(a7) trap #1 lea 12(sp),sp move.w d7,-(a7) move.w #$3E,-(a7) trap #1 addq.l #4,a7 lea 2(a6),a6 pea (a6) move.w #6,-(sp) trap #14 addq.l #6,sp move.w #7,-(sp) trap #1 addq.l #2,sp exitu clr.w -(sp) trap #1 picn dc.b "GITP.PI1",0 even 1 Quote Link to comment Share on other sites More sharing options...
madaxe Posted June 23, 2019 Share Posted June 23, 2019 Great stuff @ParanoidLittleMan, it works perfectly Thank you! Have a nice day, José Mário a.k.a. MadAxe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.