Kernel 0.94

This commit is contained in:
Rémy GIBERT 2020-05-12 17:17:25 +02:00
parent 541d9679b4
commit c500a3bdad
8 changed files with 278 additions and 241 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -316,7 +316,7 @@ CS.RUN.LL.DISKII
stz CurTrack
lda #160
lda #162
sta CurQTrack
ldx #0

View File

@ -8,81 +8,90 @@ NEW
* disk(ette). if booted in apple /// native mode, the regular
* sos boot will be attempted.
*--------------------------------------
dcmd .EQ $42 disk command (=1 for read)
unit .EQ $43 (16*slot)+(128*(drive-1))
buff .EQ $44 ram address
blok .EQ $46 disk address
dent .EQ $48 device call entry address.
idxl .EQ $4a pointer to low page of index block
idxh .EQ $4c pointer to high page of index block
idxp .EQ $4e index byte pointer.
iobuff .EQ $60
* the following are for disk ii only:
dbuf .EQ $26
slotz .EQ $2b
oddbits .EQ $3c
sector .EQ $3d
trktmp .EQ $40
track .EQ $41
prior .EQ $50
trkn .EQ $51
rtrycnt .EQ $52
curtrk .EQ $53
trkcnt .EQ $54
*
q6l .EQ $c08c
motoron .EQ $c089
motoroff .EQ $c088
phaseoff .EQ $c080
nbuf1 .EQ $300
dnib .EQ $2d6
* directory dependent stuff...
clrscrn .EQ $fc58
scrn .EQ $5ae
dostyp .EQ $ff
sosid .EQ $c00
entlen .EQ sosid+$23
kernel .EQ $2000
dcmd .EQ $42 disk command (=1 for read)
unit .EQ $43 (16*slot)+(128*(drive-1))
buff .EQ $44 ram address
blok .EQ $46 disk address
dent .EQ $48 device call entry address
idxl .EQ $4a pointer to low page of index block
idxh .EQ $4c pointer to high page of index block
idxp .EQ $4e index byte pointer
iobuff .EQ $60
* the following are for disk ii only
dbuf .EQ $26
slotz .EQ $2b
oddbits .EQ $3c
sector .EQ $3d
BB.HdrPtr .EQ $3f
BB.TargetTrk .EQ $41
BB.TargetQTrk .EQ $51
rtrycnt .EQ $52
BB.CurQTrk .EQ $53
BB.Hdr .EQ $54
BB.HdrTrk .EQ $55
BB.HdrVol .EQ $56
BB.Hdr96 .EQ $57
nbuf1 .EQ $300
dnib .EQ $2d6
clrscrn .EQ $fc58
scrn .EQ $5b6
sosid .EQ $c00
entlen .EQ sosid+$23
kernel .EQ $2000
*--------------------------------------
.PH $800
xboot .DA #1
entry sec apple iii enters xboot 'ora $38'
bcs entry1 branch if not apple iii native mode.
jmp goapl3 go do apple iii boot!
bcs entry1 branch if not apple iii native mode
*--------------------------------------
lda #$9f make apple iii boot using block 1
pha the return address is $a000
lda #$ff
pha
entry1 stx unit save unit number.
cmp #$03 for disk ii.
php save result, it may be irrelevent.
txa find out if disk ii.
and #$70 strip drive # if any.
lda #1 read block 1
ldx #0
jmp $f479
*--------------------------------------
entry1 stx unit save unit number
cmp #$03 for disk ii
php save result, it may be irrelevant
txa find out if disk ii
and #$70 strip drive # if any
lsr
lsr get slot address
lsr
lsr
lsr get slot address.
lsr
lsr
ora #$c0
sta dent+1
ldy #$ff look at last byte.
sta dent+1
ldy #$ff look at last byte
sty dent
plp restore carry (if disk ii & sect 0&2 read).
plp restore carry (if disk ii & sect 0&2 read)
iny make y=0
lda (dent),y get device entry addr.
bne ndsk2 branch if not disk ii (16 sector).
bcs isdsk2 branch if it is disk ii, but block 0 read.
lda #3 make rom read only sector 2
sta xboot to complete block 0
iny make y=0
lda (dent),y get device entry addr
bne ndsk2 branch if not disk ii (16 sector)
bcs isdsk2 branch if it is disk ii, but block 0 read
lda #3 make rom read only sector 2
sta xboot to complete block 0
inc sector was = 1
lda dent+1 do rts to re-enter rom.
pha
lda dent+1 do rts to re-enter rom
pha
lda #$5b
pha
rts go read sector 2 into $900
*--------------------------------------
isdsk2 sta trktmp make sure previous track =0
isdsk2 sta BB.HdrTrk A=0, make sure previous track =0
sta dent and dent points at beginning of slot
ldy #$63 move code from card to ram
mvboot lda (dent),y
@ -91,19 +100,28 @@ mvboot lda (dent),y
cpy #$eb have we moved enough?
bne mvboot
ldx #6 now modify code to handle errors.
ldx #9 now modify code to handle errors.
modboot ldy mods,x
lda chgs,x
sta zzstart,y
lda endcode,x
sta zzzend,x
dex
bpl modboot
ldx #7
modboot2 lda endcode-1,x
sta zzzend-1,x
dex
bne modboot2
lda #<d2io reset device entry
stx BB.HdrPtr+1
lda #BB.Hdr
sta BB.HdrPtr
lda /d2io reset device entry
sta dent+1 to point at disk ii routines.
lda #>d2io get low addr (must be <$80)
lda #d2io get low addr (must be <$80)
ndsk2 ldy #0 make sure y=0 again.
cmp #$f9
@ -116,7 +134,7 @@ ndsk2 ldy #0 make sure y=0 again.
sty idxp
sty blok+1
iny
sty dcmd ;set read command.
sty dcmd set read command.
iny
sty blok to read directory blocks
lda #$c 2-5 at $c00
@ -152,30 +170,28 @@ nxdent1 clc
bcs nxdent2
cmp #$a have all file names been compared?
beq nopro branch if no pro.kernel.
beq booterr branch if no pro.kernel.
ldy #4 else, begin at block beginning.
nxdent2 sty idxl note: this method treats garbage at
lda sysname the end of the dir block as an entry.
and #$f get target name length.
tay
ldy #0
lda (idxl),y
cmp #$26 $20 = storage type + 6 = "PRODOS" len
bne nxdent branch if no match.
ldy #6
lookpro lda (idxl),y look for matching name.
cmp sysname,y last to first method.
cmp BB.ProDOS-1,y last to first method.
bne nxdent branch if no match.
dey else check all characters.
bpl lookpro including length/storage type.
and #$f0 make sure storage type is a tree!
cmp #$20
bne booterr branch if not.
bne lookpro
ldy #$10 get file type & index block addr.
lda (idxl),y
cmp #dostyp is it a system file?
cmp #S.FI.T.SYS is it a system file?
bne booterr
iny
@ -183,10 +199,11 @@ lookpro lda (idxl),y look for matching name.
sta blok
iny
lda (idxl),y
sta blok+1
lda #0 now set up to read kernel.
sta idxl
ldy #$1e read index block at $1e00 and
sty idxl+1 kernel at $2000
sty iobuff+1
@ -198,6 +215,7 @@ bterr2 bcs booterr
inc iobuff+1
inc iobuff+1
ldy idxp get index pointer
inc idxp bump for next time.
lda (idxl),y
@ -208,72 +226,35 @@ bterr2 bcs booterr
bne rdkernl branch if more to read.
jmp kernel go execute kernel code.
*--------------------------------------
booterr jsr clrscrn clear video
ldy #BB.MSG.NoProDOS.Len-1
nopro .EQ *
booterr .EQ *
jmp quitmes
sysname .DA #$26
.AS "prodos "
.1 lda BB.MSG.NoProDOS,y
sta scrn,y
dey
bpl .1
bmi *
*--------------------------------------
goread lda iobuff
sta buff
lda iobuff+1
sta buff+1
jmp (dent)
*
mods .DA mod1,mod2,mod3,mod4,mod5,mod6,mod7
chgs .DA chg1,chg2,chg3,chg4,chg5,chg6,chg7
endcode .EQ *
*--------------------------------------
ldx slotz
mods .DA #mod1,#mod2,#mod3,#mod4,#mod5,#mod6,#mod7,#mod8,#mod8+1,#mod9
chgs .DA #chg1,#chg2,#chg3,#chg4,#chg5,#chg6,#chg7,#$91,#BB.HdrPtr,#BB.HdrTrk
endcode ldx slotz
clc
rts
jmp seek
*--------------------------------------
goapl3 .EQ *+$9800
lda #$9f make apple iii boot using block 1.
pha the return address is $a000
lda #$ff
pha
lda #1 read block 1.
ldx #0
jmp $f479
*--------------------------------------
quitmes jsr clrscrn clear video.
ldy #meslen print message centered on screen.
prmess lda errmess,y
sta scrn,y
dey
bpl prmess
hang jmp hang
meslen .EQ 28
errmess .AS -"*** unable to load prodos ***"
setphase lda curtrk get current track
clrphase and #3 mask for 1 of 4 phases
rol double for phaseon/off index
ora slotz
tax
lda phaseoff,x turn on/off one phase
lda #$2c
*--------------------------------------
mswait ldx #$11
msw1 dex delay 86 usec.
bne msw1
sbc #$1 done 'n' intervals?
bne mswait a-reg counts
ldx slotz restore x-reg
rts
BB.MSG.NoProDOS .AS -"ERROR"
BB.MSG.NoProDOS.Len .EQ *-BB.MSG.NoProDOS
BB.ProDOS .AS "PRODOS"
*--------------------------------------
d2io lda blok figure out track & sector.
and #7 strip track for now.
@ -284,61 +265,114 @@ d2io lda blok figure out track & sector.
plp
rol now we have the first sector of block.
sta sector
lda blok+1 get high block #
lsr shift hi addr to carry.
lda blok now figure track #
ror
lsr
lsr
sta track
asl
sta trkn
sta BB.TargetTrk
jsr BB.Trk2Qtrk
sta BB.TargetQTrk
lda buff+1
sta dbuf+1
sta dbuf+1
ldx slotz
lda motoron,x
lda IO.D2.DrvOn,x
jsr rdsector go read sector.
inc dbuf+1 bump address
inc sector
inc sector and sector #
bcs quitrd branch if error.
jsr rdsector
quitrd ldy motoroff,x
quitrd ldy IO.D2.DrvOff,x
erretrn rts return error status in carry.
*
*--------------------------------------
rdsector .EQ * do seek then read sector.
*
seek lda trktmp get track we're on.
seek lda BB.HdrTrk get track we're on
jsr BB.Trk2Qtrk
asl
sta curtrk
lda #$0
sta trkcnt halftrack count.
sta BB.CurQTrk
seek2 lda curtrk save curtrk for
sta prior delayed turnoff.
sec
sbc trkn delta-tracks.
beq seekend br if curtrk=destination
.1 lda BB.CurQTrk
cmp BB.TargetQTrk
beq seekend
bcs out move out, not in
bcs .2 move out, not in
inc curtrk incr current track (in).
bcc skin (always taken)
inc
out dec curtrk decr current track (out).
skin sec
step2 jsr setphase
lda prior
clc for phaseoff
jsr clrphase de-energize previous phase.
bne seek2 (always taken)
.HS B0 BCS
.2 dec
seekend .EQ *
sta BB.CurQTrk
jsr BB.PhaseOn
rdsect1 ldy #$7f allow 127 mistakes.
lda #30
jsr BB.MSWait Trash X
ldx slotz
lda IO.D2.Ph0Off,x
lda IO.D2.Ph1Off,x
lda IO.D2.Ph2Off,x
lda IO.D2.Ph3Off,x
lda #10
jsr BB.MSWait Trash X
beq .1 (always taken)
*--------------------------------------
BB.PhaseOn pha
jsr .7
pla
bit #1 1,3,5,7 ?
beq .8
inc
.7 and #6 mask for 0,2,4,6
ora slotz Slot $n0
tax
lda IO.D2.Ph0On,x turn on one phase
.8 rts
*--------------------------------------
BB.MSWait sec (6) JSR (2)
.1 ldx #15 (2)
.2 dex (2) delay 81 usec.
bne .2 (2+) 5x15 + 4 + 2
sbc #$1 (2) done 'n' intervals?
bne .1 (2+) a-reg counts
rts (6)
*--------------------------------------
BB.Trk2Qtrk asl x2
sta .1+1
bit BB.HdrVol
bmi .1 x4
lsr x3
.1 adc #$ff SELF MODIFIED
rts
*--------------------------------------
seekend ldx slotz
ldy #$7f allow 127 mistakes.
sty rtrycnt
php
@ -352,30 +386,29 @@ rddata php carry set if reading sector.
rd0 dey every time y=0 decrement find count.
beq tryread
zzstart .EQ *
*--------------------------------------
* from zzstart to zzend code is moved from rom and modified to match this code...
*--------------------------------------
zzstart .EQ *
rd1 lda q6l,x read a byet from the state machine.
bpl rd1 loop until ready.
dsect
org zzstart+5 equivalent to org *
rd1 lda IO.D2.RData,x read a byte from the state machine.
bpl rd1 loop until ready.
.DUMMY
rd1a eor #$d5 mark 1?
mod1 .EQ *-zzstart+1
bne rd0 branch if not.
chg1 .EQ rd0-*
rd2 lda q6l,x
rd2 lda IO.D2.RData,x
bpl rd2
cmp #$aa mark 2?
bne rd1a
nop waste a little time.
rd3 lda q6l,x
rd3 lda IO.D2.RData,x
bpl rd3
cmp #$96 header mark 3?
@ -392,17 +425,20 @@ chg2 .EQ rdhead-*
mod3 .EQ *-zzstart+1
rdhd0 bne rdhead otherwise, start over.
chg3 .EQ rdhead-*
chg3 .EQ rdhead-*
rdhd1 ldy #3 read in trk,sect,&volume #.
rdhd2 sta trktmp save last result in temp
rdhd3 lda q6l,x
mod8 .EQ *-zzstart
rdhd2 sta (BB.HdrPtr),y save last result in .. , BB.HdrTrk , BB.HdrVol , ..
rdhd3 lda IO.D2.RData,x
bpl rdhd3
rol
sta oddbits save odd bits (7,5,3,1)
rdhd4 lda q6l,x
rdhd4 lda IO.D2.RData,x
bpl rdhd4
and oddbits combine even and odd to form value.
@ -417,20 +453,22 @@ mod4 .EQ *-zzstart+1
chg4 .EQ rdhead-*
lda trktmp previous result is track #
cmp track is desired track found?
mod9 .EQ *-zzstart+1
lda BB.HdrTrk previous result is track #
cmp BB.TargetTrk is desired track found?
mod5 .EQ *-zzstart+1
bne goseek re-seek if mismatch.
chg5a .EQ *
mod6 .EQ *-zzstart+1
bcs rddata branch if proper track always.
chg6 .EQ rddata-*
*--------------------------------------
rddt1 ldy #$56 read 2 bit groupings first.
rddt1a sty oddbits
rddt2 ldy q6l,x
rddt2 ldy IO.D2.RData,x
bpl rddt2
eor dnib,y denibblize using table left from boot rom.
@ -441,7 +479,7 @@ rddt2 ldy q6l,x
rddt3 sty oddbits now count up for 6-bit groups.
rddt4 ldy q6l,x
rddt4 ldy IO.D2.RData,x
bpl rddt4
eor dnib,y
@ -450,7 +488,7 @@ rddt4 ldy q6l,x
iny
bne rddt3 loop for 256 bytes.
rdchk ldy q6l,x now verify checksum...
rdchk ldy IO.D2.RData,x now verify checksum...
bpl rdchk
eor dnib,y must be equal...
@ -465,23 +503,28 @@ nxttwo ldx #$56 now combine 2-bit group with 6 bit group
twobit dex all done with this group?
bmi nxttwo branch if so.
lda (dbuf),y
lda (dbuf),y
lsr nbuf1,x
rol
lsr nbuf1,x
rol
sta (dbuf),y
sta (dbuf),y
iny
bne twobit
zzzend .EQ *
ldx slotz
*--------------------------------------
zzzend ldx slotz
clc indicate good read.
rts
chg5 .EQ *-chg5a
goseek jmp seek
dend .BS $a00-zzstart-5,0
chg5 .EQ *-chg5a
goseek jmp seek
.ED
*--------------------------------------
.LIST ON
BB.End .EQ *
BB.Free .EQ $a00-*
.BS BB.Free
.LIST OFF
.EP
*--------------------------------------
MAN

