/***************************************************************************************1* Genesis Plus2* CD graphics processor3*4* Copyright (C) 2012 Eke-Eke (Genesis Plus GX)5*6* Redistribution and use of this code or any derivative works are permitted7* provided that the following conditions are met:8*9* - Redistributions may not be sold, nor may they be used in a commercial10* product or activity.11*12* - Redistributions that are modified from the original source must include the13* complete source code, including the source code for all components used by a14* binary built from the modified sources. However, as a special exception, the15* source code distributed need not include anything that is normally distributed16* (in either source or binary form) with the major components (compiler, kernel,17* and so on) of the operating system on which the executable runs, unless that18* component itself accompanies the executable.19*20* - Redistributions must reproduce the above copyright notice, this list of21* conditions and the following disclaimer in the documentation and/or other22* materials provided with the distribution.23*24* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"25* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE26* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE27* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE28* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR29* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF30* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS31* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN32* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)33* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE34* POSSIBILITY OF SUCH DAMAGE.35*36****************************************************************************************/37#ifndef _CD_GFX_38#define _CD_GFX_3940#define gfx scd.gfx_hw4142typedef struct43{44uint32 cycles; /* current cycles count for graphics operation */45uint32 cyclesPerLine; /* current graphics operation timings */46uint32 dotMask; /* stamp map size mask */47uint16 *tracePtr; /* trace vector pointer */48uint16 *mapPtr; /* stamp map table base address */49uint8 stampShift; /* stamp pixel shift value (related to stamp size) */50uint8 mapShift; /* stamp map table shift value (related to stamp map size) */51uint16 bufferOffset; /* image buffer column offset */52uint32 bufferStart; /* image buffer start index */53uint16 lut_offset[0x8000]; /* Cell Image -> WORD-RAM offset lookup table (1M Mode) */54uint8 lut_prio[4][0x100][0x100]; /* WORD-RAM data writes priority lookup table */55uint8 lut_pixel[0x200]; /* Graphics operation dot offset lookup table */56uint8 lut_cell[0x100]; /* Graphics operation stamp offset lookup table */57} gfx_t;585960/***************************************************************/61/* WORD-RAM DMA interfaces (1M & 2M modes) */62/***************************************************************/63extern void word_ram_0_dma_w(unsigned int words);64extern void word_ram_1_dma_w(unsigned int words);65extern void word_ram_2M_dma_w(unsigned int words);6667/***************************************************************/68/* WORD-RAM 0 & 1 CPU interfaces (1M mode) */69/***************************************************************/70extern unsigned int word_ram_0_read16(unsigned int address);71extern unsigned int word_ram_1_read16(unsigned int address);72extern void word_ram_0_write16(unsigned int address, unsigned int data);73extern void word_ram_1_write16(unsigned int address, unsigned int data);74extern unsigned int word_ram_0_read8(unsigned int address);75extern unsigned int word_ram_1_read8(unsigned int address);76extern void word_ram_0_write8(unsigned int address, unsigned int data);77extern void word_ram_1_write8(unsigned int address, unsigned int data);7879/***************************************************************/80/* WORD-RAM 0 & 1 DOT image SUB-CPU interface (1M mode) */81/***************************************************************/82extern unsigned int dot_ram_0_read16(unsigned int address);83extern unsigned int dot_ram_1_read16(unsigned int address);84extern void dot_ram_0_write16(unsigned int address, unsigned int data);85extern void dot_ram_1_write16(unsigned int address, unsigned int data);86extern unsigned int dot_ram_0_read8(unsigned int address);87extern unsigned int dot_ram_1_read8(unsigned int address);88extern void dot_ram_0_write8(unsigned int address, unsigned int data);89extern void dot_ram_1_write8(unsigned int address, unsigned int data);909192/***************************************************************/93/* WORD-RAM 0 & 1 CELL image MAIN-CPU interface (1M mode) */94/***************************************************************/95extern unsigned int cell_ram_0_read16(unsigned int address);96extern unsigned int cell_ram_1_read16(unsigned int address);97extern void cell_ram_0_write16(unsigned int address, unsigned int data);98extern void cell_ram_1_write16(unsigned int address, unsigned int data);99extern unsigned int cell_ram_0_read8(unsigned int address);100extern unsigned int cell_ram_1_read8(unsigned int address);101extern void cell_ram_0_write8(unsigned int address, unsigned int data);102extern void cell_ram_1_write8(unsigned int address, unsigned int data);103104105/***************************************************************/106/* Rotation / Scaling operation (2M mode) */107/***************************************************************/108extern void gfx_init(void);109extern void gfx_reset(void);110extern int gfx_context_save(uint8 *state);111extern int gfx_context_load(uint8 *state);112extern void gfx_start(unsigned int base, int cycles);113extern void gfx_update(int cycles);114115#endif116117118