I need palette color MSX2 in assembly code

Door gamecast

Expert (101)

afbeelding van gamecast

31-08-2011, 08:01

Hello Guys,

I need palette color MSX2 in assembly code for SCREEN4.

Converter here under the code basic in assembly code.
Thanks....
AG.

 
COLOR=(9,2,1,0):REM BROWN
COLOR=(13,3,1,3):REM VIOLET 
COLOR=(3,7,4,0):REM ORANGE
COLOR=(14,2,2,2):REM DARK GRAY
Aangemeld of registreer om reacties te plaatsen

Van Marq

Champion (387)

afbeelding van Marq

31-08-2011, 08:27

Something like this:

ld a,colornum
out 0x99,a
ld a,0x90
out 0x99,a
ld a,red*16+blue
out 0x9a,a
ld a,green
out 0x9a,a

Van NYYRIKKI

Enlighted (6016)

afbeelding van NYYRIKKI

31-08-2011, 08:46

	LD A,3		;Orange
	OUT (#99),A
	LD A,#90
	OUT (#99),A

	LD A,#70
	OUT (#9A),A
	LD A,4
	OUT (#9A),A

	LD A,9		;Brown
	OUT (#99),A
	LD A,#90
	OUT (#99),A

	LD A,#20
	OUT (#9A),A
	LD A,1
	OUT (#9A),A

	LD A,13		;Violet
	OUT (#99),A
	LD A,#90
	OUT (#99),A

	LD A,#33
	OUT (#9A),A
	LD A,1
	OUT (#9A),A
			;Dark gray
	LD A,#22
	OUT (#9A),A
	OUT (#9A),A

2.1.2 Setting a palette

To set data in the MSX-VIDEO palette registers (P#0 to P#15), specify the 
palette register number in the four lowest significant bits of R#16 (color 
palette pointer), and then send the data to port#2. Since palette registers 
have a length of 9 bits, data must be sent twice; red brightness and blue 
brightness first, then green brightness. Brightness is specified in the lower 
three bits of a four bit segment. Refer to Figure 4.5 for details.

After data is sent to port#2 twice, R#16 is automatically incremented. This 
feature makes it easy to initialize all the palettes.


   Figure 4.5  Setting a colour palette register

    MSB   7    6    5	 4    3    2	1    0	  LSB
	-----------------------------------------
R#16	| 0  | 0  | 0  | 0  | R3 | R2 | R1 | R0 |   1.Set palette number n
	-----------------------------------------     to R#16, with four
	|		    |			|     high order bits set
	+---------------------------------------+     to "0000".
	   fixed at "0000"      n (0 to 15)

	-----------------------------------------
Port#2	|    | Red bright.  |	 | Blue bright. |   2.Send red and blue
	-----------------------------------------     brightness to port#2.
	     |		    |	 |		|
	     +--------------+	 +--------------+
		  0 to 7	      0 to 7

	-----------------------------------------
Port#2	|    |	  |    |    |	 | Green bright.|   2.Send green brightness
	-----------------------------------------     to port#2. (*)
				 |		|
				 +--------------+
				      0 to 7

(*) Since R#16 is incremented at this point, setting next palette can be done 
    by sending data to port#2 continuously.

Van gamecast

Expert (101)

afbeelding van gamecast

31-08-2011, 15:43

Well done NYYRIKKI,

This your routine palette it work very well!!

Thanks for you ^_^
Bye!!
AG.