Thank you for revising the emulator ..
BigEd wrote:
Yikes! That's the most unusual Pascal I've ever seen. Free Pascal does a reasonable job of line breaks and indentation, but I wonder if this is meant to be a de-obfuscation challenge?
Not intentionally
i needed to re-use my old ancient eprom programmer on my windows based computer, but its operating software was 6502-based, it came from an apple II and has been translated so it could run on PET and C64. First, i thought it were possible to take Vice and simply add some specific code. But the version i tested, had a bug, it froze after half an hour ("sound buffer overflow"). additionally, i dont understand much of the C programming language, my skills are limited, so i decided to make my own emulator in Delphi/pascal. I was looking for some code at
http://www.zophar.net/6502.html but almost all examples from there are written in C or BASIC. Additionally, source code of most emulators seems to exceed 40 KB , that means in order to understand such code, i must read and flip *many* pages. Because i'm a little impaired with respect to my eyesight, i made a challenge out of it to put everything onto one single page (72 lines with 80 characters each), so i had to think very much to get it condensed, and do less typewriting in front of monitor. thank you for your patience with missing indents ...
There is an older , more object oriented (and more faulty) version , too. Perhaps you might try it:
http://home.foni.net/~sjanda/u6502b_ver ... iented.pasIt contains much human-readable information, indents and commentaries in brackets.
In order to check it out, you need to have a variable containing the processor:
... uses u6502b...
var m6502: T6502b ; Start:WORD;
begin
m6502:=T6502b.create; {Initialization}
{put some opcode into memory , e.g. LDA #$55}
m6502.mr.mM[$1000]:= $A9;
m6502.mr.mM[$1001]:= $55;
{set JAM = true causes emulation to stop after a single step}
m6502.JM :=1;
Start:= $1000;
{invoke emulation in single step mode}
m6502.SYS(start,0);
...
Showmessage('Accumulator contains now:'+ InttoHex(m6502.mr.AC,2));
...
m6502.free;
end;
Quote:
Unfortunately it isn't accepted by either p2c or gpc. But, you mention it passes 100 of Wolfgang's tests, so that's very impressive. Does it fail any or was that the number you tried?
There are two files involved, a core 6502 emulator and a c64 emulator which uses it. The latter needs some Win32-specific stuff, but the first is kept pretty portable.
I tried to get gpc to work under Cygwin, but my HelloWorld (hello.pas) won't compile. It complains the file "as" were missing, but i don't know where to start. It seems that one needs a Gnu C Compiler in order to check out the pascal one
P2C may not work because janE6502 makes heavy use of "sets" which are a very pascal-like feature. To my limited knowledge, C doesnt have sets. possibly you might want to translate them manually into structs, arrays (preferred) or something alike.
I tried more than hundred,but it was tedious work. Some of Wolfgang's tests are very C64-specific. BRK for example, doesnt work properly. And every test program has to be invoked manually, in direct mode via menu, because i didnt implement I/O trapping. None of the tests is able to load the next test via daisy chain; rather they complain a basic error (illegal quantity because of the floppy disk primary address "8") after each test because the Load command is missing. On the other hand, i saved almost 99% of code space , source and object code either.
Quote:
thanks for the pointer to Marc's ED64 site: that's a nice clear walkthrough of the construction of an emulator, with a free emulator as a bonus!
If you need an emulator which is able to detect time expensive loops and give control back to another program outside during waits, you might consider my program useful.
Code:
label_doomsday1; LDA PERIPHERAL_PORT
CMP #some_input_key
BNE doomsday
In such cases, e.g. El Dendo's program (and many other) would use up 100% CPU Load. But i needed such an "idle" feature because i wish to limit programming times for an EPROM with a timing base from outside the emulated 6502 system.