Say hello to D-Pad Hero 2 repository
[dpadhero2.git] / common / ppu.h
blob2494987c2f0c0b41a4d21a9bba3f0f8f712df997
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
21 ; PPU defines.
23 .ifndef PPU_H
24 .define PPU_H
26 ; Hardware regs.
27 PPU_CTRL0_REG .equ $2000
28 PPU_CTRL1_REG .equ $2001
29 PPU_STATUS_REG .equ $2002
30 PPU_SCROLL_REG .equ $2005
31 PPU_ADDR_REG .equ $2006
32 PPU_IO_REG .equ $2007
34 ; Records which describe PPU reg layouts.
35 .record ppu_ctrl0 nmi_on_vblank:1, pad0:1, sprite_size:1, bg_table:1, sprite_table:1, ppu_addr_inc:1, name_table:2
36 .record ppu_ctrl1 emph:3, sprite_on:1, bg_on:1, sprite_clip:1, bg_clip:1, mono:1
37 .record ppu_status vblank:1, sprite0:1, sprite_overflow:1, pad0:5
39 ; Field masks.
40 PPU_CTRL0_NMI .equ mask ppu_ctrl0::nmi_on_vblank
41 PPU_CTRL0_SPRITE_SIZE .equ mask ppu_ctrl0::sprite_size
42 PPU_CTRL0_BG_TABLE .equ mask ppu_ctrl0::bg_table
43 PPU_CTRL0_SPRITE_TABLE .equ mask ppu_ctrl0::sprite_table
44 PPU_CTRL0_PPU_ADDR_INC .equ mask ppu_ctrl0::ppu_addr_inc
45 PPU_CTRL0_NAME_TABLE .equ mask ppu_ctrl0::name_table
47 PPU_CTRL1_EMPH .equ mask ppu_ctrl1::emph
48 PPU_CTRL1_SPRITE_VISIBLE .equ mask ppu_ctrl1::sprite_on
49 PPU_CTRL1_BG_VISIBLE .equ mask ppu_ctrl1::bg_on
50 PPU_CTRL1_SPRITE_CLIP .equ mask ppu_ctrl1::sprite_clip
51 PPU_CTRL1_BG_CLIP .equ mask ppu_ctrl1::bg_clip
52 PPU_CTRL1_MONO .equ mask ppu_ctrl1::mono
54 PPU_STATUS_VBLANK .equ mask ppu_status::vblank
55 PPU_STATUS_SPRITE0 .equ mask ppu_status::sprite0
56 PPU_STATUS_SPRITE_OVERFLOW .equ mask ppu_status::sprite_overflow
58 ; Bitmasks that can be OR'ed together to create PPU_CTRL0_REG-compatible value.
59 PPU_CTRL0_NMI_ON .equ PPU_CTRL0_NMI
60 PPU_CTRL0_NMI_OFF .equ 0
61 PPU_CTRL0_SPRITE_SIZE_8x8 .equ 0
62 PPU_CTRL0_SPRITE_SIZE_8x16 .equ PPU_CTRL0_SPRITE_SIZE
63 PPU_CTRL0_BG_TABLE_0000 .equ 0
64 PPU_CTRL0_BG_TABLE_1000 .equ PPU_CTRL0_BG_TABLE
65 PPU_CTRL0_SPRITE_TABLE_0000 .equ 0
66 PPU_CTRL0_SPRITE_TABLE_1000 .equ PPU_CTRL0_SPRITE_TABLE
67 PPU_CTRL0_PPU_ADDR_INC_1 .equ 0
68 PPU_CTRL0_PPU_ADDR_INC_32 .equ PPU_CTRL0_PPU_ADDR_INC
70 ; Bitmasks that can be OR'ed together to create PPU_CTRL1_REG-compatible value.
71 PPU_CTRL1_SPRITE_ON .equ PPU_CTRL1_SPRITE_VISIBLE
72 PPU_CTRL1_SPRITE_OFF .equ 0
73 PPU_CTRL1_BG_ON .equ PPU_CTRL1_BG_VISIBLE
74 PPU_CTRL1_BG_OFF .equ 0
75 PPU_CTRL1_SPRITE_CLIP_ON .equ PPU_CTRL1_SPRITE_CLIP
76 PPU_CTRL1_SPRITE_CLIP_OFF .equ 0
77 PPU_CTRL1_BG_CLIP_ON .equ PPU_CTRL1_BG_CLIP
78 PPU_CTRL1_BG_CLIP_OFF .equ 0
80 ; PPU state.
81 .struc ppu_state
82 ctrl0 .ppu_ctrl0
83 ctrl1 .ppu_ctrl1
84 scroll_x .byte
85 scroll_y .byte
86 .ends
88 ; Exported symbols.
89 .extrn reset_screen:proc
90 .extrn screen_on:proc
91 .extrn screen_off:proc
92 .extrn nmi_on:proc
93 .extrn nmi_off:proc
94 .extrn fill_nametable:proc
95 .extrn fill_nametable_0_0:proc
96 .extrn fill_all_nametables:proc
97 .extrn get_scroll_xy:proc
98 .extrn set_scroll_xy:proc
99 .extrn write_ppu_data_at:label
100 .extrn copy_string_to_ppu_buffer:proc
101 .extrn copy_bytes_to_ppu_buffer:proc
103 .extrn ppu:ppu_state
105 .endif ; !PPU_H