6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 19, 2024 9:30 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Losing keystrokes...
PostPosted: Wed Sep 18, 2013 9:43 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
I ported EhBASIC to a CHOCHI board (http://forum.6502.org/viewtopic.php?f=10&t=2644).

I got it working, but it's eating a lot of keystrokes - I have to type very, very slowly. It is not really usable... Is it normal? My board is running at 45MHz, so I can't imagine what it would be like at 1MHz...

Any thoughts?

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Wed Sep 18, 2013 10:07 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1930
Location: Sacramento, CA, USA
I haven't tried EhBASIC, but that doesn't seem the least bit normal to me, or someone would have brought it up long ago. I don't have the answer, but perhaps you could clarify for someone who might ...
By very slowly, do you mean < 1 cps?
Are output and computation speed affected as well?
How much bus-snooping are you equipped to do?

Mike


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Wed Sep 18, 2013 11:05 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 449
Location: Canada
Quote:
I have to type very, very slowly. It is not really usable


Do you have another app you can test the keyboard with, like a ROM monitor ? Is it just not working in EhBASIC, but works elsewhere ?
I'm running my own system at 20MHz with EhBASIC and it seems to work fine.

Also, the keyboard, if it's a PS2 style keyboard, has specific timing requirements. For my keyboard controller you have to tell it the clock frequency so it can calculate the timing periods.

Is the carry flag being set/cleared properly ? (EhBASIC requires this).

What does your V_INPT routine look like ?

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Thu Sep 19, 2013 12:05 am 
Offline

Joined: Sat Oct 20, 2012 8:41 pm
Posts: 87
Location: San Diego
Quote:
Is it normal? My board is running at 45MHz, so I can't imagine what it would be like at 1MHz...
Any thoughts?


Last year I experimented with EhBasic (with a few mods for 65C816) running at 10mhz and it worked fine. There were no unusual char. I/O delay problems. FYI, there is a subroutine that gets relocated to zero page for speed improvements. Not sure if that could affect your core though.


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Thu Sep 19, 2013 12:21 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
OK, the problem is solved but points to an issue with EhBASIC that is worth knowing about.

EhBASIC requires a non-blocking input check. The routine is required to set carry flag if there is a key. I was assuming that the carry bit is enough and the contents of the accumulator don't matter. That resulted in long (1S) intermittent delays that made typing nearly impossible.

I updated my routine to clear the accumulator and set the carry flag if no character is available. That cleared up the problem.

Upon cursory examination of the code, it looks like there are many places that check for carry and re-enter the loop. I am not sure why the accumulator must be clear...

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Thu Sep 19, 2013 4:43 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1687
Location: Sacramento, CA
Enso,

That is not quite right. It does require a non-blocking (no wait for key press loop) routine. The routine should exit with Carry clear if there was no key pressed. The contents of the Accumulator are not tested and do not need to be cleared. If a key was pressed, then it is loaded into the Accumulator and the routine exits with Carry Set.

If you are setting the carry and clearing the Accumulator, you are essentially telling EhBASIC that you are pressing a lot of "Null" keys. It will do nothing but that is not the desired effect.

Here is my typical input code for a non-blocking routine using a serial interface:

Code:
UARTA_Read
               LDA   UART + SRA         ; read status register
               lsr                      ; move bit 0 to carry (test if data ready)
               bcc   UARTA_rd1          ; nothing to read exit with C=0
               LDA   UART + RXA         ; get character and exit with C=1
UARTA_Rd1
               rts


I was able to shift the data ready bit into the C flag directly, making the code efficient.

Here is an example of a 6551 routine:

Code:
ACIA1_Scan     clc                      ; pre-clear Carry
               lda   ACIA1Sta           ; Serial port status
               and   #$08               ; mask rcvr full bit
               beq   ACIA1_scan2        ; no character ready exit with carry clear
               lda   ACIA1dat           ; get chr
               sec                      ; set carry
ACIA1_scan2    rts


I hope this helps!

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Fri Sep 20, 2013 2:23 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
I made an error in my last message. I clear carry and the accumulator. Just clearing carry didn't seem to be enough - I was getting those delays.

My final code is clearing the accumulator
Code:
cin:            lda   UART_STATUS       ;Serial port status in bit 6
                and     #$40            ;mask status bit and assure 0 accumulator
                clc
                rol     a
                rol     a               ;status now in carry!
                bcc   cinx
                lda   UART_DATA         ;get chr, just in case.  Carry still ok
cinx            rts                     ;

It's possible that your status register is 0 by the time you shift resulting in cleared accumulator as well...
It seems unnecessary, but it made the delay go away. I'll investigate next time I get a chance.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
 Post subject: Re: Losing keystrokes...
PostPosted: Fri Sep 20, 2013 3:20 am 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 449
Location: Canada
I'm not clearing the accumulator and it seems to work with just clearing C. The accumulator is set to -1 by my charget routine if there is no character.

Code:
; ===== Input a character from the console into register R1
; set C if a char is available
; clear C if no char is available
;   
;
V__INPT:
   nat
   cpu      rtf65002
   phx
   ldx      #0
   jsr      (KeybdGetChar>>2,x)
   plx
   cmp      #-1
   beq      V__INPT1
   emm
   cpu      W65C02
   sec
   rts
V__INPT1:
   cpu      rtf65002
   emm
   cpu      W65C02
   clc
   rts

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: