Post by TommyGoogI will attempt in future posts to detail the bootstrap for CiV and how it differs from DOS3.3 (1980) and from MyDiversi.DSK.
Conflict in Vietnam
To view the following diagram properly, use a mono-spaced font (such as Courier New), and change all the periods to spaces. Printing to your favorite dot matrix printer is optional.
This is a map of the initial CiV bootstrap code before it is modified, relocated to [DD00..FFFF], and "patched" further.
......(1).+------+
..........|.0800.|
.+-------<|......|...JMP.B700
.v........|.08FF.|
.v........+------+
.v
.v....(4).+------+
.v........|.8700.|<<<<<<<<<<+
.v........|......|..........^
.v.+<<<<<<|......|JMP.BFAA..^
.v.v......+.8900.+...(DD84).^
.v.v......|......|..........^
.v.v......|......|..........^
.v.v......|.91FF.|..........^
.v.v......+------+..........^
.v.v........................^
.v.v........................^
.v.v..(3).+------+..........^
.v.v......|.9B00.|<<<<<<+...^
.v.v......|......|......^...^
.v.v......|......|>>>>>>>>>>+..JMP.8700
.v.v......+.9D00.+......^
.v.+>>>>>>|......|......^
.v........|.B5FF.|......^
.v........+------+......^
.v......................^
.v....(2).+------+......^
.v........|.B600.|......^
.v........|......|......^
.+>>>>>>>>+.B700.+......^
..........|......|>>>>>>+..JMP.9B00
..........+.B800.+
..........|......|
..........|.BFFF.|
..........+------+
Track 0 Sector 0 (T0S0) is loaded to 800. The code and data from 800 to 85C, and the bytes at 8FD to 8FF are identical a slave disk initialized using DOS3.3 (1980). From 85D to 8FC a DOS disk has random unused bytes, but CiV (or DiversiDos) uses this space for some of its code after T0S0 is read into [B600..B6FF] and later relocated to [F600..F6FF].
There are 2 versions of DOS3.3. One was released by Apple in 1980 and the other in 1983. The 1983 version has a few "bug fixes" to it as documented in Beneath Apple Dos (p. 2-4, p. 7-4, and 8-41). CiV is based on a version of DOS3.3 that was modified by DiversiDos and then likely modified some more (copy protection scheme etc.) The DOS3.3 (1983) "bug fixes" do not appear on the CiV disk, so it would seem Dos3.3 (1980) was a likely starting point.
CiV is a slave disk because the next part of the bootstrap code is loaded directly to B600. From track 0, sectors 0 to 9 are loaded to B600..BFFF. Once the 800 code has completed it's task, it JMPs to B700.
The code from B700 to BFFF is nearly identical to DOS3.3.
DIFFERENCES IN CODE FROM B600 TO BFFF
=====================================
[B600..B6FF]
As mentioned earlier, [B600..B6FF] is a copy of T0S0.
[B738]
At B738 is JSR B793 (BOOTIO) to read the next bunch of sectors from disk. This loads [T0SA..T2S4] into memory at [9B00..B5FF].
--For a DOS3.3 master boot, [9B00..9CFF] is not loaded with anything.
--For a DOS3.3 slave boot, [9B00..9CFF] is loaded from [T0SA..T0SB] which is all zeros.
--For a CiV boot, [9B00..9CFF] is loaded with DiversiDos bootstrap code.
[B747]
At B747 in DOS is JMP 9D84 (DBINIT DOS BASIC INTERPRETER - INITIAL ENTRY).
At B747 in CiV is JMP 9B00 to execute DiversiDos setup code.
An interesting note about this JMP 9B00 is that at 9B00 the code self-modifies this jump at B747 "back" to JMP 9D84. They apparently only want to enter this DiversiDos code once during bootstrap, and if for any reason they come back to B747 they want to then proceed with the normal bootstrap code. The DiversiDos execution path at 9B00 eventually rejoins this main path of code at 9D84, but by then 9D84 has relocated to DD84 so the JMP is actually to DD84.
[B7EB]
The RWTS IOB table begins at B7E8. B7EB is the expected Volume #.
--For DOS, B7EB is $FE
--For CiV, B7EB is $00 (match any).
B7EB is not altered before the call to BOOTIO (B793).
After the call to BOOTIO, DOS and CiV both set $B7EB to #$FF which is an invalid Volume number.
[B7F5]
$B7F5 in the RWTS IOB is the return error code.
--For DOS, its initial value is $EB.
--For CiV, its initial value is $03.
Since this value is set or cleared(?) by calling RWTS, the difference is insignificant.
[BA05]
BA05 is in MSWAIT which begins at BA00.
--For DOS this is INC $4E.
--For CiV this is INC $46.
DOS3.3 has this:
BA00: A2 11 LDX #$11
BA02: CA DEX
BA03: D0 FD BNE BA02
BA05: E6 46 INC $46
BA07: D0 02 BNE BA0B
BA09: E6 47 INC $47
CiV has this:
BA00: A2 11 LDX #$11
BA02: CA DEX
BA03: D0 FD BNE BA02
BA05: E6 46 INC $4E ***** 4E *****
BA07: D0 02 BNE BA0B
BA09: E6 47 INC $47
This sequence also shows up at BDA3 with the same difference. DiversiDos makes this change when applying DiversiDos to a disk.
The AUTOSTART ROM listing defines 4E/4F as RNDL and RNDH, and 47 as YREG.
The DOS3.3 listing defines 46/47 as MONTIMEL/MONTIMEH (Motion on time counters).
[BA69..BA95]
--DOS3.3 (1980) has random garbage here.
--DOS3.3 (1983) has the "Append Bug Patch".
--CiV has code.
[BB02..BB22] and
[BBDF..BC22]
The NYBBLE buffers reside here [$BB00..BC55].
There is no significance to these being different between DOS and CiV.
[BCDF..BCFF]
--For DOS, this is "padding" containing random garbage.
--For CiV, there is code here.
There is no significance to these being different between DOS and CiV.
[BDA3]
--For DOS, uses $46 as noted under BA05 change.
--For CiV, uses $4E as noted under BA05 change.
[BED2..BFA5]
--For DOS, use $45 as the NSYNC zero page location.
--For CiV, use $46 as the NSYNC zero page location.
[BEAF..BF0C] "Disk Format"
[BF0D..BF1B] "Write Track Subroutine"
[BF29..BFA7] "Verify Routine"
The only differences in this range of code is the use of $46 instead of $45 as the zero page location.
DOS defines NSYNC as $45.
Monitor code defines A5H and ACC as $45.
Monitor code defines XREG as $46.
I'm not sure why the code from BED2 to BFA5 uses $46 instead of $45 for the zero page location of NSYNC.
Next up will be the code at 9B00.
If anyone thinks this is useful posting this to CSA2 let me know.
Tommy