2 ; Copyright (C) 2004, 2005 Kent Hansen.
4 ; This file is part of Neotoxin.
6 ; Neotoxin is free software; you can redistribute it and/or modify
7 ; it under the terms of the GNU General Public License as published by
8 ; the Free Software Foundation; either version 2 of the License, or
9 ; (at your option) any later version.
11 ; Neotoxin is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
16 ; You should have received a copy of the GNU General Public License
17 ; along with this program; if not, write to the Free Software
18 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ; Basic palette stuff.
23 ; A copy of the palette is kept in RAM so it can be faded and such
25 ; The load_palette() function loads a palette into internal memory;
26 ; the write_palette() function writes the palette to VRAM.
32 ; background + sprite palette (16+16 bytes)
33 .
public palette .
byte[32]
45 .
public set_black_palette
46 .
public start_palette_ppu_string
48 .extrn
ppu_buffer:byte
49 .extrn
ppu_buffer_offset:byte
50 .extrn
begin_ppu_string:proc
51 .extrn
end_ppu_string:proc
53 ; Starts a PPU buffer string with address=$3F00 and count=32.
54 ; Params: A = index of first palette entry (0..31)
56 ; Returns: X = PPU buffer index
57 .
proc start_palette_ppu_string
62 ; Loads a 32-byte palette into RAM array.
63 ; The palette is not written to VRAM.
64 ; Once the palette is loaded, you can call write_palette()
65 ; or one of the palette loading functions (see fade.asm).
66 ; Params: A = low address of palette
67 ; Y = high address of palette
79 ; Writes in-RAM palette to VRAM.
80 ; You should have set a palette first with load_palette()
81 ; before calling this function.
86 jsr start_palette_ppu_string
97 ; Sets all RAM palette entries to $0F (black), and writes
98 ; the palette to VRAM.
99 .
proc set_black_palette
101 lda #
$0F ; color black
108 ; Loads a palette and writes it to VRAM in one go.
109 ; Params: A = low address of palette
110 ; Y = high address of palette