View File

@ -28,36 +28,35 @@ D2MoveHead >PULLB MoveTo
jsr CheckDiskII
bcs .9
.1 lda MoveTo
cmp MoveFrom
.1 lda MoveFrom
cmp MoveTo
beq .8
bcc .2
bcs .2
* sec
lda #0 MoveFrom>MoveTo, must move in
bra .3
inc MoveFrom>MoveTo, must move in
.HS B0 BCS
.2 lda #$ff MoveFrom<MoveTo, must move out
.2 dec MoveFrom<MoveTo, must move out
.3 adc MoveFrom
sta MoveFrom
sta MoveFrom
jsr XRW.PhaseOn
jsr D2.PhaseOn
lda #$30
jsr XRW.Wait100msA Trash X
lda #30
jsr D2.Wait100msA Trash X
jsr XRW.AllPhaseOff
jsr D2.AllPhaseOff
lda #$70
jsr XRW.Wait100msA Trash X
lda #10
jsr D2.Wait100msA Trash X
bra .1
.8 clc
.9 rts
*--------------------------------------
XRW.PhaseOn pha
D2.PhaseOn pha
jsr .7
pla
@ -72,26 +71,21 @@ XRW.PhaseOn pha
lda IO.D2.Ph0On,x turn on one phase
.8 rts
*--------------------------------------
XRW.AllPhaseOff ldx Slotn0
D2.AllPhaseOff ldx Slotn0
lda IO.D2.Ph0Off,x make sure all motor phases are off.
lda IO.D2.Ph1Off,x
lda IO.D2.Ph2Off,x
lda IO.D2.Ph3Off,x
rts
*--------------------------------------
XRW.Wait100msA
.1 ldx #$11 delay 86 usec
D2.Wait100msA sec
.1 ldx #15
.2 dex
bne .2
inc montimel
bne .3
inc montimeh
.3 sec
sbc #$01
sbc #1
bne .1
rts
@ -317,21 +311,21 @@ PutData stz Checksum
.3 lda (ZPPtr1),y
and #3
tax
lda XRW.XX000000,x
lda D2.XX000000,x
pha
lda (ZPPtr3),y
and #3
tax
pla
ora XRW.00XX0000,x
ora D2.00XX0000,x
pha
lda (ZPPtr4),y
and #3
tax
pla
ora XRW.0000XX00,x
ora D2.0000XX00,x
eor Checksum
sta Checksum

