CPCWiki forum

General Category => Programming => Topic started by: SkulleateR on 20:03, 30 August 19

Title: Displaying "readable" text in mode 0
Post by: SkulleateR on 20:03, 30 August 19
Hi guys  :D


So I finally received my M4 and after putting all those software on it and getting my old disks usable again without worrying about using them, I thought I take some of my old unfinished Basic Projects and .... well .... finish them  :laugh:


So on an old disk I found a kind of strategy game I began to write back in the 80s.


I do now nearly nothing about asm and so I code in basic.


Main screen is some kind of stellar map with some planets and stars and a spaceship. There you have to explore Planets, destroy pirate ships and so on ...


Problem is : I wrote the game back then in mode 1 with text as objects like "X" for a spaceship and "O" for a planet and so on  ;)


So I took the source and converted all to mode 0 to use some nice (well, kinda nice for my purpose) graphics but I have problem now. Some things that happen has to be displayed using text messages, but well as you now, mode 0 is kinda useless here (writing one sentence and the screen is filled)


Does anyone has a clever idea to deal with this, maybe a clever routine for displaying some amount of text in "readable" format on a mode 0 screen ?
Title: Re: Displaying "readable" text in mode 0
Post by: AMSDOS on 23:33, 30 August 19
I created a short demo here (http://www.cpcwiki.eu/forum/programming/silly-programming-ideas-turning-text-into-graphics/msg137878/#msg137878) which redefines the character set 230 to 255 to make a condensed Alphabet set which would give you 40x25 in MODE 0.
The problem I had in order to place the characters onscreen, I have to graphically place them onscreen and the Demo for which I made in that example won't be suitable for your purposes.
You would need some formulas which calculate the xpos and ypos positions based on the MODE 1 cursor position which will look something like this:


xp=(x-1)*16 and;
yp=398-((y-1)*16)


with x & y containing the text xpos & ypos positions normally set from LOCATE.


Then it's just a matter of writing a routine to PRINT the text, in my example I wanted to retain the Amstrads standard character set 65 to 90, which is why I pointed my new set to 230, writing something to PRINT the text may look like this:



1000 FOR p=1 TO LEN(a$)
1010   MOVE (x-1)*16,398-((y-1)*16)
1020   TAG
1030   v=ASC(MID$(a$,p,1))
1040   IF v<>32 THEN PRINT CHR$(v+165);
1050   x=x+1
1060 NEXT p
1070 RETURN



Modifying my earlier demo, I changed lines 1 & 2 to read:



1 DEFINT a-z:SYMBOL AFTER 230:DIM o(8,26):GOSUB 9
2 MODE 0:a$="HELLO WORLD":x=15:y=10:GOSUB 1000:END



Unfortunately it's not as fast as printing actual Text Onscreen due to the calculations which have to take place, but I hope it gives you understanding of the process.
Title: Re: Displaying "readable" text in mode 0
Post by: Fessor on 08:03, 31 August 19
You should take a look to this thread, even if the pictures are down: 
http://www.cpcwiki.eu/forum/programming/workshop-how-to-make-a-3-coloured-font-for-basic/





Title: Re: Displaying "readable" text in mode 0
Post by: SkulleateR on 14:37, 31 August 19
@AMSDOS (http://www.cpcwiki.eu/forum/index.php?action=profile;u=330)


Thx, will have a look as soon as I got some spare time again, speed should not be an issue since this will be no fast paced action shooter or something like that  :P


@Fessor (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1495)


Don´t think this could be a solution since it will mess up on Mode 0 from what I read ?
Title: Re: Displaying "readable" text in mode 0
Post by: Fessor on 19:28, 31 August 19
Try the listing of the second post. ;)
It sets the graphics to mode 0 but leaves the text-printing like mode 1, with 40x25 chars, but the chardefinitons are now storing mode-0-bitmasks.
Title: Re: Displaying "readable" text in mode 0
Post by: TotO on 19:43, 31 August 19
I remember to type a program like this from a 80's french magazine (Amstrad Cent Pour Cent?). It was really great.
Title: Re: Displaying "readable" text in mode 0
Post by: SkulleateR on 22:07, 31 August 19
Quote from: Fessor on 19:28, 31 August 19
Try the listing of the second post. ;)


Ok, tried and that really does the trick, now I only have to adjust colours so I can use my simple sprites again, looking kinda weird now  :laugh:


Best thing is I can use normal text printing without using graphics coordinates for that. I can now define a text window to display status things ... thanks a lot (also to @Devilmarkus (http://www.cpcwiki.eu/forum/index.php?action=profile;u=93) for this routine)

Title: Re: Displaying "readable" text in mode 0
Post by: SkulleateR on 23:06, 16 September 19
If anyone is curious how it looks to mix mode 0 and 1 and multicolour text in Basic ... here it is  :D


Quite happy with the result, but it´s hell of a work to convert 30 year old code and give it some graphics into it  :laugh:

Title: Re: Displaying "readable" text in mode 0
Post by: TotO on 05:35, 17 September 19
Nice, but... Where is MODE 1?  ;D 
Title: Re: Displaying "readable" text in mode 0
Post by: ZbyniuR on 17:41, 25 September 19
Other exemples how to use narrow fonts 4x8 pixel in 4 colors, are here:
http://www.cpcwiki.eu/forum/programming/basic-programming-tips/msg117620/#msg117620

Explanation is little bit higher in post 58 on the same page, and other interesting use, as pointer sprite in post 53, and walking Lemmings in post 67. DSKs are under posts. :)

I'm late, but maybe someone will be inspired. :)
Powered by SMFPacks Menu Editor Mod