File:  [Infocom source] / coco / ioprims.src
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Fri Mar 20 10:19:52 2020 UTC (20 months, 2 weeks ago) by root
Branches: infocom, MAIN
CVS tags: tandy, makefile, lwasm, VERSION_D, HEAD
Patches for lwasm

	PAGE
	;SBTTL "--- OS EQUATES ---"

SCREEN	EQU	$400		; START OF SCREEN RAM
ENDSCR	EQU	$600		; END OF SCREEN RAM
POLCAT	EQU	$A000		; KEYCODE FETCH VECTOR
CHROUT	EQU	$A002		; PRINT CHAR TO DEVICE
DEVNUM	EQU	$6F		; $00 = SCREEN, $FE = PRINTER
CURSOR	EQU	$88		; ABSOLUTE CURSOR ADDRESS
INT60	EQU	$FF03		; 60HZ INTERRUPT CONTROL
ROMON	EQU	$FFDE		; ROM ENABLE
ROMOFF	EQU	$FFDF		; ROM DISABLE
MEMTOP	EQU	$FE		; TOP PAGE OF AVAILABLE RAM

EOL	EQU	$0D		; END-OF-LINE CHARACTER
BS	EQU	$08		; BACKSPACE CHARACTER
SPACE	EQU	$20		; SPACE CHARACTER
CDURAT	EQU	5		; DURATION OF KEYCLICKS
CFREQ	EQU	25		; FREQUENCY OF KEYCLICKS
BDURAT	EQU	10		; DURATION OF RAZZ
BFREQ	EQU	500		; FREQUENCY OF RAZZ
FLASH	EQU	$180		; CURSOR BLINK FREQUENCY

	PAGE
	;SBTTL "I/O PRIMITIVES"

	; ------------------
	; ENABLE ROM FOR I/O
	; ------------------

; NO LONGER NEEDED IN 0S9 VERSION [ASK 5/17/85]****************************
ROMIN:	STA	IHOLD		; SAVE [A]
 	LDA	INT60		; ENABLE 60HZ INTERRUPT
 	ORA	#%00000001
 	STA	ROMON
 	STA	INT60
 	ANDCC	#%10101111	; INTERRUPTS ON
 	LDA	IHOLD		; RESTORE [A]
 	RTS

	; ------------------
	; ACCESS OS KEY-READ
	; ------------------

;CATPOL:	BSR	ROMIN
;CPL:	JSR	MYCAT		; TO NON-ROM ROUTINE OF POLCAT
;	BEQ	CPL

CATPOL:	JSR	MYCAT
 	BEQ	CATPOL
 	RTS

	; ----------------------
	; DISABLE ROM FOR PAGING
	; ----------------------

ROMOUT:	STA	IHOLD		; SAVE [A]
;	ORCC	#%01010000	; DISABLE INTERUPTS
;	LDA	INT60
;	ANDA	#%11111110	; DISABLE 60HZ INTERRUPT
; 	STA	INT60
 	STA	ROMOFF		; AND ROM
	LDA	IHOLD		; RESTORE [A]
	RTS

	; --------------------
	; ACCESS OS CHAR-PRINT
	; --------------------

;OUTCHR:	BSR	ROMIN
;	JSR	MYCHR 		;CHROUT COPIED
;	BRA	ROMOUT

OUTCHR:	JMP	MYCHR

	; -----------------
	; READ A SINGLE KEY
	; -----------------

	; EXIT: KEYCODE IN [A]

BADKEY:	JSR 	BOOP		; RAZZ
	BRA	WINK		; AND TRY AGAIN

GETKEY:	PSHS	U,X,Y,B		; SAVE THESE

;	BSR	ROMIN		;[ASK 5/15/85]

WINK:	LDY	#FLASH*4
	STY	CYCLE		; LONG DELAY
	LDA	#%10000000
	STA	BLINK		; INIT CURSOR MASK
