Good emulator for debugging RWTS code?

5 posts / 0 new
Last post
Last seen: 10 months 3 weeks 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
Last seen: 1 day 4 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 428
Maybe ask on USENET

 comp.emulators.apple2 comp.sys.apple2


Epple-II is cycle accurate, but I don't see any accessible debugger.


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's picture
Last seen: 4 hours 37 min ago
Joined: Aug 9 2022 - 00:48
Posts: 954
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
Last seen: 1 day 4 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 428
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:


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


Last seen: 4 hours 25 min ago
Joined: Apr 1 2020 - 16:46
Posts: 808
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:


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:


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