News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Devilmarkus

Workshop: How to make a 3 coloured Font for BASIC?

Started by Devilmarkus, 16:30, 02 July 10

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Devilmarkus

Hi together,
I want to show a little workshop, how to create a coloured font for BASIC.
Restrictions:
- Font is unreadable in normal MODE 1, 2 or 0
- You need at least a CALL to set MODE 1 with aspect of 0 or my little RSX-Routine.

First, what you need, is a MODE 0-Screen containing your Font:


Then you need a Converter tool to convert this screen as 16k CPC screen.
(ConvImgCPC or JavaCPC Paint)
You need to create a locked palette:
PEN 1 = light red (6)
PEN 4 = orange (15)
PEN 5 = pastel yellow (25)
All other PEN's set to 0!!!

Alright, convert the screen now to CPC format with this palette.
Then, put your SCR file on a DSK.
When you load this SCR now under MODE 1 you will see it like:



RUN"FONTGEN" (my FontGen-Program) and set the parameters:
- Screenname: YOURFILE.SCR
- Savename: "MYFONT.BAS"
- Start offset: 32
- End offset: 122

You will see an unreadable result:



When the program has finished reading this "font" and stored your ASCII file:
Reset the CPC
LOAD"MYFONT.BAS"
10 MODE 1:CALL &BD1C
20 INK 0,0:INK 1,6:INK 4,15:INK 5,25 ' Set all other colours as you want
RUN

You see: a nice font in MODE 0 with 40 chars per line and 3 colours.

Alternative to MODE 1:CALL &BD1C is my little binary:
        nolist
        org #8000

        LD      HL,BufferRsx
        LD      BC,PtrRsx
        JP      #BCD1

PtrRsx:
        DW      RSX_TABLE
        JP      Mode

RSX_TABLE:
        DB      "MOD","E"+#80


Mode:
    LD A,1
    CALL &BC0E
    CALL &BD1C
    RET
       
BufferRsx:
        DS      4


New RSX-command:
|MODE
Sets the required screenmode.

Have fun!

Attachment: FontGen with all prepared files you need:
http://cpc-live.com/workshop/FontGen_1_0.dsk
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

For the BASIC-type-ins-freaks:

