Change to C comments

This commit is contained in:
twinaphex 2020-01-07 12:03:08 +01:00
parent 6197544425
commit e61e082830
9 changed files with 624 additions and 539 deletions

View File

@ -1,21 +1,21 @@
//---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. See also the license.txt file for
// additional informations.
//---------------------------------------------------------------------------
/*---------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See also the license.txt file for
* additional informations.
*---------------------------------------------------------------------------
*/
//
// Support functions for interfacing with DrZ80
//
/*
* Support functions for interfacing with DrZ80
*/
#ifndef __GP32__
#include "StdAfx.h"
#endif
#include "main.h"
#include "memory.h"
//#include "mainemu.h"
#include "DrZ80_support.h"
@ -98,5 +98,5 @@ extern "C" int Z80_Execute(int cycles)
Z80.regs.cycles = cycles;
DrZ80Run(&Z80.regs, cycles);
return cycles;// (cycles-Z80.regs.cycles);
return cycles; /* (cycles-Z80.regs.cycles); */
}

View File

@ -19,7 +19,7 @@ typedef struct {
extern Z80_Regs Z80;
#define Z80_IGNORE_INT -1 /* Ignore interrupt */
#define Z80_NMI_INT -2 /* Execute NMI */
#define Z80_NMI_INT -2 /* Execute NMI */
#define Z80_IRQ_INT -1000 /* Execute IRQ */
extern unsigned Z80_GetPC (void); /* Get program counter */

View File

@ -22,24 +22,21 @@
#include "cz80.h"
// include macro file
//////////////////////
/* include macro file */
#include "cz80.inc"
// lookup tables
/////////////////
/* lookup tables */
static u8 SZXY[256]; // zero and sign flags
static u8 SZXYP[256]; // zero, sign and parity flags
static u8 SZXY_BIT[256]; // zero, sign and parity/overflow (=zero) flags for BIT opcode
static u8 SZXYHV_inc[256]; // zero, sign, half carry and overflow flags INC R8
static u8 SZXYHV_dec[256]; // zero, sign, half carry and overflow flags DEC R8
static u8 SZXY[256]; /* zero and sign flags */
static u8 SZXYP[256]; /* zero, sign and parity flags */
static u8 SZXY_BIT[256]; /* zero, sign and parity/overflow (=zero) flags for BIT opcode */
static u8 SZXYHV_inc[256]; /* zero, sign, half carry and overflow flags INC R8 */
static u8 SZXYHV_dec[256]; /* zero, sign, half carry and overflow flags DEC R8 */
#define fast_memset memset
// core main functions
///////////////////////
/* core main functions */
void Cz80_Init(cz80_struc *cpu)
{
@ -47,7 +44,7 @@ void Cz80_Init(cz80_struc *cpu)
fast_memset(cpu, 0, sizeof(cz80_struc));
// flags tables initialisation
/* flags tables initialisation */
for (i = 0; i < 256; i++)
{
SZXY[i] = i & (CZ80_SF | CZ80_YF | CZ80_XF);
@ -89,8 +86,6 @@ u32 Cz80_Reset(cz80_struc *cpu)
return CPU->Status;
}
/////////////////////////////////
void CZ80_FASTCALL Cz80_Enable(cz80_struc *cpu)
{
cpu->Status &= ~CZ80_DISABLE;
@ -101,12 +96,8 @@ void CZ80_FASTCALL Cz80_Disable(cz80_struc *cpu)
cpu->Status |= CZ80_DISABLE;
}
/////////////////////////////////
#include "cz80exec.inc"
/////////////////////////////////
void CZ80_FASTCALL Cz80_Set_IRQ(cz80_struc *cpu, s32 vector)
{
cpu->IntVect = vector;
@ -132,8 +123,6 @@ void CZ80_FASTCALL Cz80_Clear_NMI(cz80_struc *cpu)
cpu->Status &= ~CZ80_HAS_NMI;
}
/////////////////////////////////
s32 CZ80_FASTCALL Cz80_Get_CycleToDo(cz80_struc *cpu)
{
if (!(cpu->Status & CZ80_RUNNING)) return 0;
@ -166,8 +155,7 @@ void CZ80_FASTCALL Cz80_Waste_Cycle(cz80_struc *cpu, s32 cycle)
cpu->CycleIO -= cycle;
}
// externals main functions
////////////////////////////
/* externals main functions */
u32 CZ80_FASTCALL Cz80_Get_BC(cz80_struc *cpu)
{

View File

@ -13,9 +13,9 @@ switch (Opcode)
{
#endif
// 8 BITS LOAD
/* 8 BITS LOAD */
OP(0x00): // NOP
OP(0x00): /* NOP */
OP(0x40): // LD B,B
OP(0x49): // LD C,C

308
flash.cpp
View File

@ -1,16 +1,17 @@
//---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. See also the license.txt file for
// additional informations.
//---------------------------------------------------------------------------
/*---------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See also the license.txt file for
* additional informations.
*---------------------------------------------------------------------------
*/
//
// Flash chip emulation by Flavor
// with ideas from Koyote (who originally got ideas from Flavor :)
// for emulation of NGPC carts
//
/*
* Flash chip emulation by Flavor
* with ideas from Koyote (who originally got ideas from Flavor :)
* for emulation of NGPC carts
*/
#ifndef __GP32__
#include "StdAfx.h"
@ -24,7 +25,10 @@
#include <unistd.h>
#endif
//#define DEBUG_FLASH
#if 0
#define DEBUG_FLASH
#endif
#ifdef DEBUG_FLASH
FILE *debugFile = NULL;
#define stderr debugFile
@ -43,15 +47,18 @@ Other
0x01 AMD
0xBF SST
*/
unsigned char manufID = 0x98; //we're always Toshiba!
unsigned char manufID = 0x98; /* we're always Toshiba! */
unsigned char deviceID = 0x2F;
unsigned char cartSize = 32;
unsigned int bootBlockStartAddr = 0x1F0000;
unsigned char bootBlockStartNum = 31;
//unsigned int cartAddrMask = 0x3FFFFF;
#if 0
unsigned int cartAddrMask = 0x3FFFFF;
#endif
//with selector, I get
//writeSaveGameFile: Couldn't open Battery//mnt/sd/Games/race/ChryMast.ngf file
/* with selector, I get
* writeSaveGameFile: Couldn't open Battery//mnt/sd/Games/race/ChryMast.ngf file
*/
#ifdef __LIBRETRO__
extern char retro_save_directory[2048];
#define SAVEGAME_DIR retro_save_directory
@ -63,69 +70,77 @@ extern char retro_save_directory[2048];
#endif
#endif
unsigned char currentWriteCycle = 1; //can be 1 through 6
unsigned char currentWriteCycle = 1; /* can be 1 through 6 */
unsigned char currentCommand = NO_COMMAND;
#define FLASH_VALID_ID 0x0053
struct NGFheaderStruct
{
unsigned short version; //always 0x53?
unsigned short numBlocks; //how many blocks are in the file
unsigned int fileLen; //length of the file
unsigned short version; /* always 0x53? */
unsigned short numBlocks; /* how many blocks are in the file */
unsigned int fileLen; /* length of the file */
} ;
struct blockStruct
{
unsigned int NGPCaddr; //where this block starts (in NGPC memory map)
unsigned int len; // length of following data
unsigned int NGPCaddr; /* where this block starts (in NGPC memory map) */
unsigned int len; /* length of following data */
} ;
#define MAX_BLOCKS 35 //a 16m chip has 35 blocks (SA0-SA34)
unsigned char blocksDirty[2][MAX_BLOCKS]; //max of 2 chips
#define MAX_BLOCKS 35 /* a 16m chip has 35 blocks (SA0-SA34) */
unsigned char blocksDirty[2][MAX_BLOCKS]; /* max of 2 chips */
unsigned char needToWriteFile = 0;
char ngfFilename[300] = {0};
#define FLASH_WRITE 0
#define FLASH_ERASE 1
void setupFlashParams()
void setupFlashParams(void)
{
switch(cartSize)
{
default:
case 32:
deviceID = 0x2F; //the upper chip will always be 16bit
deviceID = 0x2F; /* the upper chip will always be 16bit */
bootBlockStartAddr = 0x1F0000;
bootBlockStartNum = 31;
//cartAddrMask=0x3FFFFF;
#if 0
cartAddrMask=0x3FFFFF;
#endif
break;
case 16:
deviceID = 0x2F;
bootBlockStartAddr = 0x1F0000;
bootBlockStartNum = 31;
//cartAddrMask=0x1FFFFF;
#if 0
cartAddrMask=0x1FFFFF;
#endif
break;
case 8:
deviceID = 0x2C;
bootBlockStartAddr = 0xF0000;
bootBlockStartNum = 15;
//cartAddrMask=0x0FFFFF;
#if 0
cartAddrMask=0x0FFFFF;
#endif
break;
case 4:
deviceID = 0xAB;
bootBlockStartAddr = 0x70000;
bootBlockStartNum = 7;
//cartAddrMask=0x07FFFF;
#if 0
cartAddrMask=0x07FFFF;
#endif
break;
case 0:
manufID = 0x00;
deviceID = 0x00;
bootBlockStartAddr = 0x00000;
bootBlockStartNum = 0;
//cartAddrMask=0;
#if 0
cartAddrMask=0;
#endif
break;
}
}
@ -137,7 +152,7 @@ unsigned char blockNumFromAddr(unsigned int addr)
if(addr >= bootBlockStartAddr)
{
unsigned int bootAddr = addr-bootBlockStartAddr;
//boot block is 32k, 8k, 8k, 16k (0x8000,0x2000,0x2000,0x4000)
/* boot block is 32k, 8k, 8k, 16k (0x8000,0x2000,0x2000,0x4000) */
if(bootAddr < 0x8000)
return (bootBlockStartAddr / 0x10000);
else if(bootAddr < 0xA000)
@ -211,7 +226,7 @@ void setupNGFfilename()
{
#ifdef DEBUG_FLASH
fprintf(debugFile, "setupNGFfilename: %s file already opened\n", ngfFilename);
return; //already set up
return; /* already set up */
#endif
}
@ -247,10 +262,10 @@ void setupNGFfilename()
fprintf(stdout, "setupNGFfilename: using %s for save-game info\n", ngfFilename);
}
//write all the dirty blocks out to a file
void writeSaveGameFile()
/* write all the dirty blocks out to a file */
void writeSaveGameFile(void)
{
//find the dirty blocks and write them to the .NGF file
/* find the dirty blocks and write them to the .NGF file */
int totalBlocks = bootBlockStartNum+4;
int i;
FILE *ngfFile;
@ -277,7 +292,7 @@ void writeSaveGameFile()
NGFheader.version = 0x53;
NGFheader.numBlocks = 0;
NGFheader.fileLen = sizeof(NGFheaderStruct);
//add them all up, first
/* add them all up, first */
for(i=0;i<totalBlocks;i++)
{
if(blocksDirty[0][i])
@ -290,7 +305,7 @@ void writeSaveGameFile()
}
}
if(cartSize == 32) //do the second chip, also
if(cartSize == 32) /* do the second chip, also */
{
for(i=0;i<totalBlocks;i++)
{
@ -346,7 +361,7 @@ void writeSaveGameFile()
}
}
if(cartSize == 32) //do the second chip, also
if(cartSize == 32) /* do the second chip, also */
{
for(i=0;i<totalBlocks;i++)
{
@ -386,7 +401,9 @@ void writeSaveGameFile()
#ifndef __GP32__
#ifdef TARGET_GP2X
sync();
//system("sync");
#if 0
system("sync");
#endif
#endif
#endif
@ -395,10 +412,10 @@ void writeSaveGameFile()
#endif
}
//read the save-game file and overlay it onto mainrom
void loadSaveGameFile()
/* read the save-game file and overlay it onto mainrom */
void loadSaveGameFile(void)
{
//find the NGF file and read it in
/* find the NGF file and read it in */
FILE *ngfFile;
int bytes, i;
unsigned char *blocks;
@ -430,9 +447,9 @@ void loadSaveGameFile()
/*
unsigned short version; //always 0x53?
unsigned short numBlocks; //how many blocks are in the file
unsigned int fileLen; //length of the file
unsigned short version; // always 0x53?
unsigned short numBlocks; // how many blocks are in the file
unsigned int fileLen; // length of the file
*/
if(NGFheader.version != 0x53)
@ -443,7 +460,7 @@ void loadSaveGameFile()
}
blockMem = malloc(NGFheader.fileLen - sizeof(NGFheaderStruct));
//error handling?
/* error handling? */
if(!blockMem)
{
fprintf(stderr, "loadSaveGameFile: can't malloc %d bytes\n", (NGFheader.fileLen - sizeof(NGFheaderStruct)));
@ -470,7 +487,7 @@ void loadSaveGameFile()
return;
}
//loop through the blocks and insert them into mainrom
/* loop through the blocks and insert them into mainrom */
for(i=0; i < NGFheader.numBlocks; i++)
{
blockHeader = (blockStruct*) blocks;
@ -509,9 +526,11 @@ void loadSaveGameFile()
void flashWriteByte(unsigned int addr, unsigned char data, unsigned char operation)
{
//addr &= cartAddrMask; //the stuff gets mirrored to the higher slots.
#if 0
addr &= cartAddrMask; /* the stuff gets mirrored to the higher slots. */
#endif
if(blockNumFromAddr(addr) == 0) //hack because DWARP writes to bank 0
if(blockNumFromAddr(addr) == 0) /* hack because DWARP writes to bank 0 */
return;
#ifdef DEBUG_FLASH
@ -521,7 +540,7 @@ void flashWriteByte(unsigned int addr, unsigned char data, unsigned char operati
}
#endif
//set a dirty flag for the block that we are writing to
/* set a dirty flag for the block that we are writing to */
if(addr < 0x200000)
{
blocksDirty[0][blockNumFromAddr(addr)] = 1;
@ -533,15 +552,16 @@ void flashWriteByte(unsigned int addr, unsigned char data, unsigned char operati
needToWriteFile = 1;
}
else
return; //panic
return; /* panic */
//changed to &= because it's actually how flash works
//flash memory can be erased (changed to 0xFF)
//and when written, 1s can become 0s, but you can't turn 0s into 1s (except by erasing)
/* changed to &= because it's actually how flash works
* flash memory can be erased (changed to 0xFF)
* and when written, 1s can become 0s, but you can't turn 0s into 1s (except by erasing)
*/
if(operation == FLASH_ERASE)
mainrom[addr] = 0xFF; //we're just erasing, so set to 0xFF
mainrom[addr] = 0xFF; /* we're just erasing, so set to 0xFF */
else
mainrom[addr] &= data; //actually writing data
mainrom[addr] &= data; /* actually writing data */
}
unsigned char flashReadInfo(unsigned int addr)
@ -556,8 +576,8 @@ unsigned char flashReadInfo(unsigned int addr)
case 1:
return deviceID;
case 2:
return 0; //block not protected
case 3: //thanks Koyote
return 0; /* block not protected */
case 3: /* thanks Koyote */
default:
return 0x80;
}
@ -581,7 +601,7 @@ void flashChipWrite(unsigned int addr, unsigned char data)
currentWriteCycle++;
else if(data == 0xF0)
{
currentWriteCycle=1;//this is a reset command
currentWriteCycle=1; /* this is a reset command */
writeSaveGameFile();
}
else
@ -599,7 +619,7 @@ void flashChipWrite(unsigned int addr, unsigned char data)
break;
case 3:
if((addr & 0xFFFF) == 0x5555 && data == 0x80)
currentWriteCycle++;//continue on
currentWriteCycle++; /* continue on */
else if((addr & 0xFFFF) == 0x5555 && data == 0xF0)
{
currentWriteCycle=1;
@ -609,8 +629,9 @@ void flashChipWrite(unsigned int addr, unsigned char data)
{
currentWriteCycle++;
currentCommand = COMMAND_INFO_READ;
//now, the next time we read from flash, we should return a ID value
// or a block protect value
/* now, the next time we read from flash,
* we should return a ID value
* or a block protect value */
break;
}
else if((addr & 0xFFFF) == 0x5555 && data == 0xA0)
@ -626,17 +647,18 @@ void flashChipWrite(unsigned int addr, unsigned char data)
break;
case 4:
if(currentCommand == COMMAND_BYTE_PROGRAM)//time to write to flash memory
/* time to write to flash memory */
if(currentCommand == COMMAND_BYTE_PROGRAM)
{
if(addr >= 0x200000 && addr < 0x400000)
addr -= 0x200000;
else if(addr >= 0x800000 && addr < 0xA00000)
addr -= 0x600000;
if(addr >= 0x200000 && addr < 0x400000)
addr -= 0x200000;
else if(addr >= 0x800000 && addr < 0xA00000)
addr -= 0x600000;
//should be changed to just write to mainrom
flashWriteByte(addr, data, FLASH_WRITE);
/*should be changed to just write to mainrom */
flashWriteByte(addr, data, FLASH_WRITE);
currentWriteCycle=1;
currentWriteCycle=1;
}
else if((addr & 0xFFFF) == 0x5555 && data == 0xAA)
currentWriteCycle++;
@ -654,25 +676,28 @@ void flashChipWrite(unsigned int addr, unsigned char data)
currentCommand = NO_COMMAND;
break;
case 6:
if((addr & 0xFFFF) == 0x5555 && data == 0x10)//chip erase
/* chip erase */
if((addr & 0xFFFF) == 0x5555 && data == 0x10)
{
currentWriteCycle=1;
currentCommand = COMMAND_CHIP_ERASE;
//erase the entire chip
//memset it to all 0xFF
//I think we won't implement this
/* erase the entire chip
* memset it to all 0xFF
* I think we won't implement this
*/
break;
}
if(data == 0x30 || data == 0x50)//block erase
/* block erase */
if(data == 0x30 || data == 0x50)
{
unsigned char chip=0;
currentWriteCycle=1;
currentCommand = COMMAND_BLOCK_ERASE;
//erase the entire block that contains addr
//memset it to all 0xFF
/* erase the entire block that contains addr
* memset it to all 0xFF */
if(addr >= 0x800000)
chip = 1;
@ -694,8 +719,8 @@ void flashChipWrite(unsigned int addr, unsigned char data)
}
}
//this should be called when a ROM is unloaded
void flashShutdown()
/* this should be called when a ROM is unloaded */
void flashShutdown(void)
{
writeSaveGameFile();
#ifdef DEBUG_FLASH
@ -703,8 +728,8 @@ void flashShutdown()
#endif
}
//this should be called when a ROM is loaded
void flashStartup()
/* this should be called when a ROM is loaded */
void flashStartup(void)
{
#ifdef DEBUG_FLASH
if(debugFile == NULL)
@ -722,49 +747,55 @@ void flashStartup()
void vectFlashWrite(unsigned char chip, unsigned int to, unsigned char *fromAddr, unsigned int numBytes)
{
#ifdef DEBUG_FLASH
if(debugFile != NULL)
{
fprintf(debugFile, "vFW: chip=%d to=0x%08X *fromAddr=%02x num=%d\n", chip, to, *fromAddr, numBytes);
}
if(debugFile != NULL)
{
fprintf(debugFile, "vFW: chip=%d to=0x%08X *fromAddr=%02x num=%d\n", chip, to, *fromAddr, numBytes);
}
#endif
if(chip)
to+=0x200000;
if(chip)
to+=0x200000;
//memcpy(dest,fromAddr,numBytes);
while(numBytes--)
{
flashWriteByte(to, *fromAddr, FLASH_WRITE);
fromAddr++;
to++;
}
#if 0
memcpy(dest,fromAddr,numBytes);
#endif
while(numBytes--)
{
flashWriteByte(to, *fromAddr, FLASH_WRITE);
fromAddr++;
to++;
}
}
void vectFlashErase(unsigned char chip, unsigned char blockNum)
{
/*unsigned char totalBlocks = bootBlockStartNum+4;
#if 0
unsigned char totalBlocks = bootBlockStartNum+4;
if(blockNum >= totalBlocks)
blockNum = totalBlocks-1;*/
//this needs to be modified to take into account boot block areas (less than 64k)
unsigned int blockAddr = blockNumToAddr(chip, blockNum);
unsigned int numBytes = blockSize(blockNum);
#ifdef DEBUG_FLASH
if(debugFile != NULL)
{
fprintf(debugFile, "vectFlashErase: chip=%d blockNum=%d\n", chip, blockNum);
}
if(blockNum >= totalBlocks)
blockNum = totalBlocks-1;
#endif
//memset block to 0xFF
//memset(&mainrom[blockAddr], 0xFF, numBytes);
while(numBytes--)
{
flashWriteByte(blockAddr, 0xFF, FLASH_ERASE);
blockAddr++;
}
/* this needs to be modified to take into account boot block areas (less than 64k) */
unsigned int blockAddr = blockNumToAddr(chip, blockNum);
unsigned int numBytes = blockSize(blockNum);
#ifdef DEBUG_FLASH
if(debugFile != NULL)
{
fprintf(debugFile, "vectFlashErase: chip=%d blockNum=%d\n", chip, blockNum);
}
#endif
#if 0
/* memset block to 0xFF */
memset(&mainrom[blockAddr], 0xFF, numBytes);
#endif
while(numBytes--)
{
flashWriteByte(blockAddr, 0xFF, FLASH_ERASE);
blockAddr++;
}
}
void vectFlashChipErase(unsigned char chip)
@ -779,41 +810,26 @@ void vectFlashChipErase(unsigned char chip)
void setFlashSize(unsigned int romSize)
{
//add individual hacks here.
if(strncmp((const char *)&mainrom[0x24], "DELTA WARP ", 11)==0)//delta warp
{
//1 8mbit chip
cartSize = 8;
}
/* add individual hacks here. */
/*delta warp */
if(strncmp((const char *)&mainrom[0x24], "DELTA WARP ", 11)==0)
cartSize = 8; /* 1 8mbit chip */
else if(romSize > 0x200000)
{
//2 16mbit chips
cartSize = 32;
}
cartSize = 32; /* 2 16mbit chips */
else if(romSize > 0x100000)
{
//1 16mbit chip
cartSize = 16;
}
else if(romSize > 0x080000)
{
//1 8mbit chip
cartSize = 16; /* 1 16mbit chip */
else if(romSize > 0x080000) /* 1 8mbit chip */
cartSize = 8;
}
else if(romSize > 0x040000)
{
//1 4mbit chip
else if(romSize > 0x040000) /* 1 4mbit chip */
cartSize = 4;
}
else if(romSize == 0) //no cart, just emu BIOS
{
else if(romSize == 0) /* no cart, just emu BIOS */
cartSize = 0;
}
else
{
//we don't know. It's probablly a homebrew or something cut down
// so just pretend we're a Bung! cart
//2 16mbit chips
/* we don't know. It's probably a homebrew or something cut down
* so just pretend we're a Bung! cart
* 2 16mbit chips */
cartSize = 32;
}

39
flash.h
View File

@ -1,16 +1,17 @@
//---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. See also the license.txt file for
// additional informations.
//---------------------------------------------------------------------------
/*---------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See also the license.txt file for
* additional informations.
*---------------------------------------------------------------------------
*/
//
// Flash chip emulation by Flavor
// with ideas from Koyote (who originally got ideas from Flavor :)
// for emulation of NGPC carts
//
/*
* Flash chip emulation by Flavor
* with ideas from Koyote (who originally got ideas from Flavor :)
* for emulation of NGPC carts
*/
#define NO_COMMAND 0x00
#define COMMAND_BYTE_PROGRAM 0xA0
@ -18,20 +19,22 @@
#define COMMAND_CHIP_ERASE 0x10
#define COMMAND_INFO_READ 0x90
extern unsigned char currentCommand;//what command are we currently on (if any)
/* what command are we currently on (if any) */
extern unsigned char currentCommand;
void flashChipWrite(unsigned int addr, unsigned char data);
void vectFlashWrite(unsigned char chip, unsigned int to, unsigned char *fromAddr, unsigned int numBytes);
void vectFlashWrite(unsigned char chip, unsigned int to,
unsigned char *fromAddr, unsigned int numBytes);
void vectFlashErase(unsigned char chip, unsigned char blockNum);
void vectFlashChipErase(unsigned char chip);
void setFlashSize(unsigned int romSize);
void flashShutdown();
void flashShutdown(void);
unsigned char flashReadInfo(unsigned int addr);
extern unsigned char needToWriteFile;
void writeSaveGameFile();
void writeSaveGameFile(void);
#define WRITE_SAVEGAME_IF_DIRTY if(needToWriteFile) writeSaveGameFile();//we found a dirty one, so write the file
/* we found a dirty one, so write the file */
#define WRITE_SAVEGAME_IF_DIRTY if(needToWriteFile) writeSaveGameFile();

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,6 @@
// input.cpp: implementation of the input class.
//
//////////////////////////////////////////////////////////////////////
/* input.cpp: implementation of the input class. */
//Flavor - Convert from DirectInput to SDL/GP2X
/* Flavor - Convert from DirectInput to SDL/GP2X */
#ifndef __GP32__
#include "StdAfx.h"
@ -10,7 +8,9 @@
#include "main.h"
#include "input.h"
#include "memory.h"
///#include "menu.h"
#if 0
/#include "menu.h"
#endif
#ifdef _DEBUG
@ -19,8 +19,10 @@ static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// address where the state of the input device(s) is stored
//unsigned char *InputByte = get_address(0x00006F82);
/* address where the state of the input device(s) is stored */
#if 0
unsigned char *InputByte = get_address(0x00006F82);
#endif
unsigned char ngpInputState = 0;
unsigned char *InputByte = &ngpInputState;
@ -73,15 +75,15 @@ BOOL InitInput(HWND hwnd)
#ifndef __GP32__
keystates = PSP_GetKeyStateArray(NULL);
#endif
// setup standard values for input
// NGP/NGPC:
/* setup standard values for input
* NGP/NGPC: */
m_sysInfo[NGP].InputKeys[KEY_UP] = DIK_UP;
m_sysInfo[NGP].InputKeys[KEY_DOWN] = DIK_DOWN;
m_sysInfo[NGP].InputKeys[KEY_LEFT] = DIK_LEFT;
m_sysInfo[NGP].InputKeys[KEY_RIGHT] = DIK_RIGHT;
m_sysInfo[NGP].InputKeys[KEY_BUTTON_A] = DIK_SPACE;
m_sysInfo[NGP].InputKeys[KEY_BUTTON_B] = DIK_N;
m_sysInfo[NGP].InputKeys[KEY_SELECT] = DIK_O; // Option button
m_sysInfo[NGP].InputKeys[KEY_SELECT] = DIK_O; /* Option button */
m_sysInfo[NGPC].InputKeys[KEY_UP] = DIK_UP;
m_sysInfo[NGPC].InputKeys[KEY_DOWN] = DIK_DOWN;
m_sysInfo[NGPC].InputKeys[KEY_LEFT] = DIK_LEFT;

View File

@ -1,29 +1,31 @@
//---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. See also the license.txt file for
// additional informations.
//---------------------------------------------------------------------------
/*---------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See also the license.txt file for
* additional informations.
*---------------------------------------------------------------------------
*/
// memory.cpp: implementation of the memory class.
//
// Quick & dirty implementation; no rom protection etc.
//
// TODO:
//
//////////////////////////////////////////////////////////////////////
/* memory.cpp: implementation of the memory class.
*
* Quick & dirty implementation; no rom protection etc.
*
* TODO:
*/
#ifndef __GP32__
#include "StdAfx.h"
#endif
#include "main.h"
#include "memory.h"
#include "input.h" // for Gameboy Input
#include "graphics.h" // for i/o ports of the game gear
//#include "mainemu.h"
#include "input.h" /* for Gameboy Input */
#include "graphics.h" /* for i/o ports of the game gear */
#if 0
#include "mainemu.h"
#include "sound.h"
//#include "z80.h"
#include "z80.h"
#endif
#include "tlcs900h.h"
#include "koyote_bin.h"
@ -44,12 +46,17 @@ static char THIS_FILE[]=__FILE__;
#endif
// define work memory for neogeo pocket color
//
// internal cpu ram and internal I/O register (2KB + 160 bytes)
//unsigned char cpuram[0x08a0];
// regular work ram (32 kbytes?)
// on the gameboy maximum of 128kbyte of RAM is possible, plus some internal ram (64KB)
/* define work memory for neogeo pocket color
*
* internal cpu ram and internal I/O register (2KB + 160 bytes)
*/
#if 0
unsigned char cpuram[0x08a0];
#endif
/* regular work ram (32 kbytes?)
* on the gameboy maximum of 128kbyte of RAM is possible, plus some internal ram (64KB) */
unsigned char __attribute__ ((__aligned__(4))) mainram[(64+32+128)*1024];
// rom area for roms (4 Megabyte)
unsigned char __attribute__ ((__aligned__(4))) mainrom[4*1024*1024];
@ -525,4 +532,3 @@ void mem_dump_ram(FILE *output)
{
fwrite(mainram,1,sizeof(mainram),output);
}