view level2/modules/boot_1773.asm @ 1172:5b3671305159

STEP is now set, not equ
author boisy
date Wed, 21 May 2003 13:45:29 +0000
parents a3d0ac951684
children bdd2f61d5dbc
line wrap: on
line source

********************************************************************
* Boot - WD1773 Boot module
*
* $Id$
*
* Ed.    Comments                                       Who YY/MM/DD
* ------------------------------------------------------------------
*   4    Original Tandy distribution version
*   6    Obtained from L2 Upgrade archive, has 6ms step BGP 98/10/12
*        rate and disk timeout changes
*   6r2  Added '.' output for each sector under NitrOS9 BGP 03/05/18
*        for Mark Marlette (a special request :)

         nam   Boot
         ttl   WD1773 Boot module

         ifp1
         use   defsfile
         endc

* Step Rate:
*      $00  = 6ms
*      $01  =
*      $02  =
*      $03  = 30ms
STEP     set   $00

tylg     set   Systm+Objct
atrv     set   ReEnt+rev
rev      set   $02
edition  set   6

         mod   eom,name,tylg,atrv,start,size

u0000    rmb   2
u0002    rmb   2
u0004    rmb   1
u0005    rmb   1
u0006    rmb   1
u0007    rmb   1
u0008    rmb   1
u0009    rmb   1
size     equ   .

name     fcs   /Boot/
         fcb   edition

start    clra			clear A
         ldb   #size		get our 'stack' size
L0015    pshs  a		save 0 on stack
         decb			and continue...
         bne   L0015		until we've created our stack
         tfr   s,u		put 'stack statics' in U
         ldx   #$FF48
         lda   #$D0
         sta   ,x
         lbsr  L01AA
         lda   ,x
         lda   #$FF
         sta   u0004,u
         leax  >NMIRtn,pcr
         stx   <D.NMI
         lda   #$09
         sta   >$FF40
         ldd   #$C350
         IFNE  NitrOS9
         nop
         ENDC
L003A    nop
         nop
         IFNE  NitrOS9
         nop
         nop
         nop
         ENDC
         subd  #$0001
         bne   L003A
         pshs  u,y,x,b,a
         ldd   #$0001
         os9   F$SRqMem
         bcs   L00AA
         tfr   u,d
         ldu   $06,s
         std   u0002,u
         clrb
         ldx   #$0000
         bsr   ReadSect
         bcs   L00AA
         ldd   $01,y
         std   u0007,u
         lda   <$10,y
         sta   u0005,u
         anda  #$01
         sta   u0008,u
         lda   $03,y
         sta   u0006,u
         ldd   <$18,y
         std   ,s
         ldx   <$16,y
         pshs  x
         ldd   #256
         ldu   u0002,u
         os9   F$SRtMem
         ldd   $02,s
         os9   F$BtMem
         puls  x
         bcs   L00AA
         stu   $02,s
         ldu   $06,s
         ldd   $02,s
         std   u0002,u
         ldd   ,s
         beq   L00A3
L0091    pshs  x,b,a
         clrb
         bsr   ReadSect
         bcs   L00A8

         IFNE  NitrOS9
         lda   #'.		dump out a period for boot debugging
         jsr   <D.BtBug		do the debug stuff     
         ENDC

         puls  x,b,a
         inc   u0002,u
         leax  1,x
         subd  #256
         bhi   L0091
L00A3    clrb
         puls  b,a
         bra   L00AC
L00A8    leas  $04,s
L00AA    leas  $02,s
L00AC    sta   >$FFD9		unnecessary - rel does this for us
         puls  u,y,x
         leas  size,s		clean up stack
         clr   >$FF40		shut off floppy disk
         rts

L00B7    lda   #$29
         sta   ,u
         clr   u0004,u
         lda   #$05
         lbsr  L0170
         ldb   #STEP
         lbra  L0195

* Read a sector from the 1773
* Entry: X = LSN to read
ReadSect lda   #$91
         cmpx  #$0000		LSN0?
         bne   L00DF
         bsr   L00DF
         bcs   L00D6
         ldy   u0002,u
         clrb
L00D6    rts
L00D7    bcc   L00DF
         pshs  x,b,a
         bsr   L00B7
         puls  x,b,a
L00DF    pshs  x,b,a
         bsr   L00EA
         puls  x,b,a
         bcc   L00D6
         lsra
         bne   L00D7
L00EA    bsr   L013C
         bcs   L00D6
         ldx   u0002,u
         orcc  #IntMasks
         pshs  y
         ldy   #$FFFF
         ldb   #$80
         stb   >$FF48
         ldb   ,u
         orb   #$30
         tst   u0009,u
         beq   L0107
         orb   #$40
L0107    stb   >$FF40
         lbsr  L01AA
         orb   #$80
         lda   #$02
L0111    bita  >$FF48
         bne   L0123
         leay  -$01,y
         bne   L0111
         lda   ,u
         sta   >$FF40
         puls  y
         bra   L0138
L0123    lda   >$FF4B
         sta   ,x+
         stb   >$FF40
         bra   L0123

NMIRtn   leas  R$Size,s
         puls  y
         ldb   >$FF48
         bitb  #$04
         beq   L018F
L0138    comb
         ldb   #E$Read
         rts
L013C    lda   #$09
         sta   ,u
         clr   u0009,u
         tfr   x,d
         cmpd  #$0000
         beq   L016C
         clr   ,-s
         tst   u0008,u
         beq   L0162
         bra   L0158
L0152    com   u0009,u
         bne   L0158
         inc   ,s
L0158    subb  u0006,u
         sbca  #$00
         bcc   L0152
         bra   L0168
L0160    inc   ,s
L0162    subb  u0006,u
         sbca  #$00
         bcc   L0160
L0168    addb  #$12
         puls  a
L016C    incb
         stb   >$FF4A
L0170    ldb   u0004,u
         stb   >$FF49
         cmpa  u0004,u
         beq   L018D
         sta   u0004,u
         sta   >$FF4B
         ldb   #$10+STEP
         bsr   L0195
         pshs  x
         ldx   #$222E
L0187    leax  -$01,x
         bne   L0187
         puls  x
L018D    clrb
         rts
L018F    bitb  #$98
         bne   L0138
         clrb
         rts
L0195    bsr   L01A8
L0197    ldb   >$FF48
         bitb  #$01
         bne   L0197
         rts
L019F    lda   ,u
         sta   >$FF40
         stb   >$FF48
         rts
L01A8 
         IFNE  NitrOS9
         nop
         ENDC
         bsr   L019F
L01AA  
         IFNE  NitrOS9
         nop
         nop
         ENDC
         lbsr  L01AD
L01AD 
         IFNE  NitrOS9
         nop
         nop
         ENDC
         lbsr  L01B0
L01B0 
         IFNE  NitrOS9
         nop
         ENDC
         rts

* Filler to get $1D0
Filler    fill  $39,$1D0-3-*

         emod
eom      equ   *
         end