View File

@ -67,6 +67,7 @@ CS.START cld
.DA D2TrkWriteNIB
L.TrkWriter .DA TrkWriter
L.ProDOS.Boot .DA ProDOS.Boot
L.ProDOSFX.Boot .DA ProDOSFX.Boot
.DA 0
*--------------------------------------
LIB.LOAD
@ -145,7 +146,7 @@ BuildProDOSCat >PULLW ZPPtr1 DstBuf
bpl .1
* Blk 0 : ProDOS Boot Code
>LDYA L.ProDOS.Boot
>LDYA L.ProDOSFX.Boot
>STYA ZPPtr3
ldy #0
@ -387,7 +388,7 @@ Nib2FC .HS 0004
.HS 080C
.HS FF
.HS 101418
XRW.XX000000 .HS 008040C0FFFF used in fast prenib as lookup for 2-bit quantities.
D2.XX000000 .HS 008040C0FFFF used in fast prenib as lookup for 2-bit quantities.
.HS 1C20
.HS FFFFFF
.HS 24282C3034
@ -395,7 +396,7 @@ XRW.XX000000 .HS 008040C0FFFF used in fast prenib as lookup for 2-bit quantitie
.HS 383C4044484C
.HS FF
.HS 5054585C606468
XRW.00XX0000 .HS 00201030 used in fast prenib.
D2.00XX0000 .HS 00201030 used in fast prenib.
endmrks .HS DEAAEB table using 'unused' nibbles ($C4,$C5,$C6,$C7)
.HS FFFFFFFF
.HS 6C
@ -407,7 +408,7 @@ endmrks .HS DEAAEB table using 'unused' nibbles ($C4,$C5,$C6,$C7)
.HS 8084
.HS FF
.HS 888C9094989CA0
XRW.0000XX00 .HS 0008040C used in fast prenib.
D2.0000XX00 .HS 0008040C used in fast prenib.
.HS FF
.HS A4A8AC
.HS FF
@ -520,6 +521,8 @@ ProDOS.Boot .HS 01.38.b0.03.4c.32.a1.86.43.c9.03.08.8a.29.70.4a
.HS d0.e3.a0.7f.84.52.08.28.38.c6.52.f0.ce.18.08.88
.HS f0.f5.bd.8c.c0.10.fb.00.00.00.00.00.00.00.00.00
*--------------------------------------
ProDOSFX.Boot .INB USR/SRC/LIB/LIBBLKDEV.S.BB
*--------------------------------------
* Block 2 : First DIR block
*--------------------------------------
VolDirHdr
@ -555,8 +558,6 @@ TrkNum .BS 1
VolNum .BS 1
MotorOn .BS 1
montimel .BS 1
montimeh .BS 1
Count .BS 2
*--------------------------------------

