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
8.2 KiB
Plaintext

**********************************************************************
*
* GSTextEdit Version 1.0
* File: width.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.
*
* 7-Apr-91 Dave Lyons (DAL)
*
* Changed the CharWidth loop to include the control characters,
* except we still treat Return as zero-width. There are some
* printable control characters we want to be able to deal with
* correctly (check mark, Apple, etc).
*
**********************************************************************
INCLUDE 'GlobalIncludes'
****************************************************************
Width1Proc PROC
;---------------------------------------------------------------
EXPORT SetupWidthTable
EXPORT FreeWidthTable
EXPORT ChangeWidthTable
;---------------------------------------------------------------
;---------------------------------------------------------------
SetupWidthTable lda WidthTableDepth
bne @skipSetup
inc WidthTableDepth
bra RealSetupWidth
@skipSetup inc WidthTableDepth
bra checkForChange
;---------------------------------------------------------------
FreeWidthTable dec WidthTableDepth
bne exit
PushZLong WidthTableHandle
jsr UnlockHandle
rts
;---------------------------------------------------------------
ChangeWidthTable lda WidthTableDepth
beq exit
;---------------------------------------------------------------
checkForChange phy
PushZLong TempPtr
lda WidthTablePtr
sec
sbc #4
sta TempPtr
lda WidthTablePtr+2
sbc #0
sta TempPtr+2
ldy #2
lda [TempPtr],y
pha
lda [TempPtr]
pha
jsr SetupStylePtr
PullAX
ldy #TEStyle.fontID
cmp [TempPtr],y
bne changeIt
iny
iny
txa
cmp [TempPtr],y
bne changeIt
PullLong TempPtr
ply
;---------------------------------------------------------------
exit rts
;---------------------------------------------------------------
changeIt pla
pla
pla
jsr RealSetupWidth
ldy #TERecord.StyleSuper
jsr FindSuperInfo
iny
iny
rts
;---------------------------------------------------------------
ENDP
****************************************************************
RealSetupWidth PROC ENTRY
;---------------------------------------------------------------
DefineStack
theAscent word
theDescent word
theWidMax word
theLeading word
;---------------------------------------------------------------
;---------------------------------------------------------------
PushZLong TempLong
jsr SetupStylePtr
ldy #TEStyle.fontID+2
lda [TempPtr],y
sta TempLong+2
dey
dey
lda [TempPtr],y
sta TempLong
jsr lockWTHandle ;lock down the width table handle and
lda WidthTablePtr+1 ;..check for null master pointer
beq mustRealloc
ldy WidthTableOffset ;are we already pointing to the correct
lda [WidthTablePtr],y ;..font ? If not, we must search for it
cmp TempLong
bne mustFind
iny
iny
lda [WidthTablePtr],y
cmp TempLong+2
bne mustFind
;---------------------------------------------------------------
makeWidthPtr iny ;add the offset to width table pointer
iny
tya
addl WidthTablePtr
;---------------------------------------------------------------
allDone PullLong TempLong
rts
;---------------------------------------------------------------
foundIt tya
dec a
dec a
sta WidthTableOffset
bra makeWidthPtr
;---------------------------------------------------------------
mustRealloc jsr unlockWTHandle ;unlock the purged handle and reallocate
jsr reallocWTHandle ;..it
lda #0 ;clear the count field
sta [WidthTablePtr]
;---------------------------------------------------------------
mustFind lda [WidthTablePtr] ;get the total number of items and if this
beq notFound ;..is zero, then add the font to the list
tax ;put the count in the X-Reg
ldy #2
@loop lda [WidthTablePtr],y ;check the cached fontID against TempLong
iny ;..(the fontID we are looking for)
iny
cmp TempLong
bne @next
lda [WidthTablePtr],y
cmp TempLong+2 ;if they match, then we have found the
beq foundIt ;..font, so adjust the index and make the
@next tya ;..widthTablePtr
clc ;move to the next item in the table
adc #WidthTable.RecordSize+2
tay
dex ;count down thru all the items
bne @loop
;---------------------------------------------------------------
notFound jsr GetPort ;save the old port and set the new one
jsr SetDrawPort ;..to draw port
lda [WidthTablePtr] ;increment our count of fonts in the table
inc a
@tryAgain sta [WidthTablePtr]
jsr unlockWTHandle ;unlock the table, so we can resize it
PushZLong WidthTableHandle ;get the original size of the handle and
ldy #HandleRecord.length ;..add the correct amount to make it one
lda [WidthTableHandle],y ;..font bigger. If this new size is over
sta WidthTableOffset ;..64K, then purge the handle and start
clc ;..over
adc #WidthTable.RecordSize+4
bcs @purgeTheHandle
ldx #0 ;make sure the X-Reg is zero
jsr SetHandleSize ;if we get the memory we need, then
bcc @weHaveMemory ;..continue. Otherwise purge the handle
@purgeTheHandle PushZLong WidthTableHandle ;..and try again
_PurgeHandle
jsr reallocWTHandle
lda #1
bra @tryAgain
@weHaveMemory
jsr lockWTHandle ;lock the handle down and make a pointer
ldy WidthTableOffset ;..to the new font
lda TempLong
sta [WidthTablePtr],y
iny
iny
lda TempLong+2
sta [WidthTablePtr],y
iny
iny
tya
addl WidthTablePtr
jsr InstallFontAndColor ;make sure the font is installed
ldx #0 ;now the X-Reg has zero cached
ldy #GrafPort.SpExtra+2 ;save the space extra field and set it to
lda [DrawPortPtr],y ;..$0000 0000
pha
txa
sta [DrawPortPtr],y
dey
dey
lda [DrawPortPtr],y
pha
txa
sta [DrawPortPtr],y
txa ;loop thru every character in the font
txy ;..finding the width and caching it in
;..the table.
*** 7-Apr-91 DAL -- let's don't skip the control characters, eh?
*** Control characters are people, too.
;@loop1 sta [WidthTablePtr],y
; iny
; iny
; cpy #$20
; blt @loop1
; tyx
@loop2 phx
PushWordSpace
phx
_CharWidth
pla
plx
txy
sta [WidthTablePtr],y
inx
cpx #255
bne @loop2
*** added 7-Apr-91 DAL -- make Return still be zero width (this might be important)
ldy #13
lda #0
sta [WidthTablePtr],y
*** end of 7-Apr-91 DAL
PushLongSpace ;make space for the font info record
PushLongSpace
tsc
pea $0000 ;adjust to make a pointer to the stack
inc a ;..space and push it
pha
_GetFontInfo
lda theAscent,s ;ascent = ascent + leading
clc
adc theLeading,s
ldy #WidthTable.ascent ;the offset for the ascent
sta [WidthTablePtr],y
adc theDescent,s ;the height is in A-Reg
dey ;the offset for the height
dey
sta [WidthTablePtr],y
pla ;cleanup the stack in the least number
pla ;..of bytes
pla
pla
ldy #GrafPort.SpExtra ;get back the saved space extra field
pla
sta [DrawPortPtr],y
iny
iny
pla
sta [DrawPortPtr],y
jsr ReleaseFont ;release the font
;---------------------------------------------------------------
jsr SetPort ;restore the saved port
brl allDone
;---------------------------------------------------------------
;---------------------------------------------------------------
reallocWTHandle PushLong #2 ;reallocate the handle with a size of two
PushZWord UserID ;..and purgable attributes
PushWord #$0300
PushLongSpace
PushZLong WidthTableHandle
_ReAllocHandle ;fall through into lock the handle
;---------------------------------------------------------------
lockWTHandle ldy #4
lda [WidthTableHandle],y
ora #$8000
sta [WidthTableHandle],y
dey
dey
lda [WidthTableHandle],y
sta WidthTablePtr+2
lda [WidthTableHandle]
sta WidthTablePtr
rts
;---------------------------------------------------------------
unlockWTHandle ldy #4
lda [WidthTableHandle],y
and #$7fff
sta [WidthTableHandle],y
rts
;---------------------------------------------------------------
ENDP
****************************************************************
END