18 May 2010, 20:42 | #1 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Why can't I open the Topaz-font in a boot block?
Trying to open the resident Topaz size 8, but OpenFont fails. Code works perfectly fine outside the boot block. Any ideas?
|
18 May 2010, 22:36 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,035
|
Resident fonts are case sensitive. If you tried to open "Topaz.font" it will fail, because it's called "topaz.font".
Anyway, topaz 8 ist the default font. You shouldn't need to open it. If you call InitRastPort() your RastPort will be set to topaz 8 already. |
18 May 2010, 23:27 | #3 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Thanks for the hints. I am of course opening "topaz.font" - the code works and prints text just like it should when I run it from CLI or Workbench.
What I'm after is the pointer to the actual bitmap data for the Topaz 8, and again this works fine outside the boot block. I tried calling InitRastPort and picking the TextFont pointer from there, and then the tf_CharData, but I see from the results that the TextFont doesn't get properly initialized. Any other ideas how I can obtain the pointer to the font bitmap? |
19 May 2010, 10:00 | #4 | ||
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
Quote:
Quote:
Code:
INCDIR SOURCES:INCLUDE/ INCLUDE graphics/gfxbase.i INCLUDE graphics/text.i FindFont move.l $4.w,a6 move.l $9c(a6),a6 ; nifty but naughty, gfxbase lea gb_TextFonts(a6),a0 .findFont move.l (a0),a0 cmp.w #8,tf_XSize(a0) bne.b .findfont move.l tf_CharData(a0),a0 ... Last edited by StingRay; 19 May 2010 at 10:09. Reason: typo |
||
19 May 2010, 13:45 | #5 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Thanks. You forgot to compensate for the node size in your code, but even then I can't find a single font with a width or height of 8 in the TextFonts list. I also tried picking the font via DefaultFont in the graphics base, but that gives the same random letters as when I pick the font from a freshly initialized RastPort.
What I want to get hold of is the monospaced bitmap of the Topaz 8, where the characters come in ASCII order and are 8 bytes per character, which is exactly what you get when you call OpenFont. This is what the alphabet in Topaz 8 looks like when I grab it via the graphics base or a RastPort: |
19 May 2010, 13:55 | #6 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
The code is perfectly fine!
Not sure what is wrong with your code but I can find the Topaz font with the code I posted. |
19 May 2010, 14:04 | #7 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Really? My docs say that TextFonts is at offset 140 in the graphics base, and this is a List of size 14, and at offset 0 in there is the pointer to the first Node, which has a size of 14, and the actual data, a TextFont structure, comes right after. You must've looked at some other code, because I don't see how you can traverse a list from just a TextFont structure. I can't make head nor tail of this (get it?).
|
19 May 2010, 14:12 | #8 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Let's get on the English Amiga Board Internet Relay Chat Server (TM) and solve this, or do it later if you're at work.
If anyone else knows a safe way to get to the intact Topaz 8 bitmap in a boot block, please post! Last edited by Leffmann; 19 May 2010 at 14:31. |
19 May 2010, 14:42 | #9 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,020
|
Theres plenty of bootblocks that use resident fonts, especially stuff like Interferon. The X-Copy bootblock uses a resident font doesn't it?
|
19 May 2010, 14:51 | #10 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
Quote:
lea gb_TextFonts(a6),a0 Anyway, here's the main part of my example code: Code:
MAIN move.l START\.GFXbase(pc),a0 lea gb_TextFonts(a0),a0 .findFont move.l (a0),a0 cmp.w #8,tf_XSize(a0) bne.b .findfont move.w tf_Modulo(a0),d0 move.l tf_CharData(a0),a0 lea screen,a1 moveq #40-1,d6 .line move.l a0,a2 move.l a1,a3 moveq #8-1,d7 .copy move.b (a2),(a3) add.w d0,a2 add.w #40,a3 dbf d7,.copy addq.w #1,a0 addq.w #1,a1 dbf d6,.line |
|
19 May 2010, 15:06 | #11 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,035
|
The struct TextFont *contains* the stuct Node at the beginning, it does not come after it. So the tf_#? offsets already include the 14 bytes of the Node.
|
19 May 2010, 15:50 | #12 | |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Quote:
In any case Stingray's first suggestion to iterate through the font list works fine now that I've corrected my offsets. Thanks! |
|
19 May 2010, 20:38 | #13 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,684
|
I seem to remember I needed no search algo to nick topaz 8 in the bootblock. But that was on kick 1.2-2.0. This is what I used way back when, probably the same way Leffman does it?
Code:
OpenFont: moveq #33,d0 lea GfxLib(PC),a1 jsr -408(a6) move.l d0,a6 lea FontDef(PC),a0 lea FontName(PC),a1 move.l a1,(a0) ;PC-relative, ya know! jsr -72(a6) ;openFont(topaz.font) move.l d0,a1 move.l $22(a1),a2 ;fontaddr jsr -78(a6) ;close font move.l a6,a1 move.l 4.w,a6 jsr -414(a6) rts FontDef:dc.l 0 dc.w 8,0 FontName:dc.b "topaz.font",0 GfxLib: dc.b "graphics.library",0 ;MUST BE ODD! It feels very strange to me that OpenFont would start failing on higher kicks without any mention in docs, but perhaps the last revision of those bibles was exactly in the kick 2.0 times. Maybe the font organization in memory or font struct changed at some point, and that's why some methods work/fail? |
19 May 2010, 21:52 | #14 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
You're right that OpenFont DOES work in a boot block, and looking at your code I just realized that OpenFont failed because I had set the pointer to the font name directly in the TextAttr structure, and ignored it when I made the rest of the code PC-relative. Funny how you always look for the error in the wrong place.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Open Amiga Game Database - Open Beta | FrodeSolheim | support.FS-UAE | 3 | 01 May 2013 22:37 |
1.3 Topaz font | Anakirob | request.Other | 11 | 04 March 2012 13:27 |
Topaz font.. code for grabbing it from the OS | h0ffman | Coders. General | 3 | 23 June 2011 23:59 |
Boot block examples? | h0ffman | Coders. General | 3 | 04 March 2011 16:44 |
App to edit fonts like topaz.8 and topaz.9? | Photon | support.Apps | 8 | 17 July 2008 20:32 |
|
|