Re: Help neede - "?SYNTAX ERROR" problem in my C64 emulator
- From: Polaris <polaris@xxxxxxxxxxxxx>
- Date: Mon, 19 Jun 2006 20:57:14 +0100
Hello all,
Thanks very much for all your help - I have now solved the problem.
The problem was down to my implementation of the BIT op-codes. I had mis-read the Programmers Reference Guide and set the N and V flags *after* performing the A^M operation! I haven't checked the BASIC routine responsible for scanning the keyboard buffer yet, but I'd wager that it uses a BIT operation in there somewhere!
Regarding the Emulator Test Suite, thanks for telling me about it. I hadn't seen this before - it looks extremely useful. I thought I had tested my CPU core thoroughly, but I obviously hadn't. This suite will definitely help me out in the future. Are there any similar suites available for other emulators (especially ZX Spectrum, Amstrad CPC and NES) as after this emulator I would like to try another?
Anyway, many thanks to everybody for your very helpful advice.
Kind regards,
Simon
David Horrocks wrote:
Hi.
Don't bother trying to dissect what BASIC is doing. You have a bug with the CPU and/or memory bank emulation. You will need Wolfgang Lorenz emulator test suite. The latest version is v2.15 and is in D64 format. You will most likely want to use something like Star Commander to extract the files as *.prg so you can load these hybrid BASIC / Machine Code programs. If you load the *.prg file like a memory snapshot then you will need to set the zero page BASIC memory pointers before you can run the test. The test suite requires that a minimum set of "basic" CPU instructions do work. If you pass the "basic" CPU check then the test suite will scrutinise every instruction and report its finding. You will need to scrutinise your CPU and memory emulation in order to pass the "basic" CPU check. Pay attention to the following common bugs.
1) Check instructions that affect the stack and stack pointer; like JSR RTS RTI IRQ PLA PHA etc. Note that JSR pushes the stack in a different manner to IRQ. And RTS pops the stack in a different manner to RTI.
2) Check the setting of CPU flags after instructions execute. e.g. INC does not affect the carry flag but ADC does affect the carry flag.
3) Check that you handle the CPU port registers $0000 and $0001 correctly and that the correct RAM or ROM or I/O is switched in.
4) Check that your stack pointer moves correctly and wraps arround addresses $01FF - $0100.
5) Check that ADC and SBC respond to the decimal mode flag. The test suite does not require this for its "basic" check but it will report its findings.
Hope this helps:-)
Regards
David
"Polaris" <polaris@xxxxxxxxxxxxx> wrote in message news:449582de@xxxxxxxxxxxxxxxx
Hello all,
I have been writing a C64 emulator in C for a while now. I have just implemented the keyboard handler (via the 0xDC00 and 0xDC01 registers on CIA1). Anything I type on my host keyboard is displayed correctly by the emulator (I have checked all character codes etc in memory), however I am having a bit of a problem.
If I enter "RUN", I will get a ready prompt as expected. The same is also true for "LIST", "NEW", "PRINT" etc, but as soon as I enter a line like this: -
10 PRINT "HELLO"
I get: -
?SYNTAX ERROR
READY.
Also, anything like these: -
PRINT "HELLO"
PRINT"HELLO"
PRINT 1
PRINT1
10 FORN=1TO10
(etc.)
also give a "?SYNTAX ERROR".
I have not yet completed the emulator (there are still quite a few things that I have not implemented), however these lines *should* work as far as I can tell. This is my first attempt at writing an emulator so there might be something obvious that I am missing.
The keyboard handler works by saving the status of the host keyboard keys in a structure. I have written a function to return the value in memory address 0xDC01 based on a passed value for 0xDC00. This function looks at the 0xDC00 value (i.e. the keyboard column) and returns the 0xDC01 value based on the keys that are pressed in that column. This seems to work correctly as the correct characters are being displayed on the screen, so I can't understand why I am getting this problem. Might it be due to a part of the C64 that I haven't emulated yet?
Does anybody know what the problem could be, or does anybody have a suggestion as to how I could locate it? I can't really attach any code samples as I don't really know where the problem lies.
Any help would be greatly appreciated.
Kind regards,
Simon
- References:
- Help neede - "?SYNTAX ERROR" problem in my C64 emulator
- From: Polaris
- Re: Help neede - "?SYNTAX ERROR" problem in my C64 emulator
- From: David Horrocks
- Help neede - "?SYNTAX ERROR" problem in my C64 emulator
- Prev by Date: Re: gui4cbm4win updated to version 0.40 to accommodate to OpenCBM 0.4.0
- Next by Date: Re: gui4cbm4win updated to version 0.40 to accommodate to OpenCBM 0.4.0
- Previous by thread: Re: Help neede - "?SYNTAX ERROR" problem in my C64 emulator
- Index(es):
Relevant Pages
|
Loading