6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Apr 25, 2024 1:40 am

All times are UTC




Post new topic Reply to topic  [ 60 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Mon Nov 26, 2012 4:39 am 
Offline

Joined: Mon Nov 26, 2012 3:40 am
Posts: 42
Hey there...
I know it's a bit of an internet no-no to make huge posts without lurking a bit on a forum. I just thought I would show off a project of mine and see if anyone out there can give me ideas on what to do.

It started with me wanting to make a 6502 computer for a friend of mine for his birthday. I started with a Kim-1 kit which, sadly failed. After putting the whole thing together, all it did was light it's power light and nothing happened. I tried to troubleshoot it the best I could, only to find that I soldered two caps in the wrong place and bent a few IC pins. Well, that was a lesson learned.

Discouraged, I put the project away.

About a week ago I was cleaning my apartment and found my Arduino 2560 Mega. I decided as opposed to making a 6502 computer from ICs, I would make a software version of the same thing using my Arduino. It came out awesome!

Image

I designed it to be a kind of "Super Kim". The code it's running in the picture is the following program.

Code:
.org $200
LDA $FD     ;$FD is the read-only keypad register.
CMP #$00
BEQ ($0200)
STA  $FC    ;$FC is the write-only display register.
JMP $0200


Basically it takes whatever is input on the keypad and prints in on the display.
there are 5 "hardware" registers that hang out on the zero page.
Code:
$FB Bank_Switch   (w)
$FC Display_out   (w)
$FD Keypad_in    (r)
$FE Serial_Write (w)
$FF Serial_Read  (r)

The system emulates a 6502 with 512k of ram. the bottom 32k ($8000-$FFFF) is banked in depending on what is written to $FB ($00 to $0F) if you write a zero in $FB it will mirror the top half of memory ($0000-$7FFF) and I call this "32k mode".

When you plug in a USB, it becomes a com port on a computer and you can use this as a terminal running @ 9600-8-N-1.

The emulation code I used was found here however, I did a rewrite the memory portion (The original only could use 1024 bytes of memory), added registers for my LCD display and keypad, and implemented the RESET interrupt. (The original code does not have interrupts implemented)

With everything now implemented how I want, I'm looking for a cute mini-assembler, something like the system monitor from the Apple II. This is so you can write short little programs using the keypad. The keypad matrix looks like this.

Code:
{'1','2','3','U'},
{'4','5','6','V'},
{'7','8','9','W'},
{'+','0','-','X'},
{'A','B','C','Y'},
{'D','E','F','Z'}


The letters down the right-hand side (U-Z) are just placeholders. You can make them whatever you want. I'll probably borrow from the Kim-1 keypad (GO, ST, RS, AD, DA, PC, and an extra one left over).

Programs are loaded via the USB Serial port. You load programs by transmitting a virtual punch-tape over the com port. You save you programs by doing the reverse. (I originally planned to have it load actual punch cards, but couldn't find/make a cheap punch card peripheral)

I'm going be mounting this into a black plastic case with fake wood grain detail to complete the 1977 look of it.

I'm intentionally not going to be using BASIC as my default program in the system. I'm keen on keeping it very close to the metal and then load applications the very old-fashioned way. I also have a few data pins left over so I can still interface something else.

Anyone have any ideas on what else I can come up with?


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 5:10 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Welcome to the forum!

Have you seen 8BIT-s avr 6502 emulator?
http://sbc.rictor.org/avr65c02.html

What about emulating a sid chip, so you can play all those mythical tunes.
You could also install forth.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 8:20 am 
Offline

Joined: Mon Nov 26, 2012 8:14 am
Posts: 1
Hi Halkun,

fun to see that someone is using the code I posted a while back.
You might like to know that there is a small bug in that emulator, regarding the handling of the RTS instruction.
I've fixed the bug and posted the revised version at the same link.
If possible, I'd be happy to take a look at your modified version, from the picture it looks like you're running the
emulator off an Arduino Mega?
*edit-misspelled*


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 9:03 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8427
Location: Southern California
Welcome, to both new members!
Quote:
which, sadly failed. [...] I tried to troubleshoot it the best I could, only to find that I soldered two caps in the wrong place and bent a few IC pins. Well, that was a lesson learned.

Discouraged, I put the project away.
See section 19, called "Debugging," of my 6502 primer. (Several other sections also relate directly to your post.)

Quote:
Code:
.org $200
LDA $FD     ;$FD is the read-only keypad register.
CMP #$00
BEQ ($0200)
STA  $FC    ;$FC is the write-only display register.
JMP $0200

Note that the CMP #$00 is already automatically implied as part of the LDA right before it, so it's redundant.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 1:08 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8142
Location: Midwestern USA
GARTHWILSON wrote:
Quote:
Code:
.org $200
LDA $FD     ;$FD is the read-only keypad register.
CMP #$00
BEQ ($0200)
STA  $FC    ;$FC is the write-only display register.
JMP $0200

Note that the CMP #$00 is already automatically implied as part of the LDA right before it, so it's redundant.

Welcome to our new members.

I'm puzzled a bit by the BEQ ($0200) instruction in the above code. No 6502 assembler of which I'm aware would recognize indirect addressing as valid for a branch instruction.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 1:43 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1680
Location: Sacramento, CA
halkun wrote:
...With everything now implemented how I want, I'm looking for a cute mini-assembler, something like the system monitor from the Apple II. This is so you can write short little programs using the keypad.


Take a look at my SBC-2 OS. It was based primarily on the old Apple 2 monitor. It also includes a mini assembler and has xmodem/crc file transfer support.

http://sbc.rictor.org/sbcos.html

Feel free to contact me with questions.

Daryl

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 1:44 pm 
Offline

Joined: Mon Nov 26, 2012 3:40 am
Posts: 42
I have to run along to work. I patched the RTS function. I also have my updated code attached. You can point and laugh. I'm not a very good programmer and I'm sure there are errors in the modded code and some really nasty type conversions. If you see anything jumping out at you or ways I can clean up the code... Let me know.


You can see it but my Mega has a 512K upgrade shield. It's cut off at the bottom.


Attachments:
6502.cpp [35.59 KiB]
Downloaded 199 times
Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 26, 2012 3:06 pm 
Offline
User avatar

Joined: Fri Jun 22, 2012 7:39 am
Posts: 201
SP is $1FF after reset.

_________________
6502 addict


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2012 1:52 am 
Offline

Joined: Mon Nov 26, 2012 3:40 am
Posts: 42
It's nice to see the project so well received.

I made the change to code so that SP is correct on reset. I'm now picking apart SBC-2 OS. The way the assembler works is going to dictate my keypad layout. (I want to be able to code directly from the keypad). I use ca65 as my assembler of choice, but I'll see how TASS feels.

Another picture where you can see the 512k add-on
Image

The wiring is so long because I don't quite know the size of the box it's going to be in. Better to tie it all up than to find out you soldered your leads too short. I also didn't have any ribbon cable around to cannibalize. So, it's messy, but as a newbie to this. I think I did OK.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2012 5:24 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1680
Location: Sacramento, CA
halkun wrote:
I'm now picking apart SBC-2 OS. The way the assembler works is going to dictate my keypad layout. (I want to be able to code directly from the keypad).

If you make the U-Z keys software (content) selective, you could easily substitute the Monitor command characters. These are the ones I use the most: G (go or execute), L (disassemble), U (upload to sbc via xmodem), . (period = set a range, i.e., 1000.2000), : (colon to change memory i.e., 1000:60), [ ] (space), and finally [Enter]. Then, those same keys could have other meaning for other functions.

The miniassembler will be harder as it takes letters for the assembler opcodes, along with (),# symbols. I'm not sure how to implement that, unless you have one key to bring up the opcodes and then use two others to scroll up or down. The same could be done for the operand symbols but the whole process would be tedious. FYI, the miniassembler's operands are assumed to be Hexidecimal, not decimal. The $ can be entered but it is not required.

As an example on how the miniassembler would work, here is the keystrokes for entering in the code sample you provided in your first post:

Code:
200[space]LDA[space]FD[enter]
[space]CMP[space]#00[enter]
[space]BEQ[space]200[enter]
[space]STA[space]FC[enter]
[space]JMP[space]200[enter]


The resulting disassembly would look like this:
Code:
200L
0200-  %}   A5 FD      LDA  $FD
0202-  I.   C9 00      CMP  #$00
0204-  pz   F0 FA      BEQ  $0200
0206-  .|   85 FC      STA  $FC
0208-  L..  4C 00 02   JMP  $0200


Doing that with just 24 keys could be a challenge but is not impossible.

Daryl

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2012 5:31 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Quote:
I want to be able to code directly from the keypad


Why don't you cheat a bit and add a ps/2 keyboard?
Ps/2 is really easy to handle, it only needs two wires, data and clock(and pull up resistors).


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2012 5:50 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8427
Location: Southern California
Quote:
The miniassembler will be harder as it takes letters for the assembler opcodes, along with (),# symbols. I'm not sure how to implement that, unless you have one key to bring up the opcodes and then use two others to scroll up or down. The same could be done for the operand symbols but the whole process would be tedious.

Doing that with just 24 keys could be a challenge but is not impossible.

Why not a shift key. A single shift key effectively gives you 46 keys. Two shift keys, f & g shift (or gold & blue, or however you want to make it), would be like having 66 keys. The frogpad is a single-handed keyboard of about 20 keys that can be typed on very fast. See a demo at http://www.youtube.com/watch?v=RNsrfaHl ... re=related where the person did 87wpm on one.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2012 5:55 am 
Offline

Joined: Mon Nov 26, 2012 3:40 am
Posts: 42
Dajgoro wrote:
Quote:
I want to be able to code directly from the keypad


Why don't you cheat a bit and add a ps/2 keyboard?
Ps/2 is really easy to handle, it only needs two wires, data and clock(and pull up resistors).


Nostalgia. Actually. I decided to do a straight port of SBC-2 OS and use the serial interface. My LCD display is only 16x2, and not wide enough to display the output. However, as I'm using the Kim-1 as my template, 16x2 is a huge upgrade from 6 led displays. I'll probably hack some special condensed mode to make it show up on the little screen later.

The goal is to have it as a cute little stand-alone computer.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2012 6:08 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8427
Location: Southern California
Quote:
My LCD [...] is only 16x2, and not wide enough to display the output. [...] I'll probably hack some special condensed mode to make it show up on the little screen later.

The intelligent character LCDs don't have a continuous matrix of dots, but they do let you do custom characters. I used that capability for a couple of products, making a lot of combinations of two to three characters in a single character space. You can have as many specials as you want, but only eight different ones showing at a time (in addition to all the standard ones).

Quote:
The goal is to have it as a cute little stand-alone computer.

That's a noble goal.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2012 2:23 am 
Offline

Joined: Mon Nov 26, 2012 3:40 am
Posts: 42
BAH~!

SBC-2 OS uses 65C02 opcodes, and the core I'm using in my Arduino is straight-up 6502. I have to implement about 27 more opcodes :P
Oh well, I'll post my ProDOS project in another thread to keep it interesting while I go dig back in the emulator again :(


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 60 posts ]  Go to page 1, 2, 3, 4  Next

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: