RE: Which colors for a grayscale?

2012-12-25 Thread Stefan Drissen
I have a lovely place for all my Z80 source, it's called a 3.5 disk box...
must get it organized some time :-).

In this case it is so short, here it is:

   ORG  6
   DUMP $


   JP   start

   DEFM  
   DEFM GREY-SCALE DITHERER 
   DEFM 
   DEFM This program changes all odd
   DEFM colour pixels to a stipple  
   DEFM pattern of even colours.
   DEFM 
   DEFM (C) 1993 Solar Flare of ENTROPY 
   DEFM Completion date: 4 October 1993 
   DEFM Idea: Robert van der Veeke  
start:
   LD   HL,32768
loop:
   LD   B,128
line0:
   LD   A,(HL)
   AND  %11101110
   CP   (HL)
   JR   Z,nochange
   LD   A,(HL)
   AND  %1110
   LD   C,A
   LD   A,(HL)
   AND  %
   CP   C
   JR   Z,leftsame
   LD   A,(HL)
   AND  %1110
   LD   C,A
   LD   A,(HL)
   AND  %
   CP   C
   JR   NZ,changeboth
   LD   A,(HL)
   AND  %11101110
   LD   (HL),A
   JR   nochange

leftsame:
   LD   A,(HL)
   AND  %
   LD   C,A
   LD   A,(HL)
   AND  %
   INC  A
   CP   14
   JR   C,$+4
   LD   A,%1110
   OR   C
   LD   (HL),A
   JR   nochange

changeboth:
   LD   A,(HL)
   AND  %1110
   LD   C,A
   LD   A,(HL)
   AND  %
   INC  A
   CP   14
   JR   C,$+4
   LD   A,14
   OR   C
   LD   (HL),A

nochange:
   LD   A,(HL)
   RRCA 
   LD   (HL),A
   INC  HL
   DJNZ line0


   LD   B,128
line1:
   LD   A,(HL)
   AND  %11101110
   CP   (HL)
   JR   Z,nochange1
   LD   A,(HL)
   AND  %
   LD   C,A
   LD   A,(HL)
   AND  %1110
   CP   C
   JR   Z,leftsame1
   LD   A,(HL)
   AND  %1110
   LD   C,A
   LD   A,(HL)
   AND  %
   CP   C
   JR   NZ,changeboth1
   LD   A,(HL)
   AND  %1110
   LD   C,A
   LD   A,(HL)
   AND  %
   ADD  16
   JR   NC,$+4
   LD   A,%1110
   AND  %1110
   OR   C
   LD   (HL),A
   JR   nochange1

leftsame1:
   LD   A,(HL)
   AND  %11101110
   LD   (HL),A
   JR   nochange1

changeboth1:
   LD   A,(HL)
   AND  %1110
   LD   C,A
   LD   A,(HL)
   AND  %
   ADD  A,16
   JR   NC,$+4
   LD   A,%1110
   AND  %1110
   OR   C
   LD   (HL),A

nochange1:
   LD   A,(HL)
   RRCA 
   LD   (HL),A
   INC  HL
   DJNZ line1

   LD   A,H
   CP   128+96
   JP   NZ,loop
   RET  

-Original Message-
From: owner-sam-us...@nvg.ntnu.no [mailto:owner-sam-us...@nvg.ntnu.no] On
Behalf Of Marcos Cruz
Sent: dinsdag 25 december 2012 02:06
To: sam-users@nvg.ntnu.no
Subject: Re: Which colors for a grayscale?

En/Je/On 2012-12-20 05:00, Stefan Drissen escribió / skribis / wrote :

I wrote the greyscale ditherer - see
[1]http://www.worldofsam.org/node/40

Stefan, do you keep the Z80 source?  If so, would you share it? I'd like to
adapt your routine to work on any region of the current screen. I'd publish
the modified version with the original credits and a link to its page on
World of Sam. Probably changing some values will be enough, but I didn't try
to disassemble it yet.

Marcos

--
http://programandala.net



Re: Which colors for a grayscale?

2012-12-24 Thread Marcos Cruz
En/Je/On 2012-12-20 05:00, Stefan Drissen escribió / skribis / wrote :

I wrote the greyscale ditherer - see
[1]http://www.worldofsam.org/node/40

Stefan, do you keep the Z80 source?  If so, would you share it? I'd like
to adapt your routine to work on any region of the current screen. I'd
publish the modified version with the original credits and a link to its
page on World of Sam. Probably changing some values will be enough, but
I didn't try to disassemble it yet.

Marcos

-- 
http://programandala.net


Re: Which colors for a grayscale?

2012-12-20 Thread Marcos Cruz
En/Je/On 2012-12-20 05:00, Stefan Drissen escribió / skribis / wrote :

I wrote the greyscale ditherer - see
[1]http://www.worldofsam.org/node/40 - it only uses the real greys
and dithers the in between a.

Thank you Stefan.

My first try sprite is 54x28, only few pixels got cyan using the
colorscale suggested by Simon, and of course it's an alien spacesship on
black background, so it looks nice with some cyanish touches :)