GK:	JSR	MYCAT   	; (POLCAT COPIED) LET OS DO THE WORK
	INC	RAND1		; GENERATE RANDOMNESS
	BNE	GKZ
	INC	RAND2
GKZ:	TST	CFLAG		; BLINK CURSOR?
	BEQ	NOBLIN		; NOT IF [CFLAG]=0
	LDY	CYCLE
	LEAY	-1,Y
	STY	CYCLE		; TIME TO BLINK?
	BNE	KTEST		; NOT YET
	LDY	#FLASH		; ELSE RESET BLINK TIMER
	STY	CYCLE
	LDB	BLINK
	EORB	#%10000000	; FLIP CURSOR MASK
	STB	BLINK
KTEST:	LDX	CURSOR
	LDB	,X
	ANDB	#%01111111
	ORB	BLINK
	STB	,X
NOBLIN:	TSTA
	BEQ	GK		; 0 = NO KEY YET
	TST	CFLAG
	BEQ	QKEY
	ANDB	#%01111111	; CLEAR CURSOR
	STB	,X

	; SCREEN KEYCODE IN [A]

QKEY:	CMPA	#EOL		; "ENTER" IS FINE
	BEQ	CLICK
	CMPA	#BS		; SO IS "LEFT ARROW"
	BEQ	CLICK

	CMPA	#$61		; LOWER-CASE ALPHA?
	BLO	PKICK		; NO, CHECK FOR OTHERS
	CMPA	#$7B		; NOTHING ABOVE "z" IS LEGAL
	BHS	BADKEY
	SUBA	#$20		; CONVERT TO UPPER-CASE ALPHA
	BRA	CLICK

PKICK:	CMPA	#$5B		; NOTHING BETWEEN "Z" AND "a"
	BHS	BADKEY		; IS LEGAL
	CMPA	#$20		; NOTHING BELOW "SPACE"
	BLO	BADKEY		; IS LEGAL EITHER

	; "CLICK" SOUND FOR KEYS

CLICK:	STA	IOCHAR		; SAVE KEY HERE
	JSR	AINIT		; ENABLE SOUND
	LDB	#CDURAT
TICK:	LDA	#%11111110
	STA	$FF20
	BSR	CDELAY
	LDA	#%00000010
	STA	$FF20
	BSR	CDELAY
	DECB
	BNE	TICK
	PULS	U,X,Y,B		; RESTORE THINGS
	LDA	IOCHAR		; RETRIEVE THE KEYPRESS
	RTS

;	JMP	ROMOUT		; AND SWITCH OUT THE ROMS  [ASK 5/15/85]

	; DELAY FOR KEYCLICK

CDELAY:	LDX	#CFREQ
CDEL:	LEAX	-1,X
	BNE	CDEL
	RTS

	; -------------------
	; READ A LINE OF TEXT
	; -------------------

	; ENTRY: [ARG1] HAS ADDRESS OF CHAR BUFFER
	;        LENGTH OF BUFFER IN 1ST BYTE
	; EXIT:	# CHARS READ IN [A]

INPUT:	JSR	LINOUT		; FLUSH OUTPUT BUFFER
	CLR	LINCNT		; RESET LINE COUNTER
	CLR 	DEVNUM		; POINT TO SCREEN
	LDX	ARG1		; GET ADDRESS OF INPUT BUFFER
	LDB	,X+		; GET MAX # CHARS
	SUBB	#2		; LEAVE A MARGIN FOR ERROR
	STB	BINDEX		; SAVE MAX # CHARS
	STB	CFLAG		; ENABLE CURSOR

	CLRB			; RESET	INDEX
INLOOP:	JSR	GETKEY		; KEY IN [A] AND [IOCHAR]
	CMPA	#EOL		; IF EOL,
	BEQ	ENDLIN		; LINE IS DONE
	CMPA	#BS		; IF BACKSPACE,
	BEQ	GOBACK		; TAKE CARE OF IT

	CMPA	#$41		; IF LOWER THAN ASCII "A,"
	BLO	SENDCH		; SEND THE CHARACTER
	ADDA	#$20		; ELSE CONVERT TO LOWER-CASE

