English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 28 November 2008, 00:12   #1
a4k-oerx
Registered User
 
Join Date: Oct 2008
Location: EU
Posts: 163
Evil grin Using a diskfont without diskfont.library, just incbin it! [Bugfix]

During my "create onefile versions" research in the last few days, I thought about and found a nice way to get standard bitmap-fonts incbined in a binary and used there in a standard rastport without the otherwise required diskfont.library.

Actually it's pretty simple, requires only the relocation of a few pointers within the diskfont (that's done on-the-fly before use in the following example, but can also be done before by relocating the font to a fixed adress) and the use of the right pointer to the struct TextFont. Basically OpenDiskFont() and OpenFont() are emulated with a few lines assembler-code.

Maybe somebody is interested in this, here is the ASM-One sourcecode.

Edit: Fixed a bug with some fonts where CharLoc, CharSpace or CharKern is not specified.
Code:
; Using a diskfont without diskfont.library

	incdir	"LVO:"
	include	"exec_lib.i"
	include	"graphics_lib.i"

	incdir	"INCLUDE:"
	include	"graphics/gfx.i"
	include	"graphics/rastport.i"
	include	"graphics/text.i"
	include	"graphics/gfxbase.i"

	section	chipram,CODE_C

prg	move.l	$4.w,a6
	jsr	_LVOForbid(a6)

	lea	gfxname(pc),a1
	moveq	#0,d0
	jsr	_LVOOpenLibrary(a6)
	lea	gfxbase(pc),a0
	move.l	d0,(a0)

	move.l	d0,a6
	lea	bitmap(pc),a5		; a5 used below

	move.l	a5,a0
	moveq	#1,d0
	move.l	#320,d1
	move.l	#200,d2	
	jsr	_LVOInitBitMap(a6)

	lea	plane1(pc),a0
	move.l	a0,bm_Planes+0(a5)	; *bitplane1 in bitmap

	lea	rastport(pc),a4		; a4 used below below

	move.l	a4,a1
	jsr	_LVOInitRastPort(a6)

	move.l	a5,rp_BitMap(a4)	; *bitmap in rastport
	
	move.l	a4,a1
	jsr	_LVOClearScreen(a6)

	lea	font(pc),a3
	lea	$20(a3),a3		; skip hunk header
	move.l	a3,d3			; start of binary in d3 
	lea	$4(a3),a3		; skip "moveq #64,d0 rts"
	add.l	d3,LN_NAME(a3)		; reloc
	lea	$36(a3),a3		; now *TextFont in a3, a3 used below
	add.l	d3,LN_NAME(a3)		; reloc
	add.l	d3,tf_CharData(a3)	; reloc
	tst.l	tf_CharLoc(a3)
	beq.b	.skipL
	add.l	d3,tf_CharLoc(a3)	; reloc
.skipL	tst.l	tf_CharSpace(a3)
	beq.b	.skipS
	add.l	d3,tf_CharSpace(a3)	; reloc
.skipS	tst.l	tf_CharKern(a3)
	beq.b	.skipK
	add.l	d3,tf_CharKern(a3)	; reloc
