Author Topic: Displaying "readable" text in mode 0  (Read 748 times)

0 Members and 1 Guest are viewing this topic.

Offline SkulleateR

  • CPC664
  • ***
  • Posts: 57
  • Country: de
  • Liked: 20
  • Likes Given: 8
Displaying "readable" text in mode 0
« on: 22: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 ?

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.718
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 952
  • Likes Given: 1676
Re: Displaying "readable" text in mode 0
« Reply #1 on: 01:33, 31 August 19 »
I created a short demo here 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:


Code: [Select]
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:


Code: [Select]
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.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline Fessor

  • CPC6128
  • ****
  • Posts: 199
  • Country: de
  • Liked: 164
  • Likes Given: 40
Re: Displaying "readable" text in mode 0
« Reply #2 on: 10: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/






Offline SkulleateR

  • CPC664
  • ***
  • Posts: 57
  • Country: de
  • Liked: 20
  • Likes Given: 8
Re: Displaying "readable" text in mode 0
« Reply #3 on: 16:37, 31 August 19 »
@AMSDOS


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


Don´t think this could be a solution since it will mess up on Mode 0 from what I read ?

Offline Fessor

  • CPC6128
  • ****
  • Posts: 199
  • Country: de
  • Liked: 164
  • Likes Given: 40
Re: Displaying "readable" text in mode 0
« Reply #4 on: 21: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.

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.463
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2635
  • Likes Given: 1565
Re: Displaying "readable" text in mode 0
« Reply #5 on: 21: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.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline SkulleateR

  • CPC664
  • ***
  • Posts: 57
  • Country: de
  • Liked: 20
  • Likes Given: 8
Re: Displaying "readable" text in mode 0
« Reply #6 on: 00:07, 01 September 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 for this routine)


Offline SkulleateR

  • CPC664
  • ***
  • Posts: 57
  • Country: de
  • Liked: 20
  • Likes Given: 8
Re: Displaying "readable" text in mode 0
« Reply #7 on: 01:06, 17 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:


Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.463
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2635
  • Likes Given: 1565
Re: Displaying "readable" text in mode 0
« Reply #8 on: 07:35, 17 September 19 »
Nice, but... Where is MODE 1?  ;D 
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline ZbyniuR

  • 464 Plus
  • *****
  • Posts: 316
  • Country: pl
  • 6128 A1230 PSX Win7
    • Jedyne polskie forum o CPC. :)
  • Liked: 332
  • Likes Given: 143
Re: Displaying "readable" text in mode 0
« Reply #9 on: 19: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. :)
TREK is better than WARS.