Skip to content

Commit

Permalink
amalgamation
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@227 be3aeb3a-fb24-0410-a615-afba39da0efa
  • Loading branch information
notaz committed Aug 25, 2007
1 parent a4f0cc8 commit eff5555
Show file tree
Hide file tree
Showing 35 changed files with 612 additions and 368 deletions.
4 changes: 2 additions & 2 deletions Pico/Area.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int ScanVar(void *data,int len,char *name,void *PmovFile,int PmovAction)
#define SCANP(x) ScanVar(&Pico.x,sizeof(Pico.x),#x,PmovFile,PmovAction);

// Pack the cpu into a common format:
int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
{
unsigned int pc=0;

Expand Down Expand Up @@ -82,7 +82,7 @@ int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
return 0;
}

int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
{
#ifdef EMU_A68K
memcpy(M68000_regs.d,cpu,0x40);
Expand Down
4 changes: 2 additions & 2 deletions Pico/Draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ static int DrawDisplay(int sh)

static int Skip=0;

void PicoFrameStart()
PICO_INTERNAL void PicoFrameStart(void)
{
// prepare to do this frame
rendstatus = (PicoOpt&0x80)>>5; // accurate sprites
Expand All @@ -1256,7 +1256,7 @@ void PicoFrameStart()
Skip=0;
}

int PicoLine(int scan)
PICO_INTERNAL int PicoLine(int scan)
{
int sh;
if (Skip>0) { Skip--; return 0; } // Skip rendering lines
Expand Down
30 changes: 13 additions & 17 deletions Pico/Draw2.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@


#include "PicoInt.h"
#include <assert.h>
#ifndef __GNUC__
#pragma warning (disable:4706) // Disable assignment within conditional
#endif

// port_config.h include must define these 2 defines:
// #define START_ROW 1 // which row of tiles to start rendering at?
Expand All @@ -28,8 +24,8 @@
extern unsigned char *framebuff; // in format (8+320)x(8+224+8) (eights for borders)
int currpri = 0;

static int HighCacheA[41*(TILE_ROWS+1)+1+1]; // caches for high layers
static int HighCacheB[41*(TILE_ROWS+1)+1+1];
static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
static int HighCache2B[41*(TILE_ROWS+1)+1+1];

unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
Expand Down Expand Up @@ -235,9 +231,9 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)
height=(width>>4)&3; width&=3;

xmask=(1<<shift[width ])-1; // X Mask in tiles
ymask=(height<<5)|0x1f; // Y Mask in tiles
if(width == 1) ymask&=0x3f;
else if(width>1) ymask =0x1f;
ymask=(height<<5)|0x1f; // Y Mask in tiles
if(width == 1) ymask&=0x3f;
else if(width>1) ymask =0x1f;

// Find name table:
if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A
Expand Down Expand Up @@ -563,38 +559,38 @@ static void DrawDisplayFull()
if(hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }

currpri = 0;
DrawLayerFull(1, HighCacheB, START_ROW, (maxcolc<<16)|END_ROW);
DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW);
switch(hvwin) {
case 4:
// fullscreen window
DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0);
HighCacheA[1] = 0;
HighCache2A[1] = 0;
break;

case 3:
// we have plane A and both v and h windows
DrawLayerFull(0, HighCacheA, planestart, planeend);
DrawLayerFull(0, HighCache2A, planestart, planeend);
DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h
DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v
break;

case 2:
case 1:
// both window and plane A visible, window is vertical XOR horizontal
DrawLayerFull(0, HighCacheA, planestart, planeend);
DrawLayerFull(0, HighCache2A, planestart, planeend);
DrawWindowFull(winstart, winend, 0);
break;

default:
// fullscreen plane A
DrawLayerFull(0, HighCacheA, START_ROW, (maxcolc<<16)|END_ROW);
DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW);
break;
}
DrawAllSpritesFull(0, maxw);

#ifdef USE_CACHE
if(HighCacheB[1]) DrawTilesFromCacheF(HighCacheB);
if(HighCacheA[1]) DrawTilesFromCacheF(HighCacheA);
if(HighCache2B[1]) DrawTilesFromCacheF(HighCache2B);
if(HighCache2A[1]) DrawTilesFromCacheF(HighCache2A);
switch(hvwin) {
case 4:
// fullscreen window
Expand All @@ -621,7 +617,7 @@ static void DrawDisplayFull()
}


