CPCWiki forum

General Category => Programming => Topic started by: syntaxhorror on 12:39, 26 September 18

Title: #CPCTELERA any lib available for using custom fonts?
Post by: syntaxhorror on 12:39, 26 September 18
Hi folks,
I'm working on a thing with CPCTelera (nice bit of software by the way) and I'd like to use a custom font with CPCTelera's text printing routines instead of the system font. A quick google hasn't turned up anything usable, I wonder if someone has made something publicly available somewhere? I could roll my own but it would take time and would probably be a lot less efficient than something implemented by someone who knows what they're doing :D
Just to be sure I tried redefining a symbol in basic before launching a program, but of course it doesn't work, I assume CPCTelera's text printing routines grab the characters directly from the firmware, not from the memory zone where SYMBOL characters reside.
Any help appreciated!
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: ronaldo on 18:15, 26 September 18
If you are using #CPCtelera's drawString routines, it is highly advisable for you to use latest development version of #CPCtelera (clone repository with git, change to development branch with git checkout, then install with setup). Latest #CPCtelera's drawString routines at way faster and smaller than previous routines.

If you want your own fonts, you have basically 2 options:
.globl cpct_drawCharM0_inner_asm

   ;; Enable Lower ROM during char copy operation, with interrupts disabled
   ;; to prevent firmware messing things up
;;*;;   ld     a,(_cpct_mode_rom_status) ;; [4] A = mode_rom_status (present value)
;;*;;   and    #0b11111011               ;; [2] bit 3 of A = 0 --> Lower ROM enabled (0 means enabled)
;;*;;   ld     b, #GA_port_byte          ;; [2] B = Gate Array Port (0x7F)
;;*;;   di                               ;; [1] Disable interrupts to prevent firmware from taking control while Lower ROM is enabled
;;*;;   out   (c), a                     ;; [3] GA Command: Set Video Mode and ROM status (100)

   jr    firstChar                  ;; [3] Jump to first char (Saves 1 jr back every iteration)

nextChar:
   ;; Draw next character
   push  hl                         ;; [4] Save HL
   call  cpct_drawCharM0_inner_asm  ;; [5 + 824/832] Draws the next character
   pop   hl                         ;; [3] Recover HL

   ;; Increment Pointers
   ld    de, #4                     ;; [3] /
   add   hl, de                     ;; [3] | HL += 4 (point to next position in video memory, 8 pixels to the right)
   inc   iy                         ;; [3] IX += 1 (point to next character in the string)

firstChar:
   ld     a, (iy)                   ;; [5] A = next character from the string
   or     a                         ;; [1] Check if A = 0
   jr    nz, nextChar               ;; [2/3] if A != 0, A is next character, draw it, else end

endstring:
   ;; After finishing character drawing, restore previous ROM and Interrupts status
;;*;;   ld     a, (_cpct_mode_rom_status) ;; [4] A = mode_rom_status (present saved value)
;;*;;   ld     b, #GA_port_byte           ;; [2] B = Gate Array Port (0x7F)
;;*;;   out   (c), a                      ;; [3] GA Command: Set Video Mode and ROM status (100)
;;*;;   ei                                ;; [1] Enable interrupts

;; IX/IY Restore and Return provided by bindings

   by commenting out all code that I have marked with ;;*;; you make the function read from RAM instead of reading from ROM. Then, the function expects character definitions to be in memory in [0x3800-0x3FFF]. You can put your own font definitions there, and #CPCtelera will then render your characters.

   You don't need to use the full range. If you use only capital letters, for instance, A-Z then you only need characters 65 to 90. Each character takes 8 bytes for its definition, so character A will be placed at 0x3800 + 8*65 = 0x3A08, and character Z will start at 0x3800 + 8*90 = 0x3AD0. Therefore, if you put your definitions from 0x3A08 to 0x3AD7 (Character Z takes last 8 bytes), then #CPCtelera's drawString functions will render them. Assuming you never draw the other characters, you may freely use the rest of the memory range.

   Remember to compile #CPCtelera library after any change to its sources. Just enter cpctelera/cpctelera/ folder and type in "make".
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: ervin on 04:00, 27 September 18
That's really useful information; thanks Ronaldo.
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: syntaxhorror on 12:10, 27 September 18
Thank you very much Ronaldo, that's precious information! I just checked the dev branch, I'll give it a try later. Not sure which solution I'll go with, it'll probably depend on how much memory I have to work with, I'll update here with my findings.
Thanks again!
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 23:48, 24 January 21
Hi good afternoon.

