Mapper30 cleanup
This commit is contained in:
@@ -30,12 +30,13 @@
|
||||
* Study Hall (128K PRG (in 512K flash chip), 8K CHR RAM, Horizontal Mirroring, Flash enabled)
|
||||
* Although Xmas 2013 uses a different board, where LEDs can be controlled (with writes to the $8000-BFFF space),
|
||||
* it otherwise functions identically.
|
||||
*
|
||||
* 17-10-20 - Works with Mystic Origins (Demo)
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
#include "../ines.h"
|
||||
|
||||
|
||||
extern uint32 ROM_size;
|
||||
static uint8 latche, latcheinit, bus_conflict, chrram_mask, software_id=0;
|
||||
static uint16 latcha;
|
||||
static uint8 *flashdata;
|
||||
@@ -67,8 +68,8 @@ void setfprg16(uint32 A, uint32 V) {
|
||||
V &= PRGmask16[0];
|
||||
setfpageptr(16, A, flashdata ? (&flashdata[V << 14]) : 0);
|
||||
} else {
|
||||
uint32 VA = V << 3;
|
||||
int x;
|
||||
uint32 VA = V << 3;
|
||||
|
||||
for (x = 0; x < 8; x++)
|
||||
setfpageptr(2, A + (x << 11), flashdata ? (&flashdata[((VA + x) & PRGmask2[0]) << 11]) : 0);
|
||||
@@ -106,22 +107,17 @@ static DECLFW(UNROM512HLatchWrite) {
|
||||
|
||||
static DECLFR(UNROM512LatchRead) {
|
||||
uint8 flash_id[3] = { 0xB5, 0xB6, 0xB7 };
|
||||
if(software_id)
|
||||
{
|
||||
if (software_id) {
|
||||
if (A & 1)
|
||||
return flash_id[ROM_size >> 4];
|
||||
else
|
||||
return 0xBF;
|
||||
}
|
||||
if(flash_save)
|
||||
{
|
||||
if(A < 0xC000)
|
||||
{
|
||||
if (flash_save) {
|
||||
if (A < 0xC000) {
|
||||
if (GetFlashWriteCount(flash_bank, A))
|
||||
return FlashPage[A >> 11][A];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (GetFlashWriteCount(ROM_size - 1, A))
|
||||
return FlashPage[A >> 11][A];
|
||||
}
|
||||
@@ -157,42 +153,32 @@ static void UNROM512LSync() {
|
||||
int erase_d[5] = { 0xAA, 0x55, 0x80, 0xAA, 0x55 };
|
||||
int erase_b[5] = { 1, 0, 1, 1, 0 };
|
||||
|
||||
if(flash_mode==0)
|
||||
{
|
||||
if((latcha == erase_a[flash_state]) && (latche == erase_d[flash_state]) && (flash_bank == erase_b[flash_state]))
|
||||
{
|
||||
if (flash_mode==0) {
|
||||
if ((latcha == erase_a[flash_state]) && (latche == erase_d[flash_state]) && (flash_bank == erase_b[flash_state])) {
|
||||
flash_state++;
|
||||
if(flash_state == 5)
|
||||
{
|
||||
if (flash_state == 5) {
|
||||
flash_mode = 1;
|
||||
}
|
||||
}
|
||||
else if ((flash_state==2)&&(latcha==0x9555)&&(latche==0xA0)&&(flash_bank==1))
|
||||
{
|
||||
else if ((flash_state == 2) && (latcha == 0x9555) && (latche == 0xA0) && (flash_bank == 1)) {
|
||||
flash_state++;
|
||||
flash_mode = 2;
|
||||
}
|
||||
else if ((flash_state==2)&&(latcha==0x9555)&&(latche==0x90)&&(flash_bank==1))
|
||||
{
|
||||
else if ((flash_state == 2) && (latcha == 0x9555) && (latche == 0x90) && (flash_bank == 1)) {
|
||||
flash_state = 0;
|
||||
software_id = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (latche == 0xF0)
|
||||
software_id = 0;
|
||||
flash_state = 0;
|
||||
}
|
||||
}
|
||||
else if(flash_mode==1) /* Chip Erase or Sector Erase */
|
||||
{
|
||||
if(latche==0x30)
|
||||
{
|
||||
else if (flash_mode == 1) { /* Chip Erase or Sector Erase */
|
||||
if (latche == 0x30) {
|
||||
inc_flash_write_count(flash_bank,latcha);
|
||||
memset(&FlashPage[(latcha & 0xF000) >> 11][latcha & 0xF000], 0xFF, 0x1000);
|
||||
}
|
||||
else if (latche==0x10)
|
||||
{
|
||||
else if (latche == 0x10) {
|
||||
uint32 i;
|
||||
for(i = 0; i < (ROM_size * 4); i++)
|
||||
inc_flash_write_count(i >> 2,i << 12);
|
||||
@@ -201,10 +187,8 @@ static void UNROM512LSync() {
|
||||
flash_state = 0;
|
||||
flash_mode = 0;
|
||||
}
|
||||
else if(flash_mode==2) /* Byte Program */
|
||||
{
|
||||
if(!GetFlashWriteCount(flash_bank,latcha))
|
||||
{
|
||||
else if (flash_mode == 2) { /* Byte Program */
|
||||
if (!GetFlashWriteCount(flash_bank, latcha)) {
|
||||
inc_flash_write_count(flash_bank, latcha);
|
||||
memcpy(&FlashPage[(latcha & 0xF000) >> 11][latcha & 0xF000], &Page[(latcha & 0xF000) >> 11][latcha & 0xF000], 0x1000);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#ifndef _FCEU_INES_H
|
||||
#define _FCEU_INES_H
|
||||
|
||||
extern uint32 ROM_size;
|
||||
extern uint32 VROM_size;
|
||||
|
||||
typedef struct {
|
||||
char ID[4]; /*NES^Z*/
|
||||
uint8 ROM_size;
|
||||
|
||||
Reference in New Issue
Block a user