10 MODE 1:CALL &BD1C
20 INK 0,0:INK 1,6:INK 4,15:INK 5,25
7000 SYMBOL AFTER 32
7010 SYMBOL 32,0,0,0,0,0,0,0,0
7020 SYMBOL 33,10,10,2,2,8,0,8,0
7030 SYMBOL 34,170,34,0,0,0,0,0,0
7040 SYMBOL 35,0,0,0,0,0,0,0,0
7050 SYMBOL 36,64,234,224,64,74,234,64,0
7060 SYMBOL 37,170,10,80,16,16,32,136,0
7070 SYMBOL 38,170,170,80,34,34,136,64,0
7080 SYMBOL 39,10,2,0,0,0,0,0,0
7090 SYMBOL 40,10,80,80,16,16,64,8,0
7100 SYMBOL 41,80,10,10,2,2,8,64,0
7110 SYMBOL 42,0,170,16,16,136,0,0,0
7120 SYMBOL 43,0,80,80,50,16,64,0,0
7130 SYMBOL 44,0,0,0,0,80,80,32,0
7140 SYMBOL 45,0,0,0,50,0,0,0,0
7150 SYMBOL 46,0,0,0,0,0,80,16,0
7160 SYMBOL 47,10,10,80,16,16,32,128,0
7170 SYMBOL 48,178,34,136,136,136,136,200,0
7180 SYMBOL 49,80,48,64,64,64,64,64,0
7190 SYMBOL 50,178,34,8,64,128,128,200,0
7200 SYMBOL 51,178,2,8,72,8,8,200,0
7210 SYMBOL 52,162,34,136,200,8,8,8,0
7220 SYMBOL 53,178,32,128,200,8,8,200,0
7230 SYMBOL 54,178,32,128,200,136,136,200,0
7240 SYMBOL 55,178,2,8,8,8,8,8,0
7250 SYMBOL 56,178,34,136,200,136,136,200,0
7260 SYMBOL 57,178,34,136,200,8,8,8,0
7270 SYMBOL 58,0,80,16,0,0,80,16,0
7280 SYMBOL 59,0,0,80,0,80,16,128,0
7290 SYMBOL 60,10,80,32,32,64,8,0,0
7300 SYMBOL 61,0,0,50,0,200,0,0,0
7310 SYMBOL 62,160,80,2,2,64,128,0,0
7320 SYMBOL 63,80,170,10,2,16,0,64,0
7330 SYMBOL 64,80,170,170,162,50,32,24,0
7340 SYMBOL 65,80,162,162,178,34,40,136,0
7350 SYMBOL 66,240,162,162,176,34,40,96,0
7360 SYMBOL 67,80,162,160,32,32,40,64,0
7370 SYMBOL 68,240,162,162,34,34,40,96,0
7380 SYMBOL 69,242,160,160,48,32,32,200,0
7390 SYMBOL 70,242,160,32,48,32,32,128,0
7400 SYMBOL 71,80,162,160,34,34,40,64,0
7410 SYMBOL 72,162,162,162,50,34,40,40,0
7420 SYMBOL 73,242,80,16,16,16,64,200,0
7430 SYMBOL 74,242,80,16,16,16,64,128,0
7440 SYMBOL 75,162,162,176,48,34,40,136,0
7450 SYMBOL 76,160,160,160,32,32,32,104,0
7460 SYMBOL 77,162,178,178,34,34,40,136,0
7470 SYMBOL 78,162,162,178,34,34,40,136,0
7480 SYMBOL 79,80,162,162,34,34,136,64,0
7490 SYMBOL 80,240,162,34,48,32,32,128,0
7500 SYMBOL 81,80,162,162,34,34,96,72,0
7510 SYMBOL 82,240,162,34,48,34,40,136,0
7520 SYMBOL 83,80,162,160,16,2,136,64,0
7530 SYMBOL 84,242,80,80,16,16,64,64,0
7540 SYMBOL 85,162,162,162,34,34,136,64,0
7550 SYMBOL 86,162,162,162,34,40,64,64,0
7560 SYMBOL 87,162,162,162,34,34,104,136,0
7570 SYMBOL 88,162,162,162,16,34,40,136,0
7580 SYMBOL 89,162,162,162,50,16,64,64,0
7590 SYMBOL 90,242,2,80,32,32,32,200,0
7600 SYMBOL 91,162,0,16,162,50,40,136,0
7610 SYMBOL 92,162,0,16,162,34,136,64,0
7620 SYMBOL 93,162,0,162,34,34,136,64,0
7630 SYMBOL 94,80,90,242,16,16,64,64,0
7640 SYMBOL 95,0,0,0,0,0,0,0,204
7650 SYMBOL 96,80,16,8,0,0,0,0,0
7660 SYMBOL 97,0,0,240,2,50,136,200,0
7670 SYMBOL 98,160,160,240,162,34,136,200,0
7680 SYMBOL 99,0,0,80,162,32,136,72,0
7690 SYMBOL 100,90,10,250,162,34,136,200,0
7700 SYMBOL 101,0,0,80,162,50,128,72,0
7710 SYMBOL 102,90,80,80,178,16,64,192,0
7720 SYMBOL 103,0,0,90,162,34,72,8,200
7730 SYMBOL 104,160,160,160,50,34,136,136,0
7740 SYMBOL 105,80,0,80,16,16,64,72,0
7750 SYMBOL 106,10,0,10,2,2,136,136,72
7760 SYMBOL 107,160,160,162,34,48,136,136,0
7770 SYMBOL 108,80,80,80,16,16,64,72,0
7780 SYMBOL 109,0,0,170,242,50,200,136,0
7790 SYMBOL 110,0,0,250,162,34,136,136,0
7800 SYMBOL 111,0,0,80,162,34,136,64,0
7810 SYMBOL 112,0,0,240,162,34,200,128,192
7820 SYMBOL 113,0,0,240,162,34,200,8,8
7830 SYMBOL 114,0,0,162,242,32,128,192,0
7840 SYMBOL 115,0,0,90,160,18,8,192,0
7850 SYMBOL 116,80,80,178,16,16,64,8,0
7860 SYMBOL 117,0,0,162,34,34,136,72,0
7870 SYMBOL 118,0,0,162,34,34,64,64,0
7880 SYMBOL 119,0,0,162,50,50,200,136,0
7890 SYMBOL 120,0,0,162,34,16,136,136,0
7900 SYMBOL 121,0,0,162,34,34,72,8,200
7910 SYMBOL 122,0,0,242,2,16,64,200,0
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

