Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Apple » Apple II » Apple /// and font loading, a start to figuring it out
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Apple /// and font loading, a start to figuring it out [message #371326] Fri, 27 July 2018 11:46 Go to next message
Steve Nickolas is currently offline  Steve Nickolas
Messages: 2036
Registered: October 2012
Karma: 0
Senior Member
So I was poring over a PDF transcription of the Apple /// ROM listings,
and I found the code that loads the default font.

Finally, I'm getting somewhere! But it looks like what's here is a
*packed* font, rather than a *raw* font (no doubt, to save as much ROM
space as possible).

I have yet to make this a generalized font loader, but it's a start.

-uso.

; ============================================================ ================
; Apple /// ROM Font Loader Code
; ------------------------------------------------------------ ----------------
; This code is taken from listings of the Apple /// firmware, and translated
; to assemble with CA65. No other changes have been made (apart from slight
; stylistic tweaks to the comments).
; ============================================================ ================

adr = $A0
cportl = adr
cporth = adr+1
ctemp = adr+2
ctemp1 = adr+3
ytemp = adr+4
rowtemp = adr+20
cwrton = $C0DB
cwrtoff = $C0DA
cb2ctrl = $FFEC
cb2int = $FFED

.org $FDC6
genentr: lda #$78 ; init screen index locations
sta cportl
lda #$08
sta cporth
lda #$F0 ; set up index to chrset
sta ytemp
lda #$00
tax
ziptemps: sta rowtemp, x
inx
cpx #$20
bne ziptemps
lda #$05 ; fake the first bit pattern
clc ; (phantom 9th bit shifted as bit 0)
php
pha
genasc: stx ctemp ; generate the ASCII
gasci1: ldy #$07 ; codes for the first pass
gasci2: ldx ctemp
gasci3: txa
sta (cportl), y ; $XXF = chr 0/4
inx ; $XXE = chr 1/5
dey ; $XXD = chr 2/6
bmi gasci4 ; $XXC = chr 3/7
cpy #$03 ; $XXB = chr 0/4
bne gasci3 ; $XXA = chr 1/5
beq gasci2 ; $XX9 = chr 2/6
gasci4: jsr nxtport ; $XX8 = chr 3/7
bcs cbytes ; go decode character table
cmp #$0A ; second set of 4?
bne gasci1
ldx #$24
bne genasc ; ALWAYS
cbytes: pla ; restore bit pattern
plp
ldx #$17 ; (4 characters of 6 rows)
ccolms: ldy #$05 ; (five columns)
cshft: rol rowtemp+4, x ; break byte into
asl ; 5-bit groups
bne shftcnt ; branch if more bits in this byte
sty ctemp
dec ytemp ; (NOTE: carry is set)
beq done
ldy ytemp ; get character table index
lda chrset-1, y
rol ; (carry keeps byte non-zero until all 8 shifted)
ldy ctemp ; restore column count
shftcnt: dey ; got all five bits?
bne cshft ; no, do next
dex ; all rows done?
bpl ccolms ; no, do next
php ; save remaining bit pattern and
carry
pha
jsr storchrs ; move them to non-displayed video area
jmp cbytes
done:

storchrs: ldx #$1F ; move character patterns to video area
storset: ldy #$00
storow: lda rowtemp, x
asl ; shift to center
and #$3E ; strip extra garbage
sta (cportl), y
dex
iny
cpy #$08 ; this group done?
bne storow ; no, next row
jsr nxtport
cmp #$08
beq gendone ; all rows stored?
txa
bpl storset
rts ; partial set ($478-$5FF)

gendone: lda #$01 ; set normal mode
sta ctemp
gen1: lda #$60 ; prepare to send bytes to character
bit cwrton ; generator RAM
jsr vretrce ; wait for next vertical retrace
lda #$20 ; wait again
jsr vretrce
bit cwrtoff ; characters are now loaded
jsr altchr ; repeat this set for other 64
characters
dec ctemp ; have we done alternates yet?
bpl gen2 ; no, do it!
lda #$08 ; bump ASCII values for next set
sta cporth
nxtasci: ldy #$07 ; the usual countdown
nxtasc2: lda (cportl), y
clc
adc #$08
sta (cportl), y
dey
bpl nxtasc2
jsr nxtport
bcc nxtasci
rts
gen2: ldy #$03 ; setup alternates with underlines
lda #$7F
under: sta $05FC, y
sta $07FC, y
dey
bpl under
lda #$08
sta cporth
bne gen1

altchr: ldy #$07 ; adjust ASCII for alternate set
altc1: lda (cportl), y
eor #$20 ; $20 --> $40-->$60
sta (cportl), y
dey
bpl altc1 ; adjust them all
jsr nxtport
bcc altchr
rts

nxtport: lda cportl ; convert $78->$F8 or $F8->$78
eor #$80
sta cportl
bmi nohigh
inc cporth
nohigh: lda cporth
cmp #$0C
bne porton
lda #$04
sta cporth
porton: rts

vretrce: sta ctemp1 ; save bits to be stored
lda cb2ctrl ; control port for "CB2"
and #$3F ; reset high bits to 0
ora ctemp1
sta cb2ctrl
lda #$08 ; test vertical retrace
sta cb2int
vwait: bit cb2int ; wait for retrace
beq vwait
rts

