The ESP32 SoftCard for the Apple II

378 posts / 0 new
Last post
CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
The ESP32 SoftCard for the Apple II

I’ve been working on a new card for the Apple II that would extend its capabilities using my favorite Wi-Fi module: the ESP32. I decided to called it a soft card, because similarly to the original Z80 SoftCard it contains its own processor allowing it to run software not originally meant for the Apple II. And similarly to the original 80-column card that was needed, it produces its own composite video enabled through a soft switch. Both NTSC and PAL are supported and can be switched using a command. In addition it can produce 8-bit sound that is mixed and played through the Apple II speaker. For most of its applications the card also needs a FAT32 formatted microSD card.

 

So far it has the following capabilities:

 

     - Connect to the Internet through Wi-Fi.

     - Listen to Internet radio or play MP3 files stored on the SD card or streamed from a URL. Playback can remain in the background while running Apple II programs.

     - Play videos stored on the SD card or streamed from a URL. The maximum resolution is 320x240.

     - Run Doom. Its shareware or full WAD files and MP3 music need to be placed in a folder of the SD card.

     - Run Wolfenstein 3D. A shareware or a full version of the game needs to be in a folder of the SD card.

     - Emulate a Macintosh classic. The ROM and floppy/hard drive images need to be on the SD card.

     - Emulate SEGA and NES. Game ROMs need to be on the SD card.

     - A rudimentary 80x25 text mode command console with DOS-like commands.

     - A rudimentary text based FTP client.

     - Support for an Apple II joystick. The joystick can be used in Doom, Wolfenstein 3D, SEGA, NES and the Macintosh emulator, where it can either be a regular joystick or emulate a mouse.

     - Support for grayscale mode for monochrome monitors.

     - In progress: support for the Apple Mouse II.

     - In progress: horizontal and vertical centering of the picture and overscan/underscan adjustments and persistence.

     - In progress: over-the-air firmware update capability.

 

This card does not have a boot capability and it uses a program that I wrote in Basic and compiled in Einstein, which locates the card and interfaces with it. So far it has been tested on Apple IIe, Apple II+ and Pravetz 82. It doesn’t require ProDOS and it can run on 48K.

 