.skipK
	lea	plane1(pc),a0
	move.l	a0,d0
	lea	bpl1lo(pc),a1
	move.w	d0,(a1)
	swap	d0
	lea	bpl1hi(pc),a1
	move.w	d0,(a1)

	lea	oldview(pc),a0
	move.l	gb_ActiView(a6),(a0)
	sub.l	a1,a1
	jsr	_LVOLoadView(a6)
	jsr	_LVOWaitTOF(a6)	
	jsr	_LVOWaitTOF(a6)	

	move.w	#$0020,$dff096		; we don't use sprites

	lea	newcop(pc),a0
	move.l	a0,$dff080

	move.l	a3,a0			; here comes the font...
	move.l	a4,a1
	jsr	_LVOSetFont(a6)

	moveq	#1,d0
	move.l	a4,a1
	jsr	_LVOSetAPen(a6)

	; FS_NORMAL ! FSF_BOLD ! FSF_UNDERLINED ! FSF_ITALIC
	
	move.l	a4,a1
	jsr	_LVOAskSoftStyle(a6)
	move.l	d0,d1
	moveq	#FSF_BOLD!FSF_UNDERLINED,d0
	move.l	a4,a1
	jsr	_LVOSetSoftStyle(a6)

	move.w	#0,d0
	move.w	#20,d1
	move.l	a4,a1
	jsr	_LVOMove(a6)

	lea	text1(pc),a0
	moveq	#0,d0
	move.w	#text1_end-text1,d0
	move.l	a4,a1
	jsr	_LVOText(a6)

	move.l	a4,a1
	jsr	_LVOAskSoftStyle(a6)
	move.l	d0,d1
	moveq	#FSF_UNDERLINED,d0
	move.l	a4,a1
	jsr	_LVOSetSoftStyle(a6)

	move.w	#0,d0
	move.w	#40,d1
	move.l	a4,a1
	jsr	_LVOMove(a6)

	lea	text1(pc),a0
	moveq	#0,d0
	move.w	#text1_end-text1,d0
	move.l	a4,a1
	jsr	_LVOText(a6)

	move.l	a4,a1
	jsr	_LVOAskSoftStyle(a6)
	move.l	d0,d1
	moveq	#FS_NORMAL,d0
	move.l	a4,a1
	jsr	_LVOSetSoftStyle(a6)

	move.w	#0,d0
	move.w	#60,d1
	move.l	a4,a1
	jsr	_LVOMove(a6)

	lea	text1(pc),a0
	moveq	#0,d0
	move.w	#text1_end-text1,d0
	move.l	a4,a1
	jsr	_LVOText(a6)

loop	btst	#6,$bfe001
	bne.b	loop

	move.l	gfxbase(pc),a6
	jsr	_LVOWaitTOF(a6)	
	jsr	_LVOWaitTOF(a6)	
	move.l	oldview(pc),a1
	jsr	_LVOLoadView(a6)
	move.l	gb_copinit(a6),$dff080

	move.w	#$8020,$dff096

	move.l	$4.w,a6
	move.l	gfxbase(pc),a1
	jsr	_LVOCloseLibrary(a6)

	jsr	_LVOPermit(a6)
	moveq	#0,d0
	rts

	rts
	
text1	dc.b	"Hello world!"
text1_end

gfxname	dc.b	"graphics.library",0
	cnop	0,2
gfxbase	dc.l	0
oldview	dc.l	0

font	incbin	"SYS:fonts/diamond/12"

	cnop	0,4
bitmap	dcb.b	bm_SIZEOF,0
plane1	dcb.b	(320/8)*200*1,0
rastport dcb.b	rp_SIZEOF,0

newcop	dc.w	$008e,$2c81
	dc.w	$0090,$f4c1
	dc.w	$0092,$0038
	dc.w	$0094,$00d0
	dc.w	$0102,$0000
	dc.w	$0104,$0000
	dc.w	$0108,$0000
	dc.w	$010A,$0000
	dc.w	$0180,$0000
	dc.w	$0182,$0fff
	dc.w	$0100,$1200
	dc.w	$00e0
bpl1hi	dc.w	$0000
	dc.w	$00e2
bpl1lo	dc.w	$0000
	dc.w	$2b09,$fffe,$0180,$0008
	dc.w	$2c09,$fffe,$0180,$0004
	dc.w	$f509,$fffe,$0180,$0008
	dc.w	$f609,$fffe,$0180,$0000
	dc.w	$ffff,$fffe
Old intros/demos use rastports for display of text and scrolltext with an own font, read via diskfont.library, that was a comon way in early amiga days. Creating a onefile version of these intros is now possible, the OpenLib()/CloseLib() needs to be NOPed, as well as any CloseFont() calls, also OpenDiskFont(), and as its result the pointer to *TextFont has to be patched in, that's it.

Had to share this, if nobody is interested, never mind!
Attached Thumbnails
Click image for larger version