----------------------------

Remember to compile #CPCtelera library after any change to its sources. Just enter cpctelera/cpctelera/ folder and type in "make".
----------------------------

i have my scr in .../cpctelera-1.5/cpctelera/src/strings/cpct_drawStringM0.asm
.../cpctelera-1.5/cpctelera/  make
is processed. but my data are not displayed by "A"


the "A" has been changed but is not displayed as such :0x3A08.
the "A" is not changed.




#include <cpctelera.h>


void main () {
   u8* pvmem;
   u8 *pascii = (u8 *)0x3A08;


   cpct_disableFirmware();
   cpct_setVideoMode(0);
   
   *pascii=255;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
  ++pascii;   
  *pascii=129;
  ++pascii;   
  *pascii=129;
  ++pascii;   
  *pascii=129;
  ++pascii;   
*pascii=255;

   pvmem = cpctm_screenPtr(CPCT_VMEM_START, 16, 88);                         
   cpct_drawStringM0("A", pvmem);         


   while(1);
}


greeting
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: SpDizzy on 12:05, 25 January 21
You need to put your character definitions on 0x3A08 onwards.

You are just filling memory positions 0x3A08,  0x3A09,  0x3A0A,  0x3A0B with those 4 bytes:

0xFF, 0x81, 0x81, 0xFF

That's not an "A" :(

Moreover, each character takes 8 bytes for it's definition.

