[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
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoel TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986Corp. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
# $Author$
|
# $Author$
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
111
src/NESCarts.c
111
src/NESCarts.c
@ -2,13 +2,14 @@
|
|||||||
* Cart manager - The peTI-NESulator Project
|
* Cart manager - The peTI-NESulator Project
|
||||||
* NESCart.c
|
* NESCart.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* System Headers */
|
/* System Headers */
|
||||||
#if !defined(__TIGCC__) && !defined(__GCC4TI__) && !defined(__GTC__)
|
#if !defined(__TIGCC__) && !defined(__GCC4TI__) && !defined(__GTC__)
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@ -26,89 +27,93 @@
|
|||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
void DumpCartProperties(FILE *out, NesCart * cart)
|
void DumpCartProperties(FILE *out, NesCart *cart)
|
||||||
{
|
{
|
||||||
console_printf(Console_Verbose,
|
console_printf(Console_Verbose,
|
||||||
"'%s' informations:\n"
|
"'%s' informations:\n"
|
||||||
" Total ROM Size : 0x%06lX | Total VROM Size : 0x%06lX\n"
|
" Total ROM Size : 0x%06lX | Total VROM Size : 0x%06lX\n"
|
||||||
" Mapper ID : 0x%06X | Mirroring ? : %s\n"
|
" Mapper ID : 0x%06X | Mirroring ? : %s\n"
|
||||||
" Battery ? : %s | 4 Screen ? : %s \n"
|
" Battery ? : %s | 4 Screen ? : %s \n"
|
||||||
" PROMBanks start at : %p |\n"
|
" PROMBanks start at : %p |\n"
|
||||||
" VROMBanks start at : %p |\n",
|
" VROMBanks start at : %p |\n",
|
||||||
cart->FileName,
|
cart->FileName,
|
||||||
cart->PROMSize,
|
cart->PROMSize,
|
||||||
cart->VROMSize,
|
cart->VROMSize,
|
||||||
cart->MapperID,
|
cart->MapperID,
|
||||||
(cart->Flags & iNES_MIRROR) ? "Horizontal" : "Vertical",
|
(cart->Flags & iNES_MIRROR) ? "Horizontal" : "Vertical",
|
||||||
(cart->Flags & iNES_BATTERY)? "Yes": "No ",
|
(cart->Flags & iNES_BATTERY) ? "Yes" : "No ",
|
||||||
(cart->Flags & iNES_4SCREEN)? "Yes": "No ",
|
(cart->Flags & iNES_4SCREEN) ? "Yes" : "No ",
|
||||||
cart->PROMBanks,
|
cart->PROMBanks,
|
||||||
cart->VROMBanks);
|
cart->VROMBanks);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadCart(const char *filename, NesCart * cart)
|
int LoadCart(const char *filename, NesCart *cart)
|
||||||
{
|
{
|
||||||
char buffer[6];
|
char buffer[6];
|
||||||
/* Load the cart into memory */
|
/* Load the cart into memory */
|
||||||
cart->File = (uint8_t *)LoadFilePtr((char *)filename);
|
cart->File = (uint8_t *)LoadFilePtr((char *)filename);
|
||||||
|
|
||||||
|
|
||||||
if ((cart->File == NULL) || (cart->File == MAP_FAILED))
|
if ((cart->File == NULL) || (cart->File == MAP_FAILED))
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
|
}
|
||||||
|
|
||||||
/* Verify that this is a real iNES valid file */
|
sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
|
||||||
if (memcmp(cart->File, buffer, 4))
|
|
||||||
return -1;
|
/* Verify that this is a real iNES valid file */
|
||||||
|
if (memcmp(cart->File, buffer, 4) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Before go elsewhere, verify that the header is clean !
|
/* Before go elsewhere, verify that the header is clean !
|
||||||
(aka no DiskDude! in it) */
|
(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"
|
console_printf(Console_Warning, "\n"
|
||||||
"*******************WARNING****************\n"
|
"*******************WARNING****************\n"
|
||||||
"* The header of this game is not clean *\n"
|
"* The header of this game is not clean *\n"
|
||||||
"* (DiskDude! pollution) I will only use *\n"
|
"* (DiskDude! pollution) I will only use *\n"
|
||||||
"* basic MapperID (mapper 0-15). This can *\n"
|
"* basic MapperID (mapper 0-15). This can *\n"
|
||||||
"* led to unexpected behavior... *\n"
|
"* led to unexpected behavior... *\n"
|
||||||
"* *\n"
|
"* *\n"
|
||||||
"* PLEASE CLEAN THIS FILE! *\n"
|
"* PLEASE CLEAN THIS FILE! *\n"
|
||||||
"******************WARNING*****************\n\n");
|
"******************WARNING*****************\n\n");
|
||||||
/* So this rom file is not clean, we can only rely on the "basic" mapperID */
|
/* 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
|
else
|
||||||
{ /* This rom file is clean, we can read the extended MapperID */
|
{ /* 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 */
|
/* Now fill the structure */
|
||||||
cart->FileName = (char *)filename;
|
cart->FileName = (char *)filename;
|
||||||
|
|
||||||
cart->PROMSize = cart->File[4] * 16 * 1024; /* Size of PROM */
|
cart->PROMSize = cart->File[4] * 16U * 1024U; /* Size of PROM */
|
||||||
cart->VROMSize = cart->File[5] * 8 * 1024; /* Size of VROM */
|
cart->VROMSize = cart->File[5] * 8U * 1024U; /* Size of VROM */
|
||||||
cart->Flags = cart->File[6] & 0x0F;
|
cart->Flags = cart->File[6] & 0x0F;
|
||||||
|
|
||||||
/* We don't and we will never support trainer-ed ROM */
|
/* We don't and we will never support trainer-ed ROM */
|
||||||
if (cart->Flags & iNES_TRAINER)
|
if (cart->Flags & iNES_TRAINER)
|
||||||
{
|
{
|
||||||
console_printf(Console_Error, "\n"
|
console_printf(Console_Error, "\n"
|
||||||
"********************ERROR*****************\n"
|
"********************ERROR*****************\n"
|
||||||
"* This cart have an embedded trainer. *\n"
|
"* This cart have an embedded trainer. *\n"
|
||||||
"* There is NO support for them. *\n"
|
"* There is NO support for them. *\n"
|
||||||
"* Please use a CLEAN dump if you want *\n"
|
"* Please use a CLEAN dump if you want *\n"
|
||||||
"* to play this game. *\n"
|
"* to play this game. *\n"
|
||||||
"********************ERROR*****************\n\n");
|
"********************ERROR*****************\n\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cart->PROMBanks = cart->File + 16; /* Pointer on the first PROM */
|
cart->PROMBanks = cart->File + 16; /* Pointer on the first PROM */
|
||||||
|
|
||||||
cart->VROMBanks = cart->PROMBanks + cart->PROMSize; /* Pointer on the first VROM */
|
cart->VROMBanks = cart->PROMBanks + cart->PROMSize; /* Pointer on the first VROM */
|
||||||
|
|
||||||
DumpCartProperties(stdout, cart);
|
DumpCartProperties(stdout, cart);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* APU emulation - The peTI-NESulator Project
|
* APU emulation - The peTI-NESulator Project
|
||||||
* apu.c
|
* apu.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
# $Author$
|
# $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
|
* Cart manager - The peTI-NESulator Project
|
||||||
* NESCart.h
|
* NESCart.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -18,18 +18,18 @@
|
|||||||
#define iNES_4SCREEN 0x08
|
#define iNES_4SCREEN 0x08
|
||||||
|
|
||||||
typedef struct NesCart_
|
typedef struct NesCart_
|
||||||
{
|
{
|
||||||
uint32_t PROMSize, /* Size of PROM */
|
uint32_t PROMSize, /* Size of PROM */
|
||||||
VROMSize; /* Size of VROM */
|
VROMSize; /* Size of VROM */
|
||||||
char MapperID; /* Mapper Type */
|
char MapperID; /* Mapper Type */
|
||||||
uint8_t Flags;
|
uint8_t Flags;
|
||||||
char *FileName;
|
char *FileName;
|
||||||
uint8_t *File; /* Pointer on the file in memory */
|
uint8_t *File; /* Pointer on the file in memory */
|
||||||
uint8_t *PROMBanks; /* Pointer on the first PROM */
|
uint8_t *PROMBanks; /* Pointer on the first PROM */
|
||||||
uint8_t *VROMBanks; /* Pointer on the first VROM */
|
uint8_t *VROMBanks; /* Pointer on the first VROM */
|
||||||
} NesCart;
|
} NesCart;
|
||||||
|
|
||||||
void DumpCartProperties(FILE *out, NesCart * cart);
|
void DumpCartProperties(FILE *out, NesCart *cart);
|
||||||
int LoadCart(const char *filename, NesCart * cart);
|
int LoadCart(const char *filename, NesCart *cart);
|
||||||
|
|
||||||
#endif
|
#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 emulation - The peTI-NESulator Project
|
||||||
* apu.h
|
* apu.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,18 +2,13 @@
|
|||||||
* ANSI Color definition - The Quick6502 Project
|
* ANSI Color definition - The Quick6502 Project
|
||||||
* include/color.h
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate:$
|
|
||||||
* $Author:$
|
|
||||||
* $HeadURL:$
|
|
||||||
* $Revision:$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COLOR_H
|
#ifndef COLOR_H
|
||||||
#define COLOR_H
|
#define COLOR_H
|
||||||
|
|
||||||
#define ALLOW_COLORS
|
#define ALLOW_COLORS
|
||||||
|
|
||||||
@ -44,5 +39,5 @@
|
|||||||
|
|
||||||
#define CNORMAL ANSI_COLOR("0")
|
#define CNORMAL ANSI_COLOR("0")
|
||||||
|
|
||||||
#endif /* COLOR_H */
|
#endif /* COLOR_H */
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* CoreCPU - The Quick6502 Project
|
* CoreCPU - The Quick6502 Project
|
||||||
* corecpu.h
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -37,52 +37,52 @@ typedef void (*quick6502_MemoryWriteFunction)(uint16_t addr, uint8_t value);
|
|||||||
|
|
||||||
typedef struct quick6502_cpu_
|
typedef struct quick6502_cpu_
|
||||||
{
|
{
|
||||||
/* 6502 registers */
|
/* 6502 registers */
|
||||||
uint8_t reg_A, reg_X, reg_Y;
|
uint8_t reg_A, reg_X, reg_Y;
|
||||||
uint8_t reg_P, reg_S;
|
uint8_t reg_P, reg_S;
|
||||||
uint16_t reg_PC;
|
uint16_t reg_PC;
|
||||||
|
|
||||||
/* Read/Write memory functions */
|
/* Read/Write memory functions */
|
||||||
quick6502_MemoryReadFunction memory_read;
|
quick6502_MemoryReadFunction memory_read;
|
||||||
quick6502_MemoryWriteFunction memory_write;
|
quick6502_MemoryWriteFunction memory_write;
|
||||||
quick6502_MemoryReadFunction memory_page0_read;
|
quick6502_MemoryReadFunction memory_page0_read;
|
||||||
quick6502_MemoryWriteFunction memory_page0_write;
|
quick6502_MemoryWriteFunction memory_page0_write;
|
||||||
quick6502_MemoryReadFunction memory_stack_read;
|
quick6502_MemoryReadFunction memory_stack_read;
|
||||||
quick6502_MemoryWriteFunction memory_stack_write;
|
quick6502_MemoryWriteFunction memory_stack_write;
|
||||||
quick6502_MemoryReadFunction memory_opcode_read;
|
quick6502_MemoryReadFunction memory_opcode_read;
|
||||||
|
|
||||||
/* Timing related */
|
/* Timing related */
|
||||||
long cycle_done;
|
long cycle_done;
|
||||||
uint8_t exit_loop;
|
uint8_t exit_loop;
|
||||||
uint8_t int_pending;
|
uint8_t int_pending;
|
||||||
|
|
||||||
|
/* Other config options */
|
||||||
|
uint8_t running; /* This field is used to prevent cpu free if this cpu is running */
|
||||||
|
uint8_t page_crossed;
|
||||||
|
|
||||||
|
/* TODO add support for Inst/MemAccess breakpoints */
|
||||||
|
|
||||||
/* Other config options */
|
|
||||||
uint8_t running; /* This field is used to prevent cpu free if this cpu is running */
|
|
||||||
uint8_t page_crossed;
|
|
||||||
|
|
||||||
/* TODO add support for Inst/MemAccess breakpoints */
|
|
||||||
|
|
||||||
} quick6502_cpu;
|
} quick6502_cpu;
|
||||||
|
|
||||||
typedef struct quick6502_cpuconfig_
|
typedef struct quick6502_cpuconfig_
|
||||||
{
|
{
|
||||||
/* Read/Write memory functions */
|
/* Read/Write memory functions */
|
||||||
quick6502_MemoryReadFunction memory_read;
|
quick6502_MemoryReadFunction memory_read;
|
||||||
quick6502_MemoryWriteFunction memory_write;
|
quick6502_MemoryWriteFunction memory_write;
|
||||||
quick6502_MemoryReadFunction memory_page0_read;
|
quick6502_MemoryReadFunction memory_page0_read;
|
||||||
quick6502_MemoryWriteFunction memory_page0_write;
|
quick6502_MemoryWriteFunction memory_page0_write;
|
||||||
quick6502_MemoryReadFunction memory_stack_read;
|
quick6502_MemoryReadFunction memory_stack_read;
|
||||||
quick6502_MemoryWriteFunction memory_stack_write;
|
quick6502_MemoryWriteFunction memory_stack_write;
|
||||||
quick6502_MemoryReadFunction memory_opcode_read;
|
quick6502_MemoryReadFunction memory_opcode_read;
|
||||||
} quick6502_cpuconfig;
|
} quick6502_cpuconfig;
|
||||||
|
|
||||||
/*** Signal that we can send to the CPU ***/
|
/*** Signal that we can send to the CPU ***/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Q6502_NO_SIGNAL = 0,
|
Q6502_NO_SIGNAL = 0,
|
||||||
Q6502_IRQ_SIGNAL,
|
Q6502_IRQ_SIGNAL,
|
||||||
Q6502_NMI_SIGNAL,
|
Q6502_NMI_SIGNAL,
|
||||||
Q6502_STOPLOOP_SIGNAL
|
Q6502_STOPLOOP_SIGNAL
|
||||||
} quick6502_signal;
|
} quick6502_signal;
|
||||||
|
|
||||||
/*** Some 6502 related definitions ***/
|
/*** Some 6502 related definitions ***/
|
||||||
@ -134,7 +134,7 @@ void quick6502_reset(quick6502_cpu *cpu);
|
|||||||
*
|
*
|
||||||
* int: (Number of cycle really done) - (Number of cycle asked)
|
* 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 */
|
/** Loop CPU until explicit quit */
|
||||||
void quick6502_loop(quick6502_cpu *cpu);
|
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);
|
void quick6502_int(quick6502_cpu *cpu, quick6502_signal signal);
|
||||||
|
|
||||||
/** Dump CPU State to the given file */
|
/** 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 */
|
/** Get current instruction name at specified address and put it into buffer */
|
||||||
#define MINE
|
#define MINE
|
||||||
|
|
||||||
int quick6502_getinstruction(quick6502_cpu *cpu, char interpret,
|
int quick6502_getinstruction(quick6502_cpu *cpu, char interpret,
|
||||||
uint16_t addr, char *buffer, int *strlength);
|
uint16_t addr, char *buffer, int *strlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the CPU
|
* Free the CPU
|
||||||
*
|
*
|
||||||
|
|||||||
@ -2,18 +2,13 @@
|
|||||||
* Log Facility - The Quick6502 Project
|
* Log Facility - The Quick6502 Project
|
||||||
* include/log.h
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate:$
|
|
||||||
* $Author:$
|
|
||||||
* $HeadURL:$
|
|
||||||
* $Revision:$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LOG_H
|
#ifndef _LOG_H
|
||||||
#define _LOG_H
|
#define _LOG_H
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -38,5 +33,5 @@ void log_real(int level, char *user, char *fmt, ...);
|
|||||||
if ((_level <= MAX_DEBUG_LEVEL) || (_level <= LOG_PANIC)) \
|
if ((_level <= MAX_DEBUG_LEVEL) || (_level <= LOG_PANIC)) \
|
||||||
do { _code; printf("\n"); } while(0)
|
do { _code; printf("\n"); } while(0)
|
||||||
|
|
||||||
#endif /* _LOG_H */
|
#endif /* _LOG_H */
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
* Mappers manager & facilities - The peTI-NESulator Project
|
* Mappers manager & facilities - The peTI-NESulator Project
|
||||||
* mappers.h
|
* mappers.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -14,11 +14,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <NESCarts.h>
|
#include <NESCarts.h>
|
||||||
|
|
||||||
typedef int (*MapperInit) (NesCart * cart);
|
typedef int (*MapperInit)(NesCart *cart);
|
||||||
typedef int (*MapperWriteHook) (register uint16_t Addr,
|
typedef int (*MapperWriteHook)(register uint16_t Addr, register uint8_t Value);
|
||||||
register uint8_t Value);
|
typedef int (*MapperIRQ)(int cycledone);
|
||||||
typedef int (*MapperIRQ) (int cycledone);
|
typedef void (*MapperDump)(FILE *fp);
|
||||||
typedef void (*MapperDump) (FILE *fp);
|
|
||||||
|
|
||||||
#ifdef __TINES_MAPPERS__
|
#ifdef __TINES_MAPPERS__
|
||||||
|
|
||||||
@ -33,24 +32,25 @@ extern NesCart *Cart;
|
|||||||
#define GETLAST16KBANK(c) ((c->PROMSize>>14)-1)
|
#define GETLAST16KBANK(c) ((c->PROMSize>>14)-1)
|
||||||
#define GETLAST32KBANK(c) ((c->PROMSize>>15)-1)
|
#define GETLAST32KBANK(c) ((c->PROMSize>>15)-1)
|
||||||
|
|
||||||
void set_vrom_bank_1k(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_2k(uint16_t addr, int slot);
|
||||||
void set_vrom_bank_4k(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_vrom_bank_8k(uint16_t addr, int slot);
|
||||||
|
|
||||||
void set_prom_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_16k(uint16_t addr, int slot);
|
||||||
void set_prom_bank_32k(uint16_t addr,int slot);
|
void set_prom_bank_32k(uint16_t addr, int slot);
|
||||||
|
|
||||||
#else /* __TINES_MAPPERS__ */
|
#else /* __TINES_MAPPERS__ */
|
||||||
|
|
||||||
/* Available functions outside of mappers */
|
/* Available functions outside of mappers */
|
||||||
|
|
||||||
void mapper_list();
|
void mapper_list();
|
||||||
int mapper_init(NesCart *cart);
|
|
||||||
|
|
||||||
extern MapperIRQ mapper_irqloop;
|
int mapper_init(NesCart *cart);
|
||||||
extern MapperDump mapper_dump;
|
|
||||||
|
extern MapperIRQ mapper_irqloop;
|
||||||
|
extern MapperDump mapper_dump;
|
||||||
extern MapperWriteHook mapper_hook;
|
extern MapperWriteHook mapper_hook;
|
||||||
|
|
||||||
#endif /* __TINES_MAPPERS__ */
|
#endif /* __TINES_MAPPERS__ */
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* 6502 Memory manager - The peTI-NESulator Project
|
* 6502 Memory manager - The peTI-NESulator Project
|
||||||
* memory.h - Taken from the Quick6502 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.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@
|
|||||||
#define ATTR_PAGE_MAPPED 0x01
|
#define ATTR_PAGE_MAPPED 0x01
|
||||||
|
|
||||||
typedef uint8_t (*func_rdhook)(uint8_t /* addr */);
|
typedef uint8_t (*func_rdhook)(uint8_t /* addr */);
|
||||||
|
|
||||||
typedef void (*func_wrhook)(uint8_t addr, uint8_t data);
|
typedef void (*func_wrhook)(uint8_t addr, uint8_t data);
|
||||||
|
|
||||||
/* Functions to manage pages 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_8k(uint8_t page, uint8_t *ptr);
|
||||||
void set_page_ptr_16k(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);
|
void set_page_ptr_32k(uint8_t page, uint8_t *ptr);
|
||||||
|
|
||||||
uint8_t *get_page_ptr(uint8_t page);
|
uint8_t *get_page_ptr(uint8_t page);
|
||||||
|
|
||||||
|
|
||||||
/* Functions to set pages attributes */
|
/* Functions to set pages attributes */
|
||||||
|
|
||||||
void set_page_rd_hook(uint8_t page, func_rdhook func);
|
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_wr_hook(uint8_t page, func_wrhook func);
|
||||||
|
|
||||||
void set_page_readable(uint8_t page, uint8_t value);
|
void set_page_readable(uint8_t page, uint8_t value);
|
||||||
|
|
||||||
void set_page_writeable(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);
|
void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost);
|
||||||
|
|
||||||
uint8_t get_page_attributes(uint8_t page);
|
uint8_t get_page_attributes(uint8_t page);
|
||||||
|
|
||||||
func_rdhook get_page_rdhook(uint8_t page);
|
func_rdhook get_page_rdhook(uint8_t page);
|
||||||
|
|
||||||
func_wrhook get_page_wrhook(uint8_t page);
|
func_wrhook get_page_wrhook(uint8_t page);
|
||||||
|
|
||||||
/* Generalist functions */
|
/* Generalist functions */
|
||||||
|
|
||||||
void InitMemory();
|
void InitMemory();
|
||||||
|
|
||||||
uint8_t ReadMemory(uint8_t page, uint8_t addr);
|
uint8_t ReadMemory(uint8_t page, uint8_t addr);
|
||||||
void WriteMemory(uint8_t page, uint8_t addr, uint8_t value);
|
void WriteMemory(uint8_t page, uint8_t addr, uint8_t value);
|
||||||
|
|
||||||
void DumpMemoryState(FILE *fp);
|
void DumpMemoryState(FILE *fp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* OS Dependent functions - The peTI-NESulator Project
|
* OS Dependent functions - The peTI-NESulator Project
|
||||||
* os_dependent.h
|
* 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.
|
* 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
|
typedef struct Palette_t
|
||||||
{
|
{
|
||||||
uint8_t r,g,b,a;
|
uint8_t r, g, b, a;
|
||||||
} Palette;
|
} Palette;
|
||||||
|
|
||||||
int getKeyStatus(int key);
|
int getKeyStatus(int key);
|
||||||
@ -29,17 +29,17 @@ int getKeyStatus(int key);
|
|||||||
/* Sound related functions */
|
/* Sound related functions */
|
||||||
|
|
||||||
/* IO functions */
|
/* IO functions */
|
||||||
void *LoadFilePtr(char * filename);
|
void *LoadFilePtr(char *filename);
|
||||||
|
|
||||||
/* Console functions */
|
/* Console functions */
|
||||||
typedef enum ConsoleLevel_t
|
typedef enum ConsoleLevel_t
|
||||||
{
|
{
|
||||||
Console_Error = 0,
|
Console_Error = 0,
|
||||||
Console_Warning,
|
Console_Warning,
|
||||||
Console_Alert,
|
Console_Alert,
|
||||||
Console_Default,
|
Console_Default,
|
||||||
Console_Verbose,
|
Console_Verbose,
|
||||||
Console_Debug,
|
Console_Debug,
|
||||||
} ConsoleLevel;
|
} ConsoleLevel;
|
||||||
|
|
||||||
int console_init(ConsoleLevel DefaultLevel);
|
int console_init(ConsoleLevel DefaultLevel);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Paddle manager - The peTI-NESulator Project
|
* Paddle manager - The peTI-NESulator Project
|
||||||
* paddle.h
|
* paddle.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -10,22 +10,14 @@
|
|||||||
#ifndef PADDLE_H
|
#ifndef PADDLE_H
|
||||||
#define PADDLE_H
|
#define PADDLE_H
|
||||||
|
|
||||||
typedef struct Paddle_
|
typedef struct Paddle_
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t Bit;
|
uint8_t Bit;
|
||||||
|
|
||||||
uint8_t LastWrite;
|
uint8_t LastWrite;
|
||||||
|
|
||||||
} Paddle;
|
} Paddle;
|
||||||
|
|
||||||
|
uint8_t ReadPaddle(Paddle *pdl);
|
||||||
uint8_t ReadPaddle(Paddle * pdl);
|
void InitPaddle(Paddle *pdl);
|
||||||
|
void WritePaddle(Paddle *pdl, uint8_t val);
|
||||||
|
|
||||||
void InitPaddle(Paddle * pdl);
|
|
||||||
|
|
||||||
void WritePaddle(Paddle * pdl, uint8_t val);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,260 +1,260 @@
|
|||||||
/* Generated data file from file 'stdin' */
|
/* Generated data file from file 'stdin' */
|
||||||
|
|
||||||
Palette basicPalette[] = {
|
Palette basicPalette[] = {
|
||||||
{ 0x1E, 0x1E, 0x1E, 0x07 },
|
{ 0x1E, 0x1E, 0x1E, 0x07 },
|
||||||
{ 0x03, 0x09, 0x28, 0xB7 },
|
{ 0x03, 0x09, 0x28, 0xB7 },
|
||||||
{ 0x0A, 0x04, 0x2B, 0x0D },
|
{ 0x0A, 0x04, 0x2B, 0x0D },
|
||||||
{ 0x17, 0x02, 0x28, 0x00 },
|
{ 0x17, 0x02, 0x28, 0x00 },
|
||||||
{ 0x22, 0x00, 0x1D, 0xB7 },
|
{ 0x22, 0x00, 0x1D, 0xB7 },
|
||||||
{ 0x24, 0x01, 0x0A, 0xB7 },
|
{ 0x24, 0x01, 0x0A, 0xB7 },
|
||||||
{ 0x24, 0x04, 0x02, 0xB7 },
|
{ 0x24, 0x04, 0x02, 0xB7 },
|
||||||
{ 0x1B, 0x09, 0x01, 0xB7 },
|
{ 0x1B, 0x09, 0x01, 0xB7 },
|
||||||
{ 0x11, 0x10, 0x01, 0x00 },
|
{ 0x11, 0x10, 0x01, 0x00 },
|
||||||
{ 0x05, 0x15, 0x01, 0x00 },
|
{ 0x05, 0x15, 0x01, 0x00 },
|
||||||
{ 0x01, 0x17, 0x02, 0xB7 },
|
{ 0x01, 0x17, 0x02, 0xB7 },
|
||||||
{ 0x00, 0x14, 0x0B, 0xBF },
|
{ 0x00, 0x14, 0x0B, 0xBF },
|
||||||
{ 0x01, 0x11, 0x1B, 0xBF },
|
{ 0x01, 0x11, 0x1B, 0xBF },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x2F, 0x30, 0x2F, 0xB7 },
|
{ 0x2F, 0x30, 0x2F, 0xB7 },
|
||||||
{ 0x05, 0x1A, 0x37, 0xBF },
|
{ 0x05, 0x1A, 0x37, 0xBF },
|
||||||
{ 0x12, 0x10, 0x3B, 0xBF },
|
{ 0x12, 0x10, 0x3B, 0xBF },
|
||||||
{ 0x23, 0x09, 0x38, 0xB7 },
|
{ 0x23, 0x09, 0x38, 0xB7 },
|
||||||
{ 0x31, 0x06, 0x2E, 0xBF },
|
{ 0x31, 0x06, 0x2E, 0xBF },
|
||||||
{ 0x35, 0x08, 0x18, 0xB7 },
|
{ 0x35, 0x08, 0x18, 0xB7 },
|
||||||
{ 0x35, 0x0D, 0x08, 0x00 },
|
{ 0x35, 0x0D, 0x08, 0x00 },
|
||||||
{ 0x2D, 0x16, 0x03, 0xB7 },
|
{ 0x2D, 0x16, 0x03, 0xB7 },
|
||||||
{ 0x22, 0x1E, 0x01, 0x00 },
|
{ 0x22, 0x1E, 0x01, 0x00 },
|
||||||
{ 0x0E, 0x24, 0x01, 0x00 },
|
{ 0x0E, 0x24, 0x01, 0x00 },
|
||||||
{ 0x05, 0x26, 0x06, 0x00 },
|
{ 0x05, 0x26, 0x06, 0x00 },
|
||||||
{ 0x02, 0x26, 0x16, 0xB7 },
|
{ 0x02, 0x26, 0x16, 0xB7 },
|
||||||
{ 0x02, 0x22, 0x2A, 0xBF },
|
{ 0x02, 0x22, 0x2A, 0xBF },
|
||||||
{ 0x0B, 0x0B, 0x0B, 0xBF },
|
{ 0x0B, 0x0B, 0x0B, 0xBF },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x3D, 0x3D, 0x3E, 0x00 },
|
{ 0x3D, 0x3D, 0x3E, 0x00 },
|
||||||
{ 0x12, 0x2C, 0x3E, 0xB7 },
|
{ 0x12, 0x2C, 0x3E, 0xB7 },
|
||||||
{ 0x22, 0x25, 0x3F, 0xB7 },
|
{ 0x22, 0x25, 0x3F, 0xB7 },
|
||||||
{ 0x30, 0x1E, 0x3E, 0xB7 },
|
{ 0x30, 0x1E, 0x3E, 0xB7 },
|
||||||
{ 0x3A, 0x1B, 0x3B, 0xBF },
|
{ 0x3A, 0x1B, 0x3B, 0xBF },
|
||||||
{ 0x3D, 0x1D, 0x2E, 0xB7 },
|
{ 0x3D, 0x1D, 0x2E, 0xB7 },
|
||||||
{ 0x3D, 0x20, 0x1B, 0xB7 },
|
{ 0x3D, 0x20, 0x1B, 0xB7 },
|
||||||
{ 0x3B, 0x28, 0x11, 0x07 },
|
{ 0x3B, 0x28, 0x11, 0x07 },
|
||||||
{ 0x35, 0x30, 0x08, 0x01 },
|
{ 0x35, 0x30, 0x08, 0x01 },
|
||||||
{ 0x26, 0x35, 0x08, 0x00 },
|
{ 0x26, 0x35, 0x08, 0x00 },
|
||||||
{ 0x14, 0x37, 0x11, 0x00 },
|
{ 0x14, 0x37, 0x11, 0x00 },
|
||||||
{ 0x0F, 0x37, 0x25, 0x00 },
|
{ 0x0F, 0x37, 0x25, 0x00 },
|
||||||
{ 0x0A, 0x36, 0x37, 0xB7 },
|
{ 0x0A, 0x36, 0x37, 0xB7 },
|
||||||
{ 0x18, 0x19, 0x19, 0xB7 },
|
{ 0x18, 0x19, 0x19, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x3E, 0x3E, 0x3E, 0xB7 },
|
{ 0x3E, 0x3E, 0x3E, 0xB7 },
|
||||||
{ 0x2D, 0x37, 0x3E, 0xB7 },
|
{ 0x2D, 0x37, 0x3E, 0xB7 },
|
||||||
{ 0x33, 0x34, 0x3F, 0x10 },
|
{ 0x33, 0x34, 0x3F, 0x10 },
|
||||||
{ 0x37, 0x31, 0x3E, 0x00 },
|
{ 0x37, 0x31, 0x3E, 0x00 },
|
||||||
{ 0x3C, 0x30, 0x3D, 0x00 },
|
{ 0x3C, 0x30, 0x3D, 0x00 },
|
||||||
{ 0x3D, 0x30, 0x38, 0x00 },
|
{ 0x3D, 0x30, 0x38, 0x00 },
|
||||||
{ 0x3D, 0x33, 0x30, 0x00 },
|
{ 0x3D, 0x33, 0x30, 0x00 },
|
||||||
{ 0x3D, 0x36, 0x2B, 0x00 },
|
{ 0x3D, 0x36, 0x2B, 0x00 },
|
||||||
{ 0x3B, 0x39, 0x26, 0x00 },
|
{ 0x3B, 0x39, 0x26, 0x00 },
|
||||||
{ 0x34, 0x3B, 0x27, 0x00 },
|
{ 0x34, 0x3B, 0x27, 0x00 },
|
||||||
{ 0x2E, 0x3C, 0x2D, 0x00 },
|
{ 0x2E, 0x3C, 0x2D, 0x00 },
|
||||||
{ 0x2C, 0x3C, 0x36, 0x00 },
|
{ 0x2C, 0x3C, 0x36, 0x00 },
|
||||||
{ 0x29, 0x3C, 0x3C, 0x00 },
|
{ 0x29, 0x3C, 0x3C, 0x00 },
|
||||||
{ 0x32, 0x31, 0x32, 0xB7 },
|
{ 0x32, 0x31, 0x32, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x1E, 0x1E, 0x1E, 0xB7 },
|
{ 0x1E, 0x1E, 0x1E, 0xB7 },
|
||||||
{ 0x03, 0x09, 0x28, 0xB7 },
|
{ 0x03, 0x09, 0x28, 0xB7 },
|
||||||
{ 0x0A, 0x04, 0x2B, 0xBF },
|
{ 0x0A, 0x04, 0x2B, 0xBF },
|
||||||
{ 0x17, 0x02, 0x28, 0xB7 },
|
{ 0x17, 0x02, 0x28, 0xB7 },
|
||||||
{ 0x22, 0x00, 0x1D, 0xB7 },
|
{ 0x22, 0x00, 0x1D, 0xB7 },
|
||||||
{ 0x24, 0x01, 0x0A, 0xB7 },
|
{ 0x24, 0x01, 0x0A, 0xB7 },
|
||||||
{ 0x24, 0x04, 0x02, 0x00 },
|
{ 0x24, 0x04, 0x02, 0x00 },
|
||||||
{ 0x1B, 0x09, 0x01, 0x00 },
|
{ 0x1B, 0x09, 0x01, 0x00 },
|
||||||
{ 0x11, 0x10, 0x01, 0x00 },
|
{ 0x11, 0x10, 0x01, 0x00 },
|
||||||
{ 0x05, 0x15, 0x01, 0xB7 },
|
{ 0x05, 0x15, 0x01, 0xB7 },
|
||||||
{ 0x01, 0x17, 0x02, 0x00 },
|
{ 0x01, 0x17, 0x02, 0x00 },
|
||||||
{ 0x00, 0x14, 0x0B, 0xB7 },
|
{ 0x00, 0x14, 0x0B, 0xB7 },
|
||||||
{ 0x01, 0x11, 0x1B, 0x50 },
|
{ 0x01, 0x11, 0x1B, 0x50 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x2F, 0x30, 0x2F, 0xBF },
|
{ 0x2F, 0x30, 0x2F, 0xBF },
|
||||||
{ 0x05, 0x1A, 0x37, 0xB7 },
|
{ 0x05, 0x1A, 0x37, 0xB7 },
|
||||||
{ 0x12, 0x10, 0x3B, 0xB7 },
|
{ 0x12, 0x10, 0x3B, 0xB7 },
|
||||||
{ 0x23, 0x09, 0x38, 0x20 },
|
{ 0x23, 0x09, 0x38, 0x20 },
|
||||||
{ 0x31, 0x06, 0x2E, 0xBF },
|
{ 0x31, 0x06, 0x2E, 0xBF },
|
||||||
{ 0x35, 0x08, 0x18, 0xB7 },
|
{ 0x35, 0x08, 0x18, 0xB7 },
|
||||||
{ 0x35, 0x0D, 0x08, 0xBF },
|
{ 0x35, 0x0D, 0x08, 0xBF },
|
||||||
{ 0x2D, 0x16, 0x03, 0xBF },
|
{ 0x2D, 0x16, 0x03, 0xBF },
|
||||||
{ 0x22, 0x1E, 0x01, 0xB7 },
|
{ 0x22, 0x1E, 0x01, 0xB7 },
|
||||||
{ 0x0E, 0x24, 0x01, 0xBF },
|
{ 0x0E, 0x24, 0x01, 0xBF },
|
||||||
{ 0x05, 0x26, 0x06, 0xB7 },
|
{ 0x05, 0x26, 0x06, 0xB7 },
|
||||||
{ 0x02, 0x26, 0x16, 0xBF },
|
{ 0x02, 0x26, 0x16, 0xBF },
|
||||||
{ 0x02, 0x22, 0x2A, 0xBF },
|
{ 0x02, 0x22, 0x2A, 0xBF },
|
||||||
{ 0x0B, 0x0B, 0x0B, 0x00 },
|
{ 0x0B, 0x0B, 0x0B, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x3D, 0x3D, 0x3E, 0xBF },
|
{ 0x3D, 0x3D, 0x3E, 0xBF },
|
||||||
{ 0x12, 0x2C, 0x3E, 0x53 },
|
{ 0x12, 0x2C, 0x3E, 0x53 },
|
||||||
{ 0x22, 0x25, 0x3F, 0x54 },
|
{ 0x22, 0x25, 0x3F, 0x54 },
|
||||||
{ 0x30, 0x1E, 0x3E, 0x46 },
|
{ 0x30, 0x1E, 0x3E, 0x46 },
|
||||||
{ 0x3A, 0x1B, 0x3B, 0x31 },
|
{ 0x3A, 0x1B, 0x3B, 0x31 },
|
||||||
{ 0x3D, 0x1D, 0x2E, 0x3A },
|
{ 0x3D, 0x1D, 0x2E, 0x3A },
|
||||||
{ 0x3D, 0x20, 0x1B, 0x32 },
|
{ 0x3D, 0x20, 0x1B, 0x32 },
|
||||||
{ 0x3B, 0x28, 0x11, 0x54 },
|
{ 0x3B, 0x28, 0x11, 0x54 },
|
||||||
{ 0x35, 0x30, 0x08, 0x30 },
|
{ 0x35, 0x30, 0x08, 0x30 },
|
||||||
{ 0x26, 0x35, 0x08, 0x00 },
|
{ 0x26, 0x35, 0x08, 0x00 },
|
||||||
{ 0x14, 0x37, 0x11, 0x00 },
|
{ 0x14, 0x37, 0x11, 0x00 },
|
||||||
{ 0x0F, 0x37, 0x25, 0x00 },
|
{ 0x0F, 0x37, 0x25, 0x00 },
|
||||||
{ 0x0A, 0x36, 0x37, 0x00 },
|
{ 0x0A, 0x36, 0x37, 0x00 },
|
||||||
{ 0x18, 0x19, 0x19, 0x00 },
|
{ 0x18, 0x19, 0x19, 0x00 },
|
||||||
{ 0x01, 0x01, 0x01, 0x00 },
|
{ 0x01, 0x01, 0x01, 0x00 },
|
||||||
{ 0x01, 0x01, 0x01, 0x00 },
|
{ 0x01, 0x01, 0x01, 0x00 },
|
||||||
{ 0x3E, 0x3E, 0x3E, 0x00 },
|
{ 0x3E, 0x3E, 0x3E, 0x00 },
|
||||||
{ 0x2D, 0x37, 0x3E, 0x00 },
|
{ 0x2D, 0x37, 0x3E, 0x00 },
|
||||||
{ 0x33, 0x34, 0x3F, 0x00 },
|
{ 0x33, 0x34, 0x3F, 0x00 },
|
||||||
{ 0x37, 0x31, 0x3E, 0x00 },
|
{ 0x37, 0x31, 0x3E, 0x00 },
|
||||||
{ 0x3C, 0x30, 0x3D, 0x00 },
|
{ 0x3C, 0x30, 0x3D, 0x00 },
|
||||||
{ 0x3D, 0x30, 0x38, 0x00 },
|
{ 0x3D, 0x30, 0x38, 0x00 },
|
||||||
{ 0x3D, 0x33, 0x30, 0xB7 },
|
{ 0x3D, 0x33, 0x30, 0xB7 },
|
||||||
{ 0x3D, 0x36, 0x2B, 0xB7 },
|
{ 0x3D, 0x36, 0x2B, 0xB7 },
|
||||||
{ 0x3B, 0x39, 0x26, 0x00 },
|
{ 0x3B, 0x39, 0x26, 0x00 },
|
||||||
{ 0x34, 0x3B, 0x27, 0xBF },
|
{ 0x34, 0x3B, 0x27, 0xBF },
|
||||||
{ 0x2E, 0x3C, 0x2D, 0xB7 },
|
{ 0x2E, 0x3C, 0x2D, 0xB7 },
|
||||||
{ 0x2C, 0x3C, 0x36, 0xB7 },
|
{ 0x2C, 0x3C, 0x36, 0xB7 },
|
||||||
{ 0x29, 0x3C, 0x3C, 0xB7 },
|
{ 0x29, 0x3C, 0x3C, 0xB7 },
|
||||||
{ 0x32, 0x31, 0x32, 0xB7 },
|
{ 0x32, 0x31, 0x32, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x1E, 0x1E, 0x1E, 0x07 },
|
{ 0x1E, 0x1E, 0x1E, 0x07 },
|
||||||
{ 0x03, 0x09, 0x28, 0xB7 },
|
{ 0x03, 0x09, 0x28, 0xB7 },
|
||||||
{ 0x0A, 0x04, 0x2B, 0x0D },
|
{ 0x0A, 0x04, 0x2B, 0x0D },
|
||||||
{ 0x17, 0x02, 0x28, 0x00 },
|
{ 0x17, 0x02, 0x28, 0x00 },
|
||||||
{ 0x22, 0x00, 0x1D, 0xB7 },
|
{ 0x22, 0x00, 0x1D, 0xB7 },
|
||||||
{ 0x24, 0x01, 0x0A, 0xB7 },
|
{ 0x24, 0x01, 0x0A, 0xB7 },
|
||||||
{ 0x24, 0x04, 0x02, 0xB7 },
|
{ 0x24, 0x04, 0x02, 0xB7 },
|
||||||
{ 0x1B, 0x09, 0x01, 0xB7 },
|
{ 0x1B, 0x09, 0x01, 0xB7 },
|
||||||
{ 0x11, 0x10, 0x01, 0x00 },
|
{ 0x11, 0x10, 0x01, 0x00 },
|
||||||
{ 0x05, 0x15, 0x01, 0x00 },
|
{ 0x05, 0x15, 0x01, 0x00 },
|
||||||
{ 0x01, 0x17, 0x02, 0xB7 },
|
{ 0x01, 0x17, 0x02, 0xB7 },
|
||||||
{ 0x00, 0x14, 0x0B, 0x00 },
|
{ 0x00, 0x14, 0x0B, 0x00 },
|
||||||
{ 0x01, 0x11, 0x1B, 0xB7 },
|
{ 0x01, 0x11, 0x1B, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x2F, 0x30, 0x2F, 0xB7 },
|
{ 0x2F, 0x30, 0x2F, 0xB7 },
|
||||||
{ 0x05, 0x1A, 0x37, 0xBF },
|
{ 0x05, 0x1A, 0x37, 0xBF },
|
||||||
{ 0x12, 0x10, 0x3B, 0xB7 },
|
{ 0x12, 0x10, 0x3B, 0xB7 },
|
||||||
{ 0x23, 0x09, 0x38, 0xB7 },
|
{ 0x23, 0x09, 0x38, 0xB7 },
|
||||||
{ 0x31, 0x06, 0x2E, 0x00 },
|
{ 0x31, 0x06, 0x2E, 0x00 },
|
||||||
{ 0x35, 0x08, 0x18, 0xBF },
|
{ 0x35, 0x08, 0x18, 0xBF },
|
||||||
{ 0x35, 0x0D, 0x08, 0xB7 },
|
{ 0x35, 0x0D, 0x08, 0xB7 },
|
||||||
{ 0x2D, 0x16, 0x03, 0xB7 },
|
{ 0x2D, 0x16, 0x03, 0xB7 },
|
||||||
{ 0x22, 0x1E, 0x01, 0xB7 },
|
{ 0x22, 0x1E, 0x01, 0xB7 },
|
||||||
{ 0x0E, 0x24, 0x01, 0x00 },
|
{ 0x0E, 0x24, 0x01, 0x00 },
|
||||||
{ 0x05, 0x26, 0x06, 0x00 },
|
{ 0x05, 0x26, 0x06, 0x00 },
|
||||||
{ 0x02, 0x26, 0x16, 0xB7 },
|
{ 0x02, 0x26, 0x16, 0xB7 },
|
||||||
{ 0x02, 0x22, 0x2A, 0x06 },
|
{ 0x02, 0x22, 0x2A, 0x06 },
|
||||||
{ 0x0B, 0x0B, 0x0B, 0xB7 },
|
{ 0x0B, 0x0B, 0x0B, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x00, 0x00, 0x00, 0x00 },
|
{ 0x00, 0x00, 0x00, 0x00 },
|
||||||
{ 0x3D, 0x3D, 0x3E, 0xB7 },
|
{ 0x3D, 0x3D, 0x3E, 0xB7 },
|
||||||
{ 0x12, 0x2C, 0x3E, 0xB7 },
|
{ 0x12, 0x2C, 0x3E, 0xB7 },
|
||||||
{ 0x22, 0x25, 0x3F, 0xB7 },
|
{ 0x22, 0x25, 0x3F, 0xB7 },
|
||||||
{ 0x30, 0x1E, 0x3E, 0xB7 },
|
{ 0x30, 0x1E, 0x3E, 0xB7 },
|
||||||
{ 0x3A, 0x1B, 0x3B, 0x00 },
|
{ 0x3A, 0x1B, 0x3B, 0x00 },
|
||||||
{ 0x3D, 0x1D, 0x2E, 0x00 },
|
{ 0x3D, 0x1D, 0x2E, 0x00 },
|
||||||
{ 0x3D, 0x20, 0x1B, 0xB7 },
|
{ 0x3D, 0x20, 0x1B, 0xB7 },
|
||||||
{ 0x3B, 0x28, 0x11, 0xB7 },
|
{ 0x3B, 0x28, 0x11, 0xB7 },
|
||||||
{ 0x35, 0x30, 0x08, 0x03 },
|
{ 0x35, 0x30, 0x08, 0x03 },
|
||||||
{ 0x26, 0x35, 0x08, 0xB7 },
|
{ 0x26, 0x35, 0x08, 0xB7 },
|
||||||
{ 0x14, 0x37, 0x11, 0xBF },
|
{ 0x14, 0x37, 0x11, 0xBF },
|
||||||
{ 0x0F, 0x37, 0x25, 0x00 },
|
{ 0x0F, 0x37, 0x25, 0x00 },
|
||||||
{ 0x0A, 0x36, 0x37, 0xB7 },
|
{ 0x0A, 0x36, 0x37, 0xB7 },
|
||||||
{ 0x18, 0x19, 0x19, 0xB7 },
|
{ 0x18, 0x19, 0x19, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x3E, 0x3E, 0x3E, 0x00 },
|
{ 0x3E, 0x3E, 0x3E, 0x00 },
|
||||||
{ 0x2D, 0x37, 0x3E, 0x00 },
|
{ 0x2D, 0x37, 0x3E, 0x00 },
|
||||||
{ 0x33, 0x34, 0x3F, 0xB7 },
|
{ 0x33, 0x34, 0x3F, 0xB7 },
|
||||||
{ 0x37, 0x31, 0x3E, 0xB7 },
|
{ 0x37, 0x31, 0x3E, 0xB7 },
|
||||||
{ 0x3C, 0x30, 0x3D, 0x00 },
|
{ 0x3C, 0x30, 0x3D, 0x00 },
|
||||||
{ 0x3D, 0x30, 0x38, 0x00 },
|
{ 0x3D, 0x30, 0x38, 0x00 },
|
||||||
{ 0x3D, 0x33, 0x30, 0xB7 },
|
{ 0x3D, 0x33, 0x30, 0xB7 },
|
||||||
{ 0x3D, 0x36, 0x2B, 0xB7 },
|
{ 0x3D, 0x36, 0x2B, 0xB7 },
|
||||||
{ 0x3B, 0x39, 0x26, 0xB7 },
|
{ 0x3B, 0x39, 0x26, 0xB7 },
|
||||||
{ 0x34, 0x3B, 0x27, 0xBF },
|
{ 0x34, 0x3B, 0x27, 0xBF },
|
||||||
{ 0x2E, 0x3C, 0x2D, 0xBF },
|
{ 0x2E, 0x3C, 0x2D, 0xBF },
|
||||||
{ 0x2C, 0x3C, 0x36, 0xB7 },
|
{ 0x2C, 0x3C, 0x36, 0xB7 },
|
||||||
{ 0x29, 0x3C, 0x3C, 0xBF },
|
{ 0x29, 0x3C, 0x3C, 0xBF },
|
||||||
{ 0x32, 0x31, 0x32, 0xB7 },
|
{ 0x32, 0x31, 0x32, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0x00 },
|
{ 0x01, 0x01, 0x01, 0x00 },
|
||||||
{ 0x01, 0x01, 0x01, 0xB7 },
|
{ 0x01, 0x01, 0x01, 0xB7 },
|
||||||
{ 0x1E, 0x1E, 0x1E, 0xB7 },
|
{ 0x1E, 0x1E, 0x1E, 0xB7 },
|
||||||
{ 0x03, 0x09, 0x28, 0x08 },
|
{ 0x03, 0x09, 0x28, 0x08 },
|
||||||
{ 0x0A, 0x04, 0x2B, 0xBF },
|
{ 0x0A, 0x04, 0x2B, 0xBF },
|
||||||
{ 0x17, 0x02, 0x28, 0xB7 },
|
{ 0x17, 0x02, 0x28, 0xB7 },
|
||||||
{ 0x22, 0x00, 0x1D, 0x08 },
|
{ 0x22, 0x00, 0x1D, 0x08 },
|
||||||
{ 0x24, 0x01, 0x0A, 0xB7 },
|
{ 0x24, 0x01, 0x0A, 0xB7 },
|
||||||
{ 0x24, 0x04, 0x02, 0x08 },
|
{ 0x24, 0x04, 0x02, 0x08 },
|
||||||
{ 0x1B, 0x09, 0x01, 0xB7 },
|
{ 0x1B, 0x09, 0x01, 0xB7 },
|
||||||
{ 0x11, 0x10, 0x01, 0x00 },
|
{ 0x11, 0x10, 0x01, 0x00 },
|
||||||
{ 0x05, 0x15, 0x01, 0xBF },
|
{ 0x05, 0x15, 0x01, 0xBF },
|
||||||
{ 0x01, 0x17, 0x02, 0xB7 },
|
{ 0x01, 0x17, 0x02, 0xB7 },
|
||||||
{ 0x00, 0x14, 0x0B, 0xB7 },
|
{ 0x00, 0x14, 0x0B, 0xB7 },
|
||||||
{ 0x01, 0x11, 0x1B, 0x08 },
|
{ 0x01, 0x11, 0x1B, 0x08 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0x08 },
|
{ 0x00, 0x00, 0x00, 0x08 },
|
||||||
{ 0x2F, 0x30, 0x2F, 0x01 },
|
{ 0x2F, 0x30, 0x2F, 0x01 },
|
||||||
{ 0x05, 0x1A, 0x37, 0x08 },
|
{ 0x05, 0x1A, 0x37, 0x08 },
|
||||||
{ 0x12, 0x10, 0x3B, 0x0D },
|
{ 0x12, 0x10, 0x3B, 0x0D },
|
||||||
{ 0x23, 0x09, 0x38, 0x00 },
|
{ 0x23, 0x09, 0x38, 0x00 },
|
||||||
{ 0x31, 0x06, 0x2E, 0xB7 },
|
{ 0x31, 0x06, 0x2E, 0xB7 },
|
||||||
{ 0x35, 0x08, 0x18, 0xB7 },
|
{ 0x35, 0x08, 0x18, 0xB7 },
|
||||||
{ 0x35, 0x0D, 0x08, 0xB7 },
|
{ 0x35, 0x0D, 0x08, 0xB7 },
|
||||||
{ 0x2D, 0x16, 0x03, 0xB7 },
|
{ 0x2D, 0x16, 0x03, 0xB7 },
|
||||||
{ 0x22, 0x1E, 0x01, 0x00 },
|
{ 0x22, 0x1E, 0x01, 0x00 },
|
||||||
{ 0x0E, 0x24, 0x01, 0x00 },
|
{ 0x0E, 0x24, 0x01, 0x00 },
|
||||||
{ 0x05, 0x26, 0x06, 0xB7 },
|
{ 0x05, 0x26, 0x06, 0xB7 },
|
||||||
{ 0x02, 0x26, 0x16, 0x00 },
|
{ 0x02, 0x26, 0x16, 0x00 },
|
||||||
{ 0x02, 0x22, 0x2A, 0xB7 },
|
{ 0x02, 0x22, 0x2A, 0xB7 },
|
||||||
{ 0x0B, 0x0B, 0x0B, 0xB7 },
|
{ 0x0B, 0x0B, 0x0B, 0xB7 },
|
||||||
{ 0x00, 0x00, 0x00, 0x08 },
|
{ 0x00, 0x00, 0x00, 0x08 },
|
||||||
{ 0x00, 0x00, 0x00, 0xB7 },
|
{ 0x00, 0x00, 0x00, 0xB7 },
|
||||||
{ 0x3D, 0x3D, 0x3E, 0xB7 },
|
{ 0x3D, 0x3D, 0x3E, 0xB7 },
|
||||||
{ 0x12, 0x2C, 0x3E, 0xBF },
|
{ 0x12, 0x2C, 0x3E, 0xBF },
|
||||||
{ 0x22, 0x25, 0x3F, 0xBF },
|
{ 0x22, 0x25, 0x3F, 0xBF },
|
||||||
{ 0x30, 0x1E, 0x3E, 0xB7 },
|
{ 0x30, 0x1E, 0x3E, 0xB7 },
|
||||||
{ 0x3A, 0x1B, 0x3B, 0xBF },
|
{ 0x3A, 0x1B, 0x3B, 0xBF },
|
||||||
{ 0x3D, 0x1D, 0x2E, 0xB7 },
|
{ 0x3D, 0x1D, 0x2E, 0xB7 },
|
||||||
{ 0x3D, 0x20, 0x1B, 0x00 },
|
{ 0x3D, 0x20, 0x1B, 0x00 },
|
||||||
{ 0x3B, 0x28, 0x11, 0xB7 },
|
{ 0x3B, 0x28, 0x11, 0xB7 },
|
||||||
{ 0x35, 0x30, 0x08, 0x00 },
|
{ 0x35, 0x30, 0x08, 0x00 },
|
||||||
{ 0x26, 0x35, 0x08, 0x00 },
|
{ 0x26, 0x35, 0x08, 0x00 },
|
||||||
{ 0x14, 0x37, 0x11, 0x00 },
|
{ 0x14, 0x37, 0x11, 0x00 },
|
||||||
{ 0x0F, 0x37, 0x25, 0xB7 },
|
{ 0x0F, 0x37, 0x25, 0xB7 },
|
||||||
{ 0x0A, 0x36, 0x37, 0xB7 },
|
{ 0x0A, 0x36, 0x37, 0xB7 },
|
||||||
{ 0x18, 0x19, 0x19, 0x00 },
|
{ 0x18, 0x19, 0x19, 0x00 },
|
||||||
{ 0x01, 0x01, 0x01, 0x00 },
|
{ 0x01, 0x01, 0x01, 0x00 },
|
||||||
{ 0x01, 0x01, 0x01, 0x00 },
|
{ 0x01, 0x01, 0x01, 0x00 },
|
||||||
{ 0x3E, 0x3E, 0x3E, 0x00 },
|
{ 0x3E, 0x3E, 0x3E, 0x00 },
|
||||||
{ 0x2D, 0x37, 0x3E, 0xB7 },
|
{ 0x2D, 0x37, 0x3E, 0xB7 },
|
||||||
{ 0x33, 0x34, 0x3F, 0x00 },
|
{ 0x33, 0x34, 0x3F, 0x00 },
|
||||||
{ 0x37, 0x31, 0x3E, 0xB7 },
|
{ 0x37, 0x31, 0x3E, 0xB7 },
|
||||||
{ 0x3C, 0x30, 0x3D, 0xBF },
|
{ 0x3C, 0x30, 0x3D, 0xBF },
|
||||||
{ 0x3D, 0x30, 0x38, 0xB7 },
|
{ 0x3D, 0x30, 0x38, 0xB7 },
|
||||||
{ 0x3D, 0x33, 0x30, 0x08 },
|
{ 0x3D, 0x33, 0x30, 0x08 },
|
||||||
{ 0x3D, 0x36, 0x2B, 0x01 },
|
{ 0x3D, 0x36, 0x2B, 0x01 },
|
||||||
{ 0x3B, 0x39, 0x26, 0x01 },
|
{ 0x3B, 0x39, 0x26, 0x01 },
|
||||||
{ 0x34, 0x3B, 0x27, 0x00 },
|
{ 0x34, 0x3B, 0x27, 0x00 },
|
||||||
{ 0x2E, 0x3C, 0x2D, 0xB7 },
|
{ 0x2E, 0x3C, 0x2D, 0xB7 },
|
||||||
{ 0x2C, 0x3C, 0x36, 0xB7 },
|
{ 0x2C, 0x3C, 0x36, 0xB7 },
|
||||||
{ 0x29, 0x3C, 0x3C, 0x08 },
|
{ 0x29, 0x3C, 0x3C, 0x08 },
|
||||||
{ 0x32, 0x31, 0x32, 0xB7 },
|
{ 0x32, 0x31, 0x32, 0xB7 },
|
||||||
{ 0x01, 0x01, 0x01, 0x08 },
|
{ 0x01, 0x01, 0x01, 0x08 },
|
||||||
{ 0x01, 0x01, 0x01, 0xBF },
|
{ 0x01, 0x01, 0x01, 0xBF },
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,20 +2,20 @@
|
|||||||
* Plugins manager - The peTI-NESulator Project
|
* Plugins manager - The peTI-NESulator Project
|
||||||
* plugins.h
|
* plugins.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER on 02/04/07.
|
* Created by Manoël TRAPIER on 02/04/07.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLUGINS_H
|
#ifndef PLUGINS_H
|
||||||
#define PLUGINS_H
|
#define PLUGINS_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
/* Function pointer for prototyping function that plugins may export */
|
/* Function pointer for prototyping function that plugins may export */
|
||||||
typedef int (*PluginInit) (void);
|
typedef int (*PluginInit)(void);
|
||||||
typedef int (*PluginDeinit) (void);
|
typedef int (*PluginDeinit)(void);
|
||||||
typedef void (*PluginKeypress) (void);
|
typedef void (*PluginKeypress)(void);
|
||||||
|
|
||||||
#ifdef __TINES_PLUGINS__
|
#ifdef __TINES_PLUGINS__
|
||||||
|
|
||||||
@ -30,12 +30,9 @@ int plugin_keypress(uint8_t key);
|
|||||||
|
|
||||||
/* Real Prototype: TBD */
|
/* Real Prototype: TBD */
|
||||||
void plugin_list();
|
void plugin_list();
|
||||||
|
|
||||||
int plugin_load(int id);
|
int plugin_load(int id);
|
||||||
|
|
||||||
int plugin_unload(int id);
|
int plugin_unload(int id);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __TINES_PLUGINS__ */
|
#endif /* __TINES_PLUGINS__ */
|
||||||
|
|
||||||
#endif /* PLUGINS_H */
|
#endif /* PLUGINS_H */
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* PPU debug utilities - The peTI-NESulator Project
|
* PPU debug utilities - The peTI-NESulator Project
|
||||||
* ppu.debug.h
|
* 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.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Define and emulate the PPU (Picture Processing Unit) of the real NES
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -26,13 +26,9 @@ typedef struct PPU_Sprite_
|
|||||||
PPU must be initialized after memory initialisation..
|
PPU must be initialized after memory initialisation..
|
||||||
*/
|
*/
|
||||||
int ppu_init();
|
int ppu_init();
|
||||||
|
|
||||||
int ppu_hblank(uint16_t scanline);
|
int ppu_hblank(uint16_t scanline);
|
||||||
|
|
||||||
uint8_t ppu_readReg(uint8_t id);
|
uint8_t ppu_readReg(uint8_t id);
|
||||||
|
|
||||||
void ppu_writeReg(uint8_t id, uint8_t val);
|
void ppu_writeReg(uint8_t id, uint8_t val);
|
||||||
|
|
||||||
void ppu_fillSprRamDMA(uint8_t value);
|
void ppu_fillSprRamDMA(uint8_t value);
|
||||||
|
|
||||||
#define PPU_MIRROR_HORIZTAL 0
|
#define PPU_MIRROR_HORIZTAL 0
|
||||||
@ -50,13 +46,9 @@ void ppu_fillSprRamDMA(uint8_t value);
|
|||||||
void ppu_setMirroring(uint8_t direction);
|
void ppu_setMirroring(uint8_t direction);
|
||||||
void ppu_setSingleScreen(uint8_t screen);
|
void ppu_setSingleScreen(uint8_t screen);
|
||||||
void ppu_setScreenMode(uint8_t mode);
|
void ppu_setScreenMode(uint8_t mode);
|
||||||
|
|
||||||
|
|
||||||
PPU_Sprite ppu_getSprite(uint16_t i);
|
PPU_Sprite ppu_getSprite(uint16_t i);
|
||||||
|
|
||||||
uint8_t ppu_memoryRead(uint8_t page, uint8_t addr);
|
uint8_t ppu_memoryRead(uint8_t page, uint8_t addr);
|
||||||
void ppu_memoryWrite(uint8_t page, uint8_t addr, uint8_t value);
|
void ppu_memoryWrite(uint8_t page, uint8_t addr, uint8_t value);
|
||||||
|
|
||||||
void ppu_debugSprites();
|
void ppu_debugSprites();
|
||||||
void ppu_debugColor();
|
void ppu_debugColor();
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* PPU Memory manager - The peTI-NESulator Project
|
* PPU Memory manager - The peTI-NESulator Project
|
||||||
* ppu.memory.h - Inspired from the memory manager of the Quick6502 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.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -11,17 +11,14 @@
|
|||||||
|
|
||||||
int ppu_initMemory();
|
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_setPagePtr1k(uint8_t page, uint8_t *ptr);
|
||||||
void ppu_setPagePtr2k(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_setPagePtr4k(uint8_t page, uint8_t *ptr);
|
||||||
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
|
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
|
||||||
|
|
||||||
void ppu_memoryDumpState(FILE *fp);
|
void ppu_memoryDumpState(FILE *fp);
|
||||||
|
|
||||||
uint8_t ppu_readMemory(uint8_t page, uint8_t addr);
|
uint8_t ppu_readMemory(uint8_t page, uint8_t addr);
|
||||||
void ppu_writeMemory(uint8_t page, uint8_t addr, uint8_t value);
|
void ppu_writeMemory(uint8_t page, uint8_t addr, uint8_t value);
|
||||||
|
|
||||||
void ppu_setPageGhost(uint8_t page, uint8_t value, uint8_t ghost);
|
void ppu_setPageGhost(uint8_t page, uint8_t value, uint8_t ghost);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Base type definitions - The peTI-NESulator Project
|
* Base type definitions - The peTI-NESulator Project
|
||||||
* types.h - Taken from the Quick6502 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
188
src/log.c
188
src/log.c
@ -2,14 +2,9 @@
|
|||||||
* Log Facility - The Quick6502 Project
|
* Log Facility - The Quick6502 Project
|
||||||
* log.c
|
* 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.
|
* Copyright 2010 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate:$
|
|
||||||
* $Author:$
|
|
||||||
* $HeadURL:$
|
|
||||||
* $Revision:$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -22,104 +17,133 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef TIME_STAMP_LOG
|
#ifdef TIME_STAMP_LOG
|
||||||
|
|
||||||
void time_stamp_line(void)
|
void time_stamp_line(void)
|
||||||
{
|
{
|
||||||
/* Time "0" will be thefirst log line */
|
/* Time "0" will be thefirst log line */
|
||||||
static char firstRun = 1;
|
static char firstRun = 1;
|
||||||
static struct timeval firstTime;
|
static struct timeval firstTime;
|
||||||
struct timeval curTime;
|
struct timeval curTime;
|
||||||
|
|
||||||
int cMin, cSec;
|
int cMin, cSec;
|
||||||
long long cMSec;
|
long long cMSec;
|
||||||
|
|
||||||
/* Get datetime */
|
/* Get datetime */
|
||||||
gettimeofday(&curTime, NULL);
|
gettimeofday(&curTime, NULL);
|
||||||
|
|
||||||
if (firstRun == 1)
|
if (firstRun == 1)
|
||||||
{
|
{
|
||||||
firstRun = 0;
|
firstRun = 0;
|
||||||
firstTime.tv_sec = curTime.tv_sec;
|
firstTime.tv_sec = curTime.tv_sec;
|
||||||
firstTime.tv_usec = curTime.tv_usec;
|
firstTime.tv_usec = curTime.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMSec = ((curTime.tv_sec - firstTime.tv_sec)* 1000) + (curTime.tv_usec - firstTime.tv_usec)/1000;
|
cMSec = ((curTime.tv_sec - firstTime.tv_sec) * 1000) + (curTime.tv_usec - firstTime.tv_usec) / 1000;
|
||||||
cSec = (cMSec/1000);
|
cSec = (cMSec / 1000);
|
||||||
cMSec %= 1000;
|
cMSec %= 1000;
|
||||||
|
|
||||||
cMin = cSec / 60;
|
cMin = cSec / 60;
|
||||||
|
|
||||||
cSec %= 60;
|
cSec %= 60;
|
||||||
|
|
||||||
/* Put cursor at start of line */
|
/* Put cursor at start of line */
|
||||||
printf("%c[s", 0x1B);
|
printf("%c[s", 0x1B);
|
||||||
printf("%c[7000D", 0x1B);
|
printf("%c[7000D", 0x1B);
|
||||||
printf("%c[1C", 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,
|
||||||
printf("%c[u", 0x1B);
|
cMSec);
|
||||||
|
printf("%c[u", 0x1B);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TIME_STAMP_LOG */
|
#endif /* TIME_STAMP_LOG */
|
||||||
|
|
||||||
void log_real(int level, char *user, char *fmt, ...)
|
void log_real(int level, char *user, char *fmt, ...)
|
||||||
{
|
{
|
||||||
/* The LOG_PANIC must always be displayed */
|
/* The LOG_PANIC must always be displayed */
|
||||||
if ((level <= MAX_DEBUG_LEVEL) || (level <= LOG_PANIC))
|
if ((level <= MAX_DEBUG_LEVEL) || (level <= LOG_PANIC))
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
switch(level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case LOG_PANIC: printf(BRED FWHITE); break;
|
case LOG_PANIC:
|
||||||
case LOG_ERROR: printf(FRED); break;
|
printf(BRED FWHITE);
|
||||||
case LOG_WARNING: printf(FYELLOW); break;
|
break;
|
||||||
default:
|
case LOG_ERROR:
|
||||||
case LOG_NORMAL: printf(FGREEN); break;
|
printf(FRED);
|
||||||
case LOG_VERBOSE: printf(FCYAN); break;
|
break;
|
||||||
case LOG_DEBUG: printf(BBLUE FWHITE); 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;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef TIME_STAMP_LOG
|
#ifdef TIME_STAMP_LOG
|
||||||
printf(" ");
|
printf(" ");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (user != NULL)
|
if (user != NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
i = strlen(user);
|
i = strlen(user);
|
||||||
if (i < 12)
|
if (i < 12)
|
||||||
{
|
{
|
||||||
i = 12 - i;
|
i = 12 - i;
|
||||||
for (; i >= 0; i--)
|
for (; i >= 0 ; i--)
|
||||||
putchar(' ');
|
{
|
||||||
}
|
putchar(' ');
|
||||||
printf("%s", user);
|
}
|
||||||
}
|
}
|
||||||
else
|
printf("%s", user);
|
||||||
{
|
}
|
||||||
switch(level)
|
else
|
||||||
{
|
{
|
||||||
case LOG_PANIC: printf(" PANIC"); break;
|
switch (level)
|
||||||
case LOG_ERROR: printf(" Error"); break;
|
{
|
||||||
case LOG_WARNING: printf(" Warning"); break;
|
case LOG_PANIC:
|
||||||
default:
|
printf(" PANIC");
|
||||||
case LOG_NORMAL: printf(" Info"); break;
|
break;
|
||||||
case LOG_VERBOSE: printf(" Verbose"); break;
|
case LOG_ERROR:
|
||||||
case LOG_DEBUG: printf(" Debug"); break;
|
printf(" Error");
|
||||||
}
|
break;
|
||||||
}
|
case LOG_WARNING:
|
||||||
|
printf(" Warning");
|
||||||
printf(CNORMAL ": ");
|
break;
|
||||||
|
default:
|
||||||
|
case LOG_NORMAL:
|
||||||
|
printf(" Info");
|
||||||
|
break;
|
||||||
|
case LOG_VERBOSE:
|
||||||
|
printf(" Verbose");
|
||||||
|
break;
|
||||||
|
case LOG_DEBUG:
|
||||||
|
printf(" Debug");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(CNORMAL ": ");
|
||||||
|
|
||||||
#ifdef TIME_STAMP_LOG
|
#ifdef TIME_STAMP_LOG
|
||||||
time_stamp_line();
|
time_stamp_line();
|
||||||
#endif /* TIME_STAMP_LOG */
|
#endif /* TIME_STAMP_LOG */
|
||||||
|
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
vprintf(fmt, va);
|
vprintf(fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
if (fmt[0] != 0)
|
if (fmt[0] != 0)
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1407
src/main.c
1407
src/main.c
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Mapper manager - The peTI-NESulator Project
|
* Mapper manager - The peTI-NESulator Project
|
||||||
* manager.c
|
* manager.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -14,53 +14,55 @@
|
|||||||
|
|
||||||
#include <os_dependent.h>
|
#include <os_dependent.h>
|
||||||
|
|
||||||
MapperIRQ mapper_irqloop;
|
MapperIRQ mapper_irqloop;
|
||||||
MapperDump mapper_dump;
|
MapperDump mapper_dump;
|
||||||
MapperWriteHook mapper_hook;
|
MapperWriteHook mapper_hook;
|
||||||
|
|
||||||
typedef struct Mapper_
|
typedef struct Mapper_
|
||||||
{
|
{
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
MapperInit init;
|
MapperInit init;
|
||||||
MapperIRQ irq;
|
MapperIRQ irq;
|
||||||
MapperDump dump;
|
MapperDump dump;
|
||||||
|
|
||||||
} Mapper;
|
} Mapper;
|
||||||
|
|
||||||
#include "mappers_list.h"
|
#include "mappers_list.h"
|
||||||
|
|
||||||
void mapper_list ()
|
void mapper_list()
|
||||||
{
|
{
|
||||||
Mapper *ptr = &(Mappers[0]);
|
Mapper *ptr = &(Mappers[0]);
|
||||||
console_printf(Console_Default, "Available mapers:\n");
|
console_printf(Console_Default, "Available mappers:\n");
|
||||||
while(ptr->name != NULL)
|
while (ptr->name != NULL)
|
||||||
{
|
{
|
||||||
console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
|
console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mapper_init (NesCart *cart)
|
int mapper_init(NesCart *cart)
|
||||||
{
|
{
|
||||||
Mapper *ptr = &(Mappers[0]);
|
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)
|
while (ptr->name != NULL)
|
||||||
{
|
{
|
||||||
if (ptr->id == cart->MapperID)
|
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)
|
if (ptr->init)
|
||||||
ptr->init (cart);
|
{
|
||||||
|
ptr->init(cart);
|
||||||
mapper_irqloop = ptr->irq;
|
}
|
||||||
mapper_dump = ptr->dump;
|
|
||||||
|
mapper_irqloop = ptr->irq;
|
||||||
return 0;
|
mapper_dump = ptr->dump;
|
||||||
}
|
|
||||||
ptr++;
|
return 0;
|
||||||
}
|
}
|
||||||
console_printf (Console_Default, "No compatible mapper found!\n");
|
ptr++;
|
||||||
return -1;
|
}
|
||||||
|
console_printf(Console_Default, "No compatible mapper found!\n");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* AOROM Mapper - The peTI-NESulator Project
|
* AOROM Mapper - The peTI-NESulator Project
|
||||||
* aorom.c
|
* aorom.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -15,46 +15,50 @@ void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
|
|||||||
|
|
||||||
extern uint8_t *ppu_mem_nameTables;
|
extern uint8_t *ppu_mem_nameTables;
|
||||||
|
|
||||||
int aorom_InitMapper(NesCart * cart)
|
int aorom_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
set_prom_bank_32k(0x8000,0);
|
set_prom_bank_32k(0x8000, 0);
|
||||||
|
|
||||||
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
||||||
|
|
||||||
aorom_load_bank = 0;
|
aorom_load_bank = 0;
|
||||||
|
|
||||||
/* Register the write hook */
|
/* 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_wr_hook(i, aorom_MapperWriteHook);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
int BankNb;
|
int BankNb;
|
||||||
|
|
||||||
if (Value & (1 << 4))
|
if (Value & (1 << 4))
|
||||||
ppu_setSingleScreen(PPU_SCREEN_000);
|
{
|
||||||
else
|
ppu_setSingleScreen(PPU_SCREEN_000);
|
||||||
ppu_setSingleScreen(PPU_SCREEN_400);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ppu_setSingleScreen(PPU_SCREEN_400);
|
||||||
|
}
|
||||||
|
|
||||||
BankNb = Value & 0x0F;
|
BankNb = Value & 0x0F;
|
||||||
|
|
||||||
aorom_load_bank = BankNb;
|
aorom_load_bank = BankNb;
|
||||||
|
|
||||||
//console_printf(Console_Default, "aorom: Asking bank %d - NT is 0x%04X\n",BankNb,(Value&0x10)?0x2400:0x2000);
|
//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)
|
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 Mapper - The peTI-NESulator Project
|
||||||
* aorom.h
|
* aorom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int aorom_InitMapper(NesCart * cart);
|
int aorom_InitMapper(NesCart *cart);
|
||||||
void aorom_MapperDump(FILE *fp);
|
void aorom_MapperDump(FILE *fp);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* CNROM Mapper - The peTI-NESulator Project
|
* CNROM Mapper - The peTI-NESulator Project
|
||||||
* cnrom.c
|
* cnrom.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,32 +13,32 @@ uint8_t cnrom_load_bank;
|
|||||||
|
|
||||||
void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
|
void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
|
||||||
|
|
||||||
int cnrom_InitMapper(NesCart * cart)
|
int cnrom_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, 0);
|
set_prom_bank_16k(0x8000, 0);
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart)); /* Set the last one */
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart)); /* Set the last one */
|
||||||
cnrom_load_bank = 0;
|
cnrom_load_bank = 0;
|
||||||
|
|
||||||
/* Register the write hook */
|
/* 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_wr_hook(i, cnrom_MapperWriteHook);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
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;
|
cnrom_load_bank = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cnrom_MapperDump(FILE *fp)
|
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 Mapper - The peTI-NESulator Project
|
||||||
* cnrom.h
|
* cnrom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int cnrom_InitMapper(NesCart * cart);
|
int cnrom_InitMapper(NesCart *cart);
|
||||||
void cnrom_MapperDump(FILE *fp);
|
void cnrom_MapperDump(FILE *fp);
|
||||||
@ -2,8 +2,8 @@
|
|||||||
* Generic mapper implementation - The peTI-NESulator Project
|
* Generic mapper implementation - The peTI-NESulator Project
|
||||||
* genericmapper.h
|
* genericmapper.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* IREMH3001 Mapper - The peTI-NESulator Project
|
* IREMH3001 Mapper - The peTI-NESulator Project
|
||||||
* iremh3001.c
|
* iremh3001.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,17 +13,17 @@ uint16_t iremh3001_prom_slot[3];
|
|||||||
|
|
||||||
uint16_t iremh3001_vrom_slot[8];
|
uint16_t iremh3001_vrom_slot[8];
|
||||||
|
|
||||||
int iremh3001_InitMapper(NesCart * cart)
|
int iremh3001_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, 0);
|
set_prom_bank_16k(0x8000, 0);
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
iremh3001_prom_slot[0] = 0;
|
iremh3001_prom_slot[0] = 0;
|
||||||
iremh3001_prom_slot[1] = 1;
|
iremh3001_prom_slot[1] = 1;
|
||||||
iremh3001_prom_slot[2] = GETLAST16KBANK(cart);
|
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[0] = 0;
|
||||||
iremh3001_vrom_slot[1] = 0;
|
iremh3001_vrom_slot[1] = 0;
|
||||||
@ -35,88 +35,88 @@ int iremh3001_InitMapper(NesCart * cart)
|
|||||||
iremh3001_vrom_slot[7] = 0;
|
iremh3001_vrom_slot[7] = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int iremh3001_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
int iremh3001_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
switch(Addr)
|
switch(Addr)
|
||||||
{
|
{
|
||||||
case 0x8000: /* Set 8k PROM @ 8000 */
|
case 0x8000: /* Set 8k PROM @ 8000 */
|
||||||
console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
||||||
set_prom_bank_8k(0x8000, Value);
|
set_prom_bank_8k(0x8000, Value);
|
||||||
iremh3001_prom_slot[0] = Value;
|
iremh3001_prom_slot[0] = Value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9003: /* Mirroring ??? */
|
case 0x9003: /* Mirroring ??? */
|
||||||
console_printf(Console_Default, "iremh3001: Mirroring[0x%X:%d] ?\n", Value, Value);
|
console_printf(Console_Default, "iremh3001: Mirroring[0x%X:%d] ?\n", Value, Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9005: /* IRQ ??? */
|
case 0x9005: /* IRQ ??? */
|
||||||
console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
|
console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9006: /* IRQ ??? */
|
case 0x9006: /* IRQ ??? */
|
||||||
console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
|
console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xA000: /* Set 8k PROM @ A000 */
|
case 0xA000: /* Set 8k PROM @ A000 */
|
||||||
console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
||||||
set_prom_bank_8k(0xA000, Value);
|
set_prom_bank_8k(0xA000, Value);
|
||||||
iremh3001_prom_slot[1] = Value;
|
iremh3001_prom_slot[1] = Value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xB000: /* Set 1k VROM @ 0000 */
|
case 0xB000: /* Set 1k VROM @ 0000 */
|
||||||
case 0xB001: /* Set 1k VROM @ 0400 */
|
case 0xB001: /* Set 1k VROM @ 0400 */
|
||||||
case 0xB002: /* Set 1k VROM @ 0800 */
|
case 0xB002: /* Set 1k VROM @ 0800 */
|
||||||
case 0xB003: /* Set 1k VROM @ 0C00 */
|
case 0xB003: /* Set 1k VROM @ 0C00 */
|
||||||
case 0xB004: /* Set 1k VROM @ 1000 */
|
case 0xB004: /* Set 1k VROM @ 1000 */
|
||||||
case 0xB005: /* Set 1k VROM @ 1400 */
|
case 0xB005: /* Set 1k VROM @ 1400 */
|
||||||
case 0xB006: /* Set 1k VROM @ 1800 */
|
case 0xB006: /* Set 1k VROM @ 1800 */
|
||||||
case 0xB007: /* Set 1k VROM @ 1C00 */
|
case 0xB007: /* Set 1k VROM @ 1C00 */
|
||||||
console_printf(Console_Default, "iremh3001: %X: change VROM to %d[%X]\n", (Addr&0x0F)<<10, Value, Value);
|
console_printf(Console_Default, "iremh3001: %X: change VROM to %d[%X]\n", (Addr&0x0F)<<10, Value, Value);
|
||||||
set_vrom_bank_1k((Addr&0xF)<<10, Value);
|
set_vrom_bank_1k((Addr&0xF)<<10, Value);
|
||||||
iremh3001_vrom_slot[Addr&0x0F] = Value;
|
iremh3001_vrom_slot[Addr&0x0F] = Value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xC000: /* Set 8k PROM @ C000 */
|
case 0xC000: /* Set 8k PROM @ C000 */
|
||||||
console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
||||||
set_prom_bank_8k(0xC000, Value);
|
set_prom_bank_8k(0xC000, Value);
|
||||||
iremh3001_prom_slot[2] = Value;
|
iremh3001_prom_slot[2] = Value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console_printf(Console_Default, "@:%X -- V:%X", Addr, Value);
|
console_printf(Console_Default, "@:%X -- V:%X", Addr, Value);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void iremh3001_MapperDump(FILE *fp)
|
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[0],
|
||||||
iremh3001_prom_slot[1],
|
iremh3001_prom_slot[1],
|
||||||
iremh3001_prom_slot[2]);
|
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",
|
" $1000:%d $1400:%d $1800:%d $1C00:%d\n",
|
||||||
iremh3001_vrom_slot[0],
|
iremh3001_vrom_slot[0],
|
||||||
iremh3001_vrom_slot[1],
|
iremh3001_vrom_slot[1],
|
||||||
iremh3001_vrom_slot[2],
|
iremh3001_vrom_slot[2],
|
||||||
iremh3001_vrom_slot[3],
|
iremh3001_vrom_slot[3],
|
||||||
iremh3001_vrom_slot[4],
|
iremh3001_vrom_slot[4],
|
||||||
iremh3001_vrom_slot[5],
|
iremh3001_vrom_slot[5],
|
||||||
iremh3001_vrom_slot[6],
|
iremh3001_vrom_slot[6],
|
||||||
iremh3001_vrom_slot[7]);
|
iremh3001_vrom_slot[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int iremh3001_MapperIRQ(int cycledone)
|
int iremh3001_MapperIRQ(int cycledone)
|
||||||
{
|
{
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,15 @@
|
|||||||
* IREMH3001 Mapper - The peTI-NESulator Project
|
* IREMH3001 Mapper - The peTI-NESulator Project
|
||||||
* iremh3001.h
|
* iremh3001.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int iremh3001_InitMapper(NesCart * cart);
|
int iremh3001_InitMapper(NesCart *cart);
|
||||||
void iremh3001_MapperDump(FILE *fp);
|
void iremh3001_MapperDump(FILE *fp);
|
||||||
int iremh3001_MapperIRQ(int cycledone);
|
int iremh3001_MapperIRQ(int cycledone);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* MMC1 Mapper - The peTI-NESulator Project
|
* MMC1 Mapper - The peTI-NESulator Project
|
||||||
* mmc1.h
|
* mmc1.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -39,10 +39,10 @@ uint8_t mmc1_CurrentBank;
|
|||||||
#define MMC1_R3_RESET 0x80
|
#define MMC1_R3_RESET 0x80
|
||||||
|
|
||||||
|
|
||||||
#define MMC1_REG0_DEFAULT MMC1_R0_PRGSIZE | MMC1_R0_PRGAREA
|
#define MMC1_REG0_DEFAULT (MMC1_R0_PRGSIZE | MMC1_R0_PRGAREA)
|
||||||
#define MMC1_REG1_DEFAULT 0
|
#define MMC1_REG1_DEFAULT (0)
|
||||||
#define MMC1_REG2_DEFAULT 0
|
#define MMC1_REG2_DEFAULT (0)
|
||||||
#define MMC1_REG3_DEFAULT 0
|
#define MMC1_REG3_DEFAULT (0)
|
||||||
|
|
||||||
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value);
|
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value);
|
||||||
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value);
|
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value);
|
||||||
@ -51,55 +51,57 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value);
|
|||||||
|
|
||||||
void mmc1_MapperDump(FILE *fp)
|
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;
|
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(0xC000, GETLAST16KBANK(cart));
|
|
||||||
|
|
||||||
mmc1_CurrentBank = 0;
|
|
||||||
|
|
||||||
if (cart->VROMSize > 0)
|
|
||||||
set_vrom_bank_4k(0x0000,0);
|
|
||||||
|
|
||||||
|
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||||
/* Mapper should register itself for write hook */
|
|
||||||
for (i = 0x80; i < 0xA0 ; i++)
|
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(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
|
mmc1_CurrentBank = 0;
|
||||||
|
|
||||||
|
if (cart->VROMSize > 0)
|
||||||
{
|
{
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg0);
|
set_vrom_bank_4k(0x0000, 0);
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
for (i = 0xA0; i < 0xC0 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg1);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
for (i = 0xC0; i < 0xE0 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg2);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
for (i = 0xE0; i < 0x100 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg3);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Mapper should register itself for write hook */
|
||||||
|
for (i = 0x80 ; i < 0xA0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg0);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xA0 ; i < 0xC0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg1);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xC0 ; i < 0xE0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg2);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xE0 ; i < 0x100 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg3);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -120,24 +122,26 @@ Reg 0
|
|||||||
F : 1111
|
F : 1111
|
||||||
|
|
||||||
((Addr & 0x6000) >> 13) <- port number
|
((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) )
|
|
||||||
|
|
||||||
void mmc1_ApplyReg0Mod()
|
#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) )
|
||||||
|
|
||||||
|
void mmc1_ApplyReg0Mod()
|
||||||
{
|
{
|
||||||
|
|
||||||
static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
|
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\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);
|
||||||
|
|
||||||
switch (MMC1_reg0 & 0x03)
|
switch (MMC1_reg0 & 0x03)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
||||||
ppu_setSingleScreen(PPU_SCREEN_000);
|
ppu_setSingleScreen(PPU_SCREEN_000);
|
||||||
@ -155,27 +159,27 @@ void mmc1_ApplyReg0Mod()
|
|||||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||||
break;
|
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)
|
if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
|
||||||
{ /* 0x8000 area */
|
{ /* 0x8000 area */
|
||||||
set_prom_bank_16k(0x8000,mmc1_CurrentBank);
|
set_prom_bank_16k(0x8000, mmc1_CurrentBank);
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(Cart));
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(Cart));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* 0xC000 area */
|
{ /* 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
|
OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VROMBankNb;
|
uint32_t VROMBankNb;
|
||||||
uint8_t Bit = 0;
|
uint8_t Bit = 0;
|
||||||
@ -183,10 +187,10 @@ uint8_t BitBuf = 0;
|
|||||||
|
|
||||||
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
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();
|
mmc1_ApplyReg0Mod();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -195,25 +199,25 @@ void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
|||||||
{ /* Pas encore ecrit les 5 bits */
|
{ /* Pas encore ecrit les 5 bits */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg0 = BitBuf;
|
MMC1_reg0 = BitBuf;
|
||||||
|
|
||||||
mmc1_ApplyReg0Mod();
|
mmc1_ApplyReg0Mod();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||||
console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg1 Reset occurred !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -221,31 +225,32 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
|||||||
{ /* Pas encore ecrit les 5 bits */
|
{ /* Pas encore ecrit les 5 bits */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg1 = BitBuf;
|
MMC1_reg1 = BitBuf;
|
||||||
|
|
||||||
VROMBankNb = (MMC1_reg1 /* & MMC1_R1_VROMB1 */ );
|
VROMBankNb = (MMC1_reg1 /* & MMC1_R1_VROMB1 */ );
|
||||||
|
|
||||||
if (Cart->VROMSize == 0)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||||
{ /* 4K vram */
|
{ /* 4K vram */
|
||||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 4k bank %d\n", VROMBankNb);
|
//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
|
else
|
||||||
{ /* 8K vram */
|
{ /* 8K vram */
|
||||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 8k bank %d\n", VROMBankNb>>1);
|
//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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,10 +258,10 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
|||||||
|
|
||||||
void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||||
console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg2 Reset occurred !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -264,32 +269,32 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
|||||||
{ /* Pas encore ecrit les 5 bits */
|
{ /* Pas encore ecrit les 5 bits */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg2 = BitBuf;
|
MMC1_reg2 = BitBuf;
|
||||||
|
|
||||||
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
||||||
|
|
||||||
//console_printf(Console_Default, "Want to switch VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
//console_printf(Console_Default, "Want to switch VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
||||||
if (Cart->VROMSize == 0)
|
if (Cart->VROMSize == 0)
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, ": No\n");
|
//console_printf(Console_Default, ": No\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||||
{ /* 4K vram */
|
{ /* 4K vram */
|
||||||
//console_printf(Console_Default, "Switching VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
//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
|
else
|
||||||
{ /* 8K vram */
|
{ /* 8K vram */
|
||||||
// console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
|
// console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
|
||||||
// set_vrom_bank_8k(0x1000,VROMBankNb>>1);
|
// set_vrom_bank_8k(0x1000,VROMBankNb>>1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,10 +302,10 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
|||||||
|
|
||||||
void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||||
console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg3 Reset occurred !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -308,36 +313,38 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
|||||||
{ /* Pas encore ecrit les 5 bits */
|
{ /* Pas encore ecrit les 5 bits */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg3 = BitBuf;
|
MMC1_reg3 = BitBuf;
|
||||||
|
|
||||||
if ( ((uint32_t)MMC1_reg3 << 14) > Cart->PROMSize)
|
if (((uint32_t)MMC1_reg3 << 14) > Cart->PROMSize)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if ( (MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 )
|
|
||||||
|
if ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0)
|
||||||
{ /* 16K Switch */
|
{ /* 16K Switch */
|
||||||
if ( (MMC1_reg0 & MMC1_R0_PRGAREA) != 0 )
|
if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
|
||||||
{ /* 0x8000 switch */
|
{ /* 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);
|
//console_printf(Console_Default, "LowBank is now %d ( 0x%p )\n", MMC1_reg3, mLBank);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* 0xC000 switch */
|
{ /* 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);
|
//console_printf(Console_Default, "HighBank is now %d ( 0x%p )\n", MMC1_reg3, mUBank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* 32K Switch */
|
{ /* 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();
|
unmap_sram();
|
||||||
}
|
}
|
||||||
@ -347,6 +354,6 @@ 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 Mapper - The peTI-NESulator Project
|
||||||
* mmc1.h
|
* mmc1.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int mmc1_InitMapper (NesCart *cart);
|
int mmc1_InitMapper(NesCart *cart);
|
||||||
int mmc1_MapperIRQ (int cycledone);
|
int mmc1_MapperIRQ(int cycledone);
|
||||||
void mmc1_MapperDump (FILE *fp);
|
void mmc1_MapperDump(FILE *fp);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* MMC3 Mapper - The peTI-NESulator Project
|
* MMC3 Mapper - The peTI-NESulator Project
|
||||||
* mmc3.h
|
* mmc3.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,7 @@ uint8_t mmc3_irq_enable;
|
|||||||
uint16_t mmc3_first_prom_page;
|
uint16_t mmc3_first_prom_page;
|
||||||
uint16_t mmc3_second_prom_page;
|
uint16_t mmc3_second_prom_page;
|
||||||
|
|
||||||
uint8_t mmc3_use_xor;
|
uint8_t mmc3_use_xor;
|
||||||
uint8_t mmc3_last_vrom[6];
|
uint8_t mmc3_last_vrom[6];
|
||||||
|
|
||||||
uint8_t mmc3_last_prom[2];
|
uint8_t mmc3_last_prom[2];
|
||||||
@ -27,186 +27,194 @@ uint8_t mmc3_last_prom_switch;
|
|||||||
|
|
||||||
uint16_t dummy;
|
uint16_t dummy;
|
||||||
|
|
||||||
void mmc3_MapperWrite80Hook(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_MapperWriteA0Hook(uint8_t addr, uint8_t Value);
|
||||||
void mmc3_MapperWriteC0Hook(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_MapperWriteE0Hook(uint8_t addr, uint8_t Value);
|
||||||
|
|
||||||
void mmc3_MapperDump(FILE *fp)
|
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: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n", mmc3_command, mmc3_irq_counter,
|
||||||
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]);
|
mmc3_irq_counter_reload, mmc3_irq_enable, mmc3_first_prom_page, mmc3_second_prom_page, mmc3_use_xor);
|
||||||
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: 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(0x8000, 0);
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
if ( Cart->VROMSize > 0)
|
if (Cart->VROMSize > 0)
|
||||||
{
|
{
|
||||||
set_vrom_bank_8k(0, 0x0000);
|
set_vrom_bank_8k(0, 0x0000);
|
||||||
}
|
}
|
||||||
|
|
||||||
mmc3_command = -1;
|
mmc3_command = -1;
|
||||||
|
|
||||||
mmc3_irq_counter = -1;
|
mmc3_irq_counter = -1;
|
||||||
mmc3_irq_enable = 0;
|
mmc3_irq_enable = 0;
|
||||||
mmc3_irq_counter_reload = 0;
|
mmc3_irq_counter_reload = 0;
|
||||||
|
|
||||||
mmc3_use_xor = 0x42;
|
mmc3_use_xor = 0x42;
|
||||||
|
|
||||||
mmc3_last_prom_switch = 0x42;
|
mmc3_last_prom_switch = 0x42;
|
||||||
|
|
||||||
mmc3_last_prom[0] = 0;
|
mmc3_last_prom[0] = 0;
|
||||||
mmc3_last_prom[1] = 1;
|
mmc3_last_prom[1] = 1;
|
||||||
|
|
||||||
mmc3_last_vrom[0] = 0;
|
mmc3_last_vrom[0] = 0;
|
||||||
mmc3_last_vrom[1] = 2;
|
mmc3_last_vrom[1] = 2;
|
||||||
mmc3_last_vrom[2] = 3;
|
mmc3_last_vrom[2] = 3;
|
||||||
mmc3_last_vrom[3] = 4;
|
mmc3_last_vrom[3] = 4;
|
||||||
mmc3_last_vrom[4] = 5;
|
mmc3_last_vrom[4] = 5;
|
||||||
mmc3_last_vrom[5] = 6;
|
mmc3_last_vrom[5] = 6;
|
||||||
|
|
||||||
mmc3_first_prom_page = 0x8000;
|
mmc3_first_prom_page = 0x8000;
|
||||||
mmc3_second_prom_page = 0xA000;
|
mmc3_second_prom_page = 0xA000;
|
||||||
|
|
||||||
/* Register mapper write hook */
|
/* Register mapper write hook */
|
||||||
set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
|
set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
|
||||||
set_page_writeable(0x80, true);
|
set_page_writeable(0x80, true);
|
||||||
|
|
||||||
set_page_wr_hook(0xA0, mmc3_MapperWriteA0Hook);
|
set_page_wr_hook(0xA0, mmc3_MapperWriteA0Hook);
|
||||||
set_page_writeable(0xA0, true);
|
set_page_writeable(0xA0, true);
|
||||||
|
|
||||||
set_page_wr_hook(0xC0, mmc3_MapperWriteC0Hook);
|
set_page_wr_hook(0xC0, mmc3_MapperWriteC0Hook);
|
||||||
set_page_writeable(0xC0, true);
|
set_page_writeable(0xC0, true);
|
||||||
|
|
||||||
set_page_wr_hook(0xE0, mmc3_MapperWriteE0Hook);
|
set_page_wr_hook(0xE0, mmc3_MapperWriteE0Hook);
|
||||||
set_page_writeable(0xE0, true);
|
set_page_writeable(0xE0, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||||
if (addr > 0x01)
|
if (addr > 0x01)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((Cart->VROMSize > 0) && ( mmc3_use_xor != (Value & 0x80) ))
|
if ((Cart->VROMSize > 0) && (mmc3_use_xor != (Value & 0x80)))
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
|
set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
|
||||||
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
|
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
|
||||||
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
|
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
|
||||||
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
|
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
|
||||||
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
|
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0] >> 1);
|
||||||
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
|
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1] >> 1);
|
||||||
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
|
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
|
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0] >> 1);
|
||||||
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
|
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1] >> 1);
|
||||||
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
|
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
|
||||||
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
|
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
|
||||||
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
|
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
|
||||||
set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
|
set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
|
||||||
//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
|
//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
|
||||||
}
|
}
|
||||||
mmc3_use_xor = (Value & 0x80);
|
mmc3_use_xor = (Value & 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mmc3_last_prom_switch != (Value & 0x40))
|
|
||||||
{
|
|
||||||
if (!(Value & 0x40))
|
|
||||||
{
|
|
||||||
console_printf(Console_Default, "MMC3: Switch -> 8/A\n");
|
|
||||||
mmc3_first_prom_page = 0x8000;
|
|
||||||
mmc3_second_prom_page = 0xA000;
|
|
||||||
|
|
||||||
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(0xE000, GETLAST08KBANK(cart));
|
|
||||||
//prg_bank(prg0,prg1,max_prg-1,max_prg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
console_printf(Console_Default, "MMC3: Switch -> C/A\n");
|
|
||||||
mmc3_first_prom_page = 0xC000;
|
|
||||||
mmc3_second_prom_page = 0xA000;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
//prg_bank(max_prg-1,prg1,prg0,max_prg);
|
|
||||||
}
|
|
||||||
mmc3_last_prom_switch = (Value & 0x40);
|
|
||||||
}
|
|
||||||
mmc3_command = Value & 0x07;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else { /* 8001 */
|
|
||||||
switch (mmc3_command)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
if (Cart->VROMSize == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mmc3_last_vrom[mmc3_command] = Value;
|
if (mmc3_last_prom_switch != (Value & 0x40))
|
||||||
|
{
|
||||||
if (mmc3_use_xor)
|
if (!(Value & 0x40))
|
||||||
{
|
{
|
||||||
set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
|
console_printf(Console_Default, "MMC3: Switch -> 8/A\n");
|
||||||
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
|
mmc3_first_prom_page = 0x8000;
|
||||||
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
|
mmc3_second_prom_page = 0xA000;
|
||||||
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
|
|
||||||
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
|
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
|
||||||
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
|
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
||||||
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
|
|
||||||
}
|
set_prom_bank_8k(0xC000, GETLAST08KBANK(Cart) - 1);
|
||||||
else
|
//set_prom_bank_8k(0xE000, GETLAST08KBANK(cart));
|
||||||
{
|
//prg_bank(prg0,prg1,max_prg-1,max_prg);
|
||||||
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
|
}
|
||||||
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
|
else
|
||||||
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
|
{
|
||||||
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
|
console_printf(Console_Default, "MMC3: Switch -> C/A\n");
|
||||||
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
|
mmc3_first_prom_page = 0xC000;
|
||||||
set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
|
mmc3_second_prom_page = 0xA000;
|
||||||
//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
|
|
||||||
}
|
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
|
||||||
|
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
||||||
break;
|
|
||||||
|
set_prom_bank_8k(0x8000, GETLAST08KBANK(Cart) - 1);
|
||||||
case 6:
|
|
||||||
mmc3_last_prom[0] = Value;
|
|
||||||
|
//prg_bank(max_prg-1,prg1,prg0,max_prg);
|
||||||
|
}
|
||||||
|
mmc3_last_prom_switch = (Value & 0x40);
|
||||||
|
}
|
||||||
|
mmc3_command = Value & 0x07;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* 8001 */
|
||||||
|
switch (mmc3_command)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
if (Cart->VROMSize == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mmc3_last_vrom[mmc3_command] = Value;
|
||||||
|
|
||||||
|
if (mmc3_use_xor)
|
||||||
|
{
|
||||||
|
set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
|
||||||
|
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);
|
||||||
|
//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_1k(0x1000, mmc3_last_vrom[2]);
|
||||||
|
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
|
||||||
|
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
|
||||||
|
set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
|
||||||
|
//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
mmc3_last_prom[0] = Value;
|
||||||
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
|
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
mmc3_last_prom[1] = Value;
|
mmc3_last_prom[1] = Value;
|
||||||
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(mmc3_use_xor)
|
/*if(mmc3_use_xor)
|
||||||
chr_bank(chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1);
|
chr_bank(chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1);
|
||||||
else
|
else
|
||||||
@ -220,45 +228,59 @@ void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t Value)
|
|||||||
{
|
{
|
||||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||||
if (addr > 0x01)
|
if (addr > 0x01)
|
||||||
|
{
|
||||||
return;
|
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);
|
|
||||||
|
|
||||||
}
|
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
|
else
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, "MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
|
//console_printf(Console_Default, "MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
|
||||||
if (Value)
|
if (Value)
|
||||||
map_sram();
|
{
|
||||||
else
|
map_sram();
|
||||||
unmap_sram();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unmap_sram();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value)
|
void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value)
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||||
if (addr > 0x01)
|
if (addr > 0x01)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
{
|
{
|
||||||
mmc3_irq_counter_reload = Value;
|
mmc3_irq_counter_reload = Value;
|
||||||
mmc3_irq_counter = Value;
|
mmc3_irq_counter = Value;
|
||||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
|
//console_printf(Console_Default, "MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
|
||||||
|
|
||||||
}else{ /* C001 */
|
}
|
||||||
//console_printf(Console_Default, "MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
|
else
|
||||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, Value);
|
{ /* C001 */
|
||||||
mmc3_irq_counter = Value;
|
//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,43 +288,53 @@ void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t Value)
|
|||||||
{
|
{
|
||||||
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
//console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
||||||
if (addr > 0x01)
|
if (addr > 0x01)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
||||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: IRQ disabled\n", ScanLine);
|
//console_printf(Console_Default, "MMC3 IRQ[%d]: IRQ disabled\n", ScanLine);
|
||||||
mmc3_irq_enable = 0;
|
mmc3_irq_enable = 0;
|
||||||
//MapperWantIRQ = 1;
|
//MapperWantIRQ = 1;
|
||||||
// Add a way to raise an IRQ
|
// Add a way to raise an IRQ
|
||||||
|
|
||||||
}else{ /* E001 */
|
}
|
||||||
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
else
|
||||||
//console_printf(Console_Default, "MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
|
{ /* E001 */
|
||||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
|
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
||||||
mmc3_irq_enable = 1;
|
//console_printf(Console_Default, "MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
|
||||||
|
//console_printf(Console_Default, "MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
|
||||||
|
mmc3_irq_enable = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mmc3_MapperIRQ(int cycledone)
|
int mmc3_MapperIRQ(int cycledone)
|
||||||
{
|
{
|
||||||
if (((cycledone > 0) && (cycledone < 241)) /*&&
|
if (((cycledone > 0) && (cycledone < 241)) /*&&
|
||||||
(ppu.ControlRegister2.b & (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)) == (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)*/)
|
(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;
|
/* Load next counter position */
|
||||||
|
mmc3_irq_counter = mmc3_irq_counter_reload;
|
||||||
mmc3_irq_enable = 0;
|
|
||||||
|
if (mmc3_irq_enable == 0)
|
||||||
//console_printf(Console_Default, "MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
|
{
|
||||||
|
return 0;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
return 0;
|
mmc3_irq_enable = 0;
|
||||||
|
|
||||||
|
//console_printf(Console_Default, "MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,15 @@
|
|||||||
* MMC3 Mapper - The peTI-NESulator Project
|
* MMC3 Mapper - The peTI-NESulator Project
|
||||||
* mmc3.h
|
* mmc3.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
void mmc3_MapperDump(FILE *fp);
|
void mmc3_MapperDump(FILE *fp);
|
||||||
int mmc3_InitMapper(NesCart * cart);
|
int mmc3_InitMapper(NesCart *cart);
|
||||||
int mmc3_MapperIRQ(int cycledone);
|
int mmc3_MapperIRQ(int cycledone);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* MMC4 Mapper - The peTI-NESulator Project
|
* MMC4 Mapper - The peTI-NESulator Project
|
||||||
* mmc4.h
|
* mmc4.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,7 @@ uint8_t mmc4_RegF;
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define LOG(s) printf s
|
#define LOG(s) printf s
|
||||||
#else
|
#else
|
||||||
#define LOG(s) { }
|
#define LOG(s) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* MAPPER WARNING: This mapper need to attach to the PPU memory... Need more work on this parts.. */
|
/* MAPPER WARNING: This mapper need to attach to the PPU memory... Need more work on this parts.. */
|
||||||
@ -28,57 +28,61 @@ void mmc4_MapperWriteRegA(register uint8_t Addr, register uint8_t Value)
|
|||||||
{
|
{
|
||||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||||
mmc4_RegA = Value;
|
mmc4_RegA = Value;
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, Value & 0x0F);
|
set_prom_bank_16k(0x8000, Value & 0x0F);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc4_MapperWriteRegB(register uint8_t Addr, register uint8_t Value)
|
void mmc4_MapperWriteRegB(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||||
mmc4_RegB = Value;
|
mmc4_RegB = Value;
|
||||||
|
|
||||||
set_vrom_bank_4k(0x0000, Value & 0x1F);
|
set_vrom_bank_4k(0x0000, Value & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc4_MapperWriteRegC(register uint8_t Addr, register uint8_t Value)
|
void mmc4_MapperWriteRegC(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||||
mmc4_RegC = Value;
|
mmc4_RegC = Value;
|
||||||
set_vrom_bank_4k(0x0000, Value & 0x1F);
|
set_vrom_bank_4k(0x0000, Value & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc4_MapperWriteRegD(register uint8_t Addr, register uint8_t Value)
|
void mmc4_MapperWriteRegD(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||||
mmc4_RegD = Value;
|
mmc4_RegD = Value;
|
||||||
set_vrom_bank_4k(0x1000, Value & 0x1F);
|
set_vrom_bank_4k(0x1000, Value & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc4_MapperWriteRegE(register uint8_t Addr, register uint8_t Value)
|
void mmc4_MapperWriteRegE(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||||
mmc4_RegE = Value;
|
mmc4_RegE = Value;
|
||||||
set_vrom_bank_4k(0x1000, Value & 0x1F);
|
set_vrom_bank_4k(0x1000, Value & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc4_MapperWriteRegF(register uint8_t Addr, register uint8_t Value)
|
void mmc4_MapperWriteRegF(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
|
||||||
mmc4_RegF = Value;
|
mmc4_RegF = Value;
|
||||||
if (Value & 0x01)
|
if (Value & 0x01)
|
||||||
|
{
|
||||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mmc4_MapperDump(FILE *fp)
|
void mmc4_MapperDump(FILE *fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mmc4_InitMapper(NesCart * cart)
|
int mmc4_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -86,50 +90,52 @@ int mmc4_InitMapper(NesCart * cart)
|
|||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
if (cart->VROMSize > 0)
|
if (cart->VROMSize > 0)
|
||||||
set_vrom_bank_8k(0x0000,0);
|
{
|
||||||
|
set_vrom_bank_8k(0x0000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Mapper should register itself for write hook */
|
/* 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_wr_hook(i, mmc4_MapperWriteRegA);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
|
||||||
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 = 0xB0 ; i < 0xC0 ; i++)
|
||||||
{
|
{
|
||||||
set_page_wr_hook(i, mmc4_MapperWriteRegC);
|
set_page_wr_hook(i, mmc4_MapperWriteRegB);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
|
||||||
for (i = 0xD0; i < 0xE0 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc4_MapperWriteRegD);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
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 = 0xC0 ; i < 0xD0 ; i++)
|
||||||
{
|
{
|
||||||
set_page_wr_hook(i, mmc4_MapperWriteRegF);
|
set_page_wr_hook(i, mmc4_MapperWriteRegC);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
}
|
||||||
|
for (i = 0xD0 ; i < 0xE0 ; i++)
|
||||||
for (i = 0x60; i < 0x80 ; i++)
|
|
||||||
{
|
{
|
||||||
set_page_writeable(i, true);
|
set_page_wr_hook(i, mmc4_MapperWriteRegD);
|
||||||
set_page_readable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
}
|
||||||
|
for (i = 0xE0 ; i < 0xF0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc4_MapperWriteRegE);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xF0 ; i < 0x100 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc4_MapperWriteRegF);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0x60 ; i < 0x80 ; i++)
|
||||||
|
{
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
set_page_readable(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
//ppu_setScreenMode(PPU_SCMODE_NORMAL);
|
//ppu_setScreenMode(PPU_SCMODE_NORMAL);
|
||||||
//ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
//ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,13 +2,14 @@
|
|||||||
* MMC4 Mapper - The peTI-NESulator Project
|
* MMC4 Mapper - The peTI-NESulator Project
|
||||||
* mmc4.h
|
* mmc4.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
void mmc4_MapperDump(FILE *fp);
|
void mmc4_MapperDump(FILE *fp);
|
||||||
int mmc4_InitMapper(NesCart * cart);
|
int mmc4_InitMapper(NesCart *cart);
|
||||||
@ -2,45 +2,46 @@
|
|||||||
* NOROM Mapper - The peTI-NESulator Project
|
* NOROM Mapper - The peTI-NESulator Project
|
||||||
* norom.c
|
* norom.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "norom.h"
|
#include "norom.h"
|
||||||
|
|
||||||
int norom_InitMapper(NesCart *cart)
|
int norom_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
set_page_ptr_16k(0x80, cart->PROMBanks);
|
set_page_ptr_16k(0x80, cart->PROMBanks);
|
||||||
|
|
||||||
/* mUBank = 0xC000 */
|
/* mUBank = 0xC000 */
|
||||||
if (cart->PROMSize > (16*1024))
|
if (cart->PROMSize > (16 * 1024))
|
||||||
{
|
{
|
||||||
set_prom_bank_16k(0xC000, 1);
|
set_prom_bank_16k(0xC000, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_prom_bank_16k(0xC000, 0);
|
set_prom_bank_16k(0xC000, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cart->VROMSize > 0)
|
if (cart->VROMSize > 0)
|
||||||
set_vrom_bank_8k(0x2000, 0);
|
{
|
||||||
|
set_vrom_bank_8k(0x2000, 0);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int norom_MapperIRQ(int cycledone)
|
int norom_MapperIRQ(int cycledone)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void norom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
void norom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void norom_MapperDump(FILE *fp)
|
void norom_MapperDump(FILE *fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "norom mapper have nothing to dump");
|
fprintf(fp, "norom mapper have nothing to dump");
|
||||||
}
|
}
|
||||||
@ -2,14 +2,15 @@
|
|||||||
* NOROM Mapper - The peTI-NESulator Project
|
* NOROM Mapper - The peTI-NESulator Project
|
||||||
* norom.c
|
* norom.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int norom_InitMapper (NesCart *cart);
|
int norom_InitMapper(NesCart *cart);
|
||||||
int norom_MapperIRQ (int cycledone);
|
int norom_MapperIRQ(int cycledone);
|
||||||
void norom_MapperDump (FILE *fp);
|
void norom_MapperDump(FILE *fp);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* UNROM Mapper - The peTI-NESulator Project
|
* UNROM Mapper - The peTI-NESulator Project
|
||||||
* unrom.h
|
* unrom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,36 +13,38 @@ uint8_t unrom_load_vbank;
|
|||||||
|
|
||||||
void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value);
|
void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value);
|
||||||
|
|
||||||
int unrom_InitMapper(NesCart * cart)
|
int unrom_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
set_prom_bank_16k(0xC000, 0);
|
set_prom_bank_16k(0xC000, 0);
|
||||||
set_prom_bank_16k(0x8000, GETLAST16KBANK(cart)); /* Set the last one */
|
set_prom_bank_16k(0x8000, GETLAST16KBANK(cart)); /* Set the last one */
|
||||||
|
|
||||||
if (Cart->VROMSize > 0)
|
if (Cart->VROMSize > 0)
|
||||||
set_vrom_bank_8k(0x0000,0);
|
{
|
||||||
|
set_vrom_bank_8k(0x0000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
unrom_load_vbank = 0;
|
unrom_load_vbank = 0;
|
||||||
|
|
||||||
/* Register the write hook */
|
/* 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_wr_hook(i, unrom_MapperWriteHook);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value)
|
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;
|
unrom_load_vbank = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unrom_MapperDump(FILE *fp)
|
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 Mapper - The peTI-NESulator Project
|
||||||
* unrom.h
|
* unrom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int unrom_InitMapper(NesCart * cart);
|
int unrom_InitMapper(NesCart *cart);
|
||||||
void unrom_MapperDump(FILE *fp);
|
void unrom_MapperDump(FILE *fp);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* UNROM Mapper - The peTI-NESulator Project
|
* UNROM Mapper - The peTI-NESulator Project
|
||||||
* unrom.h
|
* unrom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@ static uint8_t loaded_pbank;
|
|||||||
* 32K on such a cart
|
* 32K on such a cart
|
||||||
*/
|
*/
|
||||||
static uint8_t vram[32768];
|
static uint8_t vram[32768];
|
||||||
|
|
||||||
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
|
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
|
||||||
|
|
||||||
static void unrom512_applyValues()
|
static void unrom512_applyValues()
|
||||||
@ -39,13 +40,13 @@ static void unrom512_applyValues()
|
|||||||
static void unrom512_MapperWriteHook(uint8_t Addr, uint8_t Value)
|
static void unrom512_MapperWriteHook(uint8_t Addr, uint8_t Value)
|
||||||
{
|
{
|
||||||
mirroring_set = (Value >> 7) & 0x01;
|
mirroring_set = (Value >> 7) & 0x01;
|
||||||
loaded_vbank = (Value >> 5) & 0x03;
|
loaded_vbank = (Value >> 5) & 0x03;
|
||||||
loaded_pbank = (Value ) & 0x1F;
|
loaded_pbank = (Value) & 0x1F;
|
||||||
|
|
||||||
unrom512_applyValues();
|
unrom512_applyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
int unrom512_InitMapper(NesCart * cart)
|
int unrom512_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -54,18 +55,18 @@ int unrom512_InitMapper(NesCart * cart)
|
|||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
unrom512_applyValues();
|
unrom512_applyValues();
|
||||||
|
|
||||||
/* Register the write hook */
|
/* 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_wr_hook(i, unrom512_MapperWriteHook);
|
||||||
set_page_writeable(i, true);
|
set_page_writeable(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unrom512_MapperDump(FILE *fp)
|
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 Mapper - The peTI-NESulator Project
|
||||||
* unrom.h
|
* unrom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __TINES_MAPPERS__
|
#define __TINES_MAPPERS__
|
||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
int unrom512_InitMapper(NesCart * cart);
|
int unrom512_InitMapper(NesCart *cart);
|
||||||
void unrom512_MapperDump(FILE *fp);
|
void unrom512_MapperDump(FILE *fp);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* Mapper list - The peTI-NESulator Project
|
* Mapper list - The peTI-NESulator Project
|
||||||
* mappers_list.h
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
* Generic mapper implementation - The peTI-NESulator Project
|
* Generic mapper implementation - The peTI-NESulator Project
|
||||||
* genericmapper.h
|
* genericmapper.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* 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 */
|
if (Addr > 0x7FFF) /* Try to write to the rom */
|
||||||
{
|
{
|
||||||
set_vrom_bank_8k(0x0000,Value)
|
set_vrom_bank_8k(0x0000,Value);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,18 +2,14 @@
|
|||||||
* MMC1 Mapper - The peTI-NESulator Project
|
* MMC1 Mapper - The peTI-NESulator Project
|
||||||
* mmc1.h
|
* mmc1.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint8_t MMC1_reg0;
|
uint8_t MMC1_reg0;
|
||||||
|
|
||||||
uint8_t MMC1_reg1;
|
uint8_t MMC1_reg1;
|
||||||
|
|
||||||
uint8_t MMC1_reg2;
|
uint8_t MMC1_reg2;
|
||||||
|
|
||||||
uint8_t MMC1_reg3;
|
uint8_t MMC1_reg3;
|
||||||
|
|
||||||
uint8_t mmc1_CurrentBank;
|
uint8_t mmc1_CurrentBank;
|
||||||
|
|
||||||
#define MMC1_R0_MIRROR 0x01
|
#define MMC1_R0_MIRROR 0x01
|
||||||
@ -49,91 +45,86 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value);
|
|||||||
|
|
||||||
void mmc1_MapperDump(FILE *fp)
|
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;
|
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(0xC000, GETLAST16KBANK(cart));
|
|
||||||
|
|
||||||
mmc1_CurrentBank = 0;
|
|
||||||
|
|
||||||
if (cart->VROMSize > 0)
|
|
||||||
set_vrom_bank_4k(0x0000,0);
|
|
||||||
|
|
||||||
|
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||||
/* Mapper should register itself for write hook */
|
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||||
for (i = 0x80; i < 0xA0 ; i++)
|
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||||
|
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||||
|
|
||||||
|
set_prom_bank_16k(0x8000, 0);
|
||||||
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
|
mmc1_CurrentBank = 0;
|
||||||
|
|
||||||
|
if (cart->VROMSize > 0)
|
||||||
{
|
{
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg0);
|
set_vrom_bank_4k(0x0000, 0);
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
for (i = 0xA0; i < 0xC0 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg1);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
for (i = 0xC0; i < 0xE0 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg2);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
for (i = 0xE0; i < 0x100 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc1_MapperWriteReg3);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Mapper should register itself for write hook */
|
||||||
|
for (i = 0x80 ; i < 0xA0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg0);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xA0 ; i < 0xC0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg1);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xC0 ; i < 0xE0 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg2);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
for (i = 0xE0 ; i < 0x100 ; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, mmc1_MapperWriteReg3);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reg 0
|
* Reg 0
|
||||||
8 : 1000
|
* 8 : 1000
|
||||||
9 : 1001
|
* 9 : 1001
|
||||||
|
*
|
||||||
Reg 1
|
* Reg 1
|
||||||
A : 1010
|
* A : 1010
|
||||||
B : 1011
|
* B : 1011
|
||||||
|
*
|
||||||
Reg 2
|
* Reg 2
|
||||||
C : 1100
|
* C : 1100
|
||||||
D : 1101
|
* D : 1101
|
||||||
|
*
|
||||||
Reg 3
|
* Reg 3
|
||||||
E : 1110
|
* E : 1110
|
||||||
F : 1111
|
* F : 1111
|
||||||
|
*
|
||||||
((Addr & 0x6000) >> 13) <- port number
|
* ((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()
|
void mmc1_ApplyReg0Mod()
|
||||||
{
|
{
|
||||||
|
|
||||||
static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
|
static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
|
||||||
|
|
||||||
|
//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);
|
||||||
|
|
||||||
//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);
|
|
||||||
|
|
||||||
switch (MMC1_reg0 & 0x03)
|
switch (MMC1_reg0 & 0x03)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -153,27 +144,27 @@ void mmc1_ApplyReg0Mod()
|
|||||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(0xC000, GETLAST16KBANK(Cart));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ /* 0xC000 area */
|
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000,0);
|
|
||||||
set_prom_bank_16k(0xC000,mmc1_CurrentBank);
|
|
||||||
|
|
||||||
}
|
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(0xC000, GETLAST16KBANK(Cart));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* 0xC000 area */
|
||||||
|
set_prom_bank_16k(0x8000, 0);
|
||||||
|
set_prom_bank_16k(0xC000, mmc1_CurrentBank);
|
||||||
|
}
|
||||||
|
|
||||||
OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
|
OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VROMBankNb;
|
int VROMBankNb;
|
||||||
uint8_t Bit = 0;
|
uint8_t Bit = 0;
|
||||||
@ -181,69 +172,74 @@ uint8_t BitBuf = 0;
|
|||||||
|
|
||||||
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
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();
|
mmc1_ApplyReg0Mod();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Bit < 4)
|
if (Bit < 4)
|
||||||
{ /* Pas encore ecrit les 5 bits */
|
{
|
||||||
|
/* Haven't written the 5 bits yet */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg0 = BitBuf;
|
MMC1_reg0 = BitBuf;
|
||||||
|
|
||||||
mmc1_ApplyReg0Mod();
|
mmc1_ApplyReg0Mod();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||||
console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg1 Reset occurred !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Bit < 4)
|
if (Bit < 4)
|
||||||
{ /* Pas encore ecrit les 5 bits */
|
{
|
||||||
|
/* Haven't written the 5 bits yet */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg1 = BitBuf;
|
MMC1_reg1 = BitBuf;
|
||||||
|
|
||||||
VROMBankNb = (MMC1_reg1 /* & MMC1_R1_VROMB1 */ );
|
VROMBankNb = (MMC1_reg1 /* & MMC1_R1_VROMB1 */ );
|
||||||
|
|
||||||
if (Cart->VROMSize == 0)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||||
{ /* 4K vram */
|
{
|
||||||
|
/* 4K vram */
|
||||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 4k bank %d\n", VROMBankNb);
|
//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
|
else
|
||||||
{ /* 8K vram */
|
{
|
||||||
|
/* 8K vram */
|
||||||
//console_printf(Console_Default, "Switching VROM at 0x0000 to 8k bank %d\n", VROMBankNb>>1);
|
//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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,43 +247,46 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
|
|||||||
|
|
||||||
void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||||
console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg2 Reset occurred !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Bit < 4)
|
if (Bit < 4)
|
||||||
{ /* Pas encore ecrit les 5 bits */
|
{
|
||||||
|
/* Haven't written the 5 bits yet */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg2 = BitBuf;
|
MMC1_reg2 = BitBuf;
|
||||||
|
|
||||||
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
||||||
|
|
||||||
//console_printf(Console_Default, "Want to switch VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
//console_printf(Console_Default, "Want to switch VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
||||||
if (Cart->VROMSize == 0)
|
if (Cart->VROMSize == 0)
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, ": No\n");
|
//console_printf(Console_Default, ": No\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
|
if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
|
||||||
{ /* 4K vram */
|
{
|
||||||
|
/* 4K vram */
|
||||||
//console_printf(Console_Default, "Switching VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
|
//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
|
else
|
||||||
{ /* 8K vram */
|
{
|
||||||
// console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
|
/* 8K vram */
|
||||||
// set_vrom_bank_8k(0x1000,VROMBankNb>>1);
|
// console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
|
||||||
|
// set_vrom_bank_8k(0x1000,VROMBankNb>>1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,47 +294,54 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
|
|||||||
|
|
||||||
void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||||
console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg3 Reset occurred !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Bit < 4)
|
if (Bit < 4)
|
||||||
{ /* Pas encore ecrit les 5 bits */
|
{
|
||||||
|
/* Haven't written the 5 bits yet */
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit++;
|
Bit++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
|
||||||
Bit = 0;
|
Bit = 0;
|
||||||
|
|
||||||
MMC1_reg3 = BitBuf;
|
MMC1_reg3 = BitBuf;
|
||||||
|
|
||||||
if (MMC1_reg3<<14 > Cart->PROMSize)
|
if (MMC1_reg3 << 14 > Cart->PROMSize)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if ( (MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 )
|
|
||||||
{ /* 16K Switch */
|
if ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0)
|
||||||
if ( (MMC1_reg0 & MMC1_R0_PRGAREA) != 0 )
|
{
|
||||||
{ /* 0x8000 switch */
|
/* 16K Switch */
|
||||||
set_prom_bank_16k(0x8000,MMC1_reg3);
|
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);
|
//console_printf(Console_Default, "LowBank is now %d ( 0x%p )\n", MMC1_reg3, mLBank);
|
||||||
}
|
}
|
||||||
else
|
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);
|
//console_printf(Console_Default, "HighBank is now %d ( 0x%p )\n", MMC1_reg3, mUBank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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();
|
unmap_sram();
|
||||||
}
|
}
|
||||||
@ -345,6 +351,6 @@ 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
|
* Mapper facilities - The peTI-NESulator Project
|
||||||
* mappers.c
|
* mappers.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -27,7 +27,7 @@ extern NesCart *Cart;
|
|||||||
extern char MapperWantIRQ;
|
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)
|
void set_vrom_bank_1k(uint16_t addr,int slot)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
* 6502 Memory manager - The peTI-NESulator Project
|
* 6502 Memory manager - The peTI-NESulator Project
|
||||||
* memory.c - Taken from the Quick6502 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
/* Private structures */
|
/* Private structures */
|
||||||
|
|
||||||
#define Kuint8_t * (1024)
|
#define KByte * (1024)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* What inside memory manager:
|
* What inside memory manager:
|
||||||
*
|
*
|
||||||
* Table of attributes
|
* Table of attributes
|
||||||
* Table of original page ptr
|
* Table of original page ptr
|
||||||
* Table of moded page ptr
|
* Table of modded page ptr
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ void set_page_ptr_1k(uint8_t page, uint8_t *ptr)
|
|||||||
{ /* 1k = 4 * 256 */
|
{ /* 1k = 4 * 256 */
|
||||||
LOG(console_printf(Console_Default, "Set page(1k) 0x%X to ptr %p\n", page, ptr));
|
LOG(console_printf(Console_Default, "Set page(1k) 0x%X to ptr %p\n", page, ptr));
|
||||||
memory_pages[page + 0] = ptr;
|
memory_pages[page + 0] = ptr;
|
||||||
memory_pages[page + 1] = ptr + 0x100;
|
memory_pages[page + 1] = ptr + 0x100;
|
||||||
memory_pages[page + 2] = ptr + (0x100 * 2);
|
memory_pages[page + 2] = ptr + (0x100 * 2);
|
||||||
memory_pages[page + 3] = ptr + (0x100 * 3);
|
memory_pages[page + 3] = ptr + (0x100 * 3);
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ void set_page_ptr_2k(uint8_t page, uint8_t *ptr)
|
|||||||
{
|
{
|
||||||
LOG(console_printf(Console_Default, "Set page(2k) 0x%X to ptr %p\n", page, ptr));
|
LOG(console_printf(Console_Default, "Set page(2k) 0x%X to ptr %p\n", page, ptr));
|
||||||
memory_pages[page + 0] = ptr;
|
memory_pages[page + 0] = ptr;
|
||||||
memory_pages[page + 1] = ptr + 0x100;
|
memory_pages[page + 1] = ptr + 0x100;
|
||||||
memory_pages[page + 2] = ptr + (0x100 * 2);
|
memory_pages[page + 2] = ptr + (0x100 * 2);
|
||||||
memory_pages[page + 3] = ptr + (0x100 * 3);
|
memory_pages[page + 3] = ptr + (0x100 * 3);
|
||||||
memory_pages[page + 4] = ptr + (0x100 * 4);
|
memory_pages[page + 4] = ptr + (0x100 * 4);
|
||||||
@ -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));
|
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, 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)
|
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));
|
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, 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)
|
void set_page_ptr_16k(uint8_t page, uint8_t *ptr)
|
||||||
{
|
{
|
||||||
set_page_ptr_8k(page, 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)
|
void set_page_ptr_32k(uint8_t page, uint8_t *ptr)
|
||||||
{
|
{
|
||||||
set_page_ptr_16k(page, 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)
|
uint8_t *get_page_ptr(uint8_t page)
|
||||||
@ -113,15 +113,19 @@ void set_page_rd_hook(uint8_t page, func_rdhook func)
|
|||||||
{
|
{
|
||||||
memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_RDHOOK);
|
memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_RDHOOK);
|
||||||
if (memory_pages[page] == (uint8_t *)0x01)
|
if (memory_pages[page] == (uint8_t *)0x01)
|
||||||
|
{
|
||||||
memory_pages[page] = NULL;
|
memory_pages[page] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memory_pages_attr[page] |= ATTR_PAGE_HAVE_RDHOOK;
|
memory_pages_attr[page] |= ATTR_PAGE_HAVE_RDHOOK;
|
||||||
if (memory_pages[page] == NULL)
|
if (memory_pages[page] == NULL)
|
||||||
|
{
|
||||||
memory_pages[page] = (uint8_t *)0x01;
|
memory_pages[page] = (uint8_t *)0x01;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rdh_table[page] = func;
|
rdh_table[page] = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,34 +134,46 @@ void set_page_wr_hook(uint8_t page, func_wrhook func)
|
|||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
{
|
{
|
||||||
memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_WRHOOK);
|
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;
|
memory_pages[page] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memory_pages_attr[page] |= ATTR_PAGE_HAVE_WRHOOK;
|
memory_pages_attr[page] |= ATTR_PAGE_HAVE_WRHOOK;
|
||||||
if (memory_pages[page] == NULL)
|
if (memory_pages[page] == NULL)
|
||||||
|
{
|
||||||
memory_pages[page] = (uint8_t *)0x01;
|
memory_pages[page] = (uint8_t *)0x01;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wrh_table[page] = func;
|
wrh_table[page] = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_page_readable(uint8_t page, uint8_t value)
|
void set_page_readable(uint8_t page, uint8_t value)
|
||||||
{
|
{
|
||||||
if (value == true)
|
if (value == true)
|
||||||
|
{
|
||||||
memory_pages_attr[page] |= ATTR_PAGE_READABLE;
|
memory_pages_attr[page] |= ATTR_PAGE_READABLE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
memory_pages_attr[page] &= (~ATTR_PAGE_READABLE);
|
{
|
||||||
|
memory_pages_attr[page] &= (~ATTR_PAGE_READABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_page_writeable(uint8_t page, uint8_t value)
|
void set_page_writeable(uint8_t page, uint8_t value)
|
||||||
{
|
{
|
||||||
if (value == true)
|
if (value == true)
|
||||||
|
{
|
||||||
memory_pages_attr[page] |= ATTR_PAGE_WRITEABLE;
|
memory_pages_attr[page] |= ATTR_PAGE_WRITEABLE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
memory_pages_attr[page] &= (~ATTR_PAGE_WRITEABLE);
|
{
|
||||||
|
memory_pages_attr[page] &= (~ATTR_PAGE_WRITEABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost)
|
void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost)
|
||||||
@ -179,37 +195,45 @@ uint8_t get_page_attributes(uint8_t page)
|
|||||||
func_rdhook get_page_rdhook(uint8_t page)
|
func_rdhook get_page_rdhook(uint8_t page)
|
||||||
{
|
{
|
||||||
if (memory_pages_attr[page] & ATTR_PAGE_HAVE_RDHOOK)
|
if (memory_pages_attr[page] & ATTR_PAGE_HAVE_RDHOOK)
|
||||||
|
{
|
||||||
return rdh_table[page];
|
return rdh_table[page];
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
func_wrhook get_page_wrhook(uint8_t page)
|
func_wrhook get_page_wrhook(uint8_t page)
|
||||||
{
|
{
|
||||||
if (memory_pages_attr[page] & ATTR_PAGE_HAVE_WRHOOK)
|
if (memory_pages_attr[page] & ATTR_PAGE_HAVE_WRHOOK)
|
||||||
|
{
|
||||||
return wrh_table[page];
|
return wrh_table[page];
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ReadMemory(uint8_t page, uint8_t addr)
|
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 *page_ptr;
|
||||||
uint8_t attributes;
|
uint8_t attributes;
|
||||||
LOG(console_printf(Console_Default, "Read @ 0x%X-%X\n", page, addr));
|
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" ? */
|
/* Est-ce que la page est mappé ? && Est-ce que la page est "readable" ? */
|
||||||
if ((page_ptr = memory_pages[page]) &&
|
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"));
|
LOG(console_printf(Console_Default, "Page is non null & readable\n"));
|
||||||
if ( attributes & ATTR_PAGE_HAVE_RDHOOK )
|
if (attributes & ATTR_PAGE_HAVE_RDHOOK)
|
||||||
return ( LastRetuint8_t = rdh_table[page](addr) );
|
{
|
||||||
|
return (LastRetByte = rdh_table[page](addr));
|
||||||
|
}
|
||||||
else
|
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);
|
//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)
|
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;
|
uint8_t attributes;
|
||||||
LOG(console_printf(Console_Default, "Write 0x%x @ 0x%X-%X\n", value, page, addr));
|
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" ? */
|
/* Est-ce que la page est mappé ? && Est-ce que la page est "writable" ? */
|
||||||
if ( (page_ptr = memory_pages[page]) &&
|
if ((page_ptr = memory_pages[page]) &&
|
||||||
( (attributes = memory_pages_attr[page]) & ATTR_PAGE_WRITEABLE) )
|
((attributes = memory_pages_attr[page]) & ATTR_PAGE_WRITEABLE))
|
||||||
{
|
{
|
||||||
if ( attributes & ATTR_PAGE_HAVE_WRHOOK )
|
if (attributes & ATTR_PAGE_HAVE_WRHOOK)
|
||||||
{
|
{
|
||||||
#ifdef DETECT_BUS_CONFLICT
|
#ifdef DETECT_BUS_CONFLICT
|
||||||
if ((page >= 0x80) && (memory_pages[page][addr] != value))
|
if ((page >= 0x80) && (memory_pages[page][addr] != value))
|
||||||
@ -230,40 +254,45 @@ void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
|
|||||||
wrh_table[page](addr, value);
|
wrh_table[page](addr, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
page_ptr[addr] = value;
|
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)
|
void DumpMemoryState(FILE *fp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0x00; i < 0x100; i++)
|
for (i = 0x00 ; i < 0x100 ; i++)
|
||||||
{
|
{
|
||||||
fprintf(fp,
|
fprintf(fp,
|
||||||
"Page 0x%02X : [%c%c%c%c%c%c] RdH:%p WrH:%p ptr:%p\n",
|
"Page 0x%02X : [%c%c%c%c%c%c] RdH:%p WrH:%p ptr:%p\n",
|
||||||
i,
|
i,
|
||||||
(memory_pages_attr[i]&ATTR_PAGE_HAVE_RDHOOK)?'r':'.',
|
(memory_pages_attr[i] & ATTR_PAGE_HAVE_RDHOOK) ? 'r' : '.',
|
||||||
(memory_pages_attr[i]&ATTR_PAGE_HAVE_WRHOOK)?'w':'.',
|
(memory_pages_attr[i] & ATTR_PAGE_HAVE_WRHOOK) ? 'w' : '.',
|
||||||
(memory_pages_attr[i]&ATTR_PAGE_READABLE)?'R':'.',
|
(memory_pages_attr[i] & ATTR_PAGE_READABLE) ? 'R' : '.',
|
||||||
(memory_pages_attr[i]&ATTR_PAGE_WRITEABLE)?'W':'.',
|
(memory_pages_attr[i] & ATTR_PAGE_WRITEABLE) ? 'W' : '.',
|
||||||
(memory_pages_attr[i]&ATTR_PAGE_GHOST)?'G':'.',
|
(memory_pages_attr[i] & ATTR_PAGE_GHOST) ? 'G' : '.',
|
||||||
(memory_pages_attr[i]&ATTR_PAGE_MAPPED)?'M':'.',
|
(memory_pages_attr[i] & ATTR_PAGE_MAPPED) ? 'M' : '.',
|
||||||
rdh_table[i],
|
rdh_table[i],
|
||||||
wrh_table[i],
|
wrh_table[i],
|
||||||
memory_pages[i]
|
memory_pages[i]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitMemory()
|
void InitMemory()
|
||||||
{
|
{
|
||||||
int page;
|
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;
|
memory_pages_attr[page] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
# $Author$
|
# $Author$
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
* Graphic Manager - The peTI-NESulator Project
|
* Graphic Manager - The peTI-NESulator Project
|
||||||
* os/macos/graphics.c
|
* os/macos/graphics.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER on 08/05/08.
|
* Created by Manoël TRAPIER on 08/05/08.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <os_dependent.h>
|
#include <os_dependent.h>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* File functions - The peTI-NESulator Project
|
* File functions - The peTI-NESulator Project
|
||||||
* os/macos/load.c
|
* 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
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
# $Author$
|
# $Author$
|
||||||
|
|||||||
@ -2,13 +2,8 @@
|
|||||||
* TI-68k Loading external file functions - The peTI-NESulator Project
|
* TI-68k Loading external file functions - The peTI-NESulator Project
|
||||||
* ti68k/loadfile.c
|
* ti68k/loadfile.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
|
||||||
* $LastChangedDate:$
|
|
||||||
* $Author:$
|
|
||||||
* $HeadURL:$
|
|
||||||
* $Revision:$
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,7 +19,7 @@ void *LoadFilePtr(char * filename)
|
|||||||
if ((fp = fopen(filename,"rb")) == NULL)
|
if ((fp = fopen(filename,"rb")) == NULL)
|
||||||
return -1;
|
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);
|
HeapLock(fp->handle);
|
||||||
RetPtr = 2 + HeapDeref(fp->handle);
|
RetPtr = 2 + HeapDeref(fp->handle);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Graphic Manager - The peTI-NESulator Project
|
* Graphic Manager - The peTI-NESulator Project
|
||||||
* os/macos/graphics.c
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -14,6 +14,7 @@
|
|||||||
#include <os_dependent.h>
|
#include <os_dependent.h>
|
||||||
|
|
||||||
#define GLFW_INCLUDE_GLEXT
|
#define GLFW_INCLUDE_GLEXT
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
/* "Apple" fix */
|
/* "Apple" fix */
|
||||||
@ -27,414 +28,426 @@ typedef struct GLWindow_t GLWindow;
|
|||||||
|
|
||||||
struct KeyArray
|
struct KeyArray
|
||||||
{
|
{
|
||||||
uint8_t lastState;
|
uint8_t lastState;
|
||||||
uint8_t curState;
|
uint8_t curState;
|
||||||
uint8_t debounced;
|
uint8_t debounced;
|
||||||
GLFWwindow* window;
|
GLFWwindow *window;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GLWindow_t
|
struct GLWindow_t
|
||||||
{
|
{
|
||||||
struct KeyArray keyArray[512];
|
struct KeyArray keyArray[512];
|
||||||
GLFWwindow* windows;
|
GLFWwindow *windows;
|
||||||
uint8_t *videoMemory;
|
uint8_t *videoMemory;
|
||||||
GLint videoTexture;
|
GLuint videoTexture;
|
||||||
int WIDTH;
|
int WIDTH;
|
||||||
int HEIGHT;
|
int HEIGHT;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int window_num = 0;
|
static int window_num = 0;
|
||||||
|
|
||||||
void GLWindowInitEx(GLWindow *g, int w, int h)
|
void GLWindowInitEx(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
g->WIDTH = w;
|
g->WIDTH = w;
|
||||||
g->HEIGHT = h;
|
g->HEIGHT = h;
|
||||||
g->videoTexture = window_num++;
|
g->videoTexture = window_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLWindowInit(GLWindow *g)
|
void GLWindowInit(GLWindow *g)
|
||||||
{
|
{
|
||||||
GLWindowInitEx(g, 100, 100);
|
GLWindowInitEx(g, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowScreen(GLWindow *g, int w, int h)
|
void ShowScreen(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
||||||
|
|
||||||
// glTexSubImage2D is faster when not using a texture range
|
// glTexSubImage2D is faster when not using a texture range
|
||||||
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glTexCoord2f(0.0f, 0.0f);
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
glVertex2f(-1.0f,1.0f);
|
glVertex2f(-1.0f, 1.0f);
|
||||||
|
|
||||||
glTexCoord2f(0.0f, h);
|
glTexCoord2f(0.0f, h);
|
||||||
glVertex2f(-1.0f, -1.0f);
|
glVertex2f(-1.0f, -1.0f);
|
||||||
|
|
||||||
glTexCoord2f(w, h);
|
glTexCoord2f(w, h);
|
||||||
glVertex2f(1.0f, -1.0f);
|
glVertex2f(1.0f, -1.0f);
|
||||||
|
|
||||||
glTexCoord2f(w, 0.0f);
|
glTexCoord2f(w, 0.0f);
|
||||||
glVertex2f(1.0f, 1.0f);
|
glVertex2f(1.0f, 1.0f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupGL(GLWindow *g, int w, int h)
|
void setupGL(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
g->videoMemory = (uint8_t*)malloc(w*h*sizeof(uint32_t));
|
g->videoMemory = (uint8_t *)malloc(w * h * sizeof(uint32_t));
|
||||||
memset(g->videoMemory, 0,w*h*sizeof(uint32_t));
|
memset(g->videoMemory, 0, w * h * sizeof(uint32_t));
|
||||||
//Tell OpenGL how to convert from coordinates to pixel values
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_TEXTURE_RECTANGLE);
|
glEnable(GL_TEXTURE_RECTANGLE);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
||||||
|
|
||||||
// glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
|
// glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
|
||||||
|
|
||||||
// glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
// glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
||||||
// glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
|
// glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w,
|
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w,
|
||||||
h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreGL(GLWindow *g, int w, int h)
|
void restoreGL(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
//Tell OpenGL how to convert from coordinates to pixel values
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_TEXTURE_RECTANGLE);
|
glEnable(GL_TEXTURE_RECTANGLE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
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;
|
struct KeyArray *keyArray;
|
||||||
|
|
||||||
keyArray = (struct KeyArray*) glfwGetWindowUserPointer(window);
|
keyArray = (struct KeyArray *)glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
keyArray[key].lastState=keyArray[key].curState;
|
keyArray[key].lastState = keyArray[key].curState;
|
||||||
if (action==GLFW_RELEASE)
|
if (action == GLFW_RELEASE)
|
||||||
{
|
{
|
||||||
keyArray[key].curState=GLFW_RELEASE;
|
keyArray[key].curState = GLFW_RELEASE;
|
||||||
}
|
}
|
||||||
else
|
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;
|
keyArray[key].window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
void sizeHandler(GLFWwindow *window, int xs, int ys)
|
||||||
{
|
{
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glViewport(0, 0, xs, ys);
|
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);
|
puts(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initDisplay(GLWindow *g)
|
void initDisplay(GLWindow *g)
|
||||||
{
|
{
|
||||||
int h = g->HEIGHT;
|
int h = g->HEIGHT;
|
||||||
int w = g->WIDTH;
|
int w = g->WIDTH;
|
||||||
|
|
||||||
/// Initialize GLFW
|
/// Initialize GLFW
|
||||||
glfwInit();
|
glfwInit();
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
// Open screen OpenGL window
|
// 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();
|
glfwTerminate();
|
||||||
fprintf(stderr, "Window creation error...\n");
|
fprintf(stderr, "Window creation error...\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowAspectRatio(g->windows, 4, 3);
|
glfwSetWindowAspectRatio(g->windows, 4, 3);
|
||||||
|
|
||||||
glfwMakeContextCurrent(g->windows);
|
glfwMakeContextCurrent(g->windows);
|
||||||
setupGL(g, g->WIDTH, g->HEIGHT);
|
setupGL(g, g->WIDTH, g->HEIGHT);
|
||||||
|
|
||||||
glfwSwapInterval(0); // Disable VSYNC
|
glfwSwapInterval(0); // Disable VSYNC
|
||||||
|
|
||||||
glfwGetWindowSize(g->windows, &w, &h);
|
glfwGetWindowSize(g->windows, &w, &h);
|
||||||
|
|
||||||
glfwSetWindowUserPointer(g->windows, g->keyArray);
|
glfwSetWindowUserPointer(g->windows, g->keyArray);
|
||||||
|
|
||||||
glfwSetKeyCallback(g->windows, kbHandler);
|
glfwSetKeyCallback(g->windows, kbHandler);
|
||||||
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
|
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))
|
if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
|
||||||
return;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
b = colour & 0xFF;
|
b = colour & 0xFF;
|
||||||
g = (colour >> 8) & 0xFF;
|
g = (colour >> 8) & 0xFF;
|
||||||
r = (colour >> 16) & 0xFF;
|
r = (colour >> 16) & 0xFF;
|
||||||
a = (colour >> 24) & 0xFF;
|
a = (colour >> 24) & 0xFF;
|
||||||
|
|
||||||
gw->videoMemory[offset + 0] = a;
|
gw->videoMemory[offset + 0] = a;
|
||||||
gw->videoMemory[offset + 1] = r;
|
gw->videoMemory[offset + 1] = r;
|
||||||
gw->videoMemory[offset + 2] = g;
|
gw->videoMemory[offset + 2] = g;
|
||||||
gw->videoMemory[offset + 3] = b;
|
gw->videoMemory[offset + 3] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||||
{
|
{
|
||||||
int d, dx, dy, aincr, bincr, xincr, yincr, x, y;
|
int d, dx, dy, aincr, bincr, xincr, yincr, x, y;
|
||||||
if (abs(x1 - x0) < abs(y1 - y0))
|
if (abs(x1 - x0) < abs(y1 - y0))
|
||||||
{
|
{
|
||||||
/* parcours par l'axe vertical */
|
/* parcours par l'axe vertical */
|
||||||
if (y0 > y1)
|
if (y0 > y1)
|
||||||
{
|
{
|
||||||
drawLine(g, x1, y1, x0, y0, colour);
|
drawLine(g, x1, y1, x0, y0, colour);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
xincr = x1 > x0 ? 1 : -1;
|
xincr = x1 > x0 ? 1 : -1;
|
||||||
dy = y1 - y0;
|
dy = y1 - y0;
|
||||||
dx = abs(x1 - x0);
|
dx = abs(x1 - x0);
|
||||||
d = 2 * dx - dy;
|
d = 2 * dx - dy;
|
||||||
aincr = 2 * (dx - dy);
|
aincr = 2 * (dx - dy);
|
||||||
bincr = 2 * dx;
|
bincr = 2 * dx;
|
||||||
x = x0;
|
x = x0;
|
||||||
y = y0;
|
y = y0;
|
||||||
|
|
||||||
drawPixel(g, x, y, colour);
|
drawPixel(g, x, y, colour);
|
||||||
|
|
||||||
for (y = y0+1; y <= y1; y++)
|
for (y = y0 + 1 ; y <= y1 ; y++)
|
||||||
{
|
{
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
{
|
{
|
||||||
x += xincr;
|
x += xincr;
|
||||||
d += aincr;
|
d += aincr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d += bincr;
|
d += bincr;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawPixel(g, x, y, colour);
|
drawPixel(g, x, y, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* parcours par l'axe horizontal */
|
/* parcours par l'axe horizontal */
|
||||||
if (x0 > x1)
|
if (x0 > x1)
|
||||||
{
|
{
|
||||||
drawLine(g, x1, y1, x0, y0, colour);
|
drawLine(g, x1, y1, x0, y0, colour);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
yincr = y1 > y0 ? 1 : -1;
|
yincr = y1 > y0 ? 1 : -1;
|
||||||
dx = x1 - x0;
|
dx = x1 - x0;
|
||||||
dy = abs(y1 - y0);
|
dy = abs(y1 - y0);
|
||||||
d = 2 * dy - dx;
|
d = 2 * dy - dx;
|
||||||
aincr = 2 * (dy - dx);
|
aincr = 2 * (dy - dx);
|
||||||
bincr = 2 * dy;
|
bincr = 2 * dy;
|
||||||
x = x0;
|
x = x0;
|
||||||
y = y0;
|
y = y0;
|
||||||
|
|
||||||
drawPixel(g, x, y, colour);
|
drawPixel(g, x, y, colour);
|
||||||
|
|
||||||
for (x = x0+1; x <= x1; ++x)
|
for (x = x0 + 1 ; x <= x1 ; ++x)
|
||||||
{
|
{
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
{
|
{
|
||||||
y += yincr;
|
y += yincr;
|
||||||
d += aincr;
|
d += aincr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d += bincr;
|
d += bincr;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawPixel(g, x, y, colour);
|
drawPixel(g, x, y, colour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||||
{
|
{
|
||||||
int f = 1 - radius;
|
int f = 1 - radius;
|
||||||
int ddF_x = 0;
|
int ddF_x = 0;
|
||||||
int ddF_y = -2 * radius;
|
int ddF_y = -2 * radius;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = radius;
|
int y = radius;
|
||||||
int pX, pY;
|
int pX, pY;
|
||||||
|
|
||||||
pX = xc; pY = yc + radius;
|
pX = xc;
|
||||||
drawPixel(g, pX, pY, colour);
|
pY = yc + radius;
|
||||||
pY -= (2*radius);
|
drawPixel(g, pX, pY, colour);
|
||||||
drawPixel(g, pX, pY, colour);
|
pY -= (2 * radius);
|
||||||
pY += radius; pX += radius;
|
drawPixel(g, pX, pY, colour);
|
||||||
drawPixel(g, pX, pY, colour);
|
pY += radius;
|
||||||
pX -= (2*radius);
|
pX += radius;
|
||||||
drawPixel(g, pX, pY, colour);
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX -= (2 * radius);
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
|
||||||
while(x < y)
|
while (x < y)
|
||||||
{
|
{
|
||||||
if(f >= 0)
|
if (f >= 0)
|
||||||
{
|
{
|
||||||
y--;
|
y--;
|
||||||
ddF_y += 2;
|
ddF_y += 2;
|
||||||
f += ddF_y;
|
f += ddF_y;
|
||||||
}
|
}
|
||||||
x++;
|
x++;
|
||||||
ddF_x += 2;
|
ddF_x += 2;
|
||||||
f += ddF_x + 1;
|
f += ddF_x + 1;
|
||||||
pX = xc+x ; pY = yc+y;
|
pX = xc + x;
|
||||||
drawPixel(g, pX, pY, colour);
|
pY = yc + y;
|
||||||
pX = xc-x ; pY = yc+y;
|
drawPixel(g, pX, pY, colour);
|
||||||
drawPixel(g, pX, pY, colour);
|
pX = xc - x;
|
||||||
pX = xc+x ; pY = yc-y;
|
pY = yc + y;
|
||||||
drawPixel(g, pX, pY, colour);
|
drawPixel(g, pX, pY, colour);
|
||||||
pX = xc-x ; pY = yc-y;
|
pX = xc + x;
|
||||||
drawPixel(g, pX, pY, colour);
|
pY = yc - y;
|
||||||
pX = xc+y ; pY = yc+x;
|
drawPixel(g, pX, pY, colour);
|
||||||
drawPixel(g, pX, pY, colour);
|
pX = xc - x;
|
||||||
pX = xc-y ; pY = yc+x;
|
pY = yc - y;
|
||||||
drawPixel(g, pX, pY, colour);
|
drawPixel(g, pX, pY, colour);
|
||||||
pX = xc+y ; pY = yc-x;
|
pX = xc + y;
|
||||||
drawPixel(g, pX, pY, colour);
|
pY = yc + x;
|
||||||
pX = xc-y ; pY = yc-x;
|
drawPixel(g, pX, pY, colour);
|
||||||
drawPixel(g, pX, pY, colour);
|
pX = xc - y;
|
||||||
}
|
pY = yc + x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
return;
|
pX = xc + y;
|
||||||
|
pY = yc - x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc - y;
|
||||||
|
pY = yc - x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
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, y0, x0 + w, y0, colour);
|
||||||
drawLine(g, x0 + w, y0 , x0 + w, y0 + h, colour);
|
drawLine(g, x0 + w, y0, x0 + w, y0 + h, colour);
|
||||||
drawLine(g, x0 + w, y0 + h, x0 , 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 + h, x0, y0, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < h; i++)
|
for (i = 0 ; i < h ; i++)
|
||||||
drawLine(g, x0, y0+i, x0+w, y0+i, colour);
|
{
|
||||||
|
drawLine(g, x0, y0 + i, x0 + w, y0 + i, colour);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearScreen(GLWindow *g)
|
void clearScreen(GLWindow *g)
|
||||||
{
|
{
|
||||||
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateScreen(GLWindow *g)
|
void updateScreen(GLWindow *g)
|
||||||
{
|
{
|
||||||
/*Update windows code */
|
/*Update windows code */
|
||||||
glfwMakeContextCurrent(g->windows);
|
glfwMakeContextCurrent(g->windows);
|
||||||
ShowScreen(g, g->WIDTH, g->HEIGHT);
|
ShowScreen(g, g->WIDTH, g->HEIGHT);
|
||||||
glfwSwapBuffers(g->windows);
|
glfwSwapBuffers(g->windows);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateScreenAndWait(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);
|
updateScreen(g);
|
||||||
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
while(glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
while (glfwGetKey(g->windows, GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
||||||
{
|
{
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLWindow mainWindow;
|
GLWindow mainWindow;
|
||||||
|
|
||||||
int graphics_init()
|
int graphics_init()
|
||||||
{
|
{
|
||||||
GLWindowInitEx(&mainWindow, 256, 240);
|
GLWindowInitEx(&mainWindow, 256, 240);
|
||||||
initDisplay(&mainWindow);
|
initDisplay(&mainWindow);
|
||||||
clearScreen(&mainWindow);
|
clearScreen(&mainWindow);
|
||||||
updateScreen(&mainWindow);
|
updateScreen(&mainWindow);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t getColour(long color)
|
static uint32_t getColour(long color)
|
||||||
{
|
{
|
||||||
Palette *pal = &basicPalette[color];
|
Palette *pal = &basicPalette[color];
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
r = pal->r;
|
r = pal->r;
|
||||||
b = pal->b;
|
b = pal->b;
|
||||||
g = pal->g;
|
g = pal->g;
|
||||||
a = 255;//pal->a;
|
a = 255;//pal->a;
|
||||||
return (b << 24) | (g << 16) | (r << 8) | a;
|
return (b << 24) | (g << 16) | (r << 8) | a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int graphics_drawpixel(long x, long y, long color)
|
int graphics_drawpixel(long x, long y, long color)
|
||||||
{
|
{
|
||||||
drawPixel(&mainWindow, x, y, getColour(color));
|
drawPixel(&mainWindow, x, y, getColour(color));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||||
{
|
{
|
||||||
drawLine(&mainWindow, x, y, x1, y1, getColour(color));
|
drawLine(&mainWindow, x, y, x1, y1, getColour(color));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int graphics_blit(long x, long y, long w, long h)
|
int graphics_blit(long x, long y, long w, long h)
|
||||||
{
|
{
|
||||||
updateScreen(&mainWindow);
|
updateScreen(&mainWindow);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getKeyStatus(int key)
|
int getKeyStatus(int key)
|
||||||
{
|
{
|
||||||
return mainWindow.keyArray[key].curState;
|
return mainWindow.keyArray[key].curState;
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* Graphic Manager - The peTI-NESulator Project
|
* Graphic Manager - The peTI-NESulator Project
|
||||||
* os/macos/graphics.c
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -22,19 +22,19 @@ typedef struct GLWindow_t GLWindow;
|
|||||||
|
|
||||||
struct KeyArray
|
struct KeyArray
|
||||||
{
|
{
|
||||||
uint8_t lastState;
|
uint8_t lastState;
|
||||||
uint8_t curState;
|
uint8_t curState;
|
||||||
uint8_t debounced;
|
uint8_t debounced;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GLWindow_t
|
struct GLWindow_t
|
||||||
{
|
{
|
||||||
struct KeyArray keyArray[512];
|
struct KeyArray keyArray[512];
|
||||||
GLFWwindow* windows;
|
GLFWwindow *windows;
|
||||||
uint8_t *videoMemory;
|
uint8_t *videoMemory;
|
||||||
GLint videoTexture;
|
GLint videoTexture;
|
||||||
int WIDTH;
|
int WIDTH;
|
||||||
int HEIGHT;
|
int HEIGHT;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef GL_TEXTURE_RECTANGLE_EXT
|
#ifndef GL_TEXTURE_RECTANGLE_EXT
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,25 +108,25 @@ void updateScreenAndWait(GLWindow *g)
|
|||||||
|
|
||||||
int graphics_init()
|
int graphics_init()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int graphics_drawpixel(long x, long y, long color)
|
int graphics_drawpixel(long x, long y, long color)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int graphics_blit(long x, long y, long w, long h)
|
int graphics_blit(long x, long y, long w, long h)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getKeyStatus(int key)
|
int getKeyStatus(int key)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,46 +12,48 @@
|
|||||||
|
|
||||||
#include <os_dependent.h>
|
#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;
|
ConsoleLevel console_ActualLevel = Console_Default;
|
||||||
|
|
||||||
/* Actually nothing to do */
|
/* Actually nothing to do */
|
||||||
int console_init(ConsoleLevel DefaultLevel)
|
int console_init(ConsoleLevel DefaultLevel)
|
||||||
{
|
{
|
||||||
console_ActualLevel = DefaultLevel;
|
console_ActualLevel = DefaultLevel;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actually a simple printf with levels */
|
/* Actually a simple printf with levels */
|
||||||
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
if (console_ActualLevel >= level)
|
if (console_ActualLevel >= level)
|
||||||
vprintf(format, ap);
|
{
|
||||||
|
vprintf(format, ap);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int console_printf(const ConsoleLevel level, const char *format, ...)
|
int console_printf(const ConsoleLevel level, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
|
||||||
console_vprintf(level, format, ap);
|
console_vprintf(level, format, ap);
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int console_printf_d(const char *format, ...)
|
int console_printf_d(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
|
||||||
console_vprintf (Console_Debug, format, ap);
|
|
||||||
|
|
||||||
va_end(ap);
|
console_vprintf(Console_Debug, format, ap);
|
||||||
|
|
||||||
return 0;
|
va_end(ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,24 +16,24 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Map a file in memory */
|
/* Map a file in memory */
|
||||||
void *LoadFilePtr(char * filename)
|
void *LoadFilePtr(char *filename)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
void *RetPtr;
|
void *RetPtr;
|
||||||
struct stat FileStat;
|
struct stat FileStat;
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
fd = open(filename, O_RDONLY);
|
||||||
|
|
||||||
fstat(fd, &FileStat);
|
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 )
|
close(fd);
|
||||||
{
|
|
||||||
RetPtr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RetPtr;
|
if (RetPtr == MAP_FAILED)
|
||||||
|
{
|
||||||
|
RetPtr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RetPtr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Graphic Manager - The peTI-NESulator Project
|
* Graphic Manager - The peTI-NESulator Project
|
||||||
* os/macos/graphics.c
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
119
src/paddle.c
119
src/paddle.c
@ -2,7 +2,7 @@
|
|||||||
* Paddle manager - The peTI-NESulator Project
|
* Paddle manager - The peTI-NESulator Project
|
||||||
* paddle.c
|
* paddle.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoël TRAPIER.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,77 +13,92 @@
|
|||||||
|
|
||||||
void InitPaddle(Paddle *pdl)
|
void InitPaddle(Paddle *pdl)
|
||||||
{
|
{
|
||||||
pdl->Bit = 1;
|
pdl->Bit = 1;
|
||||||
pdl->LastWrite = 0;
|
pdl->LastWrite = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WritePaddle(Paddle *pdl, uint8_t val)
|
void WritePaddle(Paddle *pdl, uint8_t val)
|
||||||
{
|
{
|
||||||
if ( ( pdl->LastWrite == 1 ) && ( val == 0 ) )
|
if ((pdl->LastWrite == 1) && (val == 0))
|
||||||
InitPaddle(pdl);
|
{
|
||||||
|
InitPaddle(pdl);
|
||||||
|
}
|
||||||
|
|
||||||
pdl->LastWrite = val;
|
pdl->LastWrite = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ReadPaddle(Paddle *pdl)
|
uint8_t ReadPaddle(Paddle *pdl)
|
||||||
{
|
{
|
||||||
switch(pdl->Bit++)
|
switch (pdl->Bit++)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if ( getKeyStatus('O') )
|
if (getKeyStatus('O'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if ( getKeyStatus('P') )
|
if (getKeyStatus('P'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if ( getKeyStatus('I') )
|
if (getKeyStatus('I'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if ( getKeyStatus('U') )
|
if (getKeyStatus('U'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
if ( getKeyStatus('W') )
|
if (getKeyStatus('W'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
if ( getKeyStatus('S') )
|
if (getKeyStatus('S'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
if ( getKeyStatus('A') )
|
if (getKeyStatus('A'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
if ( getKeyStatus('D') )
|
if (getKeyStatus('D'))
|
||||||
return 0x41;
|
{
|
||||||
break;
|
return 0x41;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 20:
|
case 20:
|
||||||
return 0x40;
|
return 0x40;
|
||||||
break;
|
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
pdl->Bit = 1;
|
pdl->Bit = 1;
|
||||||
return 0x40;
|
return 0x40;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0x40;
|
return 0x40;
|
||||||
break;
|
}
|
||||||
|
|
||||||
}
|
return 0x40;
|
||||||
|
|
||||||
return 0x40;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Plugins manager - The peTI-NESulator Project
|
* Plugins manager - The peTI-NESulator Project
|
||||||
* plugins.c
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -15,9 +15,9 @@
|
|||||||
#include <plugins/manager.h>
|
#include <plugins/manager.h>
|
||||||
|
|
||||||
typedef struct Plugin_
|
typedef struct Plugin_
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
PluginInit init;
|
PluginInit init;
|
||||||
PluginDeinit deinit;
|
PluginDeinit deinit;
|
||||||
|
|
||||||
@ -26,11 +26,11 @@ typedef struct Plugin_
|
|||||||
typedef struct KeyHandler_
|
typedef struct KeyHandler_
|
||||||
{
|
{
|
||||||
uint8_t key;
|
uint8_t key;
|
||||||
|
|
||||||
PluginKeypress func;
|
PluginKeypress func;
|
||||||
|
|
||||||
struct KeyHandler_ *next;
|
struct KeyHandler_ *next;
|
||||||
|
|
||||||
} KeyHandler;
|
} KeyHandler;
|
||||||
|
|
||||||
KeyHandler *keyHandlersList = NULL;
|
KeyHandler *keyHandlersList = NULL;
|
||||||
@ -42,10 +42,11 @@ void plugin_list()
|
|||||||
Plugin *ptr = &(Plugins[0]);
|
Plugin *ptr = &(Plugins[0]);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
console_printf(Console_Default, "Available plugins:\n");
|
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);
|
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
|
||||||
ptr++; i++;
|
ptr++;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,17 +54,19 @@ int plugin_load(int id)
|
|||||||
{
|
{
|
||||||
Plugin *ptr = &(Plugins[0]);
|
Plugin *ptr = &(Plugins[0]);
|
||||||
int i = id;
|
int i = id;
|
||||||
|
|
||||||
console_printf(Console_Default, "%s(%d)", __func__, 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);
|
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
|
||||||
ptr ++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return ptr->init();
|
return ptr->init();
|
||||||
}
|
}
|
||||||
@ -71,12 +74,16 @@ int plugin_load(int id)
|
|||||||
int plugin_unload(int id)
|
int plugin_unload(int id)
|
||||||
{
|
{
|
||||||
Plugin *ptr = &(Plugins[0]);
|
Plugin *ptr = &(Plugins[0]);
|
||||||
|
|
||||||
for ( ; id == 0 && ptr != NULL; id -- )
|
for (; id == 0 && ptr != NULL ; id--)
|
||||||
ptr ++;
|
{
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return ptr->deinit();
|
return ptr->deinit();
|
||||||
}
|
}
|
||||||
@ -86,32 +93,34 @@ int plugin_unload(int id)
|
|||||||
int plugin_install_keypressHandler(uint8_t key, PluginKeypress func)
|
int plugin_install_keypressHandler(uint8_t key, PluginKeypress func)
|
||||||
{
|
{
|
||||||
KeyHandler *ptr;
|
KeyHandler *ptr;
|
||||||
|
|
||||||
if (keyHandlersList == NULL)
|
if (keyHandlersList == NULL)
|
||||||
{
|
{
|
||||||
keyHandlersList = (KeyHandler*) malloc(sizeof(KeyHandler));
|
keyHandlersList = (KeyHandler *)malloc(sizeof(KeyHandler));
|
||||||
|
|
||||||
keyHandlersList->key = key;
|
keyHandlersList->key = key;
|
||||||
keyHandlersList->func = func;
|
keyHandlersList->func = func;
|
||||||
keyHandlersList->next = NULL;
|
keyHandlersList->next = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr = keyHandlersList;
|
ptr = keyHandlersList;
|
||||||
|
|
||||||
while(ptr->next != NULL)
|
while (ptr->next != NULL)
|
||||||
|
{
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
ptr->next = (KeyHandler*) malloc(sizeof(KeyHandler));
|
|
||||||
|
ptr->next = (KeyHandler *)malloc(sizeof(KeyHandler));
|
||||||
|
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
|
|
||||||
ptr->key = key;
|
ptr->key = key;
|
||||||
ptr->func = func;
|
ptr->func = func;
|
||||||
ptr->next = NULL;
|
ptr->next = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +134,8 @@ int plugin_remove_keypressHandler(uint8_t key, PluginKeypress func)
|
|||||||
int plugin_keypress(uint8_t key)
|
int plugin_keypress(uint8_t key)
|
||||||
{
|
{
|
||||||
KeyHandler *ptr = keyHandlersList;
|
KeyHandler *ptr = keyHandlersList;
|
||||||
|
|
||||||
while(ptr != NULL)
|
while (ptr != NULL)
|
||||||
{
|
{
|
||||||
if (ptr->key == key)
|
if (ptr->key == key)
|
||||||
{
|
{
|
||||||
@ -134,6 +143,6 @@ int plugin_keypress(uint8_t key)
|
|||||||
}
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Code Breaker plugin - The peTI-NESulator Project
|
* Code Breaker plugin - The peTI-NESulator Project
|
||||||
* gamegenie.c: Hack your games with unlimited lives of add new powers!
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,22 +13,15 @@
|
|||||||
#include <os_dependent.h>
|
#include <os_dependent.h>
|
||||||
|
|
||||||
#define __TINES_PLUGINS__
|
#define __TINES_PLUGINS__
|
||||||
|
|
||||||
#include <plugins/manager.h>
|
#include <plugins/manager.h>
|
||||||
|
|
||||||
#undef __TINES_PLUGINS_
|
#undef __TINES_PLUGINS_
|
||||||
|
|
||||||
#include <memory/manager.h>
|
#include <memory/manager.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
#if 0
|
#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_
|
typedef enum gg_States_
|
||||||
{
|
{
|
||||||
@ -76,85 +69,95 @@ uint8_t gg_RdHookPatch##d(uint8_t addr) \
|
|||||||
#define GG_MAX_PATCH 10
|
#define GG_MAX_PATCH 10
|
||||||
/* Defines the rdhook patches */
|
/* Defines the rdhook patches */
|
||||||
GG_RDHOOKPATCH(0)
|
GG_RDHOOKPATCH(0)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(1)
|
GG_RDHOOKPATCH(1)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(2)
|
GG_RDHOOKPATCH(2)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(3)
|
GG_RDHOOKPATCH(3)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(4)
|
GG_RDHOOKPATCH(4)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(5)
|
GG_RDHOOKPATCH(5)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(6)
|
GG_RDHOOKPATCH(6)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(7)
|
GG_RDHOOKPATCH(7)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(8)
|
GG_RDHOOKPATCH(8)
|
||||||
|
|
||||||
GG_RDHOOKPATCH(9)
|
GG_RDHOOKPATCH(9)
|
||||||
|
|
||||||
void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
|
void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
|
||||||
{
|
{
|
||||||
func_rdhook fptr;
|
func_rdhook fptr;
|
||||||
|
|
||||||
if (id >= GG_MAX_PATCH)
|
if (id >= GG_MAX_PATCH)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set parameters for the patch */
|
/* Set parameters for the patch */
|
||||||
if (gg_PatchUsed[id] == 0x00)
|
if (gg_PatchUsed[id] == 0x00)
|
||||||
{
|
{
|
||||||
gg_rdhookPtr[id] = get_page_rdhook(page);
|
gg_rdhookPtr[id] = get_page_rdhook(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
gg_PatchedPage[id] = page;
|
gg_PatchedPage[id] = page;
|
||||||
gg_PatchedAddr[id] = addr;
|
gg_PatchedAddr[id] = addr;
|
||||||
gg_PatchedValue[id] = value;
|
gg_PatchedValue[id] = value;
|
||||||
gg_PatchUsed[id] = 0xFF;
|
gg_PatchUsed[id] = 0xFF;
|
||||||
|
|
||||||
/* Set a ReadHook on the page */
|
/* Set a ReadHook on the page */
|
||||||
|
|
||||||
switch(id)
|
switch (id)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
fptr = gg_RdHookPatch0;
|
fptr = gg_RdHookPatch0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
fptr = gg_RdHookPatch1;
|
fptr = gg_RdHookPatch1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
fptr = gg_RdHookPatch2;
|
fptr = gg_RdHookPatch2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
fptr = gg_RdHookPatch3;
|
fptr = gg_RdHookPatch3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
fptr = gg_RdHookPatch4;
|
fptr = gg_RdHookPatch4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
fptr = gg_RdHookPatch5;
|
fptr = gg_RdHookPatch5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
fptr = gg_RdHookPatch6;
|
fptr = gg_RdHookPatch6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
fptr = gg_RdHookPatch7;
|
fptr = gg_RdHookPatch7;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
fptr = gg_RdHookPatch8;
|
fptr = gg_RdHookPatch8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
fptr = gg_RdHookPatch9;
|
fptr = gg_RdHookPatch9;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_page_rd_hook(page, fptr);
|
set_page_rd_hook(page, fptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Access to the bitmap Buffer */
|
/* Access to the bitmap Buffer */
|
||||||
extern BITMAP *Buffer;
|
extern BITMAP *Buffer;
|
||||||
BITMAP *gg_Buffer;
|
BITMAP *gg_Buffer;
|
||||||
@ -164,28 +167,28 @@ void MessageBox(char *title, char *msg)
|
|||||||
|
|
||||||
int sc_w, sc_h;
|
int sc_w, sc_h;
|
||||||
int box_h, box_t, box_l, box_w;
|
int box_h, box_t, box_l, box_w;
|
||||||
|
|
||||||
sc_w = screen->w;
|
sc_w = screen->w;
|
||||||
sc_h = screen->h;
|
sc_h = screen->h;
|
||||||
|
|
||||||
gg_Buffer = create_bitmap(sc_w, sc_h);
|
gg_Buffer = create_bitmap(sc_w, sc_h);
|
||||||
|
|
||||||
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
|
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
|
||||||
|
|
||||||
box_w = text_length(font, title) + 10;
|
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_w += 15 * 2; /*sc_w/2;*/
|
||||||
box_h = 15*2 + 10;
|
box_h = 15 * 2 + 10;
|
||||||
|
|
||||||
/* Set the box center */
|
/* Set the box center */
|
||||||
box_t = (sc_h - box_h) / 2;
|
box_t = (sc_h - box_h) / 2;
|
||||||
box_l = (sc_w - box_w) / 2;
|
box_l = (sc_w - box_w) / 2;
|
||||||
|
|
||||||
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
||||||
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
|
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
|
||||||
|
|
||||||
/* Display the title */
|
/* Display the title */
|
||||||
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
||||||
|
|
||||||
@ -195,7 +198,7 @@ void MessageBox(char *title, char *msg)
|
|||||||
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
|
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
release_bitmap(gg_Buffer);
|
release_bitmap(gg_Buffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -205,43 +208,43 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
|
|||||||
|
|
||||||
int sc_w, sc_h;
|
int sc_w, sc_h;
|
||||||
int box_h, box_t, box_l, box_w;
|
int box_h, box_t, box_l, box_w;
|
||||||
|
|
||||||
char valueText[10];
|
char valueText[10];
|
||||||
|
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
uint8_t digit = 0;
|
uint8_t digit = 0;
|
||||||
|
|
||||||
sc_w = screen->w;
|
sc_w = screen->w;
|
||||||
sc_h = screen->h;
|
sc_h = screen->h;
|
||||||
|
|
||||||
gg_Buffer = create_bitmap(sc_w, sc_h);
|
gg_Buffer = create_bitmap(sc_w, sc_h);
|
||||||
|
|
||||||
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
|
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
|
||||||
|
|
||||||
box_w = text_length(font, title) + 10;
|
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");
|
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_w += 15 * 2; /*sc_w/2;*/
|
||||||
box_h = 15*2 + 30;
|
box_h = 15 * 2 + 30;
|
||||||
|
|
||||||
/* Set the box center */
|
/* Set the box center */
|
||||||
box_t = (sc_h - box_h) / 2;
|
box_t = (sc_h - box_h) / 2;
|
||||||
box_l = (sc_w - box_w) / 2;
|
box_l = (sc_w - box_w) / 2;
|
||||||
|
|
||||||
|
|
||||||
value = 0;
|
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);
|
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
||||||
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
|
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
|
||||||
|
|
||||||
/* Display the title */
|
/* Display the title */
|
||||||
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
||||||
|
|
||||||
@ -249,163 +252,193 @@ 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);
|
textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
|
||||||
|
|
||||||
if (size == 2)
|
if (size == 2)
|
||||||
sprintf(valueText, " %02X", value&0xFF);
|
{
|
||||||
|
sprintf(valueText, " %02X", value & 0xFF);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sprintf(valueText, "%04X", value);
|
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:
|
default:
|
||||||
case 0:
|
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;
|
break;
|
||||||
case 1:
|
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;
|
break;
|
||||||
|
|
||||||
case 2:
|
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;
|
break;
|
||||||
|
|
||||||
case 3:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
|
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
|
||||||
|
|
||||||
if (key[KEY_UP])
|
if (key[KEY_UP])
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
value += ((digit==0)?0x0001:((digit==1)?0x0010:((digit==2)?0x0100:0x1000)));
|
value += ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
|
||||||
value &= (size==2)?0xFF:0xFFFF;
|
value &= (size == 2) ? 0xFF : 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key[KEY_DOWN])
|
if (key[KEY_DOWN])
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
value -= ((digit==0)?0x0001:((digit==1)?0x0010:((digit==2)?0x0100:0x1000)));
|
value -= ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
|
||||||
value &= (size==2)?0xFF:0xFFFF;
|
value &= (size == 2) ? 0xFF : 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key[KEY_RIGHT])
|
if (key[KEY_RIGHT])
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if (digit <= 0)
|
if (digit <= 0)
|
||||||
digit = size-1;
|
{
|
||||||
else
|
digit = size - 1;
|
||||||
digit --;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
digit--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key[KEY_LEFT])
|
if (key[KEY_LEFT])
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if (digit >= size-1)
|
if (digit >= size - 1)
|
||||||
|
{
|
||||||
digit = 0;
|
digit = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
digit ++;
|
{
|
||||||
|
digit++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
release_bitmap(gg_Buffer);
|
release_bitmap(gg_Buffer);
|
||||||
while(key[KEY_ENTER]);
|
while (key[KEY_ENTER])
|
||||||
|
{
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DispMenu(int itemc, char *itemv[], char *title)
|
int DispMenu(int itemc, char *itemv[], char *title)
|
||||||
{
|
{
|
||||||
//console_printf(Console_Default, "%s(%d, %p, \"%s\");\n", __func__, itemc, itemv, title);
|
//console_printf(Console_Default, "%s(%d, %p, \"%s\");\n", __func__, itemc, itemv, title);
|
||||||
|
|
||||||
int selection = 0;
|
int selection = 0;
|
||||||
int i;
|
int i;
|
||||||
int sc_w, sc_h;
|
int sc_w, sc_h;
|
||||||
int box_h, box_t, box_l, box_w;
|
int box_h, box_t, box_l, box_w;
|
||||||
|
|
||||||
sc_w = screen->w;
|
sc_w = screen->w;
|
||||||
sc_h = screen->h;
|
sc_h = screen->h;
|
||||||
|
|
||||||
gg_Buffer = create_bitmap(sc_w, sc_h);
|
gg_Buffer = create_bitmap(sc_w, sc_h);
|
||||||
|
|
||||||
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
|
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
|
||||||
|
|
||||||
box_w = text_length(font, title) + 10;
|
box_w = text_length(font, title) + 10;
|
||||||
|
|
||||||
for (i = 0; i < itemc; 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 = (box_w > text_length(font, itemv[i])) ? box_w : text_length(font, itemv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
box_w += 15 * 2; /*sc_w/2;*/
|
box_w += 15 * 2; /*sc_w/2;*/
|
||||||
box_h = 15*2 + itemc*10;
|
box_h = 15 * 2 + itemc * 10;
|
||||||
|
|
||||||
/* Set the box center */
|
/* Set the box center */
|
||||||
box_t = (sc_h - box_h) / 2;
|
box_t = (sc_h - box_h) / 2;
|
||||||
box_l = (sc_w - box_w) / 2;
|
box_l = (sc_w - box_w) / 2;
|
||||||
|
|
||||||
|
|
||||||
while(!key[KEY_ENTER])
|
while (!key[KEY_ENTER])
|
||||||
{
|
{
|
||||||
/* Draw the box and highlight the selected item */
|
/* Draw the box and highlight the selected item */
|
||||||
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
|
||||||
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
|
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
|
||||||
|
|
||||||
/* Display the title */
|
/* Display the title */
|
||||||
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
|
||||||
|
|
||||||
/* Display the highlight item */
|
/* 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);
|
rectfill(gg_Buffer, box_l + 15, 15 + box_t + (selection * 10), box_l + box_w - 15,
|
||||||
textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60, 34);
|
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 */
|
/* Display other items */
|
||||||
for (i = 0; i < itemc; i ++)
|
for (i = 0 ; i < itemc ; i++)
|
||||||
{
|
{
|
||||||
if (i != selection)
|
if (i != selection)
|
||||||
|
{
|
||||||
textout_centre_ex(gg_Buffer, font, itemv[i], box_w / 2 + box_l, 15 + box_t + (i * 10) + 2, 34, 60);
|
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 */
|
/* Blit the screen buffer */
|
||||||
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
|
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
|
||||||
|
|
||||||
/* Now get the keyboard state */
|
/* Now get the keyboard state */
|
||||||
if (key[KEY_UP])
|
if (key[KEY_UP])
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if (selection <= 0)
|
if (selection <= 0)
|
||||||
|
{
|
||||||
selection = itemc - 1;
|
selection = itemc - 1;
|
||||||
else
|
}
|
||||||
selection --;
|
else
|
||||||
|
{
|
||||||
|
selection--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key[KEY_DOWN])
|
if (key[KEY_DOWN])
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if (selection >= (itemc - 1))
|
if (selection >= (itemc - 1))
|
||||||
|
{
|
||||||
selection = 0;
|
selection = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
selection ++;
|
{
|
||||||
|
selection++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
release_bitmap(gg_Buffer);
|
release_bitmap(gg_Buffer);
|
||||||
while(key[KEY_ENTER]);
|
while (key[KEY_ENTER])
|
||||||
|
{
|
||||||
|
}
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AskYesNo(char *title)
|
uint8_t AskYesNo(char *title)
|
||||||
{
|
{
|
||||||
char *YesNo[] = { "No", "Yes" };
|
char *YesNo[] = { "No", "Yes" };
|
||||||
|
|
||||||
return DispMenu(2, YesNo, title);
|
return DispMenu(2, YesNo, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t gg_CalcChk(uint16_t addr, uint8_t value)
|
uint8_t gg_CalcChk(uint16_t addr, uint8_t value)
|
||||||
{
|
{
|
||||||
int chk = 0x42;
|
int chk = 0x42;
|
||||||
chk += (addr & 0xFF00) >> 8;
|
chk += (addr & 0xFF00) >> 8;
|
||||||
chk -= (addr & 0x00FF);
|
chk -= (addr & 0x00FF);
|
||||||
chk += (value & 0x00FF);
|
chk += (value & 0x00FF);
|
||||||
return chk;
|
return chk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +453,7 @@ uint32_t gg_MakeCode(uint16_t addr, uint8_t value)
|
|||||||
uint32_t code = addr << 16;
|
uint32_t code = addr << 16;
|
||||||
code |= (value << 8);
|
code |= (value << 8);
|
||||||
code |= (gg_CalcChk(addr, value) & 0x00FF);
|
code |= (gg_CalcChk(addr, value) & 0x00FF);
|
||||||
|
|
||||||
return code ^ 0x246FF53A;
|
return code ^ 0x246FF53A;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,33 +463,41 @@ uint8_t gg_SelectPatch()
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
int i;
|
int i;
|
||||||
uint8_t ret;
|
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);
|
console_printf(Console_Default, "Items[%d]: %p\n", i, tmp);
|
||||||
if (gg_PatchUsed[i] == 0x00)
|
if (gg_PatchUsed[i] == 0x00)
|
||||||
|
{
|
||||||
sprintf(tmp, "Patch %d: Not used", i);
|
sprintf(tmp, "Patch %d: Not used", i);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sprintf(tmp, "Patch %d: Put 0x%02X on address 0x%02X%02X (Code: %08lX)",
|
sprintf(tmp, "Patch %d: Put 0x%02X on address 0x%02X%02X (Code: %08lX)",
|
||||||
i, gg_PatchedValue[i], gg_PatchedPage[i], gg_PatchedAddr[i],
|
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;
|
Items[i] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = (char*) malloc(0x100);
|
tmp = (char *)malloc(0x100);
|
||||||
sprintf(tmp, "Return");
|
sprintf(tmp, "Return");
|
||||||
Items[GG_MAX_PATCH] = tmp;
|
Items[GG_MAX_PATCH] = tmp;
|
||||||
|
|
||||||
ret = DispMenu(GG_MAX_PATCH + 1, Items, "Code Breaker - Select a patch");
|
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]);
|
free(Items[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == GG_MAX_PATCH)
|
if (ret == GG_MAX_PATCH)
|
||||||
|
{
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,23 +509,23 @@ void gg_PatchManager()
|
|||||||
void gg_InitSearch()
|
void gg_InitSearch()
|
||||||
{
|
{
|
||||||
uint16_t addr;
|
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;
|
gg_use_MainRAM[addr] = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
gg_ResultNumber = 0x800;
|
gg_ResultNumber = 0x800;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum gg_SearchForMode_
|
typedef enum gg_SearchForMode_
|
||||||
{
|
{
|
||||||
GG_SEARCHFOR_LOWER = 0,
|
GG_SEARCHFOR_LOWER = 0,
|
||||||
GG_SEARCHFOR_HIGHER,
|
GG_SEARCHFOR_HIGHER,
|
||||||
GG_SEARCHFOR_IDENTIC,
|
GG_SEARCHFOR_IDENTIC,
|
||||||
GG_SEARCHFOR_DIFFERENT
|
GG_SEARCHFOR_DIFFERENT
|
||||||
|
|
||||||
} gg_SearchForMode;
|
} gg_SearchForMode;
|
||||||
|
|
||||||
void gg_SearchForValue(uint8_t value)
|
void gg_SearchForValue(uint8_t value)
|
||||||
@ -493,16 +534,16 @@ void gg_SearchForValue(uint8_t value)
|
|||||||
//uint8_t oldValue;
|
//uint8_t oldValue;
|
||||||
uint8_t currentValue;
|
uint8_t currentValue;
|
||||||
gg_ResultNumber = 0x00;
|
gg_ResultNumber = 0x00;
|
||||||
for(addr = 0x000; addr < 0x800; addr ++)
|
for (addr = 0x000 ; addr < 0x800 ; addr++)
|
||||||
{
|
{
|
||||||
if (gg_use_MainRAM[addr] == 0xFF)
|
if (gg_use_MainRAM[addr] == 0xFF)
|
||||||
{
|
{
|
||||||
/* "Backup" the old ram */
|
/* "Backup" the old ram */
|
||||||
memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
|
memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
|
||||||
|
|
||||||
//oldValue = gg_MainRAM[addr];
|
//oldValue = gg_MainRAM[addr];
|
||||||
currentValue = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
|
currentValue = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
|
||||||
|
|
||||||
if (currentValue != value)
|
if (currentValue != value)
|
||||||
{ /* This is not the good one ! */
|
{ /* This is not the good one ! */
|
||||||
gg_use_MainRAM[addr] = 0x00;
|
gg_use_MainRAM[addr] = 0x00;
|
||||||
@ -522,17 +563,17 @@ void gg_SearchFor(gg_SearchForMode mode)
|
|||||||
uint8_t oldValue;
|
uint8_t oldValue;
|
||||||
uint8_t currentValue;
|
uint8_t currentValue;
|
||||||
gg_ResultNumber = 0x00;
|
gg_ResultNumber = 0x00;
|
||||||
for(addr = 0x000; addr < 0x800; addr ++)
|
for (addr = 0x000 ; addr < 0x800 ; addr++)
|
||||||
{
|
{
|
||||||
if (gg_use_MainRAM[addr] == 0xFF)
|
if (gg_use_MainRAM[addr] == 0xFF)
|
||||||
{
|
{
|
||||||
/* "Backup" the old ram */
|
/* "Backup" the old ram */
|
||||||
memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
|
memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
|
||||||
|
|
||||||
oldValue = gg_MainRAM[addr];
|
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:
|
case GG_SEARCHFOR_LOWER:
|
||||||
if (currentValue >= oldValue)
|
if (currentValue >= oldValue)
|
||||||
@ -554,7 +595,7 @@ void gg_SearchFor(gg_SearchForMode mode)
|
|||||||
else
|
else
|
||||||
{ /* This can be the good one ! */
|
{ /* This can be the good one ! */
|
||||||
gg_ResultNumber++;
|
gg_ResultNumber++;
|
||||||
gg_MainRAM[addr] = currentValue;
|
gg_MainRAM[addr] = currentValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -566,7 +607,7 @@ void gg_SearchFor(gg_SearchForMode mode)
|
|||||||
else
|
else
|
||||||
{ /* This can be the good one ! */
|
{ /* This can be the good one ! */
|
||||||
gg_ResultNumber++;
|
gg_ResultNumber++;
|
||||||
gg_MainRAM[addr] = currentValue;
|
gg_MainRAM[addr] = currentValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GG_SEARCHFOR_DIFFERENT:
|
case GG_SEARCHFOR_DIFFERENT:
|
||||||
@ -577,7 +618,7 @@ void gg_SearchFor(gg_SearchForMode mode)
|
|||||||
else
|
else
|
||||||
{ /* This can be the good one ! */
|
{ /* This can be the good one ! */
|
||||||
gg_ResultNumber++;
|
gg_ResultNumber++;
|
||||||
gg_MainRAM[addr] = currentValue;
|
gg_MainRAM[addr] = currentValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -591,7 +632,7 @@ uint8_t gg_DisplayResults()
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
int i, addr = 0x0000;
|
int i, addr = 0x0000;
|
||||||
uint8_t ret = 0;
|
uint8_t ret = 0;
|
||||||
|
|
||||||
uint16_t AddrList[21];
|
uint16_t AddrList[21];
|
||||||
if (gg_ResultNumber > 20)
|
if (gg_ResultNumber > 20)
|
||||||
{
|
{
|
||||||
@ -599,42 +640,46 @@ uint8_t gg_DisplayResults()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < gg_ResultNumber; i++)
|
for (i = 0 ; i < gg_ResultNumber ; i++)
|
||||||
{
|
{
|
||||||
while(gg_use_MainRAM[addr] != 0xFF)
|
while (gg_use_MainRAM[addr] != 0xFF)
|
||||||
addr ++;
|
{
|
||||||
console_printf(Console_Default, "0x%04X [%d]\n", addr, i);
|
addr++;
|
||||||
tmp = (char*) malloc(0x100);
|
|
||||||
sprintf(tmp,"Patch: %08XAddress 0x%04X - Was: 0x%02X - Actual: 0x%02X",
|
|
||||||
i,
|
|
||||||
addr,
|
|
||||||
gg_OldMainRAM[addr],
|
|
||||||
gg_MainRAM[addr]);
|
|
||||||
Items[i] = tmp;
|
|
||||||
AddrList[i] = addr;
|
|
||||||
|
|
||||||
addr++;
|
|
||||||
}
|
|
||||||
tmp = (char*) malloc(0x100);
|
|
||||||
sprintf(tmp, "Return");
|
|
||||||
Items[i] = tmp;
|
|
||||||
|
|
||||||
ret = DispMenu(gg_ResultNumber + 1, Items, "Code Breaker - Search");
|
|
||||||
if (ret < i)
|
|
||||||
{
|
|
||||||
if (AskYesNo("Code Breaker: Apply this patch?"))
|
|
||||||
{
|
|
||||||
/* Now patch it ! */
|
|
||||||
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++)
|
|
||||||
free(Items[i]);
|
|
||||||
}
|
}
|
||||||
|
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",
|
||||||
|
i,
|
||||||
|
addr,
|
||||||
|
gg_OldMainRAM[addr],
|
||||||
|
gg_MainRAM[addr]);
|
||||||
|
Items[i] = tmp;
|
||||||
|
AddrList[i] = addr;
|
||||||
|
|
||||||
|
addr++;
|
||||||
|
}
|
||||||
|
tmp = (char *)malloc(0x100);
|
||||||
|
sprintf(tmp, "Return");
|
||||||
|
Items[i] = tmp;
|
||||||
|
|
||||||
|
ret = DispMenu(gg_ResultNumber + 1, Items, "Code Breaker - Search");
|
||||||
|
if (ret < i)
|
||||||
|
{
|
||||||
|
if (AskYesNo("Code Breaker: Apply this patch?"))
|
||||||
|
{
|
||||||
|
/* Now patch it ! */
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
free(Items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,23 +687,23 @@ void gg_Start()
|
|||||||
{
|
{
|
||||||
char *S00_MenuList[] = { "Search a specific Value", "Search for an Unknown Value", "Enter code",
|
char *S00_MenuList[] = { "Search a specific Value", "Search for an Unknown Value", "Enter code",
|
||||||
"Manage Patches", "Exit" };
|
"Manage Patches", "Exit" };
|
||||||
|
|
||||||
char *S01_MenuList[] = { "Value is identical", "New Value...", "Value is different",
|
char *S01_MenuList[] = { "Value is identical", "New Value...", "Value is different",
|
||||||
"Value is greater", "Value is lower", "Result", "Restart", "Exit" };
|
"Value is greater", "Value is lower", "Result", "Restart", "Exit" };
|
||||||
|
|
||||||
char *S02_MenuList[] = { "Value is identical", "Value is different", "Value is greater",
|
char *S02_MenuList[] = { "Value is identical", "Value is different", "Value is greater",
|
||||||
"Value is lower", "Result", "Restart", "Exit" };
|
"Value is lower", "Result", "Restart", "Exit" };
|
||||||
|
|
||||||
char Buffer[100];
|
char Buffer[100];
|
||||||
int ret;
|
int ret;
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
switch(gg_state)
|
switch (gg_state)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case GG_S00_MAIN_STATE:
|
case GG_S00_MAIN_STATE:
|
||||||
ret = DispMenu(5, S00_MenuList, "Code Breaker - Main");
|
ret = DispMenu(5, S00_MenuList, "Code Breaker - Main");
|
||||||
|
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -666,9 +711,9 @@ void gg_Start()
|
|||||||
gg_InitSearch();
|
gg_InitSearch();
|
||||||
gg_state = GG_S01_SEARCH_VALUE;
|
gg_state = GG_S01_SEARCH_VALUE;
|
||||||
value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
|
value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
|
||||||
|
|
||||||
gg_SearchForValue(value);
|
gg_SearchForValue(value);
|
||||||
|
|
||||||
MessageBox("Code Breaker", "Search initialized !");
|
MessageBox("Code Breaker", "Search initialized !");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -679,29 +724,29 @@ void gg_Start()
|
|||||||
case 2: /* Enter code */
|
case 2: /* Enter code */
|
||||||
addr = SelectNumber("Code Breaker", "Select the address", 4);
|
addr = SelectNumber("Code Breaker", "Select the address", 4);
|
||||||
value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
|
value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
|
||||||
|
|
||||||
if (AskYesNo("Code Breaker: Apply this patch?"))
|
if (AskYesNo("Code Breaker: Apply this patch?"))
|
||||||
{
|
{
|
||||||
/* Now patch it ! */
|
/* Now patch it ! */
|
||||||
gg_SetPatch(gg_SelectPatch(),
|
gg_SetPatch(gg_SelectPatch(),
|
||||||
(addr&0xFF00)>>8, (addr&0x00FF),
|
(addr & 0xFF00) >> 8, (addr & 0x00FF),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: /* Patch manager */
|
case 3: /* Patch manager */
|
||||||
gg_PatchManager();
|
gg_PatchManager();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GG_S01_SEARCH_VALUE:
|
case GG_S01_SEARCH_VALUE:
|
||||||
S01_MENU:
|
S01_MENU:
|
||||||
ret = DispMenu(8, S01_MenuList, "Code Breaker - Search");
|
ret = DispMenu(8, S01_MenuList, "Code Breaker - Search");
|
||||||
switch(ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
gg_SearchFor(GG_SEARCHFOR_IDENTIC);
|
gg_SearchFor(GG_SEARCHFOR_IDENTIC);
|
||||||
@ -709,10 +754,10 @@ S01_MENU:
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
|
value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
|
||||||
|
|
||||||
gg_SearchForValue(value);
|
gg_SearchForValue(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
gg_SearchFor(GG_SEARCHFOR_DIFFERENT);
|
gg_SearchFor(GG_SEARCHFOR_DIFFERENT);
|
||||||
//goto S02_MENU;
|
//goto S02_MENU;
|
||||||
@ -730,11 +775,15 @@ S01_MENU:
|
|||||||
|
|
||||||
case 5: /* Results */
|
case 5: /* Results */
|
||||||
if (gg_DisplayResults() == 1)
|
if (gg_DisplayResults() == 1)
|
||||||
|
{
|
||||||
gg_state = GG_S00_MAIN_STATE;
|
gg_state = GG_S00_MAIN_STATE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
goto S01_MENU;
|
goto S01_MENU;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
if (AskYesNo("Code Breaker: Restart?"))
|
if (AskYesNo("Code Breaker: Restart?"))
|
||||||
{
|
{
|
||||||
@ -742,19 +791,21 @@ S01_MENU:
|
|||||||
gg_Start();
|
gg_Start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
goto S01_MENU;
|
goto S01_MENU;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
sprintf(Buffer,"Results found: %d", gg_ResultNumber);
|
sprintf(Buffer, "Results found: %d", gg_ResultNumber);
|
||||||
MessageBox("Code Breaker", Buffer);
|
MessageBox("Code Breaker", Buffer);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GG_S02_SEARCH_BAR:
|
case GG_S02_SEARCH_BAR:
|
||||||
S02_MENU:
|
S02_MENU:
|
||||||
ret = DispMenu(7, S02_MenuList, "Code Breaker - Search");
|
ret = DispMenu(7, S02_MenuList, "Code Breaker - Search");
|
||||||
switch(ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
gg_SearchFor(GG_SEARCHFOR_IDENTIC);
|
gg_SearchFor(GG_SEARCHFOR_IDENTIC);
|
||||||
@ -778,11 +829,15 @@ S02_MENU:
|
|||||||
|
|
||||||
case 4: /* Results */
|
case 4: /* Results */
|
||||||
if (gg_DisplayResults() == 1)
|
if (gg_DisplayResults() == 1)
|
||||||
|
{
|
||||||
gg_state = GG_S00_MAIN_STATE;
|
gg_state = GG_S00_MAIN_STATE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
goto S02_MENU;
|
goto S02_MENU;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
if (AskYesNo("Code Breaker: Restart?"))
|
if (AskYesNo("Code Breaker: Restart?"))
|
||||||
{
|
{
|
||||||
@ -790,28 +845,31 @@ S02_MENU:
|
|||||||
gg_Start();
|
gg_Start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
goto S02_MENU;
|
goto S02_MENU;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
sprintf(Buffer,"Results found: %d", gg_ResultNumber);
|
sprintf(Buffer, "Results found: %d", gg_ResultNumber);
|
||||||
MessageBox("Code Breaker", Buffer);
|
MessageBox("Code Breaker", Buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int gg_Init()
|
int gg_Init()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
console_printf(Console_Default, "Initializing GG plugin...\n");
|
console_printf(Console_Default, "Initializing GG plugin...\n");
|
||||||
|
|
||||||
plugin_install_keypressHandler('g', gg_Start);
|
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;
|
gg_PatchUsed[i] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,4 +878,5 @@ int gg_Deinit()
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* Code Breaker plugin - The peTI-NESulator Project
|
* Code Breaker plugin - The peTI-NESulator Project
|
||||||
* gamegenie.h
|
* gamegenie.h
|
||||||
*
|
*
|
||||||
* Created by Manoel Trapier.
|
* Created by Manoël Trapier.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Plugin Manager plugint list - The peTI-NESulator Project
|
* Plugin Manager plugint list - The peTI-NESulator Project
|
||||||
* plugins_list.h
|
* plugins_list.h
|
||||||
*
|
*
|
||||||
* Created by Manoel Trapier.
|
* Created by Manoël Trapier.
|
||||||
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -12,8 +12,8 @@
|
|||||||
#include "plugins/gamegenie.h"
|
#include "plugins/gamegenie.h"
|
||||||
|
|
||||||
Plugin Plugins[] = {
|
Plugin Plugins[] = {
|
||||||
// { "Game Genie", gg_Init, gg_Deinit },
|
// { "Game Genie", gg_Init, gg_Deinit },
|
||||||
|
|
||||||
/* EOL tag */
|
/* EOL tag */
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#
|
#
|
||||||
# peTI-NESulator CMake
|
# peTI-NESulator CMake
|
||||||
#
|
#
|
||||||
# Created by Manoel TRAPIER.
|
# Created by Manoël TRAPIER.
|
||||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
# Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
#
|
#
|
||||||
# $LastChangedDate$
|
# $LastChangedDate$
|
||||||
# $Author$
|
# $Author$
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* PPU Debug utilities - The peTI-NESulator Project
|
* PPU Debug utilities - The peTI-NESulator Project
|
||||||
* ppu.debug.c
|
* ppu.debug.c
|
||||||
*
|
*
|
||||||
* Created by Manoel Trapier.
|
* Created by Manoël Trapier.
|
||||||
* Copyright 2003-2008 986 Corp. All rights reserved.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Define and emulate the PPU (Picture Processing Unit) of the real NES
|
* 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -55,12 +55,6 @@ typedef struct spriteData
|
|||||||
|
|
||||||
/* PPU registers */
|
/* 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 */
|
/* FV: Fine Vertical Scroll latch/counter */
|
||||||
uint8_t PPU_Reg_FV;
|
uint8_t PPU_Reg_FV;
|
||||||
|
|
||||||
@ -79,7 +73,7 @@ uint8_t PPU_Reg_V;
|
|||||||
/* H: Horizontal Name Table Selection latch/counter */
|
/* H: Horizontal Name Table Selection latch/counter */
|
||||||
uint8_t PPU_Reg_H;
|
uint8_t PPU_Reg_H;
|
||||||
|
|
||||||
/* S: Playfield pattern table selection latch */
|
/* S: Play-field pattern table selection latch */
|
||||||
uint16_t PPU_Reg_S;
|
uint16_t PPU_Reg_S;
|
||||||
|
|
||||||
/* PAR: Picture Address Register */
|
/* PAR: Picture Address Register */
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* PPU Memory manager - The peTI-NESulator Project
|
* PPU Memory manager - The peTI-NESulator Project
|
||||||
* ppu.memory.c - Inspired from the memory manager of the Quick6502 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.
|
* Copyright (c) 2003-2018 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
/* Simple definition only for readability */
|
/* Simple definition only for readability */
|
||||||
#define Kuint8_t * (1024)
|
#define KByte * (1024)
|
||||||
|
|
||||||
/* Internal representation of the PPU memory */
|
/* Internal representation of the PPU memory */
|
||||||
uint8_t *ppu_memoryPages[0x40];
|
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)
|
void ppu_setPagePtr4k(uint8_t page, uint8_t *ptr)
|
||||||
{
|
{
|
||||||
ppu_setPagePtr2k(page, 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)
|
void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr)
|
||||||
{
|
{
|
||||||
ppu_setPagePtr4k(page, 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)
|
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)
|
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 */
|
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);
|
//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)
|
if ((addr & 0xEF) == 0x00)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* bin to header - Part of The peTI-NESulator Project
|
* 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.
|
* 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.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,81 +13,85 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *infile;
|
char *infile;
|
||||||
FILE *fpin = stdin;
|
FILE *fpin = stdin;
|
||||||
FILE *fpout = stdout;
|
FILE *fpout = stdout;
|
||||||
short c;
|
short c;
|
||||||
infile = "stdin";
|
infile = "stdin";
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(i = 1; argv[i] && argv[i][0] == '-'; i++)
|
|
||||||
{
|
|
||||||
if (i < argc)
|
|
||||||
{
|
|
||||||
switch(argv[i][1])
|
|
||||||
{
|
|
||||||
case 'i':
|
|
||||||
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]);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'o':
|
|
||||||
|
|
||||||
fpout = fopen(argv[i+1], "wb");
|
|
||||||
if (fpout == NULL)
|
|
||||||
{
|
|
||||||
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]);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fpout, "/* Generated data file from file '%s' */\n\n\n", infile);
|
for (i = 1 ; argv[i] && argv[i][0] == '-' ; i++)
|
||||||
|
{
|
||||||
fprintf(fpout, "uint8_t data[] = {\n");
|
if (i < argc)
|
||||||
i = 0;
|
{
|
||||||
while((c = fgetc(fpin)) >= 0)
|
switch (argv[i][1])
|
||||||
{
|
{
|
||||||
if (i == 0)
|
case 'i':
|
||||||
fprintf(fpout, "\t\t0x%02X", (uint8_t)c);
|
fpin = fopen(argv[i + 1], "rb");
|
||||||
else
|
infile = argv[i + 1];
|
||||||
fprintf(fpout, ", 0x%02X", (uint8_t)c);
|
if (fpin == NULL)
|
||||||
|
{
|
||||||
i++;
|
fprintf(stderr, "Error: cannot open in file '%s'\n", argv[i + 1]);
|
||||||
if (i > 10)
|
exit(-1);
|
||||||
{
|
}
|
||||||
fprintf(fpout,", \\\n");
|
i++;
|
||||||
i = 0;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
fprintf(fpout, "\n\t\t};\n");
|
|
||||||
|
|
||||||
if (fpin != stdin)
|
case 'o':
|
||||||
{
|
|
||||||
fclose(fpin);
|
|
||||||
}
|
|
||||||
if (fpout != stdout)
|
|
||||||
{
|
|
||||||
fclose(fpout);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
fpout = fopen(argv[i + 1], "wb");
|
||||||
|
if (fpout == NULL)
|
||||||
|
{
|
||||||
|
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]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fpout, "/* Generated data file from file '%s' */\n\n\n", infile);
|
||||||
|
|
||||||
|
fprintf(fpout, "uint8_t data[] = {\n");
|
||||||
|
i = 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");
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
fprintf(fpout, "\n\t\t};\n");
|
||||||
|
|
||||||
|
if (fpin != stdin)
|
||||||
|
{
|
||||||
|
fclose(fpin);
|
||||||
|
}
|
||||||
|
if (fpout != stdout)
|
||||||
|
{
|
||||||
|
fclose(fpout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import sys
|
|||||||
import hashlib.md5 as md5
|
import hashlib.md5 as md5
|
||||||
import hashlib.sha as sha
|
import hashlib.sha as sha
|
||||||
|
|
||||||
|
|
||||||
def get_page(theurl, post_data=None):
|
def get_page(theurl, post_data=None):
|
||||||
"""
|
"""
|
||||||
Helper method that gets the given URL
|
Helper method that gets the given URL
|
||||||
@ -37,25 +38,25 @@ if __name__ == '__main__':
|
|||||||
DiskDude = 0
|
DiskDude = 0
|
||||||
if fs[7:16] == "DiskDude!":
|
if fs[7:16] == "DiskDude!":
|
||||||
DiskDude = 1
|
DiskDude = 1
|
||||||
|
|
||||||
mapperID = ord(fs[6]) >> 4
|
mapperID = ord(fs[6]) >> 4
|
||||||
if DiskDude == 0:
|
if DiskDude == 0:
|
||||||
mapperID = mapperID | (ord(fs[7]) & 0xF0)
|
mapperID = mapperID | (ord(fs[7]) & 0xF0)
|
||||||
|
|
||||||
prgsize = ord(fs[4]) * 16 * 1024
|
prgsize = ord(fs[4]) * 16 * 1024
|
||||||
chrsize = ord(fs[5]) * 8 * 1024
|
chrsize = ord(fs[5]) * 8 * 1024
|
||||||
mirror = 0
|
mirror = 0
|
||||||
if Flags & 0x01:
|
if Flags & 0x01:
|
||||||
mirror = 1
|
mirror = 1
|
||||||
|
|
||||||
sram = 0
|
sram = 0
|
||||||
if Flags & 0x02:
|
if Flags & 0x02:
|
||||||
sram = 1
|
sram = 1
|
||||||
|
|
||||||
Trainer = 0
|
Trainer = 0
|
||||||
if Flags & 0x04:
|
if Flags & 0x04:
|
||||||
Trainer = 1
|
Trainer = 1
|
||||||
|
|
||||||
print(" <game>")
|
print(" <game>")
|
||||||
print(" <name>{filename}</name>".format(filename=filename))
|
print(" <name>{filename}</name>".format(filename=filename))
|
||||||
print(" <sha>{sha}</sha>".format(sha=sha.new(fs).hexdigest()))
|
print(" <sha>{sha}</sha>".format(sha=sha.new(fs).hexdigest()))
|
||||||
@ -68,11 +69,10 @@ if __name__ == '__main__':
|
|||||||
print(" <trainer>{trainer}</trainer>".format(trainer=Trainer))
|
print(" <trainer>{trainer}</trainer>".format(trainer=Trainer))
|
||||||
print(" <diskdude>{diskdude}</diskdude>".format(diskdude=DiskDude))
|
print(" <diskdude>{diskdude}</diskdude>".format(diskdude=DiskDude))
|
||||||
print(" </game>")
|
print(" </game>")
|
||||||
|
|
||||||
|
# will fill the DB :
|
||||||
#will fill the DB :
|
|
||||||
url = "http://127.0.0.1/nesstat/add.php"
|
url = "http://127.0.0.1/nesstat/add.php"
|
||||||
|
|
||||||
html = get_page(url, urllib.urlencode({
|
html = get_page(url, urllib.urlencode({
|
||||||
'n': filename,
|
'n': filename,
|
||||||
'md5': md5.new(fs).hexdigest(),
|
'md5': md5.new(fs).hexdigest(),
|
||||||
@ -85,9 +85,9 @@ if __name__ == '__main__':
|
|||||||
't': Trainer,
|
't': Trainer,
|
||||||
'd': DiskDude,
|
'd': DiskDude,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
print(html)
|
print(html)
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
#print("</gamelist>")
|
# print("</gamelist>")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user