English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 18 May 2010, 20:42   #1
Leffmann
 
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?
Leffmann is offline  
Old 18 May 2010, 22:36   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,987
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.
thomas is offline  
Old 18 May 2010, 23:27   #3
Leffmann
 
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?
Leffmann is offline  
Old 19 May 2010, 10:00   #4
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Leffmann View Post
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.
I think (not sure though) that OpenFont() doesn't work in the bootblock because it needs initialized intuition.library which isn't available at boot. But this is just a guess.

Quote:
Originally Posted by Leffmann View Post
Any other ideas how I can obtain the pointer to the font bitmap?
You could look for the first "8x8" font you find in the gb_TextFonts structure in gfxbase. Something like:

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
	...
should do the trick.

Last edited by StingRay; 19 May 2010 at 10:09. Reason: typo
StingRay is offline  
Old 19 May 2010, 13:45   #5
Leffmann
 
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:
Attached Thumbnails
Click image for larger version

Name:	topaz.png
Views:	330
Size:	556 Bytes
ID:	25348  
Leffmann is offline  
Old 19 May 2010, 13:55   #6
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Leffmann View Post
You forgot to compensate for the node size in your code
The code is perfectly fine!

Quote:
Originally Posted by Leffmann View Post
but even then I can't find a single font with a width or height of 8 in the TextFonts list.
Not sure what is wrong with your code but I can find the Topaz font with the code I posted.
StingRay is offline  
Old 19 May 2010, 14:04   #7
Leffmann
 
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?).
Leffmann is offline  
Old 19 May 2010, 14:12   #8
Leffmann
 
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.
Leffmann is offline  
Old 19 May 2010, 14:42   #9
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,987
Theres plenty of bootblocks that use resident fonts, especially stuff like Interferon. The X-Copy bootblock uses a resident font doesn't it?
Galahad/FLT is offline  
Old 19 May 2010, 14:51   #10
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Leffmann View Post
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?).
I have hacked a small example which shows that my code is perfectly fine! I have attached it here. I really don't know why you didn't just use the code I posted. And as for your question:

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
and it'll print one line with the font.
Attached Thumbnails
Click image for larger version

Name:	line.png
Views:	351
Size:	674 Bytes
ID:	25350  
Attached Files
File Type: s FindFont_Example.s (6.3 KB, 263 views)
StingRay is offline  
Old 19 May 2010, 15:06   #11
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,987
Quote:
Originally Posted by Leffmann View Post
there is the pointer to the first Node, which has a size of 14, and the actual data, a TextFont structure, comes right after.
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.
thomas is offline  
Old 19 May 2010, 15:50   #12
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Quote:
Originally Posted by thomas View Post
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.
Thanks, I've sorted the confusion now. The docs are a bit messy, the TextFont contains a Message structure which in turn contains a Node and some other data, but with no mention that fonts are effectively linked together through the Message structure, so instead I start at the graphics base and see a List which points to a Node which has a diagram depicting attached data at the end of the node, and I end up with wrong offsets.

In any case Stingray's first suggestion to iterate through the font list works fine now that I've corrected my offsets.

Thanks!
Leffmann is offline  
Old 19 May 2010, 20:38   #13
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
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!
Comments included as bonus, the last one is probably for some .library reuse or other packing.

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?
Photon is offline  
Old 19 May 2010, 21:52   #14
Leffmann
 
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.
Leffmann is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:05.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.42984 seconds with 14 queries