SENDCH:	STA	B,X		; SEND CHAR TO BUFFER
	INCB			; UPDATE INDEX
TOSCR:	LDA	IOCHAR		; RETRIEVE KEY CHAR
	BSR	CHAR		; ECHO CHAR TO SCREEN
	CMPB	BINDEX		; BUFFER FILLED?
	BHS	NOMORE		; YES -- INSIST ON BS OR EOL
	CMPB	#61		; 2 SCREEN LINES FILLED?
	BLO	INLOOP		; NO, KEEP GOING

	; LINE FULL; INSIST ON EOL OR BACKSPACE

NOMORE:	JSR 	GETKEY		; GET NEXT KEY
	CMPA	#EOL		; IF EOL,
	BEQ	ENDLIN		; WE'RE FINE
	CMPA	#BS		; BACKSPACE
	BEQ	GOBACK		; IS OKAY TOO
	JSR	BOOP
	BRA	NOMORE		; ELSE PERSIST

	; HANDLE BACKSPACE

GOBACK:	DECB			; BACK UP CHAR COUNT
	BPL	TOSCR		; SEND TO SCREEN IF NO UNDERFLOW
	CLRB			; ELSE RESET COUNT
	JSR	BOOP		; RAZZ
	BRA	INLOOP		; AND TRY AGAIN

	; HANDLE EOL

ENDLIN:	STA	B,X		; PUT EOL IN BUFFER
	BSR	CHAR		; AND ON SCREEN
	INCB			; UPDATE CHAR COUNT
	STB	BINDEX		; SAVE IT HERE

	; FALL THROUGH TO ...

	; ---------------------
	; SCRIPT A LINE OF TEXT
	; ---------------------

	; ENTRY: ADDRESS OF TEXT IN [X]
	;        LENGTH OF LINE IN [BINDEX]

TOPRIN:	TST	SCRIPT		; SCRIPTING ENABLED?
	BEQ	INPEX		; NO, EXIT IMMEDIATELY
	LDA	ZCODE+ZSCRIP+1	; GET FLAGS BYTE
	ANDA	#1		; BIT 0 SET?
	BEQ	INPEX		; NO, IGNORE THE FOLLOWING
	LDA	#$FE		; ELSE
	STA	DEVNUM		; POINT TO PRINTER
	LDB	BINDEX		; START AT 1ST BUFFER CHAR

;	JSR	ROMIN

SCROUT:	LDA	,X+		; GRAB A CHAR FROM BUFFER
	JSR	MYCHR
	DECB
	BNE	SCROUT
INPEX:	CLR	DEVNUM		; POINT BACK TO SCREEN
	LDA	BINDEX		; RETRIEVE # CHARS IN LINE
	RTS

SFLAG	.DB	0		; FLAG TO SAVE SCRIPT STATE

;	JMP	ROMOUT		; MAKE SURE ROM IS GONE [ASK 5/15/85]

	; -------------------
	; PRINT A SINGLE CHAR
	; -------------------

	; ENTRY: ASCII CODE IN [A]

CHAR:	STA	IOCHAR		; SAVE CHAR HERE
	CLR	DEVNUM		; ALWAYS TO SCREEN
	PSHS	X,Y,B		; SAVE THESE
	INC	RAND1		; RANDOMNESS
	LDY	CURSOR		; GET ADDRESS OF CURSOR
	CMPA	#EOL		; EOL?
	BEQ	OUTEOL		; HANDLE IT
	CMPY	#ENDSCR-1	; LAST CHAR ON SCREEN?
	BLO	NOSCRL		; NO SCROLL NECESSARY

	; SCROLL SCREEN, RETAINING STATUS LINE