void PicoFrameFull()
PICO_INTERNAL void PicoFrameFull()
{
// prepare cram?
if(PicoPrepareCram) PicoPrepareCram();
Expand Down
24 changes: 13 additions & 11 deletions Pico/Memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@

#include "PicoInt.h"

#include "sound/sound.h"
#include "sound/ym2612.h"
#include "sound/sn76496.h"

#ifndef UTYPES_DEFINED
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
#define UTYPES_DEFINED
#endif

extern unsigned int lastSSRamWrite; // used by serial SRAM code

Expand Down Expand Up @@ -88,14 +90,14 @@ static u32 CPU_CALL PicoCheckPc(u32 pc)
}


int PicoInitPc(u32 pc)
PICO_INTERNAL int PicoInitPc(u32 pc)
{
PicoCheckPc(pc);
return 0;
}

#ifndef _ASM_MEMORY_C
void PicoMemReset()
PICO_INTERNAL_ASM void PicoMemReset(void)
{
}
#endif
Expand Down Expand Up @@ -266,7 +268,7 @@ static void OtherWrite8End(u32 a,u32 d,int realsize)
// Read Rom and read Ram

#ifndef _ASM_MEMORY_C
u32 CPU_CALL PicoRead8(u32 a)
PICO_INTERNAL_ASM u32 CPU_CALL PicoRead8(u32 a)
{
u32 d=0;

Expand Down Expand Up @@ -317,7 +319,7 @@ u32 CPU_CALL PicoRead8(u32 a)
return d;
}

u32 CPU_CALL PicoRead16(u32 a)
PICO_INTERNAL_ASM u32 CPU_CALL PicoRead16(u32 a)
{
u32 d=0;

Expand Down Expand Up @@ -353,7 +355,7 @@ u32 CPU_CALL PicoRead16(u32 a)
return d;
}

u32 CPU_CALL PicoRead32(u32 a)
PICO_INTERNAL_ASM u32 CPU_CALL PicoRead32(u32 a)
{
u32 d=0;

Expand Down Expand Up @@ -446,7 +448,7 @@ static void CPU_CALL PicoWrite32(u32 a,u32 d)


// -----------------------------------------------------------------
void PicoMemSetup()
PICO_INTERNAL void PicoMemSetup(void)
{
#ifdef EMU_C68K
// Setup memory callbacks:
Expand Down Expand Up @@ -623,7 +625,7 @@ void m68k_write_memory_32(unsigned int address, unsigned int value)
// -----------------------------------------------------------------
// z80 memhandlers

unsigned char z80_read(unsigned short a)
PICO_INTERNAL unsigned char z80_read(unsigned short a)
{
u8 ret = 0;

Expand Down Expand Up @@ -651,14 +653,14 @@ unsigned char z80_read(unsigned short a)
return ret;
}

unsigned short z80_read16(unsigned short a)
PICO_INTERNAL unsigned short z80_read16(unsigned short a)
{
//dprintf("z80_read16");

return (u16) ( (u16)z80_read(a) | ((u16)z80_read((u16)(a+1))<<8) );
}

void z80_write(unsigned char data, unsigned short a)
PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a)
{
//if (a<0x4000)
// dprintf("z80 w8 : %06x, %02x @%04x", a, data, mz80GetRegisterValue(NULL, 0));
Expand Down Expand Up @@ -697,7 +699,7 @@ void z80_write(unsigned char data, unsigned short a)
if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; }
}

void z80_write16(unsigned short data, unsigned short a)
PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a)
{
//dprintf("z80_write16");

Expand Down
14 changes: 14 additions & 0 deletions Pico/MemoryCmn.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// common code for Memory.c and cd/Memory.c
// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas

#ifndef UTYPES_DEFINED
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
#define UTYPES_DEFINED
#endif

#ifdef _ASM_MEMORY_C
u32 OtherRead16End(u32 a, int realsize);
#endif
#ifdef _ASM_CD_MEMORY_C
static void OtherWrite8End(u32 a,u32 d,int realsize);
#endif

static int PadRead(int i)
{
int pad=0,value=0,TH;
Expand Down
14 changes: 7 additions & 7 deletions Pico/Misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ unsigned int lastSSRamWrite = 0xffff0000;

// sram_reg: LAtd sela (L=pending SCL, A=pending SDA, t=type(1==uses 0x200000 for SCL and 2K bytes),
// d=SRAM was detected (header or by access), s=started, e=save is EEPROM, l=old SCL, a=old SDA)
void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)
PICO_INTERNAL void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)
{
unsigned int sreg = Pico.m.sram_reg, saddr = Pico.m.sram_addr, scyc = Pico.m.sram_cycle, ssa = Pico.m.sram_slave;

Expand Down Expand Up @@ -247,7 +247,7 @@ void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)
Pico.m.sram_slave= (unsigned char) ssa;
}

