[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Long(!) Qs about AppleII emulator programming



(This is a mail I posted to comp.emulators.apple2 a few days ago. Someone suggested posting 
it here too as comp.sys.apple2 has more readers. So here it is.)

Hello,

Please allow me to introduce myself (and please let me point out that 1.) this is my second 
posting to a newsgroup and as I haven't received any response to the first one, I still 
don't know the mistakes I'm doing, b) I am only a German (= Kraut = bad English). Please, 
have patience with me, if I do something wrong.), I have written another (yawn!) 
AppleIIe-emulator for the PC recently as I moved from my old Amiga (sigh) to the PC. I have 
already written an AppleIIe-emulator for the Amiga (the only one AFAIK), and now I've tried 
to convert it to the PC, as I've found other emulations (as good as they may be like 
ApplePC that even emulates the mocking-board) in some special cases lack a few things 
(sometimes strange graphic output, no setting of disk-volume values, no 
getting-around-the-german QWERTZ-keyboard etc). The program was written using NASM, the 
netwide assembler, and a DOS-extender. It's 100% assembler and runs under protected mode 
environment (i.e. 32-bit code). It uses a standard SVGA-video mode ($100: 640*400/256) for 
full-screen graphic output and was tested on some computers (all Pentiums). So far it seems 
to run fine.
My problem (which is why I am posting here) is quite simple: I for myself do not have 
access to a working AppleIIe anymore, and, as I live in Germany, I will probably never be 
able to buy a new one. This means: I cannot test special behaviour (e.g. of softswitches). 
Worse: In Germany I cannot get hold of any books and magazines published in America 
somewhat in the eighties. Suggestions like: 'Take a look at the book "Beneath Apple-DOS"' 
won't work for me, I'm afraid. As a result my sources of information are rather limited. 
But I need lots of information to extend my emulator e.g. to emulate an AppleIIc if 
possible. (Which I would do even if there are already lots of better ones than mine, 
because it is my hobby and I like the AppleII :-) ) But let me explain in detail what the 
emulator does and what not (mostly due to lack of information):

What it does:

My emulator emulates a standard AppleIIe as far as my information is concerned. There may 
be some features not implemented (yet) of which I only heard of. (What about this shift-key 
testing thing? Or differences in the $c010 softswitch? How does $c019 exactly work?)
In detail:
- 128Kb ram
- All standard memory-managment softswitches: Slot/Internal, $c300 Internal, LC-bank, 80col 
store, aux read, aux write, aux ZP/LC read/write.
- Emulates 2 standard disk drives (Slot 6) using .DSK or .NIB diskimages. The volume value 
(disk ID-code) may be set seperately (in a disk-textfile) for .DSK-files to run 'Death In 
The Caribbean', 'Where In The World Is Carmen SanDiego', 'Mickey's Space Adventure' and 
other programs that rely on it. No special .NIB-files are needed then.
- All legal graphic modes supported.
  . 40/80 column text
  . 40/80 column lores
  . hires (280*192)
  . double-hires (560*192)
  . all mixed modes (4 text lines at the bottom of the screen)
  It does not (yet) emulate non-standard modes (annunciator #3 off + hires or lores) as 
  they are not used in any program I know of so far. (Information?)
  The bottom text output in mixed modes is not blurry as in ApplePC. Also the hires-output 
  looks more like RGB monitor than TV-output (like AppleWin or Apple2000). This may not be 
  accurate compared to the original AppleII, but I haven't bothered yet about copying flaws 
  of the original environment that are rather ugly than useful. What I could nevertheless 
  need are exact RGB-values for the hires/lores colours as shown on a typical NTSC or 
  PAL-monitor. The colours used in this emulation may not be correct as I've never had 
  access to a real AppleII with a colour monitor. However, the double-hires output looks 
  quite similar to the one used in ApplePC as it allows to mix "text" and graphic (mode 2, 
  isn't it? I posted a mail about the usage of the highbit in commercial software (games) a 
  while ago but nobody cared :-| ).
- 0.5 Mhz, 1 Mhz, 2 Mhz and whatever Mhz are already implemented as default emulation 
values. BTW 2 Mhz here really means a 6502 with 2 Mhz. The graphic output (50 frames per 
second (PAL)) remains as slow as with 1 Mhz, i. e. processor and graphic emulation are 
seperated.
- monochrome output (for e.g. 'Taipan' or UCSD-Pascal Turtlegraphics) with selectable white 
or green or brown output (or whatever you want... :-) ).
- full double view of both text/graphic pages ($2000 - $5fff) as found in ApplePC
- *very simple* disassembler included. Will be improved soon.

So far it seems to run all standard programs I have come across (mostly games). No bugs 
found yet.

What it does compared to other emulations:

