Page 1 of 1

Furby 1998 source code

Posted: Mon Aug 13, 2018 9:06 pm
by nanochess
Hi.

I've read in Twitter the existance of the source code for the Furby toy of 1998.

And guess what? it's written in 6502 ;)

http://www.seanriddle.com/furbysource.pdf

Re: Furby 1998 source code

Posted: Tue Aug 14, 2018 12:27 am
by MichaelM
Cool. Thanks for sharing.

Re: Furby 1998 source code

Posted: Tue Aug 14, 2018 7:47 am
by BigEd
An excellent find!

Re: Furby 1998 source code

Posted: Mon Aug 20, 2018 10:52 am
by BigEd
First thing to note is that it's not quite a 6502 - there's no Y register and some addressing modes and many opcodes are missing. But the source certainly looks like 6502 and would probably run on a 6502.

I noticed a couple of oddities:

- they always CLC before SBC, so maybe SEC is missing? It makes the result out-by-one, unless maybe SBC has the opposite sense of carry on this chip. Or, witness the comment on the front page, the programmers hadn't quite got the idea of borrow and SEC.

- they PHA and PHP in their interrupt routine. Is that PHP a mistake, or does RTI work differently on this chip? If it does, then PLA needs not to affect the flags.

Also available at the Internet Archive in their book viewer.

See also the discussion on Hacker News - with links to more readings.

See also this previous post.

(Text above mostly recycled from the recent gplus post by mos6502.)

Re: Furby 1998 source code

Posted: Mon Aug 20, 2018 12:54 pm
by ttlworks
The Sunplus SPC81A microcontroller was mentioned here in the forum in 2017.
The datasheet doesn't explicitly tell you that there is an Y register, so we could assume that this register is missing.
The data sheet doesn't tell you anything about the instruction set, either.
kakemoms wrote:
Sunplus SPC81A¤¤ (2000) - 4&6MHz - 69 opcodes(?), 80KB ROM + 128Byte RAM, 2 D/A converters (8-bit), 20-IO ports
Sunplus has a full range of controllers that contain 65B02 or 65N02 (Full instruction set), 65R02 (Reduced instruction set) or 65S02 (Reduced instruction set+bit+TAX+TXA).
A manual for 6502 related Sunplus instruction sets seems to be here.
//'Google Analytics' again, you better go with AdBlocker, NoScript etc.
Starting at page 52, there seems to be a list of the instructions for the different instruction sets...
...but I just fail to spot an instruction set where the Y register is missing.

Hmm... that Chinese Sunplus MCU page wants you to log in with a password when klicking "English".

Re: Furby 1998 source code

Posted: Mon Aug 20, 2018 1:11 pm
by BigEd
ttlworks wrote:
kakemoms wrote:
Sunplus has a full range of controllers that contain 65B02 or 65N02 (Full instruction set), 65R02 (Reduced instruction set) or 65S02 (Reduced instruction set+bit+TAX+TXA).
A manual for 6502 related Sunplus instruction sets seems to be here.
Thanks for the link!
Quote:
...
...but I just fail to spot an instruction set where the Y register is missing.
Yes, see for example TAY, the instruction has cycle counts for two flavours of core but an X for the reduced flavours.
65r02-TAY.png

Re: Furby 1998 source code

Posted: Mon Aug 20, 2018 1:32 pm
by ttlworks
BigEd wrote:
Yes, see for example TAY, the instruction has cycle counts for two flavours of core but an X for the reduced flavours.
When taking a closer look at the addressing modes for LDA...
sunplus_opcodes.png
Aha: _all_ variations of LDY are missing for 65r02, 65s02 and CPU12... plus quite a few other instructions.