Files
Shawn Quick dfcaae62dd Add qlink, the disk tools, and a bootable ProDOS 8 image.
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.
2026-10-16 14:41:55 -07:00

1 line
12 KiB
Plaintext

**********************************************************************
*
* GSTextEdit Version 1.0
* File: debug.aii
*
* Copyright Apple Computer, Inc. 1988-89
* All rights reserved
*
*
*
*
* Notes
*
* All the routines in GSTextEdit must be called in full native mode and
* return that way.
*
* All the files in GSTextEdit must be assembled with the "-unsafe"
* option to pass unresolved references to the linker.
*
*
*
*
* Change History
*
* 30 May 89 Dave Good
*
* Cleaned up comments for final release.
*
**********************************************************************
;---------------------------------------------------------------
INCLUDE 'all.macros'
INCLUDE 'Tool.Records'
INCLUDE 'GlobalRecords'
INCLUDE 'GlobalEquates'
INCLUDE '::sys.equs.asm'
print on,gen,nopage,nowarn,mcall,obj,data,nomdir,nohdr,lits,nostat,nosym
string asis
;---------------------------------------------------------------
;---------------------------------------------------------------
BreakFlag equ 1
TraceFlag equ 1
HeaderFlag equ 0
;---------------------------------------------------------------
;---------------------------------------------------------------
DefineStack
LocalLength long
TheMaxIndex word
TheLength long
TempHandle long
TempPtr long
TheHandle long
ThePtr long
TheMainPtr long
DebugRecordPtr long
InvalidFlag word
DebugStackSize DSectSize
TEDirectPage word
;---------------------------------------------------------------
****************************************************************
DebugCheck PROC EXPORT
;---------------------------------------------------------------
Trace $FF8000
phd ;save the original direct page
tsc ;allocate space for the debug variables
sec
sbc #DebugStackSize-1
tcs
tcd
ldx TEDirectPage
lda >$04,x ;this is the RecordHandle
sta TheHandle
lda >$06,x
sta TheHandle+2
jsr DerefTheHandle
movl ThePtr,DebugRecordPtr
;---------------------------------------------------------------
ldy #TERecord.SelectionStart
jsr GetDRecordLong
stax ThePtr
ldy #TERecord.SelectionEnd
jsr GetDRecordLong
cpx ThePtr+2
bltl break1
bne @1
cmp ThePtr
bltl break1
@1
;---------------------------------------------------------------
Trace $FF8010
ldy #TERecord.BlockList
jsr CheckLinkedList
bcsl break2
Trace $FF801F
Trace $FF8020
jsr CheckBlockList
bcs break3
Trace $FF802F
;---------------------------------------------------------------
Trace $FF8030
ldy #TERecord.LineSuper
jsr CheckLinkedList
bcs break4
Trace $FF803F
Trace $FF8040
ldy #TERecord.LineSuper
jsr CheckSuperArray
bcs break5
Trace $FF804F
;---------------------------------------------------------------
Trace $FF8050
ldy #TERecord.StyleSuper
jsr CheckLinkedList
bcs break6
Trace $FF805F
Trace $FF8060
ldy #TERecord.StyleSuper
jsr CheckSuperArray
bcs break7
Trace $FF806F
;---------------------------------------------------------------
allDone tsc
clc
adc #DebugStackSize-1
tcs
pld
Trace $FF800F
rts
;---------------------------------------------------------------
break1 Break $61 ;the selection is invalid
break2 Break $62 ;the block list structure is bad
break3 Break $63 ;something else is wrong with the block list
break4 Break $64 ;the line super structure is bad
break5 Break $65 ;something else is wrong with the line super
break6 Break $66 ;the style super structure is bad
break7 Break $67 ;something else is wrong with the style super
break8 Break $68
break9 Break $69
break10 Break $6A
break11 Break $6B
break12 Break $6C
break13 Break $6D
break14 Break $6E
break15 Break $6F
bra allDone
;---------------------------------------------------------------
ENDP
****************************************************************
CheckBlockList PROCNAME Entry
;---------------------------------------------------------------
ldy #TERecord.BlockList ;move to the first block in the block
jsr GetDRecordLong ;..list
stax TheHandle
jsr DerefTheHandle
@loop1 ldy #TextBlock.prevHandle
jsr MoveToHandle
bne @loop1
stzl TheLength
lda #$FFFF ;as long as InvalidFlag is $FFFF, the
sta InvalidFlag ;..block start is INVALID.
jsr compareWithStart
bcs badCache
;---------------------------------------------------------------
mainLoop ldy #TextBlock.textLength+2 ;get the logical length of the block and
lda [ThePtr],y ;..convert it to the physical length
tax
dey
dey
lda [ThePtr],y
and #$FF00
clc
adc #256+TextBlock.textStart
bcc @1
inx
@1 ldy #HandleRecord.length ;now compare the calculated physical
cmp [TheHandle],y ;..length with the actual physical length
bne badLength ;if they don't match, then break
iny
iny
txa
cmp [TheHandle],y
bne badLength
ldy #HandleRecord.attributes
lda [TheHandle],y
bmi badLocked
ldy #TextBlock.textLength ;add this block's length to the
lda [ThePtr],y ;..cumulative block length. Then compare
clc ;..this value with the cached block start
adc TheLength ;if they match, mark the block start as
sta TheLength ;..valid
iny
iny
lda [ThePtr],y
adc TheLength+2
sta TheLength+2
ldy #TextBlock.nextHandle ;move to the next block in the list.
jsr MoveToHandle
beq allDone ;if there are no more, then stop looping
jsr compareWithStart
bcs badCache
bra mainLoop
;---------------------------------------------------------------
allDone lda InvalidFlag ;is the cached block start valid ?
bne badCache
clc
rts
;---------------------------------------------------------------
badCache ldx #0
sec
rts
badLength ldx #1
sec
rts
badLocked ldx #2
sec
rts
;---------------------------------------------------------------
;---------------------------------------------------------------
compareWithStart ldy #TERecord.BlockList.cachedTextOffset
jsr GetDRecordLong
cmp TheLength
bne @noCheck
cpx TheLength+2
bne @noCheck
stz InvalidFlag
ldy #TERecord.BlockList.cachedHandle
jsr GetDRecordLong
cmp TheHandle
bne @error
cpx TheHandle+2
bne @error
@noCheck clc
rts
@error sec
rts
;---------------------------------------------------------------
ENDP
****************************************************************
CheckLinkedList PROCNAME Entry
;---------------------------------------------------------------
jsr GetDRecordLong ;get the handle to start with and deref
stax TheHandle ;..it.
jsr DerefTheHandle
;---------------------------------------------------------------
checkPrev movl TheHandle,TheMainPtr ;save the current pointer
@loop ldy #TextBlock.textLength+2 ;see if the text length field is too large
lda [ThePtr],y
cmp #$0100
bgel badLength
movl TheHandle,TempHandle
ldy #TextBlock.prevHandle
jsr MoveToHandle
bcs badHandle
beq checkNext
ldy #TextBlock.nextHandle
jsr MoveToHandle
bcs badHandle
beq badHandle
lda TempHandle
cmp TheHandle
bne badList
lda TempHandle+2
cmp TheHandle+2
bne badList
ldy #TextBlock.prevHandle
jsr MoveToHandle
bra @loop
;---------------------------------------------------------------
checkNext movl TheMainPtr,TheHandle
jsr DerefTheHandle
@loop ldy #TextBlock.textLength+2 ;see if the text length field is too large
lda [ThePtr],y
cmp #$0100
bge badLength
movl TheHandle,TempHandle
ldy #TextBlock.nextHandle
jsr MoveToHandle
bcs badHandle
beq goodList
ldy #TextBlock.prevHandle
jsr MoveToHandle
bcs badHandle
beq badHandle
lda TempHandle
cmp TheHandle
bne badList
lda TempHandle+2
cmp TheHandle+2
bne badList
ldy #TextBlock.nextHandle
jsr MoveToHandle
bra @loop
;---------------------------------------------------------------
goodList clc
rts
;---------------------------------------------------------------
badLength ldx #0
sec
rts
badHandle ldx #1
sec
rts
badList ldx #2
sec
rts
;---------------------------------------------------------------
ENDP
****************************************************************
CheckSuperArray PROCNAME Entry
;---------------------------------------------------------------
tya ;get pointer into the control record where
clc ;..we want the super handle to be stored.
adc DebugRecordPtr
sta TheMainPtr
lda DebugRecordPtr+2
adc #0
sta TheMainPtr+2
ldy #2
lda [TheMainPtr],y
sta TheHandle+2
lda [TheMainPtr]
sta TheHandle
jsr DerefTheHandle
@loop ldy #SuperBlock.prevHandle
jsr MoveToHandle
bne @loop
stzl TheLength
;---------------------------------------------------------------
mainLoop ldy #SuperHandle.itemsPerBlock ;check the size of the handle
lda [TheMainPtr],y
asl a
asl a
asl a
clc
adc #SuperBlock.RecordSize
sta TheMaxIndex
ldy #HandleRecord.length
cmp [TheHandle],y
bne badLength
iny
iny
lda [TheHandle],y
bne badLength
inc TheMaxIndex
inc TheMaxIndex
stzl LocalLength
ldy #SuperBlock.RecordSize+2
jsr checkAgainstCache
bcs badCache
@innerLoop lda [ThePtr],y
bmi @skipItem
tax
dey
dey
lda [ThePtr],y
clc
adc LocalLength
sta LocalLength
txa
adc LocalLength+2
sta LocalLength+2
iny
iny
@skipItem tya
clc
adc #SuperItemSize
tay
jsr checkAgainstCache
bcs badCache
cpy TheMaxIndex
blt @innerLoop
ldy #SuperBlock.textLength
lda [ThePtr],y
cmp LocalLength
bne badBlock
iny
iny
lda [ThePtr],y
cmp LocalLength+2
bne badBlock
lda LocalLength
clc
adc TheLength
sta TheLength
lda LocalLength+2
adc TheLength+2
sta TheLength+2
ldy #SuperBlock.nextHandle
jsr MoveToHandle
bne mainLoop
;---------------------------------------------------------------
goodArray clc
rts
;---------------------------------------------------------------
badLength ldx #0
sec
rts
badCache ldx #1
sec
rts
badBlock ldx #2
sec
rts
;---------------------------------------------------------------
;---------------------------------------------------------------
checkAgainstCache phy
tya
dec a
dec a
ldy #SuperHandle.cachedIndex
cmp [TheMainPtr],y
bne @notCached
ldy #SuperHandle.cachedHandle
lda TheHandle
cmp [TheMainPtr],y
bne @notCached
iny
iny
lda TheHandle+2
cmp [TheMainPtr],y
bne @notCached
lda TheLength
clc
adc LocalLength
tax
lda TheLength+2
adc LocalLength+2
ldy #SuperHandle.cachedTextOffset+2
cmp [TheMainPtr],y
bne @error
dey
dey
txa
cmp [TheMainPtr],y
bne @error
@notCached clc
ply
rts
@error sec
ply
rts
;---------------------------------------------------------------
ENDP
****************************************************************
Debug1Proc PROC
;---------------------------------------------------------------
ENTRY MoveToHandle
ENTRY DerefTheHandle
;---------------------------------------------------------------
;---------------------------------------------------------------
MoveToHandle lda [ThePtr],y
pha
iny
iny
lda [ThePtr],y
tax
ora 1,s
tay
pla
dey
iny
beq atTheEnd
cpx #$0100
bge error
stax TheHandle
;---------------------------------------------------------------
DerefTheHandle ldy #2
lda [TheHandle],y
sta ThePtr+2
lda [TheHandle]
sta ThePtr
rep #%00000010
;---------------------------------------------------------------
atTheEnd clc
rts
;---------------------------------------------------------------
error sec
rts
;---------------------------------------------------------------
ENDP
****************************************************************
GetDRecordLong PROCNAME Entry
;---------------------------------------------------------------
iny
iny
lda [DebugRecordPtr],y
tax
dey
dey
lda [DebugRecordPtr],y
rts
;---------------------------------------------------------------
ENDP
****************************************************************
END