109 points · by janvdberg · 8y ago · 49 comments
I work a little bit on it every week on Saturday evening, it's my way of winding down from a busy week. Other people play Sudoku ;)
In case you're wondering why: I'd like to de-solder the CPU from a broken motherboard that I have (besides two working ones) to see how hard it is to take over the hardware by simulating the CPU with a RasPi, but for that I have to know exactly how the bloody thing works in the first place and it is quite a complex beast. The ROM is 16K.
Where do you even start with your project? How to you even get to the disassembled code?
After you know the CPU it is relatively straightforward, you try to figure out the memory map by looking at the address decoding circuitry , and from there you can infer things like where the vectors are pointing (usually they are at the end of the memory map in CPUs from that era, alternatively at '0'). So that will give you a good idea where the ROM should be located, (in this case from $C000 upwards).
Then you spend lots of evenings with cups of tea and some quiet music on trying to figure out what all the instructions are trying to achieve. A good starting point is any ASCII strings, then tables of pointers to code and strings, then trace the boot vector until you come to the inevitable main loop and trace inwards from there. IRQ and NMI vectors are also useful entry points to dig around in (NMI not used here). It's a job that requires quite a bit of patience and a false start somewhere can cost you dearly. I love the little 'aha!' moments whenever I've sussed out what a particular bit of code does. For instance, the DX7 can display the battery voltage and the patch numbers and other information in decimal, like it should. So then you come across this repeated subtraction test with the contents of a table, turns out it is the binary-to-decimal convertor.
It's going to be a while before this is done but it is very interesting.
The result is here: https://github.com/thement/ds10-vst
And the project log here: http://ibawizard.net/~thement/ds10rev.html (sorry for the missing pictures, they got lost when I moved servers)
...aaand now I've run into emulation scene drama again: https://www.reddit.com/r/emulation/comments/3bzy99/mame_devs...
I'm in the midst of a pretty intense commercial job this week (but not intense enough to stop me from commenting on HN ;) ), my email is jacques@mattheij.com (I do not see an email in your profile).
I'd love to verify details like the memory map and anything that you still remember about how the button dispatch worked so I can identify a lot of code or the guts of those two main synth chips would help me tremendously.
http://s3data.computerhistory.org/brochures/apple.applei.197...
If someone’s really keen how about annotating the old GEOS applications from the c64? Someone’s already done the OS.
and #$0f
sed
clc
adc #$90
adc #$40
cldMy post is made for the benefit of current and future 6502 programmers.
I guess you must not be a 6502 programmer, because if you were, your response would be, like, "dude, fuck, that's awesome, holy shit, let me take some notes". Because that was what my response was the first time I saw this code. And that's why I'm passing it on.
From the little I know about him, this seems like exactly the thing he would care about.
Sometimes I’d throw in an extra instruction as alternate entry point into a subroutine. We’d be scrounging for ROM space and would adhoc a subroutine into the end of a different one.
Time delays were another good reason. An extra cycle mattered when you needed to sync with something.
Made for fun times when debugging but you did what you did.
... but no neat hack can justify the existence of BCD. :)
> I guess you must not be a 6502 programmer, because if you were, your response would be, like, "dude, fuck, that's awesome, holy shit, let me take some notes".
Can't we consider Woz as being a 6502 programmer?
I wonder how big implementing the equivalent functionality with an x86 PC would be --- my guess is somewhat shorter, because the x86 ISA is denser than 6502.
the constrained space means woz used a lot of tricks, like having a routine "fall thru" to another instead of calling it explicitly
Basically tail-call optimisation with jump elimination. Nearly all compilers can do it too if you have the optimisation settings right.
(grain of salt alert: I don't know a ton about modern PCs at this low a level)
Eh, maybe if a modern PC were just an Apple I with an x86 chip dropped into it - although even then, don't underestimate the 6502 for code density (or overestimate x86) when it comes to simple bit-banging and byte-bashing. And remember, your x86-64 CPU when it starts up isn't much more than a hot-rodded 8086, so we're comparing the 6502 to that - real mode x86 with 16-bit registers and all - rather than something more modern.
But my guess is that the complexity of modern IO would absolutely crush you in terms of complexity. For keyboard and video alone, the absolute bare minimum, you need to speak to the USB controller and across the PCI-E bus to the graphics card, and my intuition tells me this hardware wasn't designed to be easily programmable in a microscopic number of bytes.
(I also don't know how much stuff you strictly need to do to get a stable system, but looking through the pages of Advanced Options in my BIOS concerning things like memory timing and who knows what else makes me think the motherboard itself needs a fair amount of configuration on start up...)
If you want to start from the very beginning of bootup, you do indeed have to start by turning the RAM on. See http://www.drdobbs.com/parallel/booting-an-intel-architectur... which I found for answering https://electronics.stackexchange.com/questions/311832/can-a...
Random aside.
One thing I miss is that I never had an assembler for my Apple //e. The small assembly programs I wrote, I had to write using the bare bones mini-assembler that you got by doing
call -151
and then
!
Just did some idle digging out of curiosity, and stumbled on something that may be of interest: http://iancoog.altervista.org/HF/develop64_hf.rar
It was hiding in here: http://comp.sys.cbm.narkive.com/YJAWnSun/develop-64
There are references to a "develop64_cracked" on a retro FTP server that's 404ing for that file; this RAR seems to contain the file was was on the FTP server.
Also, backspacing the file off the path in the first URL gives a listing of some other releases, but this file isn't listed. Woot.
Here are the other tabs that ended up open:
- https://www.google.com/search?q=%22develop-64%22
- [interesting] https://www.lemon64.com/forum/viewtopic.php?t=24254 (unfortunately the embedded photos seem definitively dead; I checked IA.)
Interstitial: the forum post above mentions has a link to http://www.radiks.net/~jimbo/art/int7.htm. IA had captures of this just fine, but fiddling around with the dates caused me to stumble on the specific capture http://web.archive.org/web/20110724025913/http://www.radiks...., which contains a "page moved" update pointing to http://web.archive.org/web/20110813050154/http://www.mailsen...; after stripping the IA prefix off that to see if it was still live, it transparently redirected me to...
- [interesting] https://lawlessguy.wordpress.com/2016/12/04/an-interview-wit...
I wish I could use bold for this line - THIS is how you keep data alive, people!! :D
Also for reference, the reocities link in the above URL is dead, but oocities.com works. Unfortunately the geocities paths are not in oocities' archive.
And these links were near the top of Google's results.
- [uninteresting] https://www.lemon64.com/forum/viewtopic.php?t=40768
- [uninteresting] http://sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.ph...
There is a lot of NES programming info out there these days and if you haven't had a chance to, it's entertaining to take a look at it - it's a machine with the same CPU but real graphics hardware (for the time). Bitblitting into the mildly non-linear Apple ][ frame buffer will look pleasantly simple. The NES can do an awful lot more, of course.