CPCWiki forum

General Category => Programming => Topic started by: Fabrizio Radica on 20:42, 21 June 19

Title: Locomotive Basic - ColorMap Address
Post by: Fabrizio Radica on 20:42, 21 June 19
Hi :)i would like to put a simple char (or pixel) into memory and color it.for testing (so not oprimized) i've made this code

10 cls:mode 2:ink 0,0:border 0:ink 1,26
20 add=&c000:x=40:y=1
30 coord=add+x*2+y*80
150 poke coord,&41
160 locate x,y:print chr$(peek(coord))


How can i colorize it?
What color address does it have?
I would simply like to create a tilemap by drawing directly into memory.
Thanks you :)
Ciao!

Title: Re: Locomotive Basic - ColorMap Address
Post by: AMSDOS on 00:42, 22 June 19
Quote from: Fabrizio Radica on 20:42, 21 June 19
Hi :)i would like to put a simple char (or pixel) into memory and color it.for testing (so not oprimized) i've made this code

10 cls:mode 2:ink 0,0:border 0:ink 1,26
20 add=&c000:x=40:y=1
30 coord=add+x*2+y*80
150 poke coord,&41
160 locate x,y:print chr$(peek(coord))


How can i colorize it?
What color address does it have?
I would simply like to create a tilemap by drawing directly into memory.
Thanks you :)
Ciao!


In MODE 2 it's easy to Colourise because there's only 2 Colours, so the shape is represented as an 8-bit Binary Number, so in my MODE 2 example, this generates a small Ball at the top of the screen:




100 MODE 2:DIM o(4):GOSUB 1000
110 s=&C000
120 FOR p=1 TO 4
130   POKE s,o(p)
140   s=s+&800
150 NEXT p
160 LOCATE 1,10:END
1000 FOR a=1 TO 4
1010   READ o(a)
1020 NEXT a
1030 RETURN
1040 DATA 24,60,60,24



The DATA to produce that Ball Looks like this in Binary:



00011000
00111100
00111100
00011000



Test by Changing to MODE 1 and it becomes a little Imperial Fighter and in MODE 0 a Colourful Equals Sign.


You have to remember you're dealing with Sprites when POKEing to the Screen, I wrote a BASIC example of that back in 2011 (http://www.cpcwiki.eu/forum/programming/silly-programming-ideas-turning-text-into-graphics/msg49072/#msg49072), which is quite slow and the coding of it could be improved I suspect (draw sprite/enter loop/delete sprite/draw sprite in new position), which that isn't doing.


I also wrote this programme  (http://www.cpcwiki.eu/forum/programming/silly-programming-ideas-turning-text-into-graphics/msg83457/#msg83457), which is used to gather the Byte Masks in Mode 0, the idea is to draw the Image onscreen using the DATA to represent the Colours you want, the image is drawn and then the Byte Masks are obtained from that.
Powered by SMFPacks Menu Editor Mod