; --- Debug_ParallelPrint ($022A, code) ---
; Parallel-port (Centronics-style) debug print: A0 = null-terminated string.
; CIAA PRB ($BFE101) = parallel data port (all outputs via DDRB $BFE301).
; CIAA ICR ($BFED01) bit 4 = FLAG (parallel strobe/acknowledge input).
; NOTE: writing #$10 to ICR (bit7=0) CLEARS FLAG in the interrupt MASK
; (disables the FLAG interrupt) - it is NOT a strobe. Reading ICR tests and
; ACKNOWLEDGES the FLAG/ACK state (read clears the pending flag).
CIAA_PRB equ $BFE101 ; CIAA parallel port B (data)
CIAA_DDRB equ $BFE301 ; CIAA data direction B
CIAA_ICR equ $BFED01 ; CIAA interrupt control register
Debug_ParallelPrint:
move.b #-1,CIAA_DDRB ; DDRB = $FF (parallel data all outputs)
.char:
move.b #$10,CIAA_ICR ; disable FLAG interrupt (clear ICR mask bit4)
move.b (A0)+,CIAA_PRB ; data byte out to parallel port
.wait:
btst.b #4,CIAA_ICR ; poll FLAG (ACK); read also acknowledges
beq.b .wait
tst.b (A0)
bne.b .char
rts
; --- Debug_PrintMfmError ($0250): print an MFM error to the parallel port ------
; D0 = -error code (Loader_MfmRead's negative return). Prints the prefix
; " >> MFM Loader Error #", walks A0 to the Nth error string (the '1 -'..'7 -'
; texts are consecutive NUL-terminated strings), prints it, then a CRLF.
Debug_PrintMfmError: ; $0250
lea str_err_drive(PC),A0 ; error string #1
neg.l D0 ; error code 1-7
subq.w #1,D0 ; -> 0-based string index
.find: ; $0258
tst.w D0
beq.w .found
.scan: ; $025E
tst.b (A0)+ ; skip to end of current string
bne.b .scan
dbf D0,.find
.found: ; $0266
move.l A0,-(SP) ; the Nth error string
lea str_mfm_err_pfx(PC),A0 ; " >> MFM Loader Error #"
bsr.w Debug_ParallelPrint
movea.l (SP)+,A0
bsr.w Debug_ParallelPrint ; the error text itself
lea str_crlf(PC),A0
bra.w Debug_ParallelPrint ; tail call: print CRLF + return
; --- loader variables ($027E, data) --------------------------------------------
; Accessed via the absolute ld_* equates at the top of the file. (The bytes at
; $027C-$027D are the displacement word of the bra.w above, not data.)
loader_vars: ; $027E
dc.l 0 ; $27E ld_dest_ptr: dest ptr (A0 at entry)
dc.l 0 ; $282 ld_file_index: file index (D0 & $7F)
dc.b 0 ; $286 ld_drive_idx: current drive (0-3)
dc.b 0 ; $287 pad
dc.w 0 ; $288 ld_debug_flag: != 0 -> debug log on
; --- str_debug_banner ($028A) ---------------------------------------------------
str_debug_banner:
dc.b "HUNTER Debugger/progres monitor, this will log all disk activity....",$0A,$0D,0
; ("progres" sic - typo in the original)
; --- str_mfm_err_pfx ($02D1) ----------------------------------------------------
str_mfm_err_pfx:
dc.b " >> MFM Loader Error #",0
; --- MFM error strings (consecutive; Debug_PrintMfmError walks by index) --------
str_err_drive: ; $02E9
dc.b "1 - Drive x not responding",0
str_err_nodisk: ; $0304
dc.b "2 - No disk in drive x",0
str_err_writeprot: ; $031B
dc.b "3 - Disk write protected",0
str_err_sync: ; $0334
dc.b "4 - Time out on SYNC match",0
str_err_sector: ; $034F
dc.b "5 - Sector(s) not found in MFM buffer",0
str_err_checksum: ; $0375
dc.b "6 - Datablock check sum error",0
str_err_notfound: ; $0393
dc.b "7 - file not found",0
; --- str_loading ($03A6) ---------------------------------------------------------
; The "xx" and the six hex zeros are patched in place with the file index / load
; address before printing (see Loader_LoadFile). str_at_addr and str_crlf are
; equates pointing inside this string.
str_loading: ; $03A6
dc.b "Loading file xx : ",0
dc.b " at $000000",$0A,$0D,0 ; $03B9 str_at_addr; $03C4 str_crlf
; --- hex_digits ($03C7) ----------------------------------------------------------
hex_digits:
dc.b "0123456789ABCDEF",0