6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 17, 2024 10:08 pm

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: My 6502 computer
PostPosted: Fri May 03, 2024 5:17 am 
Offline

Joined: Wed Apr 10, 2024 7:24 am
Posts: 15
Proxy wrote:
why not just use one of the VIAs directly?
assuming you don't use the VIA's handshaking feature you can use the CA/CB pins as free I/O.

so a 74HC163 with it's clock and reset inputs hooked up the VIA's CA2 and CB2 pins (with some pull ups or pull downs). the output of the counter goes to a 74HC154 which then goes to the keyboard matrix. the other side of the matrix is then simply hooked into the VIA's regular IO pins (however many are required, though even just 8 inputs give you 128 keys).

so to scan the keyboard (assuming 74HC163 clk = CA2, reset = CB2, matrix input on Port A) once you:
1. reset the counter by pulsing CB2
2. read the value from Port A and store it into memory
3. pulse CA2
4. repeat 2 and 3 a total of 16 times
5. now either leave the raw keyboard data in memory for non-ISR code to handle or directly convert it to a bit/bytemap of which keys are being pressed at the moment.

sure it's a lot more software overhead and based on polling (i recommend some form of timer interrupt anyways), but it keeps the IC count low and makes hardware less complex.
which is good because fixing software mistakes is a lot easier and requires fewer cuts and botch wires than fixing hardware mistakes!

plus you still have one of the ports free which you could use for some software SPI for some cheap expansion (SD Card, RTC, various sensors, tiny displays, etc).


You are right it is more risky than doing it in software. Something similar as what you describe is how it was done in the older computers like the Commodore machines and the BBC Micro I have looked at how they did it. Perhaps I could use some programmable logic that would also reduce the number of chips and that is also reprogrammable in case of mistakes. But I don't have any experience with that except for programming a ROM chip if that counts as programmable logic.


Top
 Profile  
Reply with quote  
 Post subject: Re: My 6502 computer
PostPosted: Fri May 03, 2024 10:47 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 690
Location: Potsdam, DE
It's not just the scan/decode choice.

If you have a completely cpu driven keyboard scan (i.e. the main CPU, not an auxiliary part) then it has to spend a certain amount of it's time just scanning the keyboard, as well as managing the debounce and rollover in software. If you have a completely hardware approach, you need to know when a key is ready, so probably an interrupt, as well as handling (probably) debounce and rollover.

Similarly for something like PS/2, you either need to poll the clock line - rapidly - or have it trigger an interrupt (again, processor time) to decode the data, and you still need to sort out the keydown/keyup messages as well (you might want both edges of a key press, as Windows did (does? I'm out of touch) in an event loop).

My split the difference approach I think will be to use an external processor to mediate a PS/2 keyboard, read the individual packets, and spit them out as serial data - so I'll still need to sort out keydown/up messages at the processor, but the PS/2 sorts everything else out. (Or I can make it just send the keydowns as they happen and sort out control and shift there.) As it happens, I already have an SPI uart, so adding another is no great shakes.

I could do this with an eight-pin part, but I have a box full of STMs with 48 pin, so that's what it'll likely be.

(Or alternatively, use the same STM to handle an external UART channel and talk to it by SPI, let it sort out streams from serial port and keyboard. Time to play.)

Neil


Top
 Profile  
Reply with quote  
 Post subject: Re: My 6502 computer
PostPosted: Fri May 03, 2024 4:35 pm 
Offline
User avatar

Joined: Tue Feb 28, 2023 11:39 pm
Posts: 149
Location: Texas
barnacle wrote:
(you might want both edges of a key press, as Windows did (does? I'm out of touch) in an event loop).


Windows does keep track of the make/break state of each key on the keyboard (somewhat) for video games.

Imagine if you will a typical modern game these days that likes to use WSAD for forward, backward, left, and right movement. Very often players will push Some combination of Forward+Side or Backward+Side.

They may also have something like 'F' to interact, or 'Space' to jump.

If all you want to do is type, then yea, keeping detailed track of the make/break codes doesn't make sense. Last key pressed is good enough, but if the game engine forgot you were pressing "forward" when you hit "jump" and you ended up falling into the bottomless pit because of it, you wouldn't have very happy players. :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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: