Good emulator for debugging RWTS code?

5 posts / 0 new
Last post
Offline
Last seen: 1 year 1 week ago
Joined: Apr 14 2023 - 19:08
Posts: 1
Good emulator for debugging RWTS code?

I'm doing a port of my 6502 CP/M to the Apple IIe. It needs its own custom RWTS code.

I have reads working, and writes are really tough --- there's some subtle point of timing that I'm getting wrong. I've counted cycles until my calculator bleeds. The problem is that I'm using MAME for development, and it gives me no feedback of the state of the disk shift registers during execution; and, I also don't know if it's tolerating erroneous code.

Can anyone suggest any useful tools for debugging this? What I'd really like is a cycle-accurate emulator which can show me exactly when I should be feeding data to the shift register, so that I can adjust my timing correctly. But at this point I'm open to any suggestions...

mmphosis's picture
Offline
Last seen: 1 day 20 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 433
Maybe ask on USENET

 comp.emulators.apple2 comp.sys.apple2

 

Epple-II is cycle accurate, but I don't see any accessible debugger. https://github.com/cmosher01/Epple-II/blob/main/src/Trace.cpp

 

I've been working on creating my own 6502 simulator but it's not an Apple II emulator and it probably has lots of bugs.

# 6502 --help

Usage: 6502 [OPTION] [START] [FILE] [END]

Simulate the 6502 cpu.

PC=hhhh     start of program (default is 0300)

A=hh        Accumulator

X=hh        X Index

Y=hh        Y Index

S=hh        Stack Pointer

P=hh        Processor Status

-c          Cycle count displayed.

-e          Examine registers.

-l          List disassembled instructions.

-m               Memory accesses displayed.

-d          Dump memory report.

-i          Report instructions used.

 

# printf L | 6502 -c -e -l -m -

                              A=AA X=00 Y=00 S=00 P=22 PC=0300  0

0300- 4C 00 00  JMP $0000     A=AA X=00 Y=00 S=00 P=22 PC=0000  3

0000- 00 00     BRK           PwrOff 0000- 0 0 0

 

 

CVT
CVT's picture
Offline
Last seen: 7 hours 26 min ago
Joined: Aug 9 2022 - 00:48
Posts: 1000
Why don't you just use

Why don't you just use AppleWin? It is cycle accurate and it has a debugger.

mmphosis's picture
Offline
Last seen: 1 day 20 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 433
AppleWIn and Virtual ][

 

AppleWin is cycle accurate for 6502, 65C02 and the Logic State Sequencer. The author of the debugger has some really good tips:

https://old.reddit.com/r/apple2/comments/12mxjw2/good_emulator_for_debugging_rwts_code/

 

Virtual ][ can show the processor cycle count at the start of each instruction:

https://www.virtualii.com/VirtualIIHelp/InspectorHelp/inspector_help.html

 

Offline
Last seen: 1 day 21 hours ago
Joined: Apr 1 2020 - 16:46
Posts: 875
Open Source RWTS code for Apple II:

 

I fully understand why "hjalfi" of post #1 wants to write his own RWTS code. Apple (the corporation) still owns the copyright to the original RWTS code which came with Apple DOS. I'm in the same boat here as I had to write my own RWTS for my Apple-1 disk contoller card, which is here:

 

https://www.applefritter.com/content/uncle-bernies-woz-machine-based-apple-1-floppy-disk-controller

 

My RWTS works on the Apple-1 but has different cycle count requirements, to compensate for the up to 4 DRAM refresh cycles stolen from its inner loops. So sorry, I can't help "hjafi" with my code. It only works with a Woz machine that has my "time flux compensator" GAL attached, the "TFC". Which automatically adjusts the loop cycle count to 32 (or normal disk nibbles) and to 40 (for SYNC disk nibbles). The timing of these must be perfect. Else, writing does not work or screws up an exisiting properly formatted floppy disk.

 

But here is something which might help you, "hjalfi":

 

Roland Gustafsson's RWTS18 source code  is available on github:

 

https://github.com/Michaelangel007/apple2_rwts18

 

I did not look into it to any greater extent but if it is not too close to the copyrighted code from Apple then it should be OK for you to use at least parts of the RWTS18 code. The timed  low level routines which read and write stuff from and to the Woz machine shift register must be the same (32 cycles or 40 cycles) so you can avoid the trouble with debugging your own code.

 

- Uncle Bernie

Log in or register to post comments