Name:	BypassDiskfontlib.png
Views:	359
Size:	2.1 KB
ID:	19058   Click image for larger version

Name:	BypassDiskfontlib2.png
Views:	299
Size:	2.2 KB
ID:	19059   Click image for larger version

Name:	BypassDiskfontlib3.png
Views:	298
Size:	2.4 KB
ID:	19060   Click image for larger version

Name:	BypassDiskfontlib4.png
Views:	336
Size:	4.1 KB
ID:	19061  
Attached Files
File Type: 7z BypassDiskfontlib.7z (1.3 KB, 189 views)

Last edited by a4k-oerx; 30 November 2008 at 01:03.
a4k-oerx is offline  
Old 28 November 2008, 20:59   #2
hit
Registered User
 
Join Date: Jun 2008
Location: planet earth
Posts: 1,115
sounds interesting to me. i'm not a coder, so this may say not so much.
still problems running ASM-One, crashes instantly. need to find a working setup.

One question, what means "LVO" ? it has to do with the assembler includes. but what is it exactly?
hit is offline  
Old 28 November 2008, 23:01   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,987
Quote:
Old intros/demos use rastports for display of text and scrolltext with an own font, read via diskfont.library, that was a comon way in early amiga days.
Don't know of which early days you are speaking. When I was writing intros for the Amiga (almost 20 years ago, the real early days), people were using pictures as font sources. See example attachment.


Quote:
what means "LVO" ?
"Library Vector Offset". These are labels so that you can use names for calling functions instead of remembering the numeric offsets. Also "jsr _LVOOpen(a6)" is much more readable than "jsr -30(a6)". The labels are predefined in amiga.lib.
Attached Thumbnails
Click image for larger version

Name:	demofont.png
Views:	328
Size:	6.2 KB
ID:	19076  
thomas is offline  
Old 28 November 2008, 23:21   #4
hit
Registered User
 
Join Date: Jun 2008
Location: planet earth
Posts: 1,115
oh, "vector". *gosh* thanks
hit is offline  
Old 28 November 2008, 23:51   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,507
Quote:
Originally Posted by thomas View Post
Don't know of which early days you are speaking. When I was writing intros for the Amiga (almost 20 years ago, the real early days), people were using pictures as font sources. See example attachment.
There are some cracktros or intros that have wrong fonts if boot CLI is in 60 character mode (or without devs:system-information), I think they were from ks1.2 (or even ks1.1) era..
Toni Wilen is online now  
Old 29 November 2008, 02:06   #6
a4k-oerx
Registered User
 
Join Date: Oct 2008
Location: EU
Posts: 163
Lightbulb

Quote:
Originally Posted by thomas View Post
Don't know of which early days you are speaking. When I was writing intros for the Amiga (almost 20 years ago, the real early days), ...
Speaking about 1986-89. Many early small (boot)intros (e.g. HQC) use a normal graphics.library system-friendly bitmap and rastport with Move(), Text(), Draw(), etc. (some with the mentioned 60/80-chars problem mentioned by Toni), many bigger intros used diskfont.library with system-, later own bitmap-fonts and simple copper-bars (look for HQC-CruncherFactory.lha, HQC-GuildOfTheves.lha, Megaforce-CrCrazyCars.lha, RCAP-CrSpaceRacer.adf, etc.).

A during development of above method created onefile version of HQC-CruncherFactory can be found at http://kestra.exotica.org.uk/demo.php?id=1366

Got my first Amiga in 1986, C-Monitor was my "programming tool" at that time, Kuma Seka Assembler from Andelos (in a RAW: window!) was next, a big step after C-Mon, later I bought ASM-One 1.02, ...
a4k-oerx is offline  
Old 29 November 2008, 13:02   #7
hit
Registered User
 
Join Date: Jun 2008
Location: planet earth
Posts: 1,115
<CODE>
lea newcop(pc),a0
move.l a0,$dff080
</CODE>