DOSCRL:	LDY	#ENDSCR-33	; LAST POSITION IN LINE 14
	STY	CURSOR		; MOVE CURSOR
	LDX	#SCREEN+64	; [X] POINTS TO "SOURCE" LINE
	LDY	#SCREEN+32	; [Y] POINTS TO "DEST" LINE

SCRL1:	LDB	#31		; INIT LINE INDEX

SCRL2:	LDA	B,X		; GET CHAR FROM SOURCE LINE
	STA	B,Y		; MOVE TO DESTINATION LINE
	DECB			; CONTINUE TILL
	BPL	SCRL2		; ENTIRE LINE IS MOVED

	TFR	X,Y		; SOURCE IS NOW DEST
	LEAX	32,X		; ADD 32 TO SOURCE ADDRESS
	CMPX	#ENDSCR		; END OF SCREEN YET?
	BLO	SCRL1		; NO, KEEP MOVING

	LDA	#$60		; SPACE CHAR
SCRL3:	STA	,Y+
	CMPY	#ENDSCR
	BLO	SCRL3

NOSCRL:	LDA	IOCHAR		; RESTORE CHAR

	; LOWER-CASE OPTION

;	TST	LCASE		; LOWER-CASE CAPABILITY?
;	BNE	GOCHR		; YES, SEND CHAR AS-IS

	CMPA	#$61		; LESS THAN "a"?
	BLO	GOCHR		; YES, USE AS-IS
	SUBA	#$20		; ELSE CONVERT TO UPPER CASE
GOCHR:	JSR	OUTCHR		; OFF TO THE SCREEN!
	PULS	X,Y,B		; RESTORE
	RTS

	; EOL SCROLL?

OUTEOL:	CMPY	#ENDSCR-32	; ON LAST SCREEN LINE?
	BLO	NOSCRL		; NO, HANDLE NORMALLY
	BRA	DOSCRL		; ELSE MOVE CURSOR UP!

	; --------------------------
	; PRINT CONTENTS OF [BUFFER]
	; --------------------------

BUFOUT:	LDB	CHRPNT		; # CHARS IN BUFFER
	LDX	#BUFFER		; BUFFER ADDRESS

	; FALL THROUGH TO ...

	; -------------
	; PRINT MESSAGE
	; -------------

	; ENTRY: ADDRESS OF ASCII MESSAGE IN [X]
	;        LENGTH OF MESSAGE IN [B]

LINE:	STB	BINDEX		; SAVE LENGTH
	CLRB			; INIT INDEX

LN:	LDA	B,X		; GET A CHAR
	JSR	CHAR
	INCB
	CMPB	BINDEX
	BLO	LN
	JMP	TOPRIN		; HANDLE SCRIPTING

	; ----------------
	; CLEAR THE SCREEN
	; ----------------

CLS:	LDA	#$60		; SPACE CHARS
	LDX	#SCREEN
CLS0:	STA	,X+
	CMPX	#ENDSCR
	BLO	CLS0
	LDD	#SCREEN+32
	STD	CURSOR		; CURSOR AT LINE 1
	CLR	LINCNT		; RESET LINE COUNTER
	CLR	CHRPNT		; AND CHAR INDEX
	RTS

	; --------------
	; SOUND HANDLERS
	; --------------

AINIT:	LDA	$FF01		; ENABLE SOUND
	ANDA	#%11110111
	STA	$FF01
	LDA	$FF03
	ANDA	#%11110111
	STA	$FF03
	LDA	$FF23
	ORA	#%00001000
	STA	$FF23
	RTS

	; DO THE RAZZ

BOOP:	PSHS	X,D
	BSR	AINIT
	LDB	#BDURAT		; GET DURATION
BOOP1:	LDA	#%11111110	; CREST OF WAVE
	STA	$FF20		; SEND TO DAC
	BSR	DELAY		; WAIT ...
	LDA	#%00000010
	STA	$FF20		; TROUGH
	BSR	DELAY		; WAIT AGAIN
	DECB			; ELSE NEXT DURATION
	BNE	BOOP1
	PULS	X,D
	RTS

	; TIME DELAY

