Friday, January 22, 2010

color ROM 4a on the Pac-Man board

Every sprite (and I believe the background) in Pac-Man has at most 4 colors in it. Of the 4 colors, there is a 4-bit index into the palette ROM 7f mentioned in the previous post. Palette index 0 is transparent for sprites (and I assume black for the background?)



Here's the VHDL code for the ROM as generated by Mike J's romgen. Note that I've modified each x"00" through x"0f" value (4-bit palette index) to zero to avoid publishing the ROM data:



-- generated with romgen v3.0 by MikeJ
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;

library UNISIM;
use UNISIM.Vcomponents.all;

entity PACROM_4A_DST is
port (
ADDR : in std_logic_vector(7 downto 0);
DATA : out std_logic_vector(7 downto 0)
);
end;

architecture RTL of PACROM_4A_DST is

signal rom_addr : std_logic_vector(11 downto 0);

begin

p_addr : process(ADDR)
begin
rom_addr <= (others => '0');
rom_addr(7 downto 0) <= ADDR;
end process;

p_rom : process(rom_addr)
begin
DATA <= (others => '0');
case rom_addr is
when x"000" => DATA <= x"00";
when x"001" => DATA <= x"00";
when x"002" => DATA <= x"00";
when x"003" => DATA <= x"00";
when x"004" => DATA <= x"00";
when x"005" => DATA <= x"00";
when x"006" => DATA <= x"00";
when x"007" => DATA <= x"00";
when x"008" => DATA <= x"00";
when x"009" => DATA <= x"00";
when x"00A" => DATA <= x"00";
when x"00B" => DATA <= x"00";
when x"00C" => DATA <= x"00";

SNIP

when x"0FC" => DATA <= x"00";
when x"0FD" => DATA <= x"00";
when x"0FE" => DATA <= x"00";
when x"0FF" => DATA <= x"00";
when others => DATA <= (others => '0');
end case;
end process;
end RTL;

No comments:

Post a Comment