[Cosmetics]
- Update some headers that was incorrect - Reformat the code in all files to match the same code style - Removal of unwanted/unneeded files
This commit is contained in:
parent
ad195d6c20
commit
cdda587579
@ -2,7 +2,7 @@
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Copyright (c) 2003-2018 986Corp. All rights reserved.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $Author$
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* Cart manager - The peTI-NESulator Project
|
||||
* NESCart.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/* System Headers */
|
||||
#if !defined(__TIGCC__) && !defined(__GCC4TI__) && !defined(__GTC__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
@ -26,7 +27,7 @@
|
||||
#include <mappers/manager.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
void DumpCartProperties(FILE *out, NesCart * cart)
|
||||
void DumpCartProperties(FILE *out, NesCart *cart)
|
||||
{
|
||||
console_printf(Console_Verbose,
|
||||
"'%s' informations:\n"
|
||||
@ -40,13 +41,13 @@ void DumpCartProperties(FILE *out, NesCart * cart)
|
||||
cart->VROMSize,
|
||||
cart->MapperID,
|
||||
(cart->Flags & iNES_MIRROR) ? "Horizontal" : "Vertical",
|
||||
(cart->Flags & iNES_BATTERY)? "Yes": "No ",
|
||||
(cart->Flags & iNES_4SCREEN)? "Yes": "No ",
|
||||
(cart->Flags & iNES_BATTERY) ? "Yes" : "No ",
|
||||
(cart->Flags & iNES_4SCREEN) ? "Yes" : "No ",
|
||||
cart->PROMBanks,
|
||||
cart->VROMBanks);
|
||||
}
|
||||
|
||||
int LoadCart(const char *filename, NesCart * cart)
|
||||
int LoadCart(const char *filename, NesCart *cart)
|
||||
{
|
||||
char buffer[6];
|
||||
/* Load the cart into memory */
|
||||
@ -54,17 +55,21 @@ int LoadCart(const char *filename, NesCart * cart)
|
||||
|
||||
|
||||
if ((cart->File == NULL) || (cart->File == MAP_FAILED))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
|
||||
|
||||
/* Verify that this is a real iNES valid file */
|
||||
if (memcmp(cart->File, buffer, 4))
|
||||
if (memcmp(cart->File, buffer, 4) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Before go elsewhere, verify that the header is clean !
|
||||
(aka no DiskDude! in it) */
|
||||
if (memcmp(cart->File+7, "DiskDude!", 9) == 0)
|
||||
if (memcmp(cart->File + 7, "DiskDude!", 9) == 0)
|
||||
{
|
||||
console_printf(Console_Warning, "\n"
|
||||
"*******************WARNING****************\n"
|
||||
@ -76,19 +81,19 @@ int LoadCart(const char *filename, NesCart * cart)
|
||||
"* PLEASE CLEAN THIS FILE! *\n"
|
||||
"******************WARNING*****************\n\n");
|
||||
/* So this rom file is not clean, we can only rely on the "basic" mapperID */
|
||||
cart->MapperID = cart->File[6]>>4; /* Mapper Type */
|
||||
cart->MapperID = cart->File[6] >> 4; /* Mapper Type */
|
||||
|
||||
}
|
||||
else
|
||||
{ /* This rom file is clean, we can read the extended MapperID */
|
||||
cart->MapperID = (cart->File[6]>>4)|(cart->File[7]&0xF0); /* Mapper Type */
|
||||
cart->MapperID = (cart->File[6] >> 4) | (cart->File[7] & 0xF0); /* Mapper Type */
|
||||
}
|
||||
|
||||
/* Now fill the structure */
|
||||
cart->FileName = (char *)filename;
|
||||
|
||||
cart->PROMSize = cart->File[4] * 16 * 1024; /* Size of PROM */
|
||||
cart->VROMSize = cart->File[5] * 8 * 1024; /* Size of VROM */
|
||||
cart->PROMSize = cart->File[4] * 16U * 1024U; /* Size of PROM */
|
||||
cart->VROMSize = cart->File[5] * 8U * 1024U; /* Size of VROM */
|
||||
cart->Flags = cart->File[6] & 0x0F;
|
||||
|
||||
/* We don't and we will never support trainer-ed ROM */
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* APU emulation - The peTI-NESulator Project
|
||||
* apu.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $Author$
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
* Cart manager - The peTI-NESulator Project
|
||||
* NESCart.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*/
|
||||
|
||||
@ -29,7 +29,7 @@ typedef struct NesCart_
|
||||
uint8_t *VROMBanks; /* Pointer on the first VROM */
|
||||
} NesCart;
|
||||
|
||||
void DumpCartProperties(FILE *out, NesCart * cart);
|
||||
int LoadCart(const char *filename, NesCart * cart);
|
||||
void DumpCartProperties(FILE *out, NesCart *cart);
|
||||
int LoadCart(const char *filename, NesCart *cart);
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,232 +0,0 @@
|
||||
/** EMULib Emulation Library *********************************/
|
||||
/** **/
|
||||
/** Sound.h **/
|
||||
/** **/
|
||||
/** This file defines standard sound generation API and **/
|
||||
/** functions needed to log soundtrack into a MIDI file. **/
|
||||
/** See Sound.c and the sound drivers for the code. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2007 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
/*************************************************************/
|
||||
/*/
|
||||
|
||||
#ifndef SOUND_H
|
||||
#define SOUND_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* SetSound() arguments: */
|
||||
#define SND_MELODIC 0 /* Melodic sound (default) */
|
||||
#define SND_RECTANGLE 0 /* Rectangular wave */
|
||||
#define SND_QS_DU0 5
|
||||
#define SND_QS_DU1 6
|
||||
#define SND_QS_DU2 7
|
||||
#define SND_QS_DU3 8
|
||||
#define SND_TRIANGLE 1 /* Triangular wave (1/2 rect.)*/
|
||||
#define SND_NOISE 2 /* White noise */
|
||||
#define SND_PERIODIC 3 /* Periodic noise (not im-ed) */
|
||||
#define SND_WAVE 4 /* Wave sound set by SetWave()*/
|
||||
#define SND_MIDI 0x100 /* MIDI instrument (ORable) */
|
||||
|
||||
/* Drum() arguments: */
|
||||
#define DRM_CLICK 0 /* Click (default) */
|
||||
#define DRM_MIDI 0x100 /* MIDI drum (ORable) */
|
||||
|
||||
/* MIDI characteristics: */
|
||||
#define MIDI_CHANNELS 16 /* Number of MIDI channels */
|
||||
#define MIDI_MINFREQ 9 /* Min MIDI frequency (Hz) */
|
||||
#define MIDI_MAXFREQ 12285 /* Max MIDI frequency (Hz) */
|
||||
#define MIDI_DIVISIONS 1000 /* Number of ticks per second */
|
||||
|
||||
/* MIDILogging() arguments: */
|
||||
#define MIDI_OFF 0 /* Turn MIDI logging off */
|
||||
#define MIDI_ON 1 /* Turn MIDI logging on */
|
||||
#define MIDI_TOGGLE 2 /* Toggle MIDI logging */
|
||||
#define MIDI_QUERY 3 /* Query MIDI logging status */
|
||||
|
||||
/** TrashSound() *********************************************/
|
||||
/** Shut down sound driver. Each driver implements its own **/
|
||||
/** TrashSound() function. **/
|
||||
/*************************************************************/
|
||||
void TrashSound(void);
|
||||
|
||||
/** Sound() **************************************************/
|
||||
/** Generate sound of given frequency (Hz) and volume **/
|
||||
/** (0..255) via given channel. Setting Freq=0 or Volume=0 **/
|
||||
/** turns sound off. **/
|
||||
/*************************************************************/
|
||||
void Sound(int Channel,int Freq,int Volume);
|
||||
|
||||
/** Drum() ***************************************************/
|
||||
/** Hit a drum of given type with given force (0..255). **/
|
||||
/** MIDI drums can be used by ORing their numbers with **/
|
||||
/** SND_MIDI. **/
|
||||
/*************************************************************/
|
||||
void Drum(int Type,int Force);
|
||||
|
||||
/** SetSound() ***********************************************/
|
||||
/** Set sound type at a given channel. MIDI instruments can **/
|
||||
/** be set directly by ORing their numbers with SND_MIDI. **/
|
||||
/*************************************************************/
|
||||
void SetSound(int Channel,int NewType);
|
||||
|
||||
/** SetChannels() ********************************************/
|
||||
/** Set master volume (0..255) and switch channels on/off. **/
|
||||
/** Each channel N has corresponding bit 2^N in Switch. Set **/
|
||||
/** or reset this bit to turn the channel on or off. **/
|
||||
/*************************************************************/
|
||||
void SetChannels(int Volume,int Switch);
|
||||
|
||||
/** SetWave() ************************************************/
|
||||
/** Set waveform for a given channel. The channel will be **/
|
||||
/** marked with sound type SND_WAVE. Set Rate=0 if you want **/
|
||||
/** waveform to be an instrument or set it to the waveform **/
|
||||
/** own playback rate. **/
|
||||
/*************************************************************/
|
||||
void SetWave(int Channel,signed char *Data,int Length,int Rate);
|
||||
|
||||
/** GetWave() ************************************************/
|
||||
/** Get current read position for the buffer set with the **/
|
||||
/** SetWave() call. Returns 0 if no buffer has been set, or **/
|
||||
/** if there is no playrate set (i.e. wave is instrument). **/
|
||||
/*************************************************************/
|
||||
const signed char *GetWave(int Channel);
|
||||
|
||||
/** InitMIDI() ***********************************************/
|
||||
/** Initialize soundtrack logging into MIDI file FileName. **/
|
||||
/** Repeated calls to InitMIDI() will close current MIDI **/
|
||||
/** file and continue logging into a new one. **/
|
||||
/*************************************************************/
|
||||
void InitMIDI(const char *FileName);
|
||||
|
||||
/** TrashMIDI() **********************************************/
|
||||
/** Finish logging soundtrack and close the MIDI file. **/
|
||||
/*************************************************************/
|
||||
void TrashMIDI(void);
|
||||
|
||||
/** MIDILogging() ********************************************/
|
||||
/** Turn soundtrack logging on/off and return its current **/
|
||||
/** status. Possible values of Switch are MIDI_OFF (turn **/
|
||||
/** logging off), MIDI_ON (turn logging on), MIDI_TOGGLE **/
|
||||
/** (toggle logging), and MIDI_QUERY (just return current **/
|
||||
/** state of logging). **/
|
||||
/*************************************************************/
|
||||
int MIDILogging(int Switch);
|
||||
|
||||
/** MIDITicks() **********************************************/
|
||||
/** Log N 1ms MIDI ticks. **/
|
||||
/*************************************************************/
|
||||
void MIDITicks(int N);
|
||||
|
||||
//#ifdef UNIX
|
||||
#define SND_CHANNELS 4 /* Number of channels */
|
||||
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
|
||||
#define SND_BUFSIZE 256 /* Buffer size, <= 2^SND_BITS */
|
||||
#define SND_BITS 8 /* Number of bits in a fragment */
|
||||
#define SND_BUFFERS 64 /* Number of fragments, >= 2 */
|
||||
/* Bigger value results in better behaviour on loaded */
|
||||
/* but output gets more delayed. */
|
||||
|
||||
/** InitSound() **********************************************/
|
||||
/** Initialize Unix sound driver with given synthesis rate. **/
|
||||
/** Returns Rate on success, 0 otherwise. Pass Rate=0 to **/
|
||||
/** skip initialization and be silent. Pass Verbose!=0 to **/
|
||||
/** see initialization messages. **/
|
||||
/*************************************************************/
|
||||
int InitSound(int Rate,int Verbose);
|
||||
|
||||
/** StopSound() **********************************************/
|
||||
/** Temporarily suspend sound. **/
|
||||
/*************************************************************/
|
||||
void StopSound(void);
|
||||
|
||||
/** ResumeSound() ********************************************/
|
||||
/** Resume sound after StopSound(). **/
|
||||
/*************************************************************/
|
||||
void ResumeSound(void);
|
||||
//#endif /* UNIX */
|
||||
|
||||
#ifdef MSDOS
|
||||
#define SND_CHANNELS 16 /* Number of sound channels */
|
||||
#define OPL_CHANNELS 7 /* Number of Adlib channels */
|
||||
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
|
||||
#define SND_BUFSIZE 512 /* Buffer size for DMA */
|
||||
#define SND_MAXDELAY 10 /* Maximal sound delay 1/n s */
|
||||
|
||||
/** InitSound() **********************************************/
|
||||
/** Initialize sound. Returns Rate on success, 0 otherwise. **/
|
||||
/** Rate=0 to skip initialization (will be silent). **/
|
||||
/*************************************************************/
|
||||
int InitSound(uint32_t Rate,uint32_t Latency);
|
||||
#endif /* MSDOS */
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define SND_CHANNELS 16 /* Number of channels */
|
||||
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
|
||||
#define SND_BUFSIZE 512 /* Size of a wave buffer */
|
||||
#define SND_BUFFERS 32 /* Number of wave buffers */
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
/** InitSound() **********************************************/
|
||||
/** Initialize Windows sound driver with given synthesis **/
|
||||
/** rate. Returns Rate on success, 0 otherwise. Pass Rate=0 **/
|
||||
/** to skip initialization and be silent. Pass Rate=1 to **/
|
||||
/** use MIDI (midiOut). Pass Rate=8192..44100 to use wave **/
|
||||
/** synthesis (waveOut). Number of wave synthesis buffers **/
|
||||
/** must be in 2..SND_BUFFERS range. **/
|
||||
/*************************************************************/
|
||||
uint32_t InitSound(uint32_t Rate,uint32_t Delay);
|
||||
#endif /* WINDOWS */
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifndef WINDOWS
|
||||
#ifndef UNIX
|
||||
#define SND_CHANNELS MIDI_CHANNELS /* Default number */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** InitSound() **********************************************/
|
||||
/** Initialize Series60 sound driver with given synthesis **/
|
||||
/** rate. Returns Rate on success, 0 otherwise. Pass Rate=0 **/
|
||||
/** to skip initialization and be silent. **/
|
||||
/*************************************************************/
|
||||
uint32_t InitSound(uint32_t Rate,uint32_t Delay);
|
||||
#endif
|
||||
|
||||
/** RenderAudio() ********************************************/
|
||||
/** Render given number of melodic sound samples. Returns **/
|
||||
/** number of samples actually rendered. **/
|
||||
/*************************************************************/
|
||||
uint32_t RenderAudio(uint32_t Samples);
|
||||
|
||||
/** SndDriver ************************************************/
|
||||
/** Each sound driver should fill this structure with **/
|
||||
/** pointers to hardware-dependent handlers. This has to be **/
|
||||
/** done inside the InitSound() function. **/
|
||||
/*************************************************************/
|
||||
struct SndDriverStruct
|
||||
{
|
||||
void (*SetSound)(int Channel,int NewType);
|
||||
void (*Drum)(int Type,int Force);
|
||||
void (*SetChannels)(int Volume,int Switch);
|
||||
void (*Sound)(int Channel,int NewFreq,int NewVolume);
|
||||
void (*SetWave)(int Channel,signed char *Data,int Length,int Freq);
|
||||
const signed char *(*GetWave)(int Channel);
|
||||
};
|
||||
extern struct SndDriverStruct SndDriver;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SOUND_H */
|
||||
@ -2,7 +2,7 @@
|
||||
* APU emulation - The peTI-NESulator Project
|
||||
* apu.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -2,14 +2,9 @@
|
||||
* ANSI Color definition - The Quick6502 Project
|
||||
* include/color.h
|
||||
*
|
||||
* Created by Manoel Trapier on 25/06/10
|
||||
* Created by Manoël Trapier on 25/06/10
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate:$
|
||||
* $Author:$
|
||||
* $HeadURL:$
|
||||
* $Revision:$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLOR_H
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* CoreCPU - The Quick6502 Project
|
||||
* corecpu.h
|
||||
*
|
||||
* Created by Manoel Trapier on 24/02/08
|
||||
* Created by Manoël Trapier on 24/02/08
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -134,7 +134,7 @@ void quick6502_reset(quick6502_cpu *cpu);
|
||||
*
|
||||
* int: (Number of cycle really done) - (Number of cycle asked)
|
||||
*/
|
||||
int quick6502_run(quick6502_cpu *cpu, int cycles);
|
||||
uint32_t quick6502_run(quick6502_cpu *cpu, uint32_t cycles);
|
||||
|
||||
/** Loop CPU until explicit quit */
|
||||
void quick6502_loop(quick6502_cpu *cpu);
|
||||
@ -146,13 +146,14 @@ void quick6502_exec(quick6502_cpu *cpu);
|
||||
void quick6502_int(quick6502_cpu *cpu, quick6502_signal signal);
|
||||
|
||||
/** Dump CPU State to the given file */
|
||||
void quick6502_dump(quick6502_cpu *cpu, FILE * fp);
|
||||
void quick6502_dump(quick6502_cpu *cpu, FILE *fp);
|
||||
|
||||
/** Get current instruction name at specified address and put it into buffer */
|
||||
#define MINE
|
||||
|
||||
int quick6502_getinstruction(quick6502_cpu *cpu, char interpret,
|
||||
uint16_t addr, char *buffer, int *strlength);
|
||||
|
||||
/**
|
||||
* Free the CPU
|
||||
*
|
||||
|
||||
@ -2,14 +2,9 @@
|
||||
* Log Facility - The Quick6502 Project
|
||||
* include/log.h
|
||||
*
|
||||
* Created by Manoel Trapier on 19/05/10
|
||||
* Created by Manoël Trapier on 19/05/10
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate:$
|
||||
* $Author:$
|
||||
* $HeadURL:$
|
||||
* $Revision:$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOG_H
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
* Mappers manager & facilities - The peTI-NESulator Project
|
||||
* mappers.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -14,11 +14,10 @@
|
||||
#include <stdio.h>
|
||||
#include <NESCarts.h>
|
||||
|
||||
typedef int (*MapperInit) (NesCart * cart);
|
||||
typedef int (*MapperWriteHook) (register uint16_t Addr,
|
||||
register uint8_t Value);
|
||||
typedef int (*MapperIRQ) (int cycledone);
|
||||
typedef void (*MapperDump) (FILE *fp);
|
||||
typedef int (*MapperInit)(NesCart *cart);
|
||||
typedef int (*MapperWriteHook)(register uint16_t Addr, register uint8_t Value);
|
||||
typedef int (*MapperIRQ)(int cycledone);
|
||||
typedef void (*MapperDump)(FILE *fp);
|
||||
|
||||
#ifdef __TINES_MAPPERS__
|
||||
|
||||
@ -33,20 +32,21 @@ extern NesCart *Cart;
|
||||
#define GETLAST16KBANK(c) ((c->PROMSize>>14)-1)
|
||||
#define GETLAST32KBANK(c) ((c->PROMSize>>15)-1)
|
||||
|
||||
void set_vrom_bank_1k(uint16_t addr,int slot);
|
||||
void set_vrom_bank_2k(uint16_t addr,int slot);
|
||||
void set_vrom_bank_4k(uint16_t addr,int slot);
|
||||
void set_vrom_bank_1k(uint16_t addr, int slot);
|
||||
void set_vrom_bank_2k(uint16_t addr, int slot);
|
||||
void set_vrom_bank_4k(uint16_t addr, int slot);
|
||||
void set_vrom_bank_8k(uint16_t addr, int slot);
|
||||
|
||||
void set_prom_bank_8k(uint16_t addr,int slot);
|
||||
void set_prom_bank_16k(uint16_t addr,int slot);
|
||||
void set_prom_bank_32k(uint16_t addr,int slot);
|
||||
void set_prom_bank_8k(uint16_t addr, int slot);
|
||||
void set_prom_bank_16k(uint16_t addr, int slot);
|
||||
void set_prom_bank_32k(uint16_t addr, int slot);
|
||||
|
||||
#else /* __TINES_MAPPERS__ */
|
||||
|
||||
/* Available functions outside of mappers */
|
||||
|
||||
void mapper_list();
|
||||
|
||||
int mapper_init(NesCart *cart);
|
||||
|
||||
extern MapperIRQ mapper_irqloop;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* 6502 Memory manager - The peTI-NESulator Project
|
||||
* memory.h - Taken from the Quick6502 project
|
||||
*
|
||||
* Created by Manoel Trapier on 18/09/06.
|
||||
* Created by Manoël Trapier on 18/09/06.
|
||||
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -19,6 +19,7 @@
|
||||
#define ATTR_PAGE_MAPPED 0x01
|
||||
|
||||
typedef uint8_t (*func_rdhook)(uint8_t /* addr */);
|
||||
|
||||
typedef void (*func_wrhook)(uint8_t addr, uint8_t data);
|
||||
|
||||
/* Functions to manage pages data */
|
||||
@ -29,35 +30,23 @@ void set_page_ptr_4k(uint8_t page, uint8_t *ptr);
|
||||
void set_page_ptr_8k(uint8_t page, uint8_t *ptr);
|
||||
void set_page_ptr_16k(uint8_t page, uint8_t *ptr);
|
||||
void set_page_ptr_32k(uint8_t page, uint8_t *ptr);
|
||||
|
||||
uint8_t *get_page_ptr(uint8_t page);
|
||||
|
||||
|
||||
/* Functions to set pages attributes */
|
||||
|
||||
void set_page_rd_hook(uint8_t page, func_rdhook func);
|
||||
|
||||
void set_page_wr_hook(uint8_t page, func_wrhook func);
|
||||
|
||||
void set_page_readable(uint8_t page, uint8_t value);
|
||||
|
||||
void set_page_writeable(uint8_t page, uint8_t value);
|
||||
|
||||
void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost);
|
||||
|
||||
uint8_t get_page_attributes(uint8_t page);
|
||||
|
||||
func_rdhook get_page_rdhook(uint8_t page);
|
||||
|
||||
func_wrhook get_page_wrhook(uint8_t page);
|
||||
|
||||
/* Generalist functions */
|
||||
|
||||
void InitMemory();
|
||||
|
||||
uint8_t ReadMemory(uint8_t page, uint8_t addr);
|
||||
void WriteMemory(uint8_t page, uint8_t addr, uint8_t value);
|
||||
|
||||
void DumpMemoryState(FILE *fp);
|
||||
|
||||
#endif
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* OS Dependent functions - The peTI-NESulator Project
|
||||
* os_dependent.h
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Created by Manoël TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -21,7 +21,7 @@ int graphics_drawline(long x, long y, long x1, long y1, long color);
|
||||
|
||||
typedef struct Palette_t
|
||||
{
|
||||
uint8_t r,g,b,a;
|
||||
uint8_t r, g, b, a;
|
||||
} Palette;
|
||||
|
||||
int getKeyStatus(int key);
|
||||
@ -29,7 +29,7 @@ int getKeyStatus(int key);
|
||||
/* Sound related functions */
|
||||
|
||||
/* IO functions */
|
||||
void *LoadFilePtr(char * filename);
|
||||
void *LoadFilePtr(char *filename);
|
||||
|
||||
/* Console functions */
|
||||
typedef enum ConsoleLevel_t
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Paddle manager - The peTI-NESulator Project
|
||||
* paddle.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -12,20 +12,12 @@
|
||||
|
||||
typedef struct Paddle_
|
||||
{
|
||||
|
||||
uint8_t Bit;
|
||||
|
||||
uint8_t LastWrite;
|
||||
|
||||
} Paddle;
|
||||
|
||||
|
||||
uint8_t ReadPaddle(Paddle * pdl);
|
||||
|
||||
|
||||
void InitPaddle(Paddle * pdl);
|
||||
|
||||
void WritePaddle(Paddle * pdl, uint8_t val);
|
||||
|
||||
uint8_t ReadPaddle(Paddle *pdl);
|
||||
void InitPaddle(Paddle *pdl);
|
||||
void WritePaddle(Paddle *pdl, uint8_t val);
|
||||
|
||||
#endif
|
||||
|
||||
@ -257,4 +257,4 @@ Palette basicPalette[] = {
|
||||
{ 0x32, 0x31, 0x32, 0xB7 },
|
||||
{ 0x01, 0x01, 0x01, 0x08 },
|
||||
{ 0x01, 0x01, 0x01, 0xBF },
|
||||
};
|
||||
};
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
* Plugins manager - The peTI-NESulator Project
|
||||
* plugins.h
|
||||
*
|
||||
* Created by Manoel TRAPIER on 02/04/07.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Created by Manoël TRAPIER on 02/04/07.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
#include <types.h>
|
||||
|
||||
/* Function pointer for prototyping function that plugins may export */
|
||||
typedef int (*PluginInit) (void);
|
||||
typedef int (*PluginDeinit) (void);
|
||||
typedef void (*PluginKeypress) (void);
|
||||
typedef int (*PluginInit)(void);
|
||||
typedef int (*PluginDeinit)(void);
|
||||
typedef void (*PluginKeypress)(void);
|
||||
|
||||
#ifdef __TINES_PLUGINS__
|
||||
|
||||
@ -30,12 +30,9 @@ int plugin_keypress(uint8_t key);
|
||||
|
||||
/* Real Prototype: TBD */
|
||||
void plugin_list();
|
||||
|
||||
int plugin_load(int id);
|
||||
|
||||
int plugin_unload(int id);
|
||||
|
||||
|
||||
#endif /* __TINES_PLUGINS__ */
|
||||
|
||||
#endif /* PLUGINS_H */
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* PPU debug utilities - The peTI-NESulator Project
|
||||
* ppu.debug.h
|
||||
*
|
||||
* Created by Manoel Trapier on 12/04/07.
|
||||
* Created by Manoël Trapier on 12/04/07.
|
||||
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Define and emulate the PPU (Picture Processing Unit) of the real NES
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -26,13 +26,9 @@ typedef struct PPU_Sprite_
|
||||
PPU must be initialized after memory initialisation..
|
||||
*/
|
||||
int ppu_init();
|
||||
|
||||
int ppu_hblank(uint16_t scanline);
|
||||
|
||||
uint8_t ppu_readReg(uint8_t id);
|
||||
|
||||
void ppu_writeReg(uint8_t id, uint8_t val);
|
||||
|
||||
void ppu_fillSprRamDMA(uint8_t value);
|
||||
|
||||
#define PPU_MIRROR_HORIZTAL 0
|
||||
@ -50,13 +46,9 @@ void ppu_fillSprRamDMA(uint8_t value);
|
||||
void ppu_setMirroring(uint8_t direction);
|
||||
void ppu_setSingleScreen(uint8_t screen);
|
||||
void ppu_setScreenMode(uint8_t mode);
|
||||
|
||||
|
||||
PPU_Sprite ppu_getSprite(uint16_t i);
|
||||
|
||||
uint8_t ppu_memoryRead(uint8_t page, uint8_t addr);
|
||||
void ppu_memoryWrite(uint8_t page, uint8_t addr, uint8_t value);
|
||||
|
||||
void ppu_debugSprites();
|
||||
void ppu_debugColor();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* PPU Memory manager - The peTI-NESulator Project
|
||||
* ppu.memory.h - Inspired from the memory manager of the Quick6502 Project.
|
||||
*
|
||||
* Created by Manoel Trapier on 12/04/07.
|
||||
* Created by Manoël Trapier on 12/04/07.
|
||||
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -11,17 +11,14 @@
|
||||
|
||||
int ppu_initMemory();
|
||||
|
||||
void ppu_setPagePtr (uint8_t page, uint8_t *ptr);
|
||||
void ppu_setPagePtr(uint8_t page, uint8_t *ptr);
|
||||
void ppu_setPagePtr1k(uint8_t page, uint8_t *ptr);
|
||||
void ppu_setPagePtr2k(uint8_t page, uint8_t *ptr);
|
||||
void ppu_setPagePtr4k(uint8_t page, uint8_t *ptr);
|
||||
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
|
||||
|
||||
void ppu_memoryDumpState(FILE *fp);
|
||||
|
||||
uint8_t ppu_readMemory(uint8_t page, uint8_t addr);
|
||||
void ppu_writeMemory(uint8_t page, uint8_t addr, uint8_t value);
|
||||
|
||||
void ppu_setPageGhost(uint8_t page, uint8_t value, uint8_t ghost);
|
||||
|
||||
#else
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Base type definitions - The peTI-NESulator Project
|
||||
* types.h - Taken from the Quick6502 project
|
||||
*
|
||||
* Created by Manoel Trapier on 18/09/06.
|
||||
* Created by Manoël Trapier on 18/09/06.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
72
src/log.c
72
src/log.c
@ -2,14 +2,9 @@
|
||||
* Log Facility - The Quick6502 Project
|
||||
* log.c
|
||||
*
|
||||
* Created by Manoel Trapier on 19/05/10
|
||||
* Created by Manoël Trapier on 19/05/10
|
||||
* Copyright 2010 986 Corp. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate:$
|
||||
* $Author:$
|
||||
* $HeadURL:$
|
||||
* $Revision:$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -22,6 +17,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifdef TIME_STAMP_LOG
|
||||
|
||||
void time_stamp_line(void)
|
||||
{
|
||||
/* Time "0" will be thefirst log line */
|
||||
@ -42,8 +38,8 @@ void time_stamp_line(void)
|
||||
firstTime.tv_usec = curTime.tv_usec;
|
||||
}
|
||||
|
||||
cMSec = ((curTime.tv_sec - firstTime.tv_sec)* 1000) + (curTime.tv_usec - firstTime.tv_usec)/1000;
|
||||
cSec = (cMSec/1000);
|
||||
cMSec = ((curTime.tv_sec - firstTime.tv_sec) * 1000) + (curTime.tv_usec - firstTime.tv_usec) / 1000;
|
||||
cSec = (cMSec / 1000);
|
||||
cMSec %= 1000;
|
||||
|
||||
cMin = cSec / 60;
|
||||
@ -54,9 +50,11 @@ void time_stamp_line(void)
|
||||
printf("%c[s", 0x1B);
|
||||
printf("%c[7000D", 0x1B);
|
||||
printf("%c[1C", 0x1B);
|
||||
printf(FWHITE"[" FYELLOW "%03d" FRED "." FBLUE "%02d" FRED "." FGREEN "%03lld" FWHITE "]" CNORMAL, cMin, cSec, cMSec);
|
||||
printf(FWHITE"[" FYELLOW "%03d" FRED "." FBLUE "%02d" FRED "." FGREEN "%03lld" FWHITE "]" CNORMAL, cMin, cSec,
|
||||
cMSec);
|
||||
printf("%c[u", 0x1B);
|
||||
}
|
||||
|
||||
#endif /* TIME_STAMP_LOG */
|
||||
|
||||
void log_real(int level, char *user, char *fmt, ...)
|
||||
@ -66,15 +64,27 @@ void log_real(int level, char *user, char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
switch(level)
|
||||
switch (level)
|
||||
{
|
||||
case LOG_PANIC: printf(BRED FWHITE); break;
|
||||
case LOG_ERROR: printf(FRED); break;
|
||||
case LOG_WARNING: printf(FYELLOW); break;
|
||||
case LOG_PANIC:
|
||||
printf(BRED FWHITE);
|
||||
break;
|
||||
case LOG_ERROR:
|
||||
printf(FRED);
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
printf(FYELLOW);
|
||||
break;
|
||||
default:
|
||||
case LOG_NORMAL: printf(FGREEN); break;
|
||||
case LOG_VERBOSE: printf(FCYAN); break;
|
||||
case LOG_DEBUG: printf(BBLUE FWHITE); break;
|
||||
case LOG_NORMAL:
|
||||
printf(FGREEN);
|
||||
break;
|
||||
case LOG_VERBOSE:
|
||||
printf(FCYAN);
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
printf(BBLUE FWHITE);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef TIME_STAMP_LOG
|
||||
@ -88,22 +98,36 @@ void log_real(int level, char *user, char *fmt, ...)
|
||||
if (i < 12)
|
||||
{
|
||||
i = 12 - i;
|
||||
for (; i >= 0; i--)
|
||||
for (; i >= 0 ; i--)
|
||||
{
|
||||
putchar(' ');
|
||||
}
|
||||
}
|
||||
printf("%s", user);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(level)
|
||||
switch (level)
|
||||
{
|
||||
case LOG_PANIC: printf(" PANIC"); break;
|
||||
case LOG_ERROR: printf(" Error"); break;
|
||||
case LOG_WARNING: printf(" Warning"); break;
|
||||
case LOG_PANIC:
|
||||
printf(" PANIC");
|
||||
break;
|
||||
case LOG_ERROR:
|
||||
printf(" Error");
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
printf(" Warning");
|
||||
break;
|
||||
default:
|
||||
case LOG_NORMAL: printf(" Info"); break;
|
||||
case LOG_VERBOSE: printf(" Verbose"); break;
|
||||
case LOG_DEBUG: printf(" Debug"); break;
|
||||
case LOG_NORMAL:
|
||||
printf(" Info");
|
||||
break;
|
||||
case LOG_VERBOSE:
|
||||
printf(" Verbose");
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
printf(" Debug");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
245
src/main.c
245
src/main.c
@ -2,7 +2,7 @@
|
||||
* Main application source file - The peTI-NESulator Project
|
||||
* main.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -74,17 +74,10 @@ double APU_BASEFREQ = 1.7897725;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef USE_SOUND
|
||||
#undef USE_SOUND
|
||||
#endif
|
||||
|
||||
/* SVN specific values */
|
||||
|
||||
#define VS_REVISION "$Revision$"
|
||||
#define VS_LASTCHANGEDDATE "$LastChangedDate$"
|
||||
#define VS_AUTHOR "$Author$"
|
||||
|
||||
/*
|
||||
#define MAXLASTOP 42
|
||||
|
||||
@ -123,20 +116,18 @@ short IRQScanHit = -1;
|
||||
short SZHit = -1;
|
||||
|
||||
/* palette */
|
||||
uint32_t ColorPalette[ 8 * 63 ];
|
||||
uint32_t ColorPalette[8 * 63];
|
||||
|
||||
#define SET_RGB(r,g,b) ((((r<<8)|g)<<8)|b)|0xFF000000
|
||||
#define SET_RGB(_r, _g, _b) (((_r) << 16) | ((_g) << 8) | (_b) | 0xFF000000)
|
||||
|
||||
/* Memory functions */
|
||||
uint8_t MemoryRead (uint16_t Addr);
|
||||
uint8_t MemoryOpCodeRead (uint16_t Addr);
|
||||
uint8_t MemoryStackRead (uint16_t Addr);
|
||||
uint8_t MemoryPageZeroRead (uint16_t Addr);
|
||||
|
||||
void MemoryWrite (uint16_t Addr, uint8_t Value);
|
||||
void MemoryStackWrite (uint16_t Addr, uint8_t Value);
|
||||
void MemoryPageZeroWrite (uint16_t Addr, uint8_t Value);
|
||||
|
||||
uint8_t MemoryRead(uint16_t Addr);
|
||||
uint8_t MemoryOpCodeRead(uint16_t Addr);
|
||||
uint8_t MemoryStackRead(uint16_t Addr);
|
||||
uint8_t MemoryPageZeroRead(uint16_t Addr);
|
||||
void MemoryWrite(uint16_t Addr, uint8_t Value);
|
||||
void MemoryStackWrite(uint16_t Addr, uint8_t Value);
|
||||
void MemoryPageZeroWrite(uint16_t Addr, uint8_t Value);
|
||||
void Loop6502(quick6502_cpu *R);
|
||||
|
||||
void CloseHook(void)
|
||||
@ -155,7 +146,7 @@ void SaveSaveRam(char *name)
|
||||
if ((fp = fopen(fname, "wb")))
|
||||
{
|
||||
console_printf(Console_Default, "Saving savestate '%s'\n", fname);
|
||||
for( i = 0x60; i < 0x80; i++)
|
||||
for (i = 0x60 ; i < 0x80 ; i++)
|
||||
{
|
||||
fwrite(get_page_ptr(i), 1, 0x100, fp);
|
||||
}
|
||||
@ -175,7 +166,7 @@ void LoadSaveRam(char *name)
|
||||
if ((fp = fopen(fname, "rb")))
|
||||
{
|
||||
console_printf(Console_Default, "Loading savestate '%s'\n", fname);
|
||||
for( i = 0x60; i < 0x80; i++)
|
||||
for (i = 0x60 ; i < 0x80 ; i++)
|
||||
{
|
||||
fread(get_page_ptr(i), 1, 0x0100, fp);
|
||||
}
|
||||
@ -193,7 +184,7 @@ void LoadPalette(char *filename, Palette *pal)
|
||||
if ((fp = fopen(filename, "rb")) != NULL)
|
||||
{
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
for (i = 0 ; i < 64 ; i++)
|
||||
{
|
||||
|
||||
fread(&r, 1, 1, fp);
|
||||
@ -258,7 +249,7 @@ void LoadPalette(char *filename, Palette *pal)
|
||||
|
||||
void signalhandler(int sig)
|
||||
{
|
||||
static int state=0;
|
||||
static int state = 0;
|
||||
|
||||
char name[512];
|
||||
|
||||
@ -272,32 +263,50 @@ void signalhandler(int sig)
|
||||
state = 1;
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
fp = fopen(name, "wt");
|
||||
}
|
||||
|
||||
state = 2;
|
||||
|
||||
if (fp) console_printf(Console_Error,
|
||||
if (fp)
|
||||
{
|
||||
console_printf(Console_Error,
|
||||
"\n\n\n\n\n"
|
||||
"#sick# peTI-NESulator %d.%d.%d%s #sick#\n"
|
||||
"see %s for more information",
|
||||
V_MAJOR, V_MINOR, V_MICRO, V_TEXT,
|
||||
name);
|
||||
}
|
||||
|
||||
if (!fp) fp = stderr;
|
||||
if (!fp)
|
||||
{
|
||||
fp = stderr;
|
||||
}
|
||||
|
||||
fprintf(fp,"\n\n\n\n\n"
|
||||
fprintf(fp, "\n\n\n\n\n"
|
||||
"#sick# peTI-NESulator %d.%d.%d%s #sick# signal: ",
|
||||
V_MAJOR, V_MINOR, V_MICRO, V_TEXT);
|
||||
switch(sig)
|
||||
switch (sig)
|
||||
{
|
||||
default:
|
||||
case SIGABRT: fprintf(fp,"Abnormal termination"); break;
|
||||
case SIGILL: fprintf(fp,"Illegal instruction"); break;
|
||||
case SIGINT: fprintf(fp,"CTRL+C signal"); break;
|
||||
case SIGSEGV: fprintf(fp,"Segmentation fault"); break;
|
||||
case SIGTERM: fprintf(fp,"Termination request"); break;
|
||||
case SIGABRT:
|
||||
fprintf(fp, "Abnormal termination");
|
||||
break;
|
||||
case SIGILL:
|
||||
fprintf(fp, "Illegal instruction");
|
||||
break;
|
||||
case SIGINT:
|
||||
fprintf(fp, "CTRL+C signal");
|
||||
break;
|
||||
case SIGSEGV:
|
||||
fprintf(fp, "Segmentation fault");
|
||||
break;
|
||||
case SIGTERM:
|
||||
fprintf(fp, "Termination request");
|
||||
break;
|
||||
}
|
||||
fprintf(fp,"\nAn error occured during the excution.\n Crash report information :\n");
|
||||
fprintf(fp, "\nAn error occurred during the excution.\n Crash report information :\n");
|
||||
|
||||
//quick6502_dump(cpu, fp);
|
||||
|
||||
@ -337,7 +346,10 @@ void signalhandler(int sig)
|
||||
DumpMemoryState(fp);
|
||||
|
||||
console_printf(Console_Error, "\nPlease join this informations when submiting crash report\n");
|
||||
if (fp != stderr) fclose(fp);
|
||||
if (fp != stderr)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
exit(-42);
|
||||
}
|
||||
@ -346,7 +358,7 @@ uint8_t Page40[256];
|
||||
|
||||
void WrHook4000Multiplexer(uint8_t addr, uint8_t value)
|
||||
{
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case 0x14:
|
||||
ppu_fillSprRamDMA(value);
|
||||
@ -375,7 +387,7 @@ void WrHook4000Multiplexer(uint8_t addr, uint8_t value)
|
||||
uint8_t RdHook4000Multiplexer(uint8_t addr)
|
||||
{
|
||||
uint8_t ret;
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case 0x16:
|
||||
ret = ReadPaddle(&P1);
|
||||
@ -438,7 +450,7 @@ int main(int argc, char *argv[])
|
||||
/* Print the banner */
|
||||
console_printf(Console_Default, "--------------------------------------------------------------------------------\n"
|
||||
"Welcome to peTI-NESulator v%d.%d.%d%s - by Godzil`\n"
|
||||
"Copyright 2003-2018 Manoel TRAPIER (petines@godzil.net)\n"
|
||||
"Copyright 2003-2018 Manoël TRAPIER (petines@godzil.net)\n"
|
||||
"--------------------------------------------------------------------------------\n\n",
|
||||
V_MAJOR, V_MINOR, V_MICRO, V_TEXT);
|
||||
|
||||
@ -460,9 +472,9 @@ int main(int argc, char *argv[])
|
||||
console_printf(Console_Default, "[ OK ]\n");
|
||||
console_printf(Console_Default, "Parsing parameters (%d)...\n", argc);
|
||||
/* Now we use a real argument parser ! */
|
||||
for(i = 1 ; (i < argc) && (argv[i][0]=='-'); i++)
|
||||
for (i = 1 ; (i < argc) && (argv[i][0] == '-') ; i++)
|
||||
{
|
||||
switch(argv[i][1])
|
||||
switch (argv[i][1])
|
||||
{
|
||||
default: /* Option not recognized */
|
||||
case 'h': /* ask for help */
|
||||
@ -470,10 +482,10 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (atoi(argv[i+1]) != 0)
|
||||
if (atoi(argv[i + 1]) != 0)
|
||||
{
|
||||
console_printf(Console_Default, "-Load plugin #%d...\n", atoi(argv[i+1]));
|
||||
if ( plugin_load(atoi(argv[i+1])) == -1)
|
||||
console_printf(Console_Default, "-Load plugin #%d...\n", atoi(argv[i + 1]));
|
||||
if (plugin_load(atoi(argv[i + 1])) == -1)
|
||||
{
|
||||
plugin_list();
|
||||
exit(0);
|
||||
@ -498,59 +510,61 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
console_printf(Console_Default, "-Palette file is %s\n", argv[i+1]);
|
||||
PALETTE_FILENAME = argv[i+1];
|
||||
console_printf(Console_Default, "-Palette file is %s\n", argv[i + 1]);
|
||||
PALETTE_FILENAME = argv[i + 1];
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CART_FILENAME = argv[argc-1];
|
||||
CART_FILENAME = argv[argc - 1];
|
||||
|
||||
if (CART_FILENAME == NULL)
|
||||
{
|
||||
printUsage(argc, argv);
|
||||
}
|
||||
|
||||
console_printf(Console_Default, "Allocating 6502 memory\t\t");
|
||||
|
||||
/* Allocating first 0x7FF memory */
|
||||
MemoryPage = (uint8_t *)malloc (0x800);
|
||||
set_page_ptr_2k(0,MemoryPage);
|
||||
for (i = 0; i < 0x08; i++)
|
||||
MemoryPage = (uint8_t *)malloc(0x800);
|
||||
set_page_ptr_2k(0, MemoryPage);
|
||||
for (i = 0 ; i < 0x08 ; i++)
|
||||
{
|
||||
set_page_readable(i, true);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
|
||||
/* Set ghost starting from 0x800 */
|
||||
set_page_ghost(0x08,true,0x00);
|
||||
set_page_ghost(0x09,true,0x01);
|
||||
set_page_ghost(0x0A,true,0x02);
|
||||
set_page_ghost(0x0B,true,0x03);
|
||||
set_page_ghost(0x0C,true,0x04);
|
||||
set_page_ghost(0x0D,true,0x05);
|
||||
set_page_ghost(0x0E,true,0x06);
|
||||
set_page_ghost(0x0F,true,0x07);
|
||||
set_page_ghost(0x08, true, 0x00);
|
||||
set_page_ghost(0x09, true, 0x01);
|
||||
set_page_ghost(0x0A, true, 0x02);
|
||||
set_page_ghost(0x0B, true, 0x03);
|
||||
set_page_ghost(0x0C, true, 0x04);
|
||||
set_page_ghost(0x0D, true, 0x05);
|
||||
set_page_ghost(0x0E, true, 0x06);
|
||||
set_page_ghost(0x0F, true, 0x07);
|
||||
|
||||
/* Set ghost starting from 0x1000 */
|
||||
set_page_ghost(0x10,true,0x00);
|
||||
set_page_ghost(0x11,true,0x01);
|
||||
set_page_ghost(0x12,true,0x02);
|
||||
set_page_ghost(0x13,true,0x03);
|
||||
set_page_ghost(0x14,true,0x04);
|
||||
set_page_ghost(0x15,true,0x05);
|
||||
set_page_ghost(0x16,true,0x06);
|
||||
set_page_ghost(0x17,true,0x07);
|
||||
set_page_ghost(0x10, true, 0x00);
|
||||
set_page_ghost(0x11, true, 0x01);
|
||||
set_page_ghost(0x12, true, 0x02);
|
||||
set_page_ghost(0x13, true, 0x03);
|
||||
set_page_ghost(0x14, true, 0x04);
|
||||
set_page_ghost(0x15, true, 0x05);
|
||||
set_page_ghost(0x16, true, 0x06);
|
||||
set_page_ghost(0x17, true, 0x07);
|
||||
|
||||
/* Set ghost starting from 0x1800 */
|
||||
set_page_ghost(0x18,true,0x00);
|
||||
set_page_ghost(0x19,true,0x01);
|
||||
set_page_ghost(0x1A,true,0x02);
|
||||
set_page_ghost(0x1B,true,0x03);
|
||||
set_page_ghost(0x1C,true,0x04);
|
||||
set_page_ghost(0x1D,true,0x05);
|
||||
set_page_ghost(0x1E,true,0x06);
|
||||
set_page_ghost(0x1F,true,0x07);
|
||||
set_page_ghost(0x18, true, 0x00);
|
||||
set_page_ghost(0x19, true, 0x01);
|
||||
set_page_ghost(0x1A, true, 0x02);
|
||||
set_page_ghost(0x1B, true, 0x03);
|
||||
set_page_ghost(0x1C, true, 0x04);
|
||||
set_page_ghost(0x1D, true, 0x05);
|
||||
set_page_ghost(0x1E, true, 0x06);
|
||||
set_page_ghost(0x1F, true, 0x07);
|
||||
|
||||
/* Set 0x4000 registers */
|
||||
|
||||
@ -566,7 +580,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* ROM ptr will be set by mapper */
|
||||
/* But we will set the readable bit */
|
||||
for (i = 0x80; i < 0x100; i++)
|
||||
for (i = 0x80 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_readable(i, true);
|
||||
set_page_writeable(i, false);
|
||||
@ -606,7 +620,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
/* SRAM (0x6000 : 0x2000 uint8_ts ) */
|
||||
MemoryPage = (uint8_t *)malloc (0x2000);
|
||||
MemoryPage = (uint8_t *)malloc(0x2000);
|
||||
|
||||
set_page_ptr_8k(0x60, MemoryPage);
|
||||
|
||||
@ -641,7 +655,7 @@ int main(int argc, char *argv[])
|
||||
console_printf(Console_Default, "[ OK ]\n");
|
||||
#endif
|
||||
|
||||
Cart = malloc( sizeof (NesCart));
|
||||
Cart = malloc(sizeof(NesCart));
|
||||
if (Cart == NULL)
|
||||
{
|
||||
console_printf(Console_Error, "Memory allocation error...\n");
|
||||
@ -660,7 +674,7 @@ int main(int argc, char *argv[])
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
FDSRom = mmap(NULL, 8*1024, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
FDSRom = mmap(NULL, 8 * 1024, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
console_printf(Console_Default, "%p [ OK ]\n", FDSRom);
|
||||
close(fd);
|
||||
|
||||
@ -668,7 +682,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
console_printf(Console_Default, "Allocating FDS RAM...\n");
|
||||
|
||||
FDSRam = (uint8_t*) malloc( (8+16) * 1024);
|
||||
FDSRam = (uint8_t *)malloc((8 + 16) * 1024);
|
||||
|
||||
if (FDSRam == NULL)
|
||||
{
|
||||
@ -676,9 +690,9 @@ int main(int argc, char *argv[])
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for (i = 0x80; i < 0xE0; i++)
|
||||
for (i = 0x80 ; i < 0xE0 ; i++)
|
||||
{
|
||||
set_page_ptr(i, FDSRam + (i*0x100));
|
||||
set_page_ptr(i, FDSRam + (i * 0x100));
|
||||
set_page_readable(i, true);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
@ -723,12 +737,14 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
ppu_setScreenMode(PPU_SCMODE_NORMAL);
|
||||
ppu_setMirroring((Cart->Flags & iNES_MIRROR)?PPU_MIRROR_VERTICAL:PPU_MIRROR_HORIZTAL);
|
||||
ppu_setMirroring((Cart->Flags & iNES_MIRROR) ? PPU_MIRROR_VERTICAL : PPU_MIRROR_HORIZTAL);
|
||||
}
|
||||
|
||||
console_printf(Console_Default, "Init mapper...\t\t\t");
|
||||
if (mapper_init(Cart) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
console_printf(Console_Default, "[ OK ]\n");
|
||||
|
||||
// set_palette(basicPalette);
|
||||
@ -759,7 +775,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
gettimeofday(&timeStart, NULL);
|
||||
|
||||
while(!WantClosing)
|
||||
while (!WantClosing)
|
||||
{
|
||||
ccount += quick6502_run(MainCPU, HBLANK_TIME);
|
||||
|
||||
@ -785,76 +801,77 @@ extern uint8_t *memory_pages[0xFF];
|
||||
/* Memory functions */
|
||||
|
||||
/* Read memory, general function */
|
||||
uint8_t MemoryRead (uint16_t Addr)
|
||||
uint8_t MemoryRead(uint16_t Addr)
|
||||
{
|
||||
return ReadMemory((Addr&0xFF00)>>8,Addr&0x00FF);
|
||||
return ReadMemory((Addr & 0xFF00) >> 8, Addr & 0x00FF);
|
||||
}
|
||||
|
||||
/* Read memory for opcode (need fast access) */
|
||||
uint8_t MemoryOpCodeRead (uint16_t Addr)
|
||||
uint8_t MemoryOpCodeRead(uint16_t Addr)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
return ((ptr = memory_pages[(Addr&0xFF00)>>8])>(uint8_t*)1)?ptr[Addr&0x00FF]:0xEA;
|
||||
return ((ptr = memory_pages[(Addr & 0xFF00) >> 8]) > (uint8_t *)1) ? ptr[Addr & 0x00FF] : 0xEA;
|
||||
}
|
||||
|
||||
uint8_t MemoryStackRead (uint16_t Addr)
|
||||
uint8_t MemoryStackRead(uint16_t Addr)
|
||||
{
|
||||
uint8_t *ptr = memory_pages[1];
|
||||
return ptr[Addr&0x00FF];
|
||||
return ptr[Addr & 0x00FF];
|
||||
}
|
||||
|
||||
uint8_t MemoryPageZeroRead (uint16_t Addr)
|
||||
uint8_t MemoryPageZeroRead(uint16_t Addr)
|
||||
{
|
||||
uint8_t *ptr = memory_pages[0];
|
||||
return ptr[Addr&0x00FF];
|
||||
return ptr[Addr & 0x00FF];
|
||||
}
|
||||
|
||||
/* Write to memory, general function */
|
||||
void MemoryWrite (uint16_t Addr, uint8_t Value)
|
||||
void MemoryWrite(uint16_t Addr, uint8_t Value)
|
||||
{
|
||||
WriteMemory((Addr&0xFF00)>>8,Addr&0x00FF, Value);
|
||||
WriteMemory((Addr & 0xFF00) >> 8, Addr & 0x00FF, Value);
|
||||
}
|
||||
|
||||
void MemoryStackWrite (uint16_t Addr, uint8_t Value)
|
||||
void MemoryStackWrite(uint16_t Addr, uint8_t Value)
|
||||
{
|
||||
uint8_t *ptr = memory_pages[1];
|
||||
ptr[Addr&0x00FF] = Value;
|
||||
ptr[Addr & 0x00FF] = Value;
|
||||
}
|
||||
|
||||
void MemoryPageZeroWrite (uint16_t Addr, uint8_t Value)
|
||||
void MemoryPageZeroWrite(uint16_t Addr, uint8_t Value)
|
||||
{
|
||||
uint8_t *ptr = memory_pages[0];
|
||||
ptr[Addr&0x00FF] = Value;
|
||||
ptr[Addr & 0x00FF] = Value;
|
||||
}
|
||||
|
||||
void Loop6502(quick6502_cpu *R)
|
||||
{
|
||||
uint8_t ret;
|
||||
quick6502_signal cpuSignal;
|
||||
// short skey;
|
||||
long WaitTime;
|
||||
static long delta=0;
|
||||
static long delta = 0;
|
||||
|
||||
ret = 0;
|
||||
cpuSignal = Q6502_NO_SIGNAL;
|
||||
|
||||
if ( (mapper_irqloop) && ( mapper_irqloop (ScanLine) ) )
|
||||
if ((mapper_irqloop) && (mapper_irqloop(ScanLine)))
|
||||
{
|
||||
ret = Q6502_IRQ_SIGNAL;
|
||||
cpuSignal = Q6502_IRQ_SIGNAL;
|
||||
IRQScanHit = ScanLine;
|
||||
}
|
||||
|
||||
if ( MapperWantIRQ == 1)
|
||||
if (MapperWantIRQ == 1)
|
||||
{
|
||||
MapperWantIRQ = 0;
|
||||
ret = Q6502_IRQ_SIGNAL;
|
||||
cpuSignal = Q6502_IRQ_SIGNAL;
|
||||
}
|
||||
|
||||
if ( ppu_hblank(ScanLine) != 0 )
|
||||
if (ppu_hblank(ScanLine) != 0)
|
||||
{
|
||||
ret = Q6502_NMI_SIGNAL;
|
||||
cpuSignal = Q6502_NMI_SIGNAL;
|
||||
}
|
||||
|
||||
if (ScanLine == (239 + VBLANK_TIME))
|
||||
{ /* End of VBlank Time */
|
||||
{
|
||||
/* End of VBlank Time */
|
||||
frame++;
|
||||
SZHit = -1;
|
||||
IRQScanHit = -1;
|
||||
@ -876,8 +893,12 @@ void Loop6502(quick6502_cpu *R)
|
||||
/* If we press Page Up, we want to accelerate "time" */
|
||||
#ifndef RUN_COVERAGE
|
||||
if (!getKeyStatus('Y'))
|
||||
{
|
||||
if ((WaitTime >= 0) && (WaitTime < 100000))
|
||||
{
|
||||
usleep(WaitTime);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now get the time after sleep */
|
||||
@ -892,20 +913,28 @@ void Loop6502(quick6502_cpu *R)
|
||||
|
||||
/* To avoid strange time warp when stopping emulation or using acceleration a lot */
|
||||
if ((delta > 10000) || (delta < -10000))
|
||||
{
|
||||
delta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* There is Two dummy scanline */
|
||||
if (ScanLine >= (239 + VBLANK_TIME + 4))
|
||||
{
|
||||
ScanLine = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanLine++;
|
||||
}
|
||||
|
||||
//console_printf(Console_Default, "SL:%d HBT:%d VbT:%d\n", ScanLine, HBLANK_TIME, VBLANK_TIME);
|
||||
|
||||
// TODO: NO DEBUGER
|
||||
if (getKeyStatus(GLFW_KEY_ESCAPE))
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (skey == '9')
|
||||
@ -942,7 +971,9 @@ void Loop6502(quick6502_cpu *R)
|
||||
|
||||
// plugin_keypress(skey);
|
||||
|
||||
if (ret != 0)
|
||||
quick6502_int(R, ret);
|
||||
if (cpuSignal != 0)
|
||||
{
|
||||
quick6502_int(R, cpuSignal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Mapper manager - The peTI-NESulator Project
|
||||
* manager.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -31,28 +31,30 @@ typedef struct Mapper_
|
||||
|
||||
#include "mappers_list.h"
|
||||
|
||||
void mapper_list ()
|
||||
void mapper_list()
|
||||
{
|
||||
Mapper *ptr = &(Mappers[0]);
|
||||
console_printf(Console_Default, "Available mapers:\n");
|
||||
while(ptr->name != NULL)
|
||||
console_printf(Console_Default, "Available mappers:\n");
|
||||
while (ptr->name != NULL)
|
||||
{
|
||||
console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
int mapper_init (NesCart *cart)
|
||||
int mapper_init(NesCart *cart)
|
||||
{
|
||||
Mapper *ptr = &(Mappers[0]);
|
||||
console_printf (Console_Default, "Search for a compatible mapper ID #%d:\n", cart->MapperID);
|
||||
console_printf(Console_Default, "Search for a compatible mapper ID #%d:\n", cart->MapperID);
|
||||
while (ptr->name != NULL)
|
||||
{
|
||||
if (ptr->id == cart->MapperID)
|
||||
{
|
||||
console_printf (Console_Default, "Found mapper ID #%d - '%s'\n", ptr->id, ptr->name);
|
||||
console_printf(Console_Default, "Found mapper ID #%d - '%s'\n", ptr->id, ptr->name);
|
||||
if (ptr->init)
|
||||
ptr->init (cart);
|
||||
{
|
||||
ptr->init(cart);
|
||||
}
|
||||
|
||||
mapper_irqloop = ptr->irq;
|
||||
mapper_dump = ptr->dump;
|
||||
@ -61,6 +63,6 @@ int mapper_init (NesCart *cart)
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
console_printf (Console_Default, "No compatible mapper found!\n");
|
||||
console_printf(Console_Default, "No compatible mapper found!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* AOROM Mapper - The peTI-NESulator Project
|
||||
* aorom.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -15,18 +15,18 @@ void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
|
||||
|
||||
extern uint8_t *ppu_mem_nameTables;
|
||||
|
||||
int aorom_InitMapper(NesCart * cart)
|
||||
int aorom_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
set_prom_bank_32k(0x8000,0);
|
||||
set_prom_bank_32k(0x8000, 0);
|
||||
|
||||
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
||||
|
||||
aorom_load_bank = 0;
|
||||
|
||||
/* Register the write hook */
|
||||
for (i = 0x80; i < 0x100; i++)
|
||||
for (i = 0x80 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, aorom_MapperWriteHook);
|
||||
set_page_writeable(i, true);
|
||||
@ -42,19 +42,23 @@ void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||
int BankNb;
|
||||
|
||||
if (Value & (1 << 4))
|
||||
{
|
||||
ppu_setSingleScreen(PPU_SCREEN_000);
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu_setSingleScreen(PPU_SCREEN_400);
|
||||
}
|
||||
|
||||
BankNb = Value & 0x0F;
|
||||
|
||||
aorom_load_bank = BankNb;
|
||||
|
||||
//console_printf(Console_Default, "aorom: Asking bank %d - NT is 0x%04X\n",BankNb,(Value&0x10)?0x2400:0x2000);
|
||||
set_prom_bank_32k(0x8000,BankNb);
|
||||
set_prom_bank_32k(0x8000, BankNb);
|
||||
}
|
||||
|
||||
void aorom_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"aorom: bank:%d\n",aorom_load_bank);
|
||||
fprintf(fp, "aorom: bank:%d\n", aorom_load_bank);
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* AOROM Mapper - The peTI-NESulator Project
|
||||
* aorom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int aorom_InitMapper(NesCart * cart);
|
||||
int aorom_InitMapper(NesCart *cart);
|
||||
void aorom_MapperDump(FILE *fp);
|
||||
@ -2,7 +2,7 @@
|
||||
* CNROM Mapper - The peTI-NESulator Project
|
||||
* cnrom.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -13,7 +13,7 @@ uint8_t cnrom_load_bank;
|
||||
|
||||
void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
|
||||
|
||||
int cnrom_InitMapper(NesCart * cart)
|
||||
int cnrom_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -22,7 +22,7 @@ int cnrom_InitMapper(NesCart * cart)
|
||||
cnrom_load_bank = 0;
|
||||
|
||||
/* Register the write hook */
|
||||
for (i = 0x80; i < 0x100; i++)
|
||||
for (i = 0x80 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, cnrom_MapperWriteHook);
|
||||
set_page_writeable(i, true);
|
||||
@ -34,11 +34,11 @@ int cnrom_InitMapper(NesCart * cart)
|
||||
|
||||
void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||
{
|
||||
set_prom_bank_16k(0x8000,Value);
|
||||
set_prom_bank_16k(0x8000, Value);
|
||||
cnrom_load_bank = Value;
|
||||
}
|
||||
|
||||
void cnrom_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"cnrom: bank:%d\n",cnrom_load_bank);
|
||||
fprintf(fp, "cnrom: bank:%d\n", cnrom_load_bank);
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* CNROM Mapper - The peTI-NESulator Project
|
||||
* cnrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int cnrom_InitMapper(NesCart * cart);
|
||||
int cnrom_InitMapper(NesCart *cart);
|
||||
void cnrom_MapperDump(FILE *fp);
|
||||
@ -2,8 +2,8 @@
|
||||
* Generic mapper implementation - The peTI-NESulator Project
|
||||
* genericmapper.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* IREMH3001 Mapper - The peTI-NESulator Project
|
||||
* iremh3001.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -13,7 +13,7 @@ uint16_t iremh3001_prom_slot[3];
|
||||
|
||||
uint16_t iremh3001_vrom_slot[8];
|
||||
|
||||
int iremh3001_InitMapper(NesCart * cart)
|
||||
int iremh3001_InitMapper(NesCart *cart)
|
||||
{
|
||||
|
||||
set_prom_bank_16k(0x8000, 0);
|
||||
@ -23,7 +23,7 @@ int iremh3001_InitMapper(NesCart * cart)
|
||||
iremh3001_prom_slot[1] = 1;
|
||||
iremh3001_prom_slot[2] = GETLAST16KBANK(cart);
|
||||
|
||||
set_vrom_bank_8k(0x0000,4);
|
||||
set_vrom_bank_8k(0x0000, 4);
|
||||
|
||||
iremh3001_vrom_slot[0] = 0;
|
||||
iremh3001_vrom_slot[1] = 0;
|
||||
@ -97,12 +97,12 @@ int iremh3001_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||
|
||||
void iremh3001_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"iremh3001: prom: $8000:%d $A000:%d $C000:%d\n",
|
||||
fprintf(fp, "iremh3001: prom: $8000:%d $A000:%d $C000:%d\n",
|
||||
iremh3001_prom_slot[0],
|
||||
iremh3001_prom_slot[1],
|
||||
iremh3001_prom_slot[2]);
|
||||
|
||||
fprintf(fp,"iremh3001: vrom: $0000:%d $0400:%d $0800:%d $0C00:%d\n" \
|
||||
fprintf(fp, "iremh3001: vrom: $0000:%d $0400:%d $0800:%d $0C00:%d\n" \
|
||||
" $1000:%d $1400:%d $1800:%d $1C00:%d\n",
|
||||
iremh3001_vrom_slot[0],
|
||||
iremh3001_vrom_slot[1],
|
||||
|
||||
@ -2,14 +2,15 @@
|
||||
* IREMH3001 Mapper - The peTI-NESulator Project
|
||||
* iremh3001.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int iremh3001_InitMapper(NesCart * cart);
|
||||
int iremh3001_InitMapper(NesCart *cart);
|
||||
void iremh3001_MapperDump(FILE *fp);
|
||||
int iremh3001_MapperIRQ(int cycledone);
|
||||
@ -2,7 +2,7 @@
|
||||
* MMC1 Mapper - The peTI-NESulator Project
|
||||
* mmc1.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -39,10 +39,10 @@ uint8_t mmc1_CurrentBank;
|
||||
#define MMC1_R3_RESET 0x80
|
||||
|
||||
|
||||
#define MMC1_REG0_DEFAULT MMC1_R0_PRGSIZE | MMC1_R0_PRGAREA
|
||||
#define MMC1_REG1_DEFAULT 0
|
||||
#define MMC1_REG2_DEFAULT 0
|
||||
#define MMC1_REG3_DEFAULT 0
|
||||
#define MMC1_REG0_DEFAULT (MMC1_R0_PRGSIZE | MMC1_R0_PRGAREA)
|
||||
#define MMC1_REG1_DEFAULT (0)
|
||||
#define MMC1_REG2_DEFAULT (0)
|
||||
#define MMC1_REG3_DEFAULT (0)
|
||||
|
||||
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value);
|
||||
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value);
|
||||
@ -51,10 +51,10 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value);
|
||||
|
||||
void mmc1_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n",MMC1_reg0,MMC1_reg1,MMC1_reg2,MMC1_reg3);
|
||||
fprintf(fp, "MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n", MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
|
||||
}
|
||||
|
||||
int mmc1_InitMapper(NesCart * cart)
|
||||
int mmc1_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -66,32 +66,34 @@ int mmc1_InitMapper(NesCart * cart)
|
||||
|
||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||
|
||||
set_prom_bank_16k(0x8000,0);
|
||||
set_prom_bank_16k(0x8000, 0);
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||
|
||||
mmc1_CurrentBank = 0;
|
||||
|
||||
if (cart->VROMSize > 0)
|
||||
set_vrom_bank_4k(0x0000,0);
|
||||
{
|
||||
set_vrom_bank_4k(0x0000, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Mapper should register itself for write hook */
|
||||
for (i = 0x80; i < 0xA0 ; i++)
|
||||
for (i = 0x80 ; i < 0xA0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg0);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xA0; i < 0xC0 ; i++)
|
||||
for (i = 0xA0 ; i < 0xC0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg1);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xC0; i < 0xE0 ; i++)
|
||||
for (i = 0xC0 ; i < 0xE0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg2);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xE0; i < 0x100 ; i++)
|
||||
for (i = 0xE0 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg3);
|
||||
set_page_writeable(i, true);
|
||||
@ -121,11 +123,12 @@ Reg 0
|
||||
|
||||
((Addr & 0x6000) >> 13) <- port number
|
||||
*/
|
||||
#define MMC1_GetReg(a) ((a & 0x6000) >> 13)
|
||||
|
||||
#define MMC1_GetReg(_a) (((_a) & 0x6000) >> 13)
|
||||
/* (Val & 0x01) recuperation du bit */
|
||||
#define MMC1_GetBit(v) (v & 0x01)
|
||||
#define MMC1_GetBit(_v) ((_v) & 0x01)
|
||||
/* ( ( b & (1 << Bit)) | (v << Bit) ) Ajout du bit */
|
||||
#define MMC1_AddBit(b,v) ( ( b & ~(1 << Bit)) | (v << Bit) )
|
||||
#define MMC1_AddBit(_b, _v) ( ( (_b) & ~(1 << Bit)) | ( (_v) << Bit) )
|
||||
|
||||
void mmc1_ApplyReg0Mod()
|
||||
{
|
||||
@ -138,6 +141,7 @@ void mmc1_ApplyReg0Mod()
|
||||
|
||||
switch (MMC1_reg0 & 0x03)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
||||
ppu_setSingleScreen(PPU_SCREEN_000);
|
||||
@ -156,19 +160,19 @@ void mmc1_ApplyReg0Mod()
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 ) )
|
||||
if ((OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0))
|
||||
{
|
||||
|
||||
if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
|
||||
{ /* 0x8000 area */
|
||||
set_prom_bank_16k(0x8000,mmc1_CurrentBank);
|
||||
set_prom_bank_16k(0x8000, mmc1_CurrentBank);
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(Cart));
|
||||
}
|
||||
else
|
||||
{ /* 0xC000 area */
|
||||
|
||||
set_prom_bank_16k(0x8000,0);
|
||||
set_prom_bank_16k(0xC000,mmc1_CurrentBank);
|
||||
set_prom_bank_16k(0x8000, 0);
|
||||
set_prom_bank_16k(0xC000, mmc1_CurrentBank);
|
||||
|
||||
}
|
||||
|
||||
@ -186,7 +190,7 @@ void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg0 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg0 Reset occurred !\n");
|
||||
mmc1_ApplyReg0Mod();
|
||||
}
|
||||
else
|
||||
@ -213,7 +217,7 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg1 Reset occurred !\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -233,19 +237,20 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
||||
|
||||
if (Cart->VROMSize == 0)
|
||||
{
|
||||
console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n", VROMBankNb);
|
||||
console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n",
|
||||
VROMBankNb);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
||||
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||
{ /* 4K vram */
|
||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 4k bank %d\n", VROMBankNb);
|
||||
set_vrom_bank_4k(0x0000,VROMBankNb);
|
||||
set_vrom_bank_4k(0x0000, VROMBankNb);
|
||||
}
|
||||
else
|
||||
{ /* 8K vram */
|
||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 8k bank %d\n", VROMBankNb>>1);
|
||||
set_vrom_bank_8k(0x0000,VROMBankNb>>1);
|
||||
set_vrom_bank_8k(0x0000, VROMBankNb >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -256,7 +261,7 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg2 Reset occurred !\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -281,10 +286,10 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
||||
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||
{ /* 4K vram */
|
||||
//console_printf(Console_Default, "Switching VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
||||
set_vrom_bank_4k(0x1000,VROMBankNb);
|
||||
set_vrom_bank_4k(0x1000, VROMBankNb);
|
||||
}
|
||||
else
|
||||
{ /* 8K vram */
|
||||
@ -300,7 +305,7 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg3 Reset occurred !\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -316,28 +321,30 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||
|
||||
MMC1_reg3 = BitBuf;
|
||||
|
||||
if ( ((uint32_t)MMC1_reg3 << 14) > Cart->PROMSize)
|
||||
if (((uint32_t)MMC1_reg3 << 14) > Cart->PROMSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 )
|
||||
if ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0)
|
||||
{ /* 16K Switch */
|
||||
if ( (MMC1_reg0 & MMC1_R0_PRGAREA) != 0 )
|
||||
if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
|
||||
{ /* 0x8000 switch */
|
||||
set_prom_bank_16k(0x8000,MMC1_reg3);
|
||||
set_prom_bank_16k(0x8000, MMC1_reg3);
|
||||
//console_printf(Console_Default, "LowBank is now %d ( 0x%p )\n", MMC1_reg3, mLBank);
|
||||
}
|
||||
else
|
||||
{ /* 0xC000 switch */
|
||||
set_prom_bank_16k(0xC000,MMC1_reg3);
|
||||
set_prom_bank_16k(0xC000, MMC1_reg3);
|
||||
//console_printf(Console_Default, "HighBank is now %d ( 0x%p )\n", MMC1_reg3, mUBank);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* 32K Switch */
|
||||
set_prom_bank_32k(0x8000,MMC1_reg3>>1);
|
||||
set_prom_bank_32k(0x8000, MMC1_reg3 >> 1);
|
||||
}
|
||||
|
||||
if ( ( MMC1_reg3 & MMC1_R3_SAVECE ) != 0)
|
||||
if ((MMC1_reg3 & MMC1_R3_SAVECE) != 0)
|
||||
{
|
||||
unmap_sram();
|
||||
}
|
||||
@ -349,4 +356,4 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||
}
|
||||
}
|
||||
|
||||
//console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
|
||||
//console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
|
||||
|
||||
@ -2,14 +2,15 @@
|
||||
* MMC1 Mapper - The peTI-NESulator Project
|
||||
* mmc1.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int mmc1_InitMapper (NesCart *cart);
|
||||
int mmc1_MapperIRQ (int cycledone);
|
||||
void mmc1_MapperDump (FILE *fp);
|
||||
int mmc1_InitMapper(NesCart *cart);
|
||||
int mmc1_MapperIRQ(int cycledone);
|
||||
void mmc1_MapperDump(FILE *fp);
|
||||
@ -2,7 +2,7 @@
|
||||
* MMC3 Mapper - The peTI-NESulator Project
|
||||
* mmc3.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -27,24 +27,26 @@ uint8_t mmc3_last_prom_switch;
|
||||
|
||||
uint16_t dummy;
|
||||
|
||||
void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t value);
|
||||
void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t value);
|
||||
void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t value);
|
||||
void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t value);
|
||||
void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value);
|
||||
void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t Value);
|
||||
void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value);
|
||||
void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t Value);
|
||||
|
||||
void mmc3_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"MMC3: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n",mmc3_command,mmc3_irq_counter,mmc3_irq_counter_reload,mmc3_irq_enable,mmc3_first_prom_page,mmc3_second_prom_page,mmc3_use_xor);
|
||||
fprintf(fp,"MMC3: LV0:%d LV1:%d LV2:%d LV3:%d LV4:%d LV5:%d\n",mmc3_last_vrom[0],mmc3_last_vrom[1],mmc3_last_vrom[2],mmc3_last_vrom[3],mmc3_last_vrom[4],mmc3_last_vrom[5]);
|
||||
fprintf(fp,"MMC3: LP0:%d LP1:%d LPS:%d\n",mmc3_last_prom[0],mmc3_last_prom[1],mmc3_last_prom_switch);
|
||||
fprintf(fp, "MMC3: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n", mmc3_command, mmc3_irq_counter,
|
||||
mmc3_irq_counter_reload, mmc3_irq_enable, mmc3_first_prom_page, mmc3_second_prom_page, mmc3_use_xor);
|
||||
fprintf(fp, "MMC3: LV0:%d LV1:%d LV2:%d LV3:%d LV4:%d LV5:%d\n", mmc3_last_vrom[0], mmc3_last_vrom[1],
|
||||
mmc3_last_vrom[2], mmc3_last_vrom[3], mmc3_last_vrom[4], mmc3_last_vrom[5]);
|
||||
fprintf(fp, "MMC3: LP0:%d LP1:%d LPS:%d\n", mmc3_last_prom[0], mmc3_last_prom[1], mmc3_last_prom_switch);
|
||||
}
|
||||
|
||||
int mmc3_InitMapper(NesCart * cart)
|
||||
int mmc3_InitMapper(NesCart *cart)
|
||||
{
|
||||
set_prom_bank_16k(0x8000, 0);
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||
|
||||
if ( Cart->VROMSize > 0)
|
||||
if (Cart->VROMSize > 0)
|
||||
{
|
||||
set_vrom_bank_8k(0, 0x0000);
|
||||
}
|
||||
@ -92,12 +94,14 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
{
|
||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||
if (addr > 0x01)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addr)
|
||||
{
|
||||
|
||||
if ((Cart->VROMSize > 0) && ( mmc3_use_xor != (Value & 0x80) ))
|
||||
if ((Cart->VROMSize > 0) && (mmc3_use_xor != (Value & 0x80)))
|
||||
{
|
||||
if (Value & 0x80)
|
||||
{
|
||||
@ -105,14 +109,14 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
|
||||
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
|
||||
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
|
||||
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
|
||||
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
|
||||
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0] >> 1);
|
||||
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1] >> 1);
|
||||
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
|
||||
}
|
||||
else
|
||||
{
|
||||
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
|
||||
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
|
||||
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0] >> 1);
|
||||
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1] >> 1);
|
||||
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
|
||||
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
|
||||
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
|
||||
@ -134,7 +138,7 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
|
||||
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
||||
|
||||
set_prom_bank_8k(0xC000, GETLAST08KBANK(Cart)-1);
|
||||
set_prom_bank_8k(0xC000, GETLAST08KBANK(Cart) - 1);
|
||||
//set_prom_bank_8k(0xE000, GETLAST08KBANK(cart));
|
||||
//prg_bank(prg0,prg1,max_prg-1,max_prg);
|
||||
}
|
||||
@ -147,7 +151,7 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
|
||||
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
||||
|
||||
set_prom_bank_8k(0x8000, GETLAST08KBANK(Cart)-1);
|
||||
set_prom_bank_8k(0x8000, GETLAST08KBANK(Cart) - 1);
|
||||
|
||||
|
||||
//prg_bank(max_prg-1,prg1,prg0,max_prg);
|
||||
@ -157,10 +161,12 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
mmc3_command = Value & 0x07;
|
||||
|
||||
|
||||
|
||||
} else { /* 8001 */
|
||||
}
|
||||
else
|
||||
{ /* 8001 */
|
||||
switch (mmc3_command)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
@ -168,7 +174,9 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
case 4:
|
||||
case 5:
|
||||
if (Cart->VROMSize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mmc3_last_vrom[mmc3_command] = Value;
|
||||
|
||||
@ -178,14 +186,14 @@ void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
|
||||
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
|
||||
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
|
||||
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
|
||||
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
|
||||
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0] >> 1);
|
||||
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1] >> 1);
|
||||
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
|
||||
}
|
||||
else
|
||||
{
|
||||
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
|
||||
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
|
||||
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0] >> 1);
|
||||
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1] >> 1);
|
||||
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
|
||||
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
|
||||
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
|
||||
@ -220,26 +228,36 @@ void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t Value)
|
||||
{
|
||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||
if (addr > 0x01)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addr)
|
||||
{
|
||||
//console_printf(Console_Default, "MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
|
||||
|
||||
if (Value & 0x1)
|
||||
{
|
||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//console_printf(Console_Default, "MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
|
||||
if (Value)
|
||||
{
|
||||
map_sram();
|
||||
}
|
||||
else
|
||||
{
|
||||
unmap_sram();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -247,7 +265,9 @@ void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value)
|
||||
{
|
||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||
if (addr > 0x01)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addr)
|
||||
{
|
||||
@ -255,7 +275,9 @@ void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value)
|
||||
mmc3_irq_counter = Value;
|
||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
|
||||
|
||||
}else{ /* C001 */
|
||||
}
|
||||
else
|
||||
{ /* C001 */
|
||||
//console_printf(Console_Default, "MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
|
||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, Value);
|
||||
mmc3_irq_counter = Value;
|
||||
@ -266,7 +288,9 @@ void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t Value)
|
||||
{
|
||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||
if (addr > 0x01)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addr)
|
||||
{
|
||||
@ -276,7 +300,9 @@ void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t Value)
|
||||
//MapperWantIRQ = 1;
|
||||
// Add a way to raise an IRQ
|
||||
|
||||
}else{ /* E001 */
|
||||
}
|
||||
else
|
||||
{ /* E001 */
|
||||
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
||||
//console_printf(Console_Default, "MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
|
||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
|
||||
@ -290,13 +316,19 @@ int mmc3_MapperIRQ(int cycledone)
|
||||
(ppu.ControlRegister2.b & (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)) == (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)*/)
|
||||
{
|
||||
|
||||
if ((mmc3_irq_counter --) > 0 )return 0;
|
||||
if ((mmc3_irq_counter--) > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Load next counter position */
|
||||
mmc3_irq_counter = mmc3_irq_counter_reload;
|
||||
|
||||
if (mmc3_irq_enable == 0) return 0;
|
||||
if (mmc3_irq_enable == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mmc3_irq_enable = 0;
|
||||
|
||||
|
||||
@ -2,14 +2,15 @@
|
||||
* MMC3 Mapper - The peTI-NESulator Project
|
||||
* mmc3.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
void mmc3_MapperDump(FILE *fp);
|
||||
int mmc3_InitMapper(NesCart * cart);
|
||||
int mmc3_InitMapper(NesCart *cart);
|
||||
int mmc3_MapperIRQ(int cycledone);
|
||||
@ -2,7 +2,7 @@
|
||||
* MMC4 Mapper - The peTI-NESulator Project
|
||||
* mmc4.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -67,9 +67,13 @@ void mmc4_MapperWriteRegF(register uint8_t Addr, register uint8_t Value)
|
||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||
mmc4_RegF = Value;
|
||||
if (Value & 0x01)
|
||||
{
|
||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +82,7 @@ void mmc4_MapperDump(FILE *fp)
|
||||
|
||||
}
|
||||
|
||||
int mmc4_InitMapper(NesCart * cart)
|
||||
int mmc4_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -86,41 +90,43 @@ int mmc4_InitMapper(NesCart * cart)
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||
|
||||
if (cart->VROMSize > 0)
|
||||
set_vrom_bank_8k(0x0000,0);
|
||||
{
|
||||
set_vrom_bank_8k(0x0000, 0);
|
||||
}
|
||||
|
||||
/* Mapper should register itself for write hook */
|
||||
for (i = 0xA0; i < 0xB0 ; i++)
|
||||
for (i = 0xA0 ; i < 0xB0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc4_MapperWriteRegA);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xB0; i < 0xC0 ; i++)
|
||||
for (i = 0xB0 ; i < 0xC0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc4_MapperWriteRegB);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xC0; i < 0xD0 ; i++)
|
||||
for (i = 0xC0 ; i < 0xD0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc4_MapperWriteRegC);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xD0; i < 0xE0 ; i++)
|
||||
for (i = 0xD0 ; i < 0xE0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc4_MapperWriteRegD);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xE0; i < 0xF0 ; i++)
|
||||
for (i = 0xE0 ; i < 0xF0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc4_MapperWriteRegE);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xF0; i < 0x100 ; i++)
|
||||
for (i = 0xF0 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc4_MapperWriteRegF);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
|
||||
for (i = 0x60; i < 0x80 ; i++)
|
||||
for (i = 0x60 ; i < 0x80 ; i++)
|
||||
{
|
||||
set_page_writeable(i, true);
|
||||
set_page_readable(i, true);
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* MMC4 Mapper - The peTI-NESulator Project
|
||||
* mmc4.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
void mmc4_MapperDump(FILE *fp);
|
||||
int mmc4_InitMapper(NesCart * cart);
|
||||
int mmc4_InitMapper(NesCart *cart);
|
||||
@ -2,7 +2,7 @@
|
||||
* NOROM Mapper - The peTI-NESulator Project
|
||||
* norom.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -14,7 +14,7 @@ int norom_InitMapper(NesCart *cart)
|
||||
set_page_ptr_16k(0x80, cart->PROMBanks);
|
||||
|
||||
/* mUBank = 0xC000 */
|
||||
if (cart->PROMSize > (16*1024))
|
||||
if (cart->PROMSize > (16 * 1024))
|
||||
{
|
||||
set_prom_bank_16k(0xC000, 1);
|
||||
}
|
||||
@ -24,7 +24,9 @@ int norom_InitMapper(NesCart *cart)
|
||||
}
|
||||
|
||||
if (cart->VROMSize > 0)
|
||||
{
|
||||
set_vrom_bank_8k(0x2000, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -37,7 +39,6 @@ int norom_MapperIRQ(int cycledone)
|
||||
void norom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||
{
|
||||
/* Nothing to do */
|
||||
return;
|
||||
}
|
||||
|
||||
void norom_MapperDump(FILE *fp)
|
||||
|
||||
@ -2,14 +2,15 @@
|
||||
* NOROM Mapper - The peTI-NESulator Project
|
||||
* norom.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int norom_InitMapper (NesCart *cart);
|
||||
int norom_MapperIRQ (int cycledone);
|
||||
void norom_MapperDump (FILE *fp);
|
||||
int norom_InitMapper(NesCart *cart);
|
||||
int norom_MapperIRQ(int cycledone);
|
||||
void norom_MapperDump(FILE *fp);
|
||||
@ -2,7 +2,7 @@
|
||||
* UNROM Mapper - The peTI-NESulator Project
|
||||
* unrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -13,7 +13,7 @@ uint8_t unrom_load_vbank;
|
||||
|
||||
void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value);
|
||||
|
||||
int unrom_InitMapper(NesCart * cart)
|
||||
int unrom_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -21,12 +21,14 @@ int unrom_InitMapper(NesCart * cart)
|
||||
set_prom_bank_16k(0x8000, GETLAST16KBANK(cart)); /* Set the last one */
|
||||
|
||||
if (Cart->VROMSize > 0)
|
||||
set_vrom_bank_8k(0x0000,0);
|
||||
{
|
||||
set_vrom_bank_8k(0x0000, 0);
|
||||
}
|
||||
|
||||
unrom_load_vbank = 0;
|
||||
|
||||
/* Register the write hook */
|
||||
for (i = 0x80; i < 0x100; i++)
|
||||
for (i = 0x80 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, unrom_MapperWriteHook);
|
||||
set_page_writeable(i, true);
|
||||
@ -38,11 +40,11 @@ int unrom_InitMapper(NesCart * cart)
|
||||
|
||||
void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value)
|
||||
{
|
||||
set_vrom_bank_8k(0x0000,Value);
|
||||
set_vrom_bank_8k(0x0000, Value);
|
||||
unrom_load_vbank = Value;
|
||||
}
|
||||
|
||||
void unrom_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"unrom: vbank:%d\n",unrom_load_vbank);
|
||||
fprintf(fp, "unrom: vbank:%d\n", unrom_load_vbank);
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* UNROM Mapper - The peTI-NESulator Project
|
||||
* unrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int unrom_InitMapper(NesCart * cart);
|
||||
int unrom_InitMapper(NesCart *cart);
|
||||
void unrom_MapperDump(FILE *fp);
|
||||
@ -2,7 +2,7 @@
|
||||
* UNROM Mapper - The peTI-NESulator Project
|
||||
* unrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -19,6 +19,7 @@ static uint8_t loaded_pbank;
|
||||
* 32K on such a cart
|
||||
*/
|
||||
static uint8_t vram[32768];
|
||||
|
||||
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
|
||||
|
||||
static void unrom512_applyValues()
|
||||
@ -40,12 +41,12 @@ static void unrom512_MapperWriteHook(uint8_t Addr, uint8_t Value)
|
||||
{
|
||||
mirroring_set = (Value >> 7) & 0x01;
|
||||
loaded_vbank = (Value >> 5) & 0x03;
|
||||
loaded_pbank = (Value ) & 0x1F;
|
||||
loaded_pbank = (Value) & 0x1F;
|
||||
|
||||
unrom512_applyValues();
|
||||
}
|
||||
|
||||
int unrom512_InitMapper(NesCart * cart)
|
||||
int unrom512_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -56,7 +57,7 @@ int unrom512_InitMapper(NesCart * cart)
|
||||
unrom512_applyValues();
|
||||
|
||||
/* Register the write hook */
|
||||
for (i = 0x80; i < 0x100; i++)
|
||||
for (i = 0x80 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, unrom512_MapperWriteHook);
|
||||
set_page_writeable(i, true);
|
||||
@ -67,5 +68,5 @@ int unrom512_InitMapper(NesCart * cart)
|
||||
|
||||
void unrom512_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"unrom512: vbank:%d pbank:%d\n", loaded_vbank, loaded_pbank);
|
||||
fprintf(fp, "unrom512: vbank:%d pbank:%d\n", loaded_vbank, loaded_pbank);
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* UNROM Mapper - The peTI-NESulator Project
|
||||
* unrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int unrom512_InitMapper(NesCart * cart);
|
||||
int unrom512_InitMapper(NesCart *cart);
|
||||
void unrom512_MapperDump(FILE *fp);
|
||||
@ -2,7 +2,7 @@
|
||||
* Mapper list - The peTI-NESulator Project
|
||||
* mappers_list.h
|
||||
*
|
||||
* Created by Manoel TRAPIER on 25/10/07.
|
||||
* Created by Manoël TRAPIER on 25/10/07.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
* Generic mapper implementation - The peTI-NESulator Project
|
||||
* genericmapper.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -22,7 +22,7 @@ int _MapperWriteHook(register word Addr, register uint8_t Value)
|
||||
|
||||
if (Addr > 0x7FFF) /* Try to write to the rom */
|
||||
{
|
||||
set_vrom_bank_8k(0x0000,Value)
|
||||
set_vrom_bank_8k(0x0000,Value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2,18 +2,14 @@
|
||||
* MMC1 Mapper - The peTI-NESulator Project
|
||||
* mmc1.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
uint8_t MMC1_reg0;
|
||||
|
||||
uint8_t MMC1_reg1;
|
||||
|
||||
uint8_t MMC1_reg2;
|
||||
|
||||
uint8_t MMC1_reg3;
|
||||
|
||||
uint8_t mmc1_CurrentBank;
|
||||
|
||||
#define MMC1_R0_MIRROR 0x01
|
||||
@ -49,47 +45,46 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value);
|
||||
|
||||
void mmc1_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n",MMC1_reg0,MMC1_reg1,MMC1_reg2,MMC1_reg3);
|
||||
fprintf(fp, "MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n", MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
|
||||
}
|
||||
|
||||
int mmc1_InitMapper(NesCart * cart)
|
||||
int mmc1_InitMapper(NesCart *cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||
|
||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||
|
||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||
|
||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||
|
||||
set_prom_bank_16k(0x8000,0);
|
||||
set_prom_bank_16k(0x8000, 0);
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||
|
||||
mmc1_CurrentBank = 0;
|
||||
|
||||
if (cart->VROMSize > 0)
|
||||
set_vrom_bank_4k(0x0000,0);
|
||||
{
|
||||
set_vrom_bank_4k(0x0000, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Mapper should register itself for write hook */
|
||||
for (i = 0x80; i < 0xA0 ; i++)
|
||||
for (i = 0x80 ; i < 0xA0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg0);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xA0; i < 0xC0 ; i++)
|
||||
for (i = 0xA0 ; i < 0xC0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg1);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xC0; i < 0xE0 ; i++)
|
||||
for (i = 0xC0 ; i < 0xE0 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg2);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
for (i = 0xE0; i < 0x100 ; i++)
|
||||
for (i = 0xE0 ; i < 0x100 ; i++)
|
||||
{
|
||||
set_page_wr_hook(i, mmc1_MapperWriteReg3);
|
||||
set_page_writeable(i, true);
|
||||
@ -101,38 +96,34 @@ int mmc1_InitMapper(NesCart * cart)
|
||||
|
||||
|
||||
/*
|
||||
Reg 0
|
||||
8 : 1000
|
||||
9 : 1001
|
||||
|
||||
Reg 1
|
||||
A : 1010
|
||||
B : 1011
|
||||
|
||||
Reg 2
|
||||
C : 1100
|
||||
D : 1101
|
||||
|
||||
Reg 3
|
||||
E : 1110
|
||||
F : 1111
|
||||
|
||||
((Addr & 0x6000) >> 13) <- port number
|
||||
*/
|
||||
* Reg 0
|
||||
* 8 : 1000
|
||||
* 9 : 1001
|
||||
*
|
||||
* Reg 1
|
||||
* A : 1010
|
||||
* B : 1011
|
||||
*
|
||||
* Reg 2
|
||||
* C : 1100
|
||||
* D : 1101
|
||||
*
|
||||
* Reg 3
|
||||
* E : 1110
|
||||
* F : 1111
|
||||
*
|
||||
* ((Addr & 0x6000) >> 13) <- port number
|
||||
*/
|
||||
#define MMC1_GetReg(a) ((a & 0x6000) >> 13)
|
||||
/* (Val & 0x01) recuperation du bit */
|
||||
#define MMC1_GetBit(v) (v & 0x01)
|
||||
/* ( ( b & (1 << Bit)) | (v << Bit) ) Ajout du bit */
|
||||
#define MMC1_AddBit(b,v) ( ( b & ~(1 << Bit)) | (v << Bit) )
|
||||
#define MMC1_AddBit(b, v) ( ( b & ~(1 << Bit)) | (v << Bit) )
|
||||
|
||||
void mmc1_ApplyReg0Mod()
|
||||
{
|
||||
|
||||
static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
|
||||
|
||||
|
||||
|
||||
//console_printf(Console_Default, "Change to reg0 done ! (0x%x)\n\tMiror flag : %d\n\tOneScreen Flag : %d\n\tPRG Size : %d\n\tPRG Area : %d\n\tVROM Switch size : %d\n", MMC1_reg0, MMC1_reg0 & MMC1_R0_MIRROR, MMC1_reg0 & MMC1_R0_ONESCREEN, MMC1_reg0 & MMC1_R0_PRGAREA, MMC1_reg0 & MMC1_R0_PRGSIZE, MMC1_reg0 & MMC1_R0_VROMSW);
|
||||
//console_printf(Console_Default, "Change to reg0 done ! (0x%x)\n\tMirror flag : %d\n\tOneScreen Flag : %d\n\tPRG Size : %d\n\tPRG Area : %d\n\tVROM Switch size : %d\n", MMC1_reg0, MMC1_reg0 & MMC1_R0_MIRROR, MMC1_reg0 & MMC1_R0_ONESCREEN, MMC1_reg0 & MMC1_R0_PRGAREA, MMC1_reg0 & MMC1_R0_PRGSIZE, MMC1_reg0 & MMC1_R0_VROMSW);
|
||||
|
||||
switch (MMC1_reg0 & 0x03)
|
||||
{
|
||||
@ -154,20 +145,20 @@ void mmc1_ApplyReg0Mod()
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 ) )
|
||||
if ((OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0))
|
||||
{
|
||||
|
||||
if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
|
||||
{ /* 0x8000 area */
|
||||
set_prom_bank_16k(0x8000,mmc1_CurrentBank);
|
||||
{
|
||||
/* 0x8000 area */
|
||||
set_prom_bank_16k(0x8000, mmc1_CurrentBank);
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(Cart));
|
||||
}
|
||||
else
|
||||
{ /* 0xC000 area */
|
||||
|
||||
set_prom_bank_16k(0x8000,0);
|
||||
set_prom_bank_16k(0xC000,mmc1_CurrentBank);
|
||||
|
||||
{
|
||||
/* 0xC000 area */
|
||||
set_prom_bank_16k(0x8000, 0);
|
||||
set_prom_bank_16k(0xC000, mmc1_CurrentBank);
|
||||
}
|
||||
|
||||
OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
|
||||
@ -184,13 +175,14 @@ void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg0 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg0 Reset occurred !\n");
|
||||
mmc1_ApplyReg0Mod();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bit < 4)
|
||||
{ /* Pas encore ecrit les 5 bits */
|
||||
{
|
||||
/* Haven't written the 5 bits yet */
|
||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||
Bit++;
|
||||
}
|
||||
@ -211,12 +203,13 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg1 Reset occurred !\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bit < 4)
|
||||
{ /* Pas encore ecrit les 5 bits */
|
||||
{
|
||||
/* Haven't written the 5 bits yet */
|
||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||
Bit++;
|
||||
}
|
||||
@ -231,19 +224,22 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
||||
|
||||
if (Cart->VROMSize == 0)
|
||||
{
|
||||
console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n", VROMBankNb);
|
||||
console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n",
|
||||
VROMBankNb);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
||||
{ /* 4K vram */
|
||||
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||
{
|
||||
/* 4K vram */
|
||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 4k bank %d\n", VROMBankNb);
|
||||
set_vrom_bank_4k(0x0000,VROMBankNb);
|
||||
set_vrom_bank_4k(0x0000, VROMBankNb);
|
||||
}
|
||||
else
|
||||
{ /* 8K vram */
|
||||
{
|
||||
/* 8K vram */
|
||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 8k bank %d\n", VROMBankNb>>1);
|
||||
set_vrom_bank_8k(0x0000,VROMBankNb>>1);
|
||||
set_vrom_bank_8k(0x0000, VROMBankNb >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,12 +250,13 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg2 Reset occurred !\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bit < 4)
|
||||
{ /* Pas encore ecrit les 5 bits */
|
||||
{
|
||||
/* Haven't written the 5 bits yet */
|
||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||
Bit++;
|
||||
}
|
||||
@ -279,13 +276,15 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
||||
{ /* 4K vram */
|
||||
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||
{
|
||||
/* 4K vram */
|
||||
//console_printf(Console_Default, "Switching VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
||||
set_vrom_bank_4k(0x1000,VROMBankNb);
|
||||
set_vrom_bank_4k(0x1000, VROMBankNb);
|
||||
}
|
||||
else
|
||||
{ /* 8K vram */
|
||||
{
|
||||
/* 8K vram */
|
||||
// console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
|
||||
// set_vrom_bank_8k(0x1000,VROMBankNb>>1);
|
||||
}
|
||||
@ -298,12 +297,13 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||
if (Value & 0x80)
|
||||
{
|
||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||
console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
|
||||
console_printf(Console_Default, "MMC1: Reg3 Reset occurred !\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bit < 4)
|
||||
{ /* Pas encore ecrit les 5 bits */
|
||||
{
|
||||
/* Haven't written the 5 bits yet */
|
||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||
Bit++;
|
||||
}
|
||||
@ -314,28 +314,34 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||
|
||||
MMC1_reg3 = BitBuf;
|
||||
|
||||
if (MMC1_reg3<<14 > Cart->PROMSize)
|
||||
if (MMC1_reg3 << 14 > Cart->PROMSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 )
|
||||
{ /* 16K Switch */
|
||||
if ( (MMC1_reg0 & MMC1_R0_PRGAREA) != 0 )
|
||||
{ /* 0x8000 switch */
|
||||
set_prom_bank_16k(0x8000,MMC1_reg3);
|
||||
if ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0)
|
||||
{
|
||||
/* 16K Switch */
|
||||
if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
|
||||
{
|
||||
/* 0x8000 switch */
|
||||
set_prom_bank_16k(0x8000, MMC1_reg3);
|
||||
//console_printf(Console_Default, "LowBank is now %d ( 0x%p )\n", MMC1_reg3, mLBank);
|
||||
}
|
||||
else
|
||||
{ /* 0xC000 switch */
|
||||
set_prom_bank_16k(0xC000,MMC1_reg3);
|
||||
{
|
||||
/* 0xC000 switch */
|
||||
set_prom_bank_16k(0xC000, MMC1_reg3);
|
||||
//console_printf(Console_Default, "HighBank is now %d ( 0x%p )\n", MMC1_reg3, mUBank);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* 32K Switch */
|
||||
set_prom_bank_32k(0x8000,MMC1_reg3>>1);
|
||||
{
|
||||
/* 32K Switch */
|
||||
set_prom_bank_32k(0x8000, MMC1_reg3 >> 1);
|
||||
}
|
||||
|
||||
if ( ( MMC1_reg3 & MMC1_R3_SAVECE ) != 0)
|
||||
if ((MMC1_reg3 & MMC1_R3_SAVECE) != 0)
|
||||
{
|
||||
unmap_sram();
|
||||
}
|
||||
@ -347,4 +353,4 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||
}
|
||||
}
|
||||
|
||||
//console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
|
||||
//console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Mapper facilities - The peTI-NESulator Project
|
||||
* mappers.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -27,7 +27,7 @@ extern NesCart *Cart;
|
||||
extern char MapperWantIRQ;
|
||||
|
||||
/*
|
||||
Here are some fonction useful for mappers
|
||||
* Here are some function useful for mappers
|
||||
*/
|
||||
|
||||
void set_vrom_bank_1k(uint16_t addr,int slot)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* 6502 Memory manager - The peTI-NESulator Project
|
||||
* memory.c - Taken from the Quick6502 project
|
||||
*
|
||||
* Created by Manoel Trapier on 18/09/06.
|
||||
* Created by Manoël Trapier on 18/09/06.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -16,14 +16,14 @@
|
||||
|
||||
/* Private structures */
|
||||
|
||||
#define Kuint8_t * (1024)
|
||||
#define KByte * (1024)
|
||||
|
||||
/*
|
||||
* What inside memory manager:
|
||||
*
|
||||
* Table of attributes
|
||||
* Table of original page ptr
|
||||
* Table of moded page ptr
|
||||
* Table of modded page ptr
|
||||
*
|
||||
*/
|
||||
|
||||
@ -77,26 +77,26 @@ void set_page_ptr_4k(uint8_t page, uint8_t *ptr)
|
||||
{
|
||||
LOG(console_printf(Console_Default, "Set page(4k) 0x%X to ptr %p\n", page, ptr));
|
||||
set_page_ptr_2k(page, ptr);
|
||||
set_page_ptr_2k(page+((4 Kuint8_t / 256) / 2), ptr + 2 Kuint8_t);
|
||||
set_page_ptr_2k(page + ((4 KByte / 256) / 2), ptr + 2 KByte);
|
||||
}
|
||||
|
||||
void set_page_ptr_8k(uint8_t page, uint8_t *ptr)
|
||||
{
|
||||
LOG(console_printf(Console_Default, "Set page(8k) 0x%X to ptr %p\n", page, ptr));
|
||||
set_page_ptr_4k(page, ptr);
|
||||
set_page_ptr_4k(page+((8 Kuint8_t / 256) / 2), ptr + 4 Kuint8_t);
|
||||
set_page_ptr_4k(page + ((8 KByte / 256) / 2), ptr + 4 KByte);
|
||||
}
|
||||
|
||||
void set_page_ptr_16k(uint8_t page, uint8_t *ptr)
|
||||
{
|
||||
set_page_ptr_8k(page, ptr);
|
||||
set_page_ptr_8k(page+((16 Kuint8_t / 256) / 2), ptr + 8 Kuint8_t);
|
||||
set_page_ptr_8k(page + ((16 KByte / 256) / 2), ptr + 8 KByte);
|
||||
}
|
||||
|
||||
void set_page_ptr_32k(uint8_t page, uint8_t *ptr)
|
||||
{
|
||||
set_page_ptr_16k(page, ptr);
|
||||
set_page_ptr_16k(page+((32 Kuint8_t / 256) / 2), ptr + 16 Kuint8_t);
|
||||
set_page_ptr_16k(page + ((32 KByte / 256) / 2), ptr + 16 KByte);
|
||||
}
|
||||
|
||||
uint8_t *get_page_ptr(uint8_t page)
|
||||
@ -113,14 +113,18 @@ void set_page_rd_hook(uint8_t page, func_rdhook func)
|
||||
{
|
||||
memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_RDHOOK);
|
||||
if (memory_pages[page] == (uint8_t *)0x01)
|
||||
{
|
||||
memory_pages[page] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_pages_attr[page] |= ATTR_PAGE_HAVE_RDHOOK;
|
||||
if (memory_pages[page] == NULL)
|
||||
{
|
||||
memory_pages[page] = (uint8_t *)0x01;
|
||||
}
|
||||
}
|
||||
|
||||
rdh_table[page] = func;
|
||||
}
|
||||
@ -130,16 +134,20 @@ void set_page_wr_hook(uint8_t page, func_wrhook func)
|
||||
if (func == NULL)
|
||||
{
|
||||
memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_WRHOOK);
|
||||
if (memory_pages[page] == (uint8_t*)0x01)
|
||||
if (memory_pages[page] == (uint8_t *)0x01)
|
||||
{
|
||||
memory_pages[page] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_pages_attr[page] |= ATTR_PAGE_HAVE_WRHOOK;
|
||||
if (memory_pages[page] == NULL)
|
||||
{
|
||||
memory_pages[page] = (uint8_t *)0x01;
|
||||
}
|
||||
}
|
||||
|
||||
wrh_table[page] = func;
|
||||
}
|
||||
@ -147,17 +155,25 @@ void set_page_wr_hook(uint8_t page, func_wrhook func)
|
||||
void set_page_readable(uint8_t page, uint8_t value)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
memory_pages_attr[page] |= ATTR_PAGE_READABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_pages_attr[page] &= (~ATTR_PAGE_READABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void set_page_writeable(uint8_t page, uint8_t value)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
memory_pages_attr[page] |= ATTR_PAGE_WRITEABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_pages_attr[page] &= (~ATTR_PAGE_WRITEABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost)
|
||||
@ -179,7 +195,9 @@ uint8_t get_page_attributes(uint8_t page)
|
||||
func_rdhook get_page_rdhook(uint8_t page)
|
||||
{
|
||||
if (memory_pages_attr[page] & ATTR_PAGE_HAVE_RDHOOK)
|
||||
{
|
||||
return rdh_table[page];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -187,29 +205,35 @@ func_rdhook get_page_rdhook(uint8_t page)
|
||||
func_wrhook get_page_wrhook(uint8_t page)
|
||||
{
|
||||
if (memory_pages_attr[page] & ATTR_PAGE_HAVE_WRHOOK)
|
||||
{
|
||||
return wrh_table[page];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t ReadMemory(uint8_t page, uint8_t addr)
|
||||
{
|
||||
static uint8_t LastRetuint8_t = 0xA5;
|
||||
static uint8_t LastRetByte = 0xA5;
|
||||
uint8_t *page_ptr;
|
||||
uint8_t attributes;
|
||||
LOG(console_printf(Console_Default, "Read @ 0x%X-%X\n", page, addr));
|
||||
/* Est-ce que la page est mappé ? && Est-ce que la page est "readable" ? */
|
||||
if ((page_ptr = memory_pages[page]) &&
|
||||
( (attributes = memory_pages_attr[page]) & ATTR_PAGE_READABLE) )
|
||||
((attributes = memory_pages_attr[page]) & ATTR_PAGE_READABLE))
|
||||
{
|
||||
LOG(console_printf(Console_Default, "Page is non null & readable\n"));
|
||||
if ( attributes & ATTR_PAGE_HAVE_RDHOOK )
|
||||
return ( LastRetuint8_t = rdh_table[page](addr) );
|
||||
if (attributes & ATTR_PAGE_HAVE_RDHOOK)
|
||||
{
|
||||
return (LastRetByte = rdh_table[page](addr));
|
||||
}
|
||||
else
|
||||
return ( LastRetuint8_t = page_ptr[addr] );
|
||||
{
|
||||
return (LastRetByte = page_ptr[addr]);
|
||||
}
|
||||
}
|
||||
//console_printf(Console_Default, "Trying to read @ 0x%X-%X\n", page, addr);
|
||||
return LastRetuint8_t;
|
||||
return LastRetByte;
|
||||
}
|
||||
|
||||
void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
|
||||
@ -218,10 +242,10 @@ void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
|
||||
uint8_t attributes;
|
||||
LOG(console_printf(Console_Default, "Write 0x%x @ 0x%X-%X\n", value, page, addr));
|
||||
/* Est-ce que la page est mappé ? && Est-ce que la page est "writable" ? */
|
||||
if ( (page_ptr = memory_pages[page]) &&
|
||||
( (attributes = memory_pages_attr[page]) & ATTR_PAGE_WRITEABLE) )
|
||||
if ((page_ptr = memory_pages[page]) &&
|
||||
((attributes = memory_pages_attr[page]) & ATTR_PAGE_WRITEABLE))
|
||||
{
|
||||
if ( attributes & ATTR_PAGE_HAVE_WRHOOK )
|
||||
if (attributes & ATTR_PAGE_HAVE_WRHOOK)
|
||||
{
|
||||
#ifdef DETECT_BUS_CONFLICT
|
||||
if ((page >= 0x80) && (memory_pages[page][addr] != value))
|
||||
@ -230,26 +254,31 @@ void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
|
||||
wrh_table[page](addr, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
page_ptr[addr] = value;
|
||||
}
|
||||
else { console_printf(Console_Default, "Trying to write 0x%X @ 0x%X-%X\n", value, page, addr); }
|
||||
}
|
||||
else
|
||||
{
|
||||
console_printf(Console_Default, "Trying to write 0x%X @ 0x%X-%X\n", value, page, addr);
|
||||
}
|
||||
}
|
||||
|
||||
void DumpMemoryState(FILE *fp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0x00; i < 0x100; i++)
|
||||
for (i = 0x00 ; i < 0x100 ; i++)
|
||||
{
|
||||
fprintf(fp,
|
||||
"Page 0x%02X : [%c%c%c%c%c%c] RdH:%p WrH:%p ptr:%p\n",
|
||||
i,
|
||||
(memory_pages_attr[i]&ATTR_PAGE_HAVE_RDHOOK)?'r':'.',
|
||||
(memory_pages_attr[i]&ATTR_PAGE_HAVE_WRHOOK)?'w':'.',
|
||||
(memory_pages_attr[i]&ATTR_PAGE_READABLE)?'R':'.',
|
||||
(memory_pages_attr[i]&ATTR_PAGE_WRITEABLE)?'W':'.',
|
||||
(memory_pages_attr[i]&ATTR_PAGE_GHOST)?'G':'.',
|
||||
(memory_pages_attr[i]&ATTR_PAGE_MAPPED)?'M':'.',
|
||||
(memory_pages_attr[i] & ATTR_PAGE_HAVE_RDHOOK) ? 'r' : '.',
|
||||
(memory_pages_attr[i] & ATTR_PAGE_HAVE_WRHOOK) ? 'w' : '.',
|
||||
(memory_pages_attr[i] & ATTR_PAGE_READABLE) ? 'R' : '.',
|
||||
(memory_pages_attr[i] & ATTR_PAGE_WRITEABLE) ? 'W' : '.',
|
||||
(memory_pages_attr[i] & ATTR_PAGE_GHOST) ? 'G' : '.',
|
||||
(memory_pages_attr[i] & ATTR_PAGE_MAPPED) ? 'M' : '.',
|
||||
rdh_table[i],
|
||||
wrh_table[i],
|
||||
memory_pages[i]
|
||||
@ -261,9 +290,9 @@ void InitMemory()
|
||||
{
|
||||
int page;
|
||||
|
||||
for(page = 0 ; page < 0x100 ; page++)
|
||||
for (page = 0 ; page < 0x100 ; page++)
|
||||
{
|
||||
set_page_ptr(page,NULL);
|
||||
set_page_ptr(page, NULL);
|
||||
memory_pages_attr[page] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $Author$
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
* Graphic Manager - The peTI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Created by Manoël TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
#include <os_dependent.h>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* File functions - The peTI-NESulator Project
|
||||
* os/macos/load.c
|
||||
*
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $Author$
|
||||
|
||||
@ -2,13 +2,8 @@
|
||||
* TI-68k Loading external file functions - The peTI-NESulator Project
|
||||
* ti68k/loadfile.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate:$
|
||||
* $Author:$
|
||||
* $HeadURL:$
|
||||
* $Revision:$
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -24,7 +19,7 @@ void *LoadFilePtr(char * filename)
|
||||
if ((fp = fopen(filename,"rb")) == NULL)
|
||||
return -1;
|
||||
|
||||
/* TI Related stuff, very uggly, and need to be changed.. */
|
||||
/* TI Related stuff, very ugly, and need to be changed.. */
|
||||
HeapLock(fp->handle);
|
||||
RetPtr = 2 + HeapDeref(fp->handle);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Graphic Manager - The peTI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Created by Manoël TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -14,6 +14,7 @@
|
||||
#include <os_dependent.h>
|
||||
|
||||
#define GLFW_INCLUDE_GLEXT
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
/* "Apple" fix */
|
||||
@ -30,15 +31,15 @@ struct KeyArray
|
||||
uint8_t lastState;
|
||||
uint8_t curState;
|
||||
uint8_t debounced;
|
||||
GLFWwindow* window;
|
||||
GLFWwindow *window;
|
||||
};
|
||||
|
||||
struct GLWindow_t
|
||||
{
|
||||
struct KeyArray keyArray[512];
|
||||
GLFWwindow* windows;
|
||||
GLFWwindow *windows;
|
||||
uint8_t *videoMemory;
|
||||
GLint videoTexture;
|
||||
GLuint videoTexture;
|
||||
int WIDTH;
|
||||
int HEIGHT;
|
||||
};
|
||||
@ -66,7 +67,7 @@ void ShowScreen(GLWindow *g, int w, int h)
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(-1.0f,1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
|
||||
glTexCoord2f(0.0f, h);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
@ -83,8 +84,8 @@ void ShowScreen(GLWindow *g, int w, int h)
|
||||
|
||||
void setupGL(GLWindow *g, int w, int h)
|
||||
{
|
||||
g->videoMemory = (uint8_t*)malloc(w*h*sizeof(uint32_t));
|
||||
memset(g->videoMemory, 0,w*h*sizeof(uint32_t));
|
||||
g->videoMemory = (uint8_t *)malloc(w * h * sizeof(uint32_t));
|
||||
memset(g->videoMemory, 0, w * h * sizeof(uint32_t));
|
||||
//Tell OpenGL how to convert from coordinates to pixel values
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
@ -140,32 +141,32 @@ void restoreGL(GLWindow *g, int w, int h)
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||
void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
|
||||
{
|
||||
struct KeyArray *keyArray;
|
||||
|
||||
keyArray = (struct KeyArray*) glfwGetWindowUserPointer(window);
|
||||
keyArray = (struct KeyArray *)glfwGetWindowUserPointer(window);
|
||||
|
||||
keyArray[key].lastState=keyArray[key].curState;
|
||||
if (action==GLFW_RELEASE)
|
||||
keyArray[key].lastState = keyArray[key].curState;
|
||||
if (action == GLFW_RELEASE)
|
||||
{
|
||||
keyArray[key].curState=GLFW_RELEASE;
|
||||
keyArray[key].curState = GLFW_RELEASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyArray[key].curState=GLFW_PRESS;
|
||||
keyArray[key].curState = GLFW_PRESS;
|
||||
}
|
||||
keyArray[key].debounced |= (keyArray[key].lastState==GLFW_RELEASE)&&(keyArray[key].curState==GLFW_PRESS);
|
||||
keyArray[key].debounced |= (keyArray[key].lastState == GLFW_RELEASE) && (keyArray[key].curState == GLFW_PRESS);
|
||||
keyArray[key].window = window;
|
||||
}
|
||||
|
||||
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||
void sizeHandler(GLFWwindow *window, int xs, int ys)
|
||||
{
|
||||
glfwMakeContextCurrent(window);
|
||||
glViewport(0, 0, xs, ys);
|
||||
}
|
||||
|
||||
static void error_callback(int error, const char* description)
|
||||
static void error_callback(int error, const char *description)
|
||||
{
|
||||
puts(description);
|
||||
}
|
||||
@ -181,7 +182,7 @@ void initDisplay(GLWindow *g)
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
// Open screen OpenGL window
|
||||
if( !(g->windows=glfwCreateWindow( g->WIDTH, g->HEIGHT, "Main", NULL, NULL)) )
|
||||
if (!(g->windows = glfwCreateWindow(g->WIDTH, g->HEIGHT, "Main", NULL, NULL)))
|
||||
{
|
||||
glfwTerminate();
|
||||
fprintf(stderr, "Window creation error...\n");
|
||||
@ -205,12 +206,14 @@ void initDisplay(GLWindow *g)
|
||||
|
||||
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
|
||||
{
|
||||
uint8_t r,g,b,a;
|
||||
uint8_t r, g, b, a;
|
||||
|
||||
uint32_t offset = (y*gw->WIDTH*4)+4*x;
|
||||
uint32_t offset = (y * gw->WIDTH * 4U) + 4U * x;
|
||||
|
||||
if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
b = colour & 0xFF;
|
||||
g = (colour >> 8) & 0xFF;
|
||||
@ -246,7 +249,7 @@ void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||
|
||||
drawPixel(g, x, y, colour);
|
||||
|
||||
for (y = y0+1; y <= y1; y++)
|
||||
for (y = y0 + 1 ; y <= y1 ; y++)
|
||||
{
|
||||
if (d >= 0)
|
||||
{
|
||||
@ -281,7 +284,7 @@ void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||
|
||||
drawPixel(g, x, y, colour);
|
||||
|
||||
for (x = x0+1; x <= x1; ++x)
|
||||
for (x = x0 + 1 ; x <= x1 ; ++x)
|
||||
{
|
||||
if (d >= 0)
|
||||
{
|
||||
@ -297,7 +300,7 @@ void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
@ -310,18 +313,20 @@ void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||
int y = radius;
|
||||
int pX, pY;
|
||||
|
||||
pX = xc; pY = yc + radius;
|
||||
pX = xc;
|
||||
pY = yc + radius;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pY -= (2*radius);
|
||||
pY -= (2 * radius);
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pY += radius; pX += radius;
|
||||
pY += radius;
|
||||
pX += radius;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX -= (2*radius);
|
||||
pX -= (2 * radius);
|
||||
drawPixel(g, pX, pY, colour);
|
||||
|
||||
while(x < y)
|
||||
while (x < y)
|
||||
{
|
||||
if(f >= 0)
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
@ -330,40 +335,48 @@ void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x + 1;
|
||||
pX = xc+x ; pY = yc+y;
|
||||
pX = xc + x;
|
||||
pY = yc + y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-x ; pY = yc+y;
|
||||
pX = xc - x;
|
||||
pY = yc + y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc+x ; pY = yc-y;
|
||||
pX = xc + x;
|
||||
pY = yc - y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-x ; pY = yc-y;
|
||||
pX = xc - x;
|
||||
pY = yc - y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc+y ; pY = yc+x;
|
||||
pX = xc + y;
|
||||
pY = yc + x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-y ; pY = yc+x;
|
||||
pX = xc - y;
|
||||
pY = yc + x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc+y ; pY = yc-x;
|
||||
pX = xc + y;
|
||||
pY = yc - x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-y ; pY = yc-x;
|
||||
pX = xc - y;
|
||||
pY = yc - x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||
{
|
||||
drawLine(g, x0 , y0 , x0 + w, y0 , colour);
|
||||
drawLine(g, x0 + w, y0 , x0 + w, y0 + h, colour);
|
||||
drawLine(g, x0 + w, y0 + h, x0 , y0 + h, colour);
|
||||
drawLine(g, x0 , y0 + h, x0 , y0 , colour);
|
||||
drawLine(g, x0, y0, x0 + w, y0, colour);
|
||||
drawLine(g, x0 + w, y0, x0 + w, y0 + h, colour);
|
||||
drawLine(g, x0 + w, y0 + h, x0, y0 + h, colour);
|
||||
drawLine(g, x0, y0 + h, x0, y0, colour);
|
||||
}
|
||||
|
||||
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < h; i++)
|
||||
drawLine(g, x0, y0+i, x0+w, y0+i, colour);
|
||||
for (i = 0 ; i < h ; i++)
|
||||
{
|
||||
drawLine(g, x0, y0 + i, x0 + w, y0 + i, colour);
|
||||
}
|
||||
}
|
||||
|
||||
void clearScreen(GLWindow *g)
|
||||
@ -382,13 +395,13 @@ void updateScreen(GLWindow *g)
|
||||
|
||||
void updateScreenAndWait(GLWindow *g)
|
||||
{
|
||||
while (glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_PRESS)
|
||||
while (glfwGetKey(g->windows, GLFW_KEY_ESCAPE) != GLFW_PRESS)
|
||||
{
|
||||
updateScreen(g);
|
||||
|
||||
glfwPollEvents();
|
||||
}
|
||||
while(glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
||||
while (glfwGetKey(g->windows, GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Graphic Manager - The peTI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Created by Manoël TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -30,7 +30,7 @@ struct KeyArray
|
||||
struct GLWindow_t
|
||||
{
|
||||
struct KeyArray keyArray[512];
|
||||
GLFWwindow* windows;
|
||||
GLFWwindow *windows;
|
||||
uint8_t *videoMemory;
|
||||
GLint videoTexture;
|
||||
int WIDTH;
|
||||
@ -61,11 +61,11 @@ void restoreGL(GLWindow *g, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||
void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
|
||||
{
|
||||
}
|
||||
|
||||
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||
void sizeHandler(GLFWwindow *window, int xs, int ys)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include <os_dependent.h>
|
||||
|
||||
char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D'};
|
||||
char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D' };
|
||||
|
||||
ConsoleLevel console_ActualLevel = Console_Default;
|
||||
|
||||
@ -27,7 +27,9 @@ int console_init(ConsoleLevel DefaultLevel)
|
||||
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||
{
|
||||
if (console_ActualLevel >= level)
|
||||
{
|
||||
vprintf(format, ap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -49,7 +51,7 @@ int console_printf_d(const char *format, ...)
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
console_vprintf (Console_Debug, format, ap);
|
||||
console_vprintf(Console_Debug, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
/* Map a file in memory */
|
||||
void *LoadFilePtr(char * filename)
|
||||
void *LoadFilePtr(char *filename)
|
||||
{
|
||||
int fd;
|
||||
void *RetPtr;
|
||||
@ -26,11 +26,11 @@ void *LoadFilePtr(char * filename)
|
||||
|
||||
fstat(fd, &FileStat);
|
||||
|
||||
RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
RetPtr = mmap(NULL, FileStat.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
|
||||
close(fd);
|
||||
|
||||
if ( RetPtr == MAP_FAILED )
|
||||
if (RetPtr == MAP_FAILED)
|
||||
{
|
||||
RetPtr = NULL;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Graphic Manager - The peTI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Created by Manoël TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
43
src/paddle.c
43
src/paddle.c
@ -2,7 +2,7 @@
|
||||
* Paddle manager - The peTI-NESulator Project
|
||||
* paddle.c
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -20,60 +20,77 @@ void InitPaddle(Paddle *pdl)
|
||||
|
||||
void WritePaddle(Paddle *pdl, uint8_t val)
|
||||
{
|
||||
if ( ( pdl->LastWrite == 1 ) && ( val == 0 ) )
|
||||
if ((pdl->LastWrite == 1) && (val == 0))
|
||||
{
|
||||
InitPaddle(pdl);
|
||||
}
|
||||
|
||||
pdl->LastWrite = val;
|
||||
}
|
||||
|
||||
uint8_t ReadPaddle(Paddle *pdl)
|
||||
{
|
||||
switch(pdl->Bit++)
|
||||
switch (pdl->Bit++)
|
||||
{
|
||||
|
||||
case 1:
|
||||
if ( getKeyStatus('O') )
|
||||
if (getKeyStatus('O'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( getKeyStatus('P') )
|
||||
if (getKeyStatus('P'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ( getKeyStatus('I') )
|
||||
if (getKeyStatus('I'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ( getKeyStatus('U') )
|
||||
if (getKeyStatus('U'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if ( getKeyStatus('W') )
|
||||
if (getKeyStatus('W'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if ( getKeyStatus('S') )
|
||||
if (getKeyStatus('S'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if ( getKeyStatus('A') )
|
||||
if (getKeyStatus('A'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if ( getKeyStatus('D') )
|
||||
if (getKeyStatus('D'))
|
||||
{
|
||||
return 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 20:
|
||||
return 0x40;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
pdl->Bit = 1;
|
||||
@ -81,8 +98,6 @@ uint8_t ReadPaddle(Paddle *pdl)
|
||||
|
||||
default:
|
||||
return 0x40;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return 0x40;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Plugins manager - The peTI-NESulator Project
|
||||
* plugins.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 02/04/07.
|
||||
* Created by Manoël TRAPIER on 02/04/07.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -42,10 +42,11 @@ void plugin_list()
|
||||
Plugin *ptr = &(Plugins[0]);
|
||||
int i = 1;
|
||||
console_printf(Console_Default, "Available plugins:\n");
|
||||
while(ptr->name != NULL)
|
||||
while (ptr->name != NULL)
|
||||
{
|
||||
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
|
||||
ptr++; i++;
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,14 +57,16 @@ int plugin_load(int id)
|
||||
|
||||
console_printf(Console_Default, "%s(%d)", __func__, id);
|
||||
|
||||
for ( ; i > 1 && ptr->name != NULL; i -- )
|
||||
for (; i > 1 && ptr->name != NULL ; i--)
|
||||
{
|
||||
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
|
||||
ptr ++;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ptr->init();
|
||||
}
|
||||
@ -72,11 +75,15 @@ int plugin_unload(int id)
|
||||
{
|
||||
Plugin *ptr = &(Plugins[0]);
|
||||
|
||||
for ( ; id == 0 && ptr != NULL; id -- )
|
||||
ptr ++;
|
||||
for (; id == 0 && ptr != NULL ; id--)
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ptr->deinit();
|
||||
}
|
||||
@ -89,7 +96,7 @@ int plugin_install_keypressHandler(uint8_t key, PluginKeypress func)
|
||||
|
||||
if (keyHandlersList == NULL)
|
||||
{
|
||||
keyHandlersList = (KeyHandler*) malloc(sizeof(KeyHandler));
|
||||
keyHandlersList = (KeyHandler *)malloc(sizeof(KeyHandler));
|
||||
|
||||
keyHandlersList->key = key;
|
||||
keyHandlersList->func = func;
|
||||
@ -99,10 +106,12 @@ int plugin_install_keypressHandler(uint8_t key, PluginKeypress func)
|
||||
{
|
||||
ptr = keyHandlersList;
|
||||
|
||||
while(ptr->next != NULL)
|
||||
while (ptr->next != NULL)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
ptr->next = (KeyHandler*) malloc(sizeof(KeyHandler));
|
||||
ptr->next = (KeyHandler *)malloc(sizeof(KeyHandler));
|
||||
|
||||
ptr = ptr->next;
|
||||
|
||||
@ -126,7 +135,7 @@ int plugin_keypress(uint8_t key)
|
||||
{
|
||||
KeyHandler *ptr = keyHandlersList;
|
||||
|
||||
while(ptr != NULL)
|
||||
while (ptr != NULL)
|
||||
{
|
||||
if (ptr->key == key)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Code Breaker plugin - The peTI-NESulator Project
|
||||
* gamegenie.c: Hack your games with unlimited lives of add new powers!
|
||||
*
|
||||
* Created by Manoel Trapier.
|
||||
* Created by Manoël Trapier.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -13,22 +13,15 @@
|
||||
#include <os_dependent.h>
|
||||
|
||||
#define __TINES_PLUGINS__
|
||||
|
||||
#include <plugins/manager.h>
|
||||
|
||||
#undef __TINES_PLUGINS_
|
||||
|
||||
#include <memory/manager.h>
|
||||
#include <types.h>
|
||||
|
||||
#if 0
|
||||
/* Allegro includes */
|
||||
#ifdef __APPLE__
|
||||
#define USE_CONSOLE
|
||||
#include <Allegro/allegro.h>
|
||||
#else
|
||||
#define USE_CONSOLE
|
||||
#include <allegro.h>
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum gg_States_
|
||||
{
|
||||
@ -76,14 +69,23 @@ uint8_t gg_RdHookPatch##d(uint8_t addr) \
|
||||
#define GG_MAX_PATCH 10
|
||||
/* Defines the rdhook patches */
|
||||
GG_RDHOOKPATCH(0)
|
||||
|
||||
GG_RDHOOKPATCH(1)
|
||||
|
||||
GG_RDHOOKPATCH(2)
|
||||
|
||||
GG_RDHOOKPATCH(3)
|
||||
|
||||
GG_RDHOOKPATCH(4)
|
||||
|
||||
GG_RDHOOKPATCH(5)
|
||||
|
||||
GG_RDHOOKPATCH(6)
|
||||
|
||||
GG_RDHOOKPATCH(7)
|
||||
|
||||
GG_RDHOOKPATCH(8)
|
||||
|
||||
GG_RDHOOKPATCH(9)
|
||||
|
||||
void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
|
||||
@ -91,7 +93,9 @@ void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
|
||||
func_rdhook fptr;
|
||||
|
||||
if (id >= GG_MAX_PATCH)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set parameters for the patch */
|
||||
if (gg_PatchUsed[id] == 0x00)
|
||||
@ -106,7 +110,7 @@ void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
|
||||
|
||||
/* Set a ReadHook on the page */
|
||||
|
||||
switch(id)
|
||||
switch (id)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
@ -154,7 +158,6 @@ void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Access to the bitmap Buffer */
|
||||
extern BITMAP *Buffer;
|
||||
BITMAP *gg_Buffer;
|
||||
@ -174,10 +177,10 @@ void MessageBox(char *title, char *msg)
|
||||
|
||||
box_w = text_length(font, title) + 10;
|
||||
|
||||
box_w = (box_w>text_length(font, msg))?box_w:text_length(font, msg);
|
||||
box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
|
||||
|
||||
box_w += 15 * 2; /*sc_w/2;*/
|
||||
box_h = 15*2 + 10;
|
||||
box_h = 15 * 2 + 10;
|
||||
|
||||
/* Set the box center */
|
||||
box_t = (sc_h - box_h) / 2;
|
||||
@ -220,14 +223,14 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
|
||||
|
||||
box_w = text_length(font, title) + 10;
|
||||
|
||||
box_w = (box_w>text_length(font, msg))?box_w:text_length(font, msg);
|
||||
box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
|
||||
|
||||
sprintf(valueText, "0000");
|
||||
|
||||
box_w = (box_w>text_length(font, valueText))?box_w:text_length(font, msg);
|
||||
box_w = (box_w > text_length(font, valueText)) ? box_w : text_length(font, msg);
|
||||
|
||||
box_w += 15 * 2; /*sc_w/2;*/
|
||||
box_h = 15*2 + 30;
|
||||
box_h = 15 * 2 + 30;
|
||||
|
||||
/* Set the box center */
|
||||
box_t = (sc_h - box_h) / 2;
|
||||
@ -236,7 +239,7 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
|
||||
|
||||
value = 0;
|
||||
|
||||
while(!key[KEY_ENTER])
|
||||
while (!key[KEY_ENTER])
|
||||
{
|
||||
|
||||
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
||||
@ -249,28 +252,32 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
|
||||
textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
|
||||
|
||||
if (size == 2)
|
||||
sprintf(valueText, " %02X", value&0xFF);
|
||||
{
|
||||
sprintf(valueText, " %02X", value & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(valueText, "%04X", value);
|
||||
}
|
||||
|
||||
textout_centre_ex(gg_Buffer, font, valueText, box_w / 2 + box_l , 15 + box_t + 2 + 10, 34, 60);
|
||||
textout_centre_ex(gg_Buffer, font, valueText, box_w / 2 + box_l, 15 + box_t + 2 + 10, 34, 60);
|
||||
|
||||
switch(digit)
|
||||
switch (digit)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
textout_centre_ex(gg_Buffer, font, " ^", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);
|
||||
textout_centre_ex(gg_Buffer, font, " ^", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
|
||||
break;
|
||||
case 1:
|
||||
textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);
|
||||
textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);
|
||||
textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
textout_centre_ex(gg_Buffer, font, "^ ", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);
|
||||
textout_centre_ex(gg_Buffer, font, "^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -279,38 +286,48 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
|
||||
if (key[KEY_UP])
|
||||
{
|
||||
usleep(100000);
|
||||
value += ((digit==0)?0x0001:((digit==1)?0x0010:((digit==2)?0x0100:0x1000)));
|
||||
value &= (size==2)?0xFF:0xFFFF;
|
||||
value += ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
|
||||
value &= (size == 2) ? 0xFF : 0xFFFF;
|
||||
}
|
||||
|
||||
if (key[KEY_DOWN])
|
||||
{
|
||||
usleep(100000);
|
||||
value -= ((digit==0)?0x0001:((digit==1)?0x0010:((digit==2)?0x0100:0x1000)));
|
||||
value &= (size==2)?0xFF:0xFFFF;
|
||||
value -= ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
|
||||
value &= (size == 2) ? 0xFF : 0xFFFF;
|
||||
}
|
||||
|
||||
if (key[KEY_RIGHT])
|
||||
{
|
||||
usleep(100000);
|
||||
if (digit <= 0)
|
||||
digit = size-1;
|
||||
{
|
||||
digit = size - 1;
|
||||
}
|
||||
else
|
||||
digit --;
|
||||
{
|
||||
digit--;
|
||||
}
|
||||
}
|
||||
|
||||
if (key[KEY_LEFT])
|
||||
{
|
||||
usleep(100000);
|
||||
if (digit >= size-1)
|
||||
if (digit >= size - 1)
|
||||
{
|
||||
digit = 0;
|
||||
}
|
||||
else
|
||||
digit ++;
|
||||
{
|
||||
digit++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
release_bitmap(gg_Buffer);
|
||||
while(key[KEY_ENTER]);
|
||||
while (key[KEY_ENTER])
|
||||
{
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -332,18 +349,20 @@ int DispMenu(int itemc, char *itemv[], char *title)
|
||||
|
||||
box_w = text_length(font, title) + 10;
|
||||
|
||||
for (i = 0; i < itemc; i ++)
|
||||
box_w = (box_w>text_length(font, itemv[i]))?box_w:text_length(font, itemv[i]);
|
||||
for (i = 0 ; i < itemc ; i++)
|
||||
{
|
||||
box_w = (box_w > text_length(font, itemv[i])) ? box_w : text_length(font, itemv[i]);
|
||||
}
|
||||
|
||||
box_w += 15 * 2; /*sc_w/2;*/
|
||||
box_h = 15*2 + itemc*10;
|
||||
box_h = 15 * 2 + itemc * 10;
|
||||
|
||||
/* Set the box center */
|
||||
box_t = (sc_h - box_h) / 2;
|
||||
box_l = (sc_w - box_w) / 2;
|
||||
|
||||
|
||||
while(!key[KEY_ENTER])
|
||||
while (!key[KEY_ENTER])
|
||||
{
|
||||
/* Draw the box and highlight the selected item */
|
||||
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
||||
@ -353,15 +372,19 @@ int DispMenu(int itemc, char *itemv[], char *title)
|
||||
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
||||
|
||||
/* Display the highlight item */
|
||||
rectfill(gg_Buffer, box_l+15, 15 + box_t + (selection * 10) , box_l + box_w - 15, 15 + box_t + (selection * 10) + 10, 34);
|
||||
textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60, 34);
|
||||
rectfill(gg_Buffer, box_l + 15, 15 + box_t + (selection * 10), box_l + box_w - 15,
|
||||
15 + box_t + (selection * 10) + 10, 34);
|
||||
textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60,
|
||||
34);
|
||||
|
||||
/* Display other items */
|
||||
for (i = 0; i < itemc; i ++)
|
||||
for (i = 0 ; i < itemc ; i++)
|
||||
{
|
||||
if (i != selection)
|
||||
{
|
||||
textout_centre_ex(gg_Buffer, font, itemv[i], box_w / 2 + box_l, 15 + box_t + (i * 10) + 2, 34, 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Blit the screen buffer */
|
||||
@ -372,24 +395,34 @@ int DispMenu(int itemc, char *itemv[], char *title)
|
||||
{
|
||||
usleep(100000);
|
||||
if (selection <= 0)
|
||||
{
|
||||
selection = itemc - 1;
|
||||
}
|
||||
else
|
||||
selection --;
|
||||
{
|
||||
selection--;
|
||||
}
|
||||
}
|
||||
|
||||
if (key[KEY_DOWN])
|
||||
{
|
||||
usleep(100000);
|
||||
if (selection >= (itemc - 1))
|
||||
{
|
||||
selection = 0;
|
||||
}
|
||||
else
|
||||
selection ++;
|
||||
{
|
||||
selection++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
release_bitmap(gg_Buffer);
|
||||
while(key[KEY_ENTER]);
|
||||
while (key[KEY_ENTER])
|
||||
{
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
@ -431,31 +464,39 @@ uint8_t gg_SelectPatch()
|
||||
int i;
|
||||
uint8_t ret;
|
||||
|
||||
for (i = 0; i < GG_MAX_PATCH; i++)
|
||||
for (i = 0 ; i < GG_MAX_PATCH ; i++)
|
||||
{
|
||||
tmp = (char*) malloc(0x100);
|
||||
tmp = (char *)malloc(0x100);
|
||||
console_printf(Console_Default, "Items[%d]: %p\n", i, tmp);
|
||||
if (gg_PatchUsed[i] == 0x00)
|
||||
{
|
||||
sprintf(tmp, "Patch %d: Not used", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(tmp, "Patch %d: Put 0x%02X on address 0x%02X%02X (Code: %08lX)",
|
||||
i, gg_PatchedValue[i], gg_PatchedPage[i], gg_PatchedAddr[i],
|
||||
gg_MakeCode((gg_PatchedPage[i]<<8) | gg_PatchedAddr[i], gg_PatchedValue[i]));
|
||||
gg_MakeCode((gg_PatchedPage[i] << 8) | gg_PatchedAddr[i], gg_PatchedValue[i]));
|
||||
}
|
||||
|
||||
Items[i] = tmp;
|
||||
}
|
||||
|
||||
tmp = (char*) malloc(0x100);
|
||||
tmp = (char *)malloc(0x100);
|
||||
sprintf(tmp, "Return");
|
||||
Items[GG_MAX_PATCH] = tmp;
|
||||
|
||||
ret = DispMenu(GG_MAX_PATCH + 1, Items, "Code Breaker - Select a patch");
|
||||
|
||||
for(i = 0; i < GG_MAX_PATCH; i++)
|
||||
for (i = 0 ; i < GG_MAX_PATCH ; i++)
|
||||
{
|
||||
free(Items[i]);
|
||||
}
|
||||
|
||||
if (ret == GG_MAX_PATCH)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -469,9 +510,9 @@ void gg_InitSearch()
|
||||
{
|
||||
uint16_t addr;
|
||||
|
||||
for(addr = 0x000; addr < 0x800; addr ++)
|
||||
for (addr = 0x000 ; addr < 0x800 ; addr++)
|
||||
{
|
||||
gg_MainRAM[addr] = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
|
||||
gg_MainRAM[addr] = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
|
||||
gg_use_MainRAM[addr] = 0xFF;
|
||||
}
|
||||
|
||||
@ -493,7 +534,7 @@ void gg_SearchForValue(uint8_t value)
|
||||
//uint8_t oldValue;
|
||||
uint8_t currentValue;
|
||||
gg_ResultNumber = 0x00;
|
||||
for(addr = 0x000; addr < 0x800; addr ++)
|
||||
for (addr = 0x000 ; addr < 0x800 ; addr++)
|
||||
{
|
||||
if (gg_use_MainRAM[addr] == 0xFF)
|
||||
{
|
||||
@ -501,7 +542,7 @@ void gg_SearchForValue(uint8_t value)
|
||||
memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
|
||||
|
||||
//oldValue = gg_MainRAM[addr];
|
||||
currentValue = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
|
||||
currentValue = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
|
||||
|
||||
if (currentValue != value)
|
||||
{ /* This is not the good one ! */
|
||||
@ -522,7 +563,7 @@ void gg_SearchFor(gg_SearchForMode mode)
|
||||
uint8_t oldValue;
|
||||
uint8_t currentValue;
|
||||
gg_ResultNumber = 0x00;
|
||||
for(addr = 0x000; addr < 0x800; addr ++)
|
||||
for (addr = 0x000 ; addr < 0x800 ; addr++)
|
||||
{
|
||||
if (gg_use_MainRAM[addr] == 0xFF)
|
||||
{
|
||||
@ -530,9 +571,9 @@ void gg_SearchFor(gg_SearchForMode mode)
|
||||
memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
|
||||
|
||||
oldValue = gg_MainRAM[addr];
|
||||
currentValue = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
|
||||
currentValue = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
|
||||
|
||||
switch(mode)
|
||||
switch (mode)
|
||||
{
|
||||
case GG_SEARCHFOR_LOWER:
|
||||
if (currentValue >= oldValue)
|
||||
@ -599,13 +640,15 @@ uint8_t gg_DisplayResults()
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < gg_ResultNumber; i++)
|
||||
for (i = 0 ; i < gg_ResultNumber ; i++)
|
||||
{
|
||||
while(gg_use_MainRAM[addr] != 0xFF)
|
||||
addr ++;
|
||||
while (gg_use_MainRAM[addr] != 0xFF)
|
||||
{
|
||||
addr++;
|
||||
}
|
||||
console_printf(Console_Default, "0x%04X [%d]\n", addr, i);
|
||||
tmp = (char*) malloc(0x100);
|
||||
sprintf(tmp,"Patch: %08XAddress 0x%04X - Was: 0x%02X - Actual: 0x%02X",
|
||||
tmp = (char *)malloc(0x100);
|
||||
sprintf(tmp, "Patch: %08XAddress 0x%04X - Was: 0x%02X - Actual: 0x%02X",
|
||||
i,
|
||||
addr,
|
||||
gg_OldMainRAM[addr],
|
||||
@ -615,7 +658,7 @@ uint8_t gg_DisplayResults()
|
||||
|
||||
addr++;
|
||||
}
|
||||
tmp = (char*) malloc(0x100);
|
||||
tmp = (char *)malloc(0x100);
|
||||
sprintf(tmp, "Return");
|
||||
Items[i] = tmp;
|
||||
|
||||
@ -625,15 +668,17 @@ uint8_t gg_DisplayResults()
|
||||
if (AskYesNo("Code Breaker: Apply this patch?"))
|
||||
{
|
||||
/* Now patch it ! */
|
||||
gg_SetPatch(gg_SelectPatch(), (AddrList[ret]&0xFF00)>>8, (AddrList[ret]&0x00FF),
|
||||
gg_SetPatch(gg_SelectPatch(), (AddrList[ret] & 0xFF00) >> 8, (AddrList[ret] & 0x00FF),
|
||||
SelectNumber("Code Breaker", "Value to apply:", 2) & 0x00FF);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0 ; i<gg_ResultNumber+1; i++)
|
||||
for (i = 0 ; i < gg_ResultNumber + 1 ; i++)
|
||||
{
|
||||
free(Items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -653,7 +698,7 @@ void gg_Start()
|
||||
int ret;
|
||||
uint8_t value;
|
||||
uint16_t addr;
|
||||
switch(gg_state)
|
||||
switch (gg_state)
|
||||
{
|
||||
default:
|
||||
case GG_S00_MAIN_STATE:
|
||||
@ -684,7 +729,7 @@ void gg_Start()
|
||||
{
|
||||
/* Now patch it ! */
|
||||
gg_SetPatch(gg_SelectPatch(),
|
||||
(addr&0xFF00)>>8, (addr&0x00FF),
|
||||
(addr & 0xFF00) >> 8, (addr & 0x00FF),
|
||||
value);
|
||||
}
|
||||
|
||||
@ -699,9 +744,9 @@ void gg_Start()
|
||||
break;
|
||||
|
||||
case GG_S01_SEARCH_VALUE:
|
||||
S01_MENU:
|
||||
S01_MENU:
|
||||
ret = DispMenu(8, S01_MenuList, "Code Breaker - Search");
|
||||
switch(ret)
|
||||
switch (ret)
|
||||
{
|
||||
case 0:
|
||||
gg_SearchFor(GG_SEARCHFOR_IDENTIC);
|
||||
@ -730,9 +775,13 @@ S01_MENU:
|
||||
|
||||
case 5: /* Results */
|
||||
if (gg_DisplayResults() == 1)
|
||||
{
|
||||
gg_state = GG_S00_MAIN_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto S01_MENU;
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@ -742,19 +791,21 @@ S01_MENU:
|
||||
gg_Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
goto S01_MENU;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
sprintf(Buffer,"Results found: %d", gg_ResultNumber);
|
||||
sprintf(Buffer, "Results found: %d", gg_ResultNumber);
|
||||
MessageBox("Code Breaker", Buffer);
|
||||
|
||||
break;
|
||||
|
||||
case GG_S02_SEARCH_BAR:
|
||||
S02_MENU:
|
||||
S02_MENU:
|
||||
ret = DispMenu(7, S02_MenuList, "Code Breaker - Search");
|
||||
switch(ret)
|
||||
switch (ret)
|
||||
{
|
||||
case 0:
|
||||
gg_SearchFor(GG_SEARCHFOR_IDENTIC);
|
||||
@ -778,9 +829,13 @@ S02_MENU:
|
||||
|
||||
case 4: /* Results */
|
||||
if (gg_DisplayResults() == 1)
|
||||
{
|
||||
gg_state = GG_S00_MAIN_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto S02_MENU;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
@ -790,18 +845,19 @@ S02_MENU:
|
||||
gg_Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
goto S02_MENU;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
sprintf(Buffer,"Results found: %d", gg_ResultNumber);
|
||||
sprintf(Buffer, "Results found: %d", gg_ResultNumber);
|
||||
MessageBox("Code Breaker", Buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int gg_Init()
|
||||
{
|
||||
int i;
|
||||
@ -809,8 +865,10 @@ int gg_Init()
|
||||
|
||||
plugin_install_keypressHandler('g', gg_Start);
|
||||
|
||||
for ( i = 0; i < GG_MAX_PATCH; i++)
|
||||
for (i = 0 ; i < GG_MAX_PATCH ; i++)
|
||||
{
|
||||
gg_PatchUsed[i] = 0x00;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -820,4 +878,5 @@ int gg_Deinit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -2,7 +2,7 @@
|
||||
* Code Breaker plugin - The peTI-NESulator Project
|
||||
* gamegenie.h
|
||||
*
|
||||
* Created by Manoel Trapier.
|
||||
* Created by Manoël Trapier.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Plugin Manager plugint list - The peTI-NESulator Project
|
||||
* plugins_list.h
|
||||
*
|
||||
* Created by Manoel Trapier.
|
||||
* Created by Manoël Trapier.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -16,4 +16,4 @@ Plugin Plugins[] = {
|
||||
|
||||
/* EOL tag */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#
|
||||
# peTI-NESulator CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
# Created by Manoël TRAPIER.
|
||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $Author$
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* PPU Debug utilities - The peTI-NESulator Project
|
||||
* ppu.debug.c
|
||||
*
|
||||
* Created by Manoel Trapier.
|
||||
* Created by Manoël Trapier.
|
||||
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Define and emulate the PPU (Picture Processing Unit) of the real NES
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Created by Manoël TRAPIER.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -55,12 +55,6 @@ typedef struct spriteData
|
||||
|
||||
/* PPU registers */
|
||||
|
||||
/* NT: Name Table */
|
||||
uint8_t PPU_Reg_NT;
|
||||
|
||||
/* AT: Attribute/Color Table */
|
||||
uint8_t PPU_Reg_AT;
|
||||
|
||||
/* FV: Fine Vertical Scroll latch/counter */
|
||||
uint8_t PPU_Reg_FV;
|
||||
|
||||
@ -79,7 +73,7 @@ uint8_t PPU_Reg_V;
|
||||
/* H: Horizontal Name Table Selection latch/counter */
|
||||
uint8_t PPU_Reg_H;
|
||||
|
||||
/* S: Playfield pattern table selection latch */
|
||||
/* S: Play-field pattern table selection latch */
|
||||
uint16_t PPU_Reg_S;
|
||||
|
||||
/* PAR: Picture Address Register */
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* PPU Memory manager - The peTI-NESulator Project
|
||||
* ppu.memory.c - Inspired from the memory manager of the Quick6502 Project.
|
||||
*
|
||||
* Created by Manoel Trapier on 12/04/07.
|
||||
* Created by Manoël Trapier on 12/04/07.
|
||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -20,7 +20,7 @@
|
||||
#include <types.h>
|
||||
|
||||
/* Simple definition only for readability */
|
||||
#define Kuint8_t * (1024)
|
||||
#define KByte * (1024)
|
||||
|
||||
/* Internal representation of the PPU memory */
|
||||
uint8_t *ppu_memoryPages[0x40];
|
||||
@ -102,13 +102,13 @@ void ppu_setPagePtr2k(uint8_t page, uint8_t *ptr)
|
||||
void ppu_setPagePtr4k(uint8_t page, uint8_t *ptr)
|
||||
{
|
||||
ppu_setPagePtr2k(page, ptr);
|
||||
ppu_setPagePtr2k(page+((4 Kuint8_t / 256) / 2), ptr + 2 Kuint8_t);
|
||||
ppu_setPagePtr2k(page+((4 KByte / 256) / 2), ptr + 2 KByte);
|
||||
}
|
||||
|
||||
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr)
|
||||
{
|
||||
ppu_setPagePtr4k(page, ptr);
|
||||
ppu_setPagePtr4k(page+((8 Kuint8_t / 256) / 2), ptr + 4 Kuint8_t);
|
||||
ppu_setPagePtr4k(page+((8 KByte / 256) / 2), ptr + 4 KByte);
|
||||
}
|
||||
|
||||
void ppu_setPageGhost(uint8_t page, uint8_t value, uint8_t ghost)
|
||||
@ -149,7 +149,7 @@ void ppu_writeMemory(uint8_t page, uint8_t addr, uint8_t value)
|
||||
{
|
||||
if (page == 0x3F)
|
||||
{
|
||||
/* Here we will cheat with the palette miroring, since we didn't write
|
||||
/* Here we will cheat with the palette mirroring, since we didn't write
|
||||
as often as we read the palette, we will mirror here */
|
||||
//console_printf(Console_Default, "%s palette: color %02X new value : %02d (0x%02X%02X)\n", ((addr&0x10)< 0x10) ? "Bgnd" : "Sprt", addr&0x1F, value & 0x3F, page, addr);
|
||||
if ((addr & 0xEF) == 0x00)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* bin to header - Part of The peTI-NESulator Project
|
||||
* bin2h.c: Convert a binary file to a table of uint8_t in a C header file.
|
||||
*
|
||||
* Created by Manoel Trapier.
|
||||
* Created by Manoël Trapier.
|
||||
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||
*
|
||||
*/
|
||||
@ -22,18 +22,18 @@ int main(int argc, char *argv[])
|
||||
if (argc > 1)
|
||||
{
|
||||
|
||||
for(i = 1; argv[i] && argv[i][0] == '-'; i++)
|
||||
for (i = 1 ; argv[i] && argv[i][0] == '-' ; i++)
|
||||
{
|
||||
if (i < argc)
|
||||
{
|
||||
switch(argv[i][1])
|
||||
switch (argv[i][1])
|
||||
{
|
||||
case 'i':
|
||||
fpin = fopen(argv[i+1], "rb");
|
||||
infile = argv[i+1];
|
||||
fpin = fopen(argv[i + 1], "rb");
|
||||
infile = argv[i + 1];
|
||||
if (fpin == NULL)
|
||||
{
|
||||
fprintf (stderr, "Error: cannot open in file '%s'\n", argv[i+1]);
|
||||
fprintf(stderr, "Error: cannot open in file '%s'\n", argv[i + 1]);
|
||||
exit(-1);
|
||||
}
|
||||
i++;
|
||||
@ -41,17 +41,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
case 'o':
|
||||
|
||||
fpout = fopen(argv[i+1], "wb");
|
||||
fpout = fopen(argv[i + 1], "wb");
|
||||
if (fpout == NULL)
|
||||
{
|
||||
fprintf (stderr, "Error: cannot open out file '%s'\n", argv[i+1]);
|
||||
fprintf(stderr, "Error: cannot open out file '%s'\n", argv[i + 1]);
|
||||
exit(-1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf (stderr, "Error: unknown argument: %s\n", argv[i]);
|
||||
fprintf(stderr, "Error: unknown argument: %s\n", argv[i]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@ -62,17 +62,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(fpout, "uint8_t data[] = {\n");
|
||||
i = 0;
|
||||
while((c = fgetc(fpin)) >= 0)
|
||||
while ((c = fgetc(fpin)) >= 0)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
fprintf(fpout, "\t\t0x%02X", (uint8_t)c);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(fpout, ", 0x%02X", (uint8_t)c);
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i > 10)
|
||||
{
|
||||
fprintf(fpout,", \\\n");
|
||||
fprintf(fpout, ", \\\n");
|
||||
i = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import sys
|
||||
import hashlib.md5 as md5
|
||||
import hashlib.sha as sha
|
||||
|
||||
|
||||
def get_page(theurl, post_data=None):
|
||||
"""
|
||||
Helper method that gets the given URL
|
||||
@ -69,8 +70,7 @@ if __name__ == '__main__':
|
||||
print(" <diskdude>{diskdude}</diskdude>".format(diskdude=DiskDude))
|
||||
print(" </game>")
|
||||
|
||||
|
||||
#will fill the DB :
|
||||
# will fill the DB :
|
||||
url = "http://127.0.0.1/nesstat/add.php"
|
||||
|
||||
html = get_page(url, urllib.urlencode({
|
||||
@ -90,4 +90,4 @@ if __name__ == '__main__':
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
#print("</gamelist>")
|
||||
# print("</gamelist>")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user