DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
md_vdp Class Reference

#include <md.h>

List of all members.

Classes

struct  sprite_info

Public Member Functions

 md_vdp (md &)
 VDP constructor.
 ~md_vdp ()
 VDP destructor.
int command (uint16_t cmd)
 VDP commands.
unsigned short readword ()
 Read a word from memory.
unsigned char readbyte ()
 Read a byte from memory.
int writeword (unsigned short d)
 Write a word to the VDP.
int writebyte (unsigned char d)
 Write a byte to the VDP.
void reset ()
 Reset the VDP.
void sprite_masking_overflow (int line)
void sprite_mask_generate ()
void draw_scanline (struct bmap *bits, int line)
void draw_pixel (struct bmap *bits, int x, int y, uint32_t rgb)
void write_reg (uint8_t addr, uint8_t data)
 Write away a VDP register.

Public Attributes

uint8_t mem [(0x10100+0x35)]
uint8_t * vram
uint8_t * cram
uint8_t * vsram
uint8_t reg [0x20]
int rw_mode
int rw_addr
int rw_dma
bool hint_pending
bool vint_pending
bool cmd_pending
int sprite_overflow_line
unsigned char * dirt
uint32_t highpal [64]

Private Member Functions

int poke_vram (int addr, unsigned char d)
 Set value in VRAM.
int poke_cram (int addr, unsigned char d)
 Set value in CRAM.
int poke_vsram (int addr, unsigned char d)
 Set value in VSRAM.
int dma_len ()
 Calculate the DMA length.
int dma_addr ()
 Calculate DMA start address.
unsigned char dma_mem_read (int addr)
 Do a DMA read.
int putword (unsigned short d)
 Write a word to memory and update dirty flags.
int putbyte (unsigned char d)
 Write a byte to memory and update dirty flags.
void draw_tile1 (int which, int line, unsigned char *where)
void draw_tile1_solid (int which, int line, unsigned char *where)
void draw_tile2 (int which, int line, unsigned char *where)
void draw_tile2_solid (int which, int line, unsigned char *where)
void draw_tile3 (int which, int line, unsigned char *where)
void draw_tile3_solid (int which, int line, unsigned char *where)
void draw_tile4 (int which, int line, unsigned char *where)
void draw_tile4_solid (int which, int line, unsigned char *where)
void draw_window (int line, int front)
void draw_sprites (int line, bool front)
void draw_plane_back0 (int line)
void draw_plane_back1 (int line)
void draw_plane_front0 (int line)
void draw_plane_front1 (int line)
void get_sprite_info (struct sprite_info &, int)
void sprite_mask_add (uint8_t *, int, struct sprite_info &, int)

Private Attributes

unsigned char sprite_order [0x101]
unsigned char * sprite_base
uint8_t sprite_mask [512][512]
int sprite_count
int masking_sprite_index_cache
int dots_cache
unsigned int Bpp
unsigned int Bpp_times8
struct bmapbmap
unsigned char * dest
mdbelongs

Constructor & Destructor Documentation

md_vdp::md_vdp ( md md)

VDP constructor.

Parameters:
mdThe md instance this VDP belongs to.
md_vdp::~md_vdp ( )

VDP destructor.


Member Function Documentation

int md_vdp::command ( uint16_t  cmd)

VDP commands.

A VDP command is 32-bits in length written into the control port as two 16-bit words. The VDP maintains a pending flag so that it knows what to expect next.

CD1 CD0 A13 A12 A11 A10 A09 A08 (D31-D24) A07 A06 A05 A04 A03 A02 A01 A00 (D23-D16) ? ? ? ? ? ? ? ? (D15-D8) CD5 CD4 CD3 CD2 ? ? A15 A14 (D7-D0)

Where CD* indicates which ram is read or written in subsequent data port read/writes. A* is an address.

Note that the command is not cached, but rather, the lower 14 address bits are commited as soon as the first half of the command arrives. Then when the second word arrives, the remaining two address bits are commited.

It is possible to cancel (but not roll back) a pending command by:

  • reading or writing to the data port.
  • reading the control port.

In these cases the pending flag is cleared, and the first half of the command remains comitted.

Returns:
Always 0.
int md_vdp::dma_addr ( )
private

Calculate DMA start address.

int md_vdp::dma_len ( )
private