Also, ensure you had commented out all code that @ronaldo (https://www.cpcwiki.eu/forum/index.php?action=profile;u=1227) marked, as for not enabling lower ROM and force read characters from RAM instead.
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 13:58, 25 January 21
thanks.

no, I don't want to fill the "A" but only the "A" from 0x3a08 with my four dates. the letter "A" (65) is 0x3a08.


---------------------

*pascii=255;

   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
  ++pascii;
   *pascii=129;
  ++pascii;
   *pascii=129;
  ++pascii;
   *pascii=129;
  ++pascii;
  *pascii=255;
 
--------------------------

greeting




;;-----------------------------LICENSE NOTICE------------------------------------
;;  This file is part of CPCtelera: An Amstrad CPC Game Engine
;;  Copyright (C) 2018 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
;;
;;  This program is free software: you can redistribute it and/or modify
;;  it under the terms of the GNU Lesser General Public License as published by
;;  the Free Software Foundation, either version 3 of the License, or
;;  (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU Lesser General Public License for more details.
;;
;;  You should have received a copy of the GNU Lesser General Public License
;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;-------------------------------------------------------------------------------
.module cpct_strings


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Function: cpct_drawStringM0
;;
;;    Draws a null-terminated string with ROM characters to video memory or
;; to a hardware backbuffer in Mode 0 (160x200, 16 colours).
;;
;; C Definition:
;;    void <cpct_drawStringM0> ( void* *string*, void* *video_memory*) __z88dk_callee
;;
;; Input Parameters (4 Bytes):
;;  (2B IY) string       - Pointer to the null terminated string being drawn
;;  (2B HL) video_memory - Video memory location where the string will be drawn
;;
;; Assembly call (Input parameters on registers):
;;    > call cpct_drawStringM0_asm
;;
;; Parameter Restrictions:
;;  * *string* must be a null terminated string. It could contain any 8-bit value as
;; characters except 0, which will signal the end of the string. Be careful to provide
;; strings with a 0 (null) at the end of the string. Otherwise, unexpected results may
;; happen (Typically, rubbish characters printed on screen and, occasionally, memory
;; overwrite and even hangs or crashes).
;;  * *video_memory* could theoretically be any 16-bit memory location. It will work
;; outside current screen memory boundaries, which is useful if you use any kind of
;; double buffer. However, be careful where you use it, as it does no kind of check
;; or clipping, and it could overwrite data if you select a wrong place to draw.
;;
;; Requirements and limitations:
;;  * *Do not put this function's code below 0x4000 in memory*. In order to read
;; characters from ROM, this function enables Lower ROM (which is located 0x0000-0x3FFF),
;; so CPU would read code from ROM instead of RAM in first bank, effectively shadowing
;; this piece of code. This would lead to undefined results (typically program would
;; hang or crash).
;;  * This routine does not check for boundaries. If you draw too long strings or out
;; of the screen, unpredictable results will happen.
;;  * Screen must be configured in Mode 0 (160x200 px, 16 colours)
;;  * This function *disables interrupts* during main loop (character printing), and
;; re-enables them at the end.
;;  * This function *will not work from ROM*, as it uses self-modifying code.
;;
;; Details:
;;    This function receives a null-terminated string and draws it to the screen in
;; Mode 0 (160x200, 16 colours). To do so, it repeatedly calls <cpct_drawCharM0_inner_asm>,
;; for every character to be drawn. As foreground and background colours it uses the
;; ones previously set up by the latest call to <cpct_setDrawCharM0>.
;;
;;   *video_memory* parameter points to the byte where the string will be
;; drawn. The first pixel of that byte will be the upper-left corner of the string.
;; As this function uses a byte-pointer to refer to the upper-left corner of the
;; string, it can only draw string on even-pixel columns (0, 2, 4, 6...), as
;; every byte contains 2 pixels in Mode 0.
;;
;;    Usage of this function is quite straight-forward, as you can see in the
;; following example,
;; (start code)
;;    // Just print some strings for testing
;;    void main () {
;;       u8* pvmem;  // Pointer to video memory
;;
;;       // Set video mode 0
;;       cpct_disableFirmware();
;;       cpct_setVideoMode(0);
;;
;;       // Draw some testing strings with curious colours, more or less centered
;;       pvmem = cpctm_screenPtr(CPCT_VMEM_START, 16, 88);  // Calculate video memory address
;;       cpct_setDrawCharM0(3, 5);                          // Red over black
;;       cpct_drawStringM0("Hello there!", pvmem);          // Draw the string
;;
;;       pvmem = cpctm_screenPtr(CPCT_VMEM_START, 20, 108); // Calculate new video memory address
;;       cpct_setDrawCharM0(1, 9);                          // Bright yellow over yellow
;;       cpct_drawStringM0("Great man!",   pvmem);          // Draw the string
;;
;;       // And loop forever
;;       while(1);
;;    }
;; (end code)
;;
;; Destroyed Register values:
;;    C bindings  - AF, BC, DE, HL
;;  ASM bindings  - AF, BC, DE, HL, IX, IY
;;
;; Required memory:
;;    C bindings  - 58 (+100 cpct_drawCharM0_inner_asm = 158 bytes)
;;  ASM bindings  - 38 (+100 cpct_drawCharM0_inner_asm = 138 bytes)
;;
;; Time Measures:
;; (start code)
;;   Case     | microSecs (us) | CPU Cycles
;; ----------------------------------------------
;;   Best     |    74 + 854*L  |  296 + 3416*L 
;;   Worst    |    74 + 862*L  |  296 + 3448*L
;; ----------------------------------------------
;; Asm saving |      -38       |     -152
;; ----------------------------------------------
;; (end code)
;;    L = Length of the string (excluding null-terminator character)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


.globl cpct_drawCharM0_inner_asm


   ;; Enable Lower ROM during char copy operation, with interrupts disabled
   ;; to prevent firmware messing things up
;;  ld     a,(_cpct_mode_rom_status) ;; [4] A = mode_rom_status (present value)
;;   and    #0b11111011               ;; [2] bit 3 of A = 0 --> Lower ROM enabled (0 means enabled)
;;   ld     b, #GA_port_byte          ;; [2] B = Gate Array Port (0x7F)
;;   di                               ;; [1] Disable interrupts to prevent firmware from taking control while Lower ROM is enabled
;;   out   (c), a                     ;; [3] GA Command: Set Video Mode and ROM status (100)


   jr    firstChar                  ;; [3] Jump to first char (Saves 1 jr back every iteration)


nextChar:
   ;; Draw next character
   push  hl                         ;; [4] Save HL
   call  cpct_drawCharM0_inner_asm  ;; [5 + 824/832] Draws the next character
   pop   hl                         ;; [3] Recover HL


   ;; Increment Pointers
   ld    de, #4                     ;; [3] /
   add   hl, de                     ;; [3] | HL += 4 (point to next position in video memory, 8 pixels to the right)
   inc   iy                         ;; [3] IX += 1 (point to next character in the string)


firstChar:
   ld     a, (iy)                   ;; [5] A = next character from the string
   or     a                         ;; [1] Check if A = 0
   jr    nz, nextChar               ;; [2/3] if A != 0, A is next character, draw it, else end


endstring:
   ;; After finishing character drawing, restore previous ROM and Interrupts status
;;   ld     a, (_cpct_mode_rom_status) ;; [4] A = mode_rom_status (present saved value)
;;   ld     b, #GA_port_byte           ;; [2] B = Gate Array Port (0x7F)
;;   out   (c), a                      ;; [3] GA Command: Set Video Mode and ROM status (100)
;;   ei                                ;; [1] Enable interrupts


;; IX/IY Restore and Return provided by bindings
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: SpDizzy on 14:21, 25 January 21
Attached results from your first, and second code:

First one: (4 bytes definition on  0x3A08)
https://www.dropbox.com/s/stg5bbohbu0vhm7/first_code.bmp (https://www.dropbox.com/s/stg5bbohbu0vhm7/first_code.bmp)

Second one: ("Hello there!" "Great man" from RAM with no own char definition)
https://www.dropbox.com/s/9jdumfcn6h2p7fh/second_code.bmp (https://www.dropbox.com/s/9jdumfcn6h2p7fh/second_code.bmp)

I can see everyting working as expected, that's not your case?
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 14:38, 25 January 21

my data are not coming yet.


do I make an error when compiling?


thanks.
greeting
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: SpDizzy on 14:44, 25 January 21
Quote from: funkheld on 14:38, 25 January 21do I make an error when compiling?

Yes, that´s the error.

Clean first compiled objects, then make:

make clean
make
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 15:06, 25 January 21

hello thanks for help.
is ok.


greeting
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: SpDizzy on 15:28, 25 January 21
Great. Glad to help
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 16:16, 25 January 21

how much char can you change for mode 0 without the control characters?


thanks.
greeting
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: SpDizzy on 19:34, 25 January 21
Quote from: funkheld on 16:16, 25 January 21how much char can you change for mode 0 without the control characters?

You can define full character set, the memory is fully yours
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 20:12, 25 January 21
Hi good afternoon.

I also adjusted this:
cpct_drawCharM0

now I can start at 0x3800.
I was unable to reach 0x3800 with a string.

greeting



;;-----------------------------LICENSE NOTICE------------------------------------
;;  This file is part of CPCtelera: An Amstrad CPC Game Engine
;;  Copyright (C) 2018 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
;;
;;  This program is free software: you can redistribute it and/or modify
;;  it under the terms of the GNU Lesser General Public License as published by
;;  the Free Software Foundation, either version 3 of the License, or
;;  (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU Lesser General Public License for more details.
;;
;;  You should have received a copy of the GNU Lesser General Public License
;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;-------------------------------------------------------------------------------
.module cpct_strings


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Function: cpct_drawCharM0
;;
;;    Draws a ROM character to the screen or hardware back-buffer in Mode 0 format
;; (160x200 px, 16 colours).
;;
;; C Definition:
;;    void <cpct_drawCharM0> (void* *video_memory*, <u8> *ascii*) __z88dk_callee
;;
;; Input Parameters (3 Bytes):
;;  (2B HL) video_memory - Video memory location where the character will be drawn
;;  (1B E ) ascii        - Character to be drawn (ASCII code)
;;
;; Assembly call (Input parameters on registers):
;;    > call cpct_drawCharM0_asm
;;
;; Parameter Restrictions:
;;  * *video_memory* could theoretically be any 16-bit memory location. It will work
;; outside current screen memory boundaries, which is useful if you use any kind of
;; double buffer. However, be careful where you use it, as it does no kind of check
;; or clipping, and it could overwrite data if you select a wrong place to draw.
;;  * *ascii* could be any 8-bit value, as 256 characters are available in ROM.
;;
;; Requirements and limitations:
;;  * *Do not put this function's code below 0x4000 in memory*. In order to read
;; characters from ROM, this function enables Lower ROM (which is located 0x0000-0x3FFF),
;; so CPU would read code from ROM instead of RAM in first bank, effectively shadowing
;; this piece of code. This would lead to undefined results (typically program would
;; hang or crash).
;;  * Screen must be configured in Mode 0 (160x200 px, 16 colours)
;;  * This function *disables interrupts* during main loop (character printing), and
;; re-enables them at the end.
;;  * This function *will not work from ROM*, as it uses self-modifying code.
;;
;; Details:
;;    This function reads a character from ROM and draws it at a given byte-aligned
;; video memory location, that corresponds to the upper-left corner of the
;; character. As this function assumes screen is configured for Mode 0
;; (160x200, 16 colours), it means that the character can only be drawn at even
;; pixel columns (0, 2, 4, 8...), because each byte contains 2 pixels in Mode 0.
;;
;;    The character will be drawn using preconfigured foreground (FG) and
;; background (BG) colours (by default BG=0, FG=1). Both colours can be set
;; calling <cpct_setDrawCharM0> before calling this function. Colours get set
;; by modifying and internal 4-byte array called _dc_2pxtableM0_. This means
;; that once colours are set they stay. You may set them once and call
;; this function as many times as you want to draw with the same set of colours.
;;
;;    Next code example shows how to use this function in conjunction with
;; <cpct_setDrawCharM0>,
;; (start code)
;;    void drawSomeCharacters(u8* pscreen) {
;;       cpct_setDrawCharM0(5, 0);        // Foreground colour 5, Background 0
;;
;;       // Draw A, B, C consecutive
;;       cpct_drawCharM0(pscreen + 0, 'A');
;;       cpct_drawCharM0(pscreen + 4, 'B');
;;       cpct_drawCharM0(pscreen + 8, 'C');
;;
;;       // Set video inverse (inverted colours from before)
;;       cpct_setDrawCharM0(0, 5);        // Foreground colour 0, Background 5
;;
;;       // Draw D, E, F consecutive in inverse video
;;       cpct_drawCharM0(pscreen + 16, 'D');
;;       cpct_drawCharM0(pscreen + 20, 'E');
;;       cpct_drawCharM0(pscreen + 24, 'F');
;;    }
;; (end code)
;;
;; Destroyed Register values:
;;    C bindings     - AF, BC, DE, HL
;;    ASM bindings   - AF, BC, DE, HL, IX
;;
;; Required memory:
;;    C bindings   - 35 bytes (+100 from cpct_drawCharM0_inner_asm = 135 bytes)
;;    ASM bindings - 23 bytes (+100 from cpct_drawCharM0_inner_asm = 123 bytes)
;;
;; Time Measures:
;; (start code)
;;   Case     | microSecs | CPU Cycles
;; -------------------------------------
;;   Best     |    880    |    3520
;;   Worst    |    888    |    3552
;; -------------------------------------
;; Asm saving |    -25    |    -100
;; -------------------------------------
;; (end code)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


.globl cpct_drawCharM0_inner_asm


   ;; Enable Lower ROM during char copy operation, with interrupts disabled
   ;; to prevent firmware messing things up
;;   ld     a,(_cpct_mode_rom_status)  ;; [4] A = mode_rom_status (present value)
;;   and    #0b11111011                ;; [2] bit 3 of A = 0 --> Lower ROM enabled (0 means enabled)
;;   ld     b, #GA_port_byte           ;; [2] B = Gate Array Port (0x7F)
;;   di                                ;; [1] Disable interrupts to prevent firmware from taking control while Lower ROM is enabled
;;   out   (c), a                      ;; [3] GA Command: Set Video Mode and ROM status (100)


   ;; Draw the character
   ld     a, e                       ;; [1] A = ASCII Value of the character
   call   cpct_drawCharM0_inner_asm  ;; [828/837] Does the actual drawing to screen


endDraw:
   ;; After finishing character printing, restore previous ROM and Interrupts status
;;   ld     a, (_cpct_mode_rom_status) ;; [4] A = mode_rom_status (present saved value)
;;   ld     b, #GA_port_byte           ;; [2] B = Gate Array Port (0x7F)
;;   out   (c), a                      ;; [3] GA Command: Set Video Mode and ROM status (100)
;;   ei                                ;; [1] Enable interrupts


;; Restore IX and Return provided by bindings








#include <cpctelera.h>


void main () {
   u8* pvmem;
   u8 *pascii = (u8 *)0x3800;
   u16 z;


   cpct_disableFirmware();
   cpct_setVideoMode(0);
   
// 0   
   *pascii=255;   
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=255;


// 1
   ++pascii;
   *pascii=255;   
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=255;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=255;
   
   cpct_setDrawCharM0(3,1);
   pvmem = cpct_getScreenPtr(CPCT_VMEM_START,0,0);
   cpct_drawCharM0(pvmem,0);
   pvmem = cpct_getScreenPtr(CPCT_VMEM_START,4,0);
   cpct_drawCharM0(pvmem, 1);
   pvmem = cpct_getScreenPtr(CPCT_VMEM_START,8,0);
   cpct_drawCharM0(pvmem, 0);


   while(1);
}
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 14:52, 26 January 21

Hi good afternoon.
how can you please load the char from the rom to 0x3800?


thanks.
greeting
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: SRS on 15:55, 26 January 21
You just use unmodified CPCTELERA library, like written in ronaldos post, as it is the standard documented behaviour.
Title: Re: #CPCTELERA any lib available for using custom fonts?
Post by: funkheld on 16:48, 03 February 21
have now created a new one: cpct_drawCharM00.
can now change the chars.

this in strings.h:
extern void cpct_drawCharM00    (void* video_memory, u16 ascii) __z88dk_callee;

4 new files in the folder cpctelera/src
cpctelera/make clean and then make.


greeting




#include <cpctelera.h>


void main () {
   u8* pvmem;
   u8 *pascii = (u8 *)0x3800; // 0
   u16 z;


   cpct_disableFirmware();
   cpct_setVideoMode(0);
   
// 0   
   *pascii=255;   
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=255;


// 1
   ++pascii;
   *pascii=255;   
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=255;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=129;
   ++pascii;
   *pascii=255;
   
   cpct_setDrawCharM0(3,1);
   pvmem = cpct_getScreenPtr(CPCT_VMEM_START,0,0);
   cpct_drawCharM00(pvmem,0);
   
   cpct_setDrawCharM0(7,4);
   pvmem = cpct_getScreenPtr(CPCT_VMEM_START,4,0);
   cpct_drawCharM00(pvmem, 1);
   
   cpct_setDrawCharM0(5,3);
   pvmem = cpct_getScreenPtr(CPCT_VMEM_START,8,0);
   cpct_drawCharM00(pvmem, 0);


   while(1);
}
Powered by SMFPacks Menu Editor Mod