CPCWiki forum

General Category => Programming => Topic started by: hlabrande on 07:02, 18 December 21

Title: Modifying the font in a CPM program?
Post by: hlabrande on 07:02, 18 December 21
Hello,I am not that well-versed in CPC BASIC programming so apologies in advance :)I have a script that displays a picture then starts a program with |cpm. That program doesn't display accented characters well, and I need to change the font.I have written a bunch of SYMBOL statements that give me what I want... in theory. In practice, I ran into problems:Would anyone know what I am doing wrong?I can send the code to someone as a PM but I don't want to post it publicly (I'm not the one who wrote the original script).Thank you :)
Title: Re: Modifying the font in a CPM program?
Post by: SRS on 19:11, 18 December 21
Maybe this article may be giving the hint you need ?
https://cpcrulez.fr/applications_util-sonderzeichen_fur_cpm.htm (https://cpcrulez.fr/applications_util-sonderzeichen_fur_cpm.htm)
It's using the soundbuffer (so no sound for cp/m)
Title: Re: Modifying the font in a CPM program?
Post by: hlabrande on 01:19, 19 December 21
Oh, thank you very much for this link! This looks very promising. (And much more complicated than I thought... But it's good to know that SYMBOL doesn't work with CPM).No sound is fine for my application, so that could work!

Google Translate is not very clear on some aspects though... What is "DIN"? And I am also not sure I would be able to adapt this to my purposes; I have 20 characters I need to redefine, and they're not in a sequence, so I'm not sure how this DATA command can be adapted. Maybe I'll experiment... but if someone has an idea, I have attached my symbol commands to this post.
Thank you for your help, I appreciate it!
Title: Re: Modifying the font in a CPM program?
Post by: ralferoo on 11:26, 19 December 21
I think DIN here refers to the standard German keyboard layout. DIN is the German standards association, like BS for British standards, ANSI for American standards and ISO for international standards.
Title: Re: Modifying the font in a CPM program?
Post by: NotFound on 02:11, 15 February 22
SYMBOL can be used from CP/M Plus, using the USERF Bios function to invoke the firmware TXT_SET_MATRIX call. Any symbol can be redefined, just like after using SYMBOL AFTER 0 in Locomotive Basic.
Title: Re: Modifying the font in a CPM program?
Post by: NotFound on 11:49, 15 February 22
This program will do it:
SYMBOL.ASM
; Symbol
; The Basic SYMBOL command in Amstrad CPC CP/M PLus

; CP/M page 0 address
bios_jumps    equ 1
argline    equ 00080h

; CPC firmware address
txt_set_matrix    equ 0BBA8h

start:
    org 100h

    call init_data

    ld hl, argline + 1

    call skip_spaces
    call get_num

    ld a, b
    ld [charcode], a

    ld de, chartable
nextvalue:
    call skip_spaces
    or a
    jr z, doit
    cp 0Dh
    jr z, doit
    call get_num
    ld a, b
    ld [de], a
    inc de
    jr nextvalue

doit:
    ld a, [charcode]
    ld hl, chartable
    call do_userf
    dw txt_set_matrix
    call 0

skip_spaces:
    ld a, [hl]
    cp ' '
    ret nz
    inc hl
    jr skip_spaces

get_num:
    ld b, 0
digit:
; Multipliy by 10
    ld a, b
    add a, a
    ld b, a
    add a, a
    add a, a
    add a, b
    ld b, a
; Add current digit
    ld a, [hl]
    sub '0'
    add a, b
    ld b, a
    inc hl
    ld a, [hl]
    cp ' '
    ret z
    cp 0Dh
    ret z
    cp 0
    ret z
    jr digit

init_data:
; Fill the character data with 0
    ld hl, chartable
    xor a
    ld b, 8
init_more:
    ld [hl], a
    inc hl
    djnz init_more
    ret

;---------------------------------------
do_userf:
    push hl
    push de
    ld hl, [bios_jumps]
    ld de, 057h    ; Offset to USERF
    add hl, de
    pop de
    ex [sp], hl
    ret

;---------------------------------------
charcode    db 0

; Must be in the high 16K
chartable    equ 0C000h

    end start
;---------------------------------------


If you don't have a Z80 assembler:

SYMBOL.HEX:10010000CD5501218100CD3301CD3A0178326C010A
:100110001100C0CD3301B7280CFE0D2808CD3A01DF
:1001200078121318EE3A6C012100C0CD6001A8BB13
:10013000CD00007EFE20C02318F90600788747878F
:100140008780477ED6308047237EFE20C8FE0DC8BC
:10015000FE00C818E72100C0AF0608772310FCC9CD
:0D016000E5D52A010011570019D1E3C900AF
:00000001FF

Use HEXCOM SYMBOL.HEX to create SYMBOL.COM

Example use:
SYMBOL 97 255 127 63 31 15 7 3 1
Redefine 'a' to a triangle.
Powered by SMFPacks Menu Editor Mod