View File

@ -552,8 +552,9 @@ wnibl sta IO.D2.WLoad,x (5) nibl write
*--------------------------------------
XRW.Wait100ms lda #1
XRW.Wait100msA
.1 ldx #$11 delay 86 usec
XRW.Wait100msA sec
.1 ldx #13
.2 dex
bne .2
@ -563,8 +564,7 @@ XRW.Wait100msA
inc montimeh
.3 sec
sbc #$01
.3 sbc #$01
bne .1
rts
@ -740,29 +740,28 @@ XRW.Seek ldx XRW.UnitIndex
sta XRW.CurrentTrack will be current track at the end
sta XRW.D2Trk-1,x
.1 lda XRW.TargetQTrack
cmp XRW.CurrentQTrack
.1 lda XRW.CurrentQTrack
cmp XRW.TargetQTrack
beq .8
bcc .2
bcs .2
* sec
lda #0 CurrentQTrack>TargetQTrack, must move in
bra .3
inc CurrentQTrack>TargetQTrack, must move in
.2 lda #$ff CurrentQTrack<TargetQTrack, must move out
.HS B0 BCS
.2 dec CurrentQTrack<TargetQTrack, must move out
.3 adc XRW.CurrentQTrack
sta XRW.CurrentQTrack
sta XRW.CurrentQTrack
jsr XRW.PhaseOn
lda #$30
lda #30
jsr XRW.Wait100msA Trash X
jsr XRW.AllPhaseOff
lda #$70
lda #10
jsr XRW.Wait100msA Trash X
bra .1