DELAY:	LDX	#BFREQ		; INIT FREQUENCY
DELOOP:	LEAX	-1,X
	BNE	DELOOP
	RTS

;-----------------------------------------------------------------------------

	; THESE ROM ROUTINES ARE TAKEN FROM THE BASIC UNRAVELED BOOKS
	; 
	; THEY ARE HERE FOR THE OS9 VERSION REQUIREMENT OF NO ROM CALLS
	;
	; [ASK 5/15/85]

; ROM- ROUTINES

;POLCAT


PIA0 	EQU	$FF00
PIA1	EQU	$FF20
DA	EQU	$FF20

LPTPOS	EQU	$9C
LPTWID	EQU	$9B
LPTBTD	EQU	$95
LPTLND	EQU	$97

KEYBUF	EQU	$0152
CASFLG	EQU	$011A
DEBVAL	EQU	$011B


RDYTMR	EQU	$985
DCDRV	EQU	$EB
DRGRAM	EQU	$986
DCTRK	EQU	$EC
DSKREG	EQU	$FF40
DCSTA	EQU	$F0
DCOPC	EQU	$EA
DR0TRK	EQU	$97E
FDCREG	EQU	$FF48
ZERO	EQU	$8A
DSEC	EQU	$ED
DNMIVC	EQU	$983
DCBPT	EQU	$EE
NMIFLG	EQU	$982
SKP2	EQU	$8C


	; IRQ HANDLER NEEDED FOR RDYTMR

DIRQSV:	LDA	PIA0+3
	BPL	DRTI
	LDA	PIA0+2
	LDA	RDYTMR
	BEQ	DRTI
	DECA
	STA	RDYTMR
	BNE	DRTI
	LDA	DRGRAM
	ANDA	#$B0
	STA	DRGRAM
	STA	DSKREG
DRTI:	RTI



LA1AE:	JMP	LA7D3

MYCAT:	PSHS	 U,X,B
 	LDU	#PIA0
	LDX	#KEYBUF
	CLRA
	DECA
	PSHS	X,A
	STA	2,U
LA1D5:	ROL	2,U
	BCC 	LA220
	INC	,S
	BSR	LA239
	STA	1,S
	EORA	,X
	ANDA	,X
	LDB	1,S
	STB	,X+
	TSTA
	BEQ	LA1D5
	LDB	2,U
	STB	2,S

	LDB	#$F8
LA1F1:	ADDB	#8
	LSRA
	BCC	LA1F1
	ADDB	,S

	BEQ	LA244
	CMPB 	#26
	BHI	LA246
	ORB 	#$40
	BSR	LA22E
	ORA	CASFLG
	BNE	LA20B
	ORB	#$20
LA20B:	STB	,S
	LDX	DEBVAL
	BSR	LA1AE
	LDB	#$FF
	BSR	LA237
	INCA
	BNE	LA220
LA21A:	LDB	2,S
	BSR	LA237
	CMPA	1,S
LA220:	PULS	X,A

	BNE	LA22B
	CMPA	#$12
	BNE	LA22C
	COM	CASFLG
LA22B:	CLRA
LA22C:	PULS 	X,U,B,PC
LA22E:	LDA	#$7F
	STA	2,U
	LDA	,U
	COMA
	ANDA	#$40
	RTS

LA237:	STB	2,U
LA239:	LDA	,U

	ORA	#$80
	TST	2,U
	BMI	LA243
	ORA	#$C0

LA243:	RTS


LA244:	LDB	#51
LA246:	LDX	#CONTAB-$36
	CMPB	#33
	BLO	LA263
	LDX	#CONTAB-$54
	CMPB	#48
	BHS	LA263
	BSR	LA22E
	CMPB	#43
	BLS	LA25C
	EORA	#$40

LA25C:	TSTA
	BNE	LA20B
	ADDB	#$10
	BRA	LA20B
