Writing an emulator from scratch, need some input

2 replies [Last post]
Joined: Sep 22 2008
Posts: 7

I decided to emulate the //e because I found it the most powerful from the II series without going overboard as I felt the IIgs did. To me, the //e is the top-notch model of the ][ series.
Being a native emulator it means that no operating system is running in the background, so it boots as fast as the original hardware. It currently emulates the CPU with the same number of cycles per line and total per frame, keyboard input is currently done via uart, speaker works, video supports paging and modes text+HGR and HGR2.

As I demonstrate in the video below, it's having some issues and I was hoping maybe you could help me out.

Youtube video (Video tag didn't work)

1) It does not try to boot from floppy when powered on
I quite frankly don't know why. The good ol' ][ did by jumping to address $c600, but my emulated //e just drops directly to BASIC. Can someone here please shed some light on the //e's boot process for me?

2) In HGR mode, HLINE x1,y1 TO x2,y2 does not work
Is this an error in my emulation, or am I using the instruction wrong? I suspect a CPU flag might be wrongly set somewhere in the HLINE function. If nobody knows, I'm assuming it's my fault. But I thought it'd be worth a try to ask here, in case it saves me from hours of debugging and disassembly.

3) Probably related to #1, pr#6 results in an odd crash. The error message is not generated by me, but by the //e's kernel. I *think* it (and #1) could be related to improper bank switching, but either way I need some pointers to get started.

Any input would be more than welcome.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
resman's picture
Joined: Feb 9 2006
Posts: 214
Re: Writing an emulator from scratch, need some input

Given that you have so much working, I doubt anyone will be able to point out a simple cause. Writing emulators from scratch is always a fun exercise, if not a little aggravating at times. My suggestion is to start incorporating some debugger functionality. You already have the UART functional, so perhaps a certain key sequence could drop you into a basic debugging environment to display memory locations, emulator state, etc. You could use the UART to send basic debug output while it's running for sanity checking.

Sather's Inside the Apple IIe would be a good source of information about the actual hardware, Beneath Apple DOS has good information on the floppy boot process. You should be able to find both with a quick Google search. What's Where in the Apple II was always my goto reference for ROM routines (afar the actual ROM listings in the Reference Manual). Still actively maintained: http://www.whatswhereintheapple.com

Looks like a cool project. Good luck,


Joined: Sep 22 2008
Posts: 7
Re: Writing an emulator from scratch, need some input

Thanks for your input, resman. I know the questions are difficult to answer, but it was worth a try. Maybe someone else here had tried the same earlier and could save me time debugging.
I guess there's no way around so I might as well start disassembling and figure out where it goes wrong.

Thanks for the link, though, I had not seen that site before. Up until now I have only been working with fragments of documentation I have found scattered here and there.