chrset: .byte $F0, $01, $82, $18, $40, $84, $81, $2F
.byte $58, $44, $81, $29, $02, $1E, $01, $91
.byte $7C, $1F, $49, $30, $8A, $08, $43, $14
.byte $31, $2A, $22, $13, $E3, $F7, $C4, $91
.byte $48, $A2, $DA, $24, $C6, $4A, $62, $8C
.byte $24, $C6, $F8, $63, $8C, $C1, $46, $17
.byte $52, $8A, $AF, $16, $14, $E3, $33, $31
.byte $C6, $F8, $DC, $73, $3F, $46, $17, $62
.byte $8C, $21, $E6, $18, $6A, $8D, $61, $CF
.byte $18, $62, $74, $D1, $B9, $18, $49, $4C
.byte $91, $C0, $F3, $09, $2C, $91, $C0, $14
.byte $1D, $8C, $EF, $07, $17, $43, $88, $31
.byte $84, $1E, $DF, $0B, $31, $84, $F8, $FE
.byte $77, $3E, $3E, $17, $62, $8C, $FD, $C7
.byte $50, $E3, $0B, $51, $C5, $E8, $C8, $73
.byte $18, $0C, $42, $3E, $01, $02, $20, $42
.byte $3E, $41, $18, $8C, $08, $00, $70, $EE
.byte $00, $11, $11, $21, $11, $02, $E0, $3C
.byte $21, $31, $02, $E0, $1C, $00, $C8, $B9
.byte $80, $62, $14, $1F, $46, $A2, $DE, $43
.byte $2C, $04, $88, $BE, $FF, $CE, $7D, $37
.byte $49, $88, $95, $18, $98, $09, $62, $D1
.byte $44, $E8, $88, $FB, $02, $90, $40, $00
.byte $10, $E0, $03, $02, $00, $40, $00, $00
.byte $08, $00, $00, $28, $10, $42, $44, $25
.byte $82, $B8, $2F, $48, $25, $44, $10, $82
.byte $02, $00, $2F, $5A, $40, $45, $02, $8E
.byte $64, $50, $90, $01, $3E, $26, $42, $80
.byte $21, $80, $00, $05, $00, $F8, $80, $00
.byte $05, $08, $F8, $80, $28, $05, $88
Apple /// and font loading, a start to figuring it out [message #371356 is a reply to message #371326] Sat, 28 July 2018 00:12 Go to previous messageGo to next message
Rob Justice is currently offline  Rob Justice
Messages: 98
Registered: January 2013
Karma: 0
Member
That's also some that I have been meaning to look into and understand. There does no seem to be a clear description of the process in any docs.

There is also font loading in the sos loader, so that may also be some where else to look. I don't think the fonts in the driver file are packed like those in the rom. I did convert the sos1.3 source code to ca65 some time ago, it may be useful for you. I just used a simple batch file to build it, it could do with this being sorted out a bit better.
ftp://ftp.apple.asimov.net/pub/apple_II/documentation/source _code/AppleIII_sos1.3_ca65_source.zip

I also did the monitor rom. Just need to get back to the sos boot loader, never did finish that.
ftp://ftp.apple.asimov.net/pub/apple_II/emulators/rom_images /apple3/AppleIII_bootrom_ca65_source.zip

I have been enjoying reading your Apple /// ideas on here, thanks.

/Rob
Re: Apple /// and font loading, a start to figuring it out [message #371357 is a reply to message #371356] Sat, 28 July 2018 00:46 Go to previous message
Steve Nickolas is currently offline  Steve Nickolas
Messages: 2036
Registered: October 2012
Karma: 0
Senior Member
On Fri, 27 Jul 2018, Rob Justice wrote:

> That's also some that I have been meaning to look into and understand. There does no seem to be a clear description of the process in any docs.
>
> There is also font loading in the sos loader, so that may also be some where else to look. I don't think the fonts in the driver file are packed like those in the rom. I did convert the sos1.3 source code to ca65 some time ago, it may be useful for you. I just used a simple batch file to build it, it could do with this being sorted out a bit better.
> ftp://ftp.apple.asimov.net/pub/apple_II/documentation/source _code/AppleIII_sos1.3_ca65_source.zip

That's the first place I looked. Because it relied on setting SOS up with
a VBI, I couldn't use it as it was, which was why I went looking into the
source for the monitor ROM.

I don't think that particular file contains the *drivers*, though, as I
couldn't seem to find the equivalent of "CONS.DNLD.TXT" in
"apple3_SRC_Console_Driver.pdf", which has the important code.

>
> I also did the monitor rom. Just need to get back to the sos boot loader, never did finish that.
> ftp://ftp.apple.asimov.net/pub/apple_II/emulators/rom_images /apple3/AppleIII_bootrom_ca65_source.zip

That'll make things a lot easier. Geez, it was a pain typing all that
code up. x.x (Probably goes quadruple for you. ;))

>
> I have been enjoying reading your Apple /// ideas on here, thanks.
>
> /Rob
>

I've got a lot of ideas in mind to make something of the ol' dud =P

Might not be able to implement them all. But if even some of them were to
get an implementation...

-uso.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Applevision is full HGR, not TEXT on HGR
Next Topic: Lo-res 40x96 Demo (kfest hackfest entry)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Mar 29 05:28:05 EDT 2024

Total time taken to generate the page: 0.90103 seconds