LA263:	ASLB

	BSR	LA22E
	BEQ	LA269
	INCB
LA269:	LDB	B,X
	BRA	LA20B

CONTAB:	.DB 	$5E,$5F
	.DB 	$A,$5B
	.DB 	$8,$15
	.DB 	$9,$5D
	.DB 	$20,$20
	.DB 	$30,$12

	.DB 	$D,$D
	.DB 	$C,$5C
	.DB 	$3,$3
	.DB 	$40,$13

LA7D1:	LDX	ZERO
LA7D3:	LEAX	-1,X
	BNE	LA7D3
	RTS

;------------------------
; COPY OF CHROUT FROM ROM
;------------------------

RVEC3 	EQU	$0167
CR	EQU	$0D
VIDRAM	EQU	$0400
CURPOS	EQU	$88

;
;MYCHR:	JSR	RVEC3	;HOOK INTO RAM THE BOOK SAYS (BUT WHY I ASK)

MYCHR: 	PSHS	B
	LDB	DEVNUM
	INCB
	PULS	B
	BMI	LA2BF
	BNE	LA30A
;SEND TO CASSETTE NOT NEEDED

;PRINTER CODE
LA2BF:	PSHS	CC,A,B,X
	ORCC	#$50
LA2C3:	LDB	PIA1+2
	LSRB
	BCS	LA2C3
	BSR	LA2FB
	CLRB
	BSR	LA2FD
	LDB	#8
LA2C8:	PSHS	B
	CLRB
	LSRA
	ROLB
	ASLB
	BSR	LA2FD
	PULS	B
	DECB
	BNE	LA2C8
	BSR	LA2FB
	PULS	CC,A
	CMPA	#CR		;#$0D
	BEQ	LA2ED
	INC	LPTPOS
	LDB	LPTPOS
	CMPB	LPTWID
	BLO	LA2F3
LA2ED:	CLR	LPTPOS
	BSR	LA305
	BSR	LA305
LA2F3:	LDB	PIA1+2
	LSRB
	BCS	LA2F3
	PULS	B,X,PC
LA2FB:	LDB	#2
LA2FD:	STB	DA		;$FF20
	BSR	LA302
LA302:	LDX	LPTBTD
	.DB	SKP2
LA305:	LDX	LPTLND
	JMP	LA7D3



LA30A: 	PSHS	A,B,X
	LDX	CURPOS
	CMPA	#BS
	BNE	LA31D
	CMPX	#VIDRAM
	BEQ	LA35D
	LDA	#$60
	STA	,-X
	BRA	LA344
LA31D:	CMPA	#CR
	BNE	LA32F
	LDX	CURPOS
LA323:	LDA	#$60
	STA	,X+
	TFR	X,D
	BITB	#$1F
	BNE	LA323
	BRA	LA344
LA32F:	CMPA	#SPACE
	BLO	LA35D
	TSTA
	BMI	LA342
	CMPA	#$40
	BLO	LA340
	CMPA	#$60
	BLO	LA342
	ANDA	#$DF
LA340:	EORA	#$40
LA342:	STA	,X+
LA344:	STX	CURPOS
	CMPX	#VIDRAM+511
	BLS	LA35D
	LDX	#VIDRAM

LA34E:	LDD	32,X
	STD	,X++
	CMPX	#VIDRAM+$1E0
	BLO	LA34E
	LDB	#$60
	JSR	LA92D
LA35D:	PULS	A,B,X,PC

LA92D:	STX 	CURPOS
LA92F:	STB	,X+
	CMPX	#VIDRAM+511
	BLS	LA92F
	RTS

;----------------------------------
;COPY OF DISK CODE FROM ROM SOURCES
;----------------------------------


MYCON:	PSHS	U,Y,X,D		;AT $D75F IN LISTING
	LDA	#5
	PSHS	A
