Difference between revisions of "83Plus:Hooks:9B9C"
(All the bullets scared me.) |
m (Clarify zero is the zero flag) |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 16: | Line 16: | ||
== Using the Hook == | == Using the Hook == | ||
− | This hook is called | + | This hook is called to request information about a particular character. The accumulator indicates the type of information: |
+ | * '''A = 0''': A small font bitmap is requested. | ||
+ | * '''A = 1''': A large font bitmap is requested for fixed-width display. | ||
+ | * '''A = 2''': The width of a small font character is requested. | ||
+ | * '''A = 3''': A large font bitmap is requested for variable-width display. The bitmap provided will be shifted left by 1 bit and copied to [[83Plus:RAM:845A|lFont_record]] ''plus 1'', so that (lFont_record) can be set to 6. | ||
+ | HL contains the font table offset, equal to the character multiplied by 8. In modes 1 and 3, B also contains the character. If you want to use the default characters (or rather, the bitmaps provided by the [[83Plus:Hooks:9BCC|localize hook]]), return with the zero flag reset. If you do this, HL and B '''must''' be left intact. Otherwise, your outputs depend on the mode. | ||
+ | * In modes 0 and 1, set HL pointing to the font data, which must be in RAM. If you want to, you can copy data to [[83Plus:RAM:8462|sFont_record]] or [[83Plus:RAM:845A|lFont_record]], and then point HL to this location. Of course, you can use any location you want. | ||
+ | * In mode 2, set B to the width of the character. | ||
+ | * In mode 3, set HL pointing to the font data as in mode 1, but note that in this case it must ''not'' be located at lFont_record, but at lFontRecord+1, or else an entirely different area. | ||
− | + | === Character bitmap formats === | |
+ | In small font (mode 0): | ||
<nowiki>(HL) = width of character | <nowiki>(HL) = width of character | ||
(HL+1) = first (accent) row, right aligned (the last pixel usually clear) | (HL+1) = first (accent) row, right aligned (the last pixel usually clear) | ||
Line 24: | Line 33: | ||
... | ... | ||
(HL+6) = sixth row</nowiki> | (HL+6) = sixth row</nowiki> | ||
− | (HL+7) = seventh row (only displayed with bit | + | (HL+7) = seventh row (only displayed with bit [[83Plus:Flags:05#Bit_1|textEraseBelow, (iy+textFlags)]] set) |
− | + | ||
+ | In large font (modes 1 and 3): | ||
<nowiki>(HL) = first row, right aligned | <nowiki>(HL) = first row, right aligned | ||
... | ... | ||
Line 38: | Line 48: | ||
The following code displays the letter A in boldface: | The following code displays the letter A in boldface: | ||
− | + | FontHook: | |
.db 83h ; Required for all hooks | .db 83h ; Required for all hooks | ||
− | + | ld c,a | |
− | + | ld a,h ; what character is to be displayed? | |
− | ld a, | + | or l |
+ | rrca | ||
+ | rrca | ||
+ | rrca | ||
cp 'A' | cp 'A' | ||
ret nz | ret nz | ||
+ | ld a,c | ||
+ | or a ; check hook mode | ||
+ | jr z,SmallFontMode | ||
+ | cp 2 | ||
+ | jr z,WidthMode | ||
ld hl,BigA ; get our replacement bitmap | ld hl,BigA ; get our replacement bitmap | ||
− | ld de,lFont_record | + | ld de,[[83Plus:RAM:845A|lFont_record]]+1 |
ld bc,7 ; copy it into RAM | ld bc,7 ; copy it into RAM | ||
ldir | ldir | ||
− | ld hl,lFont_record | + | ld hl,[[83Plus:RAM:845A|lFont_record]]+1 |
cp a | cp a | ||
ret | ret | ||
− | + | SmallFontMode: | |
− | + | ||
− | + | ||
− | + | ||
ld hl,SmallA ; get our replacement bitmap | ld hl,SmallA ; get our replacement bitmap | ||
− | ld de,sFont_record | + | ld de,[[83Plus:RAM:8462|sFont_record]] |
ld bc,8 ; copy it into RAM | ld bc,8 ; copy it into RAM | ||
ldir | ldir | ||
− | ld hl,sFont_record | + | ld hl,[[83Plus:RAM:8462|sFont_record]] |
cp a | cp a | ||
ret | ret | ||
− | BigA: | + | WidthMode: |
+ | ld b,5 | ||
+ | cp a | ||
+ | ret | ||
+ | BigA: | ||
.db 00001110b | .db 00001110b | ||
.db 00010011b | .db 00010011b | ||
Line 71: | Line 90: | ||
.db 00010011b | .db 00010011b | ||
.db 00010011b | .db 00010011b | ||
− | SmallA: | + | SmallA: |
.db 5 | .db 5 | ||
.db 00000000b | .db 00000000b | ||
Line 79: | Line 98: | ||
.db 00010110b | .db 00010110b | ||
.db 00010110b | .db 00010110b | ||
− | .db 00000000b | + | .db 00000000b |
Latest revision as of 10:12, 5 September 2023
Synopsis
Name: Font Hook
Hook Pointer Block Address: 9B9C
Hook Enable BCALL: 4FE4
Hook Disable BCALL: 4FE7
Hook Call BCALL: 4003
Hook Active Flag: 5, (iy + 35h)
This hook allows you to change the font bitmaps; for example, it is used for Omnicalc's custom fonts.
Using the Hook
This hook is called to request information about a particular character. The accumulator indicates the type of information:
- A = 0: A small font bitmap is requested.
- A = 1: A large font bitmap is requested for fixed-width display.
- A = 2: The width of a small font character is requested.
- A = 3: A large font bitmap is requested for variable-width display. The bitmap provided will be shifted left by 1 bit and copied to lFont_record plus 1, so that (lFont_record) can be set to 6.
HL contains the font table offset, equal to the character multiplied by 8. In modes 1 and 3, B also contains the character. If you want to use the default characters (or rather, the bitmaps provided by the localize hook), return with the zero flag reset. If you do this, HL and B must be left intact. Otherwise, your outputs depend on the mode.
- In modes 0 and 1, set HL pointing to the font data, which must be in RAM. If you want to, you can copy data to sFont_record or lFont_record, and then point HL to this location. Of course, you can use any location you want.
- In mode 2, set B to the width of the character.
- In mode 3, set HL pointing to the font data as in mode 1, but note that in this case it must not be located at lFont_record, but at lFontRecord+1, or else an entirely different area.
Character bitmap formats
In small font (mode 0):
(HL) = width of character (HL+1) = first (accent) row, right aligned (the last pixel usually clear) (HL+2) = second row ... (HL+6) = sixth row (HL+7) = seventh row (only displayed with bit textEraseBelow, (iy+textFlags) set)
In large font (modes 1 and 3):
(HL) = first row, right aligned ... (HL+6) = seventh row
See the example code for actual formatted data.
Comments
This hook is one of the four "official" hooks defined in ti83plus.inc.
Example
The following code displays the letter A in boldface:
FontHook: .db 83h ; Required for all hooks ld c,a ld a,h ; what character is to be displayed? or l rrca rrca rrca cp 'A' ret nz ld a,c or a ; check hook mode jr z,SmallFontMode cp 2 jr z,WidthMode ld hl,BigA ; get our replacement bitmap ld de,lFont_record+1 ld bc,7 ; copy it into RAM ldir ld hl,lFont_record+1 cp a ret SmallFontMode: ld hl,SmallA ; get our replacement bitmap ld de,sFont_record ld bc,8 ; copy it into RAM ldir ld hl,sFont_record cp a ret WidthMode: ld b,5 cp a ret BigA: .db 00001110b .db 00010011b .db 00010011b .db 00011111b .db 00010011b .db 00010011b .db 00010011b SmallA: .db 5 .db 00000000b .db 00001100b .db 00010110b .db 00011110b .db 00010110b .db 00010110b .db 00000000b