mirror of
https://github.com/marketideas/qasm.git
synced 2026-10-24 22:02:28 +00:00
Move the assembler to src/qasm. qlink links OMF 1.0 and 2.0 from a script. makeBin flattens a load file, qomf dumps OMF, and qpro builds ProDOS volumes. APW and MPW assemble through the ORCA front end. Relocatable modules emit OMF objects. Listings stay off unless -l is set. make boot assembles the GS/OS 6.0.1 ProDOS 8 kernel and BASIC.SYSTEM into an 800K volume. BASIC.SYSTEM accepts ls and pfx, and its splash reports PRODOS BASIC 2.0, copyright 1983-2026. IIGS.601.SRC is the source and the BASIC.SYSTEM oracle that image is built from.
1 line
32 KiB
NASM
1 line
32 KiB
NASM
*****************************************************************
|
|
*
|
|
* The Print Manager
|
|
* Modem Port Driver
|
|
*
|
|
* Coding Started Summer 1986 by Luc Barthelet and VersionSoft
|
|
*
|
|
* Current Rev
|
|
*
|
|
* V1.0 May 06, 1987 Suki Lee
|
|
*
|
|
* V1.1 Aug 06, 1987 Suki Lee
|
|
* Added code to initialize printer in DevOpen. Some file were
|
|
* not able to be printed without the initialization.
|
|
*
|
|
* Version 1.2d1 May 9, 1988 Suki Lee
|
|
*
|
|
* Added capability to read data from the printer, so we can get the ID from it.
|
|
* In DevOpen, added calls to set the printer as input device as well. In DevRead,
|
|
* added wait and status mechanisms, and changed call from ReadBlock to ReadLine.
|
|
*
|
|
*
|
|
* Version 1.3
|
|
*
|
|
* June 30, 1988 Suki Lee
|
|
* Changed macro _WriteBlock to its new name: _TextWriteBlock.
|
|
* Eliminated need to use Special.Macros.
|
|
*
|
|
* August 2, 1988 Suki Lee
|
|
* Bug Fix:
|
|
* - In system disk 4.0, the ID string from the LQ arrives sooner than the firm-
|
|
* ware is ready to read it (due to interrupts). I/O buffering will have to be
|
|
* enabled right after initialization rather than just before a read. Moved the
|
|
* buffer enable code from DevRead to DevOpen. Also took out call to GetModeBits
|
|
* to check if buffering is already on since it doesn't hurt to have it on.
|
|
*
|
|
* August 12, 1988
|
|
* Bug FIx:
|
|
* - Carry was not set correctly after DevWrite, causing problems in the ImageWriter
|
|
* driver when printing in draft mode.
|
|
*
|
|
* v2.0
|
|
* d1 October 10, 1988 Suki Lee
|
|
* Fixed DevStartUp to remove two pointers off the stack since the same call in
|
|
* the AppleTalk driver uses two pointers as input.
|
|
*
|
|
* d2 December 2, 1988 Suki Lee
|
|
* The new ROM allows slot 1 and 2 to be selectable among 3 options: Printer
|
|
* (or Modem), AppleTalk, or Your Card. The present code checks the slot state
|
|
* to determine if the slot is internal or external. This will not work for new
|
|
* ROMs since AppleTalk is considered internal. The code is modified to check
|
|
* ROM version number and check the appropriate location to determine if the slot
|
|
* is configured correctly.
|
|
*
|
|
* d3 December 16, 1988 Suki Lee
|
|
* Added new header to denote this as a driver which will support new calls.
|
|
* This header is 2 words long: first word is 0 followed by a call count word.
|
|
*
|
|
* d4 January 6, 1989 Suki Lee
|
|
* Buffering in the firmware is enabled so we can read the self ID response from
|
|
* the printer. There is problem with handshaking with the printer if the buffer
|
|
* is turned off so we left it on. AppleWorks GS ran into a problem where the
|
|
* reset for the next page happens before last part of the page is finished,
|
|
* losing the remaining data. Mike Askins suggests adding code to query the output
|
|
* queue to make sure it is empty before the next firmware reset. Also added a
|
|
* flag to skip the query if the firmware has not been initialized.
|
|
*
|
|
* d5 January 18, 1989 Suki Lee
|
|
* Removed DevInitBack since none of the code is used. Replaced it with DevAsyncRead
|
|
* with the corrected number of parameters, 4 instead of 3. Renamed DevFillBack to
|
|
* DevWriteBack and corrected the number of parameters from 2 to 3. Both these calls
|
|
* currently do nothing and are not used by the printer drivers.
|
|
*
|
|
* January 25, 1989 Suki Lee
|
|
* Added code to reset firmware after printing so the firmware's buffers will be
|
|
* deallocated. Also added code to remember and reset the output redirection back
|
|
* to the way we found it.
|
|
*
|
|
* May 25, 1989 Suki Lee
|
|
* Moved the code which queries the output buffer from DevOpen to DevClose, just
|
|
* before the firmware init call. The firmware was being initialized before the
|
|
* buffer is cleared causing the system to hang in DevOpen for the next job, waiting
|
|
* for a buffer which has been deallocated to clear.
|
|
*
|
|
* August 22, 1989 Ben Koning
|
|
* Added a zap ("Ignore all subsequent ^I commands") command to DevOpen, so that
|
|
* ^I's ($09 or $89) in the data stream won't be interpreted and filtered out by
|
|
* the firmware. Removed similar zap code from DevRead.
|
|
*
|
|
*
|
|
* v2.1
|
|
*
|
|
* d1 December 15, 1989 Suki Lee
|
|
* Modified the stack offset for DevAsyncRead to not include dpage and bank address
|
|
* since the call never switches dpage.
|
|
*
|
|
* d2 January 2, 1990 Ben Koning
|
|
* Modified to not use pushptr macro.
|
|
*
|
|
* d3 May 3, 1990 Ben Koning
|
|
* If the Battery-RAM parameters indicate 19.2K baud with all other default settings, we
|
|
* bypass the texttool/serial-firmware and communicate with the SCC chip directly in the
|
|
* DevWrite call only. This allows true 19.2K baud output until a better SCC driver
|
|
* is written. 2X perfomance gain; important for high resolution printers such as LQ, which
|
|
* becomes about 72% faster.
|
|
*
|
|
* d4 May 26, 1990 Ben Koning
|
|
* Same change as in PRINTER port driver: If the current printer driver is version 4.0 or
|
|
* greater then the timeout delay in PrDevRead is about 2 seconds, instead of about 45
|
|
* seconds. Critical for backward compatibility with old IW driver, which does head
|
|
* recalibration just before doing a read and so must have a longer timeout delay.
|
|
*
|
|
* d5 June 4, 1990 Ben Koning
|
|
* In the 19.2K baud handling code, the DCD and DSR handshake lines weren't being checked.
|
|
*
|
|
*****************************************************************
|
|
|
|
*****************************************************************
|
|
*
|
|
* Copyright 1986-1990
|
|
* Apple Computer, Inc.
|
|
* All Rights Reserved
|
|
*
|
|
*****************************************************************
|
|
|
|
;------------------------------------------
|
|
;
|
|
; Equates from procedure
|
|
;
|
|
;------------------------------------------
|
|
VersionNb equ $0201 ; Version 2.1
|
|
NoError equ 0 ; No error
|
|
PortNotOn equ $1302 ; Port not active
|
|
True equ $FFFF
|
|
False equ $0000
|
|
|
|
;-----------------------------------------------
|
|
;
|
|
; Imported addresses
|
|
;
|
|
;-----------------------------------------------
|
|
|
|
IMPORT alerttemp320
|
|
IMPORT alerttemp640
|
|
|
|
;-----------------------------------------------
|
|
;
|
|
; Forward addresses and entries
|
|
;
|
|
;-----------------------------------------------
|
|
|
|
ENTRY CallCompletion
|
|
ENTRY Completion
|
|
ENTRY DevAsyncRead
|
|
ENTRY DevClose
|
|
ENTRY DevWriteBack
|
|
ENTRY DevIsItSafe
|
|
ENTRY DevOpen
|
|
ENTRY DevPrChanged
|
|
ENTRY DevRead
|
|
ENTRY DevShutDown
|
|
ENTRY DevStartup
|
|
ENTRY DevStatus
|
|
ENTRY DevWrite
|
|
ENTRY Exit10
|
|
ENTRY Exit4
|
|
ENTRY Exit6
|
|
ENTRY Exit8
|
|
ENTRY IsItSafe
|
|
ENTRY PortAlert
|
|
ENTRY PrPortVer
|
|
ENTRY exit0
|
|
|
|
* Absaddr on
|
|
* Keep modem
|
|
include 'all.macros'
|
|
|
|
|
|
EXPORT Modmeport
|
|
Modmeport PROC
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Header to denote new calls supported
|
|
;
|
|
|
|
DC.W 0 ; marker
|
|
DC.W (EndProcList-ProcList)/4 ; count of calls supported
|
|
|
|
jmp (ProcList,x)
|
|
rtl
|
|
|
|
EXPORT ProcList
|
|
ProcList DC.L DevPrChanged
|
|
DC.L DevStartup
|
|
DC.L DevShutDown
|
|
DC.L DevOpen
|
|
DC.L DevRead
|
|
DC.L DevWrite
|
|
DC.L DevClose
|
|
DC.L DevStatus
|
|
DC.L DevAsyncRead
|
|
DC.L DevWriteBack
|
|
DC.L PrPortVer
|
|
DC.L DevIsItSafe
|
|
EndProcList
|
|
|
|
ENDP
|
|
; Copy Device.mod
|
|
***************************************************************
|
|
*
|
|
* PrPortVer
|
|
*
|
|
* Returns version # of currently installed port
|
|
*
|
|
***************************************************************
|
|
EXPORT PrPortVer
|
|
PrPortVer PROC
|
|
DefineStack
|
|
Rtl1 Block 3
|
|
Rtl2 Block 3
|
|
Version Word 0
|
|
|
|
lda #VersionNb
|
|
sta Version,s
|
|
|
|
lda #0
|
|
jmp exit0
|
|
|
|
ENDP
|
|
|
|
|
|
***************************************************************
|
|
*
|
|
* DevPrChanged
|
|
*
|
|
* PtrToName LONG
|
|
*
|
|
*
|
|
*
|
|
***************************************************************
|
|
EXPORT DevPrChanged
|
|
DevPrChanged PROC
|
|
|
|
|
|
jsr IsItSafe
|
|
bcc Yes
|
|
|
|
pha
|
|
jsr PortAlert
|
|
pla
|
|
|
|
Yes jmp Exit4
|
|
|
|
ENDP
|
|
|
|
|
|
***************************************************************
|
|
*
|
|
* DevStartup
|
|
*
|
|
* LONG pointer to printer name
|
|
* LONG pointer to zone name
|
|
*
|
|
* call does nothing for serial ports
|
|
*
|
|
***************************************************************
|
|
EXPORT DevStartup
|
|
DevStartup PROC
|
|
|
|
jsr IsItsafe
|
|
jmp Exit8
|
|
|
|
ENDP
|
|
|
|
***************************************************************
|
|
*
|
|
* DevShutDown
|
|
*
|
|
* no inputs
|
|
*
|
|
***************************************************************
|
|
EXPORT DevShutDown
|
|
DevShutDown PROC
|
|
|
|
jsr IsItSafe
|
|
jmp Exit0
|
|
|
|
ENDP
|
|
|
|
***************************************************************
|
|
*
|
|
* DevOpen
|
|
*
|
|
* OpenCompletion LONG
|
|
* Reserved LONG
|
|
*
|
|
***************************************************************
|
|
EXPORT DevOpen
|
|
DevOpen PROC
|
|
DefineStack
|
|
DevOpen_DPage word 0
|
|
DevOpen_BReg byte 0
|
|
DevOpen_rtl1 block 3
|
|
DevOpen_rtl2 block 3
|
|
Reserved long 0
|
|
OpenCompletion long 0
|
|
|
|
jsr IsItSafe
|
|
bcc Yes
|
|
jmp Exit8
|
|
|
|
EXPORT Yes
|
|
Yes ;
|
|
|
|
phd
|
|
phb
|
|
phk
|
|
plb
|
|
lda OpenCompletion,s
|
|
sta Completion
|
|
lda OpenCompletion+2,s
|
|
sta Completion+2
|
|
|
|
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Find out what printer driver is requesting our services. If v4.0 or greater, then
|
|
; setup for shorter read-call timeout delay.
|
|
;
|
|
stz IsNewPrDrvrFlag
|
|
pha
|
|
_PrDriverVer
|
|
pla
|
|
cmp #$0400
|
|
bcc isnewpr_no
|
|
lda #1
|
|
sta IsNewPrDrvrFlag
|
|
isnewpr_no
|
|
|
|
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Need to save all old settings for input and output device for restoring later
|
|
; in DevClose.
|
|
;
|
|
|
|
lda #0
|
|
pha ; word space
|
|
pha
|
|
pha ; long space
|
|
_GetInputDevice
|
|
pla
|
|
sta InputSlot
|
|
pla ; high word
|
|
sta InputSlot+2
|
|
pla
|
|
sta InputType
|
|
|
|
lda #0
|
|
pha ; two word spaces
|
|
pha
|
|
_GetInGlobals
|
|
pla
|
|
sta InOrMask
|
|
pla
|
|
sta InAndMask
|
|
|
|
lda #0
|
|
pha ; word space
|
|
pha
|
|
pha ; long space
|
|
_GetOutputDevice
|
|
pla
|
|
sta OutputSlot
|
|
pla ; high word
|
|
sta OutputSlot+2
|
|
pla
|
|
sta OutputType
|
|
|
|
lda #0
|
|
pha ; two word spaces
|
|
pha
|
|
_GetOutGlobals
|
|
pla
|
|
sta OutOrMask
|
|
pla
|
|
sta OutAndMask
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Set it up for our use now
|
|
;
|
|
|
|
PushWord #1
|
|
PushLong #2
|
|
_setInputDevice
|
|
|
|
PushWord #$ffff
|
|
PushWord #0
|
|
_setInGlobals
|
|
|
|
PushWord #0
|
|
_inittextDev
|
|
|
|
PushWord #1
|
|
PushLong #2
|
|
_setOutputDevice
|
|
|
|
PushWord #$ffff
|
|
PushWord #0
|
|
_setoutGlobals
|
|
|
|
PushWord #1
|
|
_inittextDev
|
|
|
|
pushlong #InitGraph+1 ; newly added
|
|
pushword #0
|
|
lda InitGraph
|
|
and #$00ff
|
|
pha
|
|
_TextWriteBlock
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; We need to enable the buffering for input characters via the firmware.
|
|
; Experience has shown that if the input buffering is disabled, we can
|
|
; only get two characters from the ReadLine call.
|
|
;
|
|
|
|
pushlong #BuffEnable ; turn I/O buffering on
|
|
_WriteString
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Finally, make sure that no characters are interpreted by the firmware
|
|
; as commands (ie, send all data RAW).
|
|
;
|
|
|
|
pushlong #Zap ; ignore all subsequent ^I commands
|
|
_WriteString
|
|
|
|
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Check to see if the Battery-RAM settings for slot 2 imply 19.2K baud/"printer connected"
|
|
; with all other default options. If so, then set flag to allow direct
|
|
; SCC communication/firware bypass kludge for greater speed.
|
|
;
|
|
|
|
NKBaudQualify
|
|
|
|
stz NKBaudEnableFlag ;clear enable flag; assume not defaults/19.2KB
|
|
|
|
ldy #0 ;prepare to loop to check BRAM against our table
|
|
NKBaudQualLoop phy ;save Y = index into tables
|
|
lda NKBaudBattRAMLocs,y ;find out a BRAM parameter that we should check
|
|
pha ;result space
|
|
pha ;pass BRAM param no.
|
|
_ReadBParam
|
|
pla ;obtain BRAM value
|
|
ply ;restore Y = index into tables
|
|
cmp NKBaudBattRAMVals,y ;compare BRAM value against table
|
|
bne NKBaudQualDone ;break off the search as soon as one doesn't match
|
|
iny ;else continue checking
|
|
iny
|
|
cpy #NKBaudBattRAMLen
|
|
bne NKBaudQualLoop
|
|
lda #1 ;all BRAM params are as we want, so set enable flag
|
|
sta NKBaudEnableFlag
|
|
|
|
NKBaudQualDone
|
|
|
|
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Call user's completion routine, if any, and exit.
|
|
|
|
jsl CallCompletion
|
|
plb
|
|
pld
|
|
jmp Exit8
|
|
|
|
EXPORT CallCompletion
|
|
CallCompletion ;
|
|
lda Completion
|
|
ora Completion+2
|
|
bne doit
|
|
Rtl
|
|
EXPORT Doit
|
|
Doit ;
|
|
lda Completion+1
|
|
pha
|
|
phb
|
|
pla
|
|
lda Completion
|
|
sec
|
|
sbc #1
|
|
pha
|
|
rtl
|
|
EXPORT Completion
|
|
Completion ;
|
|
DS.B 4
|
|
|
|
EXPORT InitGraph
|
|
InitGraph DC.B 14
|
|
DC.B 09,67,68 ; disable line length
|
|
DC.B 09,84 ; disable basic tab
|
|
DC.B 09,70,68 ; disable keyboard input
|
|
DC.B 09,77,68 ; disable filtering LF
|
|
DC.B 09,76,68 ; disable LF after CF
|
|
|
|
Zap DC.B 2
|
|
DC.B $09
|
|
DC.B 'Z' ; zap
|
|
|
|
BuffEnable DC.B 3 ; length
|
|
DC.B $09 ; Control-I
|
|
DC.B 'BE' ; Enable buffer
|
|
|
|
|
|
|
|
export IsNewPrDrvrFlag
|
|
IsNewPrDrvrFlag dc.w 0
|
|
|
|
|
|
|
|
NKBaudBattRAMLen equ 2*11
|
|
NKBaudBattRAMLocs dc.w $14,$12,$0D,$13,$0E,$0F,$11,$10,$15,$16,$17
|
|
NKBaudBattRAMVals dc.w 2,14,0,6,0,0,0,0,1,1,0
|
|
|
|
export NKBaudEnableFlag
|
|
NKBaudEnableFlag dc.w 0
|
|
|
|
|
|
|
|
EXPORT InputSlot
|
|
InputSlot DS.B 4
|
|
EXPORT InputType
|
|
InputType DS.B 2
|
|
EXPORT InOrMask
|
|
InOrMask DS.B 2
|
|
EXPORT InAndMask
|
|
InAndMask DS.B 2
|
|
EXPORT OutputSlot
|
|
OutputSlot DS.B 4
|
|
EXPORT OutputType
|
|
OutputType DS.B 2
|
|
EXPORT OutOrMask
|
|
OutOrMask DS.B 2
|
|
EXPORT OutAndMask
|
|
OutAndMask DS.B 2
|
|
|
|
ENDP
|
|
|
|
|
|
***************************************************************
|
|
*
|
|
* DevRead
|
|
*
|
|
* Input: PutToBuffer LONG
|
|
* Max to Xfer WORD
|
|
*
|
|
* Output: Bytes read WORD
|
|
*
|
|
***************************************************************
|
|
EXPORT DevRead
|
|
DevRead PROC
|
|
DefineStack
|
|
DevRead_DPage word 0
|
|
DevRead_BReg byte 0
|
|
DevRead_rtl1 block 3
|
|
DevRead_rtl2 block 3
|
|
ReadRqd word 0
|
|
PtrReadBuf long 0
|
|
readTrnsfrd word 0
|
|
|
|
|
|
jsr IsItSafe
|
|
bcc Yes
|
|
jmp Exit6
|
|
|
|
Yes ;
|
|
|
|
phd
|
|
phb
|
|
phk
|
|
plb
|
|
|
|
lda PtrReadBuf+2,s
|
|
sta readBuf+2
|
|
lda PtrReadBuf,s
|
|
sta readBUf
|
|
lda ReadRqd,s
|
|
sta requestCount
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Aug 2, 1988 Suki Lee
|
|
; Moved buffer enable code to DevOpen. Also removed extended interface call
|
|
; to firmware to check if buffer is enabled
|
|
;
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; This read routine has a timeout delay. In the old printer drivers (<4.0),
|
|
; the status-query read is done right after the given command to perform
|
|
; head recalibration.
|
|
;
|
|
; The ImageWriter II will not respond while the print head is moving.
|
|
; Since we always reset the printer for each print job, it means that
|
|
; the head is always moving. The only difference is the distance it has
|
|
; to travel to the left edge. This counter value will work for the worst
|
|
; case of when the printer was at the right edge when it was reset. The
|
|
; wait is noticable on ImageWriter I's since it has to wait out the whole
|
|
; count.
|
|
;
|
|
; The above will now happen only if the current printer driver version is
|
|
; less than 4.0; otherwise, a much shorter timeout value is used.
|
|
;
|
|
|
|
lda #$FFFF ; wait loop counter = $FFFF if old printer driver (~45 s)
|
|
import IsNewPrDrvrFlag
|
|
ldx IsNewPrDrvrFlag
|
|
beq setup_counter
|
|
lda #$0B00 ; wait loop counter is less if new printer driver (~2 s)
|
|
setup_counter sta counter
|
|
|
|
LoopStatus
|
|
lda #0
|
|
pha
|
|
pha
|
|
pha
|
|
pha ; result spaces
|
|
inc a ; A reg: input request = 1
|
|
pha
|
|
lda #$00C2 ; X reg
|
|
pha
|
|
lda #$0020 ; Y reg
|
|
pha
|
|
lda >$00C210 ; status offset
|
|
clc
|
|
adc #$C200 ; entry point
|
|
pha
|
|
_FWEntry
|
|
pla
|
|
pla
|
|
pla
|
|
pla ; get processor status
|
|
xba ; only high byte is valid
|
|
and #$0001 ; check the carry bit
|
|
bne TimeToRead ; 0 means not ready yet
|
|
lda counter
|
|
dec a
|
|
beq Exit
|
|
sta counter
|
|
bra loopStatus
|
|
|
|
TimeToRead pha ; result: actual read count
|
|
PushLong readBuf
|
|
lda requestCount ; amount to be read
|
|
pha
|
|
lda #$0D ; EOL char = carriage return
|
|
pha
|
|
lda #0
|
|
pha ; don't echo
|
|
_ReadLine
|
|
pla
|
|
Exit sta ReadTrnsfrd,s
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; The following two line of code were taken out because it cause some
|
|
; problem with handshaking between the firmware and the printer. Mike
|
|
; Askins is unsure of the exact cause at this point and this code is
|
|
; left here so a test case can be recreated for him
|
|
;
|
|
|
|
; pushlong #BuffDisable ; we did, so we turn it back off
|
|
; _WriteString
|
|
|
|
plb
|
|
pld
|
|
jmp Exit6
|
|
|
|
|
|
readBuf DS.B 4
|
|
requestCount DS.B 2
|
|
counter DS.B 2
|
|
|
|
ENDP
|
|
|
|
***************************************************************
|
|
*
|
|
* DevWrite
|
|
*
|
|
* Writecompletion LONG
|
|
* PtrToBuffer LONG
|
|
* Length WORD
|
|
*
|
|
***************************************************************
|
|
EXPORT DevWrite
|
|
DevWrite PROC
|
|
DefineStack
|
|
DevWrite_DPage word 0
|
|
DevWrite_BReg byte 0
|
|
DevWrite_rtl1 block 3
|
|
DevWrite_rtl2 block 3
|
|
WriteLengths word 0
|
|
WritePtrBuff long 0
|
|
WriteCompletion long 0
|
|
|
|
|
|
|
|
jsr IsItSafe
|
|
bcc WriteSafe
|
|
brl Exit10
|
|
|
|
WriteSafe
|
|
phd ;save D, save B, do B=K
|
|
phb
|
|
phk
|
|
plb
|
|
lda WriteCompletion,s ;setup so we can call user's completion routine
|
|
sta Completion+0
|
|
lda WriteCompletion+2,s
|
|
sta Completion+2
|
|
|
|
|
|
|
|
import NKBaudEnableFlag ;check to see if default/19.2KBaud is selected
|
|
lda NKBaudEnableFlag ;if so then do our fast shortcut kludge
|
|
beq WriteNKBNo ;otherwise write the data through the firmware
|
|
|
|
WriteNKBYes
|
|
lda WritePtrBuff+0,s ;writing the data out directly to the SCC chip...
|
|
sta WriteNKBGetData+1 ;set up stuffed operands
|
|
lda WritePtrBuff+2,s
|
|
shortm
|
|
sta WriteNKBGetData+3
|
|
longm
|
|
lda WriteLengths,s
|
|
sta WriteNKBCmpLen+1
|
|
|
|
ldx #0 ;init counter into user's data, set 8-bit mode
|
|
shortm
|
|
WriteNKBLoop lda >$E0C038 ;poll SCC ch. B command register bit, see if chip ready
|
|
tay
|
|
bit #%00000100 ;check: b5)DSR, b3)DCD, b2)TxBuffer ready
|
|
beq WriteNKBLoop
|
|
tya
|
|
bit #%00100000
|
|
beq WriteNKBLoop
|
|
tya
|
|
bit #%00001000
|
|
beq WriteNKBLoop
|
|
WriteNKBGetData lda >$FFFFFF,x ;NOTE: operand is stuffed. get a byte from user
|
|
sta >$E0C03A ;write into SCC ch. B data register
|
|
inx ;advance our pointer into user's data
|
|
WriteNKBCmpLen cpx #$FFFF ;NOTE: operand is stuffed
|
|
bcc WriteNKBLoop
|
|
longm ;reset to 16-bit mode when done
|
|
|
|
jsl CallCompletion ;call user's routine, restore B/D, exit no error
|
|
lda #0
|
|
plb
|
|
pld
|
|
brl Exit10
|
|
|
|
WriteNKBNo
|
|
|
|
|
|
|
|
lda WritePtrBuff+2,s ;writing the data out through the serial firmware...
|
|
pha
|
|
lda WritePtrBuff+2,s
|
|
pha
|
|
lda WriteLengths+4,s
|
|
tax
|
|
lda #0
|
|
pha
|
|
phx
|
|
_TextWriteBlock ;text tool call, calls serial firmware
|
|
|
|
pha ;exiting: save error
|
|
jsl CallCompletion ;call user's routine
|
|
pla ;restore error in A
|
|
plb ;restore B, restore D, and exit
|
|
pld
|
|
brl Exit10
|
|
|
|
|
|
|
|
ENDP
|
|
|
|
|
|
|
|
|
|
***************************************************************
|
|
*
|
|
* DevClose
|
|
*
|
|
* no parameters
|
|
*
|
|
***************************************************************
|
|
EXPORT DevClose
|
|
DevClose PROC
|
|
|
|
jsr IsItSafe
|
|
bcc CloseSafe
|
|
Jmp Exit0
|
|
|
|
CloseSafe
|
|
phd
|
|
phb
|
|
phk
|
|
plb
|
|
|
|
php
|
|
sei ; disable interrupts
|
|
|
|
lda #0
|
|
pha
|
|
pha
|
|
pha
|
|
pha ; result spaces
|
|
lda #GetModeBitsParam
|
|
tax
|
|
and #$00FF ; A reg: low byte of address of parameters
|
|
pha
|
|
txa ; X reg: mid byte of address
|
|
xba
|
|
and #$00FF
|
|
pha
|
|
lda #^GetModeBitsParam ; Y reg: high byte of address
|
|
and #$00FF
|
|
pha
|
|
lda >$00C212 ; extended interface offset
|
|
clc
|
|
adc #$C200 ; entry point
|
|
pha
|
|
_FWEntry
|
|
pla
|
|
pla
|
|
pla
|
|
pla
|
|
|
|
lda GetModeBits
|
|
sta SetModeBits
|
|
lda GetModeBits+2
|
|
and #$FF7F ; clear the zap bit
|
|
sta SetModeBits+2
|
|
|
|
lda #0
|
|
pha
|
|
pha
|
|
pha
|
|
pha ; result spaces
|
|
lda #SetModeBitsParam
|
|
tax
|
|
and #$00FF ; A reg: low byte of address of parameters
|
|
pha
|
|
txa ; X reg: mid byte of address
|
|
xba
|
|
and #$00FF
|
|
pha
|
|
lda #^SetModeBitsParam ; Y reg: high byte of address
|
|
and #$00FF
|
|
pha
|
|
lda >$00C212 ; extended interface offset
|
|
clc
|
|
adc #$C200 ; entry point
|
|
pha
|
|
_FWEntry
|
|
pla
|
|
pla
|
|
pla
|
|
pla
|
|
|
|
plp ; reenable interrupt
|
|
|
|
lda #0
|
|
pha
|
|
pha
|
|
pha
|
|
pha ; result spaces
|
|
lda #GetOutBufferParam
|
|
tax
|
|
and #$00FF ; A reg: low byte of address of parameters
|
|
pha
|
|
txa ; X reg: mid byte of address
|
|
xba
|
|
and #$00FF
|
|
pha
|
|
lda #^GetOutBufferParam ; Y reg: high byte of address
|
|
and #$00FF
|
|
pha
|
|
lda >$00C212 ; extended interface offset
|
|
clc
|
|
adc #$C200 ; entry point
|
|
pha
|
|
_FWEntry
|
|
pla
|
|
pla
|
|
pla
|
|
pla
|
|
|
|
loopQuery lda #0
|
|
pha
|
|
pha
|
|
pha
|
|
pha ; result spaces
|
|
lda #OutQStatusParam
|
|
tax
|
|
and #$00FF ; A reg: low byte of address of parameters
|
|
pha
|
|
txa ; X reg: mid byte of address
|
|
xba
|
|
and #$00FF
|
|
pha
|
|
lda #^OutQStatusParam ; Y reg: high byte of address
|
|
and #$00FF
|
|
pha
|
|
lda >$00C212 ; extended interface offset
|
|
clc
|
|
adc #$C200 ; entry point
|
|
pha
|
|
_FWEntry
|
|
pla
|
|
pla
|
|
pla
|
|
pla
|
|
lda BufferLeng
|
|
dec a
|
|
cmp SpaceLeft
|
|
bne loopQuery
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Reset the firmware so the buffer will be disposed of
|
|
;
|
|
|
|
pushlong #ResetFW
|
|
_WriteString
|
|
|
|
|
|
;-----------------------------------------------------------
|
|
;
|
|
; Reset the input and output devices to whatever it was before we changed it.
|
|
;
|
|
|
|
PushWord InputType ; Pascal device type
|
|
PushLong InputSlot ; slot number
|
|
_setInputDevice
|
|
|
|
PushWord InAndMask
|
|
PushWord InOrMask
|
|
_setInGlobals
|
|
|
|
PushWord #0
|
|
_inittextDev
|
|
|
|
PushWord OutputType ; Pascal device type
|
|
PushLong OutputSlot ; slot number
|
|
_setOutputDevice
|
|
|
|
PushWord OutAndMask
|
|
PushWord OutOrMask
|
|
_setoutGlobals
|
|
|
|
PushWord #1
|
|
_inittextDev
|
|
|
|
plb
|
|
pld
|
|
jmp Exit0
|
|
|
|
|
|
GetModeBitsParam
|
|
DC.B $03 ; parameter count
|
|
DC.B $00 ; command code for GetModeBits
|
|
DS.B 2 ; result code
|
|
GetModeBits DS.B 4 ; Mode bits
|
|
|
|
SetModeBitsParam
|
|
DC.B $03 ; parameter count
|
|
DC.B $01 ; command code for SetModeBits
|
|
DS.B 2 ; result code
|
|
SetModeBits DS.B 4 ; Mode bits
|
|
|
|
GetOutBufferParam
|
|
DC.B $04 ; parameter count
|
|
DC.B $11 ; command code for GetOutBuffer
|
|
DS.B 2 ; result code
|
|
DS.B 4 ; buffer address
|
|
BufferLeng DS.B 2 ; buffer length
|
|
|
|
OutQStatusParam
|
|
DC.B $04 ; parameter count
|
|
DC.B $17 ; command code for OutQStatus
|
|
DS.B 2 ; result code
|
|
SpaceLeft DS.B 2 ; number of char in output queue
|
|
DS.B 2 ; reserved
|
|
|
|
ResetFW DC.B 3 ; length
|
|
DC.B $09 ; Control-I
|
|
DC.B 'R' ; Reset firmware
|
|
DC.B $0D ; carriage return
|
|
|
|
ENDP
|
|
|
|
|
|
***************************************************************
|
|
*
|
|
* DevStatus
|
|
*
|
|
* ??????? LONG
|
|
*
|
|
***************************************************************
|
|
EXPORT DevStatus
|
|
DevStatus PROC
|
|
|
|
jsr IsItSafe
|
|
jmp Exit4
|
|
|
|
ENDP
|
|
|
|
***************************************************************
|
|
*
|
|
* DevAsyncRead
|
|
*
|
|
* CompletionRoutine LONG
|
|
* RequestCount WORD
|
|
* PtrToBuffer LONG
|
|
*
|
|
* output:
|
|
* actual length read WORD
|
|
*
|
|
***************************************************************
|
|
EXPORT DevAsyncRead
|
|
DevAsyncRead PROC
|
|
DefineStack
|
|
|
|
AsyncRead_rtl1 block 3
|
|
AsyncRead_rtl2 block 3
|
|
ReadBuffer long 0
|
|
ReadLength word 0
|
|
ReadComplete long 0
|
|
ActualLength word 0
|
|
|
|
jsr IsItSafe
|
|
bcc Yes
|
|
jmp Exit10
|
|
|
|
Yes ;
|
|
lda #0
|
|
sta actualLength,s
|
|
|
|
jmp Exit10
|
|
|
|
|
|
ENDP
|
|
|
|
|
|
|
|
***************************************************************
|
|
*
|
|
* DevWriteBack
|
|
* Completion routine ptr
|
|
* BufferSize
|
|
* BufferAddress
|
|
*
|
|
***************************************************************
|
|
EXPORT DevWriteBack
|
|
DevWriteBack PROC
|
|
|
|
jsr IsItSafe
|
|
jmp Exit10
|
|
|
|
ENDP
|
|
|
|
***************************************************************
|
|
*
|
|
* DevIsItSafe
|
|
*
|
|
* Output: Safety WORD boolean
|
|
*
|
|
*
|
|
* EntryPoint to driver from outside.
|
|
*
|
|
* Safety is true if it is safe, false if not.
|
|
*
|
|
***************************************************************
|
|
EXPORT DevIsItSafe
|
|
DevIsItSafe PROC
|
|
DefineStack
|
|
Rtl1 block 3
|
|
Rtl2 block 3
|
|
Result word
|
|
|
|
jsr IsItSafe
|
|
bcc Yes
|
|
|
|
lda #False
|
|
sta Result,s
|
|
|
|
Join lda #0
|
|
jmp Exit0
|
|
|
|
Yes lda #True
|
|
sta Result,s
|
|
bra Join
|
|
|
|
ENDP
|
|
|
|
|
|
|
|
****************************************************************
|
|
*
|
|
* PortAlert
|
|
*
|
|
* Alert box to tell user that the appropriate port is not turned
|
|
* on.
|
|
*
|
|
* no parameters on stack
|
|
*
|
|
****************************************************************
|
|
EXPORT PortAlert
|
|
PortAlert PROC
|
|
|
|
|
|
_InitCursor ; restore cursor back to arrow
|
|
|
|
pha ; make room for result
|
|
_GetMasterSCB
|
|
pla
|
|
pha ; make room for result of alert call
|
|
and #$80 ; check mode
|
|
beq mode320 ; 320 mode
|
|
|
|
pushlong #alerttemp640 ; use 640 mode template
|
|
bra GoOn
|
|
|
|
mode320 pushlong #alerttemp320 ; use 320 mode template
|
|
|
|
GoOn pushlong #$0000
|
|
_StopAlert
|
|
|
|
; jsr WaitCursor ; set to watch again
|
|
|
|
pla ; get the item hit off stack
|
|
|
|
rts
|
|
|
|
|
|
ENDP
|
|
|
|
***************************************************************
|
|
*
|
|
* IsItSafe
|
|
*
|
|
* Returns carry set if and a-reg with error code if it is
|
|
* not safe.
|
|
*
|
|
* A-reg is clear and carry clear if it is safe.
|
|
*
|
|
*
|
|
***************************************************************
|
|
EXPORT IsItSafe
|
|
IsItSafe PROC
|
|
|
|
lda >$E0C02D ; Read slot state.
|
|
and #$0004 ; bit 2 set means external
|
|
bne NotOn
|
|
|
|
pha ; it's internal, so find out if it's
|
|
pha ; AppleTalk or serial firmware
|
|
pha
|
|
pha ; 4 word spaces for result
|
|
pha ; A reg value, don't care
|
|
pha ; x reg value, don't care
|
|
pha ; y reg value, don't care
|
|
lda #$FE1F ; the entry point to a routine which
|
|
pha ; returns system information
|
|
_FWEntry
|
|
pla ; Y register has ROM version
|
|
plx ; get unused values off stack
|
|
plx
|
|
plx
|
|
and #$00FF ; in bits 7 - 0
|
|
cmp #3 ; Version 3 or greater has AppleTalk
|
|
blt ExitSafe ; in slots 1 or 2
|
|
|
|
lda >$E101C0 ; Read AppleTalk port location
|
|
and #$00FF ; lo byte only
|
|
cmp #2 ; AppleTalk is in Slot 2
|
|
bne ExitSafe
|
|
|
|
NotOn lda #PortNotOn ; set error to port not turned on
|
|
bra ExitNotSafe
|
|
|
|
ExitSafe
|
|
lda #0 ; no problems
|
|
ExitNotSafe cmp #1
|
|
rts
|
|
ENDP
|
|
|
|
; Copy DynamicExits
|
|
EXPORT DynamicExits
|
|
DynamicExits PROC
|
|
* in a Dynamic exit we need to save 2 RTLs
|
|
|
|
EXPORT exit20
|
|
exit20 ;
|
|
tax
|
|
lda 5,s
|
|
sta 25,s
|
|
lda 3,s
|
|
sta 23,s
|
|
lda 1,s
|
|
sta 21,s
|
|
tsc
|
|
clc
|
|
adc #20
|
|
tcs
|
|
txa
|
|
brl exit0
|
|
|
|
EXPORT Exit16
|
|
Exit16 ;
|
|
tax
|
|
lda 5,s
|
|
sta 21,s
|
|
lda 3,s
|
|
sta 19,s
|
|
lda 1,s
|
|
sta 17,s
|
|
tsc
|
|
clc
|
|
adc #16
|
|
tcs
|
|
txa
|
|
brl Exit0
|
|
|
|
EXPORT Exit14
|
|
Exit14 ;
|
|
tax
|
|
lda 5,s
|
|
sta 19,s
|
|
lda 3,s
|
|
sta 17,s
|
|
lda 1,s
|
|
sta 15,s
|
|
tsc
|
|
clc
|
|
adc #14
|
|
tcs
|
|
txa
|
|
brl Exit0
|
|
|
|
EXPORT Exit12
|
|
Exit12 ;
|
|
tax
|
|
lda 5,s
|
|
sta 17,s
|
|
lda 3,s
|
|
sta 15,s
|
|
lda 1,s
|
|
sta 13,s
|
|
tsc
|
|
clc
|
|
adc #12
|
|
tcs
|
|
txa
|
|
bra Exit0
|
|
|
|
EXPORT Exit10
|
|
Exit10 ;
|
|
tax
|
|
lda 5,s
|
|
sta 15,s
|
|
lda 3,s
|
|
sta 13,s
|
|
lda 1,s
|
|
sta 11,s
|
|
tsc
|
|
clc
|
|
adc #10
|
|
tcs
|
|
txa
|
|
brl Exit0
|
|
|
|
EXPORT Exit8
|
|
Exit8 ;
|
|
tax ; Standart 8 bytes input exit
|
|
lda 5,s
|
|
sta 13,s
|
|
lda 3,s
|
|
sta 11,s
|
|
lda 1,s
|
|
sta 9,s
|
|
pla
|
|
pla
|
|
pla
|
|
pla
|
|
txa
|
|
brl Exit0
|
|
|
|
EXPORT Exit6
|
|
Exit6 ;
|
|
tax ; Standard 6 bytes input exit
|
|
lda 5,s
|
|
sta 11,s
|
|
lda 3,s
|
|
sta 9,s
|
|
lda 1,s
|
|
sta 7,s
|
|
pla
|
|
pla
|
|
pla
|
|
txa
|
|
brl Exit0
|
|
|
|
EXPORT Exit4
|
|
Exit4 ;
|
|
tax ; Standard 4 bytes input exit
|
|
lda 5,s
|
|
sta 9,s
|
|
lda 3,s
|
|
sta 7,s
|
|
lda 1,s
|
|
sta 5,s
|
|
pla
|
|
pla
|
|
txa
|
|
brl Exit0
|
|
|
|
EXPORT Exit2
|
|
Exit2 ;
|
|
tax ; Standard 2 bytes input exit
|
|
lda 5,s
|
|
sta 7,s
|
|
lda 3,s
|
|
sta 5,s
|
|
lda 1,s
|
|
sta 3,s
|
|
pla
|
|
txa
|
|
EXPORT Exit0
|
|
Exit0 ;
|
|
cmp #1 ; Standard 0 byte input exit
|
|
rtl
|
|
|
|
ENDP
|
|
|
|
END
|