mr_lou

Don't you ever sleep?
Seems you present something new almost every day.  :)
Do you need music for your Amstrad CPC game project?
Take a look at IndieGameMusic.com - that's where I put my tracks.

Devilmarkus

This prog. and font is old.
I once made it for "Elvira"
Now I share the code for you.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

You know, I've seen multicolored fonts in games often, but it never occurred to me that there's some magic that needs to take place to enable these...

jonesypeter

Quote from: Devilmarkus on 11:35, 03 July 10This prog. and font is old.
I once made it for "Elvira"
Now I share the code for you.
Hi Devilmarkus,


Would I be able to ask for your help?

I'm a Spectrum user normally, but I've been very excited by the multi-colour effects in the games by Francesc Alcaucer.

https://falcaucer.itch.io/crystal-place

I see you did something similar with three colour fonts in BASIC.

Could you just explain in very easy terms how this is working?

I understand this line:

10 MODE 1:CALL &BD1C

Set Mode 1 which is '320×200 pixels with 4 colors (2 bpp)', then switch without clearing the screen to '160×200 pixels with 16 colors (4 bpp)'

I see that you have redefined character 33 (!) as the following. How does this convert into a multicolour '!'

I've seen this explanation of pixel mode encoding, but to be honest. I don't understand it!

https://cpctech.cpcwiki.de/docs/graphics.html

Best wishes

Peter







arnoldemu

#6
I don't think Devilmarkus has logged in recently.

I can explain how this works and how to make use of it.

When MODE 0, MODE 1 or MODE 2 is used this tells the OS which mode is used and it will then choose which function it uses to draw characters and plot pixels to the screen. The translation functions can be thought of a as a lookup then a poke to the screen in the form the hardware needs it.

With SYMBOL you are normally defining if a pixel is PEN (bit is 1) or PAPER (bit is 0) and the translation code then uses that when PRINT is done.

Using MODE 1:CALL &BD1C is a trick. The OS thinks it's in mode 1 and it's translation functions are for mode 1 but we change the mode to 0 in a way that doesn't update those translation functions. Then everytime we PRINT it's trying to do it as if it's in mode 1 and drawing to a mode 0 screen.  So everytime PRINT is used instead of it using the mode 0 printing functions it's using the mode 1 printing functions.

We then take advantage of this by encoding the chars/SYMBOLS in a special form and it results in 4 coloured chars in this example.

For a mode 1 game, I would do MODE 2:CALL &BD1C,1 which makes the OS use 'mode 2' translation functions but showing as mode 1. What is easier about this is in mode 2 the OS is almost just doing a POKE because the symbols are 2 colour and the mode is 2 colour. We then setup the symbol data to be exactly as we need for the screen and it is poked onto it.

That linked page describe how the bits relate to the pixels to poke to the screen.

So setup the data for mode 1:
The pixel data is 'interleaved'.

pixels a,b,c,d

bit 7 is bit 0 of pixel a, bit 3 is bit 1 of pixel a.
bit 6 is bit 0 of pixel b, bit 2 is bit 1 of pixel b.
bit 5 is bit 0 of pixel c, bit 1 is bit 1 of pixel c.
bit 4 is bit 0 of pixel d, bit 0 is bit 1 of pixel d.

