줄바꿈을 LF로 통일

서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다.
CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다.
내용은 바뀌지 않았습니다.
This commit is contained in:
syskiller committed 2026-11-24 07:13:54 +09:00
1 parent 40615838ac
commit 2d48091205
623 files changed
+501372 -501365

No files matched your search

+282 -282
View File
@@ -1,282 +1,282 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
/* Emulate 1 frame, return cycles ran */
static int PokeMini_EmulateFrameRun;
int PokeMini_EmulateFrame(void)
{
int lcylc = 0;
int synccylc = PM_SYNCCYCLES;
PokeMini_EmulateFrameRun = 1;
if (RequireSoundSync) {
while (PokeMini_EmulateFrameRun) {
PokeHWCycles = 0;
while (PokeHWCycles < synccylc) {
if (StallCPU) PokeHWCycles += StallCycles;
else PokeHWCycles += MinxCPU_Exec();
}
MinxTimers_Sync();
MinxPRC_Sync();
MinxAudio_Sync();
lcylc += PokeHWCycles;
}
} else {
while (PokeMini_EmulateFrameRun) {
PokeHWCycles = 0;
while (PokeHWCycles < synccylc) {
if (StallCPU) PokeHWCycles += StallCycles;
else PokeHWCycles += MinxCPU_Exec();
}
MinxTimers_Sync();
MinxPRC_Sync();
lcylc += PokeHWCycles;
}
}
return lcylc;
}
// -------------------
// Internal Processing
// -------------------
uint8_t MinxCPU_OnRead(int cpu, uint32_t addr)
{
#ifdef PERFORMANCE
if (addr >= 0x2100) {
// ROM Read (ROM Cartridge)
if (PM_ROM) return PM_ROM[addr & PM_ROM_Mask];
#else
if (addr >= 0x200000) {
// Open bus
return MinxCPU.IR;
} else if (addr >= 0x2100) {
// ROM Read (Multicard)
return MulticartRead(addr);
#endif
} else if (addr >= 0x2000) {
// I/O Read
uint8_t reg = (uint8_t)addr;
switch(reg) {
// Misc interface
case 0x00: // System Control 1
return PMR_SYS_CTRL1;
case 0x01: // System Control 2
return PMR_SYS_CTRL2;
case 0x02: // System Control 3
return PMR_SYS_CTRL3;
// IRQ interface
case 0x20: case 0x21: case 0x22: case 0x23:
case 0x24: case 0x25: case 0x26: case 0x27:
case 0x28: case 0x29: case 0x2A:
return MinxIRQ_ReadReg(cpu, reg);
// Timers interface
case 0x08: case 0x09: case 0x0A: case 0x0B:
case 0x18: case 0x19: case 0x1A: case 0x1B:
case 0x1C: case 0x1D: case 0x1E: case 0x1F:
case 0x30: case 0x31: case 0x32: case 0x33:
case 0x34: case 0x35: case 0x36: case 0x37:
case 0x38: case 0x39: case 0x3A: case 0x3B:
case 0x3C: case 0x3D: case 0x3E: case 0x3F:
case 0x40: case 0x41:
case 0x48: case 0x49: case 0x4A: case 0x4B:
case 0x4C: case 0x4D: case 0x4E: case 0x4F:
return MinxTimers_ReadReg(reg);
// Parallel I/O interface & Power
case 0x10:
case 0x44: case 0x45: case 0x46: case 0x47:
case 0x50: case 0x51: case 0x52: case 0x53:
case 0x54: case 0x55:
case 0x60: case 0x61: case 0x62:
return MinxIO_ReadReg(cpu, reg);
// Program Rendering Chip interface
case 0x80: case 0x81: case 0x82: case 0x83:
case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A: case 0x8B:
case 0x8C: case 0x8D: case 0x8E: case 0x8F:
return MinxPRC_ReadReg(reg);
// Color PRC interface
case 0xF0: case 0xF1: case 0xF2: case 0xF3:
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
return MinxColorPRC_ReadReg(cpu, reg);
// LCD interface
case 0xFE: case 0xFF:
return MinxLCD_ReadReg(cpu, reg);
// Audio interface
case 0x70: case 0x71:
return MinxAudio_ReadReg(reg);
// Open bus
default:
return MinxCPU.IR;
}
} else if (addr >= 0x1000) {
// RAM Read
return PM_RAM[addr-0x1000];
} else {
// BIOS Read
return PM_BIOS[addr];
}
return 0xFF;
}
void MinxCPU_OnWrite(int cpu, uint32_t addr, uint8_t data)
{
#ifdef PERFORMANCE
if (addr >= 0x2100) {
// Do nothing...
#else
if (addr >= 0x200000) {
// Open bus
} else if (addr >= 0x2100) {
// ROM Write
MulticartWrite(addr, data);
#endif
return;
} else if (addr >= 0x2000) {
// I/O Write
uint8_t reg = (uint8_t)addr;
switch(reg) {
// Misc interface
case 0x00: // System Control 1
PMR_SYS_CTRL1 = data;
return;
case 0x01: // System Control 2
PMR_SYS_CTRL2 = data;
return;
case 0x02: // System Control 3
PMR_SYS_CTRL3 = data;
return;
// IRQ interface
case 0x20: case 0x21: case 0x22: case 0x23:
case 0x24: case 0x25: case 0x26: case 0x27:
case 0x28: case 0x29: case 0x2A:
MinxIRQ_WriteReg(cpu, reg, data);
return;
// Timers interface
case 0x08: case 0x09: case 0x0A: case 0x0B:
case 0x18: case 0x19: case 0x1A: case 0x1B:
case 0x1C: case 0x1D: case 0x1E: case 0x1F:
case 0x30: case 0x31: case 0x32: case 0x33:
case 0x34: case 0x35: case 0x36: case 0x37:
case 0x38: case 0x39: case 0x3A: case 0x3B:
case 0x3C: case 0x3D: case 0x3E: case 0x3F:
case 0x40: case 0x41:
case 0x48: case 0x49: case 0x4A: case 0x4B:
case 0x4C: case 0x4D: case 0x4E: case 0x4F:
MinxTimers_WriteReg(reg, data);
return;
// Parallel I/O interface & Power
case 0x10:
case 0x44: case 0x45: case 0x46: case 0x47:
case 0x50: case 0x51: case 0x52: case 0x53:
case 0x54: case 0x55:
case 0x60: case 0x61: case 0x62:
MinxIO_WriteReg(cpu, reg, data);
return;
// Program Rendering Chip interface
case 0x80: case 0x81: case 0x82: case 0x83:
case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A:
MinxPRC_WriteReg(reg, data);
return;
// Color PRC interface
case 0xF0: case 0xF1: case 0xF2: case 0xF3:
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
MinxColorPRC_WriteReg(reg, data);
return;
// LCD interface
case 0xFE: case 0xFF:
MinxLCD_WriteReg(cpu, reg, data);
return;
// Audio interface
case 0x70: case 0x71:
MinxAudio_WriteReg(reg, data);
return;
}
} else if (addr >= 0x1300) {
// RAM Write
PM_RAM[addr-0x1000] = data;
return;
} else if (addr >= 0x1000) {
// RAM Write / FrameBuffer
PM_RAM[addr-0x1000] = data;
if (PRCColorMap) MinxColorPRC_WriteFramebuffer(addr-0x1000, data);
return;
}
}
void MinxCPU_OnIRQHandle(uint8_t cpuflag, uint8_t shift_u)
{
// Disable or enable master interrupt and check for interrupts
if (shift_u) {
MinxIRQ_MasterIRQ = 0;
} else {
if ((cpuflag & 0xC0) == 0xC0) MinxIRQ_MasterIRQ = 0;
else {
MinxIRQ_MasterIRQ = 1;
MinxIRQ_Process();
}
}
}
void MinxCPU_OnIRQAct(uint8_t intr)
{
// Set and process interrupt
MinxIRQ_SetIRQ(intr);
}
void MinxIRQ_OnIRQ(uint8_t intr)
{
// From IRQ module, call the CPU interrupt
MinxCPU_CallIRQ(intr << 1);
}
void MinxPRC_On72HzRefresh(int prcrender)
{
// Frame rendered
#ifdef PM_FASTLCD
/* PokeMiniEmu: the Paradise program reads the LCD memory itself, only for the frames it shows (and mixes two
* frames for the grey shades); the per-dot buffers and the decay are left out (they took about 18 % of the time) */
(void)prcrender; LCDDirty = 0;
#else
if ((PokeMini_LCDMode == LCDMODE_3SHADES) && (prcrender)) memcpy(LCDPixelsA, LCDPixelsD, 96*64);
if (LCDDirty) MinxLCD_Render();
if (PokeMini_LCDMode == LCDMODE_ANALOG) MinxLCD_DecayRefresh();
#endif
PokeMini_EmulateFrameRun = 0;
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
/* Emulate 1 frame, return cycles ran */
static int PokeMini_EmulateFrameRun;
int PokeMini_EmulateFrame(void)
{
int lcylc = 0;
int synccylc = PM_SYNCCYCLES;
PokeMini_EmulateFrameRun = 1;
if (RequireSoundSync) {
while (PokeMini_EmulateFrameRun) {
PokeHWCycles = 0;
while (PokeHWCycles < synccylc) {
if (StallCPU) PokeHWCycles += StallCycles;
else PokeHWCycles += MinxCPU_Exec();
}
MinxTimers_Sync();
MinxPRC_Sync();
MinxAudio_Sync();
lcylc += PokeHWCycles;
}
} else {
while (PokeMini_EmulateFrameRun) {
PokeHWCycles = 0;
while (PokeHWCycles < synccylc) {
if (StallCPU) PokeHWCycles += StallCycles;
else PokeHWCycles += MinxCPU_Exec();
}
MinxTimers_Sync();
MinxPRC_Sync();
lcylc += PokeHWCycles;
}
}
return lcylc;
}
// -------------------
// Internal Processing
// -------------------
uint8_t MinxCPU_OnRead(int cpu, uint32_t addr)
{
#ifdef PERFORMANCE
if (addr >= 0x2100) {
// ROM Read (ROM Cartridge)
if (PM_ROM) return PM_ROM[addr & PM_ROM_Mask];
#else
if (addr >= 0x200000) {
// Open bus
return MinxCPU.IR;
} else if (addr >= 0x2100) {
// ROM Read (Multicard)
return MulticartRead(addr);
#endif
} else if (addr >= 0x2000) {
// I/O Read
uint8_t reg = (uint8_t)addr;
switch(reg) {
// Misc interface
case 0x00: // System Control 1
return PMR_SYS_CTRL1;
case 0x01: // System Control 2
return PMR_SYS_CTRL2;
case 0x02: // System Control 3
return PMR_SYS_CTRL3;
// IRQ interface
case 0x20: case 0x21: case 0x22: case 0x23:
case 0x24: case 0x25: case 0x26: case 0x27:
case 0x28: case 0x29: case 0x2A:
return MinxIRQ_ReadReg(cpu, reg);
// Timers interface
case 0x08: case 0x09: case 0x0A: case 0x0B:
case 0x18: case 0x19: case 0x1A: case 0x1B:
case 0x1C: case 0x1D: case 0x1E: case 0x1F:
case 0x30: case 0x31: case 0x32: case 0x33:
case 0x34: case 0x35: case 0x36: case 0x37:
case 0x38: case 0x39: case 0x3A: case 0x3B:
case 0x3C: case 0x3D: case 0x3E: case 0x3F:
case 0x40: case 0x41:
case 0x48: case 0x49: case 0x4A: case 0x4B:
case 0x4C: case 0x4D: case 0x4E: case 0x4F:
return MinxTimers_ReadReg(reg);
// Parallel I/O interface & Power
case 0x10:
case 0x44: case 0x45: case 0x46: case 0x47:
case 0x50: case 0x51: case 0x52: case 0x53:
case 0x54: case 0x55:
case 0x60: case 0x61: case 0x62:
return MinxIO_ReadReg(cpu, reg);
// Program Rendering Chip interface
case 0x80: case 0x81: case 0x82: case 0x83:
case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A: case 0x8B:
case 0x8C: case 0x8D: case 0x8E: case 0x8F:
return MinxPRC_ReadReg(reg);
// Color PRC interface
case 0xF0: case 0xF1: case 0xF2: case 0xF3:
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
return MinxColorPRC_ReadReg(cpu, reg);
// LCD interface
case 0xFE: case 0xFF:
return MinxLCD_ReadReg(cpu, reg);
// Audio interface
case 0x70: case 0x71:
return MinxAudio_ReadReg(reg);
// Open bus
default:
return MinxCPU.IR;
}
} else if (addr >= 0x1000) {
// RAM Read
return PM_RAM[addr-0x1000];
} else {
// BIOS Read
return PM_BIOS[addr];
}
return 0xFF;
}
void MinxCPU_OnWrite(int cpu, uint32_t addr, uint8_t data)
{
#ifdef PERFORMANCE
if (addr >= 0x2100) {
// Do nothing...
#else
if (addr >= 0x200000) {
// Open bus
} else if (addr >= 0x2100) {
// ROM Write
MulticartWrite(addr, data);
#endif
return;
} else if (addr >= 0x2000) {
// I/O Write
uint8_t reg = (uint8_t)addr;
switch(reg) {
// Misc interface
case 0x00: // System Control 1
PMR_SYS_CTRL1 = data;
return;
case 0x01: // System Control 2
PMR_SYS_CTRL2 = data;
return;
case 0x02: // System Control 3
PMR_SYS_CTRL3 = data;
return;
// IRQ interface
case 0x20: case 0x21: case 0x22: case 0x23:
case 0x24: case 0x25: case 0x26: case 0x27:
case 0x28: case 0x29: case 0x2A:
MinxIRQ_WriteReg(cpu, reg, data);
return;
// Timers interface
case 0x08: case 0x09: case 0x0A: case 0x0B:
case 0x18: case 0x19: case 0x1A: case 0x1B:
case 0x1C: case 0x1D: case 0x1E: case 0x1F:
case 0x30: case 0x31: case 0x32: case 0x33:
case 0x34: case 0x35: case 0x36: case 0x37:
case 0x38: case 0x39: case 0x3A: case 0x3B:
case 0x3C: case 0x3D: case 0x3E: case 0x3F:
case 0x40: case 0x41:
case 0x48: case 0x49: case 0x4A: case 0x4B:
case 0x4C: case 0x4D: case 0x4E: case 0x4F:
MinxTimers_WriteReg(reg, data);
return;
// Parallel I/O interface & Power
case 0x10:
case 0x44: case 0x45: case 0x46: case 0x47:
case 0x50: case 0x51: case 0x52: case 0x53:
case 0x54: case 0x55:
case 0x60: case 0x61: case 0x62:
MinxIO_WriteReg(cpu, reg, data);
return;
// Program Rendering Chip interface
case 0x80: case 0x81: case 0x82: case 0x83:
case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A:
MinxPRC_WriteReg(reg, data);
return;
// Color PRC interface
case 0xF0: case 0xF1: case 0xF2: case 0xF3:
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
MinxColorPRC_WriteReg(reg, data);
return;
// LCD interface
case 0xFE: case 0xFF:
MinxLCD_WriteReg(cpu, reg, data);
return;
// Audio interface
case 0x70: case 0x71:
MinxAudio_WriteReg(reg, data);
return;
}
} else if (addr >= 0x1300) {
// RAM Write
PM_RAM[addr-0x1000] = data;
return;
} else if (addr >= 0x1000) {
// RAM Write / FrameBuffer
PM_RAM[addr-0x1000] = data;
if (PRCColorMap) MinxColorPRC_WriteFramebuffer(addr-0x1000, data);
return;
}
}
void MinxCPU_OnIRQHandle(uint8_t cpuflag, uint8_t shift_u)
{
// Disable or enable master interrupt and check for interrupts
if (shift_u) {
MinxIRQ_MasterIRQ = 0;
} else {
if ((cpuflag & 0xC0) == 0xC0) MinxIRQ_MasterIRQ = 0;
else {
MinxIRQ_MasterIRQ = 1;
MinxIRQ_Process();
}
}
}
void MinxCPU_OnIRQAct(uint8_t intr)
{
// Set and process interrupt
MinxIRQ_SetIRQ(intr);
}
void MinxIRQ_OnIRQ(uint8_t intr)
{
// From IRQ module, call the CPU interrupt
MinxCPU_CallIRQ(intr << 1);
}
void MinxPRC_On72HzRefresh(int prcrender)
{
// Frame rendered
#ifdef PM_FASTLCD
/* PokeMiniEmu: the Paradise program reads the LCD memory itself, only for the frames it shows (and mixes two
* frames for the grey shades); the per-dot buffers and the decay are left out (they took about 18 % of the time) */
(void)prcrender; LCDDirty = 0;
#else
if ((PokeMini_LCDMode == LCDMODE_3SHADES) && (prcrender)) memcpy(LCDPixelsA, LCDPixelsD, 96*64);
if (LCDDirty) MinxLCD_Render();
if (PokeMini_LCDMode == LCDMODE_ANALOG) MinxLCD_DecayRefresh();
#endif
PokeMini_EmulateFrameRun = 0;
}
+25 -25
View File
@@ -1,25 +1,25 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HARDWARE_EMU
#define HARDWARE_EMU
/* Emulate 1 frame, return cycles ran */
int PokeMini_EmulateFrame(void);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HARDWARE_EMU
#define HARDWARE_EMU
/* Emulate 1 frame, return cycles ran */
int PokeMini_EmulateFrame(void);
#endif
+122 -122
View File
@@ -1,122 +1,122 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2014 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IO_MAP_H
#define IO_MAP_H
#include "PokeMini.h"
// Pokemon-Mini I/O Registers
#define PM_IO (&PM_RAM[0x1000])
#define PMR_SYS_CTRL1 (PM_RAM[0x1000])
#define PMR_SYS_CTRL2 (PM_RAM[0x1001])
#define PMR_SYS_CTRL3 (PM_RAM[0x1002])
#define PMR_SEC_CTRL (PM_RAM[0x1008])
#define PMR_SEC_CNT_LO (PM_RAM[0x1009])
#define PMR_SEC_CNT_MID (PM_RAM[0x100A])
#define PMR_SEC_CNT_HI (PM_RAM[0x100B])
#define PMR_SYS_BATT (PM_RAM[0x1010])
#define PMR_TMR1_SCALE (PM_RAM[0x1018])
#define PMR_TMR1_ENA_OSC (PM_RAM[0x1019])
#define PMR_TMR1_OSC (PM_RAM[0x1019])
#define PMR_TMR2_SCALE (PM_RAM[0x101A])
#define PMR_TMR2_OSC (PM_RAM[0x101B])
#define PMR_TMR3_SCALE (PM_RAM[0x101C])
#define PMR_TMR3_OSC (PM_RAM[0x101D])
#define PMR_IRQ_PRI1 (PM_RAM[0x1020])
#define PMR_IRQ_PRI2 (PM_RAM[0x1021])
#define PMR_IRQ_PRI3 (PM_RAM[0x1022])
#define PMR_IRQ_ENA1 (PM_RAM[0x1023])
#define PMR_IRQ_ENA2 (PM_RAM[0x1024])
#define PMR_IRQ_ENA3 (PM_RAM[0x1025])
#define PMR_IRQ_ENA4 (PM_RAM[0x1026])
#define PMR_IRQ_ACT1 (PM_RAM[0x1027])
#define PMR_IRQ_ACT2 (PM_RAM[0x1028])
#define PMR_IRQ_ACT3 (PM_RAM[0x1029])
#define PMR_IRQ_ACT4 (PM_RAM[0x102A])
#define PMR_TMR1_CTRL_L (PM_RAM[0x1030])
#define PMR_TMR1_CTRL_H (PM_RAM[0x1031])
#define PMR_TMR1_PRE_L (PM_RAM[0x1032])
#define PMR_TMR1_PRE_H (PM_RAM[0x1033])
#define PMR_TMR1_PVT_L (PM_RAM[0x1034])
#define PMR_TMR1_PVT_H (PM_RAM[0x1035])
#define PMR_TMR1_CNT_L (PM_RAM[0x1036])
#define PMR_TMR1_CNT_H (PM_RAM[0x1037])
#define PMR_TMR2_CTRL_L (PM_RAM[0x1038])
#define PMR_TMR2_CTRL_H (PM_RAM[0x1039])
#define PMR_TMR2_PRE_L (PM_RAM[0x103A])
#define PMR_TMR2_PRE_H (PM_RAM[0x103B])
#define PMR_TMR2_PVT_L (PM_RAM[0x103C])
#define PMR_TMR2_PVT_H (PM_RAM[0x103D])
#define PMR_TMR2_CNT_L (PM_RAM[0x103E])
#define PMR_TMR2_CNT_H (PM_RAM[0x103F])
#define PMR_TMR256_CTRL (PM_RAM[0x1040])
#define PMR_TMR256_CNT (PM_RAM[0x1041])
#define PMR_REG_44 (PM_RAM[0x1044])
#define PMR_REG_45 (PM_RAM[0x1045])
#define PMR_REG_46 (PM_RAM[0x1046])
#define PMR_REG_47 (PM_RAM[0x1047])
#define PMR_TMR3_CTRL_L (PM_RAM[0x1048])
#define PMR_TMR3_CTRL_H (PM_RAM[0x1049])
#define PMR_TMR3_PRE_L (PM_RAM[0x104A])
#define PMR_TMR3_PRE_H (PM_RAM[0x104B])
#define PMR_TMR3_PVT_L (PM_RAM[0x104C])
#define PMR_TMR3_PVT_H (PM_RAM[0x104D])
#define PMR_TMR3_CNT_L (PM_RAM[0x104E])
#define PMR_TMR3_CNT_H (PM_RAM[0x104F])
#define PMR_REG_50 (PM_RAM[0x1050])
#define PMR_REG_51 (PM_RAM[0x1051])
#define PMR_KEY_PAD (PM_RAM[0x1052])
#define PMR_REG_53 (PM_RAM[0x1053])
#define PMR_REG_54 (PM_RAM[0x1054])
#define PMR_REG_55 (PM_RAM[0x1055])
#define PMR_IO_DIR (PM_RAM[0x1060])
#define PMR_IO_DATA (PM_RAM[0x1061])
#define PMR_REG_62 (PM_RAM[0x1062])
#define PMR_AUD_CTRL (PM_RAM[0x1070])
#define PMR_AUD_VOL (PM_RAM[0x1071])
#define PMR_PRC_MODE (PM_RAM[0x1080])
#define PMR_PRC_RATE (PM_RAM[0x1081])
#define PMR_PRC_MAP_LO (PM_RAM[0x1082])
#define PMR_PRC_MAP_MID (PM_RAM[0x1083])
#define PMR_PRC_MAP_HI (PM_RAM[0x1084])
#define PMR_PRC_SCROLL_Y (PM_RAM[0x1085])
#define PMR_PRC_SCROLL_X (PM_RAM[0x1086])
#define PMR_PRC_SPR_LO (PM_RAM[0x1087])
#define PMR_PRC_SPR_MID (PM_RAM[0x1088])
#define PMR_PRC_SPR_HI (PM_RAM[0x1089])
#define PMR_PRC_CNT (PM_RAM[0x108A])
#define PMR_LCD_CTRL (PM_RAM[0x10FE])
#define PMR_LCD_DATA (PM_RAM[0x10FF])
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2014 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IO_MAP_H
#define IO_MAP_H
#include "PokeMini.h"
// Pokemon-Mini I/O Registers
#define PM_IO (&PM_RAM[0x1000])
#define PMR_SYS_CTRL1 (PM_RAM[0x1000])
#define PMR_SYS_CTRL2 (PM_RAM[0x1001])
#define PMR_SYS_CTRL3 (PM_RAM[0x1002])
#define PMR_SEC_CTRL (PM_RAM[0x1008])
#define PMR_SEC_CNT_LO (PM_RAM[0x1009])
#define PMR_SEC_CNT_MID (PM_RAM[0x100A])
#define PMR_SEC_CNT_HI (PM_RAM[0x100B])
#define PMR_SYS_BATT (PM_RAM[0x1010])
#define PMR_TMR1_SCALE (PM_RAM[0x1018])
#define PMR_TMR1_ENA_OSC (PM_RAM[0x1019])
#define PMR_TMR1_OSC (PM_RAM[0x1019])
#define PMR_TMR2_SCALE (PM_RAM[0x101A])
#define PMR_TMR2_OSC (PM_RAM[0x101B])
#define PMR_TMR3_SCALE (PM_RAM[0x101C])
#define PMR_TMR3_OSC (PM_RAM[0x101D])
#define PMR_IRQ_PRI1 (PM_RAM[0x1020])
#define PMR_IRQ_PRI2 (PM_RAM[0x1021])
#define PMR_IRQ_PRI3 (PM_RAM[0x1022])
#define PMR_IRQ_ENA1 (PM_RAM[0x1023])
#define PMR_IRQ_ENA2 (PM_RAM[0x1024])
#define PMR_IRQ_ENA3 (PM_RAM[0x1025])
#define PMR_IRQ_ENA4 (PM_RAM[0x1026])
#define PMR_IRQ_ACT1 (PM_RAM[0x1027])
#define PMR_IRQ_ACT2 (PM_RAM[0x1028])
#define PMR_IRQ_ACT3 (PM_RAM[0x1029])
#define PMR_IRQ_ACT4 (PM_RAM[0x102A])
#define PMR_TMR1_CTRL_L (PM_RAM[0x1030])
#define PMR_TMR1_CTRL_H (PM_RAM[0x1031])
#define PMR_TMR1_PRE_L (PM_RAM[0x1032])
#define PMR_TMR1_PRE_H (PM_RAM[0x1033])
#define PMR_TMR1_PVT_L (PM_RAM[0x1034])
#define PMR_TMR1_PVT_H (PM_RAM[0x1035])
#define PMR_TMR1_CNT_L (PM_RAM[0x1036])
#define PMR_TMR1_CNT_H (PM_RAM[0x1037])
#define PMR_TMR2_CTRL_L (PM_RAM[0x1038])
#define PMR_TMR2_CTRL_H (PM_RAM[0x1039])
#define PMR_TMR2_PRE_L (PM_RAM[0x103A])
#define PMR_TMR2_PRE_H (PM_RAM[0x103B])
#define PMR_TMR2_PVT_L (PM_RAM[0x103C])
#define PMR_TMR2_PVT_H (PM_RAM[0x103D])
#define PMR_TMR2_CNT_L (PM_RAM[0x103E])
#define PMR_TMR2_CNT_H (PM_RAM[0x103F])
#define PMR_TMR256_CTRL (PM_RAM[0x1040])
#define PMR_TMR256_CNT (PM_RAM[0x1041])
#define PMR_REG_44 (PM_RAM[0x1044])
#define PMR_REG_45 (PM_RAM[0x1045])
#define PMR_REG_46 (PM_RAM[0x1046])
#define PMR_REG_47 (PM_RAM[0x1047])
#define PMR_TMR3_CTRL_L (PM_RAM[0x1048])
#define PMR_TMR3_CTRL_H (PM_RAM[0x1049])
#define PMR_TMR3_PRE_L (PM_RAM[0x104A])
#define PMR_TMR3_PRE_H (PM_RAM[0x104B])
#define PMR_TMR3_PVT_L (PM_RAM[0x104C])
#define PMR_TMR3_PVT_H (PM_RAM[0x104D])
#define PMR_TMR3_CNT_L (PM_RAM[0x104E])
#define PMR_TMR3_CNT_H (PM_RAM[0x104F])
#define PMR_REG_50 (PM_RAM[0x1050])
#define PMR_REG_51 (PM_RAM[0x1051])
#define PMR_KEY_PAD (PM_RAM[0x1052])
#define PMR_REG_53 (PM_RAM[0x1053])
#define PMR_REG_54 (PM_RAM[0x1054])
#define PMR_REG_55 (PM_RAM[0x1055])
#define PMR_IO_DIR (PM_RAM[0x1060])
#define PMR_IO_DATA (PM_RAM[0x1061])
#define PMR_REG_62 (PM_RAM[0x1062])
#define PMR_AUD_CTRL (PM_RAM[0x1070])
#define PMR_AUD_VOL (PM_RAM[0x1071])
#define PMR_PRC_MODE (PM_RAM[0x1080])
#define PMR_PRC_RATE (PM_RAM[0x1081])
#define PMR_PRC_MAP_LO (PM_RAM[0x1082])
#define PMR_PRC_MAP_MID (PM_RAM[0x1083])
#define PMR_PRC_MAP_HI (PM_RAM[0x1084])
#define PMR_PRC_SCROLL_Y (PM_RAM[0x1085])
#define PMR_PRC_SCROLL_X (PM_RAM[0x1086])
#define PMR_PRC_SPR_LO (PM_RAM[0x1087])
#define PMR_PRC_SPR_MID (PM_RAM[0x1088])
#define PMR_PRC_SPR_HI (PM_RAM[0x1089])
#define PMR_PRC_CNT (PM_RAM[0x108A])
#define PMR_LCD_CTRL (PM_RAM[0x10FE])
#define PMR_LCD_DATA (PM_RAM[0x10FF])
#endif
+15 -15
View File
@@ -1,15 +1,15 @@
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2014 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2014 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
+472 -472
View File
@@ -1,472 +1,472 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <retro_inline.h>
#include "PokeMini.h"
TMinxAudio MinxAudio;
int AudioEnabled = 0;
int SoundEngine = MINX_AUDIO_DISABLED;
int PiezoFilter = 0;
int RequireSoundSync = 0;
int16_t *MinxAudio_FIFO = NULL;
volatile int MinxAudio_ReadPtr = 0;
volatile int MinxAudio_WritePtr = 0;
int MinxAudio_FIFOSize = 0;
int MinxAudio_FIFOMask = 0;
int MinxAudio_FIFOThreshold = 0;
int16_t (*MinxAudio_AudioProcess)(void) = NULL;
// Timers counting frequency table
const uint32_t MinxAudio_CountFreq[32] = {
// Osci1 disabled
1, 0, 0, 0, 0, 0, 0, 0,
// Osci1 Enabled
(4000000/2), (4000000/8), (4000000/32), (4000000/64),
(4000000/128), (4000000/256), (4000000/1024), (4000000/4096),
// Osci2 disabled
0, 0, 0, 0, 0, 0, 0, 0,
// Osci2 Enabled
(32768/1), (32768/2), (32768/4), (32768/8),
(32768/16), (32768/32), (32768/64), (32768/128)
};
//
// FIFO I/O
//
static INLINE int MinxAudio_iSamplesInBuffer(void)
{
if (MinxAudio_WritePtr > MinxAudio_ReadPtr)
return MinxAudio_WritePtr - MinxAudio_ReadPtr;
return (MinxAudio_FIFOSize - MinxAudio_ReadPtr) + MinxAudio_WritePtr;
}
static INLINE void MinxAudio_FIFOWrite(int16_t data)
{
if (MinxAudio_iSamplesInBuffer() < MinxAudio_FIFOSize) {
MinxAudio_FIFO[MinxAudio_WritePtr] = data;
MinxAudio_WritePtr = (MinxAudio_WritePtr + 1) & MinxAudio_FIFOMask;
}
}
static INLINE int16_t MinxAudio_FIFORead(void)
{
if (MinxAudio_iSamplesInBuffer() > 0)
{
int16_t data = MinxAudio_FIFO[MinxAudio_ReadPtr];
MinxAudio_ReadPtr = (MinxAudio_ReadPtr + 1) & MinxAudio_FIFOMask;
return data;
}
return 0;
}
//
// Functions
//
int MinxAudio_Create(int audioenable, int fifosize)
{
// Init variables
AudioEnabled = audioenable;
SoundEngine = MINX_AUDIO_DISABLED;
RequireSoundSync = 0;
// Reset
MinxAudio_Reset(1);
// Init FIFO if audio enabled
MinxAudio_ReadPtr = 0;
MinxAudio_WritePtr = 0;
if (fifosize)
{
MinxAudio_FIFOMask = GetMultiple2Mask(fifosize);
MinxAudio_FIFOSize = MinxAudio_FIFOMask + 1;
MinxAudio_FIFOThreshold = (fifosize * 3) >> 2; // ... at 3 / 4
}
else
{
MinxAudio_FIFOMask = 0;
MinxAudio_FIFOSize = 0;
MinxAudio_FIFOThreshold = 0;
}
if ((audioenable) && (fifosize))
{
MinxAudio_FIFO = (int16_t *)malloc(MinxAudio_FIFOSize*2);
if (!MinxAudio_FIFO) return 0;
memset(MinxAudio_FIFO, 0, MinxAudio_FIFOSize*2);
}
return 1;
}
void MinxAudio_Destroy(void)
{
if (MinxAudio_FIFO) {
free(MinxAudio_FIFO);
MinxAudio_FIFO = NULL;
}
}
void MinxAudio_Reset(int hardreset)
{
// Initialize State
memset((void *)&MinxAudio, 0, sizeof(TMinxAudio));
}
int MinxAudio_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(32);
POKELOADSS_STREAM_32(MinxAudio.AudioCCnt);
POKELOADSS_STREAM_32(MinxAudio.AudioSCnt);
POKELOADSS_STREAM_16(MinxAudio.Volume);
POKELOADSS_STREAM_16(MinxAudio.PWMMul);
POKELOADSS_STREAM_X(20);
POKELOADSS_END(32);
}
int MinxAudio_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(32);
POKESAVESS_STREAM_32(MinxAudio.AudioCCnt);
POKESAVESS_STREAM_32(MinxAudio.AudioSCnt);
POKESAVESS_STREAM_16(MinxAudio.Volume);
POKESAVESS_STREAM_16(MinxAudio.PWMMul);
POKESAVESS_STREAM_X(20);
POKESAVESS_END(32);
}
static int16_t MinxAudio_AudioProcessDirectPWM(void)
{
uint32_t Pwm = 0;
uint16_t TmrCnt = (MinxTimers.Tmr3CntA >> 24) | ((MinxTimers.Tmr3CntB >> 24) << 8);
uint16_t TmrPre = (MinxTimers.Tmr3PreA >> 24) | ((MinxTimers.Tmr3PreB >> 24) << 8);
// Affect sound based of PWM
if (TmrPre)
Pwm = MinxTimers.Timer3Piv * MINX_AUDIO_PWM_RAG / TmrPre;
if (Pwm > MINX_AUDIO_PWM_RAG)
Pwm = MINX_AUDIO_PWM_RAG-1; // Avoid clipping
if (TmrPre < 128)
TmrCnt = 0; // Avoid high hizz
// Output
if (TmrCnt <= MinxTimers.Timer3Piv)
return MinxAudio.Volume + Pwm * MinxAudio.PWMMul;
return MINX_AUDIO_SILENCE + Pwm * MinxAudio.PWMMul;
}
void MinxAudio_ChangeEngine(int engine)
{
if (PokeMini_Flags & POKEMINI_GENSOUND)
engine = engine ? 1 : 0;
SoundEngine = engine;
switch (engine) {
case MINX_AUDIO_DIRECTPWM:
RequireSoundSync = 1;
MinxAudio_AudioProcess = MinxAudio_AudioProcessDirectPWM;
break;
case MINX_AUDIO_GENERATED:
default:
RequireSoundSync = 0;
MinxAudio_AudioProcess = NULL;
break;
}
}
void MinxAudio_ChangeFilter(int piezo)
{
PiezoFilter = piezo;
}
void MinxAudio_Sync(void)
{
// Process single audio sample
MinxAudio.AudioCCnt += MINX_AUDIOINC * PokeHWCycles;
if (MinxAudio.AudioCCnt >= 0x01000000)
{
MinxAudio.AudioCCnt -= 0x01000000;
if (MinxAudio_AudioProcess)
{
if (PiezoFilter)
MinxAudio_FIFOWrite(MinxAudio_PiezoFilter(MinxAudio_AudioProcess()));
else
MinxAudio_FIFOWrite(MinxAudio_AudioProcess());
}
}
}
uint8_t MinxAudio_ReadReg(uint8_t reg)
{
// 0x70 to 0x71
switch(reg)
{
case 0x70: // Unknown Audio Control
return PMR_AUD_CTRL & 0x07;
case 0x71: // Audio Volume Control
return PMR_AUD_VOL & 0x07;
default:
break;
}
return 0;
}
void MinxAudio_WriteReg(uint8_t reg, uint8_t val)
{
/* 0x70 to 0x71 */
switch(reg)
{
case 0x70: /* Unknown Audio Control */
PMR_AUD_CTRL = val & 0x07;
break;
case 0x71: /* Audio Volume Control */
PMR_AUD_VOL = val & 0x07;
break;
}
// Calculate volume
if (PMR_AUD_CTRL & 0x03) {
// Mute audio
MinxAudio.Volume = 0;
} else {
switch (PMR_AUD_VOL & 3) {
case 0:
// 0% Sound
MinxAudio.Volume = MINX_AUDIO_SILENCE;
MinxAudio.PWMMul = 0;
break;
case 1:
case 2:
// 50% Sound
MinxAudio.Volume = MINX_AUDIO_MED_VOL;
MinxAudio.PWMMul = 1;
break;
case 3:
// 100% Sound
MinxAudio.Volume = MINX_AUDIO_MAX_VOL;
MinxAudio.PWMMul = 2;
break;
}
}
}
// Get emulated frequency and pulsewidth
// Sound_Frequency is in Hz
// Pulse_Width is between 0 to 4095 (0% to ~99.99%)
static void MinxAudio_GetEmulated(int *Sound_Frequency, int *Pulse_Width)
{
int Preset_Value, Sound_Pivot;
// Calculate timer 3 frequency
int Timer3_Frequency = MinxAudio_CountFreq[(PMR_TMR3_SCALE & 0xF) | ((PMR_TMR3_OSC & 0x01) << 4)];
if (!(PMR_TMR3_CTRL_L & 0x04))
Timer3_Frequency = 0;
if (PMR_TMR3_OSC & 0x01)
{
// Osci2
if (!MinxTimers.TmrXEna2)
Timer3_Frequency = 0;
}
else
{
// Osci1
if (!MinxTimers.TmrXEna1)
Timer3_Frequency = 0;
}
if (Timer3_Frequency)
{
// Calculate preset value
Preset_Value = (MinxTimers.Tmr3PreA >> 24) + ((MinxTimers.Tmr3PreB >> 24) << 8);
// Calculate sound frequency
*Sound_Frequency = Timer3_Frequency / (Preset_Value + 1);
// ... and pulse width
if (Preset_Value)
{
Sound_Pivot = (int)MinxTimers.Timer3Piv;
*Pulse_Width = 4095 - (Sound_Pivot * 4096 / Preset_Value);
if (*Pulse_Width < 0)
*Pulse_Width = 0;
} else *Pulse_Width = 0;
}
else
{
*Sound_Frequency = 0;
*Pulse_Width = 0;
}
}
int16_t MinxAudio_PiezoFilter(int32_t Sample)
{
int32_t HP_pCoeff = 40960;
int32_t LP_pCoeff = 4096;
int32_t LP_nCoeff = (65535 - LP_pCoeff);
static int32_t HPSamples[4], LPSamples[4];
int32_t TmpSamples[4];
// High pass to simulate a piezo crystal speaker
TmpSamples[0] = Sample;
TmpSamples[1] = (HP_pCoeff * (TmpSamples[0] + HPSamples[1] - HPSamples[0])) >> 16;
TmpSamples[2] = (HP_pCoeff * (TmpSamples[1] + HPSamples[2] - HPSamples[1])) >> 16;
TmpSamples[3] = (HP_pCoeff * (TmpSamples[2] + HPSamples[3] - HPSamples[2])) >> 16;
memcpy(HPSamples, TmpSamples, sizeof(HPSamples));
// Amplify by 4
Sample = TmpSamples[3] << 2;
if (Sample < -32768)
Sample = -32768;
else if (Sample > 32767)
Sample = 32767;
// Low pass to kill the spikes in sound
LPSamples[0] = Sample;
LPSamples[1] = (LPSamples[1] * LP_pCoeff + LPSamples[0] * LP_nCoeff) >> 16;
LPSamples[2] = (LPSamples[2] * LP_pCoeff + LPSamples[1] * LP_nCoeff) >> 16;
LPSamples[3] = (LPSamples[3] * LP_pCoeff + LPSamples[2] * LP_nCoeff) >> 16;
// Amplify by 2, clamp and output
Sample = LPSamples[3] << 1;
if (Sample < -32768)
return -32768;
if (Sample > 32767)
return 32767;
return Sample;
}
// This doesn't require audio to be created:
static void MinxAudio_GenerateEmulatedS16(
int16_t *soundout, int numsamples, int channels)
{
int i, j, Sound_Frequency, Pulse_Width;
if (numsamples <= 0)
return;
MinxAudio_GetEmulated(&Sound_Frequency, &Pulse_Width);
if (channels == 1)
{
for (i=0; i<numsamples; i++)
{
if ((Sound_Frequency >= 50) && (Sound_Frequency < 20000))
{
MinxAudio.AudioSCnt += Sound_Frequency * MINX_AUDIOCONV;
if ((MinxAudio.AudioSCnt & 0xFFF00000) >= (Pulse_Width << 20))
*soundout++ = PiezoFilter ? MinxAudio_PiezoFilter(MinxAudio.Volume) : MinxAudio.Volume;
else
*soundout++ = PiezoFilter ? MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE) : 0;
}
else
*soundout++ = PiezoFilter ? MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE) : 0;
}
}
else
{
for (i=0; i<numsamples; i++)
{
if ((Sound_Frequency >= 50) && (Sound_Frequency < 20000))
{
MinxAudio.AudioSCnt += Sound_Frequency * MINX_AUDIOCONV;
if ((MinxAudio.AudioSCnt & 0xFFF00000) >= (Pulse_Width << 20))
{
if (PiezoFilter)
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio_PiezoFilter(MinxAudio.Volume);
}
else
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio.Volume;
}
}
else
{
if (PiezoFilter)
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE);
}
else
{
for (j=0; j<channels; j++) *soundout++ = 0;
}
}
}
else
{
if (PiezoFilter)
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE);
}
else
{
for (j=0; j<channels; j++) *soundout++ = 0;
}
}
}
}
}
void MinxAudio_GetSamplesS16Ch(int16_t *soundout,
int numsamples, int channels)
{
int j;
if (SoundEngine == MINX_AUDIO_GENERATED)
{
MinxAudio_GenerateEmulatedS16(soundout, numsamples, channels);
return;
}
if (channels == 1)
{
if (AudioEnabled && SoundEngine)
{
while (numsamples--)
*soundout++ = MinxAudio_FIFORead();
}
else
{
while (numsamples--)
*soundout++ = 0x0000;
}
}
else
{
if (AudioEnabled && SoundEngine)
{
while (numsamples--)
{
int16_t sample = MinxAudio_FIFORead();
for (j=0; j<channels; j++)
*soundout++ = sample;
}
}
else
{
while (numsamples--)
for (j=0; j<channels; j++)
*soundout++ = 0x0000;
}
}
}
/* PokeMiniEmu: the sound for the Paradise's buzzer: frequency in Hz (0 = silent) and loudness 0..3 */
void pm_audio_now(int *hz, int *vol)
{
int f = 0, pw = 0;
MinxAudio_GetEmulated(&f, &pw);
*vol = (PMR_AUD_CTRL & 0x03) ? 0 : (PMR_AUD_VOL & 3);
*hz = (pw <= 0 || pw >= 4095) ? 0 : f;
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <retro_inline.h>
#include "PokeMini.h"
TMinxAudio MinxAudio;
int AudioEnabled = 0;
int SoundEngine = MINX_AUDIO_DISABLED;
int PiezoFilter = 0;
int RequireSoundSync = 0;
int16_t *MinxAudio_FIFO = NULL;
volatile int MinxAudio_ReadPtr = 0;
volatile int MinxAudio_WritePtr = 0;
int MinxAudio_FIFOSize = 0;
int MinxAudio_FIFOMask = 0;
int MinxAudio_FIFOThreshold = 0;
int16_t (*MinxAudio_AudioProcess)(void) = NULL;
// Timers counting frequency table
const uint32_t MinxAudio_CountFreq[32] = {
// Osci1 disabled
1, 0, 0, 0, 0, 0, 0, 0,
// Osci1 Enabled
(4000000/2), (4000000/8), (4000000/32), (4000000/64),
(4000000/128), (4000000/256), (4000000/1024), (4000000/4096),
// Osci2 disabled
0, 0, 0, 0, 0, 0, 0, 0,
// Osci2 Enabled
(32768/1), (32768/2), (32768/4), (32768/8),
(32768/16), (32768/32), (32768/64), (32768/128)
};
//
// FIFO I/O
//
static INLINE int MinxAudio_iSamplesInBuffer(void)
{
if (MinxAudio_WritePtr > MinxAudio_ReadPtr)
return MinxAudio_WritePtr - MinxAudio_ReadPtr;
return (MinxAudio_FIFOSize - MinxAudio_ReadPtr) + MinxAudio_WritePtr;
}
static INLINE void MinxAudio_FIFOWrite(int16_t data)
{
if (MinxAudio_iSamplesInBuffer() < MinxAudio_FIFOSize) {
MinxAudio_FIFO[MinxAudio_WritePtr] = data;
MinxAudio_WritePtr = (MinxAudio_WritePtr + 1) & MinxAudio_FIFOMask;
}
}
static INLINE int16_t MinxAudio_FIFORead(void)
{
if (MinxAudio_iSamplesInBuffer() > 0)
{
int16_t data = MinxAudio_FIFO[MinxAudio_ReadPtr];
MinxAudio_ReadPtr = (MinxAudio_ReadPtr + 1) & MinxAudio_FIFOMask;
return data;
}
return 0;
}
//
// Functions
//
int MinxAudio_Create(int audioenable, int fifosize)
{
// Init variables
AudioEnabled = audioenable;
SoundEngine = MINX_AUDIO_DISABLED;
RequireSoundSync = 0;
// Reset
MinxAudio_Reset(1);
// Init FIFO if audio enabled
MinxAudio_ReadPtr = 0;
MinxAudio_WritePtr = 0;
if (fifosize)
{
MinxAudio_FIFOMask = GetMultiple2Mask(fifosize);
MinxAudio_FIFOSize = MinxAudio_FIFOMask + 1;
MinxAudio_FIFOThreshold = (fifosize * 3) >> 2; // ... at 3 / 4
}
else
{
MinxAudio_FIFOMask = 0;
MinxAudio_FIFOSize = 0;
MinxAudio_FIFOThreshold = 0;
}
if ((audioenable) && (fifosize))
{
MinxAudio_FIFO = (int16_t *)malloc(MinxAudio_FIFOSize*2);
if (!MinxAudio_FIFO) return 0;
memset(MinxAudio_FIFO, 0, MinxAudio_FIFOSize*2);
}
return 1;
}
void MinxAudio_Destroy(void)
{
if (MinxAudio_FIFO) {
free(MinxAudio_FIFO);
MinxAudio_FIFO = NULL;
}
}
void MinxAudio_Reset(int hardreset)
{
// Initialize State
memset((void *)&MinxAudio, 0, sizeof(TMinxAudio));
}
int MinxAudio_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(32);
POKELOADSS_STREAM_32(MinxAudio.AudioCCnt);
POKELOADSS_STREAM_32(MinxAudio.AudioSCnt);
POKELOADSS_STREAM_16(MinxAudio.Volume);
POKELOADSS_STREAM_16(MinxAudio.PWMMul);
POKELOADSS_STREAM_X(20);
POKELOADSS_END(32);
}
int MinxAudio_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(32);
POKESAVESS_STREAM_32(MinxAudio.AudioCCnt);
POKESAVESS_STREAM_32(MinxAudio.AudioSCnt);
POKESAVESS_STREAM_16(MinxAudio.Volume);
POKESAVESS_STREAM_16(MinxAudio.PWMMul);
POKESAVESS_STREAM_X(20);
POKESAVESS_END(32);
}
static int16_t MinxAudio_AudioProcessDirectPWM(void)
{
uint32_t Pwm = 0;
uint16_t TmrCnt = (MinxTimers.Tmr3CntA >> 24) | ((MinxTimers.Tmr3CntB >> 24) << 8);
uint16_t TmrPre = (MinxTimers.Tmr3PreA >> 24) | ((MinxTimers.Tmr3PreB >> 24) << 8);
// Affect sound based of PWM
if (TmrPre)
Pwm = MinxTimers.Timer3Piv * MINX_AUDIO_PWM_RAG / TmrPre;
if (Pwm > MINX_AUDIO_PWM_RAG)
Pwm = MINX_AUDIO_PWM_RAG-1; // Avoid clipping
if (TmrPre < 128)
TmrCnt = 0; // Avoid high hizz
// Output
if (TmrCnt <= MinxTimers.Timer3Piv)
return MinxAudio.Volume + Pwm * MinxAudio.PWMMul;
return MINX_AUDIO_SILENCE + Pwm * MinxAudio.PWMMul;
}
void MinxAudio_ChangeEngine(int engine)
{
if (PokeMini_Flags & POKEMINI_GENSOUND)
engine = engine ? 1 : 0;
SoundEngine = engine;
switch (engine) {
case MINX_AUDIO_DIRECTPWM:
RequireSoundSync = 1;
MinxAudio_AudioProcess = MinxAudio_AudioProcessDirectPWM;
break;
case MINX_AUDIO_GENERATED:
default:
RequireSoundSync = 0;
MinxAudio_AudioProcess = NULL;
break;
}
}
void MinxAudio_ChangeFilter(int piezo)
{
PiezoFilter = piezo;
}
void MinxAudio_Sync(void)
{
// Process single audio sample
MinxAudio.AudioCCnt += MINX_AUDIOINC * PokeHWCycles;
if (MinxAudio.AudioCCnt >= 0x01000000)
{
MinxAudio.AudioCCnt -= 0x01000000;
if (MinxAudio_AudioProcess)
{
if (PiezoFilter)
MinxAudio_FIFOWrite(MinxAudio_PiezoFilter(MinxAudio_AudioProcess()));
else
MinxAudio_FIFOWrite(MinxAudio_AudioProcess());
}
}
}
uint8_t MinxAudio_ReadReg(uint8_t reg)
{
// 0x70 to 0x71
switch(reg)
{
case 0x70: // Unknown Audio Control
return PMR_AUD_CTRL & 0x07;
case 0x71: // Audio Volume Control
return PMR_AUD_VOL & 0x07;
default:
break;
}
return 0;
}
void MinxAudio_WriteReg(uint8_t reg, uint8_t val)
{
/* 0x70 to 0x71 */
switch(reg)
{
case 0x70: /* Unknown Audio Control */
PMR_AUD_CTRL = val & 0x07;
break;
case 0x71: /* Audio Volume Control */
PMR_AUD_VOL = val & 0x07;
break;
}
// Calculate volume
if (PMR_AUD_CTRL & 0x03) {
// Mute audio
MinxAudio.Volume = 0;
} else {
switch (PMR_AUD_VOL & 3) {
case 0:
// 0% Sound
MinxAudio.Volume = MINX_AUDIO_SILENCE;
MinxAudio.PWMMul = 0;
break;
case 1:
case 2:
// 50% Sound
MinxAudio.Volume = MINX_AUDIO_MED_VOL;
MinxAudio.PWMMul = 1;
break;
case 3:
// 100% Sound
MinxAudio.Volume = MINX_AUDIO_MAX_VOL;
MinxAudio.PWMMul = 2;
break;
}
}
}
// Get emulated frequency and pulsewidth
// Sound_Frequency is in Hz
// Pulse_Width is between 0 to 4095 (0% to ~99.99%)
static void MinxAudio_GetEmulated(int *Sound_Frequency, int *Pulse_Width)
{
int Preset_Value, Sound_Pivot;
// Calculate timer 3 frequency
int Timer3_Frequency = MinxAudio_CountFreq[(PMR_TMR3_SCALE & 0xF) | ((PMR_TMR3_OSC & 0x01) << 4)];
if (!(PMR_TMR3_CTRL_L & 0x04))
Timer3_Frequency = 0;
if (PMR_TMR3_OSC & 0x01)
{
// Osci2
if (!MinxTimers.TmrXEna2)
Timer3_Frequency = 0;
}
else
{
// Osci1
if (!MinxTimers.TmrXEna1)
Timer3_Frequency = 0;
}
if (Timer3_Frequency)
{
// Calculate preset value
Preset_Value = (MinxTimers.Tmr3PreA >> 24) + ((MinxTimers.Tmr3PreB >> 24) << 8);
// Calculate sound frequency
*Sound_Frequency = Timer3_Frequency / (Preset_Value + 1);
// ... and pulse width
if (Preset_Value)
{
Sound_Pivot = (int)MinxTimers.Timer3Piv;
*Pulse_Width = 4095 - (Sound_Pivot * 4096 / Preset_Value);
if (*Pulse_Width < 0)
*Pulse_Width = 0;
} else *Pulse_Width = 0;
}
else
{
*Sound_Frequency = 0;
*Pulse_Width = 0;
}
}
int16_t MinxAudio_PiezoFilter(int32_t Sample)
{
int32_t HP_pCoeff = 40960;
int32_t LP_pCoeff = 4096;
int32_t LP_nCoeff = (65535 - LP_pCoeff);
static int32_t HPSamples[4], LPSamples[4];
int32_t TmpSamples[4];
// High pass to simulate a piezo crystal speaker
TmpSamples[0] = Sample;
TmpSamples[1] = (HP_pCoeff * (TmpSamples[0] + HPSamples[1] - HPSamples[0])) >> 16;
TmpSamples[2] = (HP_pCoeff * (TmpSamples[1] + HPSamples[2] - HPSamples[1])) >> 16;
TmpSamples[3] = (HP_pCoeff * (TmpSamples[2] + HPSamples[3] - HPSamples[2])) >> 16;
memcpy(HPSamples, TmpSamples, sizeof(HPSamples));
// Amplify by 4
Sample = TmpSamples[3] << 2;
if (Sample < -32768)
Sample = -32768;
else if (Sample > 32767)
Sample = 32767;
// Low pass to kill the spikes in sound
LPSamples[0] = Sample;
LPSamples[1] = (LPSamples[1] * LP_pCoeff + LPSamples[0] * LP_nCoeff) >> 16;
LPSamples[2] = (LPSamples[2] * LP_pCoeff + LPSamples[1] * LP_nCoeff) >> 16;
LPSamples[3] = (LPSamples[3] * LP_pCoeff + LPSamples[2] * LP_nCoeff) >> 16;
// Amplify by 2, clamp and output
Sample = LPSamples[3] << 1;
if (Sample < -32768)
return -32768;
if (Sample > 32767)
return 32767;
return Sample;
}
// This doesn't require audio to be created:
static void MinxAudio_GenerateEmulatedS16(
int16_t *soundout, int numsamples, int channels)
{
int i, j, Sound_Frequency, Pulse_Width;
if (numsamples <= 0)
return;
MinxAudio_GetEmulated(&Sound_Frequency, &Pulse_Width);
if (channels == 1)
{
for (i=0; i<numsamples; i++)
{
if ((Sound_Frequency >= 50) && (Sound_Frequency < 20000))
{
MinxAudio.AudioSCnt += Sound_Frequency * MINX_AUDIOCONV;
if ((MinxAudio.AudioSCnt & 0xFFF00000) >= (Pulse_Width << 20))
*soundout++ = PiezoFilter ? MinxAudio_PiezoFilter(MinxAudio.Volume) : MinxAudio.Volume;
else
*soundout++ = PiezoFilter ? MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE) : 0;
}
else
*soundout++ = PiezoFilter ? MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE) : 0;
}
}
else
{
for (i=0; i<numsamples; i++)
{
if ((Sound_Frequency >= 50) && (Sound_Frequency < 20000))
{
MinxAudio.AudioSCnt += Sound_Frequency * MINX_AUDIOCONV;
if ((MinxAudio.AudioSCnt & 0xFFF00000) >= (Pulse_Width << 20))
{
if (PiezoFilter)
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio_PiezoFilter(MinxAudio.Volume);
}
else
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio.Volume;
}
}
else
{
if (PiezoFilter)
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE);
}
else
{
for (j=0; j<channels; j++) *soundout++ = 0;
}
}
}
else
{
if (PiezoFilter)
{
for (j=0; j<channels; j++) *soundout++ = MinxAudio_PiezoFilter(MINX_AUDIO_SILENCE);
}
else
{
for (j=0; j<channels; j++) *soundout++ = 0;
}
}
}
}
}
void MinxAudio_GetSamplesS16Ch(int16_t *soundout,
int numsamples, int channels)
{
int j;
if (SoundEngine == MINX_AUDIO_GENERATED)
{
MinxAudio_GenerateEmulatedS16(soundout, numsamples, channels);
return;
}
if (channels == 1)
{
if (AudioEnabled && SoundEngine)
{
while (numsamples--)
*soundout++ = MinxAudio_FIFORead();
}
else
{
while (numsamples--)
*soundout++ = 0x0000;
}
}
else
{
if (AudioEnabled && SoundEngine)
{
while (numsamples--)
{
int16_t sample = MinxAudio_FIFORead();
for (j=0; j<channels; j++)
*soundout++ = sample;
}
}
else
{
while (numsamples--)
for (j=0; j<channels; j++)
*soundout++ = 0x0000;
}
}
}
/* PokeMiniEmu: the sound for the Paradise's buzzer: frequency in Hz (0 = silent) and loudness 0..3 */
void pm_audio_now(int *hz, int *vol)
{
int f = 0, pw = 0;
MinxAudio_GetEmulated(&f, &pw);
*vol = (PMR_AUD_CTRL & 0x03) ? 0 : (PMR_AUD_VOL & 3);
*hz = (pw <= 0 || pw >= 4095) ? 0 : f;
}
+100 -100
View File
@@ -1,100 +1,100 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_AUDIO
#define MINXHW_AUDIO
#include "MinxTimers.h"
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
int32_t AudioCCnt; // Audio cycle counter 8.24 (Needs signed)
uint32_t AudioSCnt; // Audio sample counter 8.24 (Needs unsigned)
int16_t Volume; // Volume (S16 sample)
int16_t PWMMul; // PWM Multiplication
} TMinxAudio;
// Export Audio state
extern TMinxAudio MinxAudio;
// Audio enabled
extern int AudioEnabled;
// Sound engine
extern int SoundEngine;
// Piezo Filter
extern int PiezoFilter;
// Require sound sync
extern int RequireSoundSync;
enum {
MINX_AUDIO_DISABLED = 0, // Disabled
MINX_AUDIO_GENERATED, // Generated (Doesn't require sync)
MINX_AUDIO_DIRECTPWM // Direct from Timer 3 with PWM support
};
enum {
MINX_AUDIO_SILENCE = 0x0000,
MINX_AUDIO_MED_VOL = 0x2000,
MINX_AUDIO_MAX_VOL = 0x4000,
MINX_AUDIO_PWM_RAG = 0x1FFF // Max + Pwm*2 must not be over 0x7FFF
};
#ifndef MINX_AUDIOFREQ
#define MINX_AUDIOFREQ (44100)
#endif
// Aproximate value of 1 sample per cycle at 44100Hz (16M / ( 4M / 44K ))
#ifndef MINX_AUDIOINC
#define MINX_AUDIOINC (184969)
#endif
// Conversion for the generator counter
#define MINX_AUDIOCONV (2147483647/(MINX_AUDIOFREQ)*2)
int MinxAudio_Create(int audioenable, int fifosize);
void MinxAudio_Destroy(void);
void MinxAudio_Reset(int hardreset);
int MinxAudio_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxAudio_SaveStateStream(memstream_t *stream);
void MinxAudio_ChangeEngine(int engine);
void MinxAudio_ChangeFilter(int piezo);
void MinxAudio_Sync(void);
uint8_t MinxAudio_ReadReg(uint8_t reg);
void MinxAudio_WriteReg(uint8_t reg, uint8_t val);
int16_t MinxAudio_PiezoFilter(int32_t Sample);
void MinxAudio_GetSamplesS16Ch(int16_t *soundout, int numsamples, int channels);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_AUDIO
#define MINXHW_AUDIO
#include "MinxTimers.h"
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
int32_t AudioCCnt; // Audio cycle counter 8.24 (Needs signed)
uint32_t AudioSCnt; // Audio sample counter 8.24 (Needs unsigned)
int16_t Volume; // Volume (S16 sample)
int16_t PWMMul; // PWM Multiplication
} TMinxAudio;
// Export Audio state
extern TMinxAudio MinxAudio;
// Audio enabled
extern int AudioEnabled;
// Sound engine
extern int SoundEngine;
// Piezo Filter
extern int PiezoFilter;
// Require sound sync
extern int RequireSoundSync;
enum {
MINX_AUDIO_DISABLED = 0, // Disabled
MINX_AUDIO_GENERATED, // Generated (Doesn't require sync)
MINX_AUDIO_DIRECTPWM // Direct from Timer 3 with PWM support
};
enum {
MINX_AUDIO_SILENCE = 0x0000,
MINX_AUDIO_MED_VOL = 0x2000,
MINX_AUDIO_MAX_VOL = 0x4000,
MINX_AUDIO_PWM_RAG = 0x1FFF // Max + Pwm*2 must not be over 0x7FFF
};
#ifndef MINX_AUDIOFREQ
#define MINX_AUDIOFREQ (44100)
#endif
// Aproximate value of 1 sample per cycle at 44100Hz (16M / ( 4M / 44K ))
#ifndef MINX_AUDIOINC
#define MINX_AUDIOINC (184969)
#endif
// Conversion for the generator counter
#define MINX_AUDIOCONV (2147483647/(MINX_AUDIOFREQ)*2)
int MinxAudio_Create(int audioenable, int fifosize);
void MinxAudio_Destroy(void);
void MinxAudio_Reset(int hardreset);
int MinxAudio_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxAudio_SaveStateStream(memstream_t *stream);
void MinxAudio_ChangeEngine(int engine);
void MinxAudio_ChangeFilter(int piezo);
void MinxAudio_Sync(void);
uint8_t MinxAudio_ReadReg(uint8_t reg);
void MinxAudio_WriteReg(uint8_t reg, uint8_t val);
int16_t MinxAudio_PiezoFilter(int32_t Sample);
void MinxAudio_GetSamplesS16Ch(int16_t *soundout, int numsamples, int channels);
#endif
+113 -113
View File
@@ -1,113 +1,113 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
TMinxCPU MinxCPU;
//
// Functions
//
int MinxCPU_Create(void)
{
// Init variables
MinxCPU.BA.D = 0;
MinxCPU.HL.D = 0;
MinxCPU.X.D = 0;
MinxCPU.Y.D = 0;
MinxCPU.SP.D = 0;
MinxCPU.PC.D = 0;
MinxCPU.N.D = 0;
MinxCPU.E = 0;
MinxCPU.F = 0xC0;
Set_U(0);
MinxCPU.Status = MINX_STATUS_NORMAL;
return 1;
}
void MinxCPU_Destroy(void)
{
// Nothing...
}
// Reset core, call it after OnRead/OnWrite point to the right BIOS
void MinxCPU_Reset(int hardreset)
{
MinxCPU.Status = MINX_STATUS_NORMAL;
MinxCPU.PC.W.L = ReadMem16(hardreset ? 0 : 2);
MinxCPU.E = 0x1F;
MinxCPU.F = 0xC0;
Set_U(0);
MinxCPU_OnIRQHandle(MinxCPU.F, MinxCPU.Shift_U);
}
// Load State from stream
int MinxCPU_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(64);
POKELOADSS_STREAM_32(MinxCPU.BA.D);
POKELOADSS_STREAM_32(MinxCPU.HL.D);
POKELOADSS_STREAM_32(MinxCPU.X.D);
POKELOADSS_STREAM_32(MinxCPU.Y.D);
POKELOADSS_STREAM_32(MinxCPU.SP.D);
POKELOADSS_STREAM_32(MinxCPU.PC.D);
POKELOADSS_STREAM_32(MinxCPU.N.D);
POKELOADSS_STREAM_8(MinxCPU.U1);
POKELOADSS_STREAM_8(MinxCPU.U2);
POKELOADSS_STREAM_8(MinxCPU.F);
POKELOADSS_STREAM_8(MinxCPU.E);
POKELOADSS_STREAM_8(MinxCPU.IR);
POKELOADSS_STREAM_8(MinxCPU.Shift_U);
POKELOADSS_STREAM_8(MinxCPU.Status);
POKELOADSS_STREAM_8(MinxCPU.IRQ_Vector);
POKELOADSS_STREAM_A(MinxCPU.Reserved, 28);
POKELOADSS_END(64);
}
// Save State to stream
int MinxCPU_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(64);
POKESAVESS_STREAM_32(MinxCPU.BA.D);
POKESAVESS_STREAM_32(MinxCPU.HL.D);
POKESAVESS_STREAM_32(MinxCPU.X.D);
POKESAVESS_STREAM_32(MinxCPU.Y.D);
POKESAVESS_STREAM_32(MinxCPU.SP.D);
POKESAVESS_STREAM_32(MinxCPU.PC.D);
POKESAVESS_STREAM_32(MinxCPU.N.D);
POKESAVESS_STREAM_8(MinxCPU.U1);
POKESAVESS_STREAM_8(MinxCPU.U2);
POKESAVESS_STREAM_8(MinxCPU.F);
POKESAVESS_STREAM_8(MinxCPU.E);
POKESAVESS_STREAM_8(MinxCPU.IR);
POKESAVESS_STREAM_8(MinxCPU.Shift_U);
POKESAVESS_STREAM_8(MinxCPU.Status);
POKESAVESS_STREAM_8(MinxCPU.IRQ_Vector);
POKESAVESS_STREAM_A(MinxCPU.Reserved, 28);
POKESAVESS_END(64);
}
// Force call Interrupt by the address
int MinxCPU_CallIRQ(uint8_t addr)
{
if (MinxCPU.Status == MINX_STATUS_IRQ) return 0;
MinxCPU.Status = MINX_STATUS_IRQ;
MinxCPU.IRQ_Vector = addr;
return 1;
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
TMinxCPU MinxCPU;
//
// Functions
//
int MinxCPU_Create(void)
{
// Init variables
MinxCPU.BA.D = 0;
MinxCPU.HL.D = 0;
MinxCPU.X.D = 0;
MinxCPU.Y.D = 0;
MinxCPU.SP.D = 0;
MinxCPU.PC.D = 0;
MinxCPU.N.D = 0;
MinxCPU.E = 0;
MinxCPU.F = 0xC0;
Set_U(0);
MinxCPU.Status = MINX_STATUS_NORMAL;
return 1;
}
void MinxCPU_Destroy(void)
{
// Nothing...
}
// Reset core, call it after OnRead/OnWrite point to the right BIOS
void MinxCPU_Reset(int hardreset)
{
MinxCPU.Status = MINX_STATUS_NORMAL;
MinxCPU.PC.W.L = ReadMem16(hardreset ? 0 : 2);
MinxCPU.E = 0x1F;
MinxCPU.F = 0xC0;
Set_U(0);
MinxCPU_OnIRQHandle(MinxCPU.F, MinxCPU.Shift_U);
}
// Load State from stream
int MinxCPU_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(64);
POKELOADSS_STREAM_32(MinxCPU.BA.D);
POKELOADSS_STREAM_32(MinxCPU.HL.D);
POKELOADSS_STREAM_32(MinxCPU.X.D);
POKELOADSS_STREAM_32(MinxCPU.Y.D);
POKELOADSS_STREAM_32(MinxCPU.SP.D);
POKELOADSS_STREAM_32(MinxCPU.PC.D);
POKELOADSS_STREAM_32(MinxCPU.N.D);
POKELOADSS_STREAM_8(MinxCPU.U1);
POKELOADSS_STREAM_8(MinxCPU.U2);
POKELOADSS_STREAM_8(MinxCPU.F);
POKELOADSS_STREAM_8(MinxCPU.E);
POKELOADSS_STREAM_8(MinxCPU.IR);
POKELOADSS_STREAM_8(MinxCPU.Shift_U);
POKELOADSS_STREAM_8(MinxCPU.Status);
POKELOADSS_STREAM_8(MinxCPU.IRQ_Vector);
POKELOADSS_STREAM_A(MinxCPU.Reserved, 28);
POKELOADSS_END(64);
}
// Save State to stream
int MinxCPU_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(64);
POKESAVESS_STREAM_32(MinxCPU.BA.D);
POKESAVESS_STREAM_32(MinxCPU.HL.D);
POKESAVESS_STREAM_32(MinxCPU.X.D);
POKESAVESS_STREAM_32(MinxCPU.Y.D);
POKESAVESS_STREAM_32(MinxCPU.SP.D);
POKESAVESS_STREAM_32(MinxCPU.PC.D);
POKESAVESS_STREAM_32(MinxCPU.N.D);
POKESAVESS_STREAM_8(MinxCPU.U1);
POKESAVESS_STREAM_8(MinxCPU.U2);
POKESAVESS_STREAM_8(MinxCPU.F);
POKESAVESS_STREAM_8(MinxCPU.E);
POKESAVESS_STREAM_8(MinxCPU.IR);
POKESAVESS_STREAM_8(MinxCPU.Shift_U);
POKESAVESS_STREAM_8(MinxCPU.Status);
POKESAVESS_STREAM_8(MinxCPU.IRQ_Vector);
POKESAVESS_STREAM_A(MinxCPU.Reserved, 28);
POKESAVESS_END(64);
}
// Force call Interrupt by the address
int MinxCPU_CallIRQ(uint8_t addr)
{
if (MinxCPU.Status == MINX_STATUS_IRQ) return 0;
MinxCPU.Status = MINX_STATUS_IRQ;
MinxCPU.IRQ_Vector = addr;
return 1;
}
+695 -695
View File
File diff suppressed because it is too large. Load diff
+1127 -1127
View File
File diff suppressed because it is too large. Load diff
+779 -779
View File
File diff suppressed because it is too large. Load diff
+244 -244
View File
@@ -1,244 +1,244 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MinxCPU.h"
int MinxCPU_ExecSPCE(void)
{
// Read IR
MinxCPU.IR = Fetch8();
return 64;
}
int MinxCPU_ExecSPCF(void)
{
// Read IR
MinxCPU.IR = Fetch8();
// Process instruction
switch(MinxCPU.IR) {
case 0x00: case 0x01: case 0x02: case 0x03: // Decrement BA
MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x04: case 0x05: case 0x06: case 0x07: // Decrement BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x08: case 0x09: case 0x0A: case 0x0B: // Increment BA
MinxCPU.BA.W.L = INC16(MinxCPU.BA.W.L);
return 16;
case 0x0C: case 0x0D: case 0x0E: case 0x0F: // Increment BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = INC16(MinxCPU.BA.W.L);
return 16;
case 0x10: case 0x11: case 0x12: case 0x13: // Decrement BA
MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x14: case 0x15: case 0x16: case 0x17: // Decrement BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x18: case 0x19: case 0x1A: case 0x1B: // Increment BA (Doesn't save result!!)
INC16(MinxCPU.BA.W.L);
return 16;
case 0x1C: case 0x1D: case 0x1E: case 0x1F: // Increment BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = INC16(MinxCPU.BA.W.L);
return 16;
case 0x20: case 0x21: case 0x22: case 0x23: // Decrement HL
MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x24: case 0x25: case 0x26: case 0x27: // Decrement HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x28: case 0x29: case 0x2A: case 0x2B: // Increment HL
MinxCPU.HL.W.L = INC16(MinxCPU.HL.W.L);
return 16;
case 0x2C: case 0x2D: case 0x2E: case 0x2F: // Increment HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = INC16(MinxCPU.HL.W.L);
return 16;
case 0x30: case 0x31: case 0x32: case 0x33: // Decrement HL
MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x34: case 0x35: case 0x36: case 0x37: // Decrement HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x38: case 0x39: case 0x3A: case 0x3B: // Increment HL (Doesn't save result!!)
INC16(MinxCPU.HL.W.L);
return 16;
case 0x3C: case 0x3D: case 0x3E: case 0x3F: // Increment HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = INC16(MinxCPU.HL.W.L);
return 16;
case 0x40: case 0x41: // Decrement X
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x42: case 0x43: // Decrement Y
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x44: case 0x45: // Decrement SP
MinxCPU.SP.W.L = DEC16(MinxCPU.SP.W.L);
return 16;
case 0x46: case 0x47: // CRASH
return 16;
case 0x48: case 0x49: // Increment X
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x4A: case 0x4B: // Increment Y
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x4C: case 0x4D: // Increment SP
MinxCPU.SP.W.L = INC16(MinxCPU.SP.W.L);
return 16;
case 0x4E: case 0x4F: // CRASH
case 0x56: case 0x57: // CRASH
case 0x5E: case 0x5F: // CRASH
case 0x60: case 0x61: case 0x62: case 0x63: // CRASH
case 0x64: case 0x65: case 0x66: case 0x67:
case 0x68: case 0x69: case 0x6A: case 0x6B:
case 0x6C: case 0x6D: case 0x6E: case 0x6F:
return 16;
case 0x50: case 0x51: // Decrement X
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x52: case 0x53: // Decrement Y
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x54: case 0x55: // Decrement SP
MinxCPU.SP.W.L = DEC16(MinxCPU.SP.W.L);
return 16;
case 0x58: case 0x59: // Increment X
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x5A: case 0x5B: // Increment Y
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x5C: case 0x5D: // Increment SP
MinxCPU.SP.W.L = INC16(MinxCPU.SP.W.L);
return 16;
case 0x70: // BA = (0x4D << 8) | V
MinxCPU.BA.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x71: // HL = (0x4D << 8) | V
MinxCPU.HL.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x72: // X = (0x4D << 8) | V
MinxCPU.X.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x73: // Y = (0x4D << 8) | V
MinxCPU.Y.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x74: case 0x75: case 0x76: case 0x77: // NOTHING
return 24;
case 0x78: case 0x79: case 0x7A: case 0x7B: // CRASH
case 0x7C: case 0x7D: case 0x7E: case 0x7F:
case 0x80: case 0x81: case 0x82: case 0x83:
case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A: case 0x8B:
case 0x8C: case 0x8D: case 0x8E: case 0x8F:
case 0x90: case 0x91: case 0x92: case 0x93:
case 0x94: case 0x95: case 0x96: case 0x97:
case 0x98: case 0x99: case 0x9A: case 0x9B:
case 0x9C: case 0x9D: case 0x9E: case 0x9F:
case 0xA0: case 0xA1: case 0xA2: case 0xA3:
case 0xA4: case 0xA5: case 0xA6: case 0xA7:
case 0xA8: case 0xA9: case 0xAA: case 0xAB:
case 0xAC: case 0xAD: case 0xAE: case 0xAF:
return 24;
case 0xB0: case 0xB1: case 0xB2: case 0xB3: // NOTHING
return 12;
case 0xB4: case 0xB5: case 0xB6: case 0xB7: // CRASH
case 0xB8: case 0xB9: case 0xBA: case 0xBB:
case 0xBC: case 0xBD: case 0xBE: case 0xBF:
return 12;
case 0xC0: // BA = (0x20 << 8) | V
MinxCPU.BA.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC1: // HL = (0x20 << 8) | V
MinxCPU.HL.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC2: // X = (0x20 << 8) | V
MinxCPU.X.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC3: // Y = (0x20 << 8) | V
MinxCPU.Y.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC4: case 0xC5: case 0xC6: case 0xC7: // NOTHING
return 20;
case 0xC8: case 0xC9: case 0xCA: case 0xCB: // CRASH
case 0xCC: case 0xCD: case 0xCE: case 0xCF:
return 20;
case 0xD0: // BA = (0x20 << 8) | V
MinxCPU.BA.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD1: // HL = (0x20 << 8) | V
MinxCPU.HL.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD2: // X = (0x20 << 8) | V
MinxCPU.X.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD3: // Y = (0x00 << 8) | V ? (EH!?)
MinxCPU.Y.W.L = 0x0000 | MinxCPU.PC.B.I;
return 20;
case 0xD4: case 0xD5: case 0xD6: case 0xD7: // NOTHING
return 20;
case 0xD8: // BA = (0x20 << 8) | V
MinxCPU.BA.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD9: // HL = (0x20 << 8) | V
MinxCPU.HL.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xDA: // X = (0x20 << 8) | V
MinxCPU.X.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xDB: // Y = (0x20 << 8) | V
MinxCPU.Y.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xDC: case 0xDD: case 0xDE: case 0xDF: // NOTHING
return 20;
case 0xE0: case 0xE1: case 0xE2: case 0xE3: // CRASH
case 0xE4: case 0xE5: case 0xE6: case 0xE7:
case 0xE8: case 0xE9: case 0xEA: case 0xEB:
case 0xEC: case 0xED: case 0xEE: case 0xEF:
case 0xF0: case 0xF1: case 0xF2: case 0xF3:
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
case 0xF8: case 0xF9: case 0xFA: case 0xFB:
case 0xFC: case 0xFD: case 0xFE: case 0xFF:
return 24;
default:
break;
}
return 64;
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MinxCPU.h"
int MinxCPU_ExecSPCE(void)
{
// Read IR
MinxCPU.IR = Fetch8();
return 64;
}
int MinxCPU_ExecSPCF(void)
{
// Read IR
MinxCPU.IR = Fetch8();
// Process instruction
switch(MinxCPU.IR) {
case 0x00: case 0x01: case 0x02: case 0x03: // Decrement BA
MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x04: case 0x05: case 0x06: case 0x07: // Decrement BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x08: case 0x09: case 0x0A: case 0x0B: // Increment BA
MinxCPU.BA.W.L = INC16(MinxCPU.BA.W.L);
return 16;
case 0x0C: case 0x0D: case 0x0E: case 0x0F: // Increment BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = INC16(MinxCPU.BA.W.L);
return 16;
case 0x10: case 0x11: case 0x12: case 0x13: // Decrement BA
MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x14: case 0x15: case 0x16: case 0x17: // Decrement BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = DEC16(MinxCPU.BA.W.L);
return 16;
case 0x18: case 0x19: case 0x1A: case 0x1B: // Increment BA (Doesn't save result!!)
INC16(MinxCPU.BA.W.L);
return 16;
case 0x1C: case 0x1D: case 0x1E: case 0x1F: // Increment BA if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.BA.W.L = INC16(MinxCPU.BA.W.L);
return 16;
case 0x20: case 0x21: case 0x22: case 0x23: // Decrement HL
MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x24: case 0x25: case 0x26: case 0x27: // Decrement HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x28: case 0x29: case 0x2A: case 0x2B: // Increment HL
MinxCPU.HL.W.L = INC16(MinxCPU.HL.W.L);
return 16;
case 0x2C: case 0x2D: case 0x2E: case 0x2F: // Increment HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = INC16(MinxCPU.HL.W.L);
return 16;
case 0x30: case 0x31: case 0x32: case 0x33: // Decrement HL
MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x34: case 0x35: case 0x36: case 0x37: // Decrement HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = DEC16(MinxCPU.HL.W.L);
return 16;
case 0x38: case 0x39: case 0x3A: case 0x3B: // Increment HL (Doesn't save result!!)
INC16(MinxCPU.HL.W.L);
return 16;
case 0x3C: case 0x3D: case 0x3E: case 0x3F: // Increment HL if Carry = 0
if (!(MinxCPU.F & MINX_FLAG_CARRY)) MinxCPU.HL.W.L = INC16(MinxCPU.HL.W.L);
return 16;
case 0x40: case 0x41: // Decrement X
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x42: case 0x43: // Decrement Y
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x44: case 0x45: // Decrement SP
MinxCPU.SP.W.L = DEC16(MinxCPU.SP.W.L);
return 16;
case 0x46: case 0x47: // CRASH
return 16;
case 0x48: case 0x49: // Increment X
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x4A: case 0x4B: // Increment Y
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x4C: case 0x4D: // Increment SP
MinxCPU.SP.W.L = INC16(MinxCPU.SP.W.L);
return 16;
case 0x4E: case 0x4F: // CRASH
case 0x56: case 0x57: // CRASH
case 0x5E: case 0x5F: // CRASH
case 0x60: case 0x61: case 0x62: case 0x63: // CRASH
case 0x64: case 0x65: case 0x66: case 0x67:
case 0x68: case 0x69: case 0x6A: case 0x6B:
case 0x6C: case 0x6D: case 0x6E: case 0x6F:
return 16;
case 0x50: case 0x51: // Decrement X
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x52: case 0x53: // Decrement Y
MinxCPU.X.W.L = DEC16(MinxCPU.X.W.L);
return 16;
case 0x54: case 0x55: // Decrement SP
MinxCPU.SP.W.L = DEC16(MinxCPU.SP.W.L);
return 16;
case 0x58: case 0x59: // Increment X
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x5A: case 0x5B: // Increment Y
MinxCPU.X.W.L = INC16(MinxCPU.X.W.L);
return 16;
case 0x5C: case 0x5D: // Increment SP
MinxCPU.SP.W.L = INC16(MinxCPU.SP.W.L);
return 16;
case 0x70: // BA = (0x4D << 8) | V
MinxCPU.BA.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x71: // HL = (0x4D << 8) | V
MinxCPU.HL.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x72: // X = (0x4D << 8) | V
MinxCPU.X.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x73: // Y = (0x4D << 8) | V
MinxCPU.Y.W.L = 0x4D00 | MinxCPU.PC.B.I;
return 24;
case 0x74: case 0x75: case 0x76: case 0x77: // NOTHING
return 24;
case 0x78: case 0x79: case 0x7A: case 0x7B: // CRASH
case 0x7C: case 0x7D: case 0x7E: case 0x7F:
case 0x80: case 0x81: case 0x82: case 0x83:
case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A: case 0x8B:
case 0x8C: case 0x8D: case 0x8E: case 0x8F:
case 0x90: case 0x91: case 0x92: case 0x93:
case 0x94: case 0x95: case 0x96: case 0x97:
case 0x98: case 0x99: case 0x9A: case 0x9B:
case 0x9C: case 0x9D: case 0x9E: case 0x9F:
case 0xA0: case 0xA1: case 0xA2: case 0xA3:
case 0xA4: case 0xA5: case 0xA6: case 0xA7:
case 0xA8: case 0xA9: case 0xAA: case 0xAB:
case 0xAC: case 0xAD: case 0xAE: case 0xAF:
return 24;
case 0xB0: case 0xB1: case 0xB2: case 0xB3: // NOTHING
return 12;
case 0xB4: case 0xB5: case 0xB6: case 0xB7: // CRASH
case 0xB8: case 0xB9: case 0xBA: case 0xBB:
case 0xBC: case 0xBD: case 0xBE: case 0xBF:
return 12;
case 0xC0: // BA = (0x20 << 8) | V
MinxCPU.BA.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC1: // HL = (0x20 << 8) | V
MinxCPU.HL.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC2: // X = (0x20 << 8) | V
MinxCPU.X.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC3: // Y = (0x20 << 8) | V
MinxCPU.Y.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xC4: case 0xC5: case 0xC6: case 0xC7: // NOTHING
return 20;
case 0xC8: case 0xC9: case 0xCA: case 0xCB: // CRASH
case 0xCC: case 0xCD: case 0xCE: case 0xCF:
return 20;
case 0xD0: // BA = (0x20 << 8) | V
MinxCPU.BA.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD1: // HL = (0x20 << 8) | V
MinxCPU.HL.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD2: // X = (0x20 << 8) | V
MinxCPU.X.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD3: // Y = (0x00 << 8) | V ? (EH!?)
MinxCPU.Y.W.L = 0x0000 | MinxCPU.PC.B.I;
return 20;
case 0xD4: case 0xD5: case 0xD6: case 0xD7: // NOTHING
return 20;
case 0xD8: // BA = (0x20 << 8) | V
MinxCPU.BA.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xD9: // HL = (0x20 << 8) | V
MinxCPU.HL.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xDA: // X = (0x20 << 8) | V
MinxCPU.X.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xDB: // Y = (0x20 << 8) | V
MinxCPU.Y.W.L = 0x2000 | MinxCPU.PC.B.I;
return 20;
case 0xDC: case 0xDD: case 0xDE: case 0xDF: // NOTHING
return 20;
case 0xE0: case 0xE1: case 0xE2: case 0xE3: // CRASH
case 0xE4: case 0xE5: case 0xE6: case 0xE7:
case 0xE8: case 0xE9: case 0xEA: case 0xEB:
case 0xEC: case 0xED: case 0xEE: case 0xEF:
case 0xF0: case 0xF1: case 0xF2: case 0xF3:
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
case 0xF8: case 0xF9: case 0xFA: case 0xFB:
case 0xFC: case 0xFD: case 0xFE: case 0xFF:
return 24;
default:
break;
}
return 64;
}
+1059 -1059
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+85 -85
View File
@@ -1,85 +1,85 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_COLORPRC
#define MINXHW_COLORPRC
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
uint16_t UnlockCode;
uint8_t Unlocked;
uint8_t Access;
uint8_t Modes;
uint8_t ActivePage;
uint16_t Address;
uint8_t LNColor0;
uint8_t HNColor0;
uint8_t LNColor1;
uint8_t HNColor1;
} TMinxColorPRC;
// Export PRC state
extern TMinxColorPRC MinxColorPRC;
// For Unofficial Color Pokemon-Mini
extern int PRCColorEnable;
extern uint8_t *PRCColorPixels;
extern uint8_t *PRCColorPixelsOld;
extern uint8_t *PRCColorMap;
extern unsigned int PRCColorOffset;
extern uint8_t *PRCColorTop;
extern uint8_t PRCColorFlags;
extern const uint8_t PRCStaticColorMap[8];
//
// Functions
//
int MinxColorPRC_Create(void);
void MinxColorPRC_Destroy(void);
void MinxColorPRC_Reset(int hardreset);
int MinxColorPRC_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxColorPRC_SaveStateStream(memstream_t *stream);
uint8_t MinxColorPRC_ReadReg(int cpu, uint8_t reg);
void MinxColorPRC_WriteReg(uint8_t reg, uint8_t val);
void MinxColorPRC_WriteFramebuffer(uint16_t addr, uint8_t data);
void MinxColorPRC_WriteLCD(uint16_t addr, uint8_t data);
//
// Internals
//
void MinxColorPRC_WriteCtrl(uint8_t val);
void MinxPRC_Render_Color8(void);
void MinxPRC_Render_Color4(void);
void MinxPRC_NoRender_Color(void);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_COLORPRC
#define MINXHW_COLORPRC
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
uint16_t UnlockCode;
uint8_t Unlocked;
uint8_t Access;
uint8_t Modes;
uint8_t ActivePage;
uint16_t Address;
uint8_t LNColor0;
uint8_t HNColor0;
uint8_t LNColor1;
uint8_t HNColor1;
} TMinxColorPRC;
// Export PRC state
extern TMinxColorPRC MinxColorPRC;
// For Unofficial Color Pokemon-Mini
extern int PRCColorEnable;
extern uint8_t *PRCColorPixels;
extern uint8_t *PRCColorPixelsOld;
extern uint8_t *PRCColorMap;
extern unsigned int PRCColorOffset;
extern uint8_t *PRCColorTop;
extern uint8_t PRCColorFlags;
extern const uint8_t PRCStaticColorMap[8];
//
// Functions
//
int MinxColorPRC_Create(void);
void MinxColorPRC_Destroy(void);
void MinxColorPRC_Reset(int hardreset);
int MinxColorPRC_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxColorPRC_SaveStateStream(memstream_t *stream);
uint8_t MinxColorPRC_ReadReg(int cpu, uint8_t reg);
void MinxColorPRC_WriteReg(uint8_t reg, uint8_t val);
void MinxColorPRC_WriteFramebuffer(uint16_t addr, uint8_t data);
void MinxColorPRC_WriteLCD(uint16_t addr, uint8_t data);
//
// Internals
//
void MinxColorPRC_WriteCtrl(uint8_t val);
void MinxPRC_Render_Color8(void);
void MinxPRC_Render_Color4(void);
void MinxPRC_NoRender_Color(void);
#endif
+401 -401
View File
@@ -1,401 +1,401 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
TMinxIO MinxIO;
uint8_t *EEPROM = NULL;
int PokeMini_Rumbling = 0;
int PokeMini_RumblingLatch = 0;
int PokeMini_EEPROMWritten = 0;
int PokeMini_BatteryStatus = 0; // 0 = Full, 1 = Low
int PokeMini_ShockKey = 0;
uint8_t MinxIO_IODataRead(void);
void MinxIO_IODataWrite(void);
void MinxIO_EEPROM_WEvent(uint8_t bits);
int MinxIO_EEPROM_REvent(void);
void MinxIO_EEPROM_Write(uint8_t data);
//
// Functions
//
int MinxIO_Create(void)
{
// Create EEPROM memory & format it
EEPROM = (uint8_t *)malloc(8192);
if (!EEPROM) return 0;
MinxIO_FormatEEPROM();
// Reset
MinxIO_Reset(1);
return 1;
}
void MinxIO_Destroy(void)
{
if (EEPROM) {
free(EEPROM);
EEPROM = NULL;
}
}
void MinxIO_Reset(int hardreset)
{
// Initialize State
memset(&MinxIO, 0, sizeof(TMinxIO));
PokeMini_Rumbling = 0;
PokeMini_RumblingLatch = 0;
PokeMini_ShockKey = 0;
// Init variables
PMR_KEY_PAD = 0xFF;
MinxIO.ListenState = MINX_EEPROM_IDLE;
MinxIO.OperState = MINX_EEPROM_DEVICE;
// Restore battery status
MinxIO_BatteryLow(PokeMini_BatteryStatus);
}
int MinxIO_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(32+8192);
PokeMini_Rumbling = 0;
PokeMini_RumblingLatch = 0;
PokeMini_EEPROMWritten = 1;
POKELOADSS_STREAM_8(MinxIO.EEPLastPins);
POKELOADSS_STREAM_8(MinxIO.ListenState);
POKELOADSS_STREAM_8(MinxIO.OperState);
POKELOADSS_STREAM_8(MinxIO.EEPData);
POKELOADSS_STREAM_32(MinxIO.EEPBit);
POKELOADSS_STREAM_16(MinxIO.EEPAddress);
POKELOADSS_STREAM_X(22);
POKELOADSS_STREAM_A(EEPROM, 8192);
POKELOADSS_END(32+8192);
}
int MinxIO_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(32+8192);
POKESAVESS_STREAM_8(MinxIO.EEPLastPins);
POKESAVESS_STREAM_8(MinxIO.ListenState);
POKESAVESS_STREAM_8(MinxIO.OperState);
POKESAVESS_STREAM_8(MinxIO.EEPData);
POKESAVESS_STREAM_32(MinxIO.EEPBit);
POKESAVESS_STREAM_16(MinxIO.EEPAddress);
POKESAVESS_STREAM_X(22);
POKESAVESS_STREAM_A(EEPROM, 8192);
POKESAVESS_END(32+8192);
}
int MinxIO_FormatEEPROM(void)
{
if (!EEPROM) return 0;
memset(EEPROM, 0xFF, 8192);
return 1;
}
void MinxIO_Keypad(uint8_t key, int pressed)
{
if (!EEPROM) return;
switch (key) {
case MINX_KEY_A: // Key A
if (pressed) {
if (!(PMR_KEY_PAD & 0x01)) return;
MinxCPU_OnIRQAct(MINX_INTR_1C);
PMR_KEY_PAD &= ~0x01;
} else PMR_KEY_PAD |= 0x01;
break;
case MINX_KEY_B: // Key B
if (pressed) {
if (!(PMR_KEY_PAD & 0x02)) return;
MinxCPU_OnIRQAct(MINX_INTR_1B);
PMR_KEY_PAD &= ~0x02;
} else PMR_KEY_PAD |= 0x02;
break;
case MINX_KEY_C: // Key C
if (pressed) {
if (!(PMR_KEY_PAD & 0x04)) return;
MinxCPU_OnIRQAct(MINX_INTR_1A);
PMR_KEY_PAD &= ~0x04;
} else PMR_KEY_PAD |= 0x04;
break;
case MINX_KEY_UP: // Dpad Up
if (pressed) {
if (!(PMR_KEY_PAD & 0x08)) return;
MinxCPU_OnIRQAct(MINX_INTR_19);
PMR_KEY_PAD &= ~0x08;
} else PMR_KEY_PAD |= 0x08;
break;
case MINX_KEY_DOWN: // Dpad Down
if (pressed) {
if (!(PMR_KEY_PAD & 0x10)) return;
MinxCPU_OnIRQAct(MINX_INTR_18);
PMR_KEY_PAD &= ~0x10;
} else PMR_KEY_PAD |= 0x10;
break;
case MINX_KEY_LEFT: // Dpad Left
if (pressed) {
if (!(PMR_KEY_PAD & 0x20)) return;
MinxCPU_OnIRQAct(MINX_INTR_17);
PMR_KEY_PAD &= ~0x20;
} else PMR_KEY_PAD |= 0x20;
break;
case MINX_KEY_RIGHT: // Dpad Right
if (pressed) {
if (!(PMR_KEY_PAD & 0x40)) return;
MinxCPU_OnIRQAct(MINX_INTR_16);
PMR_KEY_PAD &= ~0x40;
} else PMR_KEY_PAD |= 0x40;
break;
case MINX_KEY_POWER: // Power key
if (pressed) {
if (!(PMR_KEY_PAD & 0x80)) return;
MinxCPU_OnIRQAct(MINX_INTR_15);
PMR_KEY_PAD &= ~0x80;
} else PMR_KEY_PAD |= 0x80;
break;
case MINX_KEY_SHOCK: // Shock key
if (!PokeMini_ShockKey && pressed) {
MinxCPU_OnIRQAct(MINX_INTR_10);
}
PokeMini_ShockKey = pressed;
break;
}
}
void MinxIO_BatteryLow(int low)
{
PokeMini_BatteryStatus = low;
if (low) PMR_SYS_BATT |= 0x20;
else PMR_SYS_BATT &= 0x1F;
}
void MinxIO_SetTimeStamp(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec)
{
uint8_t checksum;
if (!EEPROM) return;
checksum = year + month + day + hour + min + sec;
PMR_SYS_CTRL3 |= 0x02;
EEPROM[0x1FF6] = 0x00;
EEPROM[0x1FF7] = 0x00;
EEPROM[0x1FF8] = 0x00;
EEPROM[0x1FF9] = year;
EEPROM[0x1FFA] = month;
EEPROM[0x1FFB] = day;
EEPROM[0x1FFC] = hour;
EEPROM[0x1FFD] = min;
EEPROM[0x1FFE] = sec;
EEPROM[0x1FFF] = checksum;
}
uint8_t MinxIO_ReadReg(int cpu, uint8_t reg)
{
// 0x10, 0x52, 0x60 to 0x62
switch(reg) {
case 0x10: // Low Battery
return PMR_SYS_BATT;
case 0x44: // Unknown
return PMR_REG_44;
case 0x45: // Unknown
return PMR_REG_45;
case 0x46: // Unknown
return PMR_REG_46;
case 0x47: // Unknown
return PMR_REG_47;
case 0x50: // Unknown (related to power management?)
return PMR_REG_50;
case 0x51: // Unknown (related to power management?)
return PMR_REG_51;
case 0x52: // Keypad
return PMR_KEY_PAD;
case 0x53: // Unknown
return PMR_REG_53;
case 0x54: // Unknown
return PMR_REG_54;
case 0x55: // Unknown
return PMR_REG_55;
case 0x60: // I/O Direction Select ( 0 = Input, 1 = Output )
return PMR_IO_DIR;
case 0x61: // I/O Data Register
return MinxIO_IODataRead();
case 0x62: // Unknown
return PMR_REG_62;
default: // Unused
break;
}
return 0;
}
void MinxIO_WriteReg(int cpu, uint8_t reg, uint8_t val)
{
// 0x10, 0x52, 0x60 to 0x62
switch(reg) {
case 0x10: // Low Battery
PMR_SYS_BATT = (PMR_SYS_BATT & 0x20) | (val & 0x1F);
break;
case 0x44: // Unknown
PMR_REG_44 = val & 0xF7;
break;
case 0x45: // Unknown
PMR_REG_45 = val & 0x0F;
break;
case 0x46: // Unknown
PMR_REG_46 = val;
break;
case 0x47: // Unknown
PMR_REG_47 = val & 0x0F;
break;
case 0x50: // Unknown (related to power management?)
PMR_REG_50 = val;
break;
case 0x51: // Unknown (related to power management?)
PMR_REG_51 = val & 0x03;
break;
case 0x52: // Keypad
break;
case 0x53: // Unknown
PMR_REG_53 = 0x00;
/* TODO/FIXME - is fallthrough intentional ?*/
case 0x54: // Unknown
PMR_REG_54 = val & 0x77;
/* TODO/FIXME - is fallthrough intentional ?*/
case 0x55: // Unknown
PMR_REG_55 = val & 0x07;
/* TODO/FIXME - is fallthrough intentional ?*/
case 0x60: // I/O Direction Select ( 0 = Input, 1 = Output )
PMR_IO_DIR = val;
MinxIO_IODataWrite();
break;
case 0x61: // I/O Data Register
PMR_IO_DATA = val;
MinxIO_IODataWrite();
break;
case 0x62: // Unknown
PMR_REG_62 = val & 0xF0;
break;
}
}
//
// Internal
//
uint8_t MinxIO_IODataRead(void)
{
/* Update all I/Os */
uint8_t Input = MinxIO_EEPROM_REvent() ? MINX_EEPROM_DAT : 0;
return (PMR_IO_DATA & PMR_IO_DIR) | (Input & ~PMR_IO_DIR);
}
void MinxIO_IODataWrite(void)
{
uint8_t Output = (MINX_IO_PULL_UPS & ~PMR_IO_DIR) | (PMR_IO_DATA & PMR_IO_DIR);
// Update all I/Os
PokeMini_Rumbling = Output & 0x10;
if (PokeMini_Rumbling) PokeMini_RumblingLatch = 1;
MinxIO_EEPROM_WEvent(Output);
}
void MinxIO_EEPROM_WEvent(uint8_t bits)
{
uint8_t rise = bits & ~MinxIO.EEPLastPins;
uint8_t fall = ~bits & MinxIO.EEPLastPins;
MinxIO.EEPLastPins = bits;
// "Start" Command
if ((fall & MINX_EEPROM_DAT) && (bits & MINX_EEPROM_CLK)) {
MinxIO.ListenState = MINX_EEPROM_LISTEN;
MinxIO.OperState = MINX_EEPROM_DEVICE;
MinxIO.EEPBit = 8;
MinxIO.EEPData = 0x00;
return;
}
// "Stop" Command
if ((rise & MINX_EEPROM_DAT) && (bits & MINX_EEPROM_CLK)) {
MinxIO.ListenState = MINX_EEPROM_IDLE;
return;
}
// If it's Idle, there's nothing to do...
if (MinxIO.ListenState == MINX_EEPROM_IDLE) return;
// Process each bit on clock rise
if (rise & MINX_EEPROM_CLK) {
int dat = (bits & MINX_EEPROM_DAT) ? 1 : 0;
if (MinxIO.EEPBit < 0) {
MinxIO_EEPROM_Write(MinxIO.EEPData);
MinxIO.EEPBit = 8;
MinxIO.EEPData = 0x00;
} else MinxIO.EEPData = (MinxIO.EEPData << 1) | dat;
} else if (fall & MINX_EEPROM_CLK) {
MinxIO.EEPBit = MinxIO.EEPBit - 1;
}
}
int MinxIO_EEPROM_REvent(void)
{
int valid = (MinxIO.EEPBit >= 0) && (MinxIO.EEPBit < 8);
// If it's Idle, return high...
if (MinxIO.ListenState == MINX_EEPROM_IDLE)
return 1;
// Process read
if (MinxIO.OperState == MINX_EEPROM_RBYTE)
{
if (valid)
return (EEPROM[MinxIO.EEPAddress & 0x1FFF] >> MinxIO.EEPBit) & 1;
return 0;
}
return valid;
}
void MinxIO_EEPROM_Write(uint8_t data)
{
switch (MinxIO.OperState) {
case MINX_EEPROM_DEVICE:
// EEPROM Device
if ((data & 0xF0) == 0xA0)
MinxIO.OperState = data & 0x01 ? MINX_EEPROM_RBYTE : MINX_EEPROM_ADDRHI;
break;
case MINX_EEPROM_ADDRHI:
MinxIO.EEPAddress = (MinxIO.EEPAddress & 0x00FF) | (data << 8);
MinxIO.OperState = MINX_EEPROM_ADDRLO;
break;
case MINX_EEPROM_ADDRLO:
MinxIO.EEPAddress = (MinxIO.EEPAddress & 0xFF00) | data;
MinxIO.OperState = MINX_EEPROM_WBYTE;
break;
case MINX_EEPROM_WBYTE:
PokeMini_EEPROMWritten = 1;
EEPROM[MinxIO.EEPAddress & 0x1FFF] = data;
MinxIO.EEPAddress++;
break;
case MINX_EEPROM_RBYTE:
MinxIO.EEPAddress++;
break;
}
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
TMinxIO MinxIO;
uint8_t *EEPROM = NULL;
int PokeMini_Rumbling = 0;
int PokeMini_RumblingLatch = 0;
int PokeMini_EEPROMWritten = 0;
int PokeMini_BatteryStatus = 0; // 0 = Full, 1 = Low
int PokeMini_ShockKey = 0;
uint8_t MinxIO_IODataRead(void);
void MinxIO_IODataWrite(void);
void MinxIO_EEPROM_WEvent(uint8_t bits);
int MinxIO_EEPROM_REvent(void);
void MinxIO_EEPROM_Write(uint8_t data);
//
// Functions
//
int MinxIO_Create(void)
{
// Create EEPROM memory & format it
EEPROM = (uint8_t *)malloc(8192);
if (!EEPROM) return 0;
MinxIO_FormatEEPROM();
// Reset
MinxIO_Reset(1);
return 1;
}
void MinxIO_Destroy(void)
{
if (EEPROM) {
free(EEPROM);
EEPROM = NULL;
}
}
void MinxIO_Reset(int hardreset)
{
// Initialize State
memset(&MinxIO, 0, sizeof(TMinxIO));
PokeMini_Rumbling = 0;
PokeMini_RumblingLatch = 0;
PokeMini_ShockKey = 0;
// Init variables
PMR_KEY_PAD = 0xFF;
MinxIO.ListenState = MINX_EEPROM_IDLE;
MinxIO.OperState = MINX_EEPROM_DEVICE;
// Restore battery status
MinxIO_BatteryLow(PokeMini_BatteryStatus);
}
int MinxIO_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(32+8192);
PokeMini_Rumbling = 0;
PokeMini_RumblingLatch = 0;
PokeMini_EEPROMWritten = 1;
POKELOADSS_STREAM_8(MinxIO.EEPLastPins);
POKELOADSS_STREAM_8(MinxIO.ListenState);
POKELOADSS_STREAM_8(MinxIO.OperState);
POKELOADSS_STREAM_8(MinxIO.EEPData);
POKELOADSS_STREAM_32(MinxIO.EEPBit);
POKELOADSS_STREAM_16(MinxIO.EEPAddress);
POKELOADSS_STREAM_X(22);
POKELOADSS_STREAM_A(EEPROM, 8192);
POKELOADSS_END(32+8192);
}
int MinxIO_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(32+8192);
POKESAVESS_STREAM_8(MinxIO.EEPLastPins);
POKESAVESS_STREAM_8(MinxIO.ListenState);
POKESAVESS_STREAM_8(MinxIO.OperState);
POKESAVESS_STREAM_8(MinxIO.EEPData);
POKESAVESS_STREAM_32(MinxIO.EEPBit);
POKESAVESS_STREAM_16(MinxIO.EEPAddress);
POKESAVESS_STREAM_X(22);
POKESAVESS_STREAM_A(EEPROM, 8192);
POKESAVESS_END(32+8192);
}
int MinxIO_FormatEEPROM(void)
{
if (!EEPROM) return 0;
memset(EEPROM, 0xFF, 8192);
return 1;
}
void MinxIO_Keypad(uint8_t key, int pressed)
{
if (!EEPROM) return;
switch (key) {
case MINX_KEY_A: // Key A
if (pressed) {
if (!(PMR_KEY_PAD & 0x01)) return;
MinxCPU_OnIRQAct(MINX_INTR_1C);
PMR_KEY_PAD &= ~0x01;
} else PMR_KEY_PAD |= 0x01;
break;
case MINX_KEY_B: // Key B
if (pressed) {
if (!(PMR_KEY_PAD & 0x02)) return;
MinxCPU_OnIRQAct(MINX_INTR_1B);
PMR_KEY_PAD &= ~0x02;
} else PMR_KEY_PAD |= 0x02;
break;
case MINX_KEY_C: // Key C
if (pressed) {
if (!(PMR_KEY_PAD & 0x04)) return;
MinxCPU_OnIRQAct(MINX_INTR_1A);
PMR_KEY_PAD &= ~0x04;
} else PMR_KEY_PAD |= 0x04;
break;
case MINX_KEY_UP: // Dpad Up
if (pressed) {
if (!(PMR_KEY_PAD & 0x08)) return;
MinxCPU_OnIRQAct(MINX_INTR_19);
PMR_KEY_PAD &= ~0x08;
} else PMR_KEY_PAD |= 0x08;
break;
case MINX_KEY_DOWN: // Dpad Down
if (pressed) {
if (!(PMR_KEY_PAD & 0x10)) return;
MinxCPU_OnIRQAct(MINX_INTR_18);
PMR_KEY_PAD &= ~0x10;
} else PMR_KEY_PAD |= 0x10;
break;
case MINX_KEY_LEFT: // Dpad Left
if (pressed) {
if (!(PMR_KEY_PAD & 0x20)) return;
MinxCPU_OnIRQAct(MINX_INTR_17);
PMR_KEY_PAD &= ~0x20;
} else PMR_KEY_PAD |= 0x20;
break;
case MINX_KEY_RIGHT: // Dpad Right
if (pressed) {
if (!(PMR_KEY_PAD & 0x40)) return;
MinxCPU_OnIRQAct(MINX_INTR_16);
PMR_KEY_PAD &= ~0x40;
} else PMR_KEY_PAD |= 0x40;
break;
case MINX_KEY_POWER: // Power key
if (pressed) {
if (!(PMR_KEY_PAD & 0x80)) return;
MinxCPU_OnIRQAct(MINX_INTR_15);
PMR_KEY_PAD &= ~0x80;
} else PMR_KEY_PAD |= 0x80;
break;
case MINX_KEY_SHOCK: // Shock key
if (!PokeMini_ShockKey && pressed) {
MinxCPU_OnIRQAct(MINX_INTR_10);
}
PokeMini_ShockKey = pressed;
break;
}
}
void MinxIO_BatteryLow(int low)
{
PokeMini_BatteryStatus = low;
if (low) PMR_SYS_BATT |= 0x20;
else PMR_SYS_BATT &= 0x1F;
}
void MinxIO_SetTimeStamp(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec)
{
uint8_t checksum;
if (!EEPROM) return;
checksum = year + month + day + hour + min + sec;
PMR_SYS_CTRL3 |= 0x02;
EEPROM[0x1FF6] = 0x00;
EEPROM[0x1FF7] = 0x00;
EEPROM[0x1FF8] = 0x00;
EEPROM[0x1FF9] = year;
EEPROM[0x1FFA] = month;
EEPROM[0x1FFB] = day;
EEPROM[0x1FFC] = hour;
EEPROM[0x1FFD] = min;
EEPROM[0x1FFE] = sec;
EEPROM[0x1FFF] = checksum;
}
uint8_t MinxIO_ReadReg(int cpu, uint8_t reg)
{
// 0x10, 0x52, 0x60 to 0x62
switch(reg) {
case 0x10: // Low Battery
return PMR_SYS_BATT;
case 0x44: // Unknown
return PMR_REG_44;
case 0x45: // Unknown
return PMR_REG_45;
case 0x46: // Unknown
return PMR_REG_46;
case 0x47: // Unknown
return PMR_REG_47;
case 0x50: // Unknown (related to power management?)
return PMR_REG_50;
case 0x51: // Unknown (related to power management?)
return PMR_REG_51;
case 0x52: // Keypad
return PMR_KEY_PAD;
case 0x53: // Unknown
return PMR_REG_53;
case 0x54: // Unknown
return PMR_REG_54;
case 0x55: // Unknown
return PMR_REG_55;
case 0x60: // I/O Direction Select ( 0 = Input, 1 = Output )
return PMR_IO_DIR;
case 0x61: // I/O Data Register
return MinxIO_IODataRead();
case 0x62: // Unknown
return PMR_REG_62;
default: // Unused
break;
}
return 0;
}
void MinxIO_WriteReg(int cpu, uint8_t reg, uint8_t val)
{
// 0x10, 0x52, 0x60 to 0x62
switch(reg) {
case 0x10: // Low Battery
PMR_SYS_BATT = (PMR_SYS_BATT & 0x20) | (val & 0x1F);
break;
case 0x44: // Unknown
PMR_REG_44 = val & 0xF7;
break;
case 0x45: // Unknown
PMR_REG_45 = val & 0x0F;
break;
case 0x46: // Unknown
PMR_REG_46 = val;
break;
case 0x47: // Unknown
PMR_REG_47 = val & 0x0F;
break;
case 0x50: // Unknown (related to power management?)
PMR_REG_50 = val;
break;
case 0x51: // Unknown (related to power management?)
PMR_REG_51 = val & 0x03;
break;
case 0x52: // Keypad
break;
case 0x53: // Unknown
PMR_REG_53 = 0x00;
/* TODO/FIXME - is fallthrough intentional ?*/
case 0x54: // Unknown
PMR_REG_54 = val & 0x77;
/* TODO/FIXME - is fallthrough intentional ?*/
case 0x55: // Unknown
PMR_REG_55 = val & 0x07;
/* TODO/FIXME - is fallthrough intentional ?*/
case 0x60: // I/O Direction Select ( 0 = Input, 1 = Output )
PMR_IO_DIR = val;
MinxIO_IODataWrite();
break;
case 0x61: // I/O Data Register
PMR_IO_DATA = val;
MinxIO_IODataWrite();
break;
case 0x62: // Unknown
PMR_REG_62 = val & 0xF0;
break;
}
}
//
// Internal
//
uint8_t MinxIO_IODataRead(void)
{
/* Update all I/Os */
uint8_t Input = MinxIO_EEPROM_REvent() ? MINX_EEPROM_DAT : 0;
return (PMR_IO_DATA & PMR_IO_DIR) | (Input & ~PMR_IO_DIR);
}
void MinxIO_IODataWrite(void)
{
uint8_t Output = (MINX_IO_PULL_UPS & ~PMR_IO_DIR) | (PMR_IO_DATA & PMR_IO_DIR);
// Update all I/Os
PokeMini_Rumbling = Output & 0x10;
if (PokeMini_Rumbling) PokeMini_RumblingLatch = 1;
MinxIO_EEPROM_WEvent(Output);
}
void MinxIO_EEPROM_WEvent(uint8_t bits)
{
uint8_t rise = bits & ~MinxIO.EEPLastPins;
uint8_t fall = ~bits & MinxIO.EEPLastPins;
MinxIO.EEPLastPins = bits;
// "Start" Command
if ((fall & MINX_EEPROM_DAT) && (bits & MINX_EEPROM_CLK)) {
MinxIO.ListenState = MINX_EEPROM_LISTEN;
MinxIO.OperState = MINX_EEPROM_DEVICE;
MinxIO.EEPBit = 8;
MinxIO.EEPData = 0x00;
return;
}
// "Stop" Command
if ((rise & MINX_EEPROM_DAT) && (bits & MINX_EEPROM_CLK)) {
MinxIO.ListenState = MINX_EEPROM_IDLE;
return;
}
// If it's Idle, there's nothing to do...
if (MinxIO.ListenState == MINX_EEPROM_IDLE) return;
// Process each bit on clock rise
if (rise & MINX_EEPROM_CLK) {
int dat = (bits & MINX_EEPROM_DAT) ? 1 : 0;
if (MinxIO.EEPBit < 0) {
MinxIO_EEPROM_Write(MinxIO.EEPData);
MinxIO.EEPBit = 8;
MinxIO.EEPData = 0x00;
} else MinxIO.EEPData = (MinxIO.EEPData << 1) | dat;
} else if (fall & MINX_EEPROM_CLK) {
MinxIO.EEPBit = MinxIO.EEPBit - 1;
}
}
int MinxIO_EEPROM_REvent(void)
{
int valid = (MinxIO.EEPBit >= 0) && (MinxIO.EEPBit < 8);
// If it's Idle, return high...
if (MinxIO.ListenState == MINX_EEPROM_IDLE)
return 1;
// Process read
if (MinxIO.OperState == MINX_EEPROM_RBYTE)
{
if (valid)
return (EEPROM[MinxIO.EEPAddress & 0x1FFF] >> MinxIO.EEPBit) & 1;
return 0;
}
return valid;
}
void MinxIO_EEPROM_Write(uint8_t data)
{
switch (MinxIO.OperState) {
case MINX_EEPROM_DEVICE:
// EEPROM Device
if ((data & 0xF0) == 0xA0)
MinxIO.OperState = data & 0x01 ? MINX_EEPROM_RBYTE : MINX_EEPROM_ADDRHI;
break;
case MINX_EEPROM_ADDRHI:
MinxIO.EEPAddress = (MinxIO.EEPAddress & 0x00FF) | (data << 8);
MinxIO.OperState = MINX_EEPROM_ADDRLO;
break;
case MINX_EEPROM_ADDRLO:
MinxIO.EEPAddress = (MinxIO.EEPAddress & 0xFF00) | data;
MinxIO.OperState = MINX_EEPROM_WBYTE;
break;
case MINX_EEPROM_WBYTE:
PokeMini_EEPROMWritten = 1;
EEPROM[MinxIO.EEPAddress & 0x1FFF] = data;
MinxIO.EEPAddress++;
break;
case MINX_EEPROM_RBYTE:
MinxIO.EEPAddress++;
break;
}
}
+114 -114
View File
@@ -1,114 +1,114 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_IO
#define MINXHW_IO
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
uint8_t EEPLastPins;
uint8_t ListenState;
uint8_t OperState;
uint8_t EEPData;
int32_t EEPBit;
uint16_t EEPAddress;
} TMinxIO;
// Export IO state
extern TMinxIO MinxIO;
// EEPROM Data
extern uint8_t *EEPROM;
// Rumbling & EEPROM written state
extern int PokeMini_Rumbling;
extern int PokeMini_RumblingLatch;
extern int PokeMini_EEPROMWritten;
extern int PokeMini_BatteryStatus; // 0 = Full, 1 = Low
enum {
// EEPROM Listen State
MINX_EEPROM_IDLE = 0, // Idle
MINX_EEPROM_LISTEN = 1, // Listening
// EEPROM Data State
MINX_EEPROM_DEVICE = 0, // Device ID
MINX_EEPROM_ADDRHI = 1, // High Address Byte
MINX_EEPROM_ADDRLO = 2, // Low Address Byte
MINX_EEPROM_WBYTE = 3, // Write Byte
MINX_EEPROM_RBYTE = 4, // Read Byte
// Keypad
MINX_KEY_NONE = 0,
MINX_KEY_A = 1,
MINX_KEY_B = 2,
MINX_KEY_C = 3,
MINX_KEY_UP = 4,
MINX_KEY_DOWN = 5,
MINX_KEY_LEFT = 6,
MINX_KEY_RIGHT = 7,
MINX_KEY_POWER = 8,
MINX_KEY_SHOCK = 9 // Not real key, reserved for handling key event
};
// Interrupt table
enum {
MINX_INTR_0F = 0x0F, // IR Receiver
MINX_INTR_10 = 0x10, // Shock Sensor
MINX_INTR_15 = 0x15, // A key
MINX_INTR_16 = 0x16, // B key
MINX_INTR_17 = 0x17, // C key
MINX_INTR_18 = 0x18, // Up key
MINX_INTR_19 = 0x19, // Down key
MINX_INTR_1A = 0x1A, // Left key
MINX_INTR_1B = 0x1B, // Right key
MINX_INTR_1C = 0x1C // Power key
};
#define MINX_IO_PULL_UPS 0x40 // Pull-up when direction create a Z
#define MINX_EEPROM_DAT 0x04
#define MINX_EEPROM_CLK 0x08
int MinxIO_Create(void);
void MinxIO_Destroy(void);
void MinxIO_Reset(int hardreset);
int MinxIO_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxIO_SaveStateStream(memstream_t *stream);
int MinxIO_FormatEEPROM(void);
void MinxIO_Keypad(uint8_t key, int pressed);
void MinxIO_BatteryLow(int low);
void MinxIO_SetTimeStamp(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec);
uint8_t MinxIO_ReadReg(int cpu, uint8_t reg);
void MinxIO_WriteReg(int cpu, uint8_t reg, uint8_t val);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_IO
#define MINXHW_IO
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
uint8_t EEPLastPins;
uint8_t ListenState;
uint8_t OperState;
uint8_t EEPData;
int32_t EEPBit;
uint16_t EEPAddress;
} TMinxIO;
// Export IO state
extern TMinxIO MinxIO;
// EEPROM Data
extern uint8_t *EEPROM;
// Rumbling & EEPROM written state
extern int PokeMini_Rumbling;
extern int PokeMini_RumblingLatch;
extern int PokeMini_EEPROMWritten;
extern int PokeMini_BatteryStatus; // 0 = Full, 1 = Low
enum {
// EEPROM Listen State
MINX_EEPROM_IDLE = 0, // Idle
MINX_EEPROM_LISTEN = 1, // Listening
// EEPROM Data State
MINX_EEPROM_DEVICE = 0, // Device ID
MINX_EEPROM_ADDRHI = 1, // High Address Byte
MINX_EEPROM_ADDRLO = 2, // Low Address Byte
MINX_EEPROM_WBYTE = 3, // Write Byte
MINX_EEPROM_RBYTE = 4, // Read Byte
// Keypad
MINX_KEY_NONE = 0,
MINX_KEY_A = 1,
MINX_KEY_B = 2,
MINX_KEY_C = 3,
MINX_KEY_UP = 4,
MINX_KEY_DOWN = 5,
MINX_KEY_LEFT = 6,
MINX_KEY_RIGHT = 7,
MINX_KEY_POWER = 8,
MINX_KEY_SHOCK = 9 // Not real key, reserved for handling key event
};
// Interrupt table
enum {
MINX_INTR_0F = 0x0F, // IR Receiver
MINX_INTR_10 = 0x10, // Shock Sensor
MINX_INTR_15 = 0x15, // A key
MINX_INTR_16 = 0x16, // B key
MINX_INTR_17 = 0x17, // C key
MINX_INTR_18 = 0x18, // Up key
MINX_INTR_19 = 0x19, // Down key
MINX_INTR_1A = 0x1A, // Left key
MINX_INTR_1B = 0x1B, // Right key
MINX_INTR_1C = 0x1C // Power key
};
#define MINX_IO_PULL_UPS 0x40 // Pull-up when direction create a Z
#define MINX_EEPROM_DAT 0x04
#define MINX_EEPROM_CLK 0x08
int MinxIO_Create(void);
void MinxIO_Destroy(void);
void MinxIO_Reset(int hardreset);
int MinxIO_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxIO_SaveStateStream(memstream_t *stream);
int MinxIO_FormatEEPROM(void);
void MinxIO_Keypad(uint8_t key, int pressed);
void MinxIO_BatteryLow(int low);
void MinxIO_SetTimeStamp(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec);
uint8_t MinxIO_ReadReg(int cpu, uint8_t reg);
void MinxIO_WriteReg(int cpu, uint8_t reg, uint8_t val);
#endif
+278 -278
View File
@@ -1,278 +1,278 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
int MinxIRQ_MasterIRQ = 0;
void MinxIRQ_Process(void);
//
// Functions
//
int MinxIRQ_Create(void)
{
// Reset
MinxIRQ_Reset(1);
return 1;
}
void MinxIRQ_Destroy(void)
{
}
void MinxIRQ_Reset(int hardreset)
{
// Master IRQ enable
MinxIRQ_MasterIRQ = 1;
PMR_IRQ_ACT1 = 0x00;
PMR_IRQ_ACT2 = 0x00;
PMR_IRQ_ACT3 = 0x00;
PMR_IRQ_ACT4 = 0x00;
}
int MinxIRQ_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(1);
POKELOADSS_STREAM_8(MinxIRQ_MasterIRQ);
POKELOADSS_END(1);
}
int MinxIRQ_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(1);
POKESAVESS_STREAM_8(MinxIRQ_MasterIRQ);
POKESAVESS_END(1);
}
void MinxIRQ_SetIRQ(uint8_t intr)
{
switch(intr) {
case 0x03: // PRC Copy Complete
PMR_IRQ_ACT1 |= 0x80;
break;
case 0x04: // PRC Frame Divider Overflow
PMR_IRQ_ACT1 |= 0x40;
break;
case 0x05: // Timer 2-B Underflow
PMR_IRQ_ACT1 |= 0x20;
break;
case 0x06: // Timer 2-A Underflow (8-Bits only)
PMR_IRQ_ACT1 |= 0x10;
break;
case 0x07: // Timer 1-B Underflow
PMR_IRQ_ACT1 |= 0x08;
break;
case 0x08: // Timer 1-A Underflow (8-Bits only)
PMR_IRQ_ACT1 |= 0x04;
break;
case 0x09: // Timer 3 Underflow
PMR_IRQ_ACT1 |= 0x02;
break;
case 0x0A: // Timer 3 Pivot
PMR_IRQ_ACT1 |= 0x01;
break;
case 0x0B: // 32 Hz
PMR_IRQ_ACT2 |= 0x20;
break;
case 0x0C: // 8 Hz
PMR_IRQ_ACT2 |= 0x10;
break;
case 0x0D: // 2 Hz
PMR_IRQ_ACT2 |= 0x08;
break;
case 0x0E: // 1 Hz
PMR_IRQ_ACT2 |= 0x04;
break;
case 0x0F: // IR Receiver
PMR_IRQ_ACT4 |= 0x80;
break;
case 0x10: // Shock Sensor
PMR_IRQ_ACT4 |= 0x40;
break;
case 0x13: // Cartridge Ejected
PMR_IRQ_ACT2 |= 0x02;
break;
case 0x14: // Cartridge IRQ
PMR_IRQ_ACT2 |= 0x01;
break;
case 0x15: // Power Key
PMR_IRQ_ACT3 |= 0x80;
break;
case 0x16: // Right Key
PMR_IRQ_ACT3 |= 0x40;
break;
case 0x17: // Left Key
PMR_IRQ_ACT3 |= 0x20;
break;
case 0x18: // Down Key
PMR_IRQ_ACT3 |= 0x10;
break;
case 0x19: // Up Key
PMR_IRQ_ACT3 |= 0x08;
break;
case 0x1A: // C Key
PMR_IRQ_ACT3 |= 0x04;
break;
case 0x1B: // B Key
PMR_IRQ_ACT3 |= 0x02;
break;
case 0x1C: // A Key
PMR_IRQ_ACT3 |= 0x01;
break;
}
MinxIRQ_Process();
}
uint8_t MinxIRQ_ReadReg(int cpu, uint8_t reg)
{
// 0x20 to 0x2A
switch(reg) {
case 0x20: // IRQ Priority 1
return PMR_IRQ_PRI1;
case 0x21: // IRQ Priority 2
return PMR_IRQ_PRI2;
case 0x22: // IRQ Priority 3
return PMR_IRQ_PRI3 & 0x03;
case 0x23: // IRQ Enable 1
return PMR_IRQ_ENA1;
case 0x24: // IRQ Enable 2
return PMR_IRQ_ENA2 & 0x3F;
case 0x25: // IRQ Enable 3
return PMR_IRQ_ENA3;
case 0x26: // IRQ Enable 4
return PMR_IRQ_ENA4 & 0xF7;
case 0x27: // IRQ Active 1
return PMR_IRQ_ACT1;
case 0x28: // IRQ Active 2
return PMR_IRQ_ACT2 & 0x3F;
case 0x29: // IRQ Active 3
return PMR_IRQ_ACT3;
case 0x2A: // IRQ Active 4
return PMR_IRQ_ACT4 & 0xF7;
default: // Unused
return 0;
}
}
void MinxIRQ_WriteReg(int cpu, uint8_t reg, uint8_t val)
{
// 0x20 to 0x2A
switch(reg) {
case 0x20: // IRQ Priority 1
PMR_IRQ_PRI1 = val;
MinxIRQ_Process();
return;
case 0x21: // IRQ Priority 2
PMR_IRQ_PRI2 = val;
MinxIRQ_Process();
return;
case 0x22: // IRQ Priority 3
PMR_IRQ_PRI3 = val;
MinxIRQ_Process();
return;
case 0x23: // IRQ Enable 1
PMR_IRQ_ENA1 = val;
MinxIRQ_Process();
return;
case 0x24: // IRQ Enable 2
PMR_IRQ_ENA2 = val & 0x3F;
MinxIRQ_Process();
return;
case 0x25: // IRQ Enable 3
PMR_IRQ_ENA3 = val;
MinxIRQ_Process();
return;
case 0x26: // IRQ Enable 4
PMR_IRQ_ENA4 = val & 0xF7;
MinxIRQ_Process();
return;
case 0x27: // IRQ Active 1
if (cpu) PMR_IRQ_ACT1 &= ~val;
else PMR_IRQ_ACT1 = val;
return;
case 0x28: // IRQ Active 2
if (cpu) PMR_IRQ_ACT2 &= ~val;
else PMR_IRQ_ACT2 = val & 0x3F;
return;
case 0x29: // IRQ Active 3
if (cpu) PMR_IRQ_ACT3 &= ~val;
else PMR_IRQ_ACT3 = val;
return;
case 0x2A: // IRQ Active 4
if (cpu) PMR_IRQ_ACT4 &= ~val;
else PMR_IRQ_ACT4 = val & 0xF7;
return;
default: // Unused
return;
}
}
void MinxIRQ_Process(void)
{
// TODO! Need to emulate the priority system... bah...
if (!MinxIRQ_MasterIRQ) return;
if (PMR_IRQ_PRI1 & 0xC0) {
if ((PMR_IRQ_ENA1 & 0x80) && (PMR_IRQ_ACT1 & 0x80)) { MinxIRQ_OnIRQ(0x03); return; }
if ((PMR_IRQ_ENA1 & 0x40) && (PMR_IRQ_ACT1 & 0x40)) { MinxIRQ_OnIRQ(0x04); return; }
}
if (PMR_IRQ_PRI1 & 0x30) {
if ((PMR_IRQ_ENA1 & 0x20) && (PMR_IRQ_ACT1 & 0x20)) { MinxIRQ_OnIRQ(0x05); return; }
if ((PMR_IRQ_ENA1 & 0x10) && (PMR_IRQ_ACT1 & 0x10)) { MinxIRQ_OnIRQ(0x06); return; }
}
if (PMR_IRQ_PRI1 & 0x0C) {
if ((PMR_IRQ_ENA1 & 0x08) && (PMR_IRQ_ACT1 & 0x08)) { MinxIRQ_OnIRQ(0x07); return; }
if ((PMR_IRQ_ENA1 & 0x04) && (PMR_IRQ_ACT1 & 0x04)) { MinxIRQ_OnIRQ(0x08); return; }
}
if (PMR_IRQ_PRI1 & 0x03) {
if ((PMR_IRQ_ENA1 & 0x02) && (PMR_IRQ_ACT1 & 0x02)) { MinxIRQ_OnIRQ(0x09); return; }
if ((PMR_IRQ_ENA1 & 0x01) && (PMR_IRQ_ACT1 & 0x01)) { MinxIRQ_OnIRQ(0x0A); return; }
}
if (PMR_IRQ_PRI2 & 0xC0) {
if ((PMR_IRQ_ENA2 & 0x20) && (PMR_IRQ_ACT2 & 0x20)) { MinxIRQ_OnIRQ(0x0B); return; }
if ((PMR_IRQ_ENA2 & 0x10) && (PMR_IRQ_ACT2 & 0x10)) { MinxIRQ_OnIRQ(0x0C); return; }
if ((PMR_IRQ_ENA2 & 0x08) && (PMR_IRQ_ACT2 & 0x08)) { MinxIRQ_OnIRQ(0x0D); return; }
if ((PMR_IRQ_ENA2 & 0x04) && (PMR_IRQ_ACT2 & 0x04)) { MinxIRQ_OnIRQ(0x0E); return; }
}
if (PMR_IRQ_PRI3 & 0x03) {
if ((PMR_IRQ_ENA4 & 0x80) && (PMR_IRQ_ACT4 & 0x80)) { MinxIRQ_OnIRQ(0x0F); return; }
if ((PMR_IRQ_ENA4 & 0x40) && (PMR_IRQ_ACT4 & 0x40)) { MinxIRQ_OnIRQ(0x10); return; }
}
if (PMR_IRQ_PRI2 & 0x30) {
if ((PMR_IRQ_ENA2 & 0x02) && (PMR_IRQ_ACT2 & 0x02)) { MinxIRQ_OnIRQ(0x13); return; }
if ((PMR_IRQ_ENA2 & 0x01) && (PMR_IRQ_ACT2 & 0x01)) { MinxIRQ_OnIRQ(0x14); return; }
}
if (PMR_IRQ_PRI2 & 0x0C) {
if ((PMR_IRQ_ENA3 & 0x80) && (PMR_IRQ_ACT3 & 0x80)) { MinxIRQ_OnIRQ(0x15); return; }
if ((PMR_IRQ_ENA3 & 0x40) && (PMR_IRQ_ACT3 & 0x40)) { MinxIRQ_OnIRQ(0x16); return; }
if ((PMR_IRQ_ENA3 & 0x20) && (PMR_IRQ_ACT3 & 0x20)) { MinxIRQ_OnIRQ(0x17); return; }
if ((PMR_IRQ_ENA3 & 0x10) && (PMR_IRQ_ACT3 & 0x10)) { MinxIRQ_OnIRQ(0x18); return; }
if ((PMR_IRQ_ENA3 & 0x08) && (PMR_IRQ_ACT3 & 0x08)) { MinxIRQ_OnIRQ(0x19); return; }
if ((PMR_IRQ_ENA3 & 0x04) && (PMR_IRQ_ACT3 & 0x04)) { MinxIRQ_OnIRQ(0x1A); return; }
if ((PMR_IRQ_ENA3 & 0x02) && (PMR_IRQ_ACT3 & 0x02)) { MinxIRQ_OnIRQ(0x1B); return; }
if ((PMR_IRQ_ENA3 & 0x01) && (PMR_IRQ_ACT3 & 0x01)) { MinxIRQ_OnIRQ(0x1C); return; }
}
if (PMR_IRQ_PRI2 & 0x03) {
if ((PMR_IRQ_ENA4 & 0x04) && (PMR_IRQ_ACT4 & 0x04)) { MinxIRQ_OnIRQ(0x1D); return; }
if ((PMR_IRQ_ENA4 & 0x02) && (PMR_IRQ_ACT4 & 0x02)) { MinxIRQ_OnIRQ(0x1E); return; }
if ((PMR_IRQ_ENA4 & 0x01) && (PMR_IRQ_ACT4 & 0x01)) { MinxIRQ_OnIRQ(0x1F); return; }
}
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PokeMini.h"
int MinxIRQ_MasterIRQ = 0;
void MinxIRQ_Process(void);
//
// Functions
//
int MinxIRQ_Create(void)
{
// Reset
MinxIRQ_Reset(1);
return 1;
}
void MinxIRQ_Destroy(void)
{
}
void MinxIRQ_Reset(int hardreset)
{
// Master IRQ enable
MinxIRQ_MasterIRQ = 1;
PMR_IRQ_ACT1 = 0x00;
PMR_IRQ_ACT2 = 0x00;
PMR_IRQ_ACT3 = 0x00;
PMR_IRQ_ACT4 = 0x00;
}
int MinxIRQ_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(1);
POKELOADSS_STREAM_8(MinxIRQ_MasterIRQ);
POKELOADSS_END(1);
}
int MinxIRQ_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(1);
POKESAVESS_STREAM_8(MinxIRQ_MasterIRQ);
POKESAVESS_END(1);
}
void MinxIRQ_SetIRQ(uint8_t intr)
{
switch(intr) {
case 0x03: // PRC Copy Complete
PMR_IRQ_ACT1 |= 0x80;
break;
case 0x04: // PRC Frame Divider Overflow
PMR_IRQ_ACT1 |= 0x40;
break;
case 0x05: // Timer 2-B Underflow
PMR_IRQ_ACT1 |= 0x20;
break;
case 0x06: // Timer 2-A Underflow (8-Bits only)
PMR_IRQ_ACT1 |= 0x10;
break;
case 0x07: // Timer 1-B Underflow
PMR_IRQ_ACT1 |= 0x08;
break;
case 0x08: // Timer 1-A Underflow (8-Bits only)
PMR_IRQ_ACT1 |= 0x04;
break;
case 0x09: // Timer 3 Underflow
PMR_IRQ_ACT1 |= 0x02;
break;
case 0x0A: // Timer 3 Pivot
PMR_IRQ_ACT1 |= 0x01;
break;
case 0x0B: // 32 Hz
PMR_IRQ_ACT2 |= 0x20;
break;
case 0x0C: // 8 Hz
PMR_IRQ_ACT2 |= 0x10;
break;
case 0x0D: // 2 Hz
PMR_IRQ_ACT2 |= 0x08;
break;
case 0x0E: // 1 Hz
PMR_IRQ_ACT2 |= 0x04;
break;
case 0x0F: // IR Receiver
PMR_IRQ_ACT4 |= 0x80;
break;
case 0x10: // Shock Sensor
PMR_IRQ_ACT4 |= 0x40;
break;
case 0x13: // Cartridge Ejected
PMR_IRQ_ACT2 |= 0x02;
break;
case 0x14: // Cartridge IRQ
PMR_IRQ_ACT2 |= 0x01;
break;
case 0x15: // Power Key
PMR_IRQ_ACT3 |= 0x80;
break;
case 0x16: // Right Key
PMR_IRQ_ACT3 |= 0x40;
break;
case 0x17: // Left Key
PMR_IRQ_ACT3 |= 0x20;
break;
case 0x18: // Down Key
PMR_IRQ_ACT3 |= 0x10;
break;
case 0x19: // Up Key
PMR_IRQ_ACT3 |= 0x08;
break;
case 0x1A: // C Key
PMR_IRQ_ACT3 |= 0x04;
break;
case 0x1B: // B Key
PMR_IRQ_ACT3 |= 0x02;
break;
case 0x1C: // A Key
PMR_IRQ_ACT3 |= 0x01;
break;
}
MinxIRQ_Process();
}
uint8_t MinxIRQ_ReadReg(int cpu, uint8_t reg)
{
// 0x20 to 0x2A
switch(reg) {
case 0x20: // IRQ Priority 1
return PMR_IRQ_PRI1;
case 0x21: // IRQ Priority 2
return PMR_IRQ_PRI2;
case 0x22: // IRQ Priority 3
return PMR_IRQ_PRI3 & 0x03;
case 0x23: // IRQ Enable 1
return PMR_IRQ_ENA1;
case 0x24: // IRQ Enable 2
return PMR_IRQ_ENA2 & 0x3F;
case 0x25: // IRQ Enable 3
return PMR_IRQ_ENA3;
case 0x26: // IRQ Enable 4
return PMR_IRQ_ENA4 & 0xF7;
case 0x27: // IRQ Active 1
return PMR_IRQ_ACT1;
case 0x28: // IRQ Active 2
return PMR_IRQ_ACT2 & 0x3F;
case 0x29: // IRQ Active 3
return PMR_IRQ_ACT3;
case 0x2A: // IRQ Active 4
return PMR_IRQ_ACT4 & 0xF7;
default: // Unused
return 0;
}
}
void MinxIRQ_WriteReg(int cpu, uint8_t reg, uint8_t val)
{
// 0x20 to 0x2A
switch(reg) {
case 0x20: // IRQ Priority 1
PMR_IRQ_PRI1 = val;
MinxIRQ_Process();
return;
case 0x21: // IRQ Priority 2
PMR_IRQ_PRI2 = val;
MinxIRQ_Process();
return;
case 0x22: // IRQ Priority 3
PMR_IRQ_PRI3 = val;
MinxIRQ_Process();
return;
case 0x23: // IRQ Enable 1
PMR_IRQ_ENA1 = val;
MinxIRQ_Process();
return;
case 0x24: // IRQ Enable 2
PMR_IRQ_ENA2 = val & 0x3F;
MinxIRQ_Process();
return;
case 0x25: // IRQ Enable 3
PMR_IRQ_ENA3 = val;
MinxIRQ_Process();
return;
case 0x26: // IRQ Enable 4
PMR_IRQ_ENA4 = val & 0xF7;
MinxIRQ_Process();
return;
case 0x27: // IRQ Active 1
if (cpu) PMR_IRQ_ACT1 &= ~val;
else PMR_IRQ_ACT1 = val;
return;
case 0x28: // IRQ Active 2
if (cpu) PMR_IRQ_ACT2 &= ~val;
else PMR_IRQ_ACT2 = val & 0x3F;
return;
case 0x29: // IRQ Active 3
if (cpu) PMR_IRQ_ACT3 &= ~val;
else PMR_IRQ_ACT3 = val;
return;
case 0x2A: // IRQ Active 4
if (cpu) PMR_IRQ_ACT4 &= ~val;
else PMR_IRQ_ACT4 = val & 0xF7;
return;
default: // Unused
return;
}
}
void MinxIRQ_Process(void)
{
// TODO! Need to emulate the priority system... bah...
if (!MinxIRQ_MasterIRQ) return;
if (PMR_IRQ_PRI1 & 0xC0) {
if ((PMR_IRQ_ENA1 & 0x80) && (PMR_IRQ_ACT1 & 0x80)) { MinxIRQ_OnIRQ(0x03); return; }
if ((PMR_IRQ_ENA1 & 0x40) && (PMR_IRQ_ACT1 & 0x40)) { MinxIRQ_OnIRQ(0x04); return; }
}
if (PMR_IRQ_PRI1 & 0x30) {
if ((PMR_IRQ_ENA1 & 0x20) && (PMR_IRQ_ACT1 & 0x20)) { MinxIRQ_OnIRQ(0x05); return; }
if ((PMR_IRQ_ENA1 & 0x10) && (PMR_IRQ_ACT1 & 0x10)) { MinxIRQ_OnIRQ(0x06); return; }
}
if (PMR_IRQ_PRI1 & 0x0C) {
if ((PMR_IRQ_ENA1 & 0x08) && (PMR_IRQ_ACT1 & 0x08)) { MinxIRQ_OnIRQ(0x07); return; }
if ((PMR_IRQ_ENA1 & 0x04) && (PMR_IRQ_ACT1 & 0x04)) { MinxIRQ_OnIRQ(0x08); return; }
}
if (PMR_IRQ_PRI1 & 0x03) {
if ((PMR_IRQ_ENA1 & 0x02) && (PMR_IRQ_ACT1 & 0x02)) { MinxIRQ_OnIRQ(0x09); return; }
if ((PMR_IRQ_ENA1 & 0x01) && (PMR_IRQ_ACT1 & 0x01)) { MinxIRQ_OnIRQ(0x0A); return; }
}
if (PMR_IRQ_PRI2 & 0xC0) {
if ((PMR_IRQ_ENA2 & 0x20) && (PMR_IRQ_ACT2 & 0x20)) { MinxIRQ_OnIRQ(0x0B); return; }
if ((PMR_IRQ_ENA2 & 0x10) && (PMR_IRQ_ACT2 & 0x10)) { MinxIRQ_OnIRQ(0x0C); return; }
if ((PMR_IRQ_ENA2 & 0x08) && (PMR_IRQ_ACT2 & 0x08)) { MinxIRQ_OnIRQ(0x0D); return; }
if ((PMR_IRQ_ENA2 & 0x04) && (PMR_IRQ_ACT2 & 0x04)) { MinxIRQ_OnIRQ(0x0E); return; }
}
if (PMR_IRQ_PRI3 & 0x03) {
if ((PMR_IRQ_ENA4 & 0x80) && (PMR_IRQ_ACT4 & 0x80)) { MinxIRQ_OnIRQ(0x0F); return; }
if ((PMR_IRQ_ENA4 & 0x40) && (PMR_IRQ_ACT4 & 0x40)) { MinxIRQ_OnIRQ(0x10); return; }
}
if (PMR_IRQ_PRI2 & 0x30) {
if ((PMR_IRQ_ENA2 & 0x02) && (PMR_IRQ_ACT2 & 0x02)) { MinxIRQ_OnIRQ(0x13); return; }
if ((PMR_IRQ_ENA2 & 0x01) && (PMR_IRQ_ACT2 & 0x01)) { MinxIRQ_OnIRQ(0x14); return; }
}
if (PMR_IRQ_PRI2 & 0x0C) {
if ((PMR_IRQ_ENA3 & 0x80) && (PMR_IRQ_ACT3 & 0x80)) { MinxIRQ_OnIRQ(0x15); return; }
if ((PMR_IRQ_ENA3 & 0x40) && (PMR_IRQ_ACT3 & 0x40)) { MinxIRQ_OnIRQ(0x16); return; }
if ((PMR_IRQ_ENA3 & 0x20) && (PMR_IRQ_ACT3 & 0x20)) { MinxIRQ_OnIRQ(0x17); return; }
if ((PMR_IRQ_ENA3 & 0x10) && (PMR_IRQ_ACT3 & 0x10)) { MinxIRQ_OnIRQ(0x18); return; }
if ((PMR_IRQ_ENA3 & 0x08) && (PMR_IRQ_ACT3 & 0x08)) { MinxIRQ_OnIRQ(0x19); return; }
if ((PMR_IRQ_ENA3 & 0x04) && (PMR_IRQ_ACT3 & 0x04)) { MinxIRQ_OnIRQ(0x1A); return; }
if ((PMR_IRQ_ENA3 & 0x02) && (PMR_IRQ_ACT3 & 0x02)) { MinxIRQ_OnIRQ(0x1B); return; }
if ((PMR_IRQ_ENA3 & 0x01) && (PMR_IRQ_ACT3 & 0x01)) { MinxIRQ_OnIRQ(0x1C); return; }
}
if (PMR_IRQ_PRI2 & 0x03) {
if ((PMR_IRQ_ENA4 & 0x04) && (PMR_IRQ_ACT4 & 0x04)) { MinxIRQ_OnIRQ(0x1D); return; }
if ((PMR_IRQ_ENA4 & 0x02) && (PMR_IRQ_ACT4 & 0x02)) { MinxIRQ_OnIRQ(0x1E); return; }
if ((PMR_IRQ_ENA4 & 0x01) && (PMR_IRQ_ACT4 & 0x01)) { MinxIRQ_OnIRQ(0x1F); return; }
}
}
+53 -53
View File
@@ -1,53 +1,53 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_IRQ
#define MINXHW_IRQ
#include <stdint.h>
#include <streams/memory_stream.h>
// Master IRQ enable
extern int MinxIRQ_MasterIRQ;
int MinxIRQ_Create(void);
void MinxIRQ_Destroy(void);
void MinxIRQ_Reset(int hardreset);
int MinxIRQ_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxIRQ_SaveStateStream(memstream_t *stream);
void MinxIRQ_SetIRQ(uint8_t intr);
uint8_t MinxIRQ_ReadReg(int cpu, uint8_t reg);
void MinxIRQ_WriteReg(int cpu, uint8_t reg, uint8_t val);
void MinxIRQ_Process(void);
//
// Callbacks (Written by the user)
//
void MinxIRQ_OnIRQ(uint8_t intr);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_IRQ
#define MINXHW_IRQ
#include <stdint.h>
#include <streams/memory_stream.h>
// Master IRQ enable
extern int MinxIRQ_MasterIRQ;
int MinxIRQ_Create(void);
void MinxIRQ_Destroy(void);
void MinxIRQ_Reset(int hardreset);
int MinxIRQ_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxIRQ_SaveStateStream(memstream_t *stream);
void MinxIRQ_SetIRQ(uint8_t intr);
uint8_t MinxIRQ_ReadReg(int cpu, uint8_t reg);
void MinxIRQ_WriteReg(int cpu, uint8_t reg, uint8_t val);
void MinxIRQ_Process(void);
//
// Callbacks (Written by the user)
//
void MinxIRQ_OnIRQ(uint8_t intr);
#endif
+612 -612
View File
File diff suppressed because it is too large. Load diff
+99 -99
View File
@@ -1,99 +1,99 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_LCD
#define MINXHW_LCD
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
int32_t Pixel0Intensity; // Pixel 0 Intensity
int32_t Pixel1Intensity; // Pixel 1 Intensity
uint8_t Column; // Column
uint8_t StartLine; // Start line
uint8_t SetContrast; // Set contrast
uint8_t Contrast; // Contrast level
uint8_t SegmentDir; // Segment Driver Direction Select
uint8_t MaxContrast; // Max Contrast
uint8_t SetAllPix; // Set All Pixels
uint8_t InvAllPix; // Invert All Pixels
uint8_t DisplayOn; // Display On
uint8_t Page; // Page
uint8_t RowOrder; // 0 = Top to bottom, 1 = Bottom to top
uint8_t ReadModifyMode; // Read Modify Write mode
uint8_t RequireDummyR; // Require Dummy Read
uint8_t RMWColumn; // Column when Read Modify Write started
} TMinxLCD;
#ifndef MINX_DIRTYPIX
#define MINX_DIRTYPIX 4
#endif
#ifndef MINX_DIRTYSCR
#define MINX_DIRTYSCR 4
#endif
// Export LCD state
extern TMinxLCD MinxLCD;
// LCD dirty status (1+ = graphics changed)
extern int LCDDirty;
// LCD Data (132 x 65 x 1bpp), Pitch of 256 bytes
extern uint8_t *LCDData;
// LCD Pixels Digital (96 x 64, 0 or 1)
extern uint8_t *LCDPixelsD;
// LCD Pixels Analog (96 x 64, 0 to 255)
extern uint8_t *LCDPixelsA;
int MinxLCD_Create(void);
void MinxLCD_Destroy(void);
void MinxLCD_Reset(int hardreset);
int MinxLCD_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxLCD_SaveStateStream(memstream_t *stream);
uint8_t MinxLCD_ReadReg(int cpu, uint8_t reg);
void MinxLCD_WriteReg(int cpu, uint8_t reg, uint8_t val);
void MinxLCD_DecayRefresh(void);
void MinxLCD_Render(void);
uint8_t MinxLCD_LCDReadCtrl(int cpu);
uint8_t MinxLCD_LCDRead(int cpu);
void MinxLCD_LCDWriteCtrl(uint8_t data);
void MinxLCD_LCDWrite(uint8_t data);
void MinxLCD_LCDWritefb(uint8_t *fb);
void MinxLCD_SetContrast(uint8_t value);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_LCD
#define MINXHW_LCD
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
int32_t Pixel0Intensity; // Pixel 0 Intensity
int32_t Pixel1Intensity; // Pixel 1 Intensity
uint8_t Column; // Column
uint8_t StartLine; // Start line
uint8_t SetContrast; // Set contrast
uint8_t Contrast; // Contrast level
uint8_t SegmentDir; // Segment Driver Direction Select
uint8_t MaxContrast; // Max Contrast
uint8_t SetAllPix; // Set All Pixels
uint8_t InvAllPix; // Invert All Pixels
uint8_t DisplayOn; // Display On
uint8_t Page; // Page
uint8_t RowOrder; // 0 = Top to bottom, 1 = Bottom to top
uint8_t ReadModifyMode; // Read Modify Write mode
uint8_t RequireDummyR; // Require Dummy Read
uint8_t RMWColumn; // Column when Read Modify Write started
} TMinxLCD;
#ifndef MINX_DIRTYPIX
#define MINX_DIRTYPIX 4
#endif
#ifndef MINX_DIRTYSCR
#define MINX_DIRTYSCR 4
#endif
// Export LCD state
extern TMinxLCD MinxLCD;
// LCD dirty status (1+ = graphics changed)
extern int LCDDirty;
// LCD Data (132 x 65 x 1bpp), Pitch of 256 bytes
extern uint8_t *LCDData;
// LCD Pixels Digital (96 x 64, 0 or 1)
extern uint8_t *LCDPixelsD;
// LCD Pixels Analog (96 x 64, 0 to 255)
extern uint8_t *LCDPixelsA;
int MinxLCD_Create(void);
void MinxLCD_Destroy(void);
void MinxLCD_Reset(int hardreset);
int MinxLCD_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxLCD_SaveStateStream(memstream_t *stream);
uint8_t MinxLCD_ReadReg(int cpu, uint8_t reg);
void MinxLCD_WriteReg(int cpu, uint8_t reg, uint8_t val);
void MinxLCD_DecayRefresh(void);
void MinxLCD_Render(void);
uint8_t MinxLCD_LCDReadCtrl(int cpu);
uint8_t MinxLCD_LCDRead(int cpu);
void MinxLCD_LCDWriteCtrl(uint8_t data);
void MinxLCD_LCDWrite(uint8_t data);
void MinxLCD_LCDWritefb(uint8_t *fb);
void MinxLCD_SetContrast(uint8_t value);
#endif
+407 -407
View File
@@ -1,407 +1,407 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <retro_inline.h>
#include "PokeMini.h"
TMinxPRC MinxPRC;
int PRCAllowStall = 1; // Allow stall CPU?
int StallCPU = 0; // Stall CPU output flag
int PRCRenderBD = 0; // Render backdrop? (Background overrides backdrop)
int PRCRenderBG = 1; // Render background?
int PRCRenderSpr = 1; // Render sprites?
const uint8_t PRCInvertBit[256] = { // Invert Bit table
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
0x0A, 0x8A, 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allCycles = 32; // Stall CPU cycles
#endif
TMinxPRC_Render MinxPRC_Render = MinxPRC_Render_Mono;
//
// Functions
//
int MinxPRC_Create(void)
{
// Reset
MinxPRC_Reset(1);
return 1;
}
void MinxPRC_Destroy(void)
{
}
void MinxPRC_Reset(int hardreset)
{
// Initialize State
memset((void *)&MinxPRC, 0, sizeof(TMinxPRC));
// Initialize variables
StallCPU = 0;
MinxPRC.PRCRateMatch = 0x10;
}
int MinxPRC_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(1+32);
POKELOADSS_STREAM_8(StallCPU);
POKELOADSS_STREAM_32(MinxPRC.PRCCnt);
POKELOADSS_STREAM_32(MinxPRC.PRCBGBase);
POKELOADSS_STREAM_32(MinxPRC.PRCSprBase);
POKELOADSS_STREAM_8(MinxPRC.PRCMode);
POKELOADSS_STREAM_8(MinxPRC.PRCRateMatch);
POKELOADSS_STREAM_8(MinxPRC.PRCMapPX);
POKELOADSS_STREAM_8(MinxPRC.PRCMapPY);
POKELOADSS_STREAM_8(MinxPRC.PRCMapTW);
POKELOADSS_STREAM_8(MinxPRC.PRCMapTH);
POKELOADSS_STREAM_8(MinxPRC.PRCState);
POKELOADSS_STREAM_X(13);
POKELOADSS_END(1+32);
}
int MinxPRC_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(1+32);
POKESAVESS_STREAM_8(StallCPU);
POKESAVESS_STREAM_32(MinxPRC.PRCCnt);
POKESAVESS_STREAM_32(MinxPRC.PRCBGBase);
POKESAVESS_STREAM_32(MinxPRC.PRCSprBase);
POKESAVESS_STREAM_8(MinxPRC.PRCMode);
POKESAVESS_STREAM_8(MinxPRC.PRCRateMatch);
POKESAVESS_STREAM_8(MinxPRC.PRCMapPX);
POKESAVESS_STREAM_8(MinxPRC.PRCMapPY);
POKESAVESS_STREAM_8(MinxPRC.PRCMapTW);
POKESAVESS_STREAM_8(MinxPRC.PRCMapTH);
POKESAVESS_STREAM_8(MinxPRC.PRCState);
POKESAVESS_STREAM_X(13);
POKESAVESS_END(1+32);
}
void MinxPRC_Sync(void)
{
// Process PRC Counter
MinxPRC.PRCCnt += MINX_PRCTIMERINC * PokeHWCycles;
if ((PMR_PRC_RATE & 0xF0) >= MinxPRC.PRCRateMatch) {
// Active frame
if (MinxPRC.PRCCnt < 0x18000000) {
// CPU Time
MinxPRC.PRCState = 0;
} else if ((MinxPRC.PRCCnt & 0xFF000000) == 0x18000000) {
// PRC BG&SPR Trigger
if (MinxPRC.PRCState == 1) return;
if (MinxPRC.PRCMode == 2) {
if (PRCAllowStall) StallCPU = 1;
MinxPRC_Render();
MinxPRC.PRCState = 1;
} else if (PRCColorMap) MinxPRC_NoRender_Color();
} else if ((MinxPRC.PRCCnt & 0xFF000000) == 0x39000000) {
// PRC Copy Trigger
if (MinxPRC.PRCState == 2) return;
if (MinxPRC.PRCMode) {
if (PRCAllowStall) StallCPU = 1;
MinxPRC_CopyToLCD();
MinxCPU_OnIRQAct(MINX_INTR_03);
MinxPRC.PRCState = 2;
}
} else if (MinxPRC.PRCCnt >= 0x42000000) {
// End-of-frame
StallCPU = 0;
PMR_PRC_RATE &= 0x0F;
MinxPRC.PRCCnt = 0x01000000;
MinxCPU_OnIRQAct(MINX_INTR_04);
MinxPRC_On72HzRefresh(1);
}
} else {
// Non-active frame
if (MinxPRC.PRCCnt >= 0x42000000) {
PMR_PRC_RATE += 0x10;
MinxPRC.PRCCnt = 0x01000000;
MinxPRC_On72HzRefresh(0);
}
}
}
uint8_t MinxPRC_ReadReg(uint8_t reg)
{
// 0x80 to 0x8F
switch(reg) {
case 0x80: // PRC Stage Control
return PMR_PRC_MODE & 0x3F;
case 0x81: // PRC Rate Control
return PMR_PRC_RATE;
case 0x82: // PRC Map Tile Base (Lo)
return PMR_PRC_MAP_LO & 0xF8;
case 0x83: // PRC Map Tile Base (Med)
return PMR_PRC_MAP_MID;
case 0x84: // PRC Map Tile Base (Hi)
return PMR_PRC_MAP_HI & 0x1F;
case 0x85: // PRC Map Vertical Scroll
return PMR_PRC_SCROLL_Y & 0x7F;
case 0x86: // PRC Map Horizontal Scroll
return PMR_PRC_SCROLL_X & 0x7F;
case 0x87: // PRC Map Sprite Base (Lo)
return PMR_PRC_SPR_LO & 0xC0;
case 0x88: // PRC Map Sprite Base (Med)
return PMR_PRC_SPR_MID;
case 0x89: // PRC Map Sprite Base (Hi)
return PMR_PRC_SPR_HI & 0x1F;
case 0x8A: // PRC Counter
return MinxPRC.PRCCnt >> 24;
default: // Unused
return 0;
}
}
void MinxPRC_WriteReg(uint8_t reg, uint8_t val)
{
// 0x80 to 0x8F
switch(reg) {
case 0x80: // PRC Stage Control
PMR_PRC_MODE = val & 0x3F;
if (val & 0x08) {
MinxPRC.PRCMode = (val & 0x06) ? 2 : 1;
} else MinxPRC.PRCMode = 0;
switch (val & 0x30) {
case 0x00: MinxPRC.PRCMapTW = 12; MinxPRC.PRCMapTH = 16; break;
case 0x10: MinxPRC.PRCMapTW = 16; MinxPRC.PRCMapTH = 12; break;
case 0x20: MinxPRC.PRCMapTW = 24; MinxPRC.PRCMapTH = 8; break;
case 0x30: MinxPRC.PRCMapTW = 24; MinxPRC.PRCMapTH = 16; break;
}
return;
case 0x81: // PRC Rate Control
if ((PMR_PRC_RATE & 0x0E) != (val & 0x0E)) PMR_PRC_RATE = (val & 0x0F);
else PMR_PRC_RATE = (PMR_PRC_RATE & 0xF0) | (val & 0x0F);
switch (val & 0x0E) {
case 0x00: MinxPRC.PRCRateMatch = 0x20; break; // Rate /3
case 0x02: MinxPRC.PRCRateMatch = 0x50; break; // Rate /6
case 0x04: MinxPRC.PRCRateMatch = 0x80; break; // Rate /9
case 0x06: MinxPRC.PRCRateMatch = 0xB0; break; // Rate /12
case 0x08: MinxPRC.PRCRateMatch = 0x10; break; // Rate /2
case 0x0A: MinxPRC.PRCRateMatch = 0x30; break; // Rate /4
case 0x0C: MinxPRC.PRCRateMatch = 0x50; break; // Rate /6
case 0x0E: MinxPRC.PRCRateMatch = 0x70; break; // Rate /8
}
return;
case 0x82: // PRC Map Tile Base Low
PMR_PRC_MAP_LO = val & 0xF8;
MinxPRC.PRCBGBase = (MinxPRC.PRCBGBase & 0x1FFF00) | PMR_PRC_MAP_LO;
return;
case 0x83: // PRC Map Tile Base Middle
PMR_PRC_MAP_MID = val;
MinxPRC.PRCBGBase = (MinxPRC.PRCBGBase & 0x1F00F8) | (PMR_PRC_MAP_MID << 8);
return;
case 0x84: // PRC Map Tile Base High
PMR_PRC_MAP_HI = val & 0x1F;
MinxPRC.PRCBGBase = (MinxPRC.PRCBGBase & 0x00FFF8) | (PMR_PRC_MAP_HI << 16);
return;
case 0x85: // PRC Map Vertical Scroll
PMR_PRC_SCROLL_Y = val & 0x7F;
if (PMR_PRC_SCROLL_Y <= (MinxPRC.PRCMapTH*8-64)) MinxPRC.PRCMapPY = PMR_PRC_SCROLL_Y;
return;
case 0x86: // PRC Map Horizontal Scroll
PMR_PRC_SCROLL_X = val & 0x7F;
if (PMR_PRC_SCROLL_X <= (MinxPRC.PRCMapTW*8-96)) MinxPRC.PRCMapPX = PMR_PRC_SCROLL_X;
return;
case 0x87: // PRC Sprite Tile Base Low
PMR_PRC_SPR_LO = val & 0xC0;
MinxPRC.PRCSprBase = (MinxPRC.PRCSprBase & 0x1FFF00) | PMR_PRC_SPR_LO;
return;
case 0x88: // PRC Sprite Tile Base Middle
PMR_PRC_SPR_MID = val;
MinxPRC.PRCSprBase = (MinxPRC.PRCSprBase & 0x1F00C0) | (PMR_PRC_SPR_MID << 8);
return;
case 0x89: // PRC Sprite Tile Base High
PMR_PRC_SPR_HI = val & 0x1F;
MinxPRC.PRCSprBase = (MinxPRC.PRCSprBase & 0x00FFC0) | (PMR_PRC_SPR_HI << 16);
return;
case 0x8A: // PRC Counter
return;
}
}
//
// Default PRC Rendering
//
static INLINE void MinxPRC_DrawSprite8x8_Mono(uint8_t cfg, int X, int Y, int DrawT, int MaskT)
{
int xC, xP, vaddr;
uint8_t vdata, sdata, smask;
uint8_t data;
// No point to proceed if it's offscreen
if ((X < -7) || (X >= 96)) return;
if ((Y < -7) || (Y >= 64)) return;
// Pre calculate
vaddr = 0x1000 + ((Y >> 3) * 96) + X;
// Process top columns
if (Y >= 0) {
for (xC=0; xC<8; xC++) {
if ((X >= 0) && (X < 96)) {
xP = (cfg & 0x01) ? (7 - xC) : xC;
vdata = MinxPRC_OnRead(0, vaddr + xC);
sdata = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (DrawT * 8) + xP);
smask = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (MaskT * 8) + xP);
if (cfg & 0x02) {
sdata = PRCInvertBit[sdata];
smask = PRCInvertBit[smask];
}
if (cfg & 0x04) sdata = ~sdata;
data = vdata & ((smask << (Y & 7)) | (0xFF >> (8 - (Y & 7))));
data |= (sdata & ~smask) << (Y & 7);
MinxPRC_OnWrite(0, vaddr + xC, data);
}
X++;
}
X -= 8;
}
// Calculate new vaddr;
vaddr += 96;
// Process bottom columns
if ((Y < 56) && (Y & 7)) {
for (xC=0; xC<8; xC++) {
if ((X >= 0) && (X < 96)) {
xP = (cfg & 0x01) ? (7 - xC) : xC;
vdata = MinxPRC_OnRead(0, vaddr + xC);
sdata = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (DrawT * 8) + xP);
smask = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (MaskT * 8) + xP);
if (cfg & 0x02) {
sdata = PRCInvertBit[sdata];
smask = PRCInvertBit[smask];
}
if (cfg & 0x04) sdata = ~sdata;
data = vdata & ((smask >> (8-(Y & 7))) | (0xFF << (Y & 7)));
data |= (sdata & ~smask) >> (8-(Y & 7));
MinxPRC_OnWrite(0, vaddr + xC, data);
}
X++;
}
}
}
void MinxPRC_Render_Mono(void)
{
int xC, yC, tx, ty, ltileidxaddr, tileidxaddr, outaddr;
int tiletopaddr = 0, tilebotaddr = 0;
uint8_t data;
int SprTB, SprAddr;
int SprX, SprY, SprC;
int SprFX, SprFY;
if (PRCRenderBD) {
for (xC=0x1000; xC<0x1300; xC++) MinxPRC_OnWrite(0, xC, 0x00);
}
if ((PRCRenderBG) && (PMR_PRC_MODE & 0x02)) {
outaddr = 0x1000;
ltileidxaddr = -1;
for (yC=0; yC<8; yC++) {
ty = (yC << 3) + MinxPRC.PRCMapPY;
for (xC=0; xC<96; xC++) {
tx = xC + MinxPRC.PRCMapPX;
tileidxaddr = 0x1360 + (ty >> 3) * MinxPRC.PRCMapTW + (tx >> 3);
// Read tile index
if (ltileidxaddr != tileidxaddr) {
tiletopaddr = MinxPRC.PRCBGBase + (MinxPRC_OnRead(0, tileidxaddr) * 8);
tilebotaddr = MinxPRC.PRCBGBase + (MinxPRC_OnRead(0, tileidxaddr + MinxPRC.PRCMapTW) * 8);
ltileidxaddr = tileidxaddr;
}
// Read tile data
data = (MinxPRC_OnRead(0, tiletopaddr + (tx & 7)) >> (ty & 7))
| (MinxPRC_OnRead(0, tilebotaddr + (tx & 7)) << (8 - (ty & 7)));
// Write to VRAM
MinxPRC_OnWrite(0, outaddr++, (PMR_PRC_MODE & 0x01) ? ~data : data);
}
}
}
if ((PRCRenderSpr) && (PMR_PRC_MODE & 0x04)) {
SprAddr = 0x1300 + (24 * 4);
do {
SprC = MinxPRC_OnRead(0, --SprAddr);
SprTB = MinxPRC_OnRead(0, --SprAddr) * 8;
SprY = (MinxPRC_OnRead(0, --SprAddr) & 0x7F) - 16;
SprX = (MinxPRC_OnRead(0, --SprAddr) & 0x7F) - 16;
if (SprC & 0x08) {
SprFX = SprC & 0x01 ? 8 : 0;
SprFY = SprC & 0x02 ? 8 : 0;
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + SprFX, SprY + SprFY, SprTB+2, SprTB);
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + SprFX, SprY + 8 - SprFY, SprTB+3, SprTB+1);
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + 8 - SprFX, SprY + SprFY, SprTB+6, SprTB+4);
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + 8 - SprFX, SprY + 8 - SprFY, SprTB+7, SprTB+5);
}
} while (SprAddr > 0x1300);
}
}
void MinxPRC_CopyToLCD(void)
{
MinxLCD_LCDWritefb(MinxPRC_LCDfb);
/*
// Can't be used with the new color mode support for LCD
int i, j;
MinxLCD_LCDWriteCtrl(0xEE);
for (i=0; i<8; i++) {
MinxLCD_LCDWriteCtrl(0xB0 + i);
MinxLCD_LCDWriteCtrl(0x00);
MinxLCD_LCDWriteCtrl(0x10);
for (j=0; j<96; j++) {
MinxLCD_LCDWrite(MinxPRC_OnRead(0, 0x1000 + (i * 96) + j));
}
}
*/
}
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <retro_inline.h>
#include "PokeMini.h"
TMinxPRC MinxPRC;
int PRCAllowStall = 1; // Allow stall CPU?
int StallCPU = 0; // Stall CPU output flag
int PRCRenderBD = 0; // Render backdrop? (Background overrides backdrop)
int PRCRenderBG = 1; // Render background?
int PRCRenderSpr = 1; // Render sprites?
const uint8_t PRCInvertBit[256] = { // Invert Bit table
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
0x0C, 0x8C, 0x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0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
};
#ifdef PERFORMANCE
int StallCycles = 64; // Stall CPU cycles
#else
int StallCycles = 32; // Stall CPU cycles
#endif
TMinxPRC_Render MinxPRC_Render = MinxPRC_Render_Mono;
//
// Functions
//
int MinxPRC_Create(void)
{
// Reset
MinxPRC_Reset(1);
return 1;
}
void MinxPRC_Destroy(void)
{
}
void MinxPRC_Reset(int hardreset)
{
// Initialize State
memset((void *)&MinxPRC, 0, sizeof(TMinxPRC));
// Initialize variables
StallCPU = 0;
MinxPRC.PRCRateMatch = 0x10;
}
int MinxPRC_LoadStateStream(memstream_t *stream, uint32_t bsize)
{
POKELOADSS_START(1+32);
POKELOADSS_STREAM_8(StallCPU);
POKELOADSS_STREAM_32(MinxPRC.PRCCnt);
POKELOADSS_STREAM_32(MinxPRC.PRCBGBase);
POKELOADSS_STREAM_32(MinxPRC.PRCSprBase);
POKELOADSS_STREAM_8(MinxPRC.PRCMode);
POKELOADSS_STREAM_8(MinxPRC.PRCRateMatch);
POKELOADSS_STREAM_8(MinxPRC.PRCMapPX);
POKELOADSS_STREAM_8(MinxPRC.PRCMapPY);
POKELOADSS_STREAM_8(MinxPRC.PRCMapTW);
POKELOADSS_STREAM_8(MinxPRC.PRCMapTH);
POKELOADSS_STREAM_8(MinxPRC.PRCState);
POKELOADSS_STREAM_X(13);
POKELOADSS_END(1+32);
}
int MinxPRC_SaveStateStream(memstream_t *stream)
{
POKESAVESS_STREAM_START(1+32);
POKESAVESS_STREAM_8(StallCPU);
POKESAVESS_STREAM_32(MinxPRC.PRCCnt);
POKESAVESS_STREAM_32(MinxPRC.PRCBGBase);
POKESAVESS_STREAM_32(MinxPRC.PRCSprBase);
POKESAVESS_STREAM_8(MinxPRC.PRCMode);
POKESAVESS_STREAM_8(MinxPRC.PRCRateMatch);
POKESAVESS_STREAM_8(MinxPRC.PRCMapPX);
POKESAVESS_STREAM_8(MinxPRC.PRCMapPY);
POKESAVESS_STREAM_8(MinxPRC.PRCMapTW);
POKESAVESS_STREAM_8(MinxPRC.PRCMapTH);
POKESAVESS_STREAM_8(MinxPRC.PRCState);
POKESAVESS_STREAM_X(13);
POKESAVESS_END(1+32);
}
void MinxPRC_Sync(void)
{
// Process PRC Counter
MinxPRC.PRCCnt += MINX_PRCTIMERINC * PokeHWCycles;
if ((PMR_PRC_RATE & 0xF0) >= MinxPRC.PRCRateMatch) {
// Active frame
if (MinxPRC.PRCCnt < 0x18000000) {
// CPU Time
MinxPRC.PRCState = 0;
} else if ((MinxPRC.PRCCnt & 0xFF000000) == 0x18000000) {
// PRC BG&SPR Trigger
if (MinxPRC.PRCState == 1) return;
if (MinxPRC.PRCMode == 2) {
if (PRCAllowStall) StallCPU = 1;
MinxPRC_Render();
MinxPRC.PRCState = 1;
} else if (PRCColorMap) MinxPRC_NoRender_Color();
} else if ((MinxPRC.PRCCnt & 0xFF000000) == 0x39000000) {
// PRC Copy Trigger
if (MinxPRC.PRCState == 2) return;
if (MinxPRC.PRCMode) {
if (PRCAllowStall) StallCPU = 1;
MinxPRC_CopyToLCD();
MinxCPU_OnIRQAct(MINX_INTR_03);
MinxPRC.PRCState = 2;
}
} else if (MinxPRC.PRCCnt >= 0x42000000) {
// End-of-frame
StallCPU = 0;
PMR_PRC_RATE &= 0x0F;
MinxPRC.PRCCnt = 0x01000000;
MinxCPU_OnIRQAct(MINX_INTR_04);
MinxPRC_On72HzRefresh(1);
}
} else {
// Non-active frame
if (MinxPRC.PRCCnt >= 0x42000000) {
PMR_PRC_RATE += 0x10;
MinxPRC.PRCCnt = 0x01000000;
MinxPRC_On72HzRefresh(0);
}
}
}
uint8_t MinxPRC_ReadReg(uint8_t reg)
{
// 0x80 to 0x8F
switch(reg) {
case 0x80: // PRC Stage Control
return PMR_PRC_MODE & 0x3F;
case 0x81: // PRC Rate Control
return PMR_PRC_RATE;
case 0x82: // PRC Map Tile Base (Lo)
return PMR_PRC_MAP_LO & 0xF8;
case 0x83: // PRC Map Tile Base (Med)
return PMR_PRC_MAP_MID;
case 0x84: // PRC Map Tile Base (Hi)
return PMR_PRC_MAP_HI & 0x1F;
case 0x85: // PRC Map Vertical Scroll
return PMR_PRC_SCROLL_Y & 0x7F;
case 0x86: // PRC Map Horizontal Scroll
return PMR_PRC_SCROLL_X & 0x7F;
case 0x87: // PRC Map Sprite Base (Lo)
return PMR_PRC_SPR_LO & 0xC0;
case 0x88: // PRC Map Sprite Base (Med)
return PMR_PRC_SPR_MID;
case 0x89: // PRC Map Sprite Base (Hi)
return PMR_PRC_SPR_HI & 0x1F;
case 0x8A: // PRC Counter
return MinxPRC.PRCCnt >> 24;
default: // Unused
return 0;
}
}
void MinxPRC_WriteReg(uint8_t reg, uint8_t val)
{
// 0x80 to 0x8F
switch(reg) {
case 0x80: // PRC Stage Control
PMR_PRC_MODE = val & 0x3F;
if (val & 0x08) {
MinxPRC.PRCMode = (val & 0x06) ? 2 : 1;
} else MinxPRC.PRCMode = 0;
switch (val & 0x30) {
case 0x00: MinxPRC.PRCMapTW = 12; MinxPRC.PRCMapTH = 16; break;
case 0x10: MinxPRC.PRCMapTW = 16; MinxPRC.PRCMapTH = 12; break;
case 0x20: MinxPRC.PRCMapTW = 24; MinxPRC.PRCMapTH = 8; break;
case 0x30: MinxPRC.PRCMapTW = 24; MinxPRC.PRCMapTH = 16; break;
}
return;
case 0x81: // PRC Rate Control
if ((PMR_PRC_RATE & 0x0E) != (val & 0x0E)) PMR_PRC_RATE = (val & 0x0F);
else PMR_PRC_RATE = (PMR_PRC_RATE & 0xF0) | (val & 0x0F);
switch (val & 0x0E) {
case 0x00: MinxPRC.PRCRateMatch = 0x20; break; // Rate /3
case 0x02: MinxPRC.PRCRateMatch = 0x50; break; // Rate /6
case 0x04: MinxPRC.PRCRateMatch = 0x80; break; // Rate /9
case 0x06: MinxPRC.PRCRateMatch = 0xB0; break; // Rate /12
case 0x08: MinxPRC.PRCRateMatch = 0x10; break; // Rate /2
case 0x0A: MinxPRC.PRCRateMatch = 0x30; break; // Rate /4
case 0x0C: MinxPRC.PRCRateMatch = 0x50; break; // Rate /6
case 0x0E: MinxPRC.PRCRateMatch = 0x70; break; // Rate /8
}
return;
case 0x82: // PRC Map Tile Base Low
PMR_PRC_MAP_LO = val & 0xF8;
MinxPRC.PRCBGBase = (MinxPRC.PRCBGBase & 0x1FFF00) | PMR_PRC_MAP_LO;
return;
case 0x83: // PRC Map Tile Base Middle
PMR_PRC_MAP_MID = val;
MinxPRC.PRCBGBase = (MinxPRC.PRCBGBase & 0x1F00F8) | (PMR_PRC_MAP_MID << 8);
return;
case 0x84: // PRC Map Tile Base High
PMR_PRC_MAP_HI = val & 0x1F;
MinxPRC.PRCBGBase = (MinxPRC.PRCBGBase & 0x00FFF8) | (PMR_PRC_MAP_HI << 16);
return;
case 0x85: // PRC Map Vertical Scroll
PMR_PRC_SCROLL_Y = val & 0x7F;
if (PMR_PRC_SCROLL_Y <= (MinxPRC.PRCMapTH*8-64)) MinxPRC.PRCMapPY = PMR_PRC_SCROLL_Y;
return;
case 0x86: // PRC Map Horizontal Scroll
PMR_PRC_SCROLL_X = val & 0x7F;
if (PMR_PRC_SCROLL_X <= (MinxPRC.PRCMapTW*8-96)) MinxPRC.PRCMapPX = PMR_PRC_SCROLL_X;
return;
case 0x87: // PRC Sprite Tile Base Low
PMR_PRC_SPR_LO = val & 0xC0;
MinxPRC.PRCSprBase = (MinxPRC.PRCSprBase & 0x1FFF00) | PMR_PRC_SPR_LO;
return;
case 0x88: // PRC Sprite Tile Base Middle
PMR_PRC_SPR_MID = val;
MinxPRC.PRCSprBase = (MinxPRC.PRCSprBase & 0x1F00C0) | (PMR_PRC_SPR_MID << 8);
return;
case 0x89: // PRC Sprite Tile Base High
PMR_PRC_SPR_HI = val & 0x1F;
MinxPRC.PRCSprBase = (MinxPRC.PRCSprBase & 0x00FFC0) | (PMR_PRC_SPR_HI << 16);
return;
case 0x8A: // PRC Counter
return;
}
}
//
// Default PRC Rendering
//
static INLINE void MinxPRC_DrawSprite8x8_Mono(uint8_t cfg, int X, int Y, int DrawT, int MaskT)
{
int xC, xP, vaddr;
uint8_t vdata, sdata, smask;
uint8_t data;
// No point to proceed if it's offscreen
if ((X < -7) || (X >= 96)) return;
if ((Y < -7) || (Y >= 64)) return;
// Pre calculate
vaddr = 0x1000 + ((Y >> 3) * 96) + X;
// Process top columns
if (Y >= 0) {
for (xC=0; xC<8; xC++) {
if ((X >= 0) && (X < 96)) {
xP = (cfg & 0x01) ? (7 - xC) : xC;
vdata = MinxPRC_OnRead(0, vaddr + xC);
sdata = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (DrawT * 8) + xP);
smask = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (MaskT * 8) + xP);
if (cfg & 0x02) {
sdata = PRCInvertBit[sdata];
smask = PRCInvertBit[smask];
}
if (cfg & 0x04) sdata = ~sdata;
data = vdata & ((smask << (Y & 7)) | (0xFF >> (8 - (Y & 7))));
data |= (sdata & ~smask) << (Y & 7);
MinxPRC_OnWrite(0, vaddr + xC, data);
}
X++;
}
X -= 8;
}
// Calculate new vaddr;
vaddr += 96;
// Process bottom columns
if ((Y < 56) && (Y & 7)) {
for (xC=0; xC<8; xC++) {
if ((X >= 0) && (X < 96)) {
xP = (cfg & 0x01) ? (7 - xC) : xC;
vdata = MinxPRC_OnRead(0, vaddr + xC);
sdata = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (DrawT * 8) + xP);
smask = MinxPRC_OnRead(0, MinxPRC.PRCSprBase + (MaskT * 8) + xP);
if (cfg & 0x02) {
sdata = PRCInvertBit[sdata];
smask = PRCInvertBit[smask];
}
if (cfg & 0x04) sdata = ~sdata;
data = vdata & ((smask >> (8-(Y & 7))) | (0xFF << (Y & 7)));
data |= (sdata & ~smask) >> (8-(Y & 7));
MinxPRC_OnWrite(0, vaddr + xC, data);
}
X++;
}
}
}
void MinxPRC_Render_Mono(void)
{
int xC, yC, tx, ty, ltileidxaddr, tileidxaddr, outaddr;
int tiletopaddr = 0, tilebotaddr = 0;
uint8_t data;
int SprTB, SprAddr;
int SprX, SprY, SprC;
int SprFX, SprFY;
if (PRCRenderBD) {
for (xC=0x1000; xC<0x1300; xC++) MinxPRC_OnWrite(0, xC, 0x00);
}
if ((PRCRenderBG) && (PMR_PRC_MODE & 0x02)) {
outaddr = 0x1000;
ltileidxaddr = -1;
for (yC=0; yC<8; yC++) {
ty = (yC << 3) + MinxPRC.PRCMapPY;
for (xC=0; xC<96; xC++) {
tx = xC + MinxPRC.PRCMapPX;
tileidxaddr = 0x1360 + (ty >> 3) * MinxPRC.PRCMapTW + (tx >> 3);
// Read tile index
if (ltileidxaddr != tileidxaddr) {
tiletopaddr = MinxPRC.PRCBGBase + (MinxPRC_OnRead(0, tileidxaddr) * 8);
tilebotaddr = MinxPRC.PRCBGBase + (MinxPRC_OnRead(0, tileidxaddr + MinxPRC.PRCMapTW) * 8);
ltileidxaddr = tileidxaddr;
}
// Read tile data
data = (MinxPRC_OnRead(0, tiletopaddr + (tx & 7)) >> (ty & 7))
| (MinxPRC_OnRead(0, tilebotaddr + (tx & 7)) << (8 - (ty & 7)));
// Write to VRAM
MinxPRC_OnWrite(0, outaddr++, (PMR_PRC_MODE & 0x01) ? ~data : data);
}
}
}
if ((PRCRenderSpr) && (PMR_PRC_MODE & 0x04)) {
SprAddr = 0x1300 + (24 * 4);
do {
SprC = MinxPRC_OnRead(0, --SprAddr);
SprTB = MinxPRC_OnRead(0, --SprAddr) * 8;
SprY = (MinxPRC_OnRead(0, --SprAddr) & 0x7F) - 16;
SprX = (MinxPRC_OnRead(0, --SprAddr) & 0x7F) - 16;
if (SprC & 0x08) {
SprFX = SprC & 0x01 ? 8 : 0;
SprFY = SprC & 0x02 ? 8 : 0;
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + SprFX, SprY + SprFY, SprTB+2, SprTB);
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + SprFX, SprY + 8 - SprFY, SprTB+3, SprTB+1);
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + 8 - SprFX, SprY + SprFY, SprTB+6, SprTB+4);
MinxPRC_DrawSprite8x8_Mono(SprC, SprX + 8 - SprFX, SprY + 8 - SprFY, SprTB+7, SprTB+5);
}
} while (SprAddr > 0x1300);
}
}
void MinxPRC_CopyToLCD(void)
{
MinxLCD_LCDWritefb(MinxPRC_LCDfb);
/*
// Can't be used with the new color mode support for LCD
int i, j;
MinxLCD_LCDWriteCtrl(0xEE);
for (i=0; i<8; i++) {
MinxLCD_LCDWriteCtrl(0xB0 + i);
MinxLCD_LCDWriteCtrl(0x00);
MinxLCD_LCDWriteCtrl(0x10);
for (j=0; j<96; j++) {
MinxLCD_LCDWrite(MinxPRC_OnRead(0, 0x1000 + (i * 96) + j));
}
}
*/
}
+101 -101
View File
@@ -1,101 +1,101 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_PRC
#define MINXHW_PRC
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
int32_t PRCCnt; // PRC Counter 8.24 (Need signed)
uint32_t PRCBGBase; // PRC Map Tile Base
uint32_t PRCSprBase; // PRC Sprite Base
uint8_t PRCMode; // PRC Mode (0 = Off, 1 = Copy, 3 = BG+Spr+Copy)
uint8_t PRCRateMatch; // PRC Rate Match
uint8_t PRCMapPX; // PRC Map X (Pixels)
uint8_t PRCMapPY; // PRC Map Y (Pixels)
uint8_t PRCMapTW; // PRC Map Width (Tiles)
uint8_t PRCMapTH; // PRC Map Height (Tiles)
uint8_t PRCState; // PRC State
} TMinxPRC;
typedef void (*TMinxPRC_Render)(void);
// Export PRC state
extern TMinxPRC MinxPRC;
// Invert bit table
extern const uint8_t PRCInvertBit[256];
// Stall CPU
extern int PRCAllowStall;
extern int StallCPU;
extern int StallCycles;
// Render backdrop? (Background overrides backdrop)
extern int PRCRenderBD;
// Render background?
extern int PRCRenderBG;
// Render sprites?
extern int PRCRenderSpr;
// Render callback
extern TMinxPRC_Render MinxPRC_Render;
enum {
MINX_INTR_03 = 0x03, // PRC Copy Complete
MINX_INTR_04 = 0x04 // PRC Frame Divider Overflow
};
// Aproximate value of PRC Timer (~4678 Hz) (16M / ( 4M / 855 ))
#define MINX_PRCTIMERINC (16777216/855)
int MinxPRC_Create(void);
void MinxPRC_Destroy(void);
void MinxPRC_Reset(int hardreset);
int MinxPRC_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxPRC_SaveStateStream(memstream_t *stream);
void MinxPRC_Sync(void);
uint8_t MinxPRC_ReadReg(uint8_t reg);
void MinxPRC_WriteReg(uint8_t reg, uint8_t val);
//
// Internals
//
void MinxPRC_Render_Mono(void);
void MinxPRC_CopyToLCD(void);
//
// Callbacks (Written by the user)
//
void MinxPRC_On72HzRefresh(int render);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_PRC
#define MINXHW_PRC
#include <stdint.h>
#include <streams/memory_stream.h>
typedef struct {
// Internal processing
int32_t PRCCnt; // PRC Counter 8.24 (Need signed)
uint32_t PRCBGBase; // PRC Map Tile Base
uint32_t PRCSprBase; // PRC Sprite Base
uint8_t PRCMode; // PRC Mode (0 = Off, 1 = Copy, 3 = BG+Spr+Copy)
uint8_t PRCRateMatch; // PRC Rate Match
uint8_t PRCMapPX; // PRC Map X (Pixels)
uint8_t PRCMapPY; // PRC Map Y (Pixels)
uint8_t PRCMapTW; // PRC Map Width (Tiles)
uint8_t PRCMapTH; // PRC Map Height (Tiles)
uint8_t PRCState; // PRC State
} TMinxPRC;
typedef void (*TMinxPRC_Render)(void);
// Export PRC state
extern TMinxPRC MinxPRC;
// Invert bit table
extern const uint8_t PRCInvertBit[256];
// Stall CPU
extern int PRCAllowStall;
extern int StallCPU;
extern int StallCycles;
// Render backdrop? (Background overrides backdrop)
extern int PRCRenderBD;
// Render background?
extern int PRCRenderBG;
// Render sprites?
extern int PRCRenderSpr;
// Render callback
extern TMinxPRC_Render MinxPRC_Render;
enum {
MINX_INTR_03 = 0x03, // PRC Copy Complete
MINX_INTR_04 = 0x04 // PRC Frame Divider Overflow
};
// Aproximate value of PRC Timer (~4678 Hz) (16M / ( 4M / 855 ))
#define MINX_PRCTIMERINC (16777216/855)
int MinxPRC_Create(void);
void MinxPRC_Destroy(void);
void MinxPRC_Reset(int hardreset);
int MinxPRC_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxPRC_SaveStateStream(memstream_t *stream);
void MinxPRC_Sync(void);
uint8_t MinxPRC_ReadReg(uint8_t reg);
void MinxPRC_WriteReg(uint8_t reg, uint8_t val);
//
// Internals
//
void MinxPRC_Render_Mono(void);
void MinxPRC_CopyToLCD(void);
//
// Callbacks (Written by the user)
//
void MinxPRC_On72HzRefresh(int render);
#endif
+691 -691
View File
File diff suppressed because it is too large. Load diff
+127 -127
View File
@@ -1,127 +1,127 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_TIMERS
#define MINXHW_TIMERS
#include <stdint.h>
#include <streams/memory_stream.h>
/* For some reason, '_BIG_ENDIAN' is always defined when
* building for 3DS/Switch with devkitarm/a64... */
#if defined (_BIG_ENDIAN) && !defined (_3DS) && !defined(HAVE_LIBNX)
typedef union {
struct {
uint8_t H;
uint8_t L;
} B;
uint16_t W;
} MinxWord;
#else
typedef union {
struct {
uint8_t L;
uint8_t H;
} B;
uint16_t W;
} MinxWord;
#endif
typedef struct {
// Internal processing
uint32_t SecTimerCnt; // Second Timer Counter
int32_t TmrSecs; // Second Timer Fraction (Cycles, needs signed)
uint32_t Tmr1DecA; // Timer 1-Lo Decrement 8.24
uint32_t Tmr1DecB; // Timer 1-Hi Decrement 8.24
uint32_t Tmr1CntA; // Timer 1-Lo Counter 8.24
uint32_t Tmr1CntB; // Timer 1-Hi Counter 8.24
uint32_t Tmr1PreA; // Timer 1-Lo Preset 8.24
uint32_t Tmr1PreB; // Timer 1-Hi Preset 8.24
uint32_t Tmr2DecA; // Timer 2-Lo Decrement 8.24
uint32_t Tmr2DecB; // Timer 2-Hi Decrement 8.24
uint32_t Tmr2CntA; // Timer 2-Lo Counter 8.24
uint32_t Tmr2CntB; // Timer 2-Hi Counter 8.24
uint32_t Tmr2PreA; // Timer 2-Lo Preset 8.24
uint32_t Tmr2PreB; // Timer 2-Hi Preset 8.24
uint32_t Tmr3DecA; // Timer 3-Lo Decrement 8.24
uint32_t Tmr3DecB; // Timer 3-Hi Decrement 8.24
uint32_t Tmr3CntA; // Timer 3-Lo Counter 8.24
uint32_t Tmr3CntB; // Timer 3-Hi Counter 8.24
uint32_t Tmr3PreA; // Timer 3-Lo Preset 8.24
uint32_t Tmr3PreB; // Timer 3-Hi Preset 8.24
uint32_t Tmr8Cnt; // 256Hz Timer Counter 8.24
uint32_t PRCCnt; // PRC Counter 8.24
MinxWord Tmr3Cnt16; // Timer 3 16-Bits count
uint16_t Timer3Piv; // Timer 3 Pivot
uint8_t TmrXEna2; // Oscillator 2 Enabled
uint8_t TmrXEna1; // Oscillator 1 Enabled
// Performance cache
int Tmr1WMode; // Timer 1 16-bits mode
int Tmr1LEna; // Timer 1 low enable
int Tmr1HEna; // Timer 1 high enable
int Tmr2WMode; // Timer 2 16-bits mode
int Tmr2LEna; // Timer 2 low enable
int Tmr2HEna; // Timer 2 high enable
int Tmr3WMode; // Timer 3 16-bits mode
int Tmr3LEna; // Timer 3 low enable
int Tmr3HEna; // Timer 3 high enable
} TMinxTimers;
// Export Timers state
extern TMinxTimers MinxTimers;
// Interrupt table
enum {
MINX_INTR_05 = 0x05, // Timer 2-B Underflow
MINX_INTR_06 = 0x06, // Timer 2-A Underflow (8-Bits only)
MINX_INTR_07 = 0x07, // Timer 1-B Underflow
MINX_INTR_08 = 0x08, // Timer 1-A Underflow (8-Bits only)
MINX_INTR_09 = 0x09, // Timer 3 Underflow
MINX_INTR_0A = 0x0A, // Timer 3 Pivot
MINX_INTR_0B = 0x0B, // 32 Hz
MINX_INTR_0C = 0x0C, // 8 Hz
MINX_INTR_0D = 0x0D, // 2 Hz
MINX_INTR_0E = 0x0E // 1 Hz
};
#define MINX_TIMER256INC (16777216/15625) // Aproximate value of 256Hz Timer (256 Hz)
// Timers counting frequency table
extern const uint32_t MinxTimers_CountFreq[32];
int MinxTimers_Create(void);
void MinxTimers_Destroy(void);
void MinxTimers_Reset(int hardreset);
int MinxTimers_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxTimers_SaveStateStream(memstream_t *stream);
void MinxTimers_Sync(void);
uint8_t MinxTimers_ReadReg(uint8_t reg);
void MinxTimers_WriteReg(unsigned char reg, unsigned char val);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MINXHW_TIMERS
#define MINXHW_TIMERS
#include <stdint.h>
#include <streams/memory_stream.h>
/* For some reason, '_BIG_ENDIAN' is always defined when
* building for 3DS/Switch with devkitarm/a64... */
#if defined (_BIG_ENDIAN) && !defined (_3DS) && !defined(HAVE_LIBNX)
typedef union {
struct {
uint8_t H;
uint8_t L;
} B;
uint16_t W;
} MinxWord;
#else
typedef union {
struct {
uint8_t L;
uint8_t H;
} B;
uint16_t W;
} MinxWord;
#endif
typedef struct {
// Internal processing
uint32_t SecTimerCnt; // Second Timer Counter
int32_t TmrSecs; // Second Timer Fraction (Cycles, needs signed)
uint32_t Tmr1DecA; // Timer 1-Lo Decrement 8.24
uint32_t Tmr1DecB; // Timer 1-Hi Decrement 8.24
uint32_t Tmr1CntA; // Timer 1-Lo Counter 8.24
uint32_t Tmr1CntB; // Timer 1-Hi Counter 8.24
uint32_t Tmr1PreA; // Timer 1-Lo Preset 8.24
uint32_t Tmr1PreB; // Timer 1-Hi Preset 8.24
uint32_t Tmr2DecA; // Timer 2-Lo Decrement 8.24
uint32_t Tmr2DecB; // Timer 2-Hi Decrement 8.24
uint32_t Tmr2CntA; // Timer 2-Lo Counter 8.24
uint32_t Tmr2CntB; // Timer 2-Hi Counter 8.24
uint32_t Tmr2PreA; // Timer 2-Lo Preset 8.24
uint32_t Tmr2PreB; // Timer 2-Hi Preset 8.24
uint32_t Tmr3DecA; // Timer 3-Lo Decrement 8.24
uint32_t Tmr3DecB; // Timer 3-Hi Decrement 8.24
uint32_t Tmr3CntA; // Timer 3-Lo Counter 8.24
uint32_t Tmr3CntB; // Timer 3-Hi Counter 8.24
uint32_t Tmr3PreA; // Timer 3-Lo Preset 8.24
uint32_t Tmr3PreB; // Timer 3-Hi Preset 8.24
uint32_t Tmr8Cnt; // 256Hz Timer Counter 8.24
uint32_t PRCCnt; // PRC Counter 8.24
MinxWord Tmr3Cnt16; // Timer 3 16-Bits count
uint16_t Timer3Piv; // Timer 3 Pivot
uint8_t TmrXEna2; // Oscillator 2 Enabled
uint8_t TmrXEna1; // Oscillator 1 Enabled
// Performance cache
int Tmr1WMode; // Timer 1 16-bits mode
int Tmr1LEna; // Timer 1 low enable
int Tmr1HEna; // Timer 1 high enable
int Tmr2WMode; // Timer 2 16-bits mode
int Tmr2LEna; // Timer 2 low enable
int Tmr2HEna; // Timer 2 high enable
int Tmr3WMode; // Timer 3 16-bits mode
int Tmr3LEna; // Timer 3 low enable
int Tmr3HEna; // Timer 3 high enable
} TMinxTimers;
// Export Timers state
extern TMinxTimers MinxTimers;
// Interrupt table
enum {
MINX_INTR_05 = 0x05, // Timer 2-B Underflow
MINX_INTR_06 = 0x06, // Timer 2-A Underflow (8-Bits only)
MINX_INTR_07 = 0x07, // Timer 1-B Underflow
MINX_INTR_08 = 0x08, // Timer 1-A Underflow (8-Bits only)
MINX_INTR_09 = 0x09, // Timer 3 Underflow
MINX_INTR_0A = 0x0A, // Timer 3 Pivot
MINX_INTR_0B = 0x0B, // 32 Hz
MINX_INTR_0C = 0x0C, // 8 Hz
MINX_INTR_0D = 0x0D, // 2 Hz
MINX_INTR_0E = 0x0E // 1 Hz
};
#define MINX_TIMER256INC (16777216/15625) // Aproximate value of 256Hz Timer (256 Hz)
// Timers counting frequency table
extern const uint32_t MinxTimers_CountFreq[32];
int MinxTimers_Create(void);
void MinxTimers_Destroy(void);
void MinxTimers_Reset(int hardreset);
int MinxTimers_LoadStateStream(memstream_t *stream, uint32_t bsize);
int MinxTimers_SaveStateStream(memstream_t *stream);
void MinxTimers_Sync(void);
uint8_t MinxTimers_ReadReg(uint8_t reg);
void MinxTimers_WriteReg(unsigned char reg, unsigned char val);
#endif
+49 -49
View File
@@ -1,49 +1,49 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef POKEMINI_MULTICART
#define POKEMINI_MULTICART
#include <stdint.h>
typedef uint8_t (*TMulticartRead)(uint32_t addr);
typedef void (*TMulticartWrite)(uint32_t addr, uint8_t data);
// Multicart read/write
extern TMulticartRead MulticartRead;
extern TMulticartWrite MulticartWrite;
// Multicart state
extern int PM_MM_Type;
extern int PM_MM_Dirty;
extern int PM_MM_BusCycle;
extern int PM_MM_GetID;
extern int PM_MM_Bypass;
extern int PM_MM_Command;
extern uint32_t PM_MM_Offset;
// For misc information
extern uint32_t PM_MM_LastErase_Start;
extern uint32_t PM_MM_LastErase_End;
extern uint32_t PM_MM_LastProg;
// Set multicart
void NewMulticart(void);
void SetMulticart(int type);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2012 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef POKEMINI_MULTICART
#define POKEMINI_MULTICART
#include <stdint.h>
typedef uint8_t (*TMulticartRead)(uint32_t addr);
typedef void (*TMulticartWrite)(uint32_t addr, uint8_t data);
// Multicart read/write
extern TMulticartRead MulticartRead;
extern TMulticartWrite MulticartWrite;
// Multicart state
extern int PM_MM_Type;
extern int PM_MM_Dirty;
extern int PM_MM_BusCycle;
extern int PM_MM_GetID;
extern int PM_MM_Bypass;
extern int PM_MM_Command;
extern uint32_t PM_MM_Offset;
// For misc information
extern uint32_t PM_MM_LastErase_Start;
extern uint32_t PM_MM_LastErase_End;
extern uint32_t PM_MM_LastProg;
// Set multicart
void NewMulticart(void);
void SetMulticart(int type);
#endif
+48 -48
View File
@@ -1,48 +1,48 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2014 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PMCOMMON_H
#define PMCOMMON_H
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdint.h>
#include <retro_inline.h>
// Temporary variable length
// Minimum is 128
// Recommended is 256
#ifndef PMTMPV
#define PMTMPV 512
#endif
// Return true if the string is valid and non-empty
int StringIsSet(char *str);
// Get multiple of 2 (Mask)
int GetMultiple2Mask(int input);
// Check if file exist
int FileExist(const char *filename);
// Directories
void PokeMini_InitDirs(char *argv0, char *exec);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2014 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PMCOMMON_H
#define PMCOMMON_H
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdint.h>
#include <retro_inline.h>
// Temporary variable length
// Minimum is 128
// Recommended is 256
#ifndef PMTMPV
#define PMTMPV 512
#endif
// Return true if the string is valid and non-empty
int StringIsSet(char *str);
// Get multiple of 2 (Mask)
int GetMultiple2Mask(int input);
// Check if file exist
int FileExist(const char *filename);
// Directories
void PokeMini_InitDirs(char *argv0, char *exec);
#endif
+242 -242
View File
@@ -1,242 +1,242 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef POKEMINI_EMU
#define POKEMINI_EMU
#include <stdint.h>
#include <stdlib.h>
#include <retro_inline.h>
#include <streams/memory_stream.h>
// Common functions
#include "PMCommon.h"
// Configuration Flags
// Generated sound only
#define POKEMINI_GENSOUND 0x02
extern int PokeMini_FreeBIOS; // Using freebios?
extern int PokeMini_Flags; // Configuration flags
extern int PokeMini_Rumbling; // Pokemon-Mini is rumbling
extern uint8_t PM_BIOS[]; // Pokemon-Mini BIOS ($000000 to $000FFF, 4096)
extern uint8_t PM_RAM[]; // Pokemon-Mini RAM ($001000 to $002100, 4096 + 256)
extern uint8_t *PM_ROM; // Pokemon-Mini ROM ($002100 to $1FFFFF, Up to 2MB)
extern int PM_ROM_Alloc; // Pokemon-Mini ROM Allocated on memory?
extern int PM_ROM_Size; // Pokemon-Mini ROM Size
extern int PM_ROM_Mask; // Pokemon-Mini ROM Mask
extern int PokeMini_LCDMode; // LCD Mode
extern int PokeMini_ColorFormat; // Color Format (0 = 8x8, 1 = 4x4)
extern int PokeMini_HostBattStatus; // Host battery status
// Number of cycles to process on hardware
extern int PokeHWCycles;
enum {
LCDMODE_ANALOG = 0,
LCDMODE_3SHADES,
LCDMODE_2SHADES,
LCDMODE_COLORS
};
// Include Interfaces
#include "IOMap.h"
#include "MinxCPU.h"
#include "MinxTimers.h"
#include "MinxIO.h"
#include "MinxIRQ.h"
#include "MinxPRC.h"
#include "MinxColorPRC.h"
#include "MinxLCD.h"
#include "MinxAudio.h"
#include "Multicart.h"
// PRC Read/Write
#ifdef PERFORMANCE
static INLINE uint8_t MinxPRC_OnRead(int cpu, uint32_t addr)
{
if (addr >= 0x2100) {
// ROM Read
if (PM_ROM) return PM_ROM[addr & PM_ROM_Mask];
} else if (addr >= 0x2000) {
// I/O Read (Unused)
return 0xFF;
} else if (addr >= 0x1000) {
// RAM Read
return PM_RAM[addr-0x1000];
} else {
// BIOS Read
return PM_BIOS[addr];
}
return 0xFF;
}
static INLINE void MinxPRC_OnWrite(int cpu, uint32_t addr, uint8_t data)
{
// RAM Write
if ((addr >= 0x1000) && (addr < 0x2000))
PM_RAM[addr-0x1000] = data;
}
#else
#include "Multicart.h"
#define MinxPRC_OnRead MinxCPU_OnRead
#define MinxPRC_OnWrite MinxCPU_OnWrite
#endif
// LCD Framebuffer
#define MinxPRC_LCDfb PM_RAM
// Load state safe variables
#define POKELOADSS_START(size)\
uint32_t rsize = 0;\
uint32_t tmp32;\
uint16_t tmp16;\
if (size != bsize) return 0;\
{ tmp32 = 0; tmp16 = 0; }
// -- Stream versions START
#define POKELOADSS_STREAM_32(var) {\
rsize += (uint32_t)memstream_read(stream, (void *)&tmp32, 4);\
var = tmp32;\
}
#define POKELOADSS_STREAM_16(var) {\
rsize += (uint32_t)memstream_read(stream, (void *)&tmp16, 2);\
var = tmp16;\
}
#define POKELOADSS_STREAM_8(var) {\
rsize += (uint32_t)memstream_read(stream, (void *)&var, 1);\
}
#define POKELOADSS_STREAM_A(array, size) {\
rsize += (uint32_t)memstream_read(stream, (void *)array, size);\
}
#define POKE_SEEK_CUR 1
#define POKELOADSS_STREAM_X(size) {\
rsize += memstream_seek(stream, size, POKE_SEEK_CUR) ? 0 : size;\
}
// -- Stream versions End
#define POKELOADSS_END(size) {\
tmp32 = 0; tmp16 = 0;\
return (rsize == size) + tmp32 + (uint32_t)tmp16;\
}
// -- Stream versions START
#define POKESAVESS_STREAM_START(size)\
uint32_t wsize = 0;\
uint32_t tmp32 = size;\
uint16_t tmp16;\
if (memstream_write(stream, (void *)&tmp32, 4) != 4) return 0;\
{ tmp32 = 0; tmp16 = 0; }
#define POKESAVESS_STREAM_32(var) {\
tmp32 = (uint32_t)var;\
wsize += (uint32_t)memstream_write(stream, (void *)&tmp32, 4);\
}
#define POKESAVESS_STREAM_16(var) {\
tmp16 = (uint16_t)var;\
wsize += (uint32_t)memstream_write(stream, (void *)&tmp16, 2);\
}
#define POKESAVESS_STREAM_8(var) {\
wsize += (uint32_t)memstream_write(stream, (void *)&var, 1);\
}
#define POKESAVESS_STREAM_A(array, size) {\
wsize += (uint32_t)memstream_write(stream, (void *)array, size);\
}
#define POKESAVESS_STREAM_X(size) {\
tmp16 = 0;\
for (tmp32=0; tmp32<(uint32_t)size; tmp32++) {\
wsize += (uint32_t)memstream_write(stream, (void *)&tmp16, 1);\
}\
}
// -- Stream versions End
#define POKESAVESS_END(size) {\
tmp32 = 0; tmp16 = 0;\
return (wsize == size) + tmp32 + (uint32_t)tmp16;\
}
// Stream I/O
typedef int TPokeMini_StreamIO(void *data, int size, void *ptr);
// Create emulator and all interfaces
int PokeMini_Create(int flags, int soundfifo);
// Destroy emulator and all interfaces
void PokeMini_Destroy(void);
// Apply changes from command lines
void PokeMini_ApplyChanges(void);
// Low power battery emulation
void PokeMini_LowPower(int enable);
// Set LCD mode
void PokeMini_SetLCDMode(int mode);
// Generate rumble offset
int PokeMini_GenRumbleOffset(int pitch);
// Load BIOS file
int PokeMini_LoadBIOSFile(const char *filename);
// Load FreeBIOS
int PokeMini_LoadFreeBIOS(void);
// Check if file exist
int PokeMini_FileExist(const char *filename);
// New MIN ROM
int PokeMini_NewMIN(uint32_t size);
// Synchronize host time
int PokeMini_SyncHostTime(void);
// Load EEPROM data
int PokeMini_LoadEEPROMFile(const char *filename);
// Save EEPROM data
int PokeMini_SaveEEPROMFile(const char *filename);
// Load emulator state from memory stream
int PokeMini_LoadSSStream(uint8_t *buffer, uint64_t size);
// Save emulator state to memory stream
int PokeMini_SaveSSStream(uint8_t *buffer, uint64_t size);
// Reset CPU
void PokeMini_Reset(int hardreset);
// Internals, do not call directly!
void PokeMini_FreeColorInfo(void);
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009-2015 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef POKEMINI_EMU
#define POKEMINI_EMU
#include <stdint.h>
#include <stdlib.h>
#include <retro_inline.h>
#include <streams/memory_stream.h>
// Common functions
#include "PMCommon.h"
// Configuration Flags
// Generated sound only
#define POKEMINI_GENSOUND 0x02
extern int PokeMini_FreeBIOS; // Using freebios?
extern int PokeMini_Flags; // Configuration flags
extern int PokeMini_Rumbling; // Pokemon-Mini is rumbling
extern uint8_t PM_BIOS[]; // Pokemon-Mini BIOS ($000000 to $000FFF, 4096)
extern uint8_t PM_RAM[]; // Pokemon-Mini RAM ($001000 to $002100, 4096 + 256)
extern uint8_t *PM_ROM; // Pokemon-Mini ROM ($002100 to $1FFFFF, Up to 2MB)
extern int PM_ROM_Alloc; // Pokemon-Mini ROM Allocated on memory?
extern int PM_ROM_Size; // Pokemon-Mini ROM Size
extern int PM_ROM_Mask; // Pokemon-Mini ROM Mask
extern int PokeMini_LCDMode; // LCD Mode
extern int PokeMini_ColorFormat; // Color Format (0 = 8x8, 1 = 4x4)
extern int PokeMini_HostBattStatus; // Host battery status
// Number of cycles to process on hardware
extern int PokeHWCycles;
enum {
LCDMODE_ANALOG = 0,
LCDMODE_3SHADES,
LCDMODE_2SHADES,
LCDMODE_COLORS
};
// Include Interfaces
#include "IOMap.h"
#include "MinxCPU.h"
#include "MinxTimers.h"
#include "MinxIO.h"
#include "MinxIRQ.h"
#include "MinxPRC.h"
#include "MinxColorPRC.h"
#include "MinxLCD.h"
#include "MinxAudio.h"
#include "Multicart.h"
// PRC Read/Write
#ifdef PERFORMANCE
static INLINE uint8_t MinxPRC_OnRead(int cpu, uint32_t addr)
{
if (addr >= 0x2100) {
// ROM Read
if (PM_ROM) return PM_ROM[addr & PM_ROM_Mask];
} else if (addr >= 0x2000) {
// I/O Read (Unused)
return 0xFF;
} else if (addr >= 0x1000) {
// RAM Read
return PM_RAM[addr-0x1000];
} else {
// BIOS Read
return PM_BIOS[addr];
}
return 0xFF;
}
static INLINE void MinxPRC_OnWrite(int cpu, uint32_t addr, uint8_t data)
{
// RAM Write
if ((addr >= 0x1000) && (addr < 0x2000))
PM_RAM[addr-0x1000] = data;
}
#else
#include "Multicart.h"
#define MinxPRC_OnRead MinxCPU_OnRead
#define MinxPRC_OnWrite MinxCPU_OnWrite
#endif
// LCD Framebuffer
#define MinxPRC_LCDfb PM_RAM
// Load state safe variables
#define POKELOADSS_START(size)\
uint32_t rsize = 0;\
uint32_t tmp32;\
uint16_t tmp16;\
if (size != bsize) return 0;\
{ tmp32 = 0; tmp16 = 0; }
// -- Stream versions START
#define POKELOADSS_STREAM_32(var) {\
rsize += (uint32_t)memstream_read(stream, (void *)&tmp32, 4);\
var = tmp32;\
}
#define POKELOADSS_STREAM_16(var) {\
rsize += (uint32_t)memstream_read(stream, (void *)&tmp16, 2);\
var = tmp16;\
}
#define POKELOADSS_STREAM_8(var) {\
rsize += (uint32_t)memstream_read(stream, (void *)&var, 1);\
}
#define POKELOADSS_STREAM_A(array, size) {\
rsize += (uint32_t)memstream_read(stream, (void *)array, size);\
}
#define POKE_SEEK_CUR 1
#define POKELOADSS_STREAM_X(size) {\
rsize += memstream_seek(stream, size, POKE_SEEK_CUR) ? 0 : size;\
}
// -- Stream versions End
#define POKELOADSS_END(size) {\
tmp32 = 0; tmp16 = 0;\
return (rsize == size) + tmp32 + (uint32_t)tmp16;\
}
// -- Stream versions START
#define POKESAVESS_STREAM_START(size)\
uint32_t wsize = 0;\
uint32_t tmp32 = size;\
uint16_t tmp16;\
if (memstream_write(stream, (void *)&tmp32, 4) != 4) return 0;\
{ tmp32 = 0; tmp16 = 0; }
#define POKESAVESS_STREAM_32(var) {\
tmp32 = (uint32_t)var;\
wsize += (uint32_t)memstream_write(stream, (void *)&tmp32, 4);\
}
#define POKESAVESS_STREAM_16(var) {\
tmp16 = (uint16_t)var;\
wsize += (uint32_t)memstream_write(stream, (void *)&tmp16, 2);\
}
#define POKESAVESS_STREAM_8(var) {\
wsize += (uint32_t)memstream_write(stream, (void *)&var, 1);\
}
#define POKESAVESS_STREAM_A(array, size) {\
wsize += (uint32_t)memstream_write(stream, (void *)array, size);\
}
#define POKESAVESS_STREAM_X(size) {\
tmp16 = 0;\
for (tmp32=0; tmp32<(uint32_t)size; tmp32++) {\
wsize += (uint32_t)memstream_write(stream, (void *)&tmp16, 1);\
}\
}
// -- Stream versions End
#define POKESAVESS_END(size) {\
tmp32 = 0; tmp16 = 0;\
return (wsize == size) + tmp32 + (uint32_t)tmp16;\
}
// Stream I/O
typedef int TPokeMini_StreamIO(void *data, int size, void *ptr);
// Create emulator and all interfaces
int PokeMini_Create(int flags, int soundfifo);
// Destroy emulator and all interfaces
void PokeMini_Destroy(void);
// Apply changes from command lines
void PokeMini_ApplyChanges(void);
// Low power battery emulation
void PokeMini_LowPower(int enable);
// Set LCD mode
void PokeMini_SetLCDMode(int mode);
// Generate rumble offset
int PokeMini_GenRumbleOffset(int pitch);
// Load BIOS file
int PokeMini_LoadBIOSFile(const char *filename);
// Load FreeBIOS
int PokeMini_LoadFreeBIOS(void);
// Check if file exist
int PokeMini_FileExist(const char *filename);
// New MIN ROM
int PokeMini_NewMIN(uint32_t size);
// Synchronize host time
int PokeMini_SyncHostTime(void);
// Load EEPROM data
int PokeMini_LoadEEPROMFile(const char *filename);
// Save EEPROM data
int PokeMini_SaveEEPROMFile(const char *filename);
// Load emulator state from memory stream
int PokeMini_LoadSSStream(uint8_t *buffer, uint64_t size);
// Save emulator state to memory stream
int PokeMini_SaveSSStream(uint8_t *buffer, uint64_t size);
// Reset CPU
void PokeMini_Reset(int hardreset);
// Internals, do not call directly!
void PokeMini_FreeColorInfo(void);
#endif
+259 -259
View File
@@ -1,259 +1,259 @@
const unsigned char FreeBIOS[] =
{
0x9A,0x00,0xAB,0x00,0xAB,0x00,0x2F,0x02,0x41,0x02,0x53,0x02,0x65,0x02,0x77,0x02,
0x89,0x02,0x9B,0x02,0xAD,0x02,0xBF,0x02,0xD1,0x02,0xE3,0x02,0xF5,0x02,0x07,0x03,
0x19,0x03,0xAB,0x00,0xAB,0x00,0x60,0x04,0x2B,0x03,0xF1,0x03,0x3D,0x03,0x4F,0x03,
0x61,0x03,0x73,0x03,0x85,0x03,0x97,0x03,0xA9,0x03,0xBB,0x03,0xCD,0x03,0xDF,0x03,
0xF1,0xFF,0x9E,0x04,0x60,0x04,0x60,0x04,0xE4,0x04,0x60,0x04,0x0D,0x05,0x24,0x05,
0x45,0x05,0x4C,0x05,0x5D,0x05,0x7C,0x05,0x92,0x05,0x9F,0x05,0xBB,0x05,0x60,0x04,
0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,
0x60,0x04,0xD6,0x05,0xE3,0x05,0x60,0x04,0x60,0x04,0xF0,0x05,0x00,0x06,0x66,0x06,
0x7A,0x06,0x8A,0x06,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,
0x60,0x04,0x60,0x04,0x60,0x04,0x00,0x00,0x98,0x06,0xB4,0x20,0x38,0xCE,0xCD,0xDD,
0x08,0x02,0xD9,0x08,0x01,0xDD,0x00,0x7C,0xDD,0x02,0x00,0x9F,0xC0,0xB4,0x20,0x38,
0xCE,0xCD,0xCE,0xCE,0xCE,0xCF,0xCF,0x6E,0x00,0x20,0xDD,0x80,0x00,0xCE,0xC4,0x01,
0xF3,0x01,0x00,0xD9,0x00,0x03,0xD9,0x01,0x30,0xD9,0x02,0xC0,0xF2,0xE1,0x00,0xC6,
0xA0,0x06,0xBE,0x82,0x20,0x79,0x84,0x79,0x85,0x79,0x86,0x79,0x87,0x79,0x88,0x79,
0x89,0x38,0xC6,0x00,0x10,0x60,0x92,0xD6,0x00,0x20,0xEF,0xF9,0xFF,0xF2,0x05,0x01,
0xDD,0xFE,0xAF,0xF2,0x1D,0x01,0xD9,0x80,0x0A,0xD9,0x81,0x01,0xDC,0x10,0x20,0xEF,
0x40,0x00,0xF2,0x2F,0x00,0xEF,0x3A,0x00,0x38,0xDD,0x80,0x00,0xDD,0x81,0x07,0x78,
0x82,0x78,0x83,0xD8,0x01,0xEF,0xC6,0x00,0x10,0x60,0x92,0xD6,0x00,0x20,0xEF,0xF9,
0xFF,0xC4,0x00,0x00,0xCF,0xE4,0xCF,0xE8,0xCF,0xEC,0x4C,0x52,0xB0,0xFF,0x9C,0xC0,
0xF3,0xD0,0x1F,0xCE,0xD0,0x00,0x21,0x32,0x4D,0xF8,0xCE,0xD0,0x01,0x21,0x32,0x4E,
0xF8,0xB1,0x03,0xA0,0xB0,0x01,0xC6,0x7D,0x13,0xB1,0x03,0xF2,0x51,0x00,0xC6,0x88,
0x13,0xB1,0x04,0xF2,0x49,0x00,0xDC,0x10,0x20,0xEE,0x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0x53,0x02,0x65,0x02,0x77,0x02,
0x89,0x02,0x9B,0x02,0xAD,0x02,0xBF,0x02,0xD1,0x02,0xE3,0x02,0xF5,0x02,0x07,0x03,
0x19,0x03,0xAB,0x00,0xAB,0x00,0x60,0x04,0x2B,0x03,0xF1,0x03,0x3D,0x03,0x4F,0x03,
0x61,0x03,0x73,0x03,0x85,0x03,0x97,0x03,0xA9,0x03,0xBB,0x03,0xCD,0x03,0xDF,0x03,
0xF1,0xFF,0x9E,0x04,0x60,0x04,0x60,0x04,0xE4,0x04,0x60,0x04,0x0D,0x05,0x24,0x05,
0x45,0x05,0x4C,0x05,0x5D,0x05,0x7C,0x05,0x92,0x05,0x9F,0x05,0xBB,0x05,0x60,0x04,
0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,
0x60,0x04,0xD6,0x05,0xE3,0x05,0x60,0x04,0x60,0x04,0xF0,0x05,0x00,0x06,0x66,0x06,
0x7A,0x06,0x8A,0x06,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,0x60,0x04,
0x60,0x04,0x60,0x04,0x60,0x04,0x00,0x00,0x98,0x06,0xB4,0x20,0x38,0xCE,0xCD,0xDD,
0x08,0x02,0xD9,0x08,0x01,0xDD,0x00,0x7C,0xDD,0x02,0x00,0x9F,0xC0,0xB4,0x20,0x38,
0xCE,0xCD,0xCE,0xCE,0xCE,0xCF,0xCF,0x6E,0x00,0x20,0xDD,0x80,0x00,0xCE,0xC4,0x01,
0xF3,0x01,0x00,0xD9,0x00,0x03,0xD9,0x01,0x30,0xD9,0x02,0xC0,0xF2,0xE1,0x00,0xC6,
0xA0,0x06,0xBE,0x82,0x20,0x79,0x84,0x79,0x85,0x79,0x86,0x79,0x87,0x79,0x88,0x79,
0x89,0x38,0xC6,0x00,0x10,0x60,0x92,0xD6,0x00,0x20,0xEF,0xF9,0xFF,0xF2,0x05,0x01,
0xDD,0xFE,0xAF,0xF2,0x1D,0x01,0xD9,0x80,0x0A,0xD9,0x81,0x01,0xDC,0x10,0x20,0xEF,
0x40,0x00,0xF2,0x2F,0x00,0xEF,0x3A,0x00,0x38,0xDD,0x80,0x00,0xDD,0x81,0x07,0x78,
0x82,0x78,0x83,0xD8,0x01,0xEF,0xC6,0x00,0x10,0x60,0x92,0xD6,0x00,0x20,0xEF,0xF9,
0xFF,0xC4,0x00,0x00,0xCF,0xE4,0xCF,0xE8,0xCF,0xEC,0x4C,0x52,0xB0,0xFF,0x9C,0xC0,
0xF3,0xD0,0x1F,0xCE,0xD0,0x00,0x21,0x32,0x4D,0xF8,0xCE,0xD0,0x01,0x21,0x32,0x4E,
0xF8,0xB1,0x03,0xA0,0xB0,0x01,0xC6,0x7D,0x13,0xB1,0x03,0xF2,0x51,0x00,0xC6,0x88,
0x13,0xB1,0x04,0xF2,0x49,0x00,0xDC,0x10,0x20,0xEE,0x0B,0x00,0xC6,0x94,0x13,0xB0,
0x08,0xB1,0x04,0xF2,0x39,0x00,0xF2,0xCB,0xFF,0xEE,0x0B,0x00,0xC6,0xA0,0x13,0xB0,
0x0C,0xB1,0x04,0xF2,0x29,0x00,0xF2,0x2C,0x00,0xC6,0x94,0x13,0xB0,0x00,0xB1,0x04,
0xF2,0x17,0x00,0xF2,0x1F,0x00,0xA8,0xF5,0xBB,0xC6,0xA0,0x13,0xB0,0x00,0xB1,0x04,
0xF2,0x07,0x00,0xF2,0x0F,0x00,0xF3,0x6A,0xFF,0x60,0x92,0xF5,0xFD,0xF8,0x60,0x92,
0x80,0xF5,0xFC,0xF8,0xB0,0xFF,0xB1,0xFF,0xF5,0xFF,0x88,0xEF,0xF9,0xFF,0xF8,0xB1,
0x00,0xDD,0x10,0x08,0xD8,0x19,0xCF,0x79,0x20,0xDD,0x21,0x30,0xDD,0x22,0x02,0x79,
0x23,0xDD,0x24,0x02,0x79,0x25,0x79,0x26,0x79,0x40,0x79,0x44,0xDD,0x50,0xFF,0x79,
0x51,0x79,0x54,0x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FF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x20,0x20,0x20,0x20,0x46,0x72,0x65,0x65,0x77,0x61,0x72,0x65,0x20,0x20,0x20,0x20,
0x50,0x6F,0x6B,0x65,0x6D,0x6F,0x6E,0x4D,0x69,0x6E,0x69,0x20,0x42,0x49,0x4F,0x53,
0x20,0x20,0x56,0x65,0x72,0x73,0x69,0x6F,0x6E,0x20,0x20,0x31,0x2E,0x33,0x20,0x20,
0x20,0x62,0x79,0x20,0x54,0x65,0x61,0x6D,0x20,0x50,0x6F,0x6B,0x65,0x6D,0x65,0x20,
};
+25 -25
View File
@@ -1,25 +1,25 @@
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FREEBIOS_H
#define FREEBIOS_H
// Free BIOS (4KB)
extern const unsigned char FreeBIOS[];
#endif
/*
PokeMini - Pokémon-Mini Emulator
Copyright (C) 2009 JustBurn
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FREEBIOS_H
#define FREEBIOS_H
// Free BIOS (4KB)
extern const unsigned char FreeBIOS[];
#endif
+132 -132
View File
@@ -1,132 +1,132 @@
/* PokeMiniEmu: what PokeMini.c, PMCommon.c and the colour PRC give the core, cut down for the Paradise (no files,
* no colour, no multicart). The cartridge is read straight from the cached flash window (PM_ROM points there).
* Based on PokeMini by JustBurn (GPL 3 or later), see LICENSE_pokemini. Author of the changes: mameise */
#include "PokeMini.h"
#include "freebios.h"
#include <string.h>
int PokeMini_FreeBIOS = 0, PokeMini_Flags = 0, PokeMini_LCDMode = LCDMODE_ANALOG, PokeMini_ColorFormat = 0, PokeMini_HostBattStatus = 0;
uint8_t PM_BIOS[4096];
uint8_t PM_RAM[8192];
uint8_t *PM_ROM;
int PM_ROM_Alloc, PM_ROM_Size, PM_ROM_Mask;
int PokeHWCycles;
static const uint8_t PM_IO_INIT[256] = {
0x7F, 0x20, 0x5C, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0x00, 0x30, 0x02, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0xC0, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x32, 0x64, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x40, 0xFF };
/* ---- memory: a small heap for the core's buffers (EEPROM, LCD) ---- */
#ifndef PM_HEAP
#define PM_HEAP 0x5C00
#endif
static uint8_t g_heap[PM_HEAP] __attribute__((aligned(8)));
static uint32_t g_heap_n;
#ifndef PM_HOST
void *malloc(size_t n) { n = (n + 7u) & ~7u; if (g_heap_n + n > sizeof g_heap) return 0; void *p = g_heap + g_heap_n; g_heap_n += n; return p; }
void free(void *p) { (void)p; }
#endif
int GetMultiple2Mask(int input)
{
if (input) input--;
input |= input >> 1; input |= input >> 2; input |= input >> 4; input |= input >> 8; input |= input >> 16;
return input;
}
/* ---- the colour PRC is not there ---- */
int PRCColorEnable; uint8_t *PRCColorPixels, *PRCColorPixelsOld, *PRCColorMap, *PRCColorTop; unsigned int PRCColorOffset; uint8_t PRCColorFlags;
int MinxColorPRC_Create(void) { return 1; }
void MinxColorPRC_Reset(int hardreset) { (void)hardreset; }
uint8_t MinxColorPRC_ReadReg(int cpu, uint8_t reg) { (void)cpu; (void)reg; return 0xFF; }
void MinxColorPRC_WriteReg(uint8_t reg, uint8_t val) { (void)reg; (void)val; }
void MinxColorPRC_WriteFramebuffer(uint16_t addr, uint8_t data) { (void)addr; (void)data; }
void MinxColorPRC_WriteLCD(uint16_t addr, uint8_t data) { (void)addr; (void)data; }
void MinxPRC_NoRender_Color(void) {}
/* ---- the Pokemon mini ---- */
int PokeMini_Create(int flags, int soundfifo)
{
(void)soundfifo;
g_heap_n = 0;
memset(PM_BIOS, 0xFF, 4096); memset(PM_RAM, 0xFF, 8192);
PM_ROM_Mask = 0x1FFF; PM_ROM_Size = 0x2000; PM_ROM = PM_RAM;
memcpy(PM_IO, PM_IO_INIT, 256);
if (!MinxCPU_Create() || !MinxTimers_Create() || !MinxIO_Create() || !MinxIRQ_Create() || !MinxPRC_Create() || !MinxLCD_Create() || !MinxAudio_Create(0, 0)) return 0;
PokeMini_Flags = flags;
return 1;
}
int PokeMini_LoadFreeBIOS(void) { PokeMini_FreeBIOS = 1; memcpy(PM_BIOS, FreeBIOS, 4096); return 1; }
/* the cartridge in the flash window: size rounded up to a power of two (reads behind it repeat the start) */
void pm_set_rom(const uint8_t *rom, uint32_t len) { PM_ROM = (uint8_t *)rom; PM_ROM_Mask = GetMultiple2Mask((int)len); PM_ROM_Size = PM_ROM_Mask + 1; }
void PokeMini_Reset(int hardreset)
{
if (hardreset) { memset(PM_RAM, 0xFF, 8192); memcpy(PM_IO, PM_IO_INIT, 256); }
MinxTimers_Reset(hardreset); MinxIRQ_Reset(hardreset); MinxIO_Reset(hardreset); MinxPRC_Reset(hardreset);
MinxLCD_Reset(hardreset); MinxAudio_Reset(hardreset); MinxCPU_Reset(hardreset);
}
/* the clock of the game from the Paradise's (the BIOS then skips asking for the time) */
void pm_set_time(int y, int mo, int d, int h, int mi, int s)
{
MinxIO_SetTimeStamp((uint8_t)(y % 100), (uint8_t)mo, (uint8_t)d, (uint8_t)h, (uint8_t)mi, (uint8_t)s);
PMR_SEC_CTRL = 0x01; MinxTimers.SecTimerCnt = 0;
}
/* ---- the state in a buffer (as PokeMini's state files, without the colour part) ---- */
uint64_t memstream_read(memstream_t *s, void *d, uint64_t n) { if (s->pos + n > s->size) n = s->size - s->pos; memcpy(d, s->buf + s->pos, (size_t)n); s->pos += (uint32_t)n; return n; }
uint64_t memstream_write(memstream_t *s, const void *d, uint64_t n) { if (s->pos + n > s->size) n = s->size - s->pos; memcpy(s->buf + s->pos, d, (size_t)n); s->pos += (uint32_t)n; return n; }
int64_t memstream_seek(memstream_t *s, int64_t off, int whence) { int64_t p = whence == 1 ? s->pos + off : off; if (p < 0 || p > s->size) return -1; s->pos = (uint32_t)p; return 0; }
uint64_t memstream_pos(memstream_t *s) { return s->pos; }
#define PM_STATE_ID 0x31534D50u /* "PMS1" */
static void tag(memstream_t *s, const char *t) { memstream_write(s, t, 4); }
uint32_t pm_state_save(uint8_t *buf, uint32_t size)
{
memstream_t s = { buf, size, 0 }; uint32_t v = PM_STATE_ID, n;
memstream_write(&s, &v, 4);
tag(&s, "RAM-"); n = 0x1000; memstream_write(&s, &n, 4); memstream_write(&s, PM_RAM, 0x1000);
tag(&s, "REG-"); n = 256; memstream_write(&s, &n, 4); memstream_write(&s, PM_IO, 256);
tag(&s, "CPU-"); MinxCPU_SaveStateStream(&s);
tag(&s, "IRQ-"); MinxIRQ_SaveStateStream(&s);
tag(&s, "TMR-"); MinxTimers_SaveStateStream(&s);
tag(&s, "PIO-"); MinxIO_SaveStateStream(&s);
tag(&s, "PRC-"); MinxPRC_SaveStateStream(&s);
tag(&s, "LCD-"); MinxLCD_SaveStateStream(&s);
tag(&s, "AUD-"); MinxAudio_SaveStateStream(&s);
tag(&s, "END-"); n = 0; memstream_write(&s, &n, 4);
return s.pos < size ? s.pos : 0; /* 0: did not fit */
}
int pm_state_load(uint8_t *buf, uint32_t size)
{
memstream_t s = { buf, size, 0 }; uint32_t v = 0, n; char t[4];
if (memstream_read(&s, &v, 4) != 4 || v != PM_STATE_ID) return 0;
for (;;) {
if (memstream_read(&s, t, 4) != 4 || memstream_read(&s, &n, 4) != 4) return 0;
int ok = 1;
if (!memcmp(t, "RAM-", 4)) ok = n == 0x1000 && memstream_read(&s, PM_RAM, 0x1000) == 0x1000;
else if (!memcmp(t, "REG-", 4)) ok = n == 256 && memstream_read(&s, PM_IO, 256) == 256;
else if (!memcmp(t, "CPU-", 4)) ok = MinxCPU_LoadStateStream(&s, n);
else if (!memcmp(t, "IRQ-", 4)) ok = MinxIRQ_LoadStateStream(&s, n);
else if (!memcmp(t, "TMR-", 4)) ok = MinxTimers_LoadStateStream(&s, n);
else if (!memcmp(t, "PIO-", 4)) ok = MinxIO_LoadStateStream(&s, n);
else if (!memcmp(t, "PRC-", 4)) ok = MinxPRC_LoadStateStream(&s, n);
else if (!memcmp(t, "LCD-", 4)) ok = MinxLCD_LoadStateStream(&s, n);
else if (!memcmp(t, "AUD-", 4)) ok = MinxAudio_LoadStateStream(&s, n);
else if (!memcmp(t, "END-", 4)) return 1;
else ok = memstream_seek(&s, n, 1) == 0;
if (!ok) return 0;
}
}
/* PokeMiniEmu: what PokeMini.c, PMCommon.c and the colour PRC give the core, cut down for the Paradise (no files,
* no colour, no multicart). The cartridge is read straight from the cached flash window (PM_ROM points there).
* Based on PokeMini by JustBurn (GPL 3 or later), see LICENSE_pokemini. Author of the changes: mameise */
#include "PokeMini.h"
#include "freebios.h"
#include <string.h>
int PokeMini_FreeBIOS = 0, PokeMini_Flags = 0, PokeMini_LCDMode = LCDMODE_ANALOG, PokeMini_ColorFormat = 0, PokeMini_HostBattStatus = 0;
uint8_t PM_BIOS[4096];
uint8_t PM_RAM[8192];
uint8_t *PM_ROM;
int PM_ROM_Alloc, PM_ROM_Size, PM_ROM_Mask;
int PokeHWCycles;
static const uint8_t PM_IO_INIT[256] = {
0x7F, 0x20, 0x5C, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0x00, 0x30, 0x02, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0xC0, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x32, 0x64, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x40, 0xFF };
/* ---- memory: a small heap for the core's buffers (EEPROM, LCD) ---- */
#ifndef PM_HEAP
#define PM_HEAP 0x5C00
#endif
static uint8_t g_heap[PM_HEAP] __attribute__((aligned(8)));
static uint32_t g_heap_n;
#ifndef PM_HOST
void *malloc(size_t n) { n = (n + 7u) & ~7u; if (g_heap_n + n > sizeof g_heap) return 0; void *p = g_heap + g_heap_n; g_heap_n += n; return p; }
void free(void *p) { (void)p; }
#endif
int GetMultiple2Mask(int input)
{
if (input) input--;
input |= input >> 1; input |= input >> 2; input |= input >> 4; input |= input >> 8; input |= input >> 16;
return input;
}
/* ---- the colour PRC is not there ---- */
int PRCColorEnable; uint8_t *PRCColorPixels, *PRCColorPixelsOld, *PRCColorMap, *PRCColorTop; unsigned int PRCColorOffset; uint8_t PRCColorFlags;
int MinxColorPRC_Create(void) { return 1; }
void MinxColorPRC_Reset(int hardreset) { (void)hardreset; }
uint8_t MinxColorPRC_ReadReg(int cpu, uint8_t reg) { (void)cpu; (void)reg; return 0xFF; }
void MinxColorPRC_WriteReg(uint8_t reg, uint8_t val) { (void)reg; (void)val; }
void MinxColorPRC_WriteFramebuffer(uint16_t addr, uint8_t data) { (void)addr; (void)data; }
void MinxColorPRC_WriteLCD(uint16_t addr, uint8_t data) { (void)addr; (void)data; }
void MinxPRC_NoRender_Color(void) {}
/* ---- the Pokemon mini ---- */
int PokeMini_Create(int flags, int soundfifo)
{
(void)soundfifo;
g_heap_n = 0;
memset(PM_BIOS, 0xFF, 4096); memset(PM_RAM, 0xFF, 8192);
PM_ROM_Mask = 0x1FFF; PM_ROM_Size = 0x2000; PM_ROM = PM_RAM;
memcpy(PM_IO, PM_IO_INIT, 256);
if (!MinxCPU_Create() || !MinxTimers_Create() || !MinxIO_Create() || !MinxIRQ_Create() || !MinxPRC_Create() || !MinxLCD_Create() || !MinxAudio_Create(0, 0)) return 0;
PokeMini_Flags = flags;
return 1;
}
int PokeMini_LoadFreeBIOS(void) { PokeMini_FreeBIOS = 1; memcpy(PM_BIOS, FreeBIOS, 4096); return 1; }
/* the cartridge in the flash window: size rounded up to a power of two (reads behind it repeat the start) */
void pm_set_rom(const uint8_t *rom, uint32_t len) { PM_ROM = (uint8_t *)rom; PM_ROM_Mask = GetMultiple2Mask((int)len); PM_ROM_Size = PM_ROM_Mask + 1; }
void PokeMini_Reset(int hardreset)
{
if (hardreset) { memset(PM_RAM, 0xFF, 8192); memcpy(PM_IO, PM_IO_INIT, 256); }
MinxTimers_Reset(hardreset); MinxIRQ_Reset(hardreset); MinxIO_Reset(hardreset); MinxPRC_Reset(hardreset);
MinxLCD_Reset(hardreset); MinxAudio_Reset(hardreset); MinxCPU_Reset(hardreset);
}
/* the clock of the game from the Paradise's (the BIOS then skips asking for the time) */
void pm_set_time(int y, int mo, int d, int h, int mi, int s)
{
MinxIO_SetTimeStamp((uint8_t)(y % 100), (uint8_t)mo, (uint8_t)d, (uint8_t)h, (uint8_t)mi, (uint8_t)s);
PMR_SEC_CTRL = 0x01; MinxTimers.SecTimerCnt = 0;
}
/* ---- the state in a buffer (as PokeMini's state files, without the colour part) ---- */
uint64_t memstream_read(memstream_t *s, void *d, uint64_t n) { if (s->pos + n > s->size) n = s->size - s->pos; memcpy(d, s->buf + s->pos, (size_t)n); s->pos += (uint32_t)n; return n; }
uint64_t memstream_write(memstream_t *s, const void *d, uint64_t n) { if (s->pos + n > s->size) n = s->size - s->pos; memcpy(s->buf + s->pos, d, (size_t)n); s->pos += (uint32_t)n; return n; }
int64_t memstream_seek(memstream_t *s, int64_t off, int whence) { int64_t p = whence == 1 ? s->pos + off : off; if (p < 0 || p > s->size) return -1; s->pos = (uint32_t)p; return 0; }
uint64_t memstream_pos(memstream_t *s) { return s->pos; }
#define PM_STATE_ID 0x31534D50u /* "PMS1" */
static void tag(memstream_t *s, const char *t) { memstream_write(s, t, 4); }
uint32_t pm_state_save(uint8_t *buf, uint32_t size)
{
memstream_t s = { buf, size, 0 }; uint32_t v = PM_STATE_ID, n;
memstream_write(&s, &v, 4);
tag(&s, "RAM-"); n = 0x1000; memstream_write(&s, &n, 4); memstream_write(&s, PM_RAM, 0x1000);
tag(&s, "REG-"); n = 256; memstream_write(&s, &n, 4); memstream_write(&s, PM_IO, 256);
tag(&s, "CPU-"); MinxCPU_SaveStateStream(&s);
tag(&s, "IRQ-"); MinxIRQ_SaveStateStream(&s);
tag(&s, "TMR-"); MinxTimers_SaveStateStream(&s);
tag(&s, "PIO-"); MinxIO_SaveStateStream(&s);
tag(&s, "PRC-"); MinxPRC_SaveStateStream(&s);
tag(&s, "LCD-"); MinxLCD_SaveStateStream(&s);
tag(&s, "AUD-"); MinxAudio_SaveStateStream(&s);
tag(&s, "END-"); n = 0; memstream_write(&s, &n, 4);
return s.pos < size ? s.pos : 0; /* 0: did not fit */
}
int pm_state_load(uint8_t *buf, uint32_t size)
{
memstream_t s = { buf, size, 0 }; uint32_t v = 0, n; char t[4];
if (memstream_read(&s, &v, 4) != 4 || v != PM_STATE_ID) return 0;
for (;;) {
if (memstream_read(&s, t, 4) != 4 || memstream_read(&s, &n, 4) != 4) return 0;
int ok = 1;
if (!memcmp(t, "RAM-", 4)) ok = n == 0x1000 && memstream_read(&s, PM_RAM, 0x1000) == 0x1000;
else if (!memcmp(t, "REG-", 4)) ok = n == 256 && memstream_read(&s, PM_IO, 256) == 256;
else if (!memcmp(t, "CPU-", 4)) ok = MinxCPU_LoadStateStream(&s, n);
else if (!memcmp(t, "IRQ-", 4)) ok = MinxIRQ_LoadStateStream(&s, n);
else if (!memcmp(t, "TMR-", 4)) ok = MinxTimers_LoadStateStream(&s, n);
else if (!memcmp(t, "PIO-", 4)) ok = MinxIO_LoadStateStream(&s, n);
else if (!memcmp(t, "PRC-", 4)) ok = MinxPRC_LoadStateStream(&s, n);
else if (!memcmp(t, "LCD-", 4)) ok = MinxLCD_LoadStateStream(&s, n);
else if (!memcmp(t, "AUD-", 4)) ok = MinxAudio_LoadStateStream(&s, n);
else if (!memcmp(t, "END-", 4)) return 1;
else ok = memstream_seek(&s, n, 1) == 0;
if (!ok) return 0;
}
}