Most of the work and challenges so far have been on the software side, so until now I have been developing it using a prototype board and kept the schematics in Paint. However inspired by the Dan ][ Controller’s retro look, I decided it's finally time to put everything in KiCad and do the PCB. I am planning to order the first 5 boards within the next day or two.

 

Offline
Last seen: 1 day 19 hours ago
Joined: Jun 29 2018 - 16:55
Posts: 590
This is unreal! Amazing work!

This is unreal! Amazing work! Can't wait to see this develop further :)

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
Very interesting! 

Very interesting!

 

MacFly's picture
Online
Last seen: 27 min 41 sec ago
Joined: Nov 7 2019 - 13:49
Posts: 483
Looks great!

You will need to show photos of the completed board - and ideally a demo video eventually. It's crazy what these "wifi modules" (har har...) can do these days. I wasn't even aware the ESP32 could just bit bang composite video and even VGA - and still have enough CPU performance left to be a pretty decent machine.

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Yes, I need to make one

Yes, I need to make one really good demo video, because right now I have a whole bunch of bad ones that I made for the Bulgarian retro forum where I have been logging my progress. I still haven’t figured out how to make good videos of a CRT screen. I usually do it using my iPhone on a tripod in the dark.

 

This is one is from last year when I first got Internet audio streams working: https://youtu.be/dgg3BOapkbU

 

Then later I added another video of the Macintosh emulator. In order to be able to display the 512x342 resolution on a monitor made for the Apple II, I had to decrease vertical height and the framerate to about 43 Hz. The iPhone cannot make a non-flashing video of this refresh rate. It doesn’t really flash like that in person: https://youtu.be/V5yLF3C_CSQ

 

This one is of various games on the SEGA emulator. Here I used my 14” Sony Trinitron: https://youtu.be/vih4AtDKr7I

And this one is the NES emulator: https://youtu.be/CecEQY4GylI

Btw, switching games is instant now, these videos are from before, when I was going something really stupid.

 

Wolfenstein 3D: https://youtu.be/KzopVwudJho

Doom: https://youtu.be/P-yBd-xg0Ho?t=97

And finally the video player: https://youtu.be/pxhhI5pilWk

 

All of these videos are still using the prototype version in my Pravetz 82:

 

Offline
Last seen: 1 week 6 hours ago
Joined: May 31 2022 - 18:18
Posts: 360
CVT wrote:Yes, I need to make
CVT wrote:

Yes, I need to make one really good demo video, because right now I have a whole bunch of bad ones that I made for the Bulgarian retro forum where I have been logging my progress. I still haven’t figured out how to make good videos of a CRT screen. I usually do it using my iPhone on a tripod in the dark.

 

 

So is this basically a embedded system (I know the ESP32, so it's not about that)?

Does it just tap the II slot for power, or is there some native interface available? 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
jeff d wrote:So is this
jeff d wrote:

So is this basically a embedded system (I know the ESP32, so it's not about that)?

Does it just tap the II slot for power, or is there some native interface available? 

 

The card doesn’t need to be in a slot just for power. It also uses the bus for communication with the Apple II. The Einstein-compiled program called “ESP32” that I run on the Apple II continuously monitors the keyboard, the joystick and (soon to be added) the Apple Mouse II. If it detects a keypress or a joystick/mouse event, it sends one of several 2 or 3-byte commands through the Apple II bus, which triggers an interrupt in the ESP32 module and tells it to read and interpret the command. The ESP32 module also sends data back through the Apple II bus to tell the program what state it’s in. 

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 18 2010 - 13:54
Posts: 793
 CVT wrote:The Einstein

 

CVT wrote:
The Einstein-compiled program called “ESP32” that I run on the Apple II...

 

 

Sounds like a perfect job for ROMXe!!

 

Offline
Last seen: 1 week 6 hours ago
Joined: May 31 2022 - 18:18
Posts: 360
CVT wrote:The card doesn’t
CVT wrote:

The card doesn’t need to be in a slot just for power. It also uses the bus for communication with the Apple II. The Einstein-compiled program called “ESP32” that I run on the Apple II continuously monitors the keyboard, the joystick and (soon to be added) the Apple Mouse II.

 

Very Nice! After seeing that, I thought.. sound straight-forward with the card as a input gateway between two systems which is a pretty cool trick but I'm also wondering about using the II to control an external system via USB or something similar. I imagine there's no reason that couldn't be done...but I'm tired and can't think clearly.I thought I read you can control the speaker too. Is that done by just maniuplating the A-Bus from the card?  I've never tried to toggle the speaker like that but sounds like it should be do able. (Mabye??)

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
jeff d wrote:...I thought I
jeff d wrote:
...
I thought I read you can control the speaker too. Is that done by just maniuplating the A-Bus from the card?  I've never tried to toggle the speaker like that but sounds like it should be do able. (Mabye??)

 

No, the speaker needs to be connected directly to the audio amplifier of the card, which is the U1 chip. This is why the cable of the speaker needs to run through the card. The speaker output of the motherboard goes to SPEAKER IN and the speaker itself goes to SPEAKER OUT.

 

I use an 8 ohm resistor on the card to simulate a speaker, so I can capture the Apple II’s sound and mix it with the output of the ESP32’s DAC (which generates the audio) the way you would mix stereo into mono with resistors and capacitors. Then I feed the mixed signal to the audio amplifier and it goes out to the speaker. One added benefit is the volume control of the Apple II's speaker, which will function even when the ESP32 softcard is not being used.

Offline
Last seen: 5 months 2 weeks ago
Joined: Dec 14 2020 - 04:20
Posts: 14
It really is an amazing

It really is an amazing project! I can't wait for it to be functional and especially to test it! When do you think it will be sold????

 

Jeff

Offline
Last seen: 2 months 6 days ago
Joined: Aug 12 2022 - 14:40
Posts: 32
very cool idea.   escentially

very cool idea.   essentially this is a stand alone machine, which uses the apple ii for controls.  

 

if the implimentation is done right, I can see this causing the price of apple ii's to sky rocket yet again as retro gamers by the thousands jump on board.  - better buy what you need now, before its released ;-) 

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Thanks guys! I really

Thanks guys! I really appreciate the enthusiasm and I can assure you that it has already produced the extra motivation needed to bring this project to completion faster. After dotting the i’s, crossing the t’s and rounding the edges, I have already placed an order for the first 10 PCBs from JCLPCB and I will keep you posted on the progress.

Offline
Last seen: 1 week 6 hours ago
Joined: May 31 2022 - 18:18
Posts: 360
CVT wrote:No, the speaker
CVT wrote:

No, the speaker needs to be connected directly to the audio amplifier of the card, which is the U1 chip. This is why the cable of the speaker needs to run through the card. The speaker output of the motherboard goes to SPEAKER IN and the speaker itself goes to SPEAKER OUT.

 

I use an 8 ohm resistor on the card to simulate a speaker, so I can capture the Apple II’s sound and mix it with the output of the ESP32’s DAC (which generates the audio) the way you would mix stereo into mono with resistors and capacitors. Then I feed the mixed signal to the audio amplifier and it goes out to the speaker. One added benefit is the volume control of the Apple II's speaker, which will function even when the ESP32 softcard is not being used.

 

Nearly a decade ago I did something similar as a senior design project but it wasn't quite as full a design as yours everything but integrating with a II was done (ie was a host for game emulators, battery powered with a LCD screen in a printed case.I like the idea of real-time mixing of II audio with ESP32. So, one ADC dedicated to sampling the II speaker at some super high resolution ;).  Seems if you can stream audio while playing a II game through the same speaker that could be very entertaining! The other emulators... icing on the cake for me. What's your BOM cost?

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
jeff d wrote:...What's your
jeff d wrote:
...
What's your BOM cost?

 

I haven’t calculated it exactly, because it really depends on the quantity, but the ESP32 module is about $4.50 and everything else is a jellybean under 50 cents. At this point though I am looking at further annotating the project in KiCad, so that JLCPCB can also spit out a price for the sourcing and assembly, because I don't really want to solder more than 10 of these cards by hand. Instead I really want to concentrate on the software and keep adding more capabilities through over-the-air updates. So far with everything I have listed above the firmware is only 3 MB and this particular ESP32 module has 16 MB of flash. 

magnusfalkirk's picture
Offline
Last seen: 20 hours 48 min ago
Joined: Feb 18 2007 - 11:46
Posts: 335
Just amazing!

Just amazing! I'd be interested in one of these, but of course I'd need someone else to put it together for me since my soldering capabilities are zero. Any idea how large an SD card can be used with this?

retro_bill's picture
Offline
Last seen: 1 year 2 weeks ago
Joined: Aug 5 2020 - 11:56
Posts: 124
Very Cool! I will take one!

Very Cool!

 

I will take one!

 

Also I would be willing to build one for anyone needing one or if you have one just send the kit and pay shipping both ways.

 

Bill

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Today I checked with JLCPCB’s

Today I checked with JLCPCB’s assembly services and they have all non-socketed elements in stock. This means they can populate either just the 4 SMD elements or everything.

Offline
Last seen: 1 week 2 days ago
Joined: Jun 12 2022 - 23:35
Posts: 111
This is a pretty interesting

This is a pretty interesting card!

One feature that would be really cool would be genlock capability, so that the ESP32 video could be overlaid on top of the Apple ][ video.  It would have to trigger and sync from the Apple ]['s video signal in an interrupt on the ESP32.  Even if it only supported black-and-white genlock capability (which wouldn't require tracking the phase of the Apple ]['s color carrier), having the ability to interact with both the ESP32 and the Apple ][ simultaneously on the screen would be really cool.

 

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
I don’t really understand the

I don’t really understand the idea - what would overlaying over the Apple II video bring? Right now the video signal is simply switched mechanically by the K1 relay, located just above the ESP32 module on the card.

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
CVT wrote:I don’t really
CVT wrote:

I don’t really understand the idea - what would overlaying over the Apple II video bring? Right now the video signal is simply switched mechanically by the K1 relay, located just above the ESP32 module on the card.

 

 

You can do some cool things with video overlay...  but it would probably require a much more complicated video circuit to do it, and that's probably beyond the scope of this project.  One of the big things about this particular design in my opinion is it is relatively simple and straight forward but still provides some incredible power.

 

 

Wizard1969's picture
Offline
Last seen: 1 year 2 weeks ago
Joined: May 26 2016 - 02:17
Posts: 4
So, you only need one monitor

So, you only need one monitor?

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Yes, this is a single monitor

Yes, this is a single monitor setup. Maybe the two RCA connectors give the wrong idea, but the bottom one is for input.

 

The whole idea is to use whatever monitor is attached to the computer. The composite video that comes out from the back of the Apple II enters though the bottom RCA connector, goes though the relay, comes out the top RCA connector and goes to the monitor. When the card is not in use, the Apple II video signal just goes in and out. When it is in use, the relay switches to ESP32’s DAC, which is used to generate the composite video of the ESP32.

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
You know I was thinking.... 

You know I was thinking....  if you add an EPROM to this board you could, with the right programming on the ESP32, make this card a low cost, low power consumption 80 column card for ][+...  Like a Videx Videoterm compatible.

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Yes, that would be possible,

Yes, that would be possible, but at this point I really want to expand the capabilities vertically and not in parallel with what the Apple II already does. You can easily get a 80-column Videx clone for about $40 and their demand is further limited by the relatively small number of the II+'s versus that of the IIe's. Besides CP/M has already been ported to the ESP32 and I can easily add it to the firmware, but again I feel that people who want to run CP/M on the Apple II would rather use the real retro hardware, simply because it was always possible.

 

This is the main reason I want to stay away from anything that is already possible and concentrate on the new stuff. I even ported an Atari 400/800 emulator and after I had it working perfectly I decided to remove it. It was a tough cut, but the Atari 800 itself has very similar capabilities to the Apple II and all the games look and feel more or less the same.

 

Instead a lot of interesting things (like Duke Nukem 3D and MS-DOS) have already been ported to the ESP32 and I plan to keep adding capabilities post release, if my hardware configuration allows it. Basically anything that has been shown to run reasonably fast on the ESP32 I can port, but I have to further optimize it to run on a single core. My second core does the composite video and cannot be bothered to do anything else, so everything else including the audio and the communication with the Apple II peripheral devices has to be done by a single core.

 

Maybe this philosophy is wrong and sometimes I am conflicted about it, but until I get some real users there is no way for me to tell. For example sometimes I think it would be really cool to add an Apple II emulator that can run really fast. Porting would not be a problem, since it’s publicly available for the Atmega32 and it has been shown that it can run fast enough on the ESP32. I actually already have this capability to some degree, but it’s through double emulation, it’s slow and only about a third of the Apple II games work on it:

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
The experimental batch from

The experimental batch from JLCPCB just arrived today. Visually all 10 of them look perfect. One thing I noticed right away is the need to increase the distance between the pads of Q1. Even though there is no continuity between two adjacent pads on any of the PCBs, they look crazy close to me.

 

The next step is to populate one card and see how it behaves. One thing that worries me is crosstalk noise in the video or audio channels, since things are much tighter than they were in the prototype board I was using up until now.

 

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
Looking forward to hearing

Looking forward to hearing how your card works built from those PCBs.  Looks beautiful.

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Thanks! The good news is the

Thanks!

 

Well, the good news is the card is working. However this will be it for Rev.0, because I found 2 mistakes so far that require manual PCB modifications. I don’t know why I ordered 10 instead of 5. Rev.1 will be ordered within the next few days and this time I will try their assembly services. Also I need to come up with some extensions cables, since the Apple IIe speaker cable is too short.

 

Here is the populated card and below it's running King’s Quest through the Sega emulator. I am still waiting for the resistor matrix RN1 of the 5V to 3.3V voltage divider to arrive, but it also works without it. Actually I might be able to get rid of this voltage divider altogether by powering the 74HCT374 from the 3.3V rail, which will automatically get rid the R-matrix and the group of 8 resistors.

 

 

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
CVT wrote:Thanks! Well, the
CVT wrote:

Thanks!

 

Well, the good news is the card is working. However this will be it for Rev.0, because I found 2 mistakes so far that require manual PCB modifications. I don’t know why I ordere

 

Looking really good!  Hope the V2 board is perfect in every way!

 

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
I'd still be tempted if I got

I'd still be tempted if I got a couple of these to try adding a 28C64 EEPROM to the prototyping area and hacking a version of the Videx ROM to it to try to make it usable as an 80 column card.  It would also take some code for the ESP32 of course to emulate a 6845/6545/Hitachi clone chip.  But that should be fairly simple as those chips are pretty simple.

 

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Actually I added the

Actually I added the prototyping area precisely because I wanted to add an EPROM chip at some point, but in order to experiment with booting. To simulate a Videx card I don’t think I would need one, since the ESP32 is fast enough to simulate it. However the card cannot be bootable without EPROM chip, because the ESP32 takes about one second to load the firmware and run it from the moment the power is switched on and if something is not there immediately it will miss its chance.

 

Otherwise I am done with Rev.1. I was able to remove 10 elements by getting rid of the voltage divider and letting the 74HCT374 handle the voltage difference by powering it from the 3.3V rail. Also for the initial programming through the UART, I don’t really need to solder the pin headers. Instead I decided to use a PCB clip from AliExpress that can connect straight to the unpopulated footprint of the UART port.

 

Here is Rev.1 after a bit of rearrangement:

 

PTB
Offline
Last seen: 3 hours 58 min ago
Joined: Aug 14 2020 - 07:01
Posts: 118
I have no idea how I missed

I have no idea how I missed this thread....but that is Astounding.

 

So you can get color without needing a PAL encoder card as well?

 

Really nice work ! Incredible.

 

Cheers

Dave

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Thanks! Yes, the ESP32

Thanks! Yes, the ESP32 SoftCard can directly generate either PAL or NTSC color composite video signal. The following resolutions are supported and all of them are progressive (non-interlaced):

 

   • PAL: 320x240 at 50 FPS

   • NTSC: 320x240 at 60 FPS (NTSC TVs have trouble fitting 240 vertical lines on the screen, so I might cut it to 225 or even less.)

 

In color mode up to 14 distinct 256-color palettes can be allocated.

 

In addition to that it supports the following resolutions in monochrome mode:

 

   • 640x225 at 50 FPS, 4 bits per pixel (16 grayscale colors)

   • 640x225 at 60 FPS, 4 bits per pixel (16 grayscale colors)

   • 512x342 at 43 FPS, 1 bit per pixel (either black or white)

 

The last resolution is only used by the Macintosh emulator. The frame rate is not standard, but it is the only way to sync 342 vertical lines on a 15 kHz Apple II monitor. 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Project Update

Project Update:

 

Today I finally ordered Rev.1 from JLCPCB and this time they will assemble 2 of the cards. Due to chip shortage issues I decided to replace the SMD audio amp chip with the good ol’ LM386 in a DIP8 socket. This eliminates 2 more resistors and gives the card a more retro look:

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Project Update: Rev.1 assembled by JLCPCB

Project Update:

 

The other day I received the Rev.1 of the card assembled by JLCPCB. They did an amazing job on the SMD parts and the card was nicely cleaned. I am definitely going have them make the cards.

 

I really liked the retro look of the card with the DIP8 LM386 chip as the audio amplifier, however I am now forced to abandon it and go back to the original SMD LM4862 used in Rev.0. It turns out the audio quality of the LM386 is not as good and it picks up noise from the Wi-Fi modem. The LM4862 doesn’t have this problem, most likely since it allows me to run it as a unity-gain amplifier.

 

So, moving on to Rev.2, which looks like it will be the final revision and will be essentially Rev.1 with the SMD amplifier from Rev.0. Here is one of the two Rev.1 cards assembled by JLCPCB:

 

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
Thanks for the update. 

Thanks for the update.  Looking forward to getting my hands on one of these!

 

 

Offline
Last seen: 3 months 2 weeks ago
Joined: Jan 29 2023 - 21:32
Posts: 6
I am regularly amazed at the

I am regularly amazed at the intelligence and determination of people in this community. WOW. I only wish I was smarter so I could contribute other than with a few $ buying an example if someone's efforts.  

in other words, count me in for one or two when the time is right please. ;-p

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
Is2scooby wrote:I am
Is2scooby wrote:

I am regularly amazed at the intelligence and determination of people in this community. WOW. I only wish I was smarter so I could contribute other than with a few $ buying an example if someone's efforts.  

in other words, count me in for one or two when the time is right please. ;-p

 

Helping support makers either through encouragement or by buying things is a great way to start.  A lot of people here who are making things started out that way.  Albeit in cases like mine...  40+ years ago.  But it's never too late to start.

 

Offline
Last seen: 1 year 3 months ago
Joined: Sep 16 2009 - 18:34
Posts: 73
I too am amazed at what others are doing.

Until I joined this forum, I had no idea that so many people were building new things for the Apple II family. I too am amazed at what others are doing by building these products from scratch. I wish I had such skills. But I wish I has many other kinds of skills that I don't posses. Thus, I experiment with Arduino, general low voltage things, and having fun with my grandson by us learning what we can and can't do with common household battery power. My interests in other things is vast, and often battles for my mind and time. But, being retired helps. Thank you to all that share so much interesting information, which keeps me motivated to keep learning.

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
gottj wrote:Until I joined
gottj wrote:

Until I joined this forum, I had no idea that so many people were building new things for the Apple II family. I too am amazed at what others are doing by building these products from scratch. I wish I had such skills. But I wish I has many other kinds of skills that I don't posses. Thus, I experiment with Arduino, general low voltage things, and having fun with my grandson by us learning what

 

If you work with Arduino you have a lot of what you need to work with the Apple II.  This project may be of interest to you:

 

https://github.com/profdc9/Apple2Shield

 

This card allows you to plug an Arduino UNO into an Apple II card.  With the right software on both sides that can give your Apple II access to basically anything you do with the Arduino.

 

This project was started by profdc9 who is a member here...  Check out this thread:

 

https://www.applefritter.com/content/apple-ii-arduino-uno-and-shield-interface

 

 

 

 

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Project Update: I finally got

Project Update:

 

I finally got to the very last feature I wanted to add – the support for Apple Mouse II. However I ran into a wall and I need some help.

 

The issue is that I never had the time to learn the assembly language for the Apple II, so I wrote the communication program in AppleSoft Basic and then used the Einstein compiler to make it really fast. However once I added the mouse routines to it, the Einstein compiled version no longer works from ProDOS because it was never designed for ProDOS and the Apple Mouse II interface for Basic hits some of the unsupported features. More about this problem here

 

So at this point I need some help translating the AppleSoft Basic program to Assembly, so I can then use the assembly routines of the Apple Mouse II described in its documentation. The Basic program is very simple – only about 50 lines of code and half of those are just variable declarations. The first part of the program locates the slot of the ESP32 SoftCard and then it simply sends any keystrokes and joystick changes to one of the 8-bit ports. I removed AppleSoft mouse routines to avoid confusion.

 

I know quite a few people here are pretty good in assembly and I am hoping they will give me a hand. Thanks in advance!

 

Package iconESP32.zip

 

 

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 18 2010 - 13:54
Posts: 793
Happy to help. Are you

Happy to help. Are you looking for a binary file that you can BRUN to do the same as this BASIC program? Or do you want to see the assembly source code to do this so you can learn? If so, would you be using a native Apple II assembler like Merlin?

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
jeffmazur wrote:Happy to help
jeffmazur wrote:

Happy to help. Are you looking for a binary file that you can BRUN to do the same as this BASIC program? Or do you want to see the assembly source code to do this so you can learn? If so, would you be using a native Apple II assembler like Merlin?

 

I prefer it to be in assembly, so I can see how things are done.  The idea is for me to be able to understand it, play with it in Merlin and extend it to call into the firmware routines of the AppleMouse II card, that would allow me to find its slot and access the mouse coordinates. With that and the examples in the attached PDF I think I’ll be able to manage.

 

https://www.applefritter.com/files/2023/03/02/AppleMouseII.pdf

 

My only experience with assembly is from my university days when I took an x86 assembly programming course, which I liked a lot, but that was more than 26 years ago.

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 18 2010 - 13:54
Posts: 793
OK. I'll keep your basic

OK. I'll keep your basic commands as comments and convert the code to Merlin Pro assembly. This should provide you with a good explanation of what the code is doing and allow you to extend it to include whatever else you need.

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 18 2010 - 13:54
Posts: 793
Here's a simple translation

Here's a simple translation of your code to assembly. It's actually harder to convert BASIC code to assembly than just writing it from scratch. This code was written to make the translation easier to understand; it's not very elegant nor optimised. For example, if I was writing from scratch I'd probably make the slot search go from 7 down to 0. It makes the branch slightly more efficient. But this should be a good starting point.

 

Obviously I could not check all of the code without having the board. But it does correctly run and exits with the "ESP32 CARD NOT FOUND" message. Hopefully this gets you started down the correct path!

 

Plain text iconCVT.txt

CVT
CVT's picture
Offline
Last seen: 2 hours 46 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1165
Wow, thanks! This is exactly

Wow, thanks! This is exactly what I needed!

 

What did you use to generate the binary? I am using Merlin-8 v2.58 with AppleWin, however it didn't like lower case characters and underscores for the label names. I changed them to uppercase and it assembled successfully, but the binary it generated got front-padded with zeros and it jumps straight into Monitor:

 

 

Package iconMerlin.zip

Package iconESP32.zip

masteries's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: Sep 23 2022 - 05:28
Posts: 19
Great!

Great!

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 18 2010 - 13:54
Posts: 793
CVT wrote:jumps straight into
CVT wrote:

jumps straight into Monitor...

The "padding" you are seeing is the variable space which precedes the program. If you want a BRUNable file you need to add a JMP instruction to the beginning of the code to start execution at the correct place (see CVT2.text below).

 

Alternatively, the code I sent was used with the Merlin Pro Assembler; that's the least common denominator which will work in any Apple II with DOS 3.3. You can use the disk image below to see how it works. Then if you want to use Merlin 8 you can learn by converting it to work there.

 

To run the code:

1. Launch the CVT Merlin Pro image

2. Hit "R" to Read the file and type "CVT"

3. Type "ASM" followed by return

4. Hit "Q" return followed by "E"

5. Type "GET" return to load object code

6. Type "MON" return to enter monitor

7. Type 3000G to run program

 

Plain text iconCVT.txt

Package iconCVT Merlin Pro.dsk_.zip

 

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
I had to fix/enhance a few

I had to fix/enhance a few things in my assembler to make it assemble your code.  It also revealed something about code with multiple ORG directives which I need to think about.

 

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 18 2010 - 13:54
Posts: 793
 softwarejanitor wrote:I had

 

softwarejanitor wrote:

I had to fix/enhance a few things in my assembler to make it assemble your code.  It also revealed something about code with multiple ORG directives which I need to think about.

 

Actually, I commented out the second ORG and replaced with a DS directive to fill in the gap between the variables and the program. I'd probably put the variables after the end of the program anyway which would have also eliminated the need for the JMP. But this was not meant to be an example of tight, elegant code. In fact just the opposite. I would do many things quite different here. But I wanted to show the correlation to each BASIC statement as simply as I could.

Offline
Last seen: 1 month 2 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
Sure, I understand.  I have

Sure, I understand.  I have just been trying to improve my assembler when I see example code so that it will properly handle as wide a variety of code as possible.  It can handle a fair amount of Merlin, LISA, EDASM and SC syntax.  I need to read up and add code to handle ORCA/M stuff too someday.

 

 

 

Pages

Log in or register to post comments