unsigned int SRAMReadEEPROM()
PICO_INTERNAL_ASM unsigned int SRAMReadEEPROM(void)
{
unsigned int shift, d=0;
unsigned int sreg, saddr, scyc, ssa;
Expand Down Expand Up @@ -282,7 +282,7 @@ unsigned int SRAMReadEEPROM()
return d;
}

void SRAMUpdPending(unsigned int a, unsigned int d)
PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d)
{
unsigned int sreg = Pico.m.sram_reg;

Expand All @@ -306,14 +306,14 @@ void SRAMUpdPending(unsigned int a, unsigned int d)


#ifndef _ASM_MISC_C
void memcpy16(unsigned short *dest, unsigned short *src, int count)
PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)
{
while (count--)
*dest++ = *src++;
}


void memcpy16bswap(unsigned short *dest, void *src, int count)
PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
{
unsigned char *src_ = src;

Expand All @@ -322,14 +322,14 @@ void memcpy16bswap(unsigned short *dest, void *src, int count)
}


void memcpy32(int *dest, int *src, int count)
PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)
{
while (count--)
*dest++ = *src++;
}


void memset32(int *dest, int c, int count)
PICO_INTERNAL_ASM void memset32(int *dest, int c, int count)
{
while (count--)
*dest++ = c;
Expand Down
2 changes: 1 addition & 1 deletion Pico/Patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static void decode(const char* code, struct patch* result)



unsigned short PicoRead16(unsigned int a);
unsigned int PicoRead16(unsigned int a);
void PicoWrite16(unsigned int a, unsigned short d);


Expand Down
5 changes: 2 additions & 3 deletions Pico/Pico.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


#include "PicoInt.h"
#include "sound/sound.h"
#include "sound/ym2612.h"

int PicoVer=0x0110;
Expand Down Expand Up @@ -218,8 +217,8 @@ static int dma_bsycles[] = {
(488<<8)/9, (488<<8)/18, (488<<8)/17, (488<<8)/9
};

//static
int CheckDMA(void)

PICO_INTERNAL int CheckDMA(void)
{
int burn = 0, bytes_can = 0, dma_op = Pico.video.reg[0x17]>>6; // see gens for 00 and 01 modes
int bytes = Pico.m.dma_bytes;
Expand Down
15 changes: 9 additions & 6 deletions Pico/Pico.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef PICO_H
#define PICO_H

#include <stdio.h>

// port-specific compile-time settings
#include <port_config.h>

Expand Down Expand Up @@ -47,10 +49,8 @@ extern void (*PicoWriteSound)(int len); // called once per frame at the best tim
extern void (*PicoMessage)(const char *msg); // callback to output text message from emu

// cd/Pico.c
int PicoFrameMCD(void);
extern void (*PicoMCDopenTray)(void);
extern int (*PicoMCDcloseTray)(void);

extern int PicoCDBuffers;

// Area.c
Expand All @@ -67,10 +67,17 @@ extern areaseek *areaSeek;
extern areaclose *areaClose;
extern void (*PicoStateProgressCB)(const char *str);

// cd/Area.c
int PicoCdLoadStateGfx(void *file);

// cd/buffering.c
void PicoCDBufferInit(void);
void PicoCDBufferFree(void);

// cd/cd_sys.c
int Insert_CD(char *iso_name, int is_bin);
void Stop_CD(void); // releases all resources taken when CD game was started.

// Cart.c
typedef enum
{
Expand Down Expand Up @@ -117,11 +124,7 @@ extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to us
// sound.c
extern int PsndRate,PsndLen;
extern short *PsndOut;
void sound_reset();
void sound_rerate(int preserve_state);
void z80_pack(unsigned char *data);
void z80_unpack(unsigned char *data);
void z80_reset();

// Utils.c
extern int PicuAnd;
Expand Down
Loading

0 comments on commit eff5555

Please sign in to comment.