- runs 'Airheart' (Apple2000 crashes due to $ffff-$0000 PC overflow bug)
- runs 'Accolade Comics' (ApplePC crashes due to Language Card-bug)
- runs 'Dragon Wars' (ApplePC crashes (occasionally?) due to Language Card-bug)
- runs 'Amazon' Introsequence (tune communication) almost as good as on an original 
AppleII. Emulation is not slowed down (AppleWin) and graphic output does not flimmer 
(ApplePC).
- runs 'The Institute'-, 'Lucifer's Realm'-, 'Taipan'-, 'Beyond Castle Wolfenstein'-white 
noise routines almost as good as on an original AppleII. Emulation is not slowed down (as 
with AppleWin), and graphic output is almost correct.
- runs 'Ultima IV' without being slowed down (Apple2000) because of the heavy LC-card 
switching during the redrawing of the landscape (shapes are put in LC-banks).
- switches between page 1 and 2 ('Drol', 'Situation Critical' or any other program that 
uses double buffering) *without* waiting for vertical retrace (to avoid flimmering) like 
the real AppleII does
- automatically speeds up disk-access by switching to 8Mhz as long as the motor is on (like 
AppleWin but without stopping graphic output).
- allows to write protect a disk (i.e. drive to be precise)
- full screen output (like ApplePC or Apple2000) in 640*400 for best ratio. My Windows runs 
under 800*600 truecolour videomode, and the output of AppleWin is then both small and ugly.
- Emulation is definitely *slower* (sorry) than ApplePC or AppleWin. Explanation: ApplePC 
runs in realmode and uses mostly 16-Bit commands (makes uses of fs and gs though for faster 
ram-access which is why it needs at least a 386). The values for A,X,Y,PC,SP and SR are all 
kept in the x86 registers (same with AppleWin). PC-access (opcodes and adressing modes) is 
done by directly reading through the SI register. This is the reason why some programs 
fail. In that case SI reads the wrong bytes on an apple-memory boundary (e.g. $dfff/$e000 
Bank 1/2 of LC card), if the dos-ram for the LC-card is not allocated in a logical 
(physical) row. This can only be avoided by an accurate but at the same time also slower 
bus emulation.

What it does not (yet. Here are my questions):

- No disksave-option yet (PC only). I simply was to lazy to program it. Probably next beta.
- Does not read 2IMG-images (will be included soon). Or is there any other modern standard 
that should be implemented?
- Illegal opcodes not fully emulated yet are about to be implemented in the next beta. Are 
they the same as on a MOS 6510 (CBM 64)? I have also written a CBM 64 emulator for the 
Amiga (the fastest one ever. Hehe :-) ) and simply converting it to the PC may speed up 
programming.
- No proper sound. Only crappy direct PC-Speaker (not as good as ApplePC due to additional 
graphic output). I am in strong need of information on how to program a soundblaster 
compatible sound card using double buffering under protected mode environment.
- It does not emulate an AppleIIc (sigh). I haven't got enough information on how to do 
that. I have built in some 65C02 opcodes already (as well as some 65SC02), so the user will 
be able to switch to this processor (even on an AppleII or AppleIIe). But I need 
information about the differences between AppleIIe and AppleIIc, especially memory 
managment, interrupt and extra slot cards.
- No joystick. (Soon?) The joystick emulation using the number pad doesn't work properly. I 
guess I have to write my own keyboard-driver for this.
- No mouse. Sorry, but absolutely no information about the AppleII-mousecard. Shouldn't be 
too hard to implement it though.
- No printer. Same as mouse. All I need is the slot rom and a (short) description on how it 
works. But until then I cannot implement it. (Though I need it!)
- No additional ramcard emulation. See before.
- No mocking board emulation. See before.
- No hard disk emulation. See before.
- No real keyboard emulation. Up to now it simply uses the DOS-interrupt to read a key. 
Characters are the same as found on the keyboard. Only for German keyboards a patch exists 
that converts "Y" to "Z" and vice versa for better game play (may be switched off). A 
capslock patch for emulating an AppleII is also included. Since the German keyboard layout 
is quite different from a real AppleII I've found serious working with ApplePC too 
difficult as even standard chars like '#', '*', '=', '/' etc were placed anywhere on the 
keyboard. For this reason, if I should ever write my own keyboard-handler the program would 
still offer the option "Use PC-keyboard layout".

What it needs:

- DOS (with DPMI and DMS) or Windows 9x. (Won't work under NT, I'm afraid. Don't know the 
reason yet. I'm working on it.)
- VESA 1.2 compatible graphic card with SVGA mode $100 : 640*400 pixels and 256 colours. 
Linear Base Frame prefered. (May run using $a000 window segment but is definitely slower.)
- some megabyte free RAM (x MB wherever and about 128 KB DOS memory)
- probably a Pentium processor. (Couldn't test on 486. May be too slow due to the complex 
graphic emulation and readbus/writebus implementation.)

The program was tested on several Pentiums (233,350,400,700) and runs emulation at a speed 
of approximately 8 MHz (6502) with *full* graphic output (no frame skipping).

To sum it up:

What I need are lots of information about special AppleIIe-hardware, mostly slot-cards. And 
I need information about the internal organisation of the AppleIIc. My search through the 
internet so far revealed nothing but simple data like number of kb, processor etc, but no 
insider information on how it actually works. If you can help me (e.g. you know of a good 
source in the internet or you already have the answer), please post to this newsgroup or 
directly to my e-mail address. I'd really appreciate it and I'd be very grateful if someone 
could help me in any matter mentioned above. Furthermore, if you don't mind I'd like to ask 
some more questions (or in more detail) about the AppleIIe/c in this newsgroup in hope to 
receive interesting new information. As I don't want to get on anyone's nerves I'd like to 
make sure that my questions (I have lots as you could see) don't annoy anyone.
Thanks for your patience and help in advance

Cheers

Holger

P.S.: If anyone should be seriously interested in testing the emulator, just send me a 
mail. (I'm sorry I haven't got a homepage for easy download.) The file-size is about 60kb. 
Of course as it is a beta-version I cannot take any responsibility nor warranty (big 
disclaimer).