So choose your colours for a,b,c,d and setup the data like this and specify this byte in SYMBOL.

Does that help?

EDIT: If it helps MODE 1:POKE &C000,val and try out values to see how the pixels are encoded.
Try &08,&80,&88
and &04,&40,&44
and &02,&20,&22
and &01,&10,&11

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

jonesypeter

#7
Quote from: arnoldemu on 18:21, 08 January 25I can explain how this works and how to make use of it.
Thanks so much for the reply.  I'm not sure why, but I'm really struggling with the concept.

So is this a 4*8 Font? Mode one is 8*8?

In my example I have the following:

Row 0: Bits 1 & 3 Set
Row 1: Bits 1 & 3 Set
Row 2: Bit 1 Set
Row 3: Bit 1 Set
Row 4: Bit 3 Set
Row 5: Clear
Row 6: Bit 3 Set
Row 7: Clear

How does this relate to your table?

Sorry!

ZorrO

CPC+PSX 4ever

jonesypeter

Thanks, that very much helped.  I think I'm there now. 

jonesypeter

Quote from: ZorrO on 21:33, 08 January 25Read this, and look at pictures on this page higher and lower than that post. :)
https://www.cpcwiki.eu/forum/programming/basic-programming-tips/msg117556/#msg117556

Hi ZorrO,

That really helped thanks, and I'm able to create 4*8 characters of my choice and set each pixel to one of the colours.

Can you just explain setting of the ink colours here? Why is it ink 1,4 & 5?

https://www.cpcwiki.eu/forum/index.php?msg=10346

20 INK 0,0:INK 1,6:INK 4,15:INK 5,25

ZorrO

When you switch to narrow 40 characters in MODE 0, (by MODE 1:CALL &BD1C)  and you have prepared a font using 4 colors in each letter, you can use the PEN and PAPER commands but only as in MODE 1, i.e. parameter from 0 to 3. In PAPER 0 background has INK 0, and now in PEN 1 remaining colors visible in character are INKS 1,4,5, in PEN 2 they are 2,8,10, and in PEN 3 they are 3,12,15. Other combinations are possible by changing pen and paper via POKE, but don't ask for details because I don't know if anyone has fully figured this out yet, you have to experiment for yourself.

You can play examples programs on DSK added to posts in link I gave you before. Maybe it helps you understand better, or makes you confused more. ;)
CPC+PSX 4ever

FAlcaucer

Hi, I'm Francesc Alcaucer, the person who jonesypeter is asking for. Over the last 4 years I programmed four games using the MODE 1:CALL &BD1C method.

I'm really surprised by the fact of this method is discussed in this forum around January 2016, but seems it's details still unknown to most people and I don't know any game using this trick made before my Wrecking Ball, a Breakout stile game programmed entirely (100%) in Basic.

QuoteI don't know if anyone has fully figured this out yet, you have to experiment for yourself.
ZorrO, You can see a PDF with details of how I programmed Wrecking Ball on my https://falcaucer.itch.io

On this document you can see the complete relation of PEN distribution:

I already have been made a program to design fonts in this mode, I used it for develop all UDG for my games. Maybe someone interested on it, but I need to polish a bit, because don't have any instructions of how use it.  :-*

ZorrO

Where is this program to design 4 colors font?
CPC+PSX 4ever

FAlcaucer

:o  Not published yet.  I didn't expect to publish it, to be honest, I didn't think it was necessary.  I will make some modifications to make it user-friendly and publish it on itch.io

I also need to create a small example program, with comments to make the method more understandable for those interested. The truth is that it is a very interesting technique, which is why I am so surprised that it hasn't been exploited more.

FAlcaucer


XeNoMoRPH

#16
4 COLOR CHAR Editor for Amstrad CPC

" ... UPDATE: New version, now supports MODE 0 and MODE 1. Control keys are renewed for international Amstrad CPC versions ... "

your amstrad news source in spanish language : https://auamstrad.es

Powered by SMFPacks Menu Editor Mod