LD672:	CLR	RDYTMR
	LDB	DCDRV
	LDX	#LD7AA
	LDA	DRGRAM
	ANDA	#$A8
	ORA	B,X
	ORA	#$20
	LDB	DCTRK
	CMPB	#22
	BLO	LD68B
	ORA	#$10
LD68B:	TFR	A,B
	ORA	#8
	STA	DRGRAM
	STA	DSKREG
	BITB	#8
	BNE	LD69F
	JSR	LA7D1
	JSR	LA7D1
LD69F:	BSR	LD6DE
	BNE	LD6AD
	CLR	DCSTA
	LDX	#LD7A2
	LDB	DCOPC
	ASLB
	JSR	[B,X]
LD6AD:	PULS	A
	LDB	DCSTA
	BEQ	LD6BE
	DECA
	BEQ	LD6BE
	PSHS	A
	BSR	LD6C5
	BNE	LD6AD
	BRA	LD672
LD6BE:	LDA	#120
	STA	RDYTMR
	PULS	PC,U,Y,X,D

LD6C5:	LDX	#DR0TRK
	LDB	DCDRV
	CLR	B,X
	LDA	#3
	STA	FDCREG
	EXG	A,A
	EXG	A,A
	BSR	LD6DE
	BSR	LD6FD
	ANDA	#$10
	STA	DCSTA
LD6DD:	RTS

LD6DE:	LDX	ZERO
LD6E0:	LEAX	-1,X
	BEQ	LD6EC
	LDA	FDCREG
	BITA	#1
	BNE	LD6E0
	RTS
LD6EC:	LDA	#$D0
	STA	FDCREG
	EXG	A,A
	EXG	A,A
	LDA	FDCREG
	LDA	#$80
	STA	DCSTA
	RTS

LD6FD:	LDX	#8750
LD700:	LEAX	-1,X
	BNE	LD700
	RTS

LD705:	LDA	#$80
	.DB 	SKP2
LD708:	LDA	#$A0
	PSHS	A
	LDX	#DR0TRK
	LDB	DCDRV
	ABX
	LDB	,X
	STB	FDCREG+1
	CMPB	DCTRK
	BEQ	LD739
	LDA	DCTRK
	STA	FDCREG+3
	STA	,X
	LDA	#$17
	STA	FDCREG
	EXG	A,A
	EXG	A,A
	BSR	LD6DE
	BNE	LD737
	BSR	LD6FD
	ANDA	#$18
	BEQ	LD739
	STA	DCSTA
LD737:	PULS	PC,A

LD739:	LDA	DSEC
	STA	FDCREG+2
	LDX	#LD798
	STX	DNMIVC
	LDX	DCBPT
	LDA	FDCREG
	LDA	DRGRAM
	ORA	#$80
	PULS	B
	LDY	ZERO
	LDU	#FDCREG
	COM	NMIFLG
	ORCC	#$50
	STB	FDCREG
	EXG	A,A
	EXG	A,A
	CMPB	#$80
	BEQ	LD782

	LDB	#2
LD768:	BITB	,U
	BNE	LD778
	LEAY	-1,Y
	BNE	LD768
LD770:	CLR	NMIFLG
	ANDCC	#$AF
	JMP	LD6EC


;WRITE A SECTOR

LD778:	LDB	,X+
	STB	FDCREG+3
	STA	DSKREG
	BRA	LD778

LD782:	LDB	#2
LD784:	BITB	,U
	BNE	LD78E
	LEAY	-1,Y
	BNE	LD784
	BRA	LD770

LD78E:	LDB	FDCREG+3
	STB	,X+
	STA	DSKREG
	BRA	LD78E

LD798:	ANDCC	#$AF
	LDA	FDCREG
	ANDA	#$7C
	STA	DCSTA
	RTS

LD7A2:	.DW	LD6C5
	.DW	LD6DD
	.DW	LD705
	.DW	LD708

LD7AA:	.DB	1
	.DB	2
	.DB	4
	.DB	$40


	;END


unix.superglobalmegacorp.com