22 March 2023, 10:20 | #1 |
Registered User
Join Date: May 2017
Location: AmigaLand
Posts: 459
|
Amiga fonts in ASM
Hi all,
Context : Amiga 500 1.3 (512/512) I'd like to convert a fixed size .font file into RAW data in order to be used in a non system program (game, demo etc...). Here what I got when I try : I could use PPaint and display it by typing chars, but in this case I'd not have all ascii codes, but I need them all (from ascii code 0 to 255). What would be the easiest way ? I noticed also a small file coming with the font itself ("name font".font and in subdirectory a file number which could be the datas font), I guess infos are in this one (?). Thanks. Last edited by LeCaravage; 22 March 2023 at 10:27. |
22 March 2023, 10:37 | #2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
Not sure if there are good converters already. Maybe http://aminet.net/dev/c/fontconverter.lha ?
Otherwise you can still write a small program which uses the OS to output all characters into a Bitmap. Then grab and save it from there in the format you need. |
22 March 2023, 10:37 | #3 |
Registered User
Join Date: Sep 2019
Location: Finland
Posts: 365
|
I've done something like this by loading the font using "diskfont.library", then shutting down the system, and then using the loaded font data with custom routines. The font can be automatically converted after loading into whatever format you like, or used as is.
|
22 March 2023, 17:51 | #4 |
Registered User
Join Date: May 2017
Location: AmigaLand
Posts: 459
|
@all :
I tried to load the font and display them in a custom screen in order to save a portion of bitplan in Raw format. I used the source code of someone else, the screen displays but the chars don't, for some reason : Code:
; Using a diskfont without diskfont.library incdir "include/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) move.w #0,d0 move.w #100,d1 move.l a4,a1 jsr _LVOMove(a6) lea text2(pc),a0 moveq #0,d0 move.w #text2_end-text2,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 text2 dc.b "fonts/opal/9" text2_end gfxname dc.b "graphics.library",0 cnop 0,2 gfxbase dc.l 0 oldview dc.l 0 font incbin "fonts/opal/9" 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 |
22 March 2023, 18:47 | #5 |
Registered User
Join Date: Sep 2019
Location: Finland
Posts: 365
|
I think you're assuming the structure of the disk font format to be TextFont whereas it actually is DiskFontHeader, see
http://amigadev.elowar.com/read/ADCD.../node03E0.html |
22 March 2023, 18:56 | #6 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,043
|
You could try gfxlib OpenFont(), and then font->tf_CharData gives you raw data you can save to a file (or use a memory viewer/peeker to see how it looks like, etc).
Or use ARTM or similar to get info where it's at in memory and then use e.g. asm-one to look at the font structure, get tf_CharData and save it to a file. In my KS3.1 topaz8 rawdata is at $fb8d46, if you use a 320px wide screen set modulo to $98=152 to see it properly after copying it to chipmem. |
22 March 2023, 19:00 | #7 |
Registered User
Join Date: Sep 2019
Location: Finland
Posts: 365
|
Using a fixed 8x8 system font is not too difficult, no need for any conversion necessarily:
Code:
* a1 = target bitmap address, 320 pixels wide * a2 = OpenFont or OpenDiskFont result move.w tf_Modulo(a2),d4 move.l tf_CharData(a2),a2 * Output this character moveq #"K",d0 * Get address to the "K" glyph pixels lea -$20(a2,d0),a6 * Do 8 rows move.b (a6),(a1)+ add d4,a6 move.b (a6),1*40-1(a1) add d4,a6 move.b (a6),2*40-1(a1) add d4,a6 move.b (a6),3*40-1(a1) add d4,a6 move.b (a6),4*40-1(a1) add d4,a6 move.b (a6),5*40-1(a1) add d4,a6 move.b (a6),6*40-1(a1) add d4,a6 move.b (a6),7*40-1(a1) Last edited by koobo; 22 March 2023 at 19:07. |
23 March 2023, 11:47 | #8 | ||
Registered User
Join Date: Oct 2008
Location: EU
Posts: 163
|
Quote:
Quote:
The reason for no chars, your incbin path is wrong. Fixed it for you: Last edited by a4k-oerx; 23 March 2023 at 18:38. |
||
23 March 2023, 23:40 | #9 |
Moderator
Join Date: Nov 2001
Location: Germany
Posts: 869
|
Doesn't make sense to convert fonts as it is not hard to use them directly also without os.
Example taken from WHDLoad/Src/sources/whdload/savegame.s in https://whdload.de/whdload/WHDLoad_dev.lha: Code:
;-------------------------------- ; print char ; IN: d0 = word x ; d1 = word y ; d2 = char _pc movem.l d0-d7/a0-a2,-(a7) lea (_font,pc),a0 cmp.l #$3f3,(a0) bne .relok sub.l a1,a1 move.w #resload_Relocate,a2 movem.l d0-d1/a0,-(a7) bsr _sg_exec_resload movem.l (a7)+,d0-d1/a0 .relok lea (4+dfh_TF,a0),a2 ;A2 = TextFont cmp.b (tf_HiChar,a2),d2 bhi .out sub.b (tf_LoChar,a2),d2 bcc .in .out move.b (tf_HiChar,a2),d2 addq.b #1,d2 sub.b (tf_LoChar,a2),d2 .in and.w #$00ff,d2 lsl.w #2,d2 move.l (tf_CharLoc,a2),a0 movem.w (a0,d2.w),d2/d6 ;D2 = srcbitpos ;D6 = srclen move.w (tf_XSize,a2),d7 ;D7 = dstlen bsr _getscrptr ;A0 = dstptr move.l (tf_CharData,a2),a1 ;A1 = srcptr move.w (tf_YSize,a2),d3 subq.w #1,d3 .cp IFD _68020_ bfextu (a1){d2:d6},d1 lsl.l d6,d1 lsr.l d7,d1 bfins d1,(a0){d0:d6} ELSE move.l d2,d1 lsr.l #4,d1 ;words add.l d1,d1 ;bytes down rounded to word move.l (a1,d1.l),d1 move.l d2,d4 and.w #%1111,d4 lsl.l d4,d1 moveq #-1,d5 lsr.l d6,d5 not.l d5 and.l d5,d1 moveq #-1,d5 lsr.l d7,d5 move.l d0,d4 and.w #%1111,d4 lsr.l d4,d1 ror.l d4,d5 move.l d0,d4 lsr.l #4,d4 ;words add.l d4,d4 ;bytes down rounded to word and.l d5,(a0,d4.l) or.l d1,(a0,d4.l) ENDC add.w (tf_Modulo,a2),a1 add.l #LINE*8,d0 dbf d3,.cp movem.l (a7)+,d0-d7/a0-a2 rts IFND EXTSGFONT _font INCBIN Fonts:xen/8 ENDC |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ASM: Asm-ONE or AsmPro - how to set a Hello amiga coders, I hope it is ok to hijack ? | Fireball | Coders. Asm / Hardware | 3 | 08 May 2024 13:35 |
fonts for Amiga | jarre | Amiga scene | 7 | 01 December 2021 09:09 |
Tool to convert asm to gnu asm (gas) | Asman | Coders. Asm / Hardware | 13 | 30 December 2020 11:57 |
Amiga fonts to PC ? | abelthorne | support.Apps | 19 | 29 January 2018 20:35 |
Converted amiga fonts | thinlega | Amiga scene | 11 | 20 January 2003 17:58 |
|
|