# Merlin Pro on the Recurse Center Apple IIe

The goal: program in assembly directly on the Apple IIe. A popular program for
just this purpose is Merlin Pro.

## "Whoa, whoa, now, I don't want to read, I want to see computer go brrr"

**Try it in your browser:** [Open the Apple IIe playground](index.html)
(or see [how to run the webpage locally](README.md#browser-playground)).

Awesome. Make sure no floppies are in the Apple IIe. Turn the Apple IIe and the
monitor on.

You should see `Apple ][` on the top of the screen.

TODO: picture

Press control+reset. You should see a `]` on the bottom left of the screen. You
are now in Applesoft BASIC. If you want to do BASIC stuff, this is not where
you'll learn, we're here for assembly. From here, enter `CALL -151` and press
enter.

You should see a `*` prompt now. You're in the machine-language monitor,
friend. `CALL -151` enters the monitor at `$FF69`; the earlier version of these
notes said `CALL -131`, which jumps past the monitor's normal entry point.

Now for the fun thing. Type: `7FFE:A9 FF 8D 00 20 EE 01 80 D0 F6 EE 02 80 A9 60
CD 02 80 D0 EC A9 20 8D 02 80 00` and press enter.

To verify you did it right, now type `7FFEL`.

You should see this:

```
7FFE-   A9 FF       LDA #$FF
8000-   8D 00 20    STA $2000
8003-   EE 01 80    INC $8001
8006-   D0 F6       BNE $7FFE
8008-   EE 02 80    INC $8002
800B-   A9 60       LDA #$60
800D-   CD 02 80    CMP $8002
8010-   D0 EC       BNE $7FFE
8012-   A9 20       LDA #$20
8014-   8D 02 80    STA $8002
8017-   00          BRK
```

And then a bunch of stuff below that that doesn't matter. Congratulations, you
have written some 6502 assembly! Let's prep the screen for running it:

Type `C053` and press enter (this puts the Apple IIe into MIXED mode).
Type `C057` and press enter (this puts the Apple IIe into HIRES mode).
Type `C050` and press enter (this turns off TEXT mode on the Apple IIe).

You should see a lot of colors on the top of the screen with a few lines of
text on the bottom. This is MIXED mode.

Type `7FFEG` and press enter. The whole screen turned white (expect for text
stuff at the bottom). This is what the program you wrote above does.

To turn it back to black, type `7FFF:00`, press enter. Then type `7FFEG` and
press enter.

Other colors? ... Fine. Type `7FFF:55` and press enter. Type `7FFEG` and press
enter. That color is...

TODO picture.

Wait, what? Why?

You may have to do some reading.

## Hardware Breakdown

What we have:

* An Apple IIe with
    * audio I/O (originally for casette tapes)
    * 2 floppy disk drives
    * a commodore video monitor model 1702
* a writable Maxell MD2-D floppy disk
* two AUX cables
    * one with a usb-c-to-aux adapter
    * these wires are labeled audio in and audio out (audio in goes into the Apple IIe)
* A Comodore Monitor 1702 TODO

## Project contents

| Path | Purpose | How to Populate |
| --- | --- | --- |
| `disks/` | Original ProDOS Merlin Pro 2.33 disk images A and B | Search for "Merlin Pro Macro Assembler" if the archive link below does not work. |
| `audio/` | To get Merlin on the Apple IIe we're using the audio in jack | TODO: See instructions below |
| `tools/c2t-src/` | "Code to tape", pretend code is a casette tape we're loading into the Apple IIe | TODO: On repo? |
| [SHAD256SUMS](SHA256SUMS) | Verify you have the correct everything to start sending things to the Apple IIe | On repo (TODO: script that reports verification for user) |

## About the RC Apple IIe

The Apple IIe at Recurse Center is... an Apple IIe. Not to be confused with the
Apple II or the Apple IIc. As far as I can tell, this is a higher end model one
can have?

The Apple IIe we have has:
* Audio I/O
* 2 floppy disk drives
* A whopping 128 KB of RAM
* Auxiliary graphics (which allows HIRES and double HIRES?)
* Built-in Applesoft BASIC (different from Visual Basic?)


## References

* [Apple IIe Technical Manual](https://archive.org/details/Apple_IIe_Technical_Reference_Manual/page/n35/mode/2up)
* [Merlin archive](https://archive.org/details/MerlinProMacroAssembler)
* [Merlin Pro manual](https://archive.org/download/MerlinProMacroAssembler/Merlin%20Pro%20Manual.pdf)
* [c2t source and instructions](https://github.com/datajerk/c2t)