here you "simply" put the startadress of copper code into dff080 and the copper starts "dancing" ?
hit is offline  
Old 30 November 2008, 00:55   #8
a4k-oerx
Registered User
 
Join Date: Oct 2008
Location: EU
Posts: 163
Yes.

But you have to save the gb_ActiView and restore it later and restart the old/previous copperlist after your own program, located at gb_copinit of gfxbase to $dff080, see italic lines in sourcecode...

There are various ways to get a new copperlist started, the here quoted way is the most compatible.

Last edited by a4k-oerx; 30 November 2008 at 01:04.
a4k-oerx is offline  
Old 30 November 2008, 15:37   #9
hit
Registered User
 
Join Date: Jun 2008
Location: planet earth
Posts: 1,115
ah, i see. thanks
hit is offline  
Old 05 December 2008, 11:47   #10
Spellcoder
Spellcoder
 
Spellcoder's Avatar
 
Join Date: Aug 2006
Location: The Netherlands
Age: 44
Posts: 27
Maybe it's usefull to build into a kind of KillAGA program, with the choice to use the old (up to ks 1.3 Serif based) Topaz or the new (ks 2.0+ Sans-Serif based) Topaz.

Years ago I tried to make a tool called RunIntro which could batch run Intros. It would totally kill the system, make a backup of the chipmem, load the hunks from the intro, run an intro and with an interrupt kill it after X seconds, restore the original stackpointers and chipmem contents and go to the next intro. Also it would try to prevent crashes by overriding the exceptions during running of an intro.

Trouble is it was quite hacky, intros could still kill my interrupt and the system would still crash sometimes. Last time I worked on it I was trying to use trace to detect/prevent killing my interrupt during the first few seconds. But the complexity went a bit above my head, so I abandoned the project.
But maybe I'll go back to the project when I have the time and will try bolting your font solution to it :P.
Spellcoder is offline  
Old 18 December 2008, 12:29   #11
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
SpellCoder, maybe

list MyDemos >DH0:MyBatchFile
execute MyBatchFile

?

A4k-oerx, you are doing good and needed work. I.e. caring which code is compatible with a4k _and_ old systems Most of the time it's a one way street, many just make old stuff run on new Amigas and we who don't have the latest 68060 Amigas or, in my case, prefer OCS style, are left with 'run OCS stuff on AGA with accel or be damned'. :S

Exaggerated, yes, but true.
Photon is offline  
Old 18 December 2008, 12:42   #12
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Photon View Post

Exaggerated, yes, but true.
I whole heartily disagree (about the "true" thing, exaggerated it surely is).

Quote:
many just make old stuff run on new Amigas and we who don't have the latest 68060 Amigas or, in my case, prefer OCS style, are left with 'run OCS stuff on AGA with accel or be damned'. :S
"just" making stuff run on newer Amigas is often a lot of work. 68000/A500 is one thing, 680x0 Amigas a completely different one. Often it is impossible to avoid slowdowns on non-68000 systems for the demo/game to work correctly. So you have 2 choices: Either watch it on 68000 only(!) or watch it on 680x0 where it might run a little slower than intended but at least it runs. What's better?
StingRay is offline  
Old 18 December 2008, 13:16   #13
Analog-X64
 
Posts: n/a
Quote:
Originally Posted by thomas View Post
Don't know of which early days you are speaking. When I was writing intros for the Amiga (almost 20 years ago, the real early days), people were using pictures as font sources. See example attachment.
There were many creative/talented people making these bitmap fonts for Demos. Would love to see more. Is the attachment from your personal collection? Or is there a site?
 
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for powerpci.library 2.14 or better AmigaOneFan request.Other 4 06 November 2012 20:40
Math library? Tiddlypeeps Coders. General 5 08 April 2010 19:45
blitz incbin.. yoki Coders. General 5 03 April 2009 12:29
HDToolBox > Unable to find diskfont library W4r3DeV1L support.Apps 2 06 November 2008 12:10
Making a shared library from a gcc .a library JoJo Coders. General 1 10 March 2003 19:06

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:18.

Top

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