Classic Computer Magazine Archive PROGRAM LISTING: 89-07/MAKEBOOT.M65


0100 ; MAKEBOOT       (FOR OS/A+)
0110 ; BY BOB MARTIN
0120 ; (c)1989, ANTIC PUBLISHING INC.
0130 ; MAKE BOOT DISK FROM DOS FILE
0140 ;
0150 MEMTOP = $6A
0160 MEMLO = $02E7
0170 HATABS = $031A
0180 CH  =   $02FC
0190 CR  =   $00
0200 BUF1 =  $0500
0210 BUF2 =  $0600
0220 ;
0230 INBUFF = $F3
0240 CIX =   $F2
0250 LBUFF = $0580
0260 FR0 =   $D4
0270 FR1 =   $E0
0280 ICBAL = $0344
0290 ICBLL = $0348
0300 ICAX1 = $034A
0310 ICAX2 = $034B
0320 CIOV =  $E456
0330 ICCOM = $0342
0340 AFP =   $D800
0350 FASC =  $D8E6
0360 IFP =   $D9AA
0370 FPI =   $D9D2
0380 ;
0390 ; LOOK FOR AN EMPTY SPOT IN
0400 ; THE HANDLER ADDRESS TABLE
0410 ;
0420     *=  $7000
0430 ;
0440 INSERT
0450     LDX #0
0460 NEXTPLACE
0470     LDA HATABS,X
0480     BEQ ESPOT
0490     INX 
0500     INX 
0510     INX 
0520     BNE NEXTPLACE
0530     BEQ INSERT
0540 ;
0550 ;   FOUND AN EMPTY SPOT
0560 ;
0570 ESPOT
0580     LDA #$42
0590     STA HATABS,X
0600     LDA #BTAB&$FF
0610     STA HATABS+1,X
0620     LDA #BTAB/$0100
0630     STA HATABS+2,X
0640 ;
0650 ; FIND THE E: HANDLER
0660 ;
0670 EFIND
0680     LDX #0
0690 ELOOP
0700     LDA HATABS,X
0710     CMP #'E
0720     BEQ EFND
0730     INX 
0740     INX 
0750     INX 
0760     BNE ELOOP
0770     BEQ EFIND
0780 ;
0790 ;   FOUND THE E: POINTER
0800 ;
0810 EFND
0820     LDA HATABS+1,X
0830     STA $D0
0840     LDA HATABS+2,X
0850     STA $D1
0860     LDY #4
0870     LDA ($D0),Y
0880     STA EGET+1
0890     INY 
0900     LDA ($D0),Y
0910     STA EGET+2
0920     INY 
0930     LDA ($D0),Y
0940     STA EPUT+1
0950     INY 
0960     LDA ($D0),Y
0970     STA EPUT+2
0980 ;
0990     INC EGET+1
1000     BNE L013
1010     INC EGET+2
1020 L013
1030     INC EPUT+1
1040     BNE L012
1050     INC EPUT+2
1060 ; -----------------------------
4000 ; OS/A+ VERSION
4010 ;
4020 L012
4030 ;
4040 ;  SET THE LOMEM POINTER
4050 ;
4060 LMP
4070     LDA #LAST&$FF
4080     STA MEMLO
4090     LDA #LAST/$0100
4100     STA MEMLO+1
4110 ;
4120     LDA #IMSG&$FF
4130     LDY #IMSG/$0100
4140     JSR PRINTE
4150 ;
4160 CU20 RTS 
4170 ;
4180 IMSG
4190     .BYTE CR,CR,"The device"
4200     .BYTE " Bn: is now"
4210     .BYTE " ready.",CR
4220     .BYTE "Use the copy command"
4230     .BYTE " to access.",CR
4240     .BYTE " (eg. COPY D:FILE,"
4250     .BYTE "B2: ",')+128
4260 ;
4270     *=  $2100
4990 ; -----------------------------
5000 ;
5005 ; HANDLER AND HANDLER TABLE
5010 ;  FOR "B:" (MAKEBOOT)
5015 ;  HANDLER
5020 ;
5025 ;HANDLER TABLE
5030 ;
5035 BTAB
5040     .WORD BOPEN-1
5045     .WORD BCLOSE-1
5050     .WORD NOFNT-1
5055     .WORD BPUT-1
5060     .WORD STATUS-1
5065     JMP NOFNT
5070 ;
5075 ;HANDLER VARIABLES
5080 ;
5085 HEADER .BYTE $06
5090 HOLDA .BYTE $00
5095 HOLDX .BYTE $00
5100 STATS .BYTE $00
5105 SECNO .WORD $01
5110 BYTNO .BYTE $00
5115 MAXSEC .WORD $00
5120 INFOBY .BYTE $00
5125 MFLAG .BYTE $00
5130 RUNADR .WORD $00 ;INTADR must
5135 INTADR .WORD $00 ;follow RUNADR
5140 LOADAD .WORD $00
5145 CURMEM .WORD $00 ;LASTAD must
5150 LASTAD .WORD $00 ;follow CURMEM
5155 ;
5160 ;HANDLER OPEN FUNCTION
5165 ;
5170 BOPEN
5175     LDA #$00    ;clear variables
5180     STA BYTNO
5185     STA SECNO+1
5190     STA MAXSEC
5195     STA MAXSEC+1
5200     STA MFLAG
5205     STA RUNADR
5210     STA RUNADR+1
5215     STA INTADR
5220     STA INTADR+1
5225     LDA #$01
5230     STA SECNO
5235     STA STATS
5240     LDA #$06
5245     STA HEADER
5250     JSR CLEAR
5255     CLC 
5260     LDA $21     ;disk #
5265     ADC #$30    ;make ASCII #
5270     STA MSG2A
5275     LDA #MSG2&$FF
5280     LDY #MSG2/$0100
5285     JSR PRINTE
5290     JSR YESNO   ;Y/N?
5295     BNE L014
5300     LDA #$80    ;abort with
5305     STA STATS   ;error = 128
5310     JMP EXIT
5315 L014
5320     LDA #MSG1&$FF ;clear secs?
5325     LDY #MSG1/$0100
5330     JSR PRINTE
5335     JSR GETNUM
5340     BCS L014    ;error?
5345     LDA FR0
5350     STA BUF2
5355     LDA FR0+1
5360     STA BUF2+1
5365     ORA BUF2
5370     BEQ BOP04
5375 BOP01
5380     JSR PUTSEC  ;fill sectors
5385     INC SECNO   ;with zeros
5390     BNE BOP02
5395     INC SECNO+1
5400 BOP02
5405     LDA BUF2
5410     BNE BOP03
5415     DEC BUF2+1
5420 BOP03
5425     DEC BUF2
5430     BIT BUF2+1
5435     BPL BOP01
5440 BOP04
5445     LDA #0
5450     STA SECNO+1
5455     STA MAXSEC
5460     STA MAXSEC+1
5465     LDA #1
5470     STA SECNO
5475 ;
5480     JMP EXIT
5485 ;
5490 ;HANDLER SUBROUTINES
5495 ;
5500 ; 1) Store load address and
5505 ;    end of load address
5510 ;
5515 LODADR
5520     PHA         ;calc index &
5525     TYA         ;store load
5530     SEC         ;address &
5535     SBC #3      ;end of load
5540     EOR #$FF
5545     TAY 
5550     INY 
5555     PLA 
5560     STA CURMEM,Y
5565     RTS 
5570 ;
5575 ; 2) Get two 2-byte
5580 ;    load addresses
5585 ;
5590 LDINFO
5595     LDA INFOBY
5600     BNE L007
5605     LDA #4
5610     STA INFOBY
5615 L007
5620     DEC INFOBY
5625     LDY INFOBY
5630     LDA HOLDA
5635     JSR LODADR
5640     LDY INFOBY
5645     BEQ LD03
5650     CPY #2
5655     BNE LD02
5660 ;
5665     LDA CURMEM  ;check for
5670     CMP CURMEM+1 ;appended file
5675     BNE LD02
5680     CMP #$FF
5685     BNE LD02
5690     LDA #4
5695     STA INFOBY
5700 LD02
5705     JMP EXIT
5710 LD03
5715     JSR INRUAD
5720     BEQ LD02
5725     BNE L008
5730 ;
5735 ; 3) Check for load file run
5740 ;    or init. address
5745 ;    If CURMEM & LASTAD
5750 ;      are <$2E0 or >$2E3
5755 ;    THEN Z=0
5760 ;    ELSE Z=1
5765 ;
5770 INRUAD
5775     LDA CURMEM+1
5780     CMP LASTAD+1
5785     BNE IRA01
5790 IRA02
5795     CMP #2
5800     BNE IRA01
5805     LDA #$DF
5810     CMP CURMEM
5815     BCS IRA02
5820     CMP LASTAD
5825     BCS IRA02
5830     LDA #$E3
5835     CMP CURMEM
5840     BCC IRA02
5845     CMP LASTAD
5850     BCC IRA02
5855     LDA #0
5860 IRA01
5865     RTS 
5870 ;
5875 ; 4) Check for load address
5880 ;    less than initial
5885 ;
5890 L008
5895     LDA LOADAD+1
5900     CMP CURMEM+1
5905     BCC LF01
5910     BNE LF02
5915     LDA LOADAD
5920     CMP CURMEM
5925     BEQ LF01
5930     BCC LF01
5935 LF02
5940     LDA #MSG6&$FF ;LOADAD>CURMEM
5945     LDY #MSG6/$0100
5950     JSR PRINTE
5955     LDY #168
5960     STY STATS
5965     JMP EXIT
5970 ;
5975 ; 5) Calculate sector and byte
5980 ;    for new load address
5985 ;
5990 LF01
5995     SEC         ;Find offset
6000     LDA CURMEM
6005     SBC LOADAD
6010     STA BUF2
6015     LDA CURMEM+1
6020     SBC LOADAD+1
6025     STA BUF2+1
6030     LDA BUF2    ;calc byte
6035     AND #$7F
6040     STA BYTNO
6045     LDX #7
6050 L009
6055     CLC         ;calc sector
6060     ROR BUF2+1  ;divide by 128
6065     ROR BUF2
6070     DEX 
6075     BNE L009
6080     INC BUF2
6085     BNE LF11
6090     INC BUF2+1
6095 LF11
6100     LDA BUF2    ;Load sec if dif
6105     CMP SECNO
6110     BNE LDI1
6115     LDA BUF2+1
6120     CMP SECNO+1
6125     BEQ LDI2
6130 LDI1
6135     LDA BUF2
6140     STA SECNO
6145     LDA BUF2+1
6150     STA SECNO+1
6155     JMP GETSEC
6160 LDI2
6165     JMP EXIT
6170 ;
6175 ; 6) Save run and init. address
6180 ;
6185 STIRAD
6190     JSR INRUAD
6195     BNE IR01
6200     JSR CMPMEM
6205     BCC IR01
6210     LDA CURMEM
6215     AND #$0F
6220     TAY 
6225     LDA HOLDA
6230     STA RUNADR,Y
6235     INC CURMEM
6240     JMP EXIT
6245 IR01
6250     JMP L005
6255 ;
6260 ; 7) Process header information
6265 ;    for start of load file
6270 ;
6275 FSTSIX
6280     CPY #$04
6285     BEQ FSS1
6290     JMP FS01
6295 ;
6300 FSS1
6305     LDA #FM1&$FF ;  specify
6310     LDY #FM1/$0100 ;load
6315     JSR PRINTE  ;   information
6320     JSR YESNO
6325     BNE FS02
6330     JMP FS01
6335 ;
6340 FS02
6345     LDA #FM2&$FF ;  get sector
6350     LDY #FM2/$0100 ; count
6355     JSR PRINTE
6360     JSR GETNUM
6365     BCS FS02
6370     LDA FR0
6375     BEQ FS03
6380     STA BUF1+1
6385 ;
6390 FS03
6395     LDA #FM3&$FF ;  get load
6400     LDY #FM3/$0100 ;address
6405     JSR PRINTE
6410     JSR GETNUM
6415     BCS FS03
6420     LDA FR0
6425     ORA FR0+1
6430     BEQ FS03
6435     LDA FR0
6440     STA BUF1+2
6445     STA LOADAD
6450     LDA FR0+1
6455     STA BUF1+3
6460     STA LOADAD+1
6465 ;
6470 FS04
6475     LDA #FI4&$FF ;  get init
6480     LDY #FI4/$0100 ;address
6485     JSR PRINTE
6490     JSR GETNUM
6495     BCS FS04
6500     LDA FR0
6505     ORA FR0+1
6510     BEQ FS05
6515     LDA FR0
6520     STA BUF1+4
6525     LDA FR0+1
6530     STA BUF1+5
6535 ;
6540 FS05
6545     LDA #FM4&$FF ;  get run
6550     LDY #FM4/$0100 ;address
6555     JSR PRINTE
6560     JSR GETNUM
6565     BCS FS05
6570     LDA FR0
6575     ORA FR0+1
6580     BEQ FS06
6585     LDA #$4C
6590     STA BUF1+6
6595     LDA FR0
6600     STA BUF1+7
6605     LDA FR0+1
6610     STA BUF1+8
6615 ;
6620 FS06
6625     LDA #0
6630     STA HEADER
6635     JSR PUTSEC
6640     JMP LDINFO
6645 ;
6650 FS01
6655     LDA HOLDA   ;  get load
6660     STA LOADAD+1 ; address
6665     LDA CURMEM  ;  from file
6670     STA LOADAD
6675     LDA HOLDA
6680     DEC HEADER
6685     LDY HEADER
6690     CPY #4      ;Y<4
6695     BCS FS07    ;no
6700     JSR LODADR
6705     JMP EXIT
6710 FS07
6715     CMP #$FF    ;load file?
6720     BEQ EXIT
6725     LDA #MSG5&$FF
6730     LDY #MSG5/$0100
6735     JSR PRINTE
6740     LDY #168    ;error if not
6745     STY STATS   ;load file
6750 ;
6755 ;GET STATUS AND EXIT HANDLER
6760 ;
6765 STATUS
6770 EXIT
6775     LDY STATS
6780     TYA         ;Error in Y
6785 NOFNT RTS 
6790 ;
6795 ; 8) Clear output buffer
6800 ;
6805 CLEAR
6810     LDX #$7F
6815     LDA #$00
6820 CLR1
6825     STA BUF1,X
6830     DEX 
6835     BPL CLR1
6840     RTS 
6845 ;
6850 ; 9) Check for end of load
6855 ;    C=0 CURMEM  > LASTAD
6860 ;    C=1 CURMEM <= LASTAD
6865 ;
6870 CMPMEM
6875     LDA LASTAD+1
6880     CMP CURMEM+1
6885     BCC L003
6890     BNE L003
6895     LDA LASTAD
6900     CMP CURMEM
6905 L003 RTS 
6910 ;
6915 ;HANDLER PUT BYTE FUNCTION
6920 ;
6925 BPUT
6930     STA HOLDA   ;save byte
6935     LDY HEADER  ;from CIO
6940     BEQ BP02
6945     JMP FSTSIX
6950 BP02
6955     LDA INFOBY
6960     BNE INF11
6965     JSR CMPMEM  ;end of load?
6970     BCS BP01    ;no
6975 INF11
6980     JMP LDINFO
6985 BP01
6990     JMP STIRAD  ;run or init?
6995 L005
7000     LDX BYTNO
7005     LDA HOLDA
7010     STA BUF1,X  ;save in output
7015     INC CURMEM  ;buffer
7020     BNE L004
7025     INC CURMEM+1
7030 L004
7035     INC BYTNO   ;end of sector
7040     BPL L006    ;yes
7045     JSR PUTSEC  ;save sector
7050     INC SECNO
7055     BNE LP04
7060     INC SECNO+1
7065 LP04
7070     JSR GETSEC
7075     LDA #0
7080     STA BYTNO
7085     BEQ EXIT
7090 ;
7095 L006
7100     JSR CMPMEM
7105     BCS EXIT
7110     JMP PUTSEC
7115 ;
7120 ;HANDLER CLOSE FUNCTION
7125 ;
7130 BCLOSE
7135     BIT STATS
7140     BPL BCL01
7145     JMP EXIT
7150 BCL01
7155     JSR PUTSEC
7160 ;
7165     LDA #1
7170     STA SECNO
7175     LDA #0
7180     STA SECNO+1
7185     JSR GETSEC
7190 ;
7195     LDA #MSG4&$FF ;   sector
7200     LDY #MSG4/$0100 ; count
7205     JSR PRINTE
7210     LDA MAXSEC
7215     STA FR0
7220     LDA MAXSEC+1
7225     STA FR0+1
7230     JSR PNUM
7235     JSR BCLSUB
7240     BEQ BCL03
7245     LDA MAXSEC
7250     STA BUF1+1
7255 ;
7260 BCL03
7265     LDA INTADR  ;   init.
7270     ORA INTADR+1 ;  address
7275     BEQ BCL04
7280     LDA #FM5&$FF
7285     LDY #FM5/$0100
7290     JSR PRINTE
7295     LDA INTADR
7300     STA FR0
7305     LDA INTADR+1
7310     STA FR0+1
7315     JSR PNUM
7320     JSR BCLSUB
7325     BEQ BCL04
7330     LDA INTADR
7335     STA BUF1+4
7340     LDA INTADR+1
7345     STA BUF1+5
7350 ;
7355 BCL04
7360     LDA RUNADR  ;   run
7365     ORA RUNADR+1 ;  address
7370     BEQ BCL05
7375     LDA #FM6&$FF
7380     LDY #FM6/$0100
7385     JSR PRINTE
7390     LDA RUNADR
7395     STA FR0
7400     LDA RUNADR+1
7405     STA FR0+1
7410     JSR PNUM
7415     JSR BCLSUB
7420     BEQ BCL05
7425     LDA #$4C
7430     STA BUF1+6
7435     LDA RUNADR
7440     STA BUF1+7
7445     LDA RUNADR+1
7450     STA BUF1+8
7455 ;
7460 BCL05
7465     JMP PUTSEC
7470 ;
7475 BCLSUB
7480     LDA #FM7&$FF
7485     LDY #FM7/$0100
7490     JSR PRINTE
7495     JMP YESNO   ;Y/N?
7500 ;
7505 ;I/O SUBROUTINES
7510 ;
7515 ; 1) Read and write to disk
7520 ;
7525 GETSEC
7530     LDY #$52
7535     LDA #$40
7540     BNE DISKIO
7545 PUTSEC
7550     LDA MAXSEC+1 ; Check for
7555     BEQ L010    ;  too many
7560     LDA MFLAG   ;  load sectors
7565     BNE L010
7570     LDA #MSG3&$FF
7575     LDY #MSG3/$0100
7580     JSR PRINTE
7585     INC MFLAG
7590 L010
7595     LDA MAXSEC+1
7600     CMP SECNO+1
7605     BCC PU02
7610     BNE PU01
7615     LDA SECNO
7620     CMP MAXSEC
7625     BCC PU01
7630 PU02
7635     LDA SECNO
7640     STA MAXSEC
7645     LDA SECNO+1
7650     STA MAXSEC+1
7655 PU01
7660     LDY #$57    ;  Use #$50
7665     LDA #$80    ;  for no-verify
7670 DISKIO
7675     STY $0302
7680     STA $0303
7685     LDA #$31
7690     STA $0300
7695     LDA $21
7700     STA $0301
7705     LDA #$80
7710     STA $0308
7715     LDA #$0F
7720     STA $0306
7725     LDA #BUF1&$FF
7730     STA $0304
7735     LDA #0
7740     STA $0309
7745     LDA #BUF1/$0100
7750     STA $0305
7755     LDA SECNO
7760     STA $030A
7765     LDA SECNO+1
7770     STA $030B
7775     JSR $E459
7780     BMI ERROR
7785     RTS 
7790 ERROR
7795     LDA $0303
7800     STA STATS
7805     TAY 
7810     RTS 
7815 ;
7820 ; 2) Y/N - Result in accumulator
7825 ;    Y = 1
7830 ;    N = 0
7835 ;
7840 YESNO
7845     LDA #$FF
7850     STA CH
7855 YN1
7860     LDA CH      ;Get 1 character
7865     CMP #43     ;Y?
7870     BNE YN2
7875     LDA #1
7880     BNE YN4
7885 YN2
7890     CMP #35     ;N?
7895     BNE YN1
7900     LDA #0
7905 YN4
7910     PHA 
7915     LDA #$FF
7920     STA CH
7925     PLA 
7930     RTS 
7935 ;
7940 ; 3) Print the integer in FR0
7945 ;
7950 PNUM
7955     JSR IFP
7960     JSR FASC
7965     LDA INBUFF
7970     LDY INBUFF+1
7975     JMP PRINTE
7980 ;
7985 ; 4) Get a number
7990 ;    result in FR0
7995 ;
8000 GETNUM
8005     LDA #$30
8010     STA LBUFF
8015     LDX #1
8020     STX HOLDX
8025 NOTCR
8030     JSR EGET    ;Get a number
8035     LDX HOLDX
8040     INC HOLDX
8045     STA LBUFF,X ;Store it at
8050     CMP #$9B    ;$580
8055     BNE NOTCR
8060     LDA #LBUFF&$FF ;Point to
8065     STA INBUFF  ;  ASCII string
8070     LDA #LBUFF/$0100
8075     STA INBUFF+1
8080     LDA #0
8085     STA CIX
8090     JSR AFP     ;ASCII to FP
8095     BCS GN01    ;error if C set
8100     JSR FPI     ;FP to integer
8105 GN01 RTS 
8110 ;
8115 ; 5) Print text to screen
8120 ;    Low byte of text in
8125 ;    accumulator, High byte
8130 ;    of text in Y register
8135 ;
8140 PRINTE
8145     STA MSGN+1
8150     STY MSGN+2
8155     JMP MSGN
8160 EP02
8165     INC MSGN+1
8170     BNE MSGN
8175     INC MSGN+2
8180 MSGN
8185     LDA MSGN
8190     BEQ EP04
8195     BMI EP05
8200     JSR EPUT
8205     JMP EP02
8210 EP04
8215     JSR PNTCR
8220     JMP EP02
8225 ;
8230 EP05
8235     AND #$7F
8240     BEQ EP06
8245     JSR EPUT
8250 ;
8255 PNTCR
8260     LDA #$9B
8265     JSR EPUT
8270 EP06 RTS 
8275 ;
8280 ;JUMP TO SCREEN EDITOR
8285 ; PUT BYTE ROUTINE
8290 ;
8295 EPUT JMP EPUT
8300 ;
8305 ;JUMP TO SCREEN EDITOR
8310 ; GET BYTE ROUTINE
8315 ;
8320 EGET JMP EGET
8325 ;
8330 ;
8335 FM1 .BYTE CR,"Do you wish to "
8340     .BYTE "specify the boot",CR
8345     .BYTE " sector information "
8350     .BYTE "(Y/N)",'?+128
8355 ;
8360 FM2 .BYTE CR,"Enter boot sector"
8365     .BYTE " count ",128
8370 ;
8375 FM3 .BYTE CR,"Enter load "
8380     .BYTE "address ",128
8385 ;
8390 FM4 .BYTE CR,"Enter run "
8395     .BYTE "address ",128
8400 ;
8405 FI4 .BYTE CR,"Enter "
8410     .BYTE "initialization "
8415     .BYTE "address ",128
8420 ;
8425 FM5 .BYTE CR,"Load file "
8430     .BYTE "initiation address "
8435     .BYTE "= ",128
8440 ;
8445 FM6 .BYTE CR,"Load file "
8450     .BYTE "run address "
8455     .BYTE "= ",128
8460 ;
8465 FM7 .BYTE CR,"Insert into "
8470     .BYTE "boot sector (Y/N)"
8475     .BYTE '?+128
8480 ;
8485 MSG1 .BYTE CR,"How many sectors"
8490     .BYTE " to clear",'?+128
8495 ;
8500 MSG2 .BYTE CR,"Make disk #"
8505 ;
8510 MSG2A .BYTE $31," into boot"
8515     .BYTE " disk (Y/N)",'?+128
8520 ;
8525 MSG3 .BYTE CR,"Sector count"
8530     .BYTE " exceeds 25",'5+128
8535 ;
8540 MSG4 .BYTE CR,"The boot sector"
8545     .BYTE " count is ",128
8550 ;
8555 MSG5 .BYTE CR,"Not a load"
8560     .BYTE " fil",'e+128
8565 ;
8570 MSG6 .BYTE CR,"Specified load"
8575     .BYTE " address is",CR
8580     .BYTE "  is not lowest"
8585     .BYTE " addres of fil"
8590     .BYTE 'e+128
8595 ;
8600 LAST .END 

Back to previous page