28 November 2008, 00:12 | #1 |
Registered User
Join Date: Oct 2008
Location: EU
Posts: 163
|
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 Had to share this, if nobody is interested, never mind! Last edited by a4k-oerx; 30 November 2008 at 01:03. |
28 November 2008, 20:59 | #2 |
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? |
28 November 2008, 23:01 | #3 | ||
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,987
|
Quote:
Quote:
|
||
28 November 2008, 23:21 | #4 |
Registered User
Join Date: Jun 2008
Location: planet earth
Posts: 1,115
|
oh, "vector". *gosh* thanks
|
28 November 2008, 23:51 | #5 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,507
|
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..
|
29 November 2008, 02:06 | #6 | |
Registered User
Join Date: Oct 2008
Location: EU
Posts: 163
|
Quote:
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, ... |
|
29 November 2008, 13:02 | #7 |
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" ? |
30 November 2008, 00:55 | #8 |
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. |
30 November 2008, 15:37 | #9 |
Registered User
Join Date: Jun 2008
Location: planet earth
Posts: 1,115
|
ah, i see. thanks
|
05 December 2008, 11:47 | #10 |
Spellcoder
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. |
18 December 2008, 12:29 | #11 |
Moderator
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. |
18 December 2008, 12:42 | #12 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
I whole heartily disagree (about the "true" thing, exaggerated it surely is).
Quote:
|
|
18 December 2008, 13:16 | #13 |
Posts: n/a
|
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 |
|
|