Mega IIe: First Fully Functional Computer Built Around the Apple Mega-II Chip

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] hey I'm James and I have so much to tell you this video summarizes over two years of nearly daily effort to create a computer that never existed if you missed or forgot about my first video on the project here is a quick review I took the Mega 2 chip out of a 1991 era Apple 2gs it contains all of the logic plus 80 column card and a few other things of the 2E which has custom chips based on the 7400 series logic used for the original Apple 2 from 1977 some people have said including Apple the Mega 2 is responsible for the 16bit Apple 2gs being Backward Compatible with the 8bit 2E software but that isn't quite true in the 2gs it handles Apple 2 video and IO devices most of the 2E logic is completely unused related but different there is a chip called Gemini which was used on the Apple 2E expansion card for the Macintosh LC while clearly a follow on to the Mega 2 it has some functional and package differences and we already know that that works as an Apple 2 the Mega 2 however has never been in a standalone computer that's sold commercially after the last video I learned about the tiger learning computer which used the Mega 2 licensed from Apple however it never made it out of test marketing even after learning about that my goals stayed the same I wanted to prove if the Mega 2 from the 2gs was a complete Apple 2E when we left last video the Mega 2 was connected to Ram the Apple 2E ROM and a modern 6502 with the help of a p Pico it booted to The applesoft Prompt but that was it the main problem was this huge mess of wires it made debugging a nightmare so I came up with a modular Apple 2 Hardware development [Music] platform I designed multiple cards so I could test blocks of the Apple 2 circuit separately these connected into a back plane the CPU card has the mega 6502 RAM and ROM in a zip socket this time with one side connected to the analog video board from rev 1 the other side grouped together the address and Main data bus along with clocks and control signals into a couple of connectors that attached to a back plane that way I could easily distribute the common signals and if there was problem with say the keyboard controller I could respin just that board foreshadowing is a powerful storytelling technique back on rev 1 the logic analyzer was invaluable but its connections made a mess of the wiring up to 40 signals could be useful but at a minimum I always needed at least 24 to cover address and data so when I laid out these signals for the back plane I made it compatible with the digital discovery of all of the clever tricks I did in this project that was my favorite I just left the logic analyzer hanging off of the board most of the time I probably should have done Edge connectors instead of pin headers but I did not expect to change the boards often and I wanted more places to clip probes rev 2 always was and continues to be a hardware development tool the back plane concept is great for working on one block at a time especially as I worked towards the final design now before we get to that let's talk about a few things starting with something called Soft switches the Apple 2 Hardware has many features that are enabled or queried through something called Soft switches for example in basic if I Peak 49232 the computer switches to Graphics mode and Peak 49233 brings it back to text another example is this basic program it reads two switches to get the state of the open and closed Apple keys by the way these are not on the keyboard Matrix with the other keys in basic you enter the peaks with decimal numbers and in the machine language monitor typing the hex address c61 causes the same read to occur the most significant bit of hex 20 is the state of the open Apple key zero means not pressed so pressing the key causes the value to change to hex a z or one for pressed now there are two switches I became very familiar with while working on the keyboard interace the C switch c0000 Returns the last key pressed so if I press a we get 193 in decimal and if you subtract 128 from that you get 65 which is the asky value for Capital a the reason for that subtraction is in the Apple 2E it has a ROM that is addressed by a keyboard controller when c0000 is hit the ROM is enabled and it outputs the 7 bit asky value the IOU chip sets the eighth bit when a new key is pressed to clear that bit you hit c010 which enables the strobe and Returns the last key pressed all of that logic is contained in the mmu and IOU of the Apple 2E which made me think that was also in the Mega 2 spoiler it is not the Apple 2gs has three signals called Kell or k select one and two come from the Mega 2 but K select zero comes from a chip called slot maker of course a does so this single chip Apple 2E now needs Ram ROM a CPU and another aset called slot maker even though the keyboard has nothing to do with the slots also it needs a keyboard controller anyway with the 3K select signals I could see the difference between a c0000 and a c010 on a logic analyzer and how the windowed respond is less than 1 microsecond but in the 2gs the strobe bit comes from the keyboard controller not the mega so to to drive the data bus correctly I need a microcontroller that outputs the correct asky value but only during the data phase and manages the magic strob bit hm what could we use the rp240 from the Pico has programmable ioin that can respond faster than a traditional interrupt I did a whole video on that basically this Pio program watches the K cell signals plus a couple of others to determine when to drive the data bus and when to provide that new key strobe in Hardware I use a 74hc 245 buffer to trate when not active and to provide the translation between 3.3 and 5V Logic on the PC the black window is the composite video capture and the green window is a Serial terminal initially I programmed the rp240 to accept serial characters from the PC and type those I could even do control characters because it is all asky and this method works shockingly well for a long time then with the tiny USB Library I I got a USB keyboard to work eventually I even got the in key rollover behavior of the Apple 2 to work as well now to get the keyboard access working I said I needed a chip called slot maker it had the case select signal and it was also the key to making dis drives work slot Maker's primary purpose is to buffer the clocks for the slots in the 2gs and it selects between the slots or internal peripherals for example in the 2gs there is a chip called the iwm that was a single chip version of the disc two card since I was at the point where I needed to load and save data anyway I turned my attention to dis access this card is an Infamous Steve wnc design it has a few logic chips and a ROM that implements a state machine to control the steppers of the disc drive the code in its program ROM is only 256 bytes and is just enough code to load the first sector off the floppy disc which loaded the rest of the dis operating system at the start of the disc 2 controller's code is a three byte sequence that the Apple 2 ROM looks for at boot that's how it knows which slot has the discard the iwm chip in the 2gs incorporates the logic of the disc 2 card and only needs a few signals to operate my card Incorporated the iwm with 20 pin header and 19 pin duub for connecting to drives the iwm's enable signal connects to the slot maker card with a signal called internal device 6 that Mega two uses to talk to Virtual slot 6 however when powered on the ROM goes straight to the applesoft prompt and never even tries to read from dis thanks to the new keyboard stuff I drop into the monitor so I could list the code at slot 6 which should start with the magic 3 bytes of the dis 2 ROM but they weren't there eventually it hit me the iwm incorporates the logic of the disc 2 controller but not the ROM so when we read from c600 that's the ROM in the computer which is my version of the Apple 2 eom ROM the Apple 2E didn't have that code in its ROM since it relied on the disk support from the card plugged into the slot so using a hex editor I copied the 256 bytes of code from the disc 2 card into address c600 of myrom I used an eon programmer to erase and write this update up binary file which I could now easily reinstall into the Rev 2 socket let's see what happens this time it boots from disk and now that I could start to save and load programs things were really starting to speed up except then they weren't not everything would load correctly for example This Modern program loader would sometimes crash during boot the game Frogger is another example here's a clip I captured during a live stream see it's actually crashed into the monitor can I go I'm laughing because in that moment I'm starting to realize how much I understand about how the Apple 2 is operating it turns out I found what I am calling a bug in the Mega 2 finding the sequence that led to the crash meant a lot of time with the logic analyzer the key signals I looked at were the address bus between the 6502 and mega enable 245 which is the enable signal for the buffer on the rp240 board and of course the three bits of case select notice that when address sees 002 gets hit the case select signals activate and then enable 245 asserts meaning I am driving the data bus when I should not as the address lines change States the Mega 2 asserts the case select lines when the logic matches the keyboard soft switches let's use a chart in this book to show the problem in the Apple 2 the 6502 is clocked at about 1 MHz but the RAM is clocked at two because it is shared between the CPU and video circuit so half of the phase zero cycle is for video and the second half is for the 6 6502 my Pio code however does not reset after seeing a rising edge of phase zero so anytime K select changes state the Pio arms itself to drive the data bus which is why the enable 245 signal asserts after c002 so I needed a way to qualify the signals but the Pio can only have 32 instructions and I was already using all of them so I channeled my inner wasse and looked for a hardware optimization it was simple instead of the 245 buffer doing the voltage translation I replaced it with a 573 transparent latch and drove that with the phas Z clock now the Pio only sees K selects during a 6502 phase it goes without saying even though I'm about to say it I was very happy about the decision to make a modular development platform since I was now on my third revision of the keyboard PCB who could have foreshadowed that anyway here was the really cool part when the board came back I was able to use it with zero code changes all of the previously broken software worked fine this was a very significant moment for me because I realized I was now able to run any Apple 2 software on the Mega 2 however I wasn't done yet up until now I was still using the 2gs analog board from rev one and I really wanted to ditch that terrible composite video signal do you like free stuff you can join the road test program you can get free Dev kits test equipment and even on online training courses in exchange for a detailed review join our road test program learn more at the link below ah free stuff the Mega 2 has several signals for video one called servid and four bits called RGB why are there four bits for three colors well they actually make up a lookup table for the 16 bits of the Apple 2 color pallet servid represents a single horizontal line of chroma enuma data the RGB signals are a demux copy of that signal this boring example is just white dots here is a zoomed out example of multiple colors drawn on the same screen so for this project I came up with an rp240 base board to capture the RGB bus with the intention of driving an HDMI encoder chip but I could not find the actual programming data sheet for that chip so I wasn't really sure how to capture the data from the Mega 2 yet and I didn't know how to drive the HDMI chip that meant for my next major step I had two critical unknowns I briefly considered using some of the early DVI hacks for the rp240 but then I found a robust VGA implementation called Pico VGA it had a ton of greatl looking examples at this point I need to give a big thank you to my friend Tim because he figured out how to get that library to compile under vs code for me then my plan became to use one rp240 core to decode the mega 2's video signals into a shared frame buffer with the other core running PCO VG a that meant I could focus on writing Pio code to capture the four signals at 14 MHz now to figure out those RGB signals I wrote a Python program to download a frame of video over serial this was not exactly 60 frames per second but it allowed me to test the capture code for all of the Apple 2 video modes then I combined that code with the Pico VGA library and designed yet another PCB and actually this one worked on the first try check out how much cleaner the output is compared to composite video also even though the video signal is now entirely digital the Mega 2 generates the characteristic rainbow or ringing effect of the original Apple 2's color modes for those keeping track it means the project now uses two rp240s I did think about trying to fit it into one but I ran out of IO pins okay now it is time to take all of these boards and combine them into a single PCB with all of the major blocks debugged and a significantly better understanding of the Apple 2 design it was time to get to work in kycad essentially I pasted all of the Rev 2 boards into their own sub sheets fixed the issues mostly and cleaned up a lot of the net names to get everything connected it was a lot of work but a necessary step I did make a couple of changes in rev 3 for example these jumpers give some flexibility for the rp240s ultimately I want the two to communicate with i squ c also I added an audio circuit based on an LM 4875 this is a single Supply amplifier that lets you easily select between an internal or external speaker I mostly picked it though because a part named boomer seemed appropriate for a 40-year-old chip then I began the Monumental effort of Designing the PCB rev 3 is the most complex circuit board I have ever designed myself but it fits a modern 6502 an eom 128k Ram the Mega 2 obviously an iwm slot maker with a single Apple 2 compatible slot one rp240 for the keyboard another for the BGA a socket for the power supply a VGA port a db19 for the floppy drive and both connector types for the joystick initially I thought I could fit everything onto two layers but I decided to go with four and so glad that I did one approach I took was to Route the signals in a circle for example see how the buses kind of flow around the board instead of just branching randomly like a pointless Auto would do for fun I added some LEDs on the top eight bits of the address bus I also added four LEDs for the bits called annunciators the time it takes to refill the zones and process DRC makes passing DRC incredibly satisfying it takes a while even on the Beast that is my video editing machine between streaming and offline work I easily put over 100 hours into just the board design so I was excited to order the boards at least until they arrived my first batch of pcbs arrived with serious short circuits in the boards strangely the Fab sent me an electrical report on how the four boards were all bad but I only ordered and received three boards it was clear to me that they screwed up the registration on one of the layers so I resubmitted the grubbers to a different Fab and got five boards back that worked fine my assembly plan was to use 10led solder for the the Passos on the back side and then use bismuth based low temp solder on the top side the bald pick and place machine seemed to do quite well and at first things seemed to go well an initial power on with the keyboard 2040 worked as expected especially after plugging in a keyboard I did the VGA rp240 separately the qfn sold her pretty well especially now that I've had a lot of practice I did have a little bit of trouble with the programming header but the blink test worked fine and so did V GA output I was starting to feel really good then I encountered an incredibly frustrating series of issues that started with the eom since I did not reflow the board hot air started to melt the surface mount socket heating the board from behind did seem to work well though it was only then that I realized my programmer did not come with an adapter for plcc32 so I used fly wires to connect a generic breakout board but Parts would not reliably programm and spoiler later I got the correct adapter and the parts still would not reliably programmed however eventually I got one to accept the binary but VGA 2040 could not lock on to the video stream that's when I realized I loaded the crystal Wrong by 90° this was a quick fix that showed a little bit of activity but not a valid boot here is a clip where pass James realized a mistake that even more pass James had made but that got me thinking about what was the difference between rev 2 and rep 3 because the C CPU the RAM and the Mega 2 are all virtually identical between the two I didn't change much in terms of their design that's when it sort of hit me the major difference is my favorite chip the EO so let's look at it schematic real quick there's my eom and if we look at the control signals we can see there's the problem the right enable signal is connected to ground which means the chip is stuck in right mode for a readon memory that's a problem the other problem is that output enable is tied high so it is literally impossible for this chip to drive any outputs it is just sitting in a permanent High impedance [Music] State the repairs to make the eom readable just needed some capton tape jumper wires a steady hand a fine tip soldering iron and patience the one resource I was running low on the result was a familiar boot screen this happens when the Mega 2 is able to read the ram in general generate a stable video signal but the 6502 does not seem to be running I added header pins to the card socket area to connect my old friend the logic analyzer it confirmed the 6502 was fetching addresses but getting garbage data I tried a few more things but awesome man I was really hoping that would be the case wow okay so I decided to heck with the socket and soldered the chip to the board with the appropriate bodges also I replaced the Mega's plcc 84 Pock ET one of its pins were damaged and I found a ball of solder stuck between two others but fix after fix it was the same thing my confidence in getting this board to boot had dropped to zero bummer no matter what I tried or what I looked at or what I fixed it was fail after fail so uh I don't know what to do even though I was ready to give up I continued to debug but without the camera's running and you know what just like with rev one I eventually found the last solder joint I got the boot screen but then it crashed when checking the keyboard a few updates to the 2040 and it was stable enough to write basic programs and finally with help from my friend Rob we got the bga's 2040 color palette looking correct with it running the seven LEDs on the upper address bits are fun to watch and were worth adding they helped me see where the ROM was getting stuck without having to attach the logic analyzer every single time I even had some fun with a basic program that turned the four enunciator LEDs into a binary counter but the good times came to a halt when I load it Apple Works why does it say I need 128k of ram there is 128k in the design it worked fine on RAV 2 it's what I showed at the beginning of this video so what the turns out Apple Pro protos checks a few things to determine what kind of Apple 2 it is running on and sets a bite called machine ID some applications like Apple Works checked that bite rev 3 was identifying as an apple 2+ or a clone not as an enhanced Apple 2E like it should have been the problem is I used the same ROM as rev 2 or so I thought one place in ROM that protos checks is this string of hex values if you ignore the eighth bit it spells out Apple 2 in asking I need the ly messed with that sequence when trying to get my ROM image to say mega 2E at boot so protos was confused the simple fix is to change the bite sequence back remember why that's a problem fortunately a newer version of pros from 2018 assumes the ROM image is valid when generating the ID so as long as I boot with the latest protos stuff that relies on that bite will work as expected and after all of that frustration the Mega 2E works now to get to this point I need to say thank you to a ton of people these are just a few of the names who helped me build this crazy computer some answered questions wrote bits of code sent me some Hardware or just let me ramble while troubleshooting again thank you to everyone that has helped we did it we have a fully functional Apple 2E computer based on the Mega 2 chip but there is just one more [Music] [Music] thing [Music] [Music] here at the bald engineer engineering Institute of over engineered products with simple but clever names we wondered a simple but obvious question what if we made a computer that is bigger and slower than today's options we base this new computer on an almost 40-year-old very large scale integration chip called the Mega 2 it is expertly combined with a WDC 65 CO2 8bit microprocessor running at 1.012 mahz 4 64 out of 65 clocks there are two 64 Koby Dam Banks and 32 KOB of apparently onetime programmable e prom the unique Sanders integrated was Chip supports 5 and A4 floppy drives and that's it look I couldn't get smart portor yet okay if you could fit one of the many expansion cards available it could be configured for any ID except for three or six for obvious reasons with the help of a dual core arm cortex m0 plus the Mega 2 displays up to 560x 192 pixels with up to 16 colors at the same time via a VGA port did anyone check if VGA monitors are still available enjoy softwar driven onebit audio via either built-in or external [Music] speakers beeps have never sounded so good another raspberry flavored arm chip handles the delicate operation of converting a custommade USB 1.1 keyboard to the Apple 2 Data bus this brilliantly designed keyboard features volume adjustments and a soft power control for those pesky programs that rudely take over the reset Vector it even includes macro keys for common applesoft activities and supports the famous three-finger salute the allnew mega 2E is compatible with thousands of Apple 2 2 plus and 2E applications utilities and [Music] games it's still blowing my mind that 5 years ago I asked the simple question can the Mega 2 be a standalone computer and while I really only spent the last two two and a half years working in Earnest on it it's amazing to me that it's sitting in front of me now I do plan to do another revision I want to fix all the mistakes on the logic board and and add a few more features I also want to redo this case design it'll probably stay about the same size but it should really be two pieces in fact I never meant for this to be the final case I just got carried away with painting it so let me know what you think about the project you can leave a comment here or contact me on the element 14 Community for now it is time for me to get back to another no I was going to say get back to another project but I think I'm going to go finish where in the USA is Carmen San Diego [Music]
Info
Channel: element14 presents
Views: 50,335
Rating: undefined out of 5
Keywords: electronics, hardware, hacking, mods, element14, maker, engineering, element14presents, apple ii hardware, vintage computer restoration, electronics diy storytelling, picovga, picovga video output innovations, mega ii chip exploration, modular hardware development, rp2040 integration techniques, usb keyboard retro integration, electronics enthusiast blogs, retro computing projects
Id: gFCD4s_hsb4
Channel Id: undefined
Length: 27min 52sec (1672 seconds)
Published: Fri Nov 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.