Calculate the DMA length.

unsigned char md_vdp::dma_mem_read ( int  addr)
private

Do a DMA read.

DMA can read from anywhere.

Parameters:
addrAddress where to read from.
Returns:
Byte read at "addr".
void md_vdp::draw_pixel ( struct bmap bits,
int  x,
int  y,
uint32_t  rgb 
)
void md_vdp::draw_plane_back0 ( int  line)
private
void md_vdp::draw_plane_back1 ( int  line)
private
void md_vdp::draw_plane_front0 ( int  line)
private
void md_vdp::draw_plane_front1 ( int  line)
private
void md_vdp::draw_scanline ( struct bmap bits,
int  line 
)
void md_vdp::draw_sprites ( int  line,
bool  front 
)
private
void md_vdp::draw_tile1 ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile1_solid ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile2 ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile2_solid ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile3 ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile3_solid ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile4 ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_tile4_solid ( int  which,
int  line,
unsigned char *  where 
)
inlineprivate
void md_vdp::draw_window ( int  line,
int  front 
)
private
void md_vdp::get_sprite_info ( struct sprite_info info,
int  index 
)
inlineprivate
int md_vdp::poke_cram ( int  addr,
unsigned char  d 
)
private

Set value in CRAM.

Parameters:
addrAddress to write to.
dByte to write.
Returns:
Always 0.
int md_vdp::poke_vram ( int  addr,
unsigned char  d 
)
private

Set value in VRAM.

Must go through these calls to update the dirty flags.

Parameters:
addrAddress to write to.
dByte to write.
Returns:
Always 0.
int md_vdp::poke_vsram ( int  addr,
unsigned char  d 
)
private

Set value in VSRAM.

Parameters:
addrAddress to write to.
dByte to write.
Returns:
Always 0.
int md_vdp::putbyte ( unsigned char  d)
private

Write a byte to memory and update dirty flags.

Parameters:
d8-bit data to write.
Returns:
Always 0.
int md_vdp::putword ( unsigned short  d)
private

Write a word to memory and update dirty flags.

Parameters:
d16-bit data to write.
Returns:
Always 0.
unsigned char md_vdp::readbyte ( )

Read a byte from memory.

Returns:
Read byte.
unsigned short md_vdp::readword ( )

Read a word from memory.

Returns:
Read word.
void md_vdp::reset ( )

Reset the VDP.

void md_vdp::sprite_mask_add ( uint8_t *  dest,
int  pitch,
struct sprite_info info,
int  value 
)
inlineprivate
void md_vdp::sprite_mask_generate ( )
void md_vdp::sprite_masking_overflow ( int  line)
void md_vdp::write_reg ( uint8_t  addr,
uint8_t  data 
)

Write away a VDP register.

Parameters:
addrAddress of register.
data8-bit data to write.
int md_vdp::writebyte ( unsigned char  d)

Write a byte to the VDP.

Parameters:
d8-bit data to write.
Returns:
Always 0.
int md_vdp::writeword ( unsigned short  d)

Write a word to the VDP.

Parameters:
d16-bit data to write.
Returns:
Always 0.

Member Data Documentation

md& md_vdp::belongs
private
struct bmap* md_vdp::bmap
private
unsigned int md_vdp::Bpp
private
unsigned int md_vdp::Bpp_times8
private
bool md_vdp::cmd_pending
uint8_t * md_vdp::cram
unsigned char* md_vdp::dest
private
unsigned char* md_vdp::dirt
int md_vdp::dots_cache
private
uint32_t md_vdp::highpal[64]
bool md_vdp::hint_pending
int md_vdp::masking_sprite_index_cache
private
uint8_t md_vdp::mem[(0x10100+0x35)]
uint8_t md_vdp::reg[0x20]
int md_vdp::rw_addr
int md_vdp::rw_dma
int md_vdp::rw_mode
unsigned char * md_vdp::sprite_base
private
int md_vdp::sprite_count
private
uint8_t md_vdp::sprite_mask[512][512]
private
unsigned char md_vdp::sprite_order[0x101]
private
int md_vdp::sprite_overflow_line
bool md_vdp::vint_pending
uint8_t* md_vdp::vram
uint8_t * md_vdp::vsram

The documentation for this class was generated from the following files: