Gemdos $b (CCONIS)

All 680x0 related coding posts in this section please.

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

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Gemdos $b (CCONIS)

Postby rockyone » Sat Apr 15, 2017 12:07 pm

How to clear the keyboard buffer before using the Gemdos function $b "Cconis"

mikro
Atari God
Atari God
Posts: 1263
Joined: Sat Sep 10, 2005 11:11 am
Location: Brisbane, Queensland, Australia
Contact:

Re: Gemdos $b (CCONIS)

Postby mikro » Sat Apr 15, 2017 12:20 pm

My old archive says:

Code: Select all

flush_keyboard:

.read_key:      move.w  #11,-(sp)                       ; Cconis()
                trap    #1
                addq.l  #2,sp

                tst.w   d0
                beq.b   .empty

                move.w  #8,-(sp)                        ; Cnecin()
                trap    #1
                addq.l  #2,sp
                bra.b   .read_key

.empty:         rts

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Sat Apr 15, 2017 12:56 pm

Unlike gemdos 11, gemdos 7 and 8 expect a key before returning the hand.
But bug also if a character is waiting in the keyboard buffer

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Sat Apr 15, 2017 1:44 pm

Since I had the keyboard buffer not empty, gemdos 11 did not return a valid value.
I tested with gemdos 6 and I did not get any wrong return.
Then, another function using gemdos 11 worked correctly.
But I only made a test!

Code: Select all

   move.w   #$ff,-(sp)
   move.w   #$6,-(sp)
   trap   #1
   addq.l   #4,sp
   tst.w   d0
   beq.s   no_key


User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2000
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Gemdos $b (CCONIS)

Postby charles » Sun Apr 16, 2017 2:59 am

is the keyboard buffer a circular buffer like midi?
just reset the head /tail pointer ?
using the keybdvec pointer
too abstract I know ..
but possible ???
from what I roughily remember if the head tail are different it sends interrupt hence the code command
conis


im always wrong

tell me im wrong please
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

ThorstenOtto
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 129
Joined: Sun Aug 03, 2014 5:54 pm

Re: Gemdos $b (CCONIS)

Postby ThorstenOtto » Sun Apr 16, 2017 9:23 am

rockyone wrote:How to clear the keyboard buffer before using the Gemdos function $b "Cconis"


Erm... i don't understand that question, *first* clear the keyboard buffer, *then* test wether a key has been pressed? What sense does that make?

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Sun Apr 16, 2017 1:10 pm

Gemdoss 7 and 8, are more a logical expectation than physics.
That is, if a character waits in the keyboard buffer, this function returns a value even if no key has been pressed.

On the other hand, gemdos, 6 is a physical wait and correctly resets the keyboard buffer.

mikro
Atari God
Atari God
Posts: 1263
Joined: Sat Sep 10, 2005 11:11 am
Location: Brisbane, Queensland, Australia
Contact:

Re: Gemdos $b (CCONIS)

Postby mikro » Sun Apr 16, 2017 1:30 pm

I'm sorry but I'm lost here as well. So you don't want a function to flush keyboard? I've used the posted code snippet pretty reliably for years.

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Sun Apr 16, 2017 2:08 pm

I'm just trying to test the keyboard to get out of a loop

mikro
Atari God
Atari God
Posts: 1263
Joined: Sat Sep 10, 2005 11:11 am
Location: Brisbane, Queensland, Australia
Contact:

Re: Gemdos $b (CCONIS)

Postby mikro » Sun Apr 16, 2017 2:15 pm

And doing something like:

flush_keyboard();
loop: read_key();
do_stuff();
goto loop;

is a problem because... ?

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2000
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Gemdos $b (CCONIS)

Postby charles » Sun Apr 16, 2017 3:23 pm

so I see , your program hangs or it returns the wrong value
is this why u want to clear keyboard buffer?
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Sun Apr 16, 2017 3:47 pm

Yes, if the buffer is not empty, the loop ends without pressing a key. With gemdos 6, it should go

Code: Select all

loop:
   ....
   move.w   #$ff,-(sp)
   move.w   #$6,-(sp)
   trap   #1
   addq.l   #4,sp
   tst.w   d0
   beq.s   loop
   ....

ThorstenOtto
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 129
Joined: Sun Aug 03, 2014 5:54 pm

Re: Gemdos $b (CCONIS)

Postby ThorstenOtto » Sun Apr 16, 2017 4:24 pm

And what is Cconis() is supposed to return when you empty the keyboard buffer first? If your loop ends without pressing a key, and you don't want that. why not just simply wait for a keypress then?

User avatar
shoggoth
Nature
Nature
Posts: 848
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Gemdos $b (CCONIS)

Postby shoggoth » Sun Apr 16, 2017 4:27 pm

The OS features properly buffered keyboard input. If you don't want that, you'll have to implement you own keyboard handler, either through the OS keyboardvectors, or by bypassing the whole shebang and implement your own IKBD handler.

Cconis() does what it's supposed to do.
Ain't no space like PeP-space.

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Sun Apr 16, 2017 4:41 pm

With the $ff parameter, Crawio tests the keyboard.
Is apparently does not return an erroneous value if the keyboard buffer is not empty

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

Re: Gemdos $b (CCONIS)

Postby simonsunnyboy » Mon Apr 17, 2017 7:16 am

I personally have much better experience reading keys with the BIOS. Bconstat() to check if there is any and Bconin() to read the value. It also gives scancodes if decoded properly.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Mon Apr 17, 2017 9:31 am

I was able to do a second test this morning, Crawio, returned a value without pressing the keyboard.
By cons, basic Inkey $ works correctly?
I will test the bios functions in 68k hoping not to have this problem.

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Mon Apr 17, 2017 7:00 pm

Testing bios functions
The current state of the keyboard buffer, still disrupts gemdos functions,
But the bios functions function correctly in basic is in routines in 68k :D

charles wrote:is the keyboard buffer a circular buffer like midi?
just reset the head /tail pointer ?
using the keybdvec pointer
too abstract I know ..
but possible ???
from what I roughily remember if the head tail are different it sends interrupt hence the code command
conis


im always wrong

tell me im wrong please

  I have no knowledge about it, but certainly something like that.
Apart from the Reset, I would like to know how to remedy this problem (if possible?)

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2000
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Gemdos $b (CCONIS)

Postby charles » Mon Apr 17, 2017 10:00 pm

my best guess would be to initialize the keyboard vector
see pages 341 in st internals as how it handles inout input
then u could prob set head/tail to correspond

but im still completeily lost without a flow chart of what your program does
clearing the keyboard buffer is easy , just move 128 zeros to the keyboard buffer area ?????
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

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

Re: Gemdos $b (CCONIS)

Postby simonsunnyboy » Tue Apr 18, 2017 5:44 pm

No need to be so complicated. There is no need to mess with TOS own buffers. Just use the system calls as they were meant to, here in C but this is easily translated to bare m68k:

Code: Select all

void flush_kbd(void)
{
    while(Bconstat(2) != 0)
    {
        (void)Bconin(2);
    }
}


reading is simple as uint32_t key = Bconin(2);
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2000
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Gemdos $b (CCONIS)

Postby charles » Wed Apr 19, 2017 12:49 am

id like to know why he doesn't do that with cconis() crawcin()
then proceed with his cconis()?
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2000
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Gemdos $b (CCONIS)

Postby charles » Wed Apr 19, 2017 3:29 am

2 variations

simons clears the buffer by reading it

mine tells the next operations functionality not to read anything

benchmark ,I don't have time


is this what you had in mind?



this is what I made to demonstrate in gfa

Code: Select all

' sof
'
' PRINT XBIOS(34)
ptr%=XBIOS(14,1)
PRINT "keyboard  input adrress";ptr%
PRINT "keyboard buf size";DPEEK(ptr%+4)                 ! size
PRINT "keyboard buf head-pos";DPEEK(ptr%+6)             ! buffer-head
PRINT "keyboard buf tail-pos";DPEEK(ptr%+8)             ! buffer-tail
PRINT "keyboard buf low mark=1/4size";DPEEK(ptr%+10)    ! low mark (not used)1/4
PRINT "keyboard buf hi mark 3/4size";DPEEK(ptr%+12)     ! high mark (not used)3/4
PRINT
'
SLPOKE &H4BA,0
PRINT "timer @ 0ms";TIMER
PRINT
PRINT "type some keystokes for the buffer"
PRINT
WHILE TIMER<600
WEND
PRINT "timer @ 600ms";TIMER
PRINT
'
' *************************************************************************
' *************************************************************************
' **** set the keyboard tail                                       ********
' **** (which would be longer cause it indexes keystrokes)         ********
' **** to the head-pos                                             ********
' **** !!!! now the operating system cant detect any keystrokes!!! ********
' *************************************************************************
' *************************************************************************
' 
' *************************************************************************
' **** try this next line of code active ,and altenatily deactive *********
' *************************************************************************
' DPOKE ptr%+8,DPEEK(ptr%+6)  !poke tail-pos the head-pos... see what haps !!
' *************************************************************************
' *************************************************************************
' *************************************************************************
'
WHILE BIOS(1,2)
  PRINT "your keystroke is:"+CHR$(BIOS(2,2) AND &X1111111)
WEND
'
PRINT "keyboard buf size";DPEEK(ptr%+4)                 ! size
PRINT "keyboard buf head-pos";DPEEK(ptr%+6)             ! buffer-head
PRINT "keyboard buf tail-pos";DPEEK(ptr%+8)             ! buffer-tail
PRINT "keyboard buf low mark=1/4size";DPEEK(ptr%+10)    ! low mark (not used)1/4
PRINT "keyboard buf hi mark 3/4size";DPEEK(ptr%+12)     ! high mark (not used)3/4
PRINT
'
END
'
eof


is this called an op-hook or a system hook?
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Wed Apr 19, 2017 1:49 pm

In basic omicron
,...................................................................
'... If Gemdos, 7 works or does not work:
Xbios (Address, 14,1)
Wpoke Address + 4, $b ' ( A lower value requires a restart) test with value $b, $c, $d, $e, $f, $8c
Wpoke Address + 6, $b ' tested each time with the same value as the above command
Wpoke Address + 8,64 ' not tested without this command (64 = value always returned by Xbios )
'Simulates waiting for a key
'..................................................................
"Then Gemdos, 7 normally works

I wait for the next block of Gemdos to continue the tests

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

Re: Gemdos $b (CCONIS)

Postby simonsunnyboy » Wed Apr 19, 2017 3:16 pm

It is completely unnecessary to dig into the buffers themselves. Polling the contents out of unwanted contents is the clearest, safest and most portable way when a direct "clear buffer" call is not available.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: Gemdos $b (CCONIS)

Postby rockyone » Thu Apr 20, 2017 1:01 am

I have seen several ways to clean the keyboard buffer, but none solves this problem.
The BIOS works fine, it suits me.
If anyone has a solution ...


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 3 guests