But your code does an impresive job. I'll use it to create alternative
gray-only sprites.

Marcos

-- 
http://programandala.net



Re: Which colors for a grayscale?

2012-12-19 Thread Simon Owen
Hi Marcos,

The SAM palette is make up using 2-bit RGB plus intensity, which bitwise
is:  xGRBigrb.  For pure greys you'd use:

 = 00 = 0
0111 = 07 = 7
1000 = 08 = 8
 = 0f = 15
0111 = 70 = 112
01110111 = 77 = 119
0000 = 78 = 120
0111 = 7f = 127

The SAM demo tape astronaut image uses cyan to fill some of the gaps,
which duplicates black and white on the ends:

  0, 0, 8, 5, 7, 13, 15, 82, 112, 90, 120, 117, 119, 125, 127, 127

That's  maybe as good as you'll get for a 16-colour palette.

Si

On 19/12/2012 20:43, Marcos Cruz wrote:
 Hi all,

 In order to automate and simplify as much as possible the process of
 importing images into the SAM and avoid the palette conversion problems,
 I'm tinkering with the Netpbm raster formats
 (http://en.wikipedia.org/wiki/Netpbm_format).  BMP and others could be
 used too, but Netpbm files have two encoding variants (ASCII and binary)
 for every type (PBM, PGM and PPM), what makes them very versatile in
 this case.

 The Netpbm images are created with Linux tools and the SAM does the
 final conversion, PLOTing the image pixels with the desired equivalent
 colors and GRABbing it.

 The first tries with a grayscale image look promising, but I need to
 choose 16 grays from the SAM palette (0, 7, 8, 15, 112, 120, 127...?)
 I'm afraid there are less than 16 gray tones, and blue must be used to
 complete the set. Am I right? Does anyboy know which are the best 16 SAM
 original colors for a grayscale?

 Thank you.

 Marcos

   



Re: Which colors for a grayscale?

2012-12-19 Thread Marcos Cruz
En/Je/On 2012-12-19 21:54, Simon Owen escribió / skribis / wrote :

 bitwise is:  xGRBigrb.  For pure greys you'd use:
 
  = 00 = 0
 0111 = 07 = 7
 1000 = 08 = 8
  = 0f = 15
 0111 = 70 = 112
 01110111 = 77 = 119
 0000 = 78 = 120
 0111 = 7f = 127

I already knew the format but didn't have the idea to confirm which
colors are actually gray just by looking its code. I see my eyes worked
fine anyway :)

   0, 0, 8, 5, 7, 13, 15, 82, 112, 90, 120, 117, 119, 125, 127, 127

That's what I needed. It looks great. I'll try a 14-gray variant; the
two duplicates can be useful for some color effect.

Thank you.

Marcos

-- 
http://programandala.net



Re: Which colors for a grayscale?

2012-12-19 Thread Stefan Drissen
Although the cyanish in between colours looked good on an old CRT television, I 
thought they looked horrible on a monitor. That's why I wrote the greyscale 
ditherer - see http://www.worldofsam.org/node/40 - it only uses the real greys 
and dithers the in between a. 

Op 19 dec. 2012 om 22:54 heeft Simon Owen simon.o...@simcoupe.org het 
volgende geschreven:

 Hi Marcos,
 
 The SAM palette is make up using 2-bit RGB plus intensity, which bitwise
 is:  xGRBigrb.  For pure greys you'd use:
 
  = 00 = 0
 0111 = 07 = 7
 1000 = 08 = 8
  = 0f = 15
 0111 = 70 = 112
 01110111 = 77 = 119
 0000 = 78 = 120
 0111 = 7f = 127
 
 The SAM demo tape astronaut image uses cyan to fill some of the gaps,
 which duplicates black and white on the ends:
 
  0, 0, 8, 5, 7, 13, 15, 82, 112, 90, 120, 117, 119, 125, 127, 127
 
 That's  maybe as good as you'll get for a 16-colour palette.
 
 Si
 
 On 19/12/2012 20:43, Marcos Cruz wrote:
 Hi all,
 
 In order to automate and simplify as much as possible the process of
 importing images into the SAM and avoid the palette conversion problems,
 I'm tinkering with the Netpbm raster formats
 (http://en.wikipedia.org/wiki/Netpbm_format).  BMP and others could be
 used too, but Netpbm files have two encoding variants (ASCII and binary)
 for every type (PBM, PGM and PPM), what makes them very versatile in
 this case.
 
 The Netpbm images are created with Linux tools and the SAM does the
 final conversion, PLOTing the image pixels with the desired equivalent
 colors and GRABbing it.
 
 The first tries with a grayscale image look promising, but I need to
 choose 16 grays from the SAM palette (0, 7, 8, 15, 112, 120, 127...?)
 I'm afraid there are less than 16 gray tones, and blue must be used to
 complete the set. Am I right? Does anyboy know which are the best 16 SAM
 original colors for a grayscale?
 
 Thank you.
 
 Marcos