Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5336cf6272 | ||
|
|
29a2deb1f3 | ||
|
|
05f17740fd | ||
|
|
6e179a5866 | ||
|
|
a6586b3467 | ||
|
|
79e43a98e4 | ||
|
|
9413fc5e27 | ||
|
|
1158daab8b | ||
|
|
6f2bf79917 | ||
|
|
c7c21ce752 | ||
|
|
8b34ba6c26 | ||
|
|
e8171d4705 | ||
|
|
f5c15c741b | ||
|
|
1ac164cbda | ||
|
|
4da1c434cd | ||
|
|
6a1064a852 | ||
|
|
0a0d086f31 | ||
|
|
a09f33fe33 | ||
|
|
b6c4793f44 | ||
|
|
b0ed951235 | ||
|
|
ff80e60879 | ||
|
|
bfd4597afa | ||
|
|
7ffe343e7a | ||
|
|
75bac739ee | ||
|
|
779a22006c | ||
|
|
3d3d6729f6 | ||
|
|
d26bd788cf | ||
|
|
cc9fe51828 | ||
|
|
866dcfa969 | ||
|
|
54a685cdaa | ||
|
|
bcf60e8d96 | ||
|
|
0d6ed068ca | ||
|
|
bc65a7a4f0 | ||
|
|
211b1f86c8 | ||
|
|
8e99ac85ff | ||
|
|
c2ae371bed | ||
|
|
79ac4c42f1 | ||
|
|
02a8b24523 | ||
|
|
735217df00 | ||
|
|
5d3895f08a | ||
|
|
bc118baac8 |
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#Temp files
|
||||||
|
/build*
|
||||||
|
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "external/glfw"]
|
||||||
|
path = external/glfw
|
||||||
|
url = https://github.com/glfw/glfw.git
|
||||||
|
[submodule "external/coveralls-cmake"]
|
||||||
|
path = external/coveralls-cmake
|
||||||
|
url = https://github.com/JoakimSoderberg/coveralls-cmake.git
|
||||||
40
.travis.yml
Normal file
40
.travis.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
language: c
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- os: osx
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- lcov
|
||||||
|
- curl
|
||||||
|
- xorg-dev
|
||||||
|
- libglu1-mesa-dev
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- clang
|
||||||
|
- gcc
|
||||||
|
|
||||||
|
script:
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=OFF -DCMAKE_BUILD_TYPE=Release ..
|
||||||
|
- cmake --build .
|
||||||
|
- cd ..
|
||||||
|
- mkdir coverage
|
||||||
|
- cd coverage
|
||||||
|
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
|
- cmake --build .
|
||||||
|
- cmake --build . --target coveralls
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
|
||||||
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install glew; fi
|
||||||
|
|
||||||
|
install: true
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
28
CMakeLists.txt
Normal file
28
CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
|
project (TINES)
|
||||||
|
|
||||||
|
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
|
add_subdirectory("external/glfw")
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
|
include_directories(${OPENGL_INCLUDE_DIR})
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
enable_testing()
|
||||||
|
endif (COVERALLS)
|
||||||
|
|
||||||
|
add_subdirectory (src)
|
||||||
21
README.md
Normal file
21
README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
TI-NESulator
|
||||||
|
============
|
||||||
|
|
||||||
|
[](https://coveralls.io/github/Godzil/TI-NESulator?branch=master) [](https://codecov.io/gh/Godzil/TI-NESulator) [](https://travis-ci.org/Godzil/TI-NESulator)
|
||||||
|
|
||||||
|
This is a cleaned version of the TI-NESulator repository (all non free data has been removed)
|
||||||
|
|
||||||
|
Some part of the original subversion has been lost because of harddrive crash so the
|
||||||
|
early stage of the project is completely lost. Or I would need to check all the
|
||||||
|
backups arount to recreate part of that history, but that not a fun thing to do to be
|
||||||
|
honest, and there is virtually nothing to gain from that.
|
||||||
|
|
||||||
|
The source is given as is, I have to select a proper licence for this code, but concider
|
||||||
|
it to be in a 3 clause BSD with a non commercial clause:
|
||||||
|
|
||||||
|
- You are free to use that code and integrate some part in your project
|
||||||
|
- Will need to state where some of your code come from
|
||||||
|
- This code is given as-is without any waranty of working as expected
|
||||||
|
- You CAN'T use that code for commercial product without my prior consent.
|
||||||
|
|
||||||
|
|
||||||
19
README.txt
Normal file
19
README.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
TI-NESulator
|
||||||
|
============
|
||||||
|
|
||||||
|
This is a cleaned version of the TI-NESulator repository (all data has been removed)
|
||||||
|
|
||||||
|
Some part of the original subversion has been lost because of harddrive crash so the
|
||||||
|
early stage of the project is completely lost. Or I would need to check all the
|
||||||
|
backups arount to recreate part of that history, but that not a fun thing to do to be
|
||||||
|
honest, and there is virtually nothing to gain from that.
|
||||||
|
|
||||||
|
The source is given as is, I have to select a proper licence for this code, but concider
|
||||||
|
it to be in a 3 clause BSD with a non commercial clause:
|
||||||
|
|
||||||
|
- You are free to use that code and integrate some part in your project
|
||||||
|
- Will need to state where some of your code come from
|
||||||
|
- This code is given as-is without any waranty of working as expected
|
||||||
|
- You CAN'T use that code for commercial product without my prior consent.
|
||||||
|
|
||||||
|
|
||||||
BIN
data/bad_apple_2.nes
Normal file
BIN
data/bad_apple_2.nes
Normal file
Binary file not shown.
BIN
data/trollburner_demo.nes
Normal file
BIN
data/trollburner_demo.nes
Normal file
Binary file not shown.
@@ -1,3 +1,15 @@
|
|||||||
|
25/02/2008: V0.30 part 2
|
||||||
|
- Correct a bug in CPU emulation related with cycle count and the stupid R_FLAG
|
||||||
|
- Correct bugs in PAL emulation where VBlank line count was incorrect.
|
||||||
|
- Correct a bug with VBlank (it occured one line too late)
|
||||||
|
- Correct a bug with cart loading, if the file name was incorrect it crashed instead
|
||||||
|
exiting gently.
|
||||||
|
- All mappers are remerged.
|
||||||
|
- Unix & Windows build are totaly broken...
|
||||||
|
- Sprite are back! There are some bad behaviour, but they will be corrected with next versions.
|
||||||
|
- New SVN repository (the disk where the old one was had crashed...)
|
||||||
|
- Iremh3100 is now active! (finaly)
|
||||||
|
|
||||||
05/10/2007 V0.30 part 2 ... In progress ...
|
05/10/2007 V0.30 part 2 ... In progress ...
|
||||||
- Start rewrite of mapper manager. The goal, like for plugin manager, is
|
- Start rewrite of mapper manager. The goal, like for plugin manager, is
|
||||||
to allow in the future to have plugins or mapper in external libraries.
|
to allow in the future to have plugins or mapper in external libraries.
|
||||||
@@ -101,5 +113,5 @@
|
|||||||
- Premiere version public, ne sert que de d<>monstration.
|
- Premiere version public, ne sert que de d<>monstration.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
$Id: Changements.txt 29 2007-04-03 14:34:02Z mtrapier $
|
$Id$
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,21 +1,33 @@
|
|||||||
05/10/2007 V0.30 part 2 ... In progress ...
|
25/02/2008: V0.30 part 2
|
||||||
- Start rewrite of mapper manager. The goal, like for plugin manager, is
|
- Correct a bug in CPU emulation related with cycle count and the stupid R_FLAG
|
||||||
to allow in the future to have plugins or mapper in external libraries.
|
- Correct bugs in PAL emulation where VBlank line count was incorrect.
|
||||||
- New sound layer using Allegro. Not really accurate, but more portable.
|
- Correct a bug with VBlank (it occured one line too late)
|
||||||
A lot of work has to be done on this (especialy because the actual sound
|
- Correct a bug with cart loading, if the file name was incorrect it crashed instead
|
||||||
is really bad.)
|
exiting gently.
|
||||||
- Started a new source organisation. Should be the good one this time !
|
- All mappers are remerged.
|
||||||
|
- Unix & Windows build are totaly broken...
|
||||||
|
- Sprite are back! There are some bad behaviour, but they will be corrected with next versions.
|
||||||
|
- New SVN repository (the disk where the old one was had crashed...)
|
||||||
|
- Iremh3100 is now active! (finaly)
|
||||||
|
|
||||||
25/10/2007:
|
25/10/2007:
|
||||||
- Savestate now work correctly (It was not loaded at the right time...)
|
- Savestate now work correctly (It was not loaded at the right time...)
|
||||||
- Mapper manager seems to work correctly ok
|
- Mapper manager seems to work correctly ok
|
||||||
- [MACOSX] Buils options are better now
|
- [MACOSX] Builds options are better now
|
||||||
|
|
||||||
|
|
||||||
- [TODO] Remerge old PPU debug utilities in real plugin form
|
- [TODO] Remerge old PPU debug utilities in real plugin form
|
||||||
- [TODO] Change the make util. Maybe cmake ?
|
- [TODO] Change the make util. Maybe cmake ?
|
||||||
- [TODO] Remerge all mappers with the new manager
|
- [TODO] Remerge all mappers with the new manager
|
||||||
- [TODO] Rewrite UNIX Makefile for support new src organization.
|
- [TODO] Rewrite UNIX Makefile for support new src organization.
|
||||||
|
|
||||||
|
05/10/2007:
|
||||||
|
- Start rewrite of mapper manager. The goal, like for plugin manager, is
|
||||||
|
to allow in the future to have plugins or mapper in external libraries.
|
||||||
|
- New sound layer using Allegro. Not really accurate, but more portable.
|
||||||
|
A lot of work has to be done on this (especialy because the actual sound
|
||||||
|
is really bad.)
|
||||||
|
- Started a new source organisation. Should be the good one this time!
|
||||||
|
|
||||||
03/05/2007 V0.30 part 1
|
03/05/2007 V0.30 part 1
|
||||||
- Started the process of PPU total rewrite.
|
- Started the process of PPU total rewrite.
|
||||||
- Bg seem to draw fine, sprite is under the way
|
- Bg seem to draw fine, sprite is under the way
|
||||||
@@ -123,5 +135,5 @@
|
|||||||
- Premiere version public, ne sert que de d<>monstration.
|
- Premiere version public, ne sert que de d<>monstration.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
$Id: Changes.txt 51 2007-05-22 16:33:04Z mtrapier $
|
$Id$
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
224
doc/LisezMoi.txt
224
doc/LisezMoi.txt
@@ -1,65 +1,64 @@
|
|||||||
<---------------------------------------------------------------------------------->
|
<------------------------------------------------------------------------------>
|
||||||
TI-NESulator
|
TI-NESulator
|
||||||
Version 0.26 beta
|
Version 0.30.2 beta
|
||||||
|
|
||||||
Par Manoël TRAPIER aka Godzil
|
Par Manoel TRAPIER aka Godzil
|
||||||
godzil at godzil point net
|
godzil at godzil point net
|
||||||
|
|
||||||
1 -> #include <disclamer.h>
|
1 -> #include <disclamer.h>
|
||||||
|
|
||||||
L'utilisation de se logiciel se fait a vos risque et périls. Il s'agit d'une pars
|
L'utilisation de se logiciel se fait a vos risque et p<EFBFBD>rils. Il s'agit d'une
|
||||||
d'une version non terminée, et en cours de dévellopement, et la diffusion n'a été
|
pars d'une version non termin<EFBFBD>e, et en cours de d<EFBFBD>vellopement, et la diffusion
|
||||||
faite que pour permettre le teste, et la démonstration de se que sera le logiciel
|
n'a <20>t<EFBFBD> faite que pour permettre le teste, et la d<EFBFBD>monstration de se que sera le
|
||||||
final.
|
logiciel final.
|
||||||
|
|
||||||
Je ne peut donc être tenu pour responsable en cas de problème lié a l'utilisation
|
Je ne peut donc <EFBFBD>tre tenu pour responsable en cas de probl<EFBFBD>me li<EFBFBD> <20>
|
||||||
ou posession de se logiciel.
|
l'utilisation ou posession de se logiciel.
|
||||||
|
|
||||||
Vous êtes libre de l'utiliser à partir du moment au se logiciel n'a pas été modifié
|
Vous <EFBFBD>tes libre de l'utiliser <EFBFBD> partir du moment au se logiciel n'a pas <EFBFBD>t<EFBFBD>
|
||||||
que sa soit de manière binaire, ou par désassemblage. Si vous trouver une version
|
modifi<EFBFBD> que sa soit de mani<EFBFBD>re binaire, ou par d<EFBFBD>sassemblage. Si vous trouver
|
||||||
modifié ou fourni avec des fichiers illégaux, veuillez me le faire savoir. Vous
|
une version modifi<EFBFBD> ou fourni avec des fichiers ill<EFBFBD>gaux, veuillez me le faire
|
||||||
trouverez comment me contacter dans la suite de se fichier.
|
savoir. Vous trouverez comment me contacter dans la suite de se fichier.
|
||||||
|
|
||||||
Vous êtes libre aussi de le distribuer tant que les fichiers contenus dans le
|
Vous <EFBFBD>tes libre aussi de le distribuer tant que les fichiers contenus dans le
|
||||||
paquetage original sont laissé intouché (les fichiers Changements.txt LisezMoi.txt
|
paquetage original sont laiss<EFBFBD> intouch<EFBFBD>.
|
||||||
et TINes.exe)
|
|
||||||
|
|
||||||
Information légales :
|
Information l<EFBFBD>gales :
|
||||||
NES, Famicon, Nintendo Entertainment System, Nintendo sont des marques déposé de
|
NES, Famicon, Nintendo Entertainment System, Nintendo sont des marques d<EFBFBD>pos<EFBFBD> de
|
||||||
Nintendo France, Nintendo of america et Nintendo Company, Ltd.
|
Nintendo France, Nintendo of america et Nintendo Company, Ltd.
|
||||||
Tout les titres et marques apparaisant dans se fichier texte sont la propriété de
|
Tout les titres et marques apparaisant dans se fichier texte sont la propri<EFBFBD>t<EFBFBD>
|
||||||
leurs auteurs respectifs.
|
de leurs auteurs respectifs.
|
||||||
|
|
||||||
N'oubliez pas aussi que la posession de ROM (Fichier binaire représentant le
|
N'oubliez pas aussi que la posession de ROM (Fichier binaire repr<EFBFBD>sentant le
|
||||||
contenue d'une cartouche) sans en posseder l'originale (la cartouche) est absolument
|
contenue d'une cartouche) sans en posseder l'originale (la cartouche) est
|
||||||
illégale, que vous la gardiez 24 heures ou seulement 30 secondes
|
absolument ill<EFBFBD>gale, que vous la gardiez 24 heures ou seulement 30 secondes
|
||||||
|
|
||||||
|
|
||||||
2 -> Qu'est-ce que TI-NESulator ?
|
2 -> Qu'est-ce que TI-NESulator ?
|
||||||
|
|
||||||
TI-NESulator est un émulateur de la console Nintendo Entertainment System
|
TI-NESulator est un <EFBFBD>mulateur de la console Nintendo Entertainment System
|
||||||
(connunément appelé NES) fabriqué par Nintendo au milieu des année 80. L'originalité
|
(connun<EFBFBD>ment appel<EFBFBD> NES) fabriqu<EFBFBD> par Nintendo au milieu des ann<EFBFBD>e 80.
|
||||||
de cet emulateur est que sa plateforme de fonctionnement principal est les
|
L'originalit<69> de cet emulateur est que sa plateforme de fonctionnement principal
|
||||||
calculatrices TI-89 et TI-92+ de chez Texas Instrument. Ses calculatrices on la
|
est les calculatrices TI-89 et TI-92+ de chez Texas Instrument. Ses
|
||||||
particularité de posseder un microprocesseur 68000 de chez motorola, qui est pour
|
calculatrices on la particularit<EFBFBD> de posseder un microprocesseur 68000 de chez
|
||||||
se genre de plateforme relativement puissant et programmer un emulateur, meme de
|
motorola, qui est pour se genre de plateforme relativement puissant et
|
||||||
NES, sur ses machine est un véritable défit.
|
programmer un emulateur, meme de NES, sur ses machine est un v<EFBFBD>ritable d<EFBFBD>fit
|
||||||
Tant au niveau matériel que mémoire, la NES et les TI-68k sont completements
|
tant au niveau mat<EFBFBD>riel que m<EFBFBD>moire, la NES et les TI-68k sont completements
|
||||||
différents.
|
diff<EFBFBD>rents.
|
||||||
La NES utilise une version légérement personalisé du microprocesseur 6502
|
La NES utilise une version l<EFBFBD>g<EFBFBD>rement personalis<EFBFBD> du microprocesseur 6502
|
||||||
fonctionnant a environ 1.7Mhz.
|
fonctionnant <EFBFBD> environ 1.7Mhz.
|
||||||
|
|
||||||
Vous avez actuellement une version spéciale (comprendre pas faite pour
|
Vous avez actuellement une version sp<EFBFBD>ciale (comprendre pas faite pour
|
||||||
calculatrices TI.) Cette version ne me sert qu'a mettre en oeuvre de nouvelles
|
calculatrices TI.) Cette version ne me sert qu'a mettre en oeuvre de nouvelles
|
||||||
choses dans la version TI de l'émulateur (notemment a cause d'un gros manque
|
choses dans la version TI de l'<EFBFBD>mulateur (notemment a cause d'un gros manque
|
||||||
de debuggueur C dans le monde TI.)
|
de debuggueur C dans le monde TI.)
|
||||||
|
|
||||||
Cette version est et sera toujours plus avancé que la version TI dans le sens ou
|
Cette version est et sera toujours plus avanc<EFBFBD> que la version TI dans le sens ou
|
||||||
elle me sert a expérimenter les nouveaux hardware émulé et a finaliser le hardware
|
elle me sert a exp<EFBFBD>rimenter les nouveaux hardware <EFBFBD>mul<EFBFBD> et a finaliser le
|
||||||
deja emuler. Une fois fonctionnant d'un maniere convenable sur le portage Windows,
|
hardware deja emuler. Une fois fonctionnant d'un maniere convenable sur le
|
||||||
les mises a jours sont faites dans la version TI. Mais la version Windows au final
|
portage Windows, les mises a jours sont faites dans la version TI. Mais la
|
||||||
contiendra plus de fonctionnalité que la version TI (support des palletes, de la
|
version Windows au final contiendra plus de fonctionnalit<EFBFBD> que la version TI
|
||||||
couleur, voir meme le son etc...)
|
(support des palletes, de la couleur, voir meme le son etc...)
|
||||||
|
|
||||||
|
|
||||||
3 -> Utilisation de TI-NESulator
|
3 -> Utilisation de TI-NESulator
|
||||||
@@ -86,7 +85,7 @@ SELECT P
|
|||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
Autres touches :
|
Autres touches :
|
||||||
R identique a l'apuis du bouton Reset de la console
|
R identique <EFBFBD> l'apuis du bouton Reset de la console
|
||||||
|
|
||||||
|
|
||||||
1-2 A un effet, mais vous risque de pas le voir ;)
|
1-2 A un effet, mais vous risque de pas le voir ;)
|
||||||
@@ -97,137 +96,110 @@ R identique a l'apuis du bouton Reset de la console
|
|||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
Il faut noter aussi qu'afficher ces tables ralenti considérablement la vitesse de
|
Il faut noter aussi qu'afficher ces tables ralentisent consid<EFBFBD>rablement la
|
||||||
l'émulateur
|
vitesse de l'<EFBFBD>mulateur
|
||||||
|
|
||||||
4 -> Compatibilité
|
4 -> Compatibilit<EFBFBD>
|
||||||
|
|
||||||
TI-NESulator version Win32 est normalement compatible avec tous les Windows (95, 98,
|
TI-NESulator version Win32 est normalement compatible avec tous les Windows
|
||||||
Me, NT 4, 2000, XP)
|
(95, 98,Me, NT 4, 2000, XP)
|
||||||
TI-NESulator version .X (MacOS X) est normalement compatible toutes version de OS X
|
TI-NESulator version .X (MacOS X) est normalement compatible toutes version
|
||||||
(.1.x .2.x .3.x)
|
de OS X (.1.x .2.x .3.x)
|
||||||
L'émulateur émule actuellement avec les mappers :
|
|
||||||
|
L'<27>mulateur <20>mule actuellement avec les mappers :
|
||||||
|
|
||||||
- 0 aucun mapper (Super Mario Bros 1, Donkey Kong, ...)
|
- 0 aucun mapper (Super Mario Bros 1, Donkey Kong, ...)
|
||||||
|
|
||||||
- 1 MMC1 (a 99%, Megaman 2, Zelda1 & 2, Final Fantasy 1, ...)
|
- 1 MMC1 (a 99%, Megaman 2, Zelda1 & 2, Final Fantasy 1, ...)
|
||||||
|
|
||||||
- 2 UNROM (MegaMan, Final fantasy 2, ...)
|
- 2 UNROM (MegaMan, Final fantasy 2, ...)
|
||||||
|
|
||||||
- 3 CNROM
|
- 3 CNROM
|
||||||
|
- 4 MMC3 (Super mario Bross 2 & 3, MegaMan 3 <20> 6, ...)
|
||||||
|
- 7 AOROM (Battletoad, ...)
|
||||||
|
|
||||||
- 4 *NOUVEAU* MMC3 (Super mario Bross 2 & 3, MegaMan 3 à 6, ...)
|
Les mappers marqu<71> comme *NOUVEAU* sont ceux qui on <20>t<EFBFBD> ajout<75> dans la derniere
|
||||||
|
version disponible. Merci de faire un rapport d<>taill<6C> si vous rencontrer des
|
||||||
|
probl<EFBFBD>mes avec.
|
||||||
|
|
||||||
- 7 *NOUVEAU* AOROM (Battletoad, ...)
|
5 -> Question R<>ponses
|
||||||
|
|
||||||
Les mappers marqué comme *NOUVEAU* sont ceux qui on été ajouté dans la derniere
|
|
||||||
version disponible. Merci de faire un rapport détaillé si vous rencontrer des
|
|
||||||
problèmes avec.
|
|
||||||
|
|
||||||
|
|
||||||
5 -> A faire
|
|
||||||
|
|
||||||
* Optimisation du coeur de l'émulation du CPU de la NES.
|
|
||||||
|
|
||||||
* Son ?
|
|
||||||
|
|
||||||
* Supprimer les printf et les remplacer par l'affichage dans une console (prochaine
|
|
||||||
maj) pour eviter les soucis sur
|
|
||||||
|
|
||||||
- PC: car la console n'est pas forcement ouverte tout le temps
|
|
||||||
- Unix: pour la meme raison
|
|
||||||
- MacOS: aussi (%))
|
|
||||||
- TI: pasqu'on peut pas avoir les deux en meme temps.
|
|
||||||
|
|
||||||
* Recoder le ppu (gestion de l'affichage)
|
|
||||||
|
|
||||||
6 -> Question Réponses
|
|
||||||
|
|
||||||
Q: Pourquoi le jeu xxx ne fonctionne pas ?
|
Q: Pourquoi le jeu xxx ne fonctionne pas ?
|
||||||
R: TI-NESulator est actuellement en cours de dévellopement. Beaucoup de jeux ne
|
R: TI-NESulator est actuellement en cours de d<EFBFBD>vellopement. Beaucoup de jeux ne
|
||||||
sont pas supporté.
|
sont pas support<EFBFBD>.
|
||||||
|
|
||||||
Q: Vous dites que certain de jeux ne sont pas supporté, mais si j'essaye xxx, il
|
Q: Vous dites que certain de jeux ne sont pas support<EFBFBD>, mais si j'essaye xxx, il
|
||||||
marche ! Pourquoi ?
|
marche ! Pourquoi ?
|
||||||
R: Ceci est du a une des particularité du Hardware de la NES/Famicon. Le hardware
|
R: Ceci est du a une des particularit<EFBFBD> du Hardware de la NES/Famicon. Le
|
||||||
de base de la console est assé limité, et la mémoire est aussi tres limité. pour
|
hardware de base de la console est ass<EFBFBD> limit<EFBFBD>, et la m<EFBFBD>moire est aussi tres
|
||||||
palier à ses limitations, certains jeux utilise ce qu'on appele des Mappers, qui
|
limit<EFBFBD>. pour palier <EFBFBD> ses limitations, certains jeux utilise ce qu'on appele des
|
||||||
permettent notemment d'avoir des jeux plus gros, et qui sont implémenté dans la
|
Mappers, qui permettent notemment d'avoir des jeux plus gros, et qui sont
|
||||||
cartouche du jeu. Malheureusement supporter tout ses mappers font grossir
|
impl<EFBFBD>ment<EFBFBD> dans la cartouche du jeu. Malheureusement supporter tout ses mappers
|
||||||
l'emulateur, et certain on un fonctionnement qui est malheureusement encore
|
font grossir l'emulateur, et certain on un fonctionnement qui est
|
||||||
inconnu. N'oubliez pas non plus que TI-NESulator est encore en dévellopement.
|
malheureusement encore inconnu. N'oubliez pas non plus que TI-NESulator est
|
||||||
Certain mapper connu ne sont pas encore implémenté.
|
encore en d<>vellopement. Certain mapper connu ne sont pas encore impl<EFBFBD>ment<EFBFBD>.
|
||||||
|
|
||||||
Q: Oui puis-je trouver le jeux xxxx ?
|
Q: Oui puis-je trouver le jeux xxxx ?
|
||||||
R: Désolé, je ne donne aucun lien menant, ni aucune ROM de jeux commerciaux.
|
R: D<EFBFBD>sol<EFBFBD>, je ne donne aucun lien menant, ni aucune ROM de jeux commerciaux.
|
||||||
N'oubliez pas que les personnes vous disant que vous avez le droit de ne garder que
|
N'oubliez pas que les personnes vous disant que vous avez le droit de ne garder
|
||||||
24h une ROM, vous raconte absolument n'importe quoi. Il est absolument *ILLEGAL* de
|
que 24h une ROM, vous raconte absolument n'importe quoi. Il est absolument
|
||||||
posseder la ROM d'un jeu que vous ne possedez pas officiellement.
|
*ILLEGAL* de posseder la ROM d'un jeu que vous ne possedez pas officiellement.
|
||||||
|
|
||||||
Q: XXX donne l'air de fonctionner, pourtant il ne reagis pas au touches
|
Q: XXX donne l'air de fonctionner, pourtant il ne reagis pas au touches
|
||||||
R: Cet emulateur n'est pas parfait. Certain jeux/demo demandent un fonctionnement
|
R: Cet emulateur n'est pas parfait. Certain jeux/demo demandent un
|
||||||
tres proche de celui de la console originale, ce que TI-NESulator est encore loin
|
fonctionnement tres proche de celui de la console originale, ce que TI-NESulator
|
||||||
d'arriver a faire
|
est encore loin d'arriver a faire.
|
||||||
|
|
||||||
Q:J'ai des problèmes graphiques avec XXXX
|
Q: J'ai des probl<EFBFBD>mes graphiques avec XXXX
|
||||||
R:Cf réponse-ci dessus
|
R: Cf r<EFBFBD>ponse-ci dessus
|
||||||
|
|
||||||
Q: C'est lent :(
|
Q: C'est lent :(
|
||||||
R: Désolé. Le code est toujours en cours de devellopement. Si vous trouvez trop lent,
|
R: D<EFBFBD>sol<EFBFBD>. Le code est toujours en cours de devellopement. Si vous trouvez trop
|
||||||
attendez la prochaine version une surprise vous y attendra peut-etre !
|
lent, attendez la prochaine version une surprise vous y attendra peut-etre !
|
||||||
|
|
||||||
7 -> En cas de problème
|
7 -> En cas de probl<EFBFBD>me
|
||||||
|
|
||||||
a) Un jeu indiqué compatible ne fonctionne pas (ie "Mapper non supporté")
|
a) Un jeu indiqu<EFBFBD> compatible ne fonctionne pas (ie "Mapper non support<EFBFBD>")
|
||||||
|
|
||||||
Alors plusieurs possibilité, soit vous avez une autre version du jeu officielle
|
Alors plusieurs possibilit<EFBFBD>, soit vous avez une autre version du jeu officielle
|
||||||
ou non, cela peut changer par exemple le mapper utilisé par le jeux, soit vous
|
ou non, cela peut changer par exemple le mapper utilis<EFBFBD> par le jeux, soit vous
|
||||||
avez recuperer un "bad dump", c'est a dire plus simplement une rom foireuse.
|
avez recuperer un "bad dump", c'est a dire plus simplement une rom foireuse.
|
||||||
|
|
||||||
Dans ces deux cas essayez d'en recuperer une autre version.
|
Dans ces deux cas essayez d'en recuperer une autre version.
|
||||||
|
|
||||||
b) TI-NESulator à planté !!
|
b) TI-NESulator <EFBFBD> plant<EFBFBD> !!
|
||||||
Si cela arrive regulierement pour le meme jeu et au meme endroit faites moi un
|
Si cela arrive regulierement pour le meme jeu et au meme endroit faites moi un
|
||||||
crash report avec les information que TI-NESulator vous met dans la console
|
crash report avec les information que TI-NESulator vous met dans la console
|
||||||
(pour pouvoir la copier tranquillement il faut lancer a partir d'une console
|
(pour pouvoir la copier tranquillement il faut lancer a partir d'une console
|
||||||
et pas faire glisser la rom sur l'executable)
|
et pas faire glisser la rom sur l'executable)
|
||||||
|
|
||||||
N'oubliez pas de préciser le nom complet du jeu, la taille du fichier et toutes
|
N'oubliez pas de pr<EFBFBD>ciser le nom complet du jeu, la taille du fichier et toutes
|
||||||
les infos que vous trouverez pertinante (manipulation a faire etc...)
|
les infos que vous trouverez pertinante (manipulation a faire etc...)
|
||||||
|
|
||||||
|
|
||||||
8 -> Remerciement
|
8 -> Remerciement
|
||||||
|
|
||||||
PpHd pour PreOS, et SMA :)
|
Loopy, Y0Shi, Marrat Fayzullin, et bcp d'autre pour la documentation technique
|
||||||
TiMad Membre de la XTeam sans lequel XLib existerait pas.
|
sur la NES
|
||||||
nEUrOO Membre de la XTeam sans lequel XLib existerait pas.
|
|
||||||
|
|
||||||
Loopy, Y0Shi,
|
|
||||||
Marrat Fayzullin,
|
|
||||||
et bcp d'autre pour la documentation technique sur la NES
|
|
||||||
|
|
||||||
Ainsi que tout ceux que j'ai pu oublier
|
Ainsi que tout ceux que j'ai pu oublier
|
||||||
|
|
||||||
9 -> Litérature
|
9 -> Lit<EFBFBD>rature
|
||||||
|
|
||||||
[A faire.]
|
[A faire.]
|
||||||
|
|
||||||
mais lien rapide :
|
mais lien rapide :
|
||||||
|
|
||||||
http://www.nesdev.org
|
http://nesdev.parodius.com/
|
||||||
|
http://nesdevwiki.org/
|
||||||
|
|
||||||
|
|
||||||
10 -> Comment me contacter ?
|
10 -> Comment me contacter ?
|
||||||
s
|
|
||||||
Vous pouvez me contacter grace au forum yAronet
|
|
||||||
http://www.yaronet.com
|
|
||||||
|
|
||||||
Et surtout grace au lien suivant :
|
Vous pouvez me contacter grace au forum yAronet: http://www.yaronet.com
|
||||||
http://www.yaronet.com/posts.php?sl=&s=2339
|
|
||||||
|
|
||||||
Vous pouvez aussi me joindre par mail en m'écrivant à "godzil chez godzil point net"
|
Et surtout grace au lien suivant : http://www.yaronet.com/posts.php?sl=&s=2339
|
||||||
Vous pouvez aussi essayer de visiter un de mes sites :
|
|
||||||
http://www.godzil.net
|
Vous pouvez aussi me joindre par mail en m'<27>crivant <20>
|
||||||
|
"godzil chez godzil point net"
|
||||||
|
Vous pouvez aussi essayer de visiter mon site : http://www.godzil.net
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
$Id: LisezMoi.txt 17 2007-03-27 09:25:23Z mtrapier $
|
$Id$
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
12
doc/TODO.txt
12
doc/TODO.txt
@@ -1,7 +1,15 @@
|
|||||||
07/10/2007 V0.30 part 2
|
25/02/2008
|
||||||
|
- Finish th Quick6502 C project to merge it into TI-NESulator [ ]
|
||||||
|
- Extract graphic primitive to be less dependent of Allegro [ ]
|
||||||
|
- Rewrite sound engine [ ]
|
||||||
|
|
||||||
|
07/10/2007
|
||||||
- Remerge old PPU debug utilities in real plugin form [ ]
|
- Remerge old PPU debug utilities in real plugin form [ ]
|
||||||
- Change the make util for UNIX. Maybe cmake ? [ ]
|
- Change the make util for UNIX. Maybe cmake ? [ ]
|
||||||
- Cleanup os/win32 folder [ ]
|
- Cleanup os/win32 folder [ ]
|
||||||
- Thinks about a better svn repository (Maybe a dedibox is a good choice?)
|
- Thinks about a better svn repository (Maybe a dedibox is a good choice?)
|
||||||
[ ]
|
[X]
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$Id$
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
1
external/coveralls-cmake
vendored
Submodule
1
external/coveralls-cmake
vendored
Submodule
Submodule external/coveralls-cmake added at e37d5b8674
1
external/glfw
vendored
Submodule
1
external/glfw
vendored
Submodule
Submodule external/glfw added at 525ad7bfb8
106
src/CMakeLists.txt
Normal file
106
src/CMakeLists.txt
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Configurations variables
|
||||||
|
##########################
|
||||||
|
set(PPU_ISPAL OFF CACHE BOOL "When switch to ON the PPU is in PAL mode, else it will act as a NTSC one.")
|
||||||
|
set(Q6502_DEBUGGER OFF CACHE BOOL "Activate the Quick6502 debugger?")
|
||||||
|
set(USE_SOUND OFF CACHE BOOL "Activate the sound?")
|
||||||
|
set(DETECT_BUS_CONFLICT OFF CACHE BOOL "Activate the bus conflit detector? (Could slow down the emulator a lot.)")
|
||||||
|
|
||||||
|
set(USE_EFENCE OFF CACHE BOOL "Use electricfence memory debugger?")
|
||||||
|
set(USE_PROFILING OFF CACHE BOOL "Use profiling tools? (Will slow down a lot.)")
|
||||||
|
|
||||||
|
set(USE_ALLEGRO ON CACHE BOOL "Use Allegro backend")
|
||||||
|
|
||||||
|
option(COVERALLS "Generate coveralls data" OFF)
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Link & Compile flags
|
||||||
|
##########################
|
||||||
|
|
||||||
|
set (CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Werror ${PLATFORM_FLAGS}")
|
||||||
|
set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Werror ${PLATFORM_FLAGS}")
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake)
|
||||||
|
|
||||||
|
add_definitions (-DNO_DECIMAL)
|
||||||
|
|
||||||
|
if (PPU_ISPAL)
|
||||||
|
add_definitions (-DISPAL)
|
||||||
|
else (PPU_ISPAL)
|
||||||
|
add_definitions (-DISNTSC)
|
||||||
|
endif (PPU_ISPAL)
|
||||||
|
|
||||||
|
if (Q6502_DEBUGGER)
|
||||||
|
add_definitions (-DDEBUG)
|
||||||
|
endif (Q6502_DEBUGGER)
|
||||||
|
|
||||||
|
if (USE_SOUND)
|
||||||
|
add_definitions (-DUSE_SOUND)
|
||||||
|
endif (USE_SOUND)
|
||||||
|
|
||||||
|
if (DETECT_BUS_CONFLICT)
|
||||||
|
add_definitions (-DDETECT_BUS_CONFLICT)
|
||||||
|
endif (DETECT_BUS_CONFLICT)
|
||||||
|
|
||||||
|
if (USE_PROFILING)
|
||||||
|
if (CMAKE_BUILD_TYPE MATCHES Rel)
|
||||||
|
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Debug info is forced" FORCE)
|
||||||
|
else(CMAKE_BUILD_TYPE MATCHES Rel)
|
||||||
|
SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Debug info is forced" FORCE)
|
||||||
|
endif(CMAKE_BUILD_TYPE MATCHES Rel)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS -pg)
|
||||||
|
endif (USE_PROFILING)
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
add_definitions (-DRUN_COVERAGE)
|
||||||
|
include(Coveralls)
|
||||||
|
coveralls_turn_on_coverage()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
add_subdirectory(apu)
|
||||||
|
add_subdirectory(corecpu)
|
||||||
|
add_subdirectory(mappersmanager)
|
||||||
|
add_subdirectory(memorymanager)
|
||||||
|
add_subdirectory(pluginsmanager)
|
||||||
|
add_subdirectory(ppu)
|
||||||
|
|
||||||
|
|
||||||
|
if (TARGET_TI68k)
|
||||||
|
add_subdirectory(os/ti68k)
|
||||||
|
elseif (WIN32)
|
||||||
|
add_subdirectory(os/win32)
|
||||||
|
else (TARGET_TI68k)
|
||||||
|
add_subdirectory(os/unix)
|
||||||
|
endif (TARGET_TI68k)
|
||||||
|
|
||||||
|
find_library(PTHREADLIB pthread)
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
set(COVERAGE_SRCS src/main.c src/paddle.c src/NESCarts.c ${COVERAGE_SRCS})
|
||||||
|
|
||||||
|
# Create the coveralls target.
|
||||||
|
coveralls_setup(
|
||||||
|
"${COVERAGE_SRCS}" # The source files.
|
||||||
|
ON # If we should upload.
|
||||||
|
) # (Optional) Alternate project cmake module path.
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(tines main.c paddle.c NESCarts.c)
|
||||||
|
target_link_libraries(tines apu corecpu mappermanager memorymanager pluginsmanager ppu oslib ${PTHREADLIB})
|
||||||
|
|
||||||
|
add_test(NAME tines_test COMMAND $<TARGET_FILE:tines> ${PROJECT_SOURCE_DIR}/data/bad_apple_2.nes)
|
||||||
@@ -3,29 +3,39 @@
|
|||||||
* NESCart.c
|
* NESCart.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/NESCarts.c $
|
* $HeadURL$
|
||||||
* $Revision: 50 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "include/NESCarts.h"
|
/* System Headers */
|
||||||
#include "include/mappers/manager.h"
|
#if !defined(__TIGCC__) && !defined(__GCC4TI__) && !defined(__GTC__)
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
/* Plateform dependent function */
|
#else /* Support for TI-68k compilation */
|
||||||
void *LoadFilePtr(char * filename);
|
|
||||||
|
#define TIGCC_COMPAT
|
||||||
|
#include <tigcclib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* TI-NES headers */
|
||||||
|
#include <os_dependent.h>
|
||||||
|
#include <NESCarts.h>
|
||||||
|
#include <os_dependent.h>
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
void DumpCartProperties(FILE *out, NesCart * cart)
|
void DumpCartProperties(FILE *out, NesCart * cart)
|
||||||
{
|
{
|
||||||
fprintf(out,
|
console_printf(Console_Verbose,
|
||||||
"'%s' informations:\n"
|
"'%s' informations:\n"
|
||||||
" Total ROM Size : 0x%06X | Total VROM Size : 0x%06X\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"
|
||||||
@@ -43,12 +53,12 @@ void DumpCartProperties(FILE *out, NesCart * cart)
|
|||||||
|
|
||||||
int LoadCart(const char *filename, NesCart * cart)
|
int LoadCart(const char *filename, NesCart * cart)
|
||||||
{
|
{
|
||||||
byte buffer[6];
|
char buffer[6];
|
||||||
/* Load the cart into memory */
|
/* Load the cart into memory */
|
||||||
cart->File = (byte *)LoadFilePtr(filename);
|
cart->File = (byte *)LoadFilePtr((char *)filename);
|
||||||
|
|
||||||
|
|
||||||
if (cart->File == -1)
|
if ((cart->File == NULL) || (cart->File == MAP_FAILED))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
|
sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
|
||||||
@@ -57,14 +67,11 @@ int LoadCart(const char *filename, NesCart * cart)
|
|||||||
if (memcmp(cart->File, buffer, 4))
|
if (memcmp(cart->File, buffer, 4))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((cart->File == NULL) || (cart->File == -1))
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
printf("\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"
|
||||||
@@ -83,7 +90,7 @@ int LoadCart(const char *filename, NesCart * cart)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now fill the structure */
|
/* Now fill the structure */
|
||||||
cart->FileName = filename;
|
cart->FileName = (char *)filename;
|
||||||
|
|
||||||
cart->PROMSize = cart->File[4] * 16 * 1024; /* Size of PROM */
|
cart->PROMSize = cart->File[4] * 16 * 1024; /* Size of PROM */
|
||||||
cart->VROMSize = cart->File[5] * 8 * 1024; /* Size of VROM */
|
cart->VROMSize = cart->File[5] * 8 * 1024; /* Size of VROM */
|
||||||
@@ -92,7 +99,7 @@ int LoadCart(const char *filename, NesCart * cart)
|
|||||||
/* 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)
|
||||||
{
|
{
|
||||||
printf("\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"
|
||||||
|
|||||||
13
src/apu/CMakeLists.txt
Normal file
13
src/apu/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
add_library(apu SndUnixT.c Sound.c)
|
||||||
|
#add_library(apu SndAlleg.c Sound.c)
|
||||||
@@ -1,18 +1,28 @@
|
|||||||
/** EMULib Emulation Library *********************************/
|
/*
|
||||||
/** **/
|
* Allegro Sound Driver for EMULib Sound system - The TI-NESulator Project
|
||||||
/** SndUnix.c **/
|
* SndAlleg.C
|
||||||
/** **/
|
*
|
||||||
/** This file contains standard sound generation routines **/
|
* Created by Manoel Trapier
|
||||||
/** for Unix using /dev/dsp and /dev/audio. **/
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
/** **/
|
*
|
||||||
/** Copyright (C) Marat Fayzullin 1996-2002 **/
|
* $LastChangedDate$
|
||||||
/** You are not allowed to distribute this software **/
|
* $Author$
|
||||||
/** commercially. Please, notify me, if you make any **/
|
* $HeadURL$
|
||||||
/** changes to this file. **/
|
* $Revision$
|
||||||
/*************************************************************/
|
*
|
||||||
#include "Sound.h"
|
*/
|
||||||
|
#include <Sound.h>
|
||||||
|
|
||||||
|
/* Allegro includes */
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define USE_CONSOLE
|
||||||
|
#include <Allegro/allegro.h>
|
||||||
|
#else
|
||||||
|
#define USE_CONSOLE
|
||||||
#include <allegro.h>
|
#include <allegro.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -27,21 +37,20 @@
|
|||||||
AUDIOSTREAM *stream;
|
AUDIOSTREAM *stream;
|
||||||
|
|
||||||
static pthread_t ThreadID;
|
static pthread_t ThreadID;
|
||||||
static int SoundFD;
|
|
||||||
static int SoundRate = 0;
|
static int SoundRate = 0;
|
||||||
static int MasterVolume = 64;
|
static int MasterVolume = 64;
|
||||||
static int MasterSwitch = (1<<SND_CHANNELS)-1;
|
static int MasterSwitch = (1<<SND_CHANNELS)-1;
|
||||||
static int LoopFreq = 25;
|
static int LoopFreq = 25;
|
||||||
static int NoiseGen = 1;
|
static int NoiseGen = 1;
|
||||||
static int Suspended = 0;
|
static int Suspended = 0;
|
||||||
|
static int SoundRun = 0;
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
int Type; /* Channel type (SND_*) */
|
int Type; /* Channel type (SND_*) */
|
||||||
int Freq; /* Channel frequency (Hz) */
|
int Freq; /* Channel frequency (Hz) */
|
||||||
int Volume; /* Channel volume (0..255) */
|
int Volume; /* Channel volume (0..255) */
|
||||||
|
|
||||||
signed char *Data; /* Wave data (-128..127 each) */
|
const signed char *Data; /* Wave data (-128..127 each) */
|
||||||
int Length; /* Wave length in Data */
|
int Length; /* Wave length in Data */
|
||||||
int Rate; /* Wave playback rate (or 0Hz) */
|
int Rate; /* Wave playback rate (or 0Hz) */
|
||||||
int Pos; /* Wave current position in Data */
|
int Pos; /* Wave current position in Data */
|
||||||
@@ -49,7 +58,7 @@ static struct
|
|||||||
int Count; /* Phase counter */
|
int Count; /* Phase counter */
|
||||||
} CH[SND_CHANNELS];
|
} CH[SND_CHANNELS];
|
||||||
|
|
||||||
static void UnixSetWave(int Channel,signed char *Data,int Length,int Rate);
|
static void UnixSetWave(int Channel,const signed char *Data,int Length,int Rate);
|
||||||
static void UnixSetSound(int Channel,int NewType);
|
static void UnixSetSound(int Channel,int NewType);
|
||||||
static void UnixDrum(int Type,int Force);
|
static void UnixDrum(int Type,int Force);
|
||||||
static void UnixSetChannels(int Volume,int Switch);
|
static void UnixSetChannels(int Volume,int Switch);
|
||||||
@@ -89,6 +98,7 @@ static void *DSPLoop(void *Arg)
|
|||||||
unsigned char *Buf;
|
unsigned char *Buf;
|
||||||
register int J,I,K,L,M,N,L1,L2,A1,A2,V;
|
register int J,I,K,L,M,N,L1,L2,A1,A2,V;
|
||||||
int FreqCount;
|
int FreqCount;
|
||||||
|
N = L = A2 = 0;
|
||||||
|
|
||||||
for(J=0;J<SND_CHANNELS;J++)
|
for(J=0;J<SND_CHANNELS;J++)
|
||||||
{
|
{
|
||||||
@@ -262,8 +272,10 @@ static void *DSPLoop(void *Arg)
|
|||||||
for(I=0;I<SND_BUFSIZE;I++)
|
for(I=0;I<SND_BUFSIZE;I++)
|
||||||
{
|
{
|
||||||
L2=L1+K;
|
L2=L1+K;
|
||||||
Wave[I]+= L1&0x2000?V:-V /*(L2&0x8000? V:0):(L2&0x8000? 0:-V)*/;
|
Wave[I]+= L1&0x8000?V:-V /*(L2&0x8000? V:0):(L2&0x8000? 0:-V)*/;
|
||||||
L1=L2;
|
L1=L2;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
CH[J].Count=L1;
|
CH[J].Count=L1;
|
||||||
break;
|
break;
|
||||||
@@ -313,14 +325,14 @@ int InitSound(int Rate,int Verbose)
|
|||||||
|
|
||||||
if (install_sound(DIGI_AUTODETECT, MIDI_NONE, "") != 0)
|
if (install_sound(DIGI_AUTODETECT, MIDI_NONE, "") != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s!\n", allegro_error);
|
console_printf(Console_Error, "%s!\n", allegro_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stream = play_audio_stream(SND_BUFSIZE, 8, FALSE, Rate, 255, 128);
|
stream = play_audio_stream(SND_BUFSIZE, 8, FALSE, Rate, 255, 128);
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
fprintf(stderr, "Error creating audio stream!\n");
|
console_printf(Console_Error, "Error creating audio stream!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +343,7 @@ int InitSound(int Rate,int Verbose)
|
|||||||
if(!(Rate=OpenSoundDevice(Rate,Verbose))) return(0);
|
if(!(Rate=OpenSoundDevice(Rate,Verbose))) return(0);
|
||||||
|
|
||||||
/* Create DSPLoop() thread */
|
/* Create DSPLoop() thread */
|
||||||
if(Verbose) printf(" Creating thread...");
|
if(Verbose) console_printf(Console_Default, " Creating thread...");
|
||||||
if(pthread_create(&ThreadID,0,DSPLoop,0))
|
if(pthread_create(&ThreadID,0,DSPLoop,0))
|
||||||
{ if(Verbose) puts("FAILED");return(0); }
|
{ if(Verbose) puts("FAILED");return(0); }
|
||||||
|
|
||||||
@@ -339,6 +351,7 @@ int InitSound(int Rate,int Verbose)
|
|||||||
pthread_detach(ThreadID);
|
pthread_detach(ThreadID);
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
|
SoundRun = 1;
|
||||||
if(Verbose) puts("OK");
|
if(Verbose) puts("OK");
|
||||||
return(SoundRate=Rate);
|
return(SoundRate=Rate);
|
||||||
}
|
}
|
||||||
@@ -348,10 +361,13 @@ int InitSound(int Rate,int Verbose)
|
|||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
void TrashSound(void)
|
void TrashSound(void)
|
||||||
{
|
{
|
||||||
StopSound();
|
if (SoundRun == 1)
|
||||||
printf("%s: Kill thread...\n", __func__);
|
{
|
||||||
if(ThreadID) pthread_cancel(ThreadID);
|
StopSound();
|
||||||
|
console_printf(Console_Default, "%s: Kill thread...\n", __func__);
|
||||||
|
if(ThreadID) pthread_cancel(ThreadID);
|
||||||
|
}
|
||||||
|
SoundRun = 0;
|
||||||
SoundRate = 0;
|
SoundRate = 0;
|
||||||
ThreadID = 0;
|
ThreadID = 0;
|
||||||
}
|
}
|
||||||
@@ -397,7 +413,7 @@ void UnixSetSound(int Channel,int NewType)
|
|||||||
/** waveform to be an instrument or set it to the waveform **/
|
/** waveform to be an instrument or set it to the waveform **/
|
||||||
/** own playback rate. **/
|
/** own playback rate. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
void UnixSetWave(int Channel,signed char *Data,int Length,int Rate)
|
void UnixSetWave(int Channel,const signed char *Data,int Length,int Rate)
|
||||||
{
|
{
|
||||||
if((Channel<0)||(Channel>=SND_CHANNELS)||(Length<=0)) return;
|
if((Channel<0)||(Channel>=SND_CHANNELS)||(Length<=0)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
/** commercially. Please, notify me, if you make any **/
|
/** commercially. Please, notify me, if you make any **/
|
||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
#ifdef UNIX
|
//#include "Sound.h"
|
||||||
|
|
||||||
#include "Sound.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -21,6 +19,8 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
#if 0
|
||||||
#ifdef SUN_AUDIO
|
#ifdef SUN_AUDIO
|
||||||
|
|
||||||
#include <sys/audioio.h>
|
#include <sys/audioio.h>
|
||||||
@@ -106,7 +106,7 @@ static struct
|
|||||||
int Count; /* Phase counter */
|
int Count; /* Phase counter */
|
||||||
} CH[SND_CHANNELS];
|
} CH[SND_CHANNELS];
|
||||||
|
|
||||||
static void UnixSetWave(int Channel,signed char *Data,int Length,int Rate);
|
static void UnixSetWave(int Channel, signed char *Data,int Length,int Freq);
|
||||||
static void UnixSetSound(int Channel,int NewType);
|
static void UnixSetSound(int Channel,int NewType);
|
||||||
static void UnixDrum(int Type,int Force);
|
static void UnixDrum(int Type,int Force);
|
||||||
static void UnixSetChannels(int Volume,int Switch);
|
static void UnixSetChannels(int Volume,int Switch);
|
||||||
@@ -135,7 +135,7 @@ static int OpenSoundDevice(int Rate,int Verbose)
|
|||||||
|
|
||||||
#ifdef SUN_AUDIO
|
#ifdef SUN_AUDIO
|
||||||
|
|
||||||
if(Verbose) printf(" Opening /dev/audio...");
|
if(Verbose) console_printf(Console_Default, " Opening /dev/audio...");
|
||||||
if((SoundFD=open("/dev/audio",O_WRONLY | O_NONBLOCK))==-1)
|
if((SoundFD=open("/dev/audio",O_WRONLY | O_NONBLOCK))==-1)
|
||||||
{
|
{
|
||||||
if(Verbose) puts("FAILED");
|
if(Verbose) puts("FAILED");
|
||||||
@@ -150,13 +150,13 @@ static int OpenSoundDevice(int Rate,int Verbose)
|
|||||||
#else /* SUN_AUDIO */
|
#else /* SUN_AUDIO */
|
||||||
|
|
||||||
/* At first, we need to open /dev/dsp: */
|
/* At first, we need to open /dev/dsp: */
|
||||||
if(Verbose) printf(" Opening /dev/dsp...");
|
if(Verbose) console_printf(Console_Default, " Opening /dev/dsp...");
|
||||||
I=((SoundFD=open("/dev/dsp",O_WRONLY))<0);
|
I=((SoundFD=open("/dev/dsp",O_WRONLY))<0);
|
||||||
|
|
||||||
/* Set 8-bit sound */
|
/* Set 8-bit sound */
|
||||||
if(!I)
|
if(!I)
|
||||||
{
|
{
|
||||||
if(Verbose) printf("OK\n Setting mode: 8bit...");
|
if(Verbose) console_printf(Console_Default, "OK\n Setting mode: 8bit...");
|
||||||
J=AFMT_U8;
|
J=AFMT_U8;
|
||||||
I=(ioctl(SoundFD,SNDCTL_DSP_SETFMT,&J)<0);
|
I=(ioctl(SoundFD,SNDCTL_DSP_SETFMT,&J)<0);
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ static int OpenSoundDevice(int Rate,int Verbose)
|
|||||||
/* Set mono sound */
|
/* Set mono sound */
|
||||||
if(!I)
|
if(!I)
|
||||||
{
|
{
|
||||||
if(Verbose) printf("mono...");
|
if(Verbose) console_printf(Console_Default, "mono...");
|
||||||
J=0;
|
J=0;
|
||||||
I=(ioctl(SoundFD,SNDCTL_DSP_STEREO,&J)<0);
|
I=(ioctl(SoundFD,SNDCTL_DSP_STEREO,&J)<0);
|
||||||
}
|
}
|
||||||
@@ -172,9 +172,9 @@ static int OpenSoundDevice(int Rate,int Verbose)
|
|||||||
/* Set sampling rate */
|
/* Set sampling rate */
|
||||||
if(!I)
|
if(!I)
|
||||||
{
|
{
|
||||||
if(Verbose) printf("OK\n Setting sampling rate: %dHz...",Rate);
|
if(Verbose) console_printf(Console_Default, "OK\n Setting sampling rate: %dHz...",Rate);
|
||||||
I=(ioctl(SoundFD,SNDCTL_DSP_SPEED,&Rate)<0);
|
I=(ioctl(SoundFD,SNDCTL_DSP_SPEED,&Rate)<0);
|
||||||
if(Verbose) printf("(got %dHz)...",Rate);
|
if(Verbose) console_printf(Console_Default, "(got %dHz)...",Rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Here we set the number of buffers to use */
|
/* Here we set the number of buffers to use */
|
||||||
@@ -221,6 +221,9 @@ static void *DSPLoop(void *Arg)
|
|||||||
unsigned char Buf[SND_BUFSIZE];
|
unsigned char Buf[SND_BUFSIZE];
|
||||||
register int J,I,K,L,M,N,L1,L2,A1,A2,V;
|
register int J,I,K,L,M,N,L1,L2,A1,A2,V;
|
||||||
int FreqCount;
|
int FreqCount;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
L = N = A2 = 0;
|
||||||
|
|
||||||
for(J=0;J<SND_CHANNELS;J++)
|
for(J=0;J<SND_CHANNELS;J++)
|
||||||
{
|
{
|
||||||
@@ -421,7 +424,7 @@ static void *DSPLoop(void *Arg)
|
|||||||
/* We'll block here until next DMA buffer becomes free. It happens
|
/* We'll block here until next DMA buffer becomes free. It happens
|
||||||
** once per (1<<SND_BITS)/SoundRate seconds.
|
** once per (1<<SND_BITS)/SoundRate seconds.
|
||||||
*/
|
*/
|
||||||
write(SoundFD,Buf,SND_BUFSIZE);
|
ret = write(SoundFD,Buf,SND_BUFSIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,7 +465,7 @@ int InitSound(int Rate,int Verbose)
|
|||||||
if(!(Rate=OpenSoundDevice(Rate,Verbose))) return(0);
|
if(!(Rate=OpenSoundDevice(Rate,Verbose))) return(0);
|
||||||
|
|
||||||
/* Create DSPLoop() thread */
|
/* Create DSPLoop() thread */
|
||||||
if(Verbose) printf(" Creating thread...");
|
if(Verbose) console_printf(Console_Default, " Creating thread...");
|
||||||
if(pthread_create(&ThreadID,0,DSPLoop,0))
|
if(pthread_create(&ThreadID,0,DSPLoop,0))
|
||||||
{ if(Verbose) puts("FAILED");return(0); }
|
{ if(Verbose) puts("FAILED");return(0); }
|
||||||
|
|
||||||
@@ -480,9 +483,9 @@ int InitSound(int Rate,int Verbose)
|
|||||||
void TrashSound(void)
|
void TrashSound(void)
|
||||||
{
|
{
|
||||||
StopSound();
|
StopSound();
|
||||||
printf("%s: Kill thread...\n", __func__);
|
console_printf(Console_Default, "%s: Kill thread...\n", __func__);
|
||||||
if(ThreadID) pthread_cancel(ThreadID);
|
if(ThreadID) pthread_cancel(ThreadID);
|
||||||
printf("%s: close /dev/xxx ...\n", __func__);
|
console_printf(Console_Default, "%s: close /dev/xxx ...\n", __func__);
|
||||||
if(SoundFD!=-1) close(SoundFD);
|
if(SoundFD!=-1) close(SoundFD);
|
||||||
|
|
||||||
SoundRate = 0;
|
SoundRate = 0;
|
||||||
@@ -531,13 +534,13 @@ void UnixSetSound(int Channel,int NewType)
|
|||||||
/** waveform to be an instrument or set it to the waveform **/
|
/** waveform to be an instrument or set it to the waveform **/
|
||||||
/** own playback rate. **/
|
/** own playback rate. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
void UnixSetWave(int Channel,signed char *Data,int Length,int Rate)
|
void UnixSetWave(int Channel, signed char *Data, int Length, int Freq)
|
||||||
{
|
{
|
||||||
if((Channel<0)||(Channel>=SND_CHANNELS)||(Length<=0)) return;
|
if((Channel<0)||(Channel>=SND_CHANNELS)||(Length<=0)) return;
|
||||||
|
|
||||||
CH[Channel].Type = SND_WAVE;
|
CH[Channel].Type = SND_WAVE;
|
||||||
CH[Channel].Length = Length;
|
CH[Channel].Length = Length;
|
||||||
CH[Channel].Rate = Rate;
|
CH[Channel].Rate = Freq;
|
||||||
CH[Channel].Pos = 0;
|
CH[Channel].Pos = 0;
|
||||||
CH[Channel].Count = 0;
|
CH[Channel].Count = 0;
|
||||||
CH[Channel].Data = Data;
|
CH[Channel].Data = Data;
|
||||||
@@ -550,5 +553,4 @@ void UnixDrum(int Type,int Force)
|
|||||||
{
|
{
|
||||||
/* This function is currently empty */
|
/* This function is currently empty */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif /* UNIX */
|
|
||||||
@@ -11,6 +11,13 @@
|
|||||||
/** commercially. Please, notify me, if you make any **/
|
/** commercially. Please, notify me, if you make any **/
|
||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
|
/*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -29,7 +36,7 @@ struct SndDriverStruct SndDriver =
|
|||||||
(void (*)(int,int))0,
|
(void (*)(int,int))0,
|
||||||
(void (*)(int,int))0,
|
(void (*)(int,int))0,
|
||||||
(void (*)(int,int,int))0,
|
(void (*)(int,int,int))0,
|
||||||
(void (*)(int,const signed char *,int,int))0,
|
(void (*)(int,signed char *,int,int))0,
|
||||||
(const signed char *(*)(int))0
|
(const signed char *(*)(int))0
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -160,7 +167,7 @@ void SetChannels(int Volume,int Switch)
|
|||||||
/** waveform to be an instrument or set it to the waveform **/
|
/** waveform to be an instrument or set it to the waveform **/
|
||||||
/** own playback rate. **/
|
/** own playback rate. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
void SetWave(int Channel,const signed char *Data,int Length,int Rate)
|
void SetWave(int Channel,signed char *Data,int Length,int Rate)
|
||||||
{
|
{
|
||||||
if((Channel<0)||(Length<=0)) return;
|
if((Channel<0)||(Length<=0)) return;
|
||||||
|
|
||||||
|
|||||||
16
src/corecpu/CMakeLists.txt
Normal file
16
src/corecpu/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
set(COVERAGE_SRCS src/corecpu/corecpu.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(corecpu corecpu.c)
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/*
|
/*
|
||||||
* $LastChangedDate: 2007-05-31 18:01:41 +0200 (jeu, 31 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/Codes.h $
|
* $HeadURL$
|
||||||
* $Revision: 57 $
|
* $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case 0x10:
|
case 0x10:
|
||||||
@@ -91,7 +91,7 @@ break; /* BVS * REL */
|
|||||||
case 0x40:
|
case 0x40:
|
||||||
|
|
||||||
M_POP(R->P);
|
M_POP(R->P);
|
||||||
R->P |= R_FLAG;
|
//R->P |= R_FLAG;
|
||||||
M_POP(R->PC.B.l);
|
M_POP(R->PC.B.l);
|
||||||
M_POP(R->PC.B.h);
|
M_POP(R->PC.B.h);
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ if ((R->IRequest != INT_NONE) && ((I ^ R->P) & ~I & I_FLAG))
|
|||||||
R->ICount = 1;
|
R->ICount = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
R->P = I | R_FLAG | B_FLAG;
|
R->P = I /*| R_FLAG*/ | B_FLAG;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -835,3 +835,4 @@ case 0x6A:
|
|||||||
M_ROR(R->A);
|
M_ROR(R->A);
|
||||||
break; /* ROR a ACC */
|
break; /* ROR a ACC */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/*
|
/*
|
||||||
* $LastChangedDate: 2007-04-19 18:18:57 +0200 (jeu, 19 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/Debug.c $
|
* $HeadURL$
|
||||||
* $Revision: 43 $
|
* $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "M6502.h"
|
#include "M6502.h"
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include <ppu/ppu.h>
|
#include <ppu/ppu.h>
|
||||||
|
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
#include <memory/manager.h>
|
||||||
#include <Sound.h>
|
#include <Sound.h>
|
||||||
|
|
||||||
#define RDWORD(A) (Rd6502(A+1)*256+Rd6502(A))
|
#define RDWORD(A) (Rd6502(A+1)*256+Rd6502(A))
|
||||||
@@ -38,58 +40,58 @@ void showlastop();
|
|||||||
|
|
||||||
enum Addressing_Modes
|
enum Addressing_Modes
|
||||||
{
|
{
|
||||||
Ac = 0, Il, Im, Ab, Zp, Zx, Zy, Ax, Ay, Rl, Ix, Iy, In, No
|
Ac = 0, Il, Im, Ab, Zp, Zx, Zy, Ax, Ay, Rl, Ix, Iy, In, No
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static byte *mn[] =
|
static char *mn[] =
|
||||||
{
|
{
|
||||||
"adc ", "and ", "asl ", "bcc ", "bcs ", "beq ", "bit ", "bmi ",
|
"adc ", "and ", "asl ", "bcc ", "bcs ", "beq ", "bit ", "bmi ",
|
||||||
"bne ", "bpl ", "brk", "bvc ", "bvs ", "clc", "cld", "cli",
|
"bne ", "bpl ", "brk", "bvc ", "bvs ", "clc", "cld", "cli",
|
||||||
"clv", "cmp ", "cpx ", "cpy ", "dec ", "dex", "dey", "inx",
|
"clv", "cmp ", "cpx ", "cpy ", "dec ", "dex", "dey", "inx",
|
||||||
"iny", "eor ", "inc ", "jmp ", "jsr ", "lda ", "nop ", "ldx ",
|
"iny", "eor ", "inc ", "jmp ", "jsr ", "lda ", "nop ", "ldx ",
|
||||||
"ldy ", "lsr ", "ora ", "pha", "php", "pla", "plp", "rol ",
|
"ldy ", "lsr ", "ora ", "pha", "php", "pla", "plp", "rol ",
|
||||||
"ror ", "rti", "rts", "sbc ", "sta ", "stx ", "sty ", "sec ",
|
"ror ", "rti", "rts", "sbc ", "sta ", "stx ", "sty ", "sec ",
|
||||||
"sed", "sei", "tax", "tay", "txa", "tya", "tsx", "txs"
|
"sed", "sei", "tax", "tay", "txa", "tya", "tsx", "txs"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static byte ad[512] =
|
static byte ad[512] =
|
||||||
{
|
{
|
||||||
10, Il, 34, Ix, No, No, No, No, No, No, 34, Zp, 2, Zp, No, No,
|
10, Il, 34, Ix, No, No, No, No, No, No, 34, Zp, 2, Zp, No, No,
|
||||||
36, Il, 34, Im, 2, Ac, No, No, No, No, 34, Ab, 2, Ab, No, No,
|
36, Il, 34, Im, 2, Ac, No, No, No, No, 34, Ab, 2, Ab, No, No,
|
||||||
9, Rl, 34, Iy, No, No, No, No, No, No, 34, Zx, 2, Zx, No, No,
|
9, Rl, 34, Iy, No, No, No, No, No, No, 34, Zx, 2, Zx, No, No,
|
||||||
13, Il, 34, Ay, No, No, No, No, No, No, 34, Ax, 2, Ax, No, No,
|
13, Il, 34, Ay, No, No, No, No, No, No, 34, Ax, 2, Ax, No, No,
|
||||||
28, Ab, 1, Ix, No, No, No, No, 6, Zp, 1, Zp, 39, Zp, No, No,
|
28, Ab, 1, Ix, No, No, No, No, 6, Zp, 1, Zp, 39, Zp, No, No,
|
||||||
38, Il, 1, Im, 39, Ac, No, No, 6, Ab, 1, Ab, 39, Ab, No, No,
|
38, Il, 1, Im, 39, Ac, No, No, 6, Ab, 1, Ab, 39, Ab, No, No,
|
||||||
7, Rl, 1, Iy, No, No, No, No, No, No, 1, Zx, 39, Zx, No, No,
|
7, Rl, 1, Iy, No, No, No, No, No, No, 1, Zx, 39, Zx, No, No,
|
||||||
47, Il, 1, Ay, No, No, No, No, No, No, 1, Ax, 39, Ax, No, No,
|
47, Il, 1, Ay, No, No, No, No, No, No, 1, Ax, 39, Ax, No, No,
|
||||||
41, Il, 25, Ix, No, No, No, No, No, No, 25, Zp, 33, Zp, No, No,
|
41, Il, 25, Ix, No, No, No, No, No, No, 25, Zp, 33, Zp, No, No,
|
||||||
35, Il, 25, Im, 33, Ac, No, No, 27, Ab, 25, Ab, 33, Ab, No, No,
|
35, Il, 25, Im, 33, Ac, No, No, 27, Ab, 25, Ab, 33, Ab, No, No,
|
||||||
11, Rl, 25, Iy, No, No, No, No, No, No, 25, Zx, 33, Zx, No, No,
|
11, Rl, 25, Iy, No, No, No, No, No, No, 25, Zx, 33, Zx, No, No,
|
||||||
15, Il, 25, Ay, No, No, No, No, No, No, 25, Ax, 33, Ax, No, No,
|
15, Il, 25, Ay, No, No, No, No, No, No, 25, Ax, 33, Ax, No, No,
|
||||||
42, Il, 0, Ix, No, No, No, No, No, No, 0, Zp, 40, Zp, No, No,
|
42, Il, 0, Ix, No, No, No, No, No, No, 0, Zp, 40, Zp, No, No,
|
||||||
37, Il, 0, Im, 40, Ac, No, No, 27, In, 0, Ab, 40, Ab, No, No,
|
37, Il, 0, Im, 40, Ac, No, No, 27, In, 0, Ab, 40, Ab, No, No,
|
||||||
12, Rl, 0, Iy, No, No, No, No, No, No, 0, Zx, 40, Zx, No, No,
|
12, Rl, 0, Iy, No, No, No, No, No, No, 0, Zx, 40, Zx, No, No,
|
||||||
49, Il, 0, Ay, No, No, No, No, No, No, 0, Ax, 40, Ax, No, No,
|
49, Il, 0, Ay, No, No, No, No, No, No, 0, Ax, 40, Ax, No, No,
|
||||||
No, No, 44, Ix, No, No, No, No, 46, Zp, 44, Zp, 45, Zp, No, No,
|
No, No, 44, Ix, No, No, No, No, 46, Zp, 44, Zp, 45, Zp, No, No,
|
||||||
22, Il, No, No, 52, Il, No, No, 46, Ab, 44, Ab, 45, Ab, No, No,
|
22, Il, No, No, 52, Il, No, No, 46, Ab, 44, Ab, 45, Ab, No, No,
|
||||||
3, Rl, 44, Iy, No, No, No, No, 46, Zx, 44, Zx, 45, Zy, No, No,
|
3, Rl, 44, Iy, No, No, No, No, 46, Zx, 44, Zx, 45, Zy, No, No,
|
||||||
53, Il, 44, Ay, 55, Il, No, No, No, No, 44, Ax, No, No, No, No,
|
53, Il, 44, Ay, 55, Il, No, No, No, No, 44, Ax, No, No, No, No,
|
||||||
32, Im, 29, Ix, 31, Im, No, No, 32, Zp, 29, Zp, 31, Zp, No, No,
|
32, Im, 29, Ix, 31, Im, No, No, 32, Zp, 29, Zp, 31, Zp, No, No,
|
||||||
51, Il, 29, Im, 50, Il, No, No, 32, Ab, 29, Ab, 31, Ab, No, No,
|
51, Il, 29, Im, 50, Il, No, No, 32, Ab, 29, Ab, 31, Ab, No, No,
|
||||||
4, Rl, 29, Iy, No, No, No, No, 32, Zx, 29, Zx, 31, Zy, No, No,
|
4, Rl, 29, Iy, No, No, No, No, 32, Zx, 29, Zx, 31, Zy, No, No,
|
||||||
16, Il, 29, Ay, 54, Il, No, No, 32, Ax, 29, Ax, 31, Ay, No, No,
|
16, Il, 29, Ay, 54, Il, No, No, 32, Ax, 29, Ax, 31, Ay, No, No,
|
||||||
19, Im, 17, Ix, No, No, No, No, 19, Zp, 17, Zp, 20, Zp, No, No,
|
19, Im, 17, Ix, No, No, No, No, 19, Zp, 17, Zp, 20, Zp, No, No,
|
||||||
24, Il, 17, Im, 21, Il, No, No, 19, Ab, 17, Ab, 20, Ab, No, No,
|
24, Il, 17, Im, 21, Il, No, No, 19, Ab, 17, Ab, 20, Ab, No, No,
|
||||||
8, Rl, 17, Iy, No, No, No, No, No, No, 17, Zx, 20, Zx, No, No,
|
8, Rl, 17, Iy, No, No, No, No, No, No, 17, Zx, 20, Zx, No, No,
|
||||||
14, Il, 17, Ay, No, No, No, No, No, No, 17, Ax, 20, Ax, No, No,
|
14, Il, 17, Ay, No, No, No, No, No, No, 17, Ax, 20, Ax, No, No,
|
||||||
18, Im, 43, Ix, No, No, No, No, 18, Zp, 43, Zp, 26, Zp, No, No,
|
18, Im, 43, Ix, No, No, No, No, 18, Zp, 43, Zp, 26, Zp, No, No,
|
||||||
23, Il, 43, Im, 30, Il, No, No, 18, Ab, 43, Ab, 26, Ab, No, No,
|
23, Il, 43, Im, 30, Il, No, No, 18, Ab, 43, Ab, 26, Ab, No, No,
|
||||||
5, Rl, 43, Iy, No, No, No, No, No, No, 43, Zx, 26, Zx, No, No,
|
5, Rl, 43, Iy, No, No, No, No, No, No, 43, Zx, 26, Zx, No, No,
|
||||||
48, Il, 43, Ay, No, No, No, No, No, No, 43, Ax, 26, Ax, No, No
|
48, Il, 43, Ay, No, No, No, No, No, No, 43, Ax, 26, Ax, No, No
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -225,8 +227,8 @@ byte Debug6502(M6502 * R)
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
sprintf(S, "");
|
S[0] = 0;
|
||||||
remove_keyboard();
|
remove_keyboard();
|
||||||
|
|
||||||
#ifdef USE_SOUND
|
#ifdef USE_SOUND
|
||||||
StopSound();
|
StopSound();
|
||||||
@@ -274,7 +276,7 @@ byte Debug6502(M6502 * R)
|
|||||||
puts("a : Dump all memory to memory.log");
|
puts("a : Dump all memory to memory.log");
|
||||||
puts("s : Dump sprite table to sprite.log");
|
puts("s : Dump sprite table to sprite.log");
|
||||||
puts("n <nb> : Dump name table <nb> to nt.log");
|
puts("n <nb> : Dump name table <nb> to nt.log");
|
||||||
puts("z : Show lastest opcode executed");
|
puts("z : Dump mapper status");
|
||||||
puts("i : SpriteTable Dump");
|
puts("i : SpriteTable Dump");
|
||||||
puts("g <nb> : Get sprite <nb> info");
|
puts("g <nb> : Get sprite <nb> info");
|
||||||
break;
|
break;
|
||||||
@@ -283,7 +285,7 @@ byte Debug6502(M6502 * R)
|
|||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
case 'Z':
|
case 'Z':
|
||||||
showlastop();
|
mapper_dump(stdout);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'W':
|
case 'W':
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/*
|
/*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/M6502.c $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "M6502.h"
|
#include "M6502.h"
|
||||||
@@ -201,7 +201,7 @@ INLINE byte Op6502(register word A) { return(Page[A>>13][A&0x1FFF]); }
|
|||||||
void Reset6502(M6502 *R)
|
void Reset6502(M6502 *R)
|
||||||
{
|
{
|
||||||
R->A=R->X=R->Y=0x00;
|
R->A=R->X=R->Y=0x00;
|
||||||
R->P=Z_FLAG|R_FLAG;
|
R->P=Z_FLAG;
|
||||||
R->S=0xFF;
|
R->S=0xFF;
|
||||||
R->PC.B.l=Rd6502(0xFFFC);
|
R->PC.B.l=Rd6502(0xFFFC);
|
||||||
R->PC.B.h=Rd6502(0xFFFD);
|
R->PC.B.h=Rd6502(0xFFFD);
|
||||||
@@ -245,7 +245,7 @@ void Int6502(M6502 *R,byte Type)
|
|||||||
R->ICount-=7;
|
R->ICount-=7;
|
||||||
M_PUSH(R->PC.B.h);
|
M_PUSH(R->PC.B.h);
|
||||||
M_PUSH(R->PC.B.l);
|
M_PUSH(R->PC.B.l);
|
||||||
M_PUSH(R->P&~B_FLAG);
|
M_PUSH(R->P & ~(B_FLAG|R_FLAG));
|
||||||
R->P&=~D_FLAG;
|
R->P&=~D_FLAG;
|
||||||
if(R->IAutoReset&&(Type==R->IRequest)) R->IRequest=INT_NONE;
|
if(R->IAutoReset&&(Type==R->IRequest)) R->IRequest=INT_NONE;
|
||||||
if(Type==INT_NMI) J.W=0xFFFA; else { R->P|=I_FLAG;J.W=0xFFFE; }
|
if(Type==INT_NMI) J.W=0xFFFA; else { R->P|=I_FLAG;J.W=0xFFFE; }
|
||||||
@@ -254,6 +254,158 @@ void Int6502(M6502 *R,byte Type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TRACE_EXECUTION
|
||||||
|
|
||||||
|
enum Addressing_Modes
|
||||||
|
{
|
||||||
|
Ac = 0, Il, Im, Ab, Zp, Zx, Zy, Ax, Ay, Rl, Ix, Iy, In, No
|
||||||
|
};
|
||||||
|
|
||||||
|
static char *mnCAP[] =
|
||||||
|
{
|
||||||
|
"ADC", "AND", "ASL", "BCC", "BCS", "BEQ", "BIT", "BMI",
|
||||||
|
"BNE", "BPL", "BRK", "BVC", "BVS", "CLC", "CLD", "CLI",
|
||||||
|
"CLV", "CMP", "CPX", "CPY", "DEC", "DEX", "DEY", "INX",
|
||||||
|
"INY", "EOR", "INC", "JMP", "JSR", "LDA", "NOP", "LDX",
|
||||||
|
"LDY", "LSR", "ORA", "PHA", "PHP", "PLA", "PLP", "ROL",
|
||||||
|
"ROR", "RTI", "RTS", "SBC", "STA", "STX", "STY", "SEC",
|
||||||
|
"SED", "SEI", "TAX", "TAY", "TXA", "TYA", "TSX", "TXS"
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DAsm DAsmCAP
|
||||||
|
|
||||||
|
static byte ad[512] =
|
||||||
|
{
|
||||||
|
10, Il, 34, Ix, No, No, No, No, No, No, 34, Zp, 2, Zp, No, No,
|
||||||
|
36, Il, 34, Im, 2, Ac, No, No, No, No, 34, Ab, 2, Ab, No, No,
|
||||||
|
9, Rl, 34, Iy, No, No, No, No, No, No, 34, Zx, 2, Zx, No, No,
|
||||||
|
13, Il, 34, Ay, No, No, No, No, No, No, 34, Ax, 2, Ax, No, No,
|
||||||
|
28, Ab, 1, Ix, No, No, No, No, 6, Zp, 1, Zp, 39, Zp, No, No,
|
||||||
|
38, Il, 1, Im, 39, Ac, No, No, 6, Ab, 1, Ab, 39, Ab, No, No,
|
||||||
|
7, Rl, 1, Iy, No, No, No, No, No, No, 1, Zx, 39, Zx, No, No,
|
||||||
|
47, Il, 1, Ay, No, No, No, No, No, No, 1, Ax, 39, Ax, No, No,
|
||||||
|
41, Il, 25, Ix, No, No, No, No, No, No, 25, Zp, 33, Zp, No, No,
|
||||||
|
35, Il, 25, Im, 33, Ac, No, No, 27, Ab, 25, Ab, 33, Ab, No, No,
|
||||||
|
11, Rl, 25, Iy, No, No, No, No, No, No, 25, Zx, 33, Zx, No, No,
|
||||||
|
15, Il, 25, Ay, No, No, No, No, No, No, 25, Ax, 33, Ax, No, No,
|
||||||
|
42, Il, 0, Ix, No, No, No, No, No, No, 0, Zp, 40, Zp, No, No,
|
||||||
|
37, Il, 0, Im, 40, Ac, No, No, 27, In, 0, Ab, 40, Ab, No, No,
|
||||||
|
12, Rl, 0, Iy, No, No, No, No, No, No, 0, Zx, 40, Zx, No, No,
|
||||||
|
49, Il, 0, Ay, No, No, No, No, No, No, 0, Ax, 40, Ax, No, No,
|
||||||
|
No, No, 44, Ix, No, No, No, No, 46, Zp, 44, Zp, 45, Zp, No, No,
|
||||||
|
22, Il, No, No, 52, Il, No, No, 46, Ab, 44, Ab, 45, Ab, No, No,
|
||||||
|
3, Rl, 44, Iy, No, No, No, No, 46, Zx, 44, Zx, 45, Zy, No, No,
|
||||||
|
53, Il, 44, Ay, 55, Il, No, No, No, No, 44, Ax, No, No, No, No,
|
||||||
|
32, Im, 29, Ix, 31, Im, No, No, 32, Zp, 29, Zp, 31, Zp, No, No,
|
||||||
|
51, Il, 29, Im, 50, Il, No, No, 32, Ab, 29, Ab, 31, Ab, No, No,
|
||||||
|
4, Rl, 29, Iy, No, No, No, No, 32, Zx, 29, Zx, 31, Zy, No, No,
|
||||||
|
16, Il, 29, Ay, 54, Il, No, No, 32, Ax, 29, Ax, 31, Ay, No, No,
|
||||||
|
19, Im, 17, Ix, No, No, No, No, 19, Zp, 17, Zp, 20, Zp, No, No,
|
||||||
|
24, Il, 17, Im, 21, Il, No, No, 19, Ab, 17, Ab, 20, Ab, No, No,
|
||||||
|
8, Rl, 17, Iy, No, No, No, No, No, No, 17, Zx, 20, Zx, No, No,
|
||||||
|
14, Il, 17, Ay, No, No, No, No, No, No, 17, Ax, 20, Ax, No, No,
|
||||||
|
18, Im, 43, Ix, No, No, No, No, 18, Zp, 43, Zp, 26, Zp, No, No,
|
||||||
|
23, Il, 43, Im, 30, Il, No, No, 18, Ab, 43, Ab, 26, Ab, No, No,
|
||||||
|
5, Rl, 43, Iy, No, No, No, No, No, No, 43, Zx, 26, Zx, No, No,
|
||||||
|
48, Il, 43, Ay, No, No, No, No, No, No, 43, Ax, 26, Ax, No, No
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RDWORD(A) (Rd6502(A+1)*256+Rd6502(A))
|
||||||
|
|
||||||
|
/** DAsm() ****************************************************/
|
||||||
|
/** This function will disassemble a single command and **/
|
||||||
|
/** return the number of bytes disassembled. **/
|
||||||
|
/**************************************************************/
|
||||||
|
int DAsmCAP(char *S, word A)
|
||||||
|
{
|
||||||
|
|
||||||
|
byte J;
|
||||||
|
|
||||||
|
word B, OP, TO;
|
||||||
|
|
||||||
|
|
||||||
|
B = A;
|
||||||
|
OP = Rd6502(B++) * 2;
|
||||||
|
|
||||||
|
|
||||||
|
switch (ad[OP + 1])
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
case Ac:
|
||||||
|
sprintf(S, "%s A", mnCAP[ad[OP]]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Il:
|
||||||
|
sprintf(S, "%s", mnCAP[ad[OP]]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case Rl:
|
||||||
|
J = Rd6502(B++);
|
||||||
|
TO = A + 2 + ((J < 0x80) ? J : (J - 256));
|
||||||
|
|
||||||
|
sprintf(S, "%s $%04x", mnCAP[ad[OP]], TO);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case Im:
|
||||||
|
sprintf(S, "%s #$%02x", mnCAP[ad[OP]], Rd6502(B++));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Zp:
|
||||||
|
sprintf(S, "%s $%02x", mnCAP[ad[OP]], Rd6502(B++));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Zx:
|
||||||
|
sprintf(S, "%s $%02x,X", mnCAP[ad[OP]], Rd6502(B++));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Zy:
|
||||||
|
sprintf(S, "%s $%02x,Y", mnCAP[ad[OP]], Rd6502(B++));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ix:
|
||||||
|
sprintf(S, "%s ($%02x,X)", mnCAP[ad[OP]], Rd6502(B++));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Iy:
|
||||||
|
sprintf(S, "%s ($%02x),Y", mnCAP[ad[OP]], Rd6502(B++));
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case Ab:
|
||||||
|
sprintf(S, "%s $%04x", mnCAP[ad[OP]], RDWORD(B));
|
||||||
|
B += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ax:
|
||||||
|
sprintf(S, "%s $%04x,X", mnCAP[ad[OP]], RDWORD(B));
|
||||||
|
B += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ay:
|
||||||
|
sprintf(S, "%s $%04x,Y", mnCAP[ad[OP]], RDWORD(B));
|
||||||
|
B += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case In:
|
||||||
|
sprintf(S, "%s ($%04x)", mnCAP[ad[OP]], RDWORD(B));
|
||||||
|
B += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
sprintf(S, ".db $%02x; <Invalid OPcode>", OP / 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
return (B - A);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extern unsigned short ScanLine;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Run6502() ************************************************/
|
/** Run6502() ************************************************/
|
||||||
/** This function will run 6502 code until Loop6502() call **/
|
/** This function will run 6502 code until Loop6502() call **/
|
||||||
@@ -264,7 +416,7 @@ word Run6502(M6502 *R)
|
|||||||
{
|
{
|
||||||
register pair J,K;
|
register pair J,K;
|
||||||
register byte I;
|
register byte I;
|
||||||
|
byte nb_of_cycle;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -275,20 +427,67 @@ word Run6502(M6502 *R)
|
|||||||
if(!Debug6502(R)) return(R->PC.W);
|
if(!Debug6502(R)) return(R->PC.W);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
I=Op6502(R->PC.W++);
|
#ifdef TRACE_EXECUTION
|
||||||
R->ICount-=Cycles[I];
|
while(1)
|
||||||
|
{
|
||||||
|
|
||||||
|
static char FA[8] = "NV.BDIZC";
|
||||||
|
char S[128];
|
||||||
|
byte F;
|
||||||
|
int J, I;
|
||||||
|
|
||||||
|
DAsm(S, R->PC.W);
|
||||||
|
|
||||||
|
printf
|
||||||
|
(
|
||||||
|
"AT PC: [%02x - %s]\n",
|
||||||
|
Rd6502(R->PC.W), S
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
I=Op6502(R->PC.W++);
|
||||||
|
nb_of_cycle = Cycles[I];
|
||||||
//#ifdef DEBUG
|
//#ifdef DEBUG
|
||||||
// pushop(I);
|
// pushop(I);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
icount++;
|
icount++;
|
||||||
|
|
||||||
switch(I)
|
switch(I)
|
||||||
{
|
{
|
||||||
#include "Codes.h"
|
#include "Codes.h"
|
||||||
}
|
}
|
||||||
|
#ifdef TRACE_EXECUTION
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
static char FA[8] = "NV.BDIZC";
|
||||||
|
char S[128];
|
||||||
|
byte F;
|
||||||
|
int J, I;
|
||||||
|
|
||||||
|
printf
|
||||||
|
(
|
||||||
|
"A:%02x X:%02x Y:%02x S:%04x, PC:%04x Flags:[",
|
||||||
|
R->A, R->X, R->Y, R->S + 0x0100, R->PC.W
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
for (J = 0, F = R->P; J < 8; J++, F <<= 1)
|
||||||
|
|
||||||
|
printf("%c", F & 0x80 ? FA[J] : '.');
|
||||||
|
|
||||||
|
printf("], Stack[%02x, %02x, %02x], %03d, %03d\n",
|
||||||
|
Rd6502(0x0100 + (byte) (R->S + 1)),
|
||||||
|
Rd6502(0x0100 + (byte) (R->S + 2)),
|
||||||
|
Rd6502(0x0100 + (byte) (R->S + 3)),
|
||||||
|
R->ICount,
|
||||||
|
ScanLine
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
R->ICount-= nb_of_cycle;
|
||||||
/* If cycle counter expired... */
|
/* If cycle counter expired... */
|
||||||
if(R->ICount<=0)
|
if(R->ICount<=0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/*
|
/*
|
||||||
* $LastChangedDate: 2007-04-23 18:55:35 +0200 (lun, 23 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/M6502.h $
|
* $HeadURL$
|
||||||
* $Revision: 45 $
|
* $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef M6502_H
|
#ifndef M6502_H
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/*
|
/*
|
||||||
* $LastChangedDate: 2007-05-24 15:07:13 +0200 (jeu, 24 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/Tables.h $
|
* $HeadURL$
|
||||||
* $Revision: 52 $
|
* $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static byte Cycles[256] =
|
static byte Cycles[256] =
|
||||||
|
|||||||
2255
src/corecpu/corecpu.c
Normal file
2255
src/corecpu/corecpu.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,12 @@
|
|||||||
/** commercially. Please, notify me, if you make any **/
|
/** commercially. Please, notify me, if you make any **/
|
||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
|
/*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
{ -36, 8063 },{ -12, 8063 },{ -3, 8298 },{ 3, 8358 },
|
{ -36, 8063 },{ -12, 8063 },{ -3, 8298 },{ 3, 8358 },
|
||||||
{ 8, 8201 },{ 12, 8063 },{ 15, 8054 },{ 17, 8238 },
|
{ 8, 8201 },{ 12, 8063 },{ 15, 8054 },{ 17, 8238 },
|
||||||
|
|||||||
@@ -3,18 +3,19 @@
|
|||||||
* NESCart.h
|
* NESCart.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/NESCarts.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NESCARTS_H
|
#ifndef NESCARTS_H
|
||||||
#define NESCARTS_H
|
#define NESCARTS_H
|
||||||
|
|
||||||
#include "types.h"
|
#include <stdint.h>
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
#define iNES_MIRROR 0x01
|
#define iNES_MIRROR 0x01
|
||||||
#define iNES_BATTERY 0x02
|
#define iNES_BATTERY 0x02
|
||||||
@@ -23,14 +24,14 @@
|
|||||||
|
|
||||||
typedef struct NesCart_
|
typedef struct NesCart_
|
||||||
{
|
{
|
||||||
unsigned long 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 */
|
||||||
byte Flags;
|
uint8_t Flags;
|
||||||
char *FileName;
|
char *FileName;
|
||||||
byte *File; /* Pointer on the file in memory */
|
uint8_t *File; /* Pointer on the file in memory */
|
||||||
byte *PROMBanks; /* Pointer on the first PROM */
|
uint8_t *PROMBanks; /* Pointer on the first PROM */
|
||||||
byte *VROMBanks; /* Pointer on the first VROM */
|
uint8_t *VROMBanks; /* Pointer on the first VROM */
|
||||||
} NesCart;
|
} NesCart;
|
||||||
|
|
||||||
void DumpCartProperties();
|
void DumpCartProperties();
|
||||||
|
|||||||
@@ -11,6 +11,12 @@
|
|||||||
/** commercially. Please, notify me, if you make any **/
|
/** commercially. Please, notify me, if you make any **/
|
||||||
/** changes to this file. **/
|
/** changes to this file. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
|
/*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef SOUND_H
|
#ifndef SOUND_H
|
||||||
#define SOUND_H
|
#define SOUND_H
|
||||||
@@ -87,7 +93,7 @@ void SetChannels(int Volume,int Switch);
|
|||||||
/** waveform to be an instrument or set it to the waveform **/
|
/** waveform to be an instrument or set it to the waveform **/
|
||||||
/** own playback rate. **/
|
/** own playback rate. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
void SetWave(int Channel,const signed char *Data,int Length,int Rate);
|
void SetWave(int Channel,signed char *Data,int Length,int Rate);
|
||||||
|
|
||||||
/** GetWave() ************************************************/
|
/** GetWave() ************************************************/
|
||||||
/** Get current read position for the buffer set with the **/
|
/** Get current read position for the buffer set with the **/
|
||||||
@@ -123,7 +129,7 @@ int MIDILogging(int Switch);
|
|||||||
void MIDITicks(int N);
|
void MIDITicks(int N);
|
||||||
|
|
||||||
//#ifdef UNIX
|
//#ifdef UNIX
|
||||||
#define SND_CHANNELS 16 /* Number of channels */
|
#define SND_CHANNELS 4 /* Number of channels */
|
||||||
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
|
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
|
||||||
#define SND_BUFSIZE 256 /* Buffer size, <= 2^SND_BITS */
|
#define SND_BUFSIZE 256 /* Buffer size, <= 2^SND_BITS */
|
||||||
#define SND_BITS 8 /* Number of bits in a fragment */
|
#define SND_BITS 8 /* Number of bits in a fragment */
|
||||||
@@ -137,7 +143,6 @@ void MIDITicks(int N);
|
|||||||
/** skip initialization and be silent. Pass Verbose!=0 to **/
|
/** skip initialization and be silent. Pass Verbose!=0 to **/
|
||||||
/** see initialization messages. **/
|
/** see initialization messages. **/
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
#warning You Suck !
|
|
||||||
int InitSound(int Rate,int Verbose);
|
int InitSound(int Rate,int Verbose);
|
||||||
|
|
||||||
/** StopSound() **********************************************/
|
/** StopSound() **********************************************/
|
||||||
@@ -220,7 +225,7 @@ struct SndDriverStruct
|
|||||||
void (*Drum)(int Type,int Force);
|
void (*Drum)(int Type,int Force);
|
||||||
void (*SetChannels)(int Volume,int Switch);
|
void (*SetChannels)(int Volume,int Switch);
|
||||||
void (*Sound)(int Channel,int NewFreq,int NewVolume);
|
void (*Sound)(int Channel,int NewFreq,int NewVolume);
|
||||||
void (*SetWave)(int Channel,const signed char *Data,int Length,int Freq);
|
void (*SetWave)(int Channel,signed char *Data,int Length,int Freq);
|
||||||
const signed char *(*GetWave)(int Channel);
|
const signed char *(*GetWave)(int Channel);
|
||||||
};
|
};
|
||||||
extern struct SndDriverStruct SndDriver;
|
extern struct SndDriverStruct SndDriver;
|
||||||
|
|||||||
48
src/include/color.h
Normal file
48
src/include/color.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* ANSI Color definition - The Quick6502 Project
|
||||||
|
* include/color.h
|
||||||
|
*
|
||||||
|
* Created by Manoel Trapier on 25/06/10
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate:$
|
||||||
|
* $Author:$
|
||||||
|
* $HeadURL:$
|
||||||
|
* $Revision:$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COLOR_H
|
||||||
|
#define COLOR_H
|
||||||
|
|
||||||
|
#define ALLOW_COLORS
|
||||||
|
|
||||||
|
#ifdef ALLOW_COLORS
|
||||||
|
#define __C(c) "\x1B[" c "m"
|
||||||
|
#else
|
||||||
|
#define __C(c) ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ANSI_COLOR __C
|
||||||
|
#define FBLACK ANSI_COLOR("30")
|
||||||
|
#define FRED ANSI_COLOR("31")
|
||||||
|
#define FGREEN ANSI_COLOR("32")
|
||||||
|
#define FYELLOW ANSI_COLOR("33")
|
||||||
|
#define FBLUE ANSI_COLOR("34")
|
||||||
|
#define FMAGENTA ANSI_COLOR("35")
|
||||||
|
#define FCYAN ANSI_COLOR("36")
|
||||||
|
#define FWHITE ANSI_COLOR("37")
|
||||||
|
|
||||||
|
#define BBLACK ANSI_COLOR("40")
|
||||||
|
#define BRED ANSI_COLOR("41")
|
||||||
|
#define BGREEN ANSI_COLOR("42")
|
||||||
|
#define BYELLOW ANSI_COLOR("43")
|
||||||
|
#define BBLUE ANSI_COLOR("44")
|
||||||
|
#define BMAGENTA ANSI_COLOR("45")
|
||||||
|
#define BCYAN ANSI_COLOR("46")
|
||||||
|
#define BWHITE ANSI_COLOR("47")
|
||||||
|
|
||||||
|
#define CNORMAL ANSI_COLOR("0")
|
||||||
|
|
||||||
|
#endif /* COLOR_H */
|
||||||
|
|
||||||
170
src/include/corecpu.h
Normal file
170
src/include/corecpu.h
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
/**
|
||||||
|
* CoreCPU - The Quick6502 Project
|
||||||
|
* corecpu.h
|
||||||
|
*
|
||||||
|
* Created by Manoel Trapier on 24/02/08
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _QUICK6502_CORECPU_H_
|
||||||
|
#define _QUICK6502_CORECPU_H_
|
||||||
|
|
||||||
|
/* M6502 configuration
|
||||||
|
*
|
||||||
|
* Supported DEFINEs :
|
||||||
|
* Q6502_NO_DECIMAL Quick6502 will not support BDC arithemtic (used for NES)
|
||||||
|
* Q6502_CMOS Quick6502 will act as a CMOS 6502 (Not actually used)
|
||||||
|
* Q6502_DEBUGGER Quick6502 will be build with debugguer support. Add some KB to the binary
|
||||||
|
* and may slowdown a bit the emulation.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef Q6502_CMOS
|
||||||
|
//#warning Quick6502 CMOS support is actually desactivated, desactivate it
|
||||||
|
#undef Q6502_CMOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Q6502_NO_DECIMAL
|
||||||
|
//#warning Quick6502 have actually no BCD support, fallback to no NO_DECIMAL
|
||||||
|
#define Q6502_NO_DECIMAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
typedef byte (*quick6502_MemoryReadFunction)(unsigned short addr);
|
||||||
|
typedef void (*quick6502_MemoryWriteFunction)(unsigned short addr, byte value);
|
||||||
|
|
||||||
|
typedef struct quick6502_cpu_
|
||||||
|
{
|
||||||
|
/* 6502 registers */
|
||||||
|
byte reg_A, reg_X, reg_Y;
|
||||||
|
byte reg_P, reg_S;
|
||||||
|
unsigned short reg_PC;
|
||||||
|
|
||||||
|
/* Read/Write memory functions */
|
||||||
|
quick6502_MemoryReadFunction memory_read;
|
||||||
|
quick6502_MemoryWriteFunction memory_write;
|
||||||
|
quick6502_MemoryReadFunction memory_page0_read;
|
||||||
|
quick6502_MemoryWriteFunction memory_page0_write;
|
||||||
|
quick6502_MemoryReadFunction memory_stack_read;
|
||||||
|
quick6502_MemoryWriteFunction memory_stack_write;
|
||||||
|
quick6502_MemoryReadFunction memory_opcode_read;
|
||||||
|
|
||||||
|
/* Timing related */
|
||||||
|
long cycle_done;
|
||||||
|
byte exit_loop;
|
||||||
|
byte int_pending;
|
||||||
|
|
||||||
|
/* Other config options */
|
||||||
|
byte running; /* This field is used to prevent cpu free if this cpu is running */
|
||||||
|
byte page_crossed;
|
||||||
|
|
||||||
|
/* TODO add support for Inst/MemAccess breakpoints */
|
||||||
|
|
||||||
|
} quick6502_cpu;
|
||||||
|
|
||||||
|
typedef struct quick6502_cpuconfig_
|
||||||
|
{
|
||||||
|
/* Read/Write memory functions */
|
||||||
|
quick6502_MemoryReadFunction memory_read;
|
||||||
|
quick6502_MemoryWriteFunction memory_write;
|
||||||
|
quick6502_MemoryReadFunction memory_page0_read;
|
||||||
|
quick6502_MemoryWriteFunction memory_page0_write;
|
||||||
|
quick6502_MemoryReadFunction memory_stack_read;
|
||||||
|
quick6502_MemoryWriteFunction memory_stack_write;
|
||||||
|
quick6502_MemoryReadFunction memory_opcode_read;
|
||||||
|
} quick6502_cpuconfig;
|
||||||
|
|
||||||
|
/*** Signal that we can send to the CPU ***/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Q6502_NO_SIGNAL = 0,
|
||||||
|
Q6502_IRQ_SIGNAL,
|
||||||
|
Q6502_NMI_SIGNAL,
|
||||||
|
Q6502_STOPLOOP_SIGNAL
|
||||||
|
} quick6502_signal;
|
||||||
|
|
||||||
|
/*** Some 6502 related definitions ***/
|
||||||
|
|
||||||
|
/*** P register flags ***/
|
||||||
|
#define Q6502_N_FLAG 0x80 /* Negavite flag */
|
||||||
|
#define Q6502_V_FLAG 0x40 /* oVerflow flag */
|
||||||
|
#define Q6502_R_FLAG 0x20 /* Not a real flag, but need to be to 1 on PHP */
|
||||||
|
#define Q6502_B_FLAG 0x10 /* Break flag */
|
||||||
|
#define Q6502_D_FLAG 0x08 /* BCD flag */
|
||||||
|
#define Q6502_I_FLAG 0x04 /* IRQ/BRK flag */
|
||||||
|
#define Q6502_Z_FLAG 0x02 /* Zero flag */
|
||||||
|
#define Q6502_C_FLAG 0x01 /* Carry flag */
|
||||||
|
|
||||||
|
/*** Interuption Vectors ***/
|
||||||
|
#define Q6502_NMI_LOW 0xFFFA
|
||||||
|
#define Q6502_NMI_HIGH 0xFFFB
|
||||||
|
#define Q6502_RESET_LOW 0xFFFC
|
||||||
|
#define Q6502_RESET_HIGH 0xFFFD
|
||||||
|
#define Q6502_IRQ_LOW 0xFFFE
|
||||||
|
#define Q6502_IRQ_HIGH 0xFFFF
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the CPU
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
*
|
||||||
|
* - CPU Init structure:
|
||||||
|
* +- Memory Read function pointer
|
||||||
|
* +- Memory Write function pointer
|
||||||
|
* +- Fast memory read function pointer (for opcodes read)
|
||||||
|
* +- Fast page 0 function / Read/Write
|
||||||
|
* +- Fast page 1 function / Read/Write
|
||||||
|
*
|
||||||
|
* Output:
|
||||||
|
*
|
||||||
|
* (void *): An opaque pointer to the internal structure of the CPU
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
quick6502_cpu *quick6502_init(quick6502_cpuconfig *config);
|
||||||
|
|
||||||
|
/* Reset the CPU (must be done after init) */
|
||||||
|
void quick6502_reset(quick6502_cpu *cpu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run cpu for at least X cycles
|
||||||
|
*
|
||||||
|
* Output:
|
||||||
|
*
|
||||||
|
* int: (Number of cycle really done) - (Number of cycle asked)
|
||||||
|
*/
|
||||||
|
int quick6502_run(quick6502_cpu *cpu, int cycles);
|
||||||
|
|
||||||
|
/** Loop CPU until explicit quit */
|
||||||
|
void quick6502_loop(quick6502_cpu *cpu);
|
||||||
|
|
||||||
|
/** Run CPU for one instruction */
|
||||||
|
void quick6502_exec(quick6502_cpu *cpu);
|
||||||
|
|
||||||
|
/** Send IRQ/NMI/EXITLOOP signal to CPU */
|
||||||
|
void quick6502_int(quick6502_cpu *cpu, quick6502_signal signal);
|
||||||
|
|
||||||
|
/** Dump CPU State to the given file */
|
||||||
|
void quick6502_dump(quick6502_cpu *cpu, FILE * fp);
|
||||||
|
|
||||||
|
/** Get current instruction name at specified address and put it into buffer */
|
||||||
|
#define MINE
|
||||||
|
|
||||||
|
int quick6502_getinstruction(quick6502_cpu *cpu, char interpret,
|
||||||
|
unsigned short addr, char *buffer, int *strlength);
|
||||||
|
/**
|
||||||
|
* Free the CPU
|
||||||
|
*
|
||||||
|
* This function will free the CPU only if it's not currently used, it will
|
||||||
|
* return !0 if everything goes well and 0 if the free is impossible
|
||||||
|
*/
|
||||||
|
int quick6502_free(quick6502_cpu *cpu);
|
||||||
|
|
||||||
|
#endif /* _QUICK6502_CORECPU_H_ */
|
||||||
|
|
||||||
42
src/include/log.h
Normal file
42
src/include/log.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Log Facility - The Quick6502 Project
|
||||||
|
* include/log.h
|
||||||
|
*
|
||||||
|
* Created by Manoel Trapier on 19/05/10
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate:$
|
||||||
|
* $Author:$
|
||||||
|
* $HeadURL:$
|
||||||
|
* $Revision:$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOG_H
|
||||||
|
#define _LOG_H
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LOG_ALWAYS = -1,
|
||||||
|
LOG_PANIC = 0,
|
||||||
|
LOG_ERROR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NORMAL,
|
||||||
|
LOG_VERBOSE,
|
||||||
|
LOG_DEBUG,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define TIME_STAMP_LOG
|
||||||
|
|
||||||
|
#define MAX_DEBUG_LEVEL LOG_PANIC
|
||||||
|
#define log(_level, _user, _fmt, ...) if ((_level <= MAX_DEBUG_LEVEL) || (_level <= LOG_PANIC)) do { log_real(_level, _user, _fmt, ##__VA_ARGS__); } while(0)
|
||||||
|
|
||||||
|
void log_real(int level, char *user, char *fmt, ...);
|
||||||
|
|
||||||
|
#define LOG(_level, _str, ...) if ((_level <= MAX_DEBUG_LEVEL) || (_level <= LOG_PANIC)) do { puts(_str); } while(0)
|
||||||
|
#define LOGCODE(_level, _user, _code) log(_level, _user, ""); \
|
||||||
|
if ((_level <= MAX_DEBUG_LEVEL) || (_level <= LOG_PANIC)) \
|
||||||
|
do { _code; printf("\n"); } while(0)
|
||||||
|
|
||||||
|
#endif /* _LOG_H */
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
* mappers.h
|
* mappers.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate$
|
* $LastChangedDate$
|
||||||
* $Author$
|
* $Author$
|
||||||
@@ -27,6 +27,10 @@ typedef void (*MapperDump) ();
|
|||||||
|
|
||||||
#ifdef __TINES_MAPPERS__
|
#ifdef __TINES_MAPPERS__
|
||||||
|
|
||||||
|
#include <ppu/ppu.h>
|
||||||
|
#include <memory/manager.h>
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
extern NesCart *Cart;
|
extern NesCart *Cart;
|
||||||
|
|
||||||
/* Available functions for mappers */
|
/* Available functions for mappers */
|
||||||
@@ -34,9 +38,6 @@ 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 map_sram(); /* Map SRAM */
|
|
||||||
void unmap_sram(); /* Unmap SRAM */
|
|
||||||
|
|
||||||
void set_vrom_bank_1k(unsigned short addr,int slot);
|
void set_vrom_bank_1k(unsigned short addr,int slot);
|
||||||
void set_vrom_bank_2k(unsigned short addr,int slot);
|
void set_vrom_bank_2k(unsigned short addr,int slot);
|
||||||
void set_vrom_bank_4k(unsigned short addr,int slot);
|
void set_vrom_bank_4k(unsigned short addr,int slot);
|
||||||
@@ -57,4 +58,7 @@ extern void (*mapper_dump) (FILE *fp);
|
|||||||
|
|
||||||
#endif /* __TINES_MAPPERS__ */
|
#endif /* __TINES_MAPPERS__ */
|
||||||
|
|
||||||
|
void map_sram(); /* Map SRAM */
|
||||||
|
void unmap_sram(); /* Unmap SRAM */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
* 6502 Memory manager - The TI-NESulator Project
|
* 6502 Memory manager - The TI-NESulator Project
|
||||||
* memory.h - Taken from the Quick6502 project
|
* memory.h - Taken from the Quick6502 project
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 18/09/06.
|
* Created by Manoel Trapier on 18/09/06.
|
||||||
* Copyright 2003-2007 986 Corp. All rights reserved.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-05 16:30:20 +0200 (jeu, 05 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/memory.h $
|
* $HeadURL$
|
||||||
* $Revision: 31 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef MEMORY_H
|
#ifndef MEMORY_H
|
||||||
@@ -63,6 +63,6 @@ void InitMemory();
|
|||||||
byte ReadMemory(byte page, byte addr);
|
byte ReadMemory(byte page, byte addr);
|
||||||
void WriteMemory(byte page, byte addr, byte value);
|
void WriteMemory(byte page, byte addr, byte value);
|
||||||
|
|
||||||
void DumpMemoryState();
|
void DumpMemoryState(FILE *fp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
54
src/include/os_dependent.h
Normal file
54
src/include/os_dependent.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* OS Dependent functions - The TI-NESulator Project
|
||||||
|
* os_dependent.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER on 08/05/08.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OS_DEPENDENT_H
|
||||||
|
#define OS_DEPENDENT_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* File related functions */
|
||||||
|
/* Graphics related functions */
|
||||||
|
int graphics_init();
|
||||||
|
int graphics_drawpixel(long x, long y, long color);
|
||||||
|
int graphics_blit(long x, long y, long w, long h);
|
||||||
|
int graphics_drawline(long x, long y, long x1, long y1, long color);
|
||||||
|
|
||||||
|
typedef struct Palette_t
|
||||||
|
{
|
||||||
|
uint8_t r,g,b,a;
|
||||||
|
} Palette;
|
||||||
|
|
||||||
|
int getKeyStatus(int key);
|
||||||
|
|
||||||
|
/* Sound related functions */
|
||||||
|
|
||||||
|
/* IO functions */
|
||||||
|
void *LoadFilePtr(char * filename);
|
||||||
|
|
||||||
|
/* Console functions */
|
||||||
|
typedef enum ConsoleLevel_t
|
||||||
|
{
|
||||||
|
Console_Error = 0,
|
||||||
|
Console_Warning,
|
||||||
|
Console_Alert,
|
||||||
|
Console_Default,
|
||||||
|
Console_Verbose,
|
||||||
|
Console_Debug,
|
||||||
|
} ConsoleLevel;
|
||||||
|
|
||||||
|
int console_init(ConsoleLevel DefaultLevel);
|
||||||
|
int console_printf(const ConsoleLevel level, const char *format, ...);
|
||||||
|
int console_printf_d(const char *format, ...);
|
||||||
|
|
||||||
|
#endif /* OS_DEPENDENT_H */
|
||||||
@@ -3,12 +3,12 @@
|
|||||||
* paddle.h
|
* paddle.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/paddle.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
/* Generated data file from file 'stdin' */
|
/* Generated data file from file 'stdin' */
|
||||||
|
/*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
|
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 },
|
||||||
@@ -257,5 +262,5 @@ PALETTE basicPalette = {
|
|||||||
{ 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 },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* plugins.h
|
* plugins.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER on 02/04/07.
|
* Created by Manoel TRAPIER on 02/04/07.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate$
|
* $LastChangedDate$
|
||||||
* $Author$
|
* $Author$
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
* PPU debug utilities - The TI-NESulator Project
|
* PPU debug utilities - The TI-NESulator Project
|
||||||
* ppu.debug.h
|
* ppu.debug.h
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 12/04/07.
|
* Created by Manoel Trapier on 12/04/07.
|
||||||
* Copyright 2003-2007 986 Corp. All rights reserved.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-24 15:11:55 +0200 (jeu, 24 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/ppu/ppu.debug.h $
|
* $HeadURL$
|
||||||
* $Revision: 53 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
* 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 Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-26 18:47:34 +0200 (jeu, 26 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/ppu.h $
|
* $HeadURL$
|
||||||
* $Revision: 46 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
typedef struct PPU_Sprite_
|
typedef struct PPU_Sprite_
|
||||||
{
|
{
|
||||||
byte y;
|
uint8_t y;
|
||||||
byte tileid;
|
uint8_t tileid;
|
||||||
byte flags;
|
uint8_t flags;
|
||||||
byte x;
|
uint8_t x;
|
||||||
} PPU_Sprite;
|
} PPU_Sprite;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -32,13 +32,13 @@ PPU must be initialized after memory initialisation..
|
|||||||
*/
|
*/
|
||||||
int ppu_init();
|
int ppu_init();
|
||||||
|
|
||||||
int ppu_hblank(int scanline);
|
int ppu_hblank(uint16_t scanline);
|
||||||
|
|
||||||
byte ppu_readReg(byte id);
|
uint8_t ppu_readReg(uint8_t id);
|
||||||
|
|
||||||
void ppu_writeReg(byte id, byte val);
|
void ppu_writeReg(uint8_t id, uint8_t val);
|
||||||
|
|
||||||
void ppu_fillSprRamDMA(byte value);
|
void ppu_fillSprRamDMA(uint8_t value);
|
||||||
|
|
||||||
#define PPU_MIRROR_HORIZTAL 0
|
#define PPU_MIRROR_HORIZTAL 0
|
||||||
#define PPU_MIRROR_VERTICAL 1
|
#define PPU_MIRROR_VERTICAL 1
|
||||||
@@ -52,15 +52,15 @@ void ppu_fillSprRamDMA(byte value);
|
|||||||
#define PPU_SCMODE_NORMAL 1
|
#define PPU_SCMODE_NORMAL 1
|
||||||
#define PPU_SCMODE_FOURSC 2
|
#define PPU_SCMODE_FOURSC 2
|
||||||
|
|
||||||
void ppu_setMirroring(byte direction);
|
void ppu_setMirroring(uint8_t direction);
|
||||||
void ppu_setSingleScreen(byte screen);
|
void ppu_setSingleScreen(uint8_t screen);
|
||||||
void ppu_setScreenMode(byte mode);
|
void ppu_setScreenMode(uint8_t mode);
|
||||||
|
|
||||||
|
|
||||||
PPU_Sprite ppu_getSprite(unsigned short i);
|
PPU_Sprite ppu_getSprite(uint16_t i);
|
||||||
|
|
||||||
unsigned char ppu_memoryRead(byte page, byte addr);
|
unsigned char ppu_memoryRead(uint8_t page, uint8_t addr);
|
||||||
void ppu_memoryWrite(byte page, byte addr, byte 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,13 +2,13 @@
|
|||||||
* PPU Memory manager - The TI-NESulator Project
|
* PPU Memory manager - The TI-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 Manoël Trapier on 12/04/07.
|
* Created by Manoel Trapier on 12/04/07.
|
||||||
* Copyright 2003-2007 986 Corp. All rights reserved.
|
* Copyright 2003-2008 986 Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-24 15:11:55 +0200 (jeu, 24 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/ppu/ppu.memory.h $
|
* $HeadURL$
|
||||||
* $Revision: 53 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ void ppu_memoryDumpState(FILE *fp);
|
|||||||
byte ppu_readMemory(byte page, byte addr);
|
byte ppu_readMemory(byte page, byte addr);
|
||||||
void ppu_writeMemory(byte page, byte addr, byte value);
|
void ppu_writeMemory(byte page, byte addr, byte value);
|
||||||
|
|
||||||
|
void ppu_setPageGhost(byte page, bool value, byte ghost);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Must only be included inside the PPU code
|
#error Must only be included inside the PPU code
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,25 +2,27 @@
|
|||||||
* Base type definitions - The TI-NESulator Project
|
* Base type definitions - The TI-NESulator Project
|
||||||
* types.h - Taken from the Quick6502 project
|
* types.h - Taken from the Quick6502 project
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 18/09/06.
|
* Created by Manoel Trapier on 18/09/06.
|
||||||
* Copyright 2003-2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-03-28 15:50:50 +0200 (mer, 28 mar 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/types.h $
|
* $HeadURL$
|
||||||
* $Revision: 25 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TYPES_H
|
#ifndef TYPES_H
|
||||||
#define TYPES_H
|
#define TYPES_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef BYTE_TYPE_DEFINED
|
#ifndef BYTE_TYPE_DEFINED
|
||||||
#define BYTE_TYPE_DEFINED
|
#define BYTE_TYPE_DEFINED
|
||||||
typedef unsigned char byte;
|
typedef uint8_t byte;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned char bool;
|
typedef uint8_t bool;
|
||||||
|
|
||||||
#define true (0)
|
#define true (0)
|
||||||
#define false (!true)
|
#define false (!true)
|
||||||
|
|||||||
125
src/log.c
Normal file
125
src/log.c
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/**
|
||||||
|
* Log Facility - The Quick6502 Project
|
||||||
|
* log.c
|
||||||
|
*
|
||||||
|
* Created by Manoel Trapier on 19/05/10
|
||||||
|
* Copyright 2010 986 Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate:$
|
||||||
|
* $Author:$
|
||||||
|
* $HeadURL:$
|
||||||
|
* $Revision:$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <color.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <log.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifdef TIME_STAMP_LOG
|
||||||
|
void time_stamp_line(void)
|
||||||
|
{
|
||||||
|
/* Time "0" will be thefirst log line */
|
||||||
|
static char firstRun = 1;
|
||||||
|
static struct timeval firstTime;
|
||||||
|
struct timeval curTime;
|
||||||
|
|
||||||
|
int cMin, cSec;
|
||||||
|
long long cMSec;
|
||||||
|
|
||||||
|
/* Get datetime */
|
||||||
|
gettimeofday(&curTime, NULL);
|
||||||
|
|
||||||
|
if (firstRun == 1)
|
||||||
|
{
|
||||||
|
firstRun = 0;
|
||||||
|
firstTime.tv_sec = curTime.tv_sec;
|
||||||
|
firstTime.tv_usec = curTime.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
|
cMSec = ((curTime.tv_sec - firstTime.tv_sec)* 1000) + (curTime.tv_usec - firstTime.tv_usec)/1000;
|
||||||
|
cSec = (cMSec/1000);
|
||||||
|
cMSec %= 1000;
|
||||||
|
|
||||||
|
cMin = cSec / 60;
|
||||||
|
|
||||||
|
cSec %= 60;
|
||||||
|
|
||||||
|
/* Put cursor at start of line */
|
||||||
|
printf("%c[s", 0x1B);
|
||||||
|
printf("%c[7000D", 0x1B);
|
||||||
|
printf("%c[1C", 0x1B);
|
||||||
|
printf(FWHITE"[" FYELLOW "%03d" FRED "." FBLUE "%02d" FRED "." FGREEN "%03lld" FWHITE "]" CNORMAL, cMin, cSec, cMSec);
|
||||||
|
printf("%c[u", 0x1B);
|
||||||
|
}
|
||||||
|
#endif /* TIME_STAMP_LOG */
|
||||||
|
|
||||||
|
void log_real(int level, char *user, char *fmt, ...)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
va_list va;
|
||||||
|
|
||||||
|
/* The LOG_PANIC must always be displayed */
|
||||||
|
if ((level <= MAX_DEBUG_LEVEL) || (level <= LOG_PANIC))
|
||||||
|
{
|
||||||
|
switch(level)
|
||||||
|
{
|
||||||
|
case LOG_PANIC: printf(BRED FWHITE); break;
|
||||||
|
case LOG_ERROR: printf(FRED); break;
|
||||||
|
case LOG_WARNING: printf(FYELLOW); break;
|
||||||
|
default:
|
||||||
|
case LOG_NORMAL: printf(FGREEN); break;
|
||||||
|
case LOG_VERBOSE: printf(FCYAN); break;
|
||||||
|
case LOG_DEBUG: printf(BBLUE FWHITE); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TIME_STAMP_LOG
|
||||||
|
printf(" ");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (user != NULL)
|
||||||
|
{
|
||||||
|
i = strlen(user);
|
||||||
|
if (i < 12)
|
||||||
|
{
|
||||||
|
i = 12 - i;
|
||||||
|
for (; i >= 0; i--)
|
||||||
|
putchar(' ');
|
||||||
|
}
|
||||||
|
printf("%s", user);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch(level)
|
||||||
|
{
|
||||||
|
case LOG_PANIC: printf(" PANIC"); break;
|
||||||
|
case LOG_ERROR: printf(" Error"); break;
|
||||||
|
case LOG_WARNING: printf(" Warning"); break;
|
||||||
|
default:
|
||||||
|
case LOG_NORMAL: printf(" Info"); break;
|
||||||
|
case LOG_VERBOSE: printf(" Verbose"); break;
|
||||||
|
case LOG_DEBUG: printf(" Debug"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(CNORMAL ": ");
|
||||||
|
|
||||||
|
#ifdef TIME_STAMP_LOG
|
||||||
|
time_stamp_line();
|
||||||
|
#endif /* TIME_STAMP_LOG */
|
||||||
|
|
||||||
|
va_start(va, fmt);
|
||||||
|
vprintf(fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
if (fmt[0] != 0)
|
||||||
|
{
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1280
src/main.c
1280
src/main.c
File diff suppressed because it is too large
Load Diff
18
src/mappersmanager/CMakeLists.txt
Normal file
18
src/mappersmanager/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
file(GLOB mappers_list mappers/*.c)
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
set(COVERAGE_SRCS src/mappersmanager/manager.c src/mappersmanager/utils.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(mappermanager utils.c manager.c ${mappers_list} )
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
|
* Mapper manager - The TI-NESulator Project
|
||||||
* manager.c
|
* manager.c
|
||||||
* TI-NESulator.X
|
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 07/10/07.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright 2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -12,6 +17,8 @@
|
|||||||
|
|
||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
MapperIRQ mapper_irqloop;
|
MapperIRQ mapper_irqloop;
|
||||||
MapperDump mapper_dump;
|
MapperDump mapper_dump;
|
||||||
MapperWriteHook mapper_hook;
|
MapperWriteHook mapper_hook;
|
||||||
@@ -19,7 +26,7 @@ MapperWriteHook mapper_hook;
|
|||||||
typedef struct Mapper_
|
typedef struct Mapper_
|
||||||
{
|
{
|
||||||
byte id;
|
byte id;
|
||||||
byte *name;
|
char *name;
|
||||||
|
|
||||||
MapperInit init;
|
MapperInit init;
|
||||||
MapperIRQ irq;
|
MapperIRQ irq;
|
||||||
@@ -32,10 +39,10 @@ typedef struct Mapper_
|
|||||||
void mapper_list ()
|
void mapper_list ()
|
||||||
{
|
{
|
||||||
Mapper *ptr = &(Mappers[0]);
|
Mapper *ptr = &(Mappers[0]);
|
||||||
printf("Available mapers:\n");
|
console_printf(Console_Default, "Available mapers:\n");
|
||||||
while(ptr->name != NULL)
|
while(ptr->name != NULL)
|
||||||
{
|
{
|
||||||
printf("%d - %s\n", ptr->id, ptr->name);
|
console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,13 +50,14 @@ void mapper_list ()
|
|||||||
int mapper_init (NesCart *cart)
|
int mapper_init (NesCart *cart)
|
||||||
{
|
{
|
||||||
Mapper *ptr = &(Mappers[0]);
|
Mapper *ptr = &(Mappers[0]);
|
||||||
printf ("Search for a compatible mapper ID #%X:\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)
|
||||||
{
|
{
|
||||||
printf ("Found mapper ID #%X - '%s'\n", ptr->id, ptr->name);
|
console_printf (Console_Default, "Found mapper ID #%d - '%s'\n", ptr->id, ptr->name);
|
||||||
ptr->init (cart);
|
if (ptr->init)
|
||||||
|
ptr->init (cart);
|
||||||
|
|
||||||
mapper_irqloop = ptr->irq;
|
mapper_irqloop = ptr->irq;
|
||||||
mapper_dump = ptr->dump;
|
mapper_dump = ptr->dump;
|
||||||
@@ -58,5 +66,6 @@ int mapper_init (NesCart *cart)
|
|||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
console_printf (Console_Default, "No compatible mapper found!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* AOROM Mapper - The TI-NESulator Project
|
* AOROM Mapper - The TI-NESulator Project
|
||||||
* aorom.h
|
* aorom.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-26 18:47:34 +0200 (jeu, 26 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/aorom.h $
|
* $HeadURL$
|
||||||
* $Revision: 46 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "aorom.h"
|
||||||
|
|
||||||
unsigned char aorom_load_bank;
|
unsigned char aorom_load_bank;
|
||||||
|
|
||||||
void aorom_MapperWriteHook(register byte Addr, register byte Value);
|
void aorom_MapperWriteHook(register byte Addr, register byte Value);
|
||||||
@@ -53,7 +55,7 @@ void aorom_MapperWriteHook(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
aorom_load_bank = BankNb;
|
aorom_load_bank = BankNb;
|
||||||
|
|
||||||
//printf("aorom: Asking bank %d (giving %d & %d) - mirror is %d\n",BankNb,BankNb,(Value<<1)+1,Value&0x0F);
|
//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);
|
||||||
}
|
}
|
||||||
|
|
||||||
19
src/mappersmanager/mappers/aorom.h
Executable file
19
src/mappersmanager/mappers/aorom.h
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* AOROM Mapper - The TI-NESulator Project
|
||||||
|
* aorom.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
int aorom_InitMapper(NesCart * cart);
|
||||||
|
void aorom_MapperDump(FILE *fp);
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* CNROM Mapper - The TI-NESulator Project
|
* CNROM Mapper - The TI-NESulator Project
|
||||||
* cnrom.h
|
* cnrom.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/cnrom.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "cnrom.h"
|
||||||
|
|
||||||
unsigned char cnrom_load_bank;
|
unsigned char cnrom_load_bank;
|
||||||
|
|
||||||
void cnrom_MapperWriteHook(register byte Addr, register byte Value);
|
void cnrom_MapperWriteHook(register byte Addr, register byte Value);
|
||||||
19
src/mappersmanager/mappers/cnrom.h
Executable file
19
src/mappersmanager/mappers/cnrom.h
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* CNROM Mapper - The TI-NESulator Project
|
||||||
|
* cnrom.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
int cnrom_InitMapper(NesCart * cart);
|
||||||
|
void cnrom_MapperDump(FILE *fp);
|
||||||
@@ -3,12 +3,12 @@
|
|||||||
* genericmapper.h
|
* genericmapper.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/genericmapper.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* IREMH3001 Mapper - The TI-NESulator Project
|
* IREMH3001 Mapper - The TI-NESulator Project
|
||||||
* iremh3001.h
|
* iremh3001.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/iremh3001.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "iremh3001.h"
|
||||||
|
|
||||||
unsigned short iremh3001_prom_slot[3];
|
unsigned short iremh3001_prom_slot[3];
|
||||||
|
|
||||||
unsigned short iremh3001_vrom_slot[8];
|
unsigned short iremh3001_vrom_slot[8];
|
||||||
@@ -41,31 +43,31 @@ int iremh3001_InitMapper(NesCart * cart)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int iremh3001_MapperWriteHook(register word Addr, register byte Value)
|
int iremh3001_MapperWriteHook(register byte Addr, register byte Value)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
switch(Addr)
|
switch(Addr)
|
||||||
{
|
{
|
||||||
case 0x8000: /* Set 8k PROM @ 8000 */
|
case 0x8000: /* Set 8k PROM @ 8000 */
|
||||||
printf("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 ??? */
|
||||||
printf("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 ??? */
|
||||||
printf("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 ??? */
|
||||||
printf("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 */
|
||||||
printf("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;
|
||||||
@@ -78,23 +80,23 @@ int iremh3001_MapperWriteHook(register word Addr, register byte Value)
|
|||||||
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 */
|
||||||
printf("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 */
|
||||||
printf("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:
|
||||||
printf("@:%X -- V:%X", Addr, Value);
|
console_printf(Console_Default, "@:%X -- V:%X", Addr, Value);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +116,7 @@ void iremh3001_MapperDump(FILE *fp)
|
|||||||
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_prom_slot[7]);
|
iremh3001_vrom_slot[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
20
src/mappersmanager/mappers/iremh3001.h
Executable file
20
src/mappersmanager/mappers/iremh3001.h
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* IREMH3001 Mapper - The TI-NESulator Project
|
||||||
|
* iremh3001.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
int iremh3001_InitMapper(NesCart * cart);
|
||||||
|
void iremh3001_MapperDump(FILE *fp);
|
||||||
|
int iremh3001_MapperIRQ(int cycledone);
|
||||||
@@ -3,29 +3,26 @@
|
|||||||
* mmc1.h
|
* mmc1.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mmc1.h $
|
* $HeadURL$
|
||||||
* $Revision: 50 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "norom.h"
|
#include "mmc1.h"
|
||||||
|
|
||||||
#include <ppu/ppu.h>
|
uint8_t MMC1_reg0;
|
||||||
#include <memory/manager.h>
|
|
||||||
|
|
||||||
unsigned char MMC1_reg0;
|
uint8_t MMC1_reg1;
|
||||||
|
|
||||||
unsigned char MMC1_reg1;
|
uint8_t MMC1_reg2;
|
||||||
|
|
||||||
unsigned char MMC1_reg2;
|
uint8_t MMC1_reg3;
|
||||||
|
|
||||||
unsigned char MMC1_reg3;
|
uint8_t mmc1_CurrentBank;
|
||||||
|
|
||||||
unsigned char mmc1_CurrentBank;
|
|
||||||
|
|
||||||
#define MMC1_R0_MIRROR 0x01
|
#define MMC1_R0_MIRROR 0x01
|
||||||
#define MMC1_R0_ONESCREEN 0x02
|
#define MMC1_R0_ONESCREEN 0x02
|
||||||
@@ -52,7 +49,6 @@ unsigned char mmc1_CurrentBank;
|
|||||||
#define MMC1_REG2_DEFAULT 0
|
#define MMC1_REG2_DEFAULT 0
|
||||||
#define MMC1_REG3_DEFAULT 0
|
#define MMC1_REG3_DEFAULT 0
|
||||||
|
|
||||||
|
|
||||||
void mmc1_MapperWriteReg0(register byte Addr, register byte Value);
|
void mmc1_MapperWriteReg0(register byte Addr, register byte Value);
|
||||||
void mmc1_MapperWriteReg1(register byte Addr, register byte Value);
|
void mmc1_MapperWriteReg1(register byte Addr, register byte Value);
|
||||||
void mmc1_MapperWriteReg2(register byte Addr, register byte Value);
|
void mmc1_MapperWriteReg2(register byte Addr, register byte Value);
|
||||||
@@ -139,11 +135,11 @@ Reg 0
|
|||||||
void mmc1_ApplyReg0Mod()
|
void mmc1_ApplyReg0Mod()
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char OldSwitchArea = MMC1_R0_PRGAREA;
|
static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//printf("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)
|
||||||
{
|
{
|
||||||
@@ -186,16 +182,16 @@ void mmc1_ApplyReg0Mod()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VROMBankNb;
|
uint32_t VROMBankNb;
|
||||||
unsigned char Bit = 0;
|
uint8_t Bit = 0;
|
||||||
unsigned char BitBuf = 0;
|
uint8_t BitBuf = 0;
|
||||||
|
|
||||||
void mmc1_MapperWriteReg0(register byte Addr, register byte Value)
|
void mmc1_MapperWriteReg0(register byte Addr, register byte Value)
|
||||||
{
|
{
|
||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||||
printf("MMC1: Reg0 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg0 Reset occured !\n");
|
||||||
mmc1_ApplyReg0Mod();
|
mmc1_ApplyReg0Mod();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -222,7 +218,7 @@ void mmc1_MapperWriteReg1(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||||
printf("MMC1: Reg1 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -242,18 +238,18 @@ void mmc1_MapperWriteReg1(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
if (Cart->VROMSize == 0)
|
if (Cart->VROMSize == 0)
|
||||||
{
|
{
|
||||||
printf("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 */
|
||||||
//printf("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 */
|
||||||
//printf("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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,7 +261,7 @@ void mmc1_MapperWriteReg2(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||||
printf("MMC1: Reg2 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -283,21 +279,21 @@ void mmc1_MapperWriteReg2(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
||||||
|
|
||||||
//printf("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)
|
||||||
{
|
{
|
||||||
//printf(": 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 */
|
||||||
//printf("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 */
|
||||||
// printf("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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,7 +305,7 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||||
printf("MMC1: Reg3 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -325,7 +321,7 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
MMC1_reg3 = BitBuf;
|
MMC1_reg3 = BitBuf;
|
||||||
|
|
||||||
if (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 )
|
||||||
@@ -333,12 +329,12 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
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);
|
||||||
//printf("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);
|
||||||
//printf("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
|
||||||
@@ -358,4 +354,4 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("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);
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
|
* MMC1 Mapper - The TI-NESulator Project
|
||||||
* mmc1.h
|
* mmc1.h
|
||||||
* TI-NESulator.X
|
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 02/12/07.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright 2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,4 +18,3 @@
|
|||||||
int mmc1_InitMapper (NesCart *cart);
|
int mmc1_InitMapper (NesCart *cart);
|
||||||
int mmc1_MapperIRQ (int cycledone);
|
int mmc1_MapperIRQ (int cycledone);
|
||||||
void mmc1_MapperDump ();
|
void mmc1_MapperDump ();
|
||||||
void mmc1_MapperWriteHook(register byte Addr, register byte Value);
|
|
||||||
@@ -3,14 +3,17 @@
|
|||||||
* mmc3.h
|
* mmc3.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mmc3.h $
|
* $HeadURL$
|
||||||
* $Revision: 50 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include "mmc3.h"
|
||||||
|
|
||||||
|
extern unsigned short ScanLine;
|
||||||
|
|
||||||
unsigned short mmc3_command;
|
unsigned short mmc3_command;
|
||||||
|
|
||||||
@@ -43,8 +46,6 @@ void mmc3_MapperDump(FILE *fp)
|
|||||||
|
|
||||||
int mmc3_InitMapper(NesCart * cart)
|
int mmc3_InitMapper(NesCart * cart)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ int mmc3_InitMapper(NesCart * cart)
|
|||||||
mmc3_command = -1;
|
mmc3_command = -1;
|
||||||
|
|
||||||
mmc3_irq_counter = -1;
|
mmc3_irq_counter = -1;
|
||||||
mmc3_irq_enable = 1;
|
mmc3_irq_enable = 0;
|
||||||
mmc3_irq_counter_reload = 0;
|
mmc3_irq_counter_reload = 0;
|
||||||
|
|
||||||
mmc3_use_xor = 0x42;
|
mmc3_use_xor = 0x42;
|
||||||
@@ -75,8 +76,6 @@ int mmc3_InitMapper(NesCart * cart)
|
|||||||
|
|
||||||
mmc3_first_prom_page = 0x8000;
|
mmc3_first_prom_page = 0x8000;
|
||||||
mmc3_second_prom_page = 0xA000;
|
mmc3_second_prom_page = 0xA000;
|
||||||
//mmc3_first_prom_page = 0; // Set it to 0x8000
|
|
||||||
|
|
||||||
|
|
||||||
/* Register mapper write hook */
|
/* Register mapper write hook */
|
||||||
set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
|
set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
|
||||||
@@ -92,12 +91,11 @@ int mmc3_InitMapper(NesCart * cart)
|
|||||||
set_page_writeable(0xE0, true);
|
set_page_writeable(0xE0, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
||||||
{
|
{
|
||||||
//printf("%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;
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
|||||||
{
|
{
|
||||||
if (!(Value & 0x40))
|
if (!(Value & 0x40))
|
||||||
{
|
{
|
||||||
printf("MMC3: Switch -> 8/A\n");
|
console_printf(Console_Default, "MMC3: Switch -> 8/A\n");
|
||||||
mmc3_first_prom_page = 0x8000;
|
mmc3_first_prom_page = 0x8000;
|
||||||
mmc3_second_prom_page = 0xA000;
|
mmc3_second_prom_page = 0xA000;
|
||||||
|
|
||||||
@@ -147,7 +145,7 @@ void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("MMC3: Switch -> C/A\n");
|
console_printf(Console_Default, "MMC3: Switch -> C/A\n");
|
||||||
mmc3_first_prom_page = 0xC000;
|
mmc3_first_prom_page = 0xC000;
|
||||||
mmc3_second_prom_page = 0xA000;
|
mmc3_second_prom_page = 0xA000;
|
||||||
|
|
||||||
@@ -159,9 +157,9 @@ void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
|||||||
|
|
||||||
//prg_bank(max_prg-1,prg1,prg0,max_prg);
|
//prg_bank(max_prg-1,prg1,prg0,max_prg);
|
||||||
}
|
}
|
||||||
mmc3_last_prom_switch = (Value & 0x40);
|
mmc3_last_prom_switch = (Value & 0x40);
|
||||||
}
|
}
|
||||||
mmc3_command = Value & 0x07;
|
mmc3_command = Value & 0x07;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -225,13 +223,13 @@ void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
|||||||
|
|
||||||
void mmc3_MapperWriteA0Hook(byte addr, byte Value)
|
void mmc3_MapperWriteA0Hook(byte addr, byte Value)
|
||||||
{
|
{
|
||||||
//printf("%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)
|
||||||
{
|
{
|
||||||
//printf("MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
|
//console_printf(Console_Default, "MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
|
||||||
|
|
||||||
if (Value & 0x1)
|
if (Value & 0x1)
|
||||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
||||||
@@ -241,7 +239,7 @@ void mmc3_MapperWriteA0Hook(byte addr, byte Value)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf("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();
|
map_sram();
|
||||||
else
|
else
|
||||||
@@ -250,11 +248,9 @@ void mmc3_MapperWriteA0Hook(byte addr, byte Value)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern unsigned short ScanLine;
|
|
||||||
|
|
||||||
void mmc3_MapperWriteC0Hook(byte addr, byte Value)
|
void mmc3_MapperWriteC0Hook(byte addr, byte Value)
|
||||||
{
|
{
|
||||||
//printf("%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;
|
||||||
|
|
||||||
@@ -262,33 +258,33 @@ void mmc3_MapperWriteC0Hook(byte addr, byte Value)
|
|||||||
{
|
{
|
||||||
mmc3_irq_counter_reload = Value;
|
mmc3_irq_counter_reload = Value;
|
||||||
mmc3_irq_counter = Value;
|
mmc3_irq_counter = Value;
|
||||||
//printf("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 */
|
}else{ /* C001 */
|
||||||
//printf("MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
|
//console_printf(Console_Default, "MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
|
||||||
//printf("MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, 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;
|
mmc3_irq_counter = Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmc3_MapperWriteE0Hook(byte addr, byte Value)
|
void mmc3_MapperWriteE0Hook(byte addr, byte Value)
|
||||||
{
|
{
|
||||||
//printf("%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)
|
||||||
{
|
{
|
||||||
//printf("MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
||||||
//printf("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 */
|
}else{ /* E001 */
|
||||||
//printf("MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
//console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
||||||
//printf("MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
|
//console_printf(Console_Default, "MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
|
||||||
//printf("MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
|
//console_printf(Console_Default, "MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
|
||||||
mmc3_irq_enable = 1;
|
mmc3_irq_enable = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,7 +305,7 @@ int mmc3_MapperIRQ(int cycledone)
|
|||||||
|
|
||||||
mmc3_irq_enable = 0;
|
mmc3_irq_enable = 0;
|
||||||
|
|
||||||
//printf("MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
|
//console_printf(Console_Default, "MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
20
src/mappersmanager/mappers/mmc3.h
Executable file
20
src/mappersmanager/mappers/mmc3.h
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* MMC3 Mapper - The TI-NESulator Project
|
||||||
|
* mmc3.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
void mmc3_MapperDump(FILE *fp);
|
||||||
|
int mmc3_InitMapper(NesCart * cart);
|
||||||
|
int mmc3_MapperIRQ(int cycledone);
|
||||||
@@ -3,15 +3,17 @@
|
|||||||
* mmc4.h
|
* mmc4.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-31 18:00:41 +0200 (jeu, 31 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mmc4.h $
|
* $HeadURL$
|
||||||
* $Revision: 56 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "mmc4.h"
|
||||||
|
|
||||||
byte mmc4_RegA;
|
byte mmc4_RegA;
|
||||||
byte mmc4_RegB;
|
byte mmc4_RegB;
|
||||||
byte mmc4_RegC;
|
byte mmc4_RegC;
|
||||||
@@ -20,16 +22,16 @@ byte mmc4_RegE;
|
|||||||
byte mmc4_RegF;
|
byte mmc4_RegF;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define LOG
|
#define LOG(s) printf s
|
||||||
//printf
|
|
||||||
#else
|
#else
|
||||||
#define LOG
|
#define LOG(s) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* MAPPER WARNING: This mapper need to attach to the PPU memory... Need more work on this parts.. */
|
||||||
|
|
||||||
void mmc4_MapperWriteRegA(register byte Addr, register byte Value)
|
void mmc4_MapperWriteRegA(register byte Addr, register byte 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);
|
||||||
@@ -38,7 +40,7 @@ void mmc4_MapperWriteRegA(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
void mmc4_MapperWriteRegB(register byte Addr, register byte Value)
|
void mmc4_MapperWriteRegB(register byte Addr, register byte 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);
|
||||||
@@ -46,28 +48,28 @@ void mmc4_MapperWriteRegB(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
void mmc4_MapperWriteRegC(register byte Addr, register byte Value)
|
void mmc4_MapperWriteRegC(register byte Addr, register byte 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 byte Addr, register byte Value)
|
void mmc4_MapperWriteRegD(register byte Addr, register byte 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 byte Addr, register byte Value)
|
void mmc4_MapperWriteRegE(register byte Addr, register byte 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 byte Addr, register byte Value)
|
void mmc4_MapperWriteRegF(register byte Addr, register byte 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);
|
||||||
@@ -85,10 +87,11 @@ int mmc4_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_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
if (cart->VROMSize > 0)
set_vrom_bank_8k(0x0000,0);
|
if (cart->VROMSize > 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++)
|
||||||
19
src/mappersmanager/mappers/mmc4.h
Normal file
19
src/mappersmanager/mappers/mmc4.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* MMC4 Mapper - The TI-NESulator Project
|
||||||
|
* mmc4.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
void mmc4_MapperDump(FILE *fp);
|
||||||
|
int mmc4_InitMapper(NesCart * cart);
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
|
* NOROM Mapper - The TI-NESulator Project
|
||||||
* norom.c
|
* norom.c
|
||||||
* TI-NESulator.X
|
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 25/10/07.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright 2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -11,8 +16,6 @@
|
|||||||
|
|
||||||
int norom_InitMapper(NesCart *cart)
|
int norom_InitMapper(NesCart *cart)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
set_page_ptr_16k(0x80, cart->PROMBanks);
|
set_page_ptr_16k(0x80, cart->PROMBanks);
|
||||||
|
|
||||||
/* mUBank = 0xC000 */
|
/* mUBank = 0xC000 */
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* norom.h
|
* NOROM Mapper - The TI-NESulator Project
|
||||||
* TI-NESulator.X
|
* norom.c
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 25/10/07.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright 2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,4 +18,3 @@
|
|||||||
int norom_InitMapper (NesCart *cart);
|
int norom_InitMapper (NesCart *cart);
|
||||||
int norom_MapperIRQ (int cycledone);
|
int norom_MapperIRQ (int cycledone);
|
||||||
void norom_MapperDump ();
|
void norom_MapperDump ();
|
||||||
void norom_MapperWriteHook(register byte Addr, register byte Value);
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* AOROM Mapper - The TI-NESulator Project
|
|
||||||
* aorom.h
|
|
||||||
*
|
|
||||||
* Created by Manoel TRAPIER.
|
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
|
||||||
*
|
|
||||||
* $LastChangedDate: 2007-04-26 18:47:34 +0200 (jeu, 26 avr 2007) $
|
|
||||||
* $Author: mtrapier $
|
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/aorom.h $
|
|
||||||
* $Revision: 46 $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned char aorom_load_bank;
|
|
||||||
|
|
||||||
void aorom_MapperWriteHook(register byte Addr, register byte Value);
|
|
||||||
|
|
||||||
extern byte *ppu_mem_nameTables;
|
|
||||||
|
|
||||||
int aorom_InitMapper(NesCart * cart)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
set_prom_bank_32k(0x8000,0);
|
|
||||||
|
|
||||||
ppu_setScreenMode(PPU_SCMODE_SINGLE);
|
|
||||||
|
|
||||||
aorom_load_bank = 0;
|
|
||||||
|
|
||||||
/* Register the write hook */
|
|
||||||
for (i = 0x80; i < 0x100; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, aorom_MapperWriteHook);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void aorom_MapperWriteHook(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
int BankNb;
|
|
||||||
|
|
||||||
if (Value & (1 << 4))
|
|
||||||
ppu_setSingleScreen(PPU_SCREEN_000);
|
|
||||||
else
|
|
||||||
ppu_setSingleScreen(PPU_SCREEN_400);
|
|
||||||
|
|
||||||
BankNb = Value & 0x0F;
|
|
||||||
|
|
||||||
aorom_load_bank = BankNb;
|
|
||||||
|
|
||||||
//printf("aorom: Asking bank %d (giving %d & %d) - mirror is %d\n",BankNb,BankNb,(Value<<1)+1,Value&0x0F);
|
|
||||||
set_prom_bank_32k(0x8000,BankNb);
|
|
||||||
}
|
|
||||||
|
|
||||||
void aorom_MapperDump(FILE *fp)
|
|
||||||
{
|
|
||||||
fprintf(fp,"aorom: bank:%d\n",aorom_load_bank);
|
|
||||||
}
|
|
||||||
@@ -3,18 +3,20 @@
|
|||||||
* unrom.h
|
* unrom.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/unrom.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "unrom.h"
|
||||||
|
|
||||||
unsigned char unrom_load_vbank;
|
unsigned char unrom_load_vbank;
|
||||||
|
|
||||||
void unrom_MapperWriteHook(register byte Addr, register byte Value);
|
void unrom_MapperWriteHook(byte Addr, byte Value);
|
||||||
|
|
||||||
int unrom_InitMapper(NesCart * cart)
|
int unrom_InitMapper(NesCart * cart)
|
||||||
{
|
{
|
||||||
@@ -39,7 +41,7 @@ int unrom_InitMapper(NesCart * cart)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void unrom_MapperWriteHook(register byte Addr, register byte Value)
|
void unrom_MapperWriteHook(byte Addr, byte Value)
|
||||||
{
|
{
|
||||||
set_vrom_bank_8k(0x0000,Value);
|
set_vrom_bank_8k(0x0000,Value);
|
||||||
unrom_load_vbank = Value;
|
unrom_load_vbank = Value;
|
||||||
19
src/mappersmanager/mappers/unrom.h
Executable file
19
src/mappersmanager/mappers/unrom.h
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* UNROM Mapper - The TI-NESulator Project
|
||||||
|
* unrom.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
int unrom_InitMapper(NesCart * cart);
|
||||||
|
void unrom_MapperDump(FILE *fp);
|
||||||
68
src/mappersmanager/mappers/unrom512.c
Executable file
68
src/mappersmanager/mappers/unrom512.c
Executable file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* UNROM Mapper - The TI-NESulator Project
|
||||||
|
* unrom.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ppu/ppu.h>
|
||||||
|
#include "unrom512.h"
|
||||||
|
|
||||||
|
static byte mirroring_set;
|
||||||
|
static byte loaded_vbank;
|
||||||
|
static byte loaded_pbank;
|
||||||
|
static void unrom512_applyValues()
|
||||||
|
{
|
||||||
|
/*if (mirroring_set)
|
||||||
|
{
|
||||||
|
ppu_setMirroring(PPU);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//set_vrom_bank_8k(0x0000, loaded_vbank);
|
||||||
|
set_prom_bank_16k(0x8000, loaded_pbank);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unrom512_MapperWriteHook(byte Addr, byte Value)
|
||||||
|
{
|
||||||
|
mirroring_set = (Value >> 7) & 0x01;
|
||||||
|
loaded_vbank = (Value >> 5) & 0x03;
|
||||||
|
loaded_pbank = (Value ) & 0x1F;
|
||||||
|
|
||||||
|
unrom512_applyValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
int unrom512_InitMapper(NesCart * cart)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
loaded_vbank = 0;
|
||||||
|
loaded_pbank = 0;
|
||||||
|
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||||
|
|
||||||
|
unrom512_applyValues();
|
||||||
|
|
||||||
|
/* Register the write hook */
|
||||||
|
for (i = 0x80; i < 0x100; i++)
|
||||||
|
{
|
||||||
|
set_page_wr_hook(i, unrom512_MapperWriteHook);
|
||||||
|
set_page_writeable(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unrom512_MapperDump(FILE *fp)
|
||||||
|
{
|
||||||
|
fprintf(fp,"unrom512: vbank:%d pbank:%d\n", loaded_vbank, loaded_pbank);
|
||||||
|
}
|
||||||
19
src/mappersmanager/mappers/unrom512.h
Executable file
19
src/mappersmanager/mappers/unrom512.h
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* UNROM Mapper - The TI-NESulator Project
|
||||||
|
* unrom.h
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __TINES_MAPPERS__
|
||||||
|
#include <mappers/manager.h>
|
||||||
|
|
||||||
|
int unrom512_InitMapper(NesCart * cart);
|
||||||
|
void unrom512_MapperDump(FILE *fp);
|
||||||
@@ -1,20 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
|
* Mapper list - The TI-NESulator Project
|
||||||
* mappers_list.h
|
* mappers_list.h
|
||||||
* TI-NESulator.X
|
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 25/10/07.
|
* Created by Manoel TRAPIER on 25/10/07.
|
||||||
* Copyright 2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This file could be generated from the mappers directory... */
|
/* This file could be generated from the mappers directory... */
|
||||||
#include "mappers/norom.h"
|
#include "mappers/norom.h"
|
||||||
|
#include "mappers/aorom.h"
|
||||||
|
#include "mappers/unrom.h"
|
||||||
|
#include "mappers/cnrom.h"
|
||||||
|
|
||||||
|
#include "mappers/unrom512.h"
|
||||||
|
|
||||||
|
#include "mappers/iremh3001.h"
|
||||||
|
|
||||||
#include "mappers/mmc1.h"
|
#include "mappers/mmc1.h"
|
||||||
|
#include "mappers/mmc3.h"
|
||||||
|
#include "mappers/mmc4.h"
|
||||||
|
|
||||||
Mapper Mappers[] = {
|
Mapper Mappers[] = {
|
||||||
{ 0, "No Mapper", norom_InitMapper, norom_MapperIRQ, norom_MapperDump },
|
{ 0 , "No Mapper", norom_InitMapper, norom_MapperIRQ, norom_MapperDump },
|
||||||
{ 1, "MMC1", mmc1_InitMapper, norom_MapperIRQ, mmc1_MapperDump },
|
{ 7 , "AOROM", aorom_InitMapper, norom_MapperIRQ, aorom_MapperDump },
|
||||||
|
{ 2 , "CNROM", cnrom_InitMapper, norom_MapperIRQ, cnrom_MapperDump },
|
||||||
|
{ 3 , "UNROM", unrom_InitMapper, norom_MapperIRQ, unrom_MapperDump },
|
||||||
|
|
||||||
|
{ 1 , "MMC1", mmc1_InitMapper, norom_MapperIRQ, mmc1_MapperDump },
|
||||||
|
{ 4 , "MMC3", mmc3_InitMapper, mmc3_MapperIRQ, mmc3_MapperDump },
|
||||||
|
{ 10, "MMC4", mmc4_InitMapper, norom_MapperIRQ, mmc4_MapperDump },
|
||||||
|
|
||||||
|
{ 30, "UNROM512", unrom512_InitMapper, norom_MapperIRQ, unrom512_MapperDump },
|
||||||
|
|
||||||
|
{ 65, "Irem H3001", iremh3001_InitMapper, iremh3001_MapperIRQ, iremh3001_MapperDump },
|
||||||
|
|
||||||
|
|
||||||
|
{ 100, "Floppy Disk System", NULL, norom_MapperIRQ, norom_MapperDump },
|
||||||
/* EOL tag */
|
/* EOL tag */
|
||||||
{ 0, NULL, NULL, NULL, NULL }
|
{ 0, NULL, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* CNROM Mapper - The TI-NESulator Project
|
|
||||||
* cnrom.h
|
|
||||||
*
|
|
||||||
* Created by Manoel TRAPIER.
|
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
|
||||||
*
|
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
|
||||||
* $Author: godzil $
|
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/cnrom.h $
|
|
||||||
* $Revision: 39 $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned char cnrom_load_bank;
|
|
||||||
|
|
||||||
void cnrom_MapperWriteHook(register byte Addr, register byte Value);
|
|
||||||
|
|
||||||
int cnrom_InitMapper(NesCart * cart)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, 0);
|
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart)); /* Set the last one */
|
|
||||||
cnrom_load_bank = 0;
|
|
||||||
|
|
||||||
/* Register the write hook */
|
|
||||||
for (i = 0x80; i < 0x100; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, cnrom_MapperWriteHook);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void cnrom_MapperWriteHook(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
set_prom_bank_16k(0x8000,Value);
|
|
||||||
cnrom_load_bank = Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cnrom_MapperDump(FILE *fp)
|
|
||||||
{
|
|
||||||
fprintf(fp,"cnrom: bank:%d\n",cnrom_load_bank);
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,12 @@
|
|||||||
* genericmapper.h
|
* genericmapper.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: godzil $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/genericmapper.h $
|
* $HeadURL$
|
||||||
* $Revision: 39 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
* IREMH3001 Mapper - The TI-NESulator Project
|
|
||||||
* iremh3001.h
|
|
||||||
*
|
|
||||||
* Created by Manoel TRAPIER.
|
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
|
||||||
*
|
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
|
||||||
* $Author: godzil $
|
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/iremh3001.h $
|
|
||||||
* $Revision: 39 $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned short iremh3001_prom_slot[3];
|
|
||||||
|
|
||||||
unsigned short iremh3001_vrom_slot[8];
|
|
||||||
|
|
||||||
int iremh3001_InitMapper(NesCart * cart)
|
|
||||||
{
|
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, 0);
|
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
|
||||||
|
|
||||||
iremh3001_prom_slot[0] = 0;
|
|
||||||
iremh3001_prom_slot[1] = 1;
|
|
||||||
iremh3001_prom_slot[2] = GETLAST16KBANK(cart);
|
|
||||||
|
|
||||||
set_vrom_bank_8k(0x0000,4);
|
|
||||||
|
|
||||||
iremh3001_vrom_slot[0] = 0;
|
|
||||||
iremh3001_vrom_slot[1] = 0;
|
|
||||||
iremh3001_vrom_slot[2] = 0;
|
|
||||||
iremh3001_vrom_slot[3] = 0;
|
|
||||||
iremh3001_vrom_slot[4] = 0;
|
|
||||||
iremh3001_vrom_slot[5] = 0;
|
|
||||||
iremh3001_vrom_slot[6] = 0;
|
|
||||||
iremh3001_vrom_slot[7] = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int iremh3001_MapperWriteHook(register word Addr, register byte Value)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch(Addr)
|
|
||||||
{
|
|
||||||
case 0x8000: /* Set 8k PROM @ 8000 */
|
|
||||||
printf("iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
|
||||||
set_prom_bank_8k(0x8000, Value);
|
|
||||||
iremh3001_prom_slot[0] = Value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x9003: /* Mirroring ??? */
|
|
||||||
printf("iremh3001: Mirroring[0x%X:%d] ?\n", Value, Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x9005: /* IRQ ??? */
|
|
||||||
printf("iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x9006: /* IRQ ??? */
|
|
||||||
printf("iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xA000: /* Set 8k PROM @ A000 */
|
|
||||||
printf("iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
|
||||||
set_prom_bank_8k(0xA000, Value);
|
|
||||||
iremh3001_prom_slot[1] = Value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xB000: /* Set 1k VROM @ 0000 */
|
|
||||||
case 0xB001: /* Set 1k VROM @ 0400 */
|
|
||||||
case 0xB002: /* Set 1k VROM @ 0800 */
|
|
||||||
case 0xB003: /* Set 1k VROM @ 0C00 */
|
|
||||||
case 0xB004: /* Set 1k VROM @ 1000 */
|
|
||||||
case 0xB005: /* Set 1k VROM @ 1400 */
|
|
||||||
case 0xB006: /* Set 1k VROM @ 1800 */
|
|
||||||
case 0xB007: /* Set 1k VROM @ 1C00 */
|
|
||||||
printf("iremh3001: %X: change VROM to %d[%X]\n", (Addr&0x0F)<<10, Value, Value);
|
|
||||||
set_vrom_bank_1k((Addr&0xF)<<10, Value);
|
|
||||||
iremh3001_vrom_slot[Addr&0x0F] = Value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xC000: /* Set 8k PROM @ C000 */
|
|
||||||
printf("iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
|
|
||||||
set_prom_bank_8k(0xC000, Value);
|
|
||||||
iremh3001_prom_slot[2] = Value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
printf("@:%X -- V:%X", Addr, Value);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void iremh3001_MapperDump(FILE *fp)
|
|
||||||
{
|
|
||||||
fprintf(fp,"iremh3001: prom: $8000:%d $A000:%d $C000:%d\n",
|
|
||||||
iremh3001_prom_slot[0],
|
|
||||||
iremh3001_prom_slot[1],
|
|
||||||
iremh3001_prom_slot[2]);
|
|
||||||
|
|
||||||
fprintf(fp,"iremh3001: vrom: $0000:%d $0400:%d $0800:%d $0C00:%d\n" \
|
|
||||||
" $1000:%d $1400:%d $1800:%d $1C00:%d\n",
|
|
||||||
iremh3001_vrom_slot[0],
|
|
||||||
iremh3001_vrom_slot[1],
|
|
||||||
iremh3001_vrom_slot[2],
|
|
||||||
iremh3001_vrom_slot[3],
|
|
||||||
iremh3001_vrom_slot[4],
|
|
||||||
iremh3001_vrom_slot[5],
|
|
||||||
iremh3001_vrom_slot[6],
|
|
||||||
iremh3001_prom_slot[7]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int iremh3001_MapperIRQ(int cycledone)
|
|
||||||
{
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,12 @@
|
|||||||
* mmc1.h
|
* mmc1.h
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mmc1.h $
|
* $HeadURL$
|
||||||
* $Revision: 50 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
unsigned char MMC1_reg0;
|
unsigned char MMC1_reg0;
|
||||||
@@ -137,7 +137,7 @@ void mmc1_ApplyReg0Mod()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//printf("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)
|
||||||
{
|
{
|
||||||
@@ -189,7 +189,7 @@ void mmc1_MapperWriteReg0(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
MMC1_reg0 = MMC1_REG0_DEFAULT;
|
||||||
printf("MMC1: Reg0 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg0 Reset occured !\n");
|
||||||
mmc1_ApplyReg0Mod();
|
mmc1_ApplyReg0Mod();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -216,7 +216,7 @@ void mmc1_MapperWriteReg1(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
MMC1_reg1 = MMC1_REG1_DEFAULT;
|
||||||
printf("MMC1: Reg1 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -236,18 +236,18 @@ void mmc1_MapperWriteReg1(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
if (Cart->VROMSize == 0)
|
if (Cart->VROMSize == 0)
|
||||||
{
|
{
|
||||||
printf("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 */
|
||||||
//printf("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 */
|
||||||
//printf("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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ void mmc1_MapperWriteReg2(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
MMC1_reg2 = MMC1_REG2_DEFAULT;
|
||||||
printf("MMC1: Reg2 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -277,21 +277,21 @@ void mmc1_MapperWriteReg2(register byte Addr, register byte Value)
|
|||||||
|
|
||||||
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
|
||||||
|
|
||||||
//printf("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)
|
||||||
{
|
{
|
||||||
//printf(": 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 */
|
||||||
//printf("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 */
|
||||||
// printf("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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
if (Value & 0x80)
|
if (Value & 0x80)
|
||||||
{
|
{
|
||||||
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
MMC1_reg3 = MMC1_REG3_DEFAULT;
|
||||||
printf("MMC1: Reg3 Reset occured !\n");
|
console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -327,12 +327,12 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
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);
|
||||||
//printf("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);
|
||||||
//printf("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
|
||||||
@@ -352,4 +352,4 @@ void mmc1_MapperWriteReg3(register byte Addr, register byte Value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("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);
|
||||||
|
|||||||
@@ -1,317 +0,0 @@
|
|||||||
/*
|
|
||||||
* MMC3 Mapper - The TI-NESulator Project
|
|
||||||
* mmc3.h
|
|
||||||
*
|
|
||||||
* Created by Manoel TRAPIER.
|
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
|
||||||
*
|
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
|
||||||
* $Author: mtrapier $
|
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mmc3.h $
|
|
||||||
* $Revision: 50 $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned short mmc3_command;
|
|
||||||
|
|
||||||
unsigned char mmc3_irq_counter;
|
|
||||||
unsigned char mmc3_irq_counter_reload;
|
|
||||||
unsigned char mmc3_irq_enable;
|
|
||||||
|
|
||||||
unsigned short mmc3_first_prom_page;
|
|
||||||
unsigned short mmc3_second_prom_page;
|
|
||||||
|
|
||||||
unsigned char mmc3_use_xor;
|
|
||||||
unsigned char mmc3_last_vrom[6];
|
|
||||||
|
|
||||||
unsigned char mmc3_last_prom[2];
|
|
||||||
unsigned char mmc3_last_prom_switch;
|
|
||||||
|
|
||||||
unsigned short dummy;
|
|
||||||
|
|
||||||
void mmc3_MapperWrite80Hook(byte addr, byte value);
|
|
||||||
void mmc3_MapperWriteA0Hook(byte addr, byte value);
|
|
||||||
void mmc3_MapperWriteC0Hook(byte addr, byte value);
|
|
||||||
void mmc3_MapperWriteE0Hook(byte addr, byte value);
|
|
||||||
|
|
||||||
void mmc3_MapperDump(FILE *fp)
|
|
||||||
{
|
|
||||||
fprintf(fp,"MMC3: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n",mmc3_command,mmc3_irq_counter,mmc3_irq_counter_reload,mmc3_irq_enable,mmc3_first_prom_page,mmc3_second_prom_page,mmc3_use_xor);
|
|
||||||
fprintf(fp,"MMC3: LV0:%d LV1:%d LV2:%d LV3:%d LV4:%d LV5:%d\n",mmc3_last_vrom[0],mmc3_last_vrom[1],mmc3_last_vrom[2],mmc3_last_vrom[3],mmc3_last_vrom[4],mmc3_last_vrom[5]);
|
|
||||||
fprintf(fp,"MMC3: LP0:%d LP1:%d LPS:%d\n",mmc3_last_prom[0],mmc3_last_prom[1],mmc3_last_prom_switch);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mmc3_InitMapper(NesCart * cart)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, 0);
|
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
|
||||||
|
|
||||||
if ( Cart->VROMSize > 0)
|
|
||||||
{
|
|
||||||
set_vrom_bank_8k(0, 0x0000);
|
|
||||||
}
|
|
||||||
|
|
||||||
mmc3_command = -1;
|
|
||||||
|
|
||||||
mmc3_irq_counter = -1;
|
|
||||||
mmc3_irq_enable = 1;
|
|
||||||
mmc3_irq_counter_reload = 0;
|
|
||||||
|
|
||||||
mmc3_use_xor = 0x42;
|
|
||||||
|
|
||||||
mmc3_last_prom_switch = 0x42;
|
|
||||||
|
|
||||||
mmc3_last_prom[0] = 0;
|
|
||||||
mmc3_last_prom[1] = 1;
|
|
||||||
|
|
||||||
mmc3_last_vrom[0] = 0;
|
|
||||||
mmc3_last_vrom[1] = 2;
|
|
||||||
mmc3_last_vrom[2] = 3;
|
|
||||||
mmc3_last_vrom[3] = 4;
|
|
||||||
mmc3_last_vrom[4] = 5;
|
|
||||||
mmc3_last_vrom[5] = 6;
|
|
||||||
|
|
||||||
mmc3_first_prom_page = 0x8000;
|
|
||||||
mmc3_second_prom_page = 0xA000;
|
|
||||||
//mmc3_first_prom_page = 0; // Set it to 0x8000
|
|
||||||
|
|
||||||
|
|
||||||
/* Register mapper write hook */
|
|
||||||
set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
|
|
||||||
set_page_writeable(0x80, true);
|
|
||||||
|
|
||||||
set_page_wr_hook(0xA0, mmc3_MapperWriteA0Hook);
|
|
||||||
set_page_writeable(0xA0, true);
|
|
||||||
|
|
||||||
set_page_wr_hook(0xC0, mmc3_MapperWriteC0Hook);
|
|
||||||
set_page_writeable(0xC0, true);
|
|
||||||
|
|
||||||
set_page_wr_hook(0xE0, mmc3_MapperWriteE0Hook);
|
|
||||||
set_page_writeable(0xE0, true);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc3_MapperWrite80Hook(byte addr, byte Value)
|
|
||||||
{
|
|
||||||
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
|
||||||
if (addr > 0x01)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!addr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ((Cart->VROMSize > 0) && ( mmc3_use_xor != (Value & 0x80) ))
|
|
||||||
{
|
|
||||||
if (Value & 0x80)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
mmc3_use_xor = (Value & 0x80);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (mmc3_last_prom_switch != (Value & 0x40))
|
|
||||||
{
|
|
||||||
if (!(Value & 0x40))
|
|
||||||
{
|
|
||||||
printf("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
|
|
||||||
{
|
|
||||||
printf("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_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]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
mmc3_last_prom[1] = Value;
|
|
||||||
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if(mmc3_use_xor)
|
|
||||||
chr_bank(chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1);
|
|
||||||
else
|
|
||||||
chr_bank(chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc3_MapperWriteA0Hook(byte addr, byte Value)
|
|
||||||
{
|
|
||||||
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
|
||||||
if (addr > 0x01)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!addr)
|
|
||||||
{
|
|
||||||
//printf("MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
|
|
||||||
|
|
||||||
if (Value & 0x1)
|
|
||||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
|
||||||
else
|
|
||||||
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//printf("MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
|
|
||||||
if (Value)
|
|
||||||
map_sram();
|
|
||||||
else
|
|
||||||
unmap_sram();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extern unsigned short ScanLine;
|
|
||||||
|
|
||||||
void mmc3_MapperWriteC0Hook(byte addr, byte Value)
|
|
||||||
{
|
|
||||||
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
|
||||||
if (addr > 0x01)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!addr)
|
|
||||||
{
|
|
||||||
mmc3_irq_counter_reload = Value;
|
|
||||||
mmc3_irq_counter = Value;
|
|
||||||
//printf("MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
|
|
||||||
|
|
||||||
}else{ /* C001 */
|
|
||||||
//printf("MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
|
|
||||||
//printf("MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, Value);
|
|
||||||
mmc3_irq_counter = Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc3_MapperWriteE0Hook(byte addr, byte Value)
|
|
||||||
{
|
|
||||||
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
|
|
||||||
if (addr > 0x01)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!addr)
|
|
||||||
{
|
|
||||||
//printf("MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
|
||||||
//printf("MMC3 IRQ[%d]: IRQ disabled\n", ScanLine);
|
|
||||||
mmc3_irq_enable = 0;
|
|
||||||
//MapperWantIRQ = 1;
|
|
||||||
// Add a way to raise an IRQ
|
|
||||||
|
|
||||||
}else{ /* E001 */
|
|
||||||
//printf("MMC3: Writing to 0xE001 : 0x%X\n",Value);
|
|
||||||
//printf("MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
|
|
||||||
//printf("MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
|
|
||||||
mmc3_irq_enable = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int mmc3_MapperIRQ(int cycledone)
|
|
||||||
{
|
|
||||||
if (((cycledone > 0) && (cycledone < 241)) /*&&
|
|
||||||
(ppu.ControlRegister2.b & (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)) == (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)*/)
|
|
||||||
{
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
mmc3_irq_enable = 0;
|
|
||||||
|
|
||||||
//printf("MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* MMC4 Mapper - The TI-NESulator Project
|
|
||||||
* mmc4.h
|
|
||||||
*
|
|
||||||
* Created by Manoel TRAPIER.
|
|
||||||
* Copyright (c) 2007 986Corp. All rights reserved.
|
|
||||||
*
|
|
||||||
* $LastChangedDate: 2007-05-31 18:00:41 +0200 (jeu, 31 mai 2007) $
|
|
||||||
* $Author: mtrapier $
|
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mmc4.h $
|
|
||||||
* $Revision: 56 $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
byte mmc4_RegA;
|
|
||||||
byte mmc4_RegB;
|
|
||||||
byte mmc4_RegC;
|
|
||||||
byte mmc4_RegD;
|
|
||||||
byte mmc4_RegE;
|
|
||||||
byte mmc4_RegF;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define LOG
|
|
||||||
//printf
|
|
||||||
#else
|
|
||||||
#define LOG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void mmc4_MapperWriteRegA(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
|
|
||||||
mmc4_RegA = Value;
|
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000, Value & 0x0F);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc4_MapperWriteRegB(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
|
|
||||||
mmc4_RegB = Value;
|
|
||||||
|
|
||||||
set_vrom_bank_4k(0x0000, Value & 0x1F);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc4_MapperWriteRegC(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
|
|
||||||
mmc4_RegC = Value;
|
|
||||||
set_vrom_bank_4k(0x0000, Value & 0x1F);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc4_MapperWriteRegD(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
|
|
||||||
mmc4_RegD = Value;
|
|
||||||
set_vrom_bank_4k(0x1000, Value & 0x1F);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc4_MapperWriteRegE(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
|
|
||||||
mmc4_RegE = Value;
|
|
||||||
set_vrom_bank_4k(0x1000, Value & 0x1F);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmc4_MapperWriteRegF(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
|
|
||||||
mmc4_RegF = Value;
|
|
||||||
if (Value & 0x01)
|
|
||||||
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
|
|
||||||
else
|
|
||||||
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void mmc4_MapperDump(FILE *fp)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int mmc4_InitMapper(NesCart * cart)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
set_prom_bank_16k(0x8000,0);
|
|
||||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
|
||||||
|
|
||||||
if (cart->VROMSize > 0)
|
|
||||||
set_vrom_bank_8k(0x0000,0);
|
|
||||||
|
|
||||||
/* Mapper should register itself for write hook */
|
|
||||||
for (i = 0xA0; i < 0xB0 ; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc4_MapperWriteRegA);
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, mmc4_MapperWriteRegC);
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
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_setMirroring(PPU_MIRROR_HORIZTAL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* UNROM Mapper - The TI-NESulator Project
|
|
||||||
* unrom.h
|
|
||||||
*
|
|
||||||
* Created by Manoel TRAPIER.
|
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
|
||||||
*
|
|
||||||
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
|
|
||||||
* $Author: godzil $
|
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/unrom.h $
|
|
||||||
* $Revision: 39 $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned char unrom_load_vbank;
|
|
||||||
|
|
||||||
void unrom_MapperWriteHook(register byte Addr, register byte Value);
|
|
||||||
|
|
||||||
int unrom_InitMapper(NesCart * cart)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
set_prom_bank_16k(0xC000, 0);
|
|
||||||
set_prom_bank_16k(0x8000, GETLAST16KBANK(cart)); /* Set the last one */
|
|
||||||
|
|
||||||
if (Cart->VROMSize > 0)
|
|
||||||
set_vrom_bank_8k(0x0000,0);
|
|
||||||
|
|
||||||
unrom_load_vbank = 0;
|
|
||||||
|
|
||||||
/* Register the write hook */
|
|
||||||
for (i = 0x80; i < 0x100; i++)
|
|
||||||
{
|
|
||||||
set_page_wr_hook(i, unrom_MapperWriteHook);
|
|
||||||
set_page_writeable(i, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void unrom_MapperWriteHook(register byte Addr, register byte Value)
|
|
||||||
{
|
|
||||||
set_vrom_bank_8k(0x0000,Value);
|
|
||||||
unrom_load_vbank = Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unrom_MapperDump(FILE *fp)
|
|
||||||
{
|
|
||||||
fprintf(fp,"unrom: vbank:%d\n",unrom_load_vbank);
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,12 @@
|
|||||||
* mappers.c
|
* mappers.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-31 18:00:41 +0200 (jeu, 31 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/mappers.c $
|
* $HeadURL$
|
||||||
* $Revision: 56 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
#include <mappers/manager.h>
|
#include <mappers/manager.h>
|
||||||
#include <memory/manager.h>
|
#include <memory/manager.h>
|
||||||
|
|
||||||
|
#define __TINES_PPU_INTERNAL__
|
||||||
|
#include <ppu/ppu.memory.h>
|
||||||
|
#undef __TINES_PPU_INTERNAL__
|
||||||
|
|
||||||
extern NesCart *Cart;
|
extern NesCart *Cart;
|
||||||
|
|
||||||
extern char MapperWantIRQ;
|
extern char MapperWantIRQ;
|
||||||
@@ -34,7 +38,7 @@ extern char MapperWantIRQ;
|
|||||||
void set_vrom_bank_1k(unsigned short addr,int slot)
|
void set_vrom_bank_1k(unsigned short addr,int slot)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_VROM_BANK_SWITCH
|
#ifdef DEBUG_VROM_BANK_SWITCH
|
||||||
printf("Change vrom 1k bank 0x%X to slot %d\n",addr,slot);
|
console_printf(Console_Default, "Change vrom 1k bank 0x%X to slot %d\n",addr,slot);
|
||||||
#endif
|
#endif
|
||||||
ppu_setPagePtr1k((addr>>8)&0xFF, Cart->VROMBanks + (slot * 1024));
|
ppu_setPagePtr1k((addr>>8)&0xFF, Cart->VROMBanks + (slot * 1024));
|
||||||
// memcpy(ppu.Memory+addr, Cart->VROMBanks + (slot * 1024), 0x0400);
|
// memcpy(ppu.Memory+addr, Cart->VROMBanks + (slot * 1024), 0x0400);
|
||||||
@@ -43,7 +47,7 @@ void set_vrom_bank_1k(unsigned short addr,int slot)
|
|||||||
void set_vrom_bank_2k(unsigned short addr,int slot)
|
void set_vrom_bank_2k(unsigned short addr,int slot)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_VROM_BANK_SWITCH
|
#ifdef DEBUG_VROM_BANK_SWITCH
|
||||||
printf("Change vrom 2k bank 0x%X to slot %d\n",addr,slot);
|
console_printf(Console_Default, "Change vrom 2k bank 0x%X to slot %d\n",addr,slot);
|
||||||
#endif
|
#endif
|
||||||
ppu_setPagePtr2k((addr>>8)&0xFF, Cart->VROMBanks + (slot * 2 * 1024));
|
ppu_setPagePtr2k((addr>>8)&0xFF, Cart->VROMBanks + (slot * 2 * 1024));
|
||||||
// memcpy(ppu.Memory+addr, Cart->VROMBanks + (slot * 2 * 1024), 0x0800);
|
// memcpy(ppu.Memory+addr, Cart->VROMBanks + (slot * 2 * 1024), 0x0800);
|
||||||
@@ -52,7 +56,7 @@ void set_vrom_bank_2k(unsigned short addr,int slot)
|
|||||||
void set_vrom_bank_4k(unsigned short addr,int slot)
|
void set_vrom_bank_4k(unsigned short addr,int slot)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_VROM_BANK_SWITCH
|
#ifdef DEBUG_VROM_BANK_SWITCH
|
||||||
printf("Change vrom 4k bank 0x%X to slot %d\n",addr,slot);
|
console_printf(Console_Default, "Change vrom 4k bank 0x%X to slot %d\n",addr,slot);
|
||||||
#endif
|
#endif
|
||||||
ppu_setPagePtr4k((addr>>8)&0xFF, Cart->VROMBanks + (slot * 4 * 1024));
|
ppu_setPagePtr4k((addr>>8)&0xFF, Cart->VROMBanks + (slot * 4 * 1024));
|
||||||
// memcpy(ppu.Memory+addr, Cart->VROMBanks + (slot * 4 * 1024), 0x1000);
|
// memcpy(ppu.Memory+addr, Cart->VROMBanks + (slot * 4 * 1024), 0x1000);
|
||||||
@@ -61,7 +65,7 @@ void set_vrom_bank_4k(unsigned short addr,int slot)
|
|||||||
void set_vrom_bank_8k(unsigned short addr, int slot)
|
void set_vrom_bank_8k(unsigned short addr, int slot)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_VROM_BANK_SWITCH
|
#ifdef DEBUG_VROM_BANK_SWITCH
|
||||||
printf("Change vrom 8k bank 0x%X to slot %d\n",addr,slot);
|
console_printf(Console_Default, "Change vrom 8k bank 0x%X to slot %d\n",addr,slot);
|
||||||
#endif
|
#endif
|
||||||
ppu_setPagePtr8k(0x00, Cart->VROMBanks + (slot * 8 * 1024));
|
ppu_setPagePtr8k(0x00, Cart->VROMBanks + (slot * 8 * 1024));
|
||||||
// memcpy(ppu.Memory, Cart->VROMBanks + (slot * 8 * 1024) , 0x2000);
|
// memcpy(ppu.Memory, Cart->VROMBanks + (slot * 8 * 1024) , 0x2000);
|
||||||
@@ -72,7 +76,7 @@ void set_vrom_bank_8k(unsigned short addr, int slot)
|
|||||||
void set_prom_bank_8k(unsigned short addr,int slot)
|
void set_prom_bank_8k(unsigned short addr,int slot)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_PROM_BANK_SWITCH
|
#ifdef DEBUG_PROM_BANK_SWITCH
|
||||||
printf("Change prom 8k bank 0x%X to slot %d\n",addr,slot);
|
console_printf(Console_Default, "Change prom 8k bank 0x%X to slot %d\n",addr,slot);
|
||||||
#endif
|
#endif
|
||||||
set_page_ptr_8k(addr >> 8, Cart->PROMBanks + (slot * 8 * 1024));
|
set_page_ptr_8k(addr >> 8, Cart->PROMBanks + (slot * 8 * 1024));
|
||||||
}
|
}
|
||||||
@@ -80,7 +84,7 @@ void set_prom_bank_8k(unsigned short addr,int slot)
|
|||||||
void set_prom_bank_16k(unsigned short addr,int slot)
|
void set_prom_bank_16k(unsigned short addr,int slot)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_PROM_BANK_SWITCH
|
#ifdef DEBUG_PROM_BANK_SWITCH
|
||||||
printf("Change prom 16k bank @ 0x%X [0x%X] to slot 0x%X\n",addr, addr>>8,slot);
|
console_printf(Console_Default, "Change prom 16k bank @ 0x%X [0x%X] to slot 0x%X\n",addr, addr>>8,slot);
|
||||||
#endif
|
#endif
|
||||||
set_page_ptr_16k(addr >> 8, Cart->PROMBanks + (slot * 16 * 1024));
|
set_page_ptr_16k(addr >> 8, Cart->PROMBanks + (slot * 16 * 1024));
|
||||||
}
|
}
|
||||||
@@ -89,7 +93,7 @@ void set_prom_bank_32k(unsigned short addr,int slot)
|
|||||||
{ /* addr may not be different from 0x8000 !*/
|
{ /* addr may not be different from 0x8000 !*/
|
||||||
/* Anyway I don't use it */
|
/* Anyway I don't use it */
|
||||||
#ifdef DEBUG_PROM_BANK_SWITCH
|
#ifdef DEBUG_PROM_BANK_SWITCH
|
||||||
printf("Change prom 32k bank 0x%X to slot %d\n",addr,slot);
|
console_printf(Console_Default, "Change prom 32k bank 0x%X to slot %d\n",addr,slot);
|
||||||
#endif
|
#endif
|
||||||
set_page_ptr_32k(addr >> 8, Cart->PROMBanks + (slot * 32 * 1024));
|
set_page_ptr_32k(addr >> 8, Cart->PROMBanks + (slot * 32 * 1024));
|
||||||
/* set_page_ptr_16k(0x80, Cart->PROMBanks[(slot<<1)]);
|
/* set_page_ptr_16k(0x80, Cart->PROMBanks[(slot<<1)]);
|
||||||
|
|||||||
16
src/memorymanager/CMakeLists.txt
Normal file
16
src/memorymanager/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
set(COVERAGE_SRCS src/memorymanager/memory.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(memorymanager memory.c)
|
||||||
@@ -2,20 +2,22 @@
|
|||||||
* 6502 Memory manager - The TI-NESulator Project
|
* 6502 Memory manager - The TI-NESulator Project
|
||||||
* memory.c - Taken from the Quick6502 project
|
* memory.c - Taken from the Quick6502 project
|
||||||
*
|
*
|
||||||
* Created by Manoël Trapier on 18/09/06.
|
* Created by Manoel Trapier on 18/09/06.
|
||||||
* Copyright 2003-2007 986 Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/memory.c $
|
* $HeadURL$
|
||||||
* $Revision: 50 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "types.h"
|
#include <types.h>
|
||||||
#include "../include/memory/manager.h"
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
#include <memory/manager.h>
|
||||||
|
|
||||||
/* Private structures */
|
/* Private structures */
|
||||||
|
|
||||||
@@ -50,13 +52,13 @@ func_wrhook wrh_table[0x100];
|
|||||||
/* Public functions */
|
/* Public functions */
|
||||||
void set_page_ptr(byte page, byte *ptr)
|
void set_page_ptr(byte page, byte *ptr)
|
||||||
{
|
{
|
||||||
LOG(printf("Set page 0x%X to ptr %p\n", page, ptr));
|
LOG(console_printf(Console_Default, "Set page 0x%X to ptr %p\n", page, ptr));
|
||||||
memory_pages[page] = ptr;
|
memory_pages[page] = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_page_ptr_1k(byte page, byte *ptr)
|
void set_page_ptr_1k(byte page, byte *ptr)
|
||||||
{ /* 1k = 4 * 256 */
|
{ /* 1k = 4 * 256 */
|
||||||
LOG(printf("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);
|
||||||
@@ -65,7 +67,7 @@ void set_page_ptr_1k(byte page, byte *ptr)
|
|||||||
|
|
||||||
void set_page_ptr_2k(byte page, byte *ptr)
|
void set_page_ptr_2k(byte page, byte *ptr)
|
||||||
{
|
{
|
||||||
LOG(printf("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);
|
||||||
@@ -78,14 +80,14 @@ void set_page_ptr_2k(byte page, byte *ptr)
|
|||||||
|
|
||||||
void set_page_ptr_4k(byte page, byte *ptr)
|
void set_page_ptr_4k(byte page, byte *ptr)
|
||||||
{
|
{
|
||||||
LOG(printf("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 KBYTE / 256) / 2), ptr + 2 KBYTE);
|
set_page_ptr_2k(page+((4 KBYTE / 256) / 2), ptr + 2 KBYTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_page_ptr_8k(byte page, byte *ptr)
|
void set_page_ptr_8k(byte page, byte *ptr)
|
||||||
{
|
{
|
||||||
LOG(printf("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 KBYTE / 256) / 2), ptr + 4 KBYTE);
|
set_page_ptr_4k(page+((8 KBYTE / 256) / 2), ptr + 4 KBYTE);
|
||||||
}
|
}
|
||||||
@@ -195,26 +197,23 @@ func_wrhook get_page_wrhook(byte page)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
byte ReadMemory(byte page, byte addr)
|
byte ReadMemory(byte page, byte addr)
|
||||||
{
|
{
|
||||||
static byte LastRetByte = 0xA5;
|
static byte LastRetByte = 0xA5;
|
||||||
byte *page_ptr;
|
byte *page_ptr;
|
||||||
byte attributes;
|
byte attributes;
|
||||||
LOG(printf("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(printf("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 ( LastRetByte = rdh_table[page](addr) );
|
return ( LastRetByte = rdh_table[page](addr) );
|
||||||
else
|
else
|
||||||
return ( LastRetByte = page_ptr[addr] );
|
return ( LastRetByte = page_ptr[addr] );
|
||||||
}
|
}
|
||||||
//printf("Trying to read @ 0x%X-%X\n", page, addr);
|
//console_printf(Console_Default, "Trying to read @ 0x%X-%X\n", page, addr);
|
||||||
return LastRetByte;
|
return LastRetByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +221,7 @@ void WriteMemory(byte page, byte addr, byte value)
|
|||||||
{
|
{
|
||||||
byte *page_ptr;
|
byte *page_ptr;
|
||||||
byte attributes;
|
byte attributes;
|
||||||
LOG(printf("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) )
|
||||||
@@ -231,14 +230,14 @@ void WriteMemory(byte page, byte addr, byte value)
|
|||||||
{
|
{
|
||||||
#ifdef DETECT_BUS_CONFLICT
|
#ifdef DETECT_BUS_CONFLICT
|
||||||
if ((page >= 0x80) && (memory_pages[page][addr] != value))
|
if ((page >= 0x80) && (memory_pages[page][addr] != value))
|
||||||
printf("WriteHook: bus conflict at %02X%02X rom:%02X write:%02X\n", page, addr, memory_pages[page][addr], value);
|
console_printf(Console_Default, "WriteHook: bus conflict at %02X%02X rom:%02X write:%02X\n", page, addr, memory_pages[page][addr], value);
|
||||||
#endif
|
#endif
|
||||||
wrh_table[page](addr, value);
|
wrh_table[page](addr, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
page_ptr[addr] = value;
|
page_ptr[addr] = value;
|
||||||
}
|
}
|
||||||
else { printf("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)
|
||||||
|
|||||||
12
src/os/macos/CMakeLists.txt
Normal file
12
src/os/macos/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
add_library(oslib loadfile.c graphics.c sound.c io.c)
|
||||||
29
src/os/macos/graphics.c
Normal file
29
src/os/macos/graphics.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Graphic Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER on 08/05/08.
|
||||||
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
int graphics_init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawpixel(long x, long y, long color)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_blit(long x, long y, long w, long h)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
61
src/os/macos/io.c
Normal file
61
src/os/macos/io.c
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* IO Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoël Trapier on 04/01/09.
|
||||||
|
* Copyright (c) 2003-2009 986 Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D'};
|
||||||
|
|
||||||
|
ConsoleLevel console_ActualLevel = Console_Default;
|
||||||
|
|
||||||
|
/* Actually nothing to do */
|
||||||
|
int console_init(ConsoleLevel DefaultLevel)
|
||||||
|
{
|
||||||
|
console_ActualLevel = DefaultLevel;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actually a simple printf with levels */
|
||||||
|
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||||
|
{
|
||||||
|
if (console_ActualLevel >= level)
|
||||||
|
vprintf(format, ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int console_printf(const ConsoleLevel level, const char *format, ...)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
ret = console_vprintf(level, format, ap);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int console_printf_d(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
console_vprintf (Console_Debug, format, ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
45
src/os/macos/loadfile.c
Normal file
45
src/os/macos/loadfile.c
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* File functions - The TI-NESulator Project
|
||||||
|
* os/macos/load.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
/* Map a file in memory */
|
||||||
|
void *LoadFilePtr(char * filename)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
void *RetPtr = NULL;
|
||||||
|
struct stat FileStat;
|
||||||
|
|
||||||
|
fd = open(filename, O_RDONLY);
|
||||||
|
|
||||||
|
fstat(fd, &FileStat);
|
||||||
|
|
||||||
|
RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return RetPtr;
|
||||||
|
}
|
||||||
0
src/os/macos/sound.c
Normal file
0
src/os/macos/sound.c
Normal file
12
src/os/ti68k/CMakeLists.txt
Normal file
12
src/os/ti68k/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
add_library(oslib loadfile.c)
|
||||||
34
src/os/ti68k/loadfile.c
Normal file
34
src/os/ti68k/loadfile.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* TI-68k Loading external file functions - The TI-NESulator Project
|
||||||
|
* ti68k/loadfile.c
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER.
|
||||||
|
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate:$
|
||||||
|
* $Author:$
|
||||||
|
* $HeadURL:$
|
||||||
|
* $Revision:$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TIGCC_COMPAT
|
||||||
|
#include <tigcclib.h>
|
||||||
|
|
||||||
|
/* Map a file in memory */
|
||||||
|
void *LoadFilePtr(char * filename)
|
||||||
|
{
|
||||||
|
void *RetPtr = NULL;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if ((fp = fopen(filename,"rb")) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* TI Related stuff, very uggly, and need to be changed.. */
|
||||||
|
HeapLock(fp->handle);
|
||||||
|
RetPtr = 2 + HeapDeref(fp->handle);
|
||||||
|
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
return RetPtr;
|
||||||
|
}
|
||||||
8
src/os/ti68k/main.c
Normal file
8
src/os/ti68k/main.c
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <tigcclib.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]);
|
||||||
|
|
||||||
|
void _main()
|
||||||
|
{
|
||||||
|
main(1, "smb1.nes");
|
||||||
|
}
|
||||||
19
src/os/unix/CMakeLists.txt
Normal file
19
src/os/unix/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
set(COVERAGE_SRCS src/os/unix/loadfile.c src/os/unix/graphics_dummy.c src/os/unix/sound.c src/os/unix/io.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||||
|
add_library(oslib loadfile.c graphics_dummy.c sound.c io.c)
|
||||||
|
else()
|
||||||
|
add_library(oslib loadfile.c graphics.c sound.c io.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(oslib glfw ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
|
||||||
438
src/os/unix/graphics.c
Normal file
438
src/os/unix/graphics.c
Normal file
@@ -0,0 +1,438 @@
|
|||||||
|
/*
|
||||||
|
* Graphic Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER on 08/05/08.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
#define GLFW_INCLUDE_GLEXT
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include <palette.h>
|
||||||
|
|
||||||
|
typedef struct GLWindow_t GLWindow;
|
||||||
|
|
||||||
|
struct KeyArray
|
||||||
|
{
|
||||||
|
unsigned char lastState;
|
||||||
|
unsigned char curState;
|
||||||
|
unsigned char debounced;
|
||||||
|
GLFWwindow* window;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GLWindow_t
|
||||||
|
{
|
||||||
|
struct KeyArray keyArray[512];
|
||||||
|
GLFWwindow* windows;
|
||||||
|
unsigned char *videoMemory;
|
||||||
|
GLint videoTexture;
|
||||||
|
int WIDTH;
|
||||||
|
int HEIGHT;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int window_num = 0;
|
||||||
|
|
||||||
|
void GLWindowInitEx(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
g->WIDTH = w;
|
||||||
|
g->HEIGHT = h;
|
||||||
|
g->videoTexture = window_num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWindowInit(GLWindow *g)
|
||||||
|
{
|
||||||
|
GLWindowInitEx(g, 100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowScreen(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
|
glVertex2f(-1.0f,1.0f);
|
||||||
|
|
||||||
|
glTexCoord2f(0.0f, h);
|
||||||
|
glVertex2f(-1.0f, -1.0f);
|
||||||
|
|
||||||
|
glTexCoord2f(w, h);
|
||||||
|
glVertex2f(1.0f, -1.0f);
|
||||||
|
|
||||||
|
glTexCoord2f(w, 0.0f);
|
||||||
|
glVertex2f(1.0f, 1.0f);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupGL(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
g->videoMemory = (unsigned char*)malloc(w*h*sizeof(unsigned int));
|
||||||
|
memset(g->videoMemory, 0,w*h*sizeof(unsigned int));
|
||||||
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
||||||
|
|
||||||
|
// glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
|
||||||
|
|
||||||
|
// glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
||||||
|
// glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
|
||||||
|
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_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w,
|
||||||
|
h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void restoreGL(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||||
|
{
|
||||||
|
struct KeyArray *keyArray;
|
||||||
|
|
||||||
|
keyArray = (struct KeyArray*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
|
keyArray[key].lastState=keyArray[key].curState;
|
||||||
|
if (action==GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
keyArray[key].curState=GLFW_RELEASE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keyArray[key].curState=GLFW_PRESS;
|
||||||
|
}
|
||||||
|
keyArray[key].debounced |= (keyArray[key].lastState==GLFW_RELEASE)&&(keyArray[key].curState==GLFW_PRESS);
|
||||||
|
keyArray[key].window = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
glViewport(0, 0, xs, ys);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void error_callback(int error, const char* description)
|
||||||
|
{
|
||||||
|
puts(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initDisplay(GLWindow *g)
|
||||||
|
{
|
||||||
|
int h = g->HEIGHT;
|
||||||
|
int w = g->WIDTH;
|
||||||
|
|
||||||
|
/// Initialize GLFW
|
||||||
|
glfwInit();
|
||||||
|
|
||||||
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
|
// Open screen OpenGL window
|
||||||
|
if( !(g->windows=glfwCreateWindow( g->WIDTH, g->HEIGHT, "Main", NULL, NULL)) )
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
fprintf(stderr, "Window creation error...\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(g->windows);
|
||||||
|
setupGL(g, g->WIDTH, g->HEIGHT);
|
||||||
|
|
||||||
|
glfwSwapInterval(0); // Disable VSYNC
|
||||||
|
|
||||||
|
glfwGetWindowSize(g->windows, &w, &h);
|
||||||
|
|
||||||
|
glfwSetWindowUserPointer(g->windows, g->keyArray);
|
||||||
|
|
||||||
|
glfwSetKeyCallback(g->windows, kbHandler);
|
||||||
|
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
|
||||||
|
{
|
||||||
|
uint8_t r,g,b,a;
|
||||||
|
|
||||||
|
uint32_t offset = (y*gw->WIDTH*4)+4*x;
|
||||||
|
|
||||||
|
if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
b = colour & 0xFF;
|
||||||
|
g = (colour >> 8) & 0xFF;
|
||||||
|
r = (colour >> 16) & 0xFF;
|
||||||
|
a = (colour >> 24) & 0xFF;
|
||||||
|
|
||||||
|
gw->videoMemory[offset + 0] = a;
|
||||||
|
gw->videoMemory[offset + 1] = r;
|
||||||
|
gw->videoMemory[offset + 2] = g;
|
||||||
|
gw->videoMemory[offset + 3] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (abs(x1 - x0) < abs(y1 - y0))
|
||||||
|
{
|
||||||
|
/* parcours par l'axe vertical */
|
||||||
|
if (y0 > y1)
|
||||||
|
{
|
||||||
|
drawLine(g, x1, y1, x0, y0, colour);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
xincr = x1 > x0 ? 1 : -1;
|
||||||
|
dy = y1 - y0;
|
||||||
|
dx = abs(x1 - x0);
|
||||||
|
d = 2 * dx - dy;
|
||||||
|
aincr = 2 * (dx - dy);
|
||||||
|
bincr = 2 * dx;
|
||||||
|
x = x0;
|
||||||
|
y = y0;
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
|
||||||
|
for (y = y0+1; y <= y1; y++)
|
||||||
|
{
|
||||||
|
if (d >= 0)
|
||||||
|
{
|
||||||
|
x += xincr;
|
||||||
|
d += aincr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d += bincr;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* parcours par l'axe horizontal */
|
||||||
|
if (x0 > x1)
|
||||||
|
{
|
||||||
|
drawLine(g, x1, y1, x0, y0, colour);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
yincr = y1 > y0 ? 1 : -1;
|
||||||
|
dx = x1 - x0;
|
||||||
|
dy = abs(y1 - y0);
|
||||||
|
d = 2 * dy - dx;
|
||||||
|
aincr = 2 * (dy - dx);
|
||||||
|
bincr = 2 * dy;
|
||||||
|
x = x0;
|
||||||
|
y = y0;
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
|
||||||
|
for (x = x0+1; x <= x1; ++x)
|
||||||
|
{
|
||||||
|
if (d >= 0)
|
||||||
|
{
|
||||||
|
y += yincr;
|
||||||
|
d += aincr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d += bincr;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||||
|
{
|
||||||
|
int f = 1 - radius;
|
||||||
|
int ddF_x = 0;
|
||||||
|
int ddF_y = -2 * radius;
|
||||||
|
int x = 0;
|
||||||
|
int y = radius;
|
||||||
|
int pX, pY;
|
||||||
|
|
||||||
|
pX = xc; pY = yc + radius;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pY -= (2*radius);
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pY += radius; pX += radius;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX -= (2*radius);
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
|
||||||
|
while(x < y)
|
||||||
|
{
|
||||||
|
if(f >= 0)
|
||||||
|
{
|
||||||
|
y--;
|
||||||
|
ddF_y += 2;
|
||||||
|
f += ddF_y;
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
ddF_x += 2;
|
||||||
|
f += ddF_x + 1;
|
||||||
|
pX = xc+x ; pY = yc+y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-x ; pY = yc+y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc+x ; pY = yc-y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-x ; pY = yc-y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc+y ; pY = yc+x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-y ; pY = yc+x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc+y ; pY = yc-x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-y ; pY = yc-x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||||
|
{
|
||||||
|
drawLine(g, x0 , y0 , x0 + w, y0 , colour);
|
||||||
|
drawLine(g, x0 + w, y0 , x0 + w, y0 + h, colour);
|
||||||
|
drawLine(g, x0 + w, y0 + h, x0 , y0 + h, colour);
|
||||||
|
drawLine(g, x0 , y0 + h, x0 , y0 , colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < h; i++)
|
||||||
|
drawLine(g, x0, y0+i, x0+w, y0+i, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearScreen(GLWindow *g)
|
||||||
|
{
|
||||||
|
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScreen(GLWindow *g)
|
||||||
|
{
|
||||||
|
/*Update windows code */
|
||||||
|
glfwMakeContextCurrent(g->windows);
|
||||||
|
ShowScreen(g, g->WIDTH, g->HEIGHT);
|
||||||
|
glfwSwapBuffers(g->windows);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScreenAndWait(GLWindow *g)
|
||||||
|
{
|
||||||
|
while (glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_PRESS)
|
||||||
|
{
|
||||||
|
updateScreen(g);
|
||||||
|
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
while(glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLWindow mainWindow;
|
||||||
|
|
||||||
|
int graphics_init()
|
||||||
|
{
|
||||||
|
GLWindowInitEx(&mainWindow, 256, 240);
|
||||||
|
initDisplay(&mainWindow);
|
||||||
|
clearScreen(&mainWindow);
|
||||||
|
updateScreen(&mainWindow);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long getColour(long color)
|
||||||
|
{
|
||||||
|
Palette *pal = &basicPalette[color];
|
||||||
|
uint8_t r, g, b, a;
|
||||||
|
r = pal->r;
|
||||||
|
b = pal->b;
|
||||||
|
g = pal->g;
|
||||||
|
a = 255;//pal->a;
|
||||||
|
return (b << 24) | (g << 16) | (r << 8) | a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawpixel(long x, long y, long color)
|
||||||
|
{
|
||||||
|
drawPixel(&mainWindow, x, y, getColour(color));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||||
|
{
|
||||||
|
drawLine(&mainWindow, x, y, x1, y1, getColour(color));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_blit(long x, long y, long w, long h)
|
||||||
|
{
|
||||||
|
updateScreen(&mainWindow);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getKeyStatus(int key)
|
||||||
|
{
|
||||||
|
return mainWindow.keyArray[key].curState;
|
||||||
|
}
|
||||||
138
src/os/unix/graphics_dummy.c
Normal file
138
src/os/unix/graphics_dummy.c
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* Graphic Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER on 08/05/08.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
//#include <OpenGL/glext.h>
|
||||||
|
|
||||||
|
#include <palette.h>
|
||||||
|
|
||||||
|
typedef struct GLWindow_t GLWindow;
|
||||||
|
|
||||||
|
struct KeyArray
|
||||||
|
{
|
||||||
|
unsigned char lastState;
|
||||||
|
unsigned char curState;
|
||||||
|
unsigned char debounced;
|
||||||
|
GLFWwindow* window;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GLWindow_t
|
||||||
|
{
|
||||||
|
struct KeyArray keyArray[512];
|
||||||
|
GLFWwindow* windows;
|
||||||
|
unsigned char *videoMemory;
|
||||||
|
GLint videoTexture;
|
||||||
|
int WIDTH;
|
||||||
|
int HEIGHT;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef GL_TEXTURE_RECTANGLE_EXT
|
||||||
|
#define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void GLWindowInitEx(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWindowInit(GLWindow *g)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowScreen(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupGL(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void restoreGL(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initDisplay(GLWindow *g)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawRect(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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearScreen(GLWindow *g)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScreen(GLWindow *g)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScreenAndWait(GLWindow *g)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_init()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawpixel(long x, long y, long color)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_blit(long x, long y, long w, long h)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getKeyStatus(int key)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
60
src/os/unix/io.c
Normal file
60
src/os/unix/io.c
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* IO Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoël Trapier on 04/01/09.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D'};
|
||||||
|
|
||||||
|
ConsoleLevel console_ActualLevel = Console_Default;
|
||||||
|
|
||||||
|
/* Actually nothing to do */
|
||||||
|
int console_init(ConsoleLevel DefaultLevel)
|
||||||
|
{
|
||||||
|
console_ActualLevel = DefaultLevel;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actually a simple printf with levels */
|
||||||
|
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||||
|
{
|
||||||
|
if (console_ActualLevel >= level)
|
||||||
|
vprintf(format, ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int console_printf(const ConsoleLevel level, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
console_vprintf(level, format, ap);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int console_printf_d(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
console_vprintf (Console_Debug, format, ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -27,5 +30,10 @@ void *LoadFilePtr(char * filename)
|
|||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
if ( RetPtr == MAP_FAILED )
|
||||||
|
{
|
||||||
|
RetPtr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return RetPtr;
|
return RetPtr;
|
||||||
}
|
}
|
||||||
|
|||||||
0
src/os/unix/sound.c
Normal file
0
src/os/unix/sound.c
Normal file
14
src/os/win32/CMakeLists.txt
Normal file
14
src/os/win32/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
add_library(oslib loadfile.c graphics.c sound.c io.c)
|
||||||
|
|
||||||
|
target_link_libraries(oslib glfw ${OPENGL_glu_LIBRARY})
|
||||||
436
src/os/win32/graphics.c
Normal file
436
src/os/win32/graphics.c
Normal file
@@ -0,0 +1,436 @@
|
|||||||
|
/*
|
||||||
|
* Graphic Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoel TRAPIER on 08/05/08.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <OpenGL/glext.h>
|
||||||
|
|
||||||
|
#include <palette.h>
|
||||||
|
|
||||||
|
typedef struct GLWindow_t GLWindow;
|
||||||
|
|
||||||
|
struct KeyArray
|
||||||
|
{
|
||||||
|
unsigned char lastState;
|
||||||
|
unsigned char curState;
|
||||||
|
unsigned char debounced;
|
||||||
|
GLFWwindow* window;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GLWindow_t
|
||||||
|
{
|
||||||
|
struct KeyArray keyArray[512];
|
||||||
|
GLFWwindow* windows;
|
||||||
|
unsigned char *videoMemory;
|
||||||
|
GLint videoTexture;
|
||||||
|
int WIDTH;
|
||||||
|
int HEIGHT;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef GL_TEXTURE_RECTANGLE_EXT
|
||||||
|
#define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int window_num = 0;
|
||||||
|
|
||||||
|
void GLWindowInitEx(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
g->WIDTH = w;
|
||||||
|
g->HEIGHT = h;
|
||||||
|
g->videoTexture = window_num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWindowInit(GLWindow *g)
|
||||||
|
{
|
||||||
|
GLWindowInitEx(g, 100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowScreen(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, g->videoTexture);
|
||||||
|
|
||||||
|
// glTexSubImage2D is faster when not using a texture range
|
||||||
|
glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
|
glVertex2f(-1.0f,1.0f);
|
||||||
|
|
||||||
|
glTexCoord2f(0.0f, h);
|
||||||
|
glVertex2f(-1.0f, -1.0f);
|
||||||
|
|
||||||
|
glTexCoord2f(w, h);
|
||||||
|
glVertex2f(1.0f, -1.0f);
|
||||||
|
|
||||||
|
glTexCoord2f(w, 0.0f);
|
||||||
|
glVertex2f(1.0f, 1.0f);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupGL(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
g->videoMemory = (unsigned char*)malloc(w*h*sizeof(unsigned int));
|
||||||
|
memset(g->videoMemory, 0,w*h*sizeof(unsigned int));
|
||||||
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_EXT);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, g->videoTexture);
|
||||||
|
|
||||||
|
// glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
|
||||||
|
|
||||||
|
// glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
||||||
|
// glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
|
||||||
|
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, w,
|
||||||
|
h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void restoreGL(GLWindow *g, int w, int h)
|
||||||
|
{
|
||||||
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_EXT);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||||
|
{
|
||||||
|
struct KeyArray *keyArray;
|
||||||
|
|
||||||
|
keyArray = (struct KeyArray*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
|
keyArray[key].lastState=keyArray[key].curState;
|
||||||
|
if (action==GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
keyArray[key].curState=GLFW_RELEASE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keyArray[key].curState=GLFW_PRESS;
|
||||||
|
}
|
||||||
|
keyArray[key].debounced |= (keyArray[key].lastState==GLFW_RELEASE)&&(keyArray[key].curState==GLFW_PRESS);
|
||||||
|
keyArray[key].window = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
glViewport(0, 0, xs, ys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initDisplay(GLWindow *g)
|
||||||
|
{
|
||||||
|
int h = g->HEIGHT;
|
||||||
|
int w = g->WIDTH;
|
||||||
|
|
||||||
|
/// Initialize GLFW
|
||||||
|
glfwInit();
|
||||||
|
|
||||||
|
// Open screen OpenGL window
|
||||||
|
if( !(g->windows=glfwCreateWindow( g->WIDTH, g->HEIGHT, "Main", NULL, NULL)) )
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
fprintf(stderr, "Window creation error...\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(g->windows);
|
||||||
|
setupGL(g, g->WIDTH, g->HEIGHT);
|
||||||
|
|
||||||
|
glfwSwapInterval(0); // Disable VSYNC
|
||||||
|
|
||||||
|
glfwGetWindowSize(g->windows, &w, &h);
|
||||||
|
|
||||||
|
glfwSetWindowUserPointer(g->windows, g->keyArray);
|
||||||
|
|
||||||
|
glfwSetKeyCallback(g->windows, kbHandler);
|
||||||
|
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
|
||||||
|
{
|
||||||
|
uint8_t r,g,b,a;
|
||||||
|
|
||||||
|
uint32_t offset = (y*gw->WIDTH*4)+4*x;
|
||||||
|
|
||||||
|
if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
b = colour & 0xFF;
|
||||||
|
g = (colour >> 8) & 0xFF;
|
||||||
|
r = (colour >> 16) & 0xFF;
|
||||||
|
a = (colour >> 24) & 0xFF;
|
||||||
|
|
||||||
|
gw->videoMemory[offset + 0] = a;
|
||||||
|
gw->videoMemory[offset + 1] = r;
|
||||||
|
gw->videoMemory[offset + 2] = g;
|
||||||
|
gw->videoMemory[offset + 3] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (abs(x1 - x0) < abs(y1 - y0))
|
||||||
|
{
|
||||||
|
/* parcours par l'axe vertical */
|
||||||
|
if (y0 > y1)
|
||||||
|
{
|
||||||
|
drawLine(g, x1, y1, x0, y0, colour);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
xincr = x1 > x0 ? 1 : -1;
|
||||||
|
dy = y1 - y0;
|
||||||
|
dx = abs(x1 - x0);
|
||||||
|
d = 2 * dx - dy;
|
||||||
|
aincr = 2 * (dx - dy);
|
||||||
|
bincr = 2 * dx;
|
||||||
|
x = x0;
|
||||||
|
y = y0;
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
|
||||||
|
for (y = y0+1; y <= y1; y++)
|
||||||
|
{
|
||||||
|
if (d >= 0)
|
||||||
|
{
|
||||||
|
x += xincr;
|
||||||
|
d += aincr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d += bincr;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* parcours par l'axe horizontal */
|
||||||
|
if (x0 > x1)
|
||||||
|
{
|
||||||
|
drawLine(g, x1, y1, x0, y0, colour);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
yincr = y1 > y0 ? 1 : -1;
|
||||||
|
dx = x1 - x0;
|
||||||
|
dy = abs(y1 - y0);
|
||||||
|
d = 2 * dy - dx;
|
||||||
|
aincr = 2 * (dy - dx);
|
||||||
|
bincr = 2 * dy;
|
||||||
|
x = x0;
|
||||||
|
y = y0;
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
|
||||||
|
for (x = x0+1; x <= x1; ++x)
|
||||||
|
{
|
||||||
|
if (d >= 0)
|
||||||
|
{
|
||||||
|
y += yincr;
|
||||||
|
d += aincr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d += bincr;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPixel(g, x, y, colour);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||||
|
{
|
||||||
|
int f = 1 - radius;
|
||||||
|
int ddF_x = 0;
|
||||||
|
int ddF_y = -2 * radius;
|
||||||
|
int x = 0;
|
||||||
|
int y = radius;
|
||||||
|
int pX, pY;
|
||||||
|
|
||||||
|
pX = xc; pY = yc + radius;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pY -= (2*radius);
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pY += radius; pX += radius;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX -= (2*radius);
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
|
||||||
|
while(x < y)
|
||||||
|
{
|
||||||
|
if(f >= 0)
|
||||||
|
{
|
||||||
|
y--;
|
||||||
|
ddF_y += 2;
|
||||||
|
f += ddF_y;
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
ddF_x += 2;
|
||||||
|
f += ddF_x + 1;
|
||||||
|
pX = xc+x ; pY = yc+y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-x ; pY = yc+y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc+x ; pY = yc-y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-x ; pY = yc-y;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc+y ; pY = yc+x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-y ; pY = yc+x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc+y ; pY = yc-x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
pX = xc-y ; pY = yc-x;
|
||||||
|
drawPixel(g, pX, pY, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||||
|
{
|
||||||
|
drawLine(g, x0 , y0 , x0 + w, y0 , colour);
|
||||||
|
drawLine(g, x0 + w, y0 , x0 + w, y0 + h, colour);
|
||||||
|
drawLine(g, x0 + w, y0 + h, x0 , y0 + h, colour);
|
||||||
|
drawLine(g, x0 , y0 + h, x0 , y0 , colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < h; i++)
|
||||||
|
drawLine(g, x0, y0+i, x0+w, y0+i, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearScreen(GLWindow *g)
|
||||||
|
{
|
||||||
|
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScreen(GLWindow *g)
|
||||||
|
{
|
||||||
|
/*Update windows code */
|
||||||
|
glfwMakeContextCurrent(g->windows);
|
||||||
|
ShowScreen(g, g->WIDTH, g->HEIGHT);
|
||||||
|
glfwSwapBuffers(g->windows);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScreenAndWait(GLWindow *g)
|
||||||
|
{
|
||||||
|
while (glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_PRESS)
|
||||||
|
{
|
||||||
|
updateScreen(g);
|
||||||
|
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
while(glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLWindow mainWindow;
|
||||||
|
|
||||||
|
int graphics_init()
|
||||||
|
{
|
||||||
|
GLWindowInitEx(&mainWindow, 256, 240);
|
||||||
|
initDisplay(&mainWindow);
|
||||||
|
clearScreen(&mainWindow);
|
||||||
|
updateScreen(&mainWindow);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long getColour(long color)
|
||||||
|
{
|
||||||
|
Palette *pal = &basicPalette[color];
|
||||||
|
uint8_t r, g, b, a;
|
||||||
|
r = pal->r;
|
||||||
|
b = pal->b;
|
||||||
|
g = pal->g;
|
||||||
|
a = 255;//pal->a;
|
||||||
|
return (b << 24) | (g << 16) | (r << 8) | a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawpixel(long x, long y, long color)
|
||||||
|
{
|
||||||
|
drawPixel(&mainWindow, x, y, getColour(color));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||||
|
{
|
||||||
|
drawLine(&mainWindow, x, y, x1, y1, getColour(color));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graphics_blit(long x, long y, long w, long h)
|
||||||
|
{
|
||||||
|
updateScreen(&mainWindow);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getKeyStatus(int key)
|
||||||
|
{
|
||||||
|
return mainWindow.keyArray[key].curState;
|
||||||
|
}
|
||||||
61
src/os/win32/io.c
Normal file
61
src/os/win32/io.c
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* IO Manager - The TI-NESulator Project
|
||||||
|
* os/macos/graphics.c
|
||||||
|
*
|
||||||
|
* Created by Manoël Trapier on 04/01/09.
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
* $LastChangedDate$
|
||||||
|
* $Author$
|
||||||
|
* $HeadURL$
|
||||||
|
* $Revision$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
|
char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D'};
|
||||||
|
|
||||||
|
ConsoleLevel console_ActualLevel = Console_Default;
|
||||||
|
|
||||||
|
/* Actually nothing to do */
|
||||||
|
int console_init(ConsoleLevel DefaultLevel)
|
||||||
|
{
|
||||||
|
console_ActualLevel = DefaultLevel;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actually a simple printf with levels */
|
||||||
|
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||||
|
{
|
||||||
|
if (console_ActualLevel >= level)
|
||||||
|
vprintf(format, ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int console_printf(const ConsoleLevel level, const char *format, ...)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
ret = console_vprintf(level, format, ap);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int console_printf_d(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
console_vprintf (Console_Debug, format, ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
34
src/os/win32/loadfile.c
Normal file
34
src/os/win32/loadfile.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Map a file in memory */
|
||||||
|
void *LoadFilePtr(char * filename)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
void *RetPtr = NULL;
|
||||||
|
struct stat FileStat;
|
||||||
|
|
||||||
|
fd = open(filename, O_RDONLY);
|
||||||
|
|
||||||
|
fstat(fd, &FileStat);
|
||||||
|
|
||||||
|
RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return RetPtr;
|
||||||
|
}
|
||||||
0
src/os/win32/sound.c
Normal file
0
src/os/win32/sound.c
Normal file
147
src/paddle.c
147
src/paddle.c
@@ -3,119 +3,92 @@
|
|||||||
* paddle.c
|
* paddle.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER.
|
* Created by Manoel TRAPIER.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate: 2007-05-02 18:37:41 +0200 (mer, 02 mai 2007) $
|
* $LastChangedDate$
|
||||||
* $Author: mtrapier $
|
* $Author$
|
||||||
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/paddle.c $
|
* $HeadURL$
|
||||||
* $Revision: 50 $
|
* $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <allegro.h>
|
#include <os_dependent.h>
|
||||||
|
|
||||||
#include "paddle.h"
|
#include "paddle.h"
|
||||||
|
|
||||||
void InitPaddle(Paddle * pdl)
|
void InitPaddle(Paddle *pdl)
|
||||||
{
|
{
|
||||||
pdl->Bit = 1;
|
pdl->Bit = 1;
|
||||||
pdl->LastWrite = 0;
|
pdl->LastWrite = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WritePaddle(Paddle *pdl, unsigned char val)
|
void WritePaddle(Paddle *pdl, unsigned char val)
|
||||||
{
|
{
|
||||||
if ((pdl->LastWrite == 1) && (val == 0))
|
if ( ( pdl->LastWrite == 1 ) && ( val == 0 ) )
|
||||||
InitPaddle(pdl);
|
InitPaddle(pdl);
|
||||||
|
|
||||||
pdl->LastWrite = val;
|
pdl->LastWrite = val;
|
||||||
}
|
}
|
||||||
unsigned char ReadPaddle(Paddle * pdl)
|
|
||||||
|
unsigned char ReadPaddle(Paddle *pdl)
|
||||||
{
|
{
|
||||||
switch (pdl->Bit++)
|
switch(pdl->Bit++)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (key[KEY_Z])
|
if ( getKeyStatus('O') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
return 0x41;
|
case 2:
|
||||||
|
if ( getKeyStatus('P') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
break;
|
case 3:
|
||||||
|
if ( getKeyStatus('I') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 4:
|
||||||
|
if ( getKeyStatus('U') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
if (key[KEY_X])
|
case 5:
|
||||||
|
if ( getKeyStatus('W') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
return 0x41;
|
case 6:
|
||||||
|
if ( getKeyStatus('S') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
break;
|
case 7:
|
||||||
|
if ( getKeyStatus('A') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 8:
|
||||||
|
if ( getKeyStatus('D') )
|
||||||
|
return 0x41;
|
||||||
|
break;
|
||||||
|
|
||||||
if (key[KEY_P])
|
case 20:
|
||||||
|
return 0x40;
|
||||||
|
break;
|
||||||
|
|
||||||
return 0x41;
|
case 24:
|
||||||
|
pdl->Bit = 1;
|
||||||
|
return 0x40;
|
||||||
|
|
||||||
break;
|
default:
|
||||||
|
return 0x40;
|
||||||
|
break;
|
||||||
|
|
||||||
case 4:
|
}
|
||||||
|
|
||||||
if (key[KEY_ENTER])
|
|
||||||
|
|
||||||
return 0x41;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
|
|
||||||
if (key[KEY_UP])
|
|
||||||
|
|
||||||
return 0x41;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
|
|
||||||
if (key[KEY_DOWN])
|
|
||||||
|
|
||||||
return 0x41;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
|
|
||||||
if (key[KEY_LEFT])
|
|
||||||
|
|
||||||
return 0x41;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
|
|
||||||
if (key[KEY_RIGHT])
|
|
||||||
|
|
||||||
return 0x41;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 20:
|
|
||||||
|
|
||||||
return 0x41;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 24:
|
|
||||||
|
|
||||||
pdl->Bit = 1;
|
|
||||||
|
|
||||||
return 0x40;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
return 0x40;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0x40;
|
|
||||||
|
|
||||||
|
return 0x40;
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/pluginsmanager/CMakeLists.txt
Normal file
18
src/pluginsmanager/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# TI-NES CMake
|
||||||
|
#
|
||||||
|
# Created by Manoel TRAPIER.
|
||||||
|
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
|
#
|
||||||
|
# $LastChangedDate$
|
||||||
|
# $Author$
|
||||||
|
# $HeadURL$
|
||||||
|
# $Revision$
|
||||||
|
|
||||||
|
file(GLOB plugins_list plugins/*.c)
|
||||||
|
|
||||||
|
if (COVERALLS)
|
||||||
|
set(COVERAGE_SRCS src/pluginsmanager/manager.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(pluginsmanager manager.c ${plugins_list})
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
* plugins.c
|
* plugins.c
|
||||||
*
|
*
|
||||||
* Created by Manoel TRAPIER on 02/04/07.
|
* Created by Manoel TRAPIER on 02/04/07.
|
||||||
* Copyright (c) 2003-2007 986Corp. All rights reserved.
|
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||||
*
|
*
|
||||||
* $LastChangedDate$
|
* $LastChangedDate$
|
||||||
* $Author$
|
* $Author$
|
||||||
@@ -15,11 +15,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <os_dependent.h>
|
||||||
|
|
||||||
#include <plugins/manager.h>
|
#include <plugins/manager.h>
|
||||||
|
|
||||||
typedef struct Plugin_
|
typedef struct Plugin_
|
||||||
{
|
{
|
||||||
byte *name;
|
char *name;
|
||||||
|
|
||||||
PluginInit init;
|
PluginInit init;
|
||||||
PluginDeinit deinit;
|
PluginDeinit deinit;
|
||||||
@@ -44,10 +46,10 @@ void plugin_list()
|
|||||||
{
|
{
|
||||||
Plugin *ptr = &(Plugins[0]);
|
Plugin *ptr = &(Plugins[0]);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
printf("Available plugins:\n");
|
console_printf(Console_Default, "Available plugins:\n");
|
||||||
while(ptr->name != NULL)
|
while(ptr->name != NULL)
|
||||||
{
|
{
|
||||||
printf("%d - %s\n", i, ptr->name);
|
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
|
||||||
ptr++; i++;
|
ptr++; i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,9 +57,15 @@ void plugin_list()
|
|||||||
int plugin_load(int id)
|
int plugin_load(int id)
|
||||||
{
|
{
|
||||||
Plugin *ptr = &(Plugins[0]);
|
Plugin *ptr = &(Plugins[0]);
|
||||||
|
int i = id;
|
||||||
|
|
||||||
for ( ; id == 0 && ptr != NULL; id -- )
|
console_printf(Console_Default, "%s(%d)", __func__, id);
|
||||||
|
|
||||||
|
for ( ; i > 1 && ptr->name != NULL; i -- )
|
||||||
|
{
|
||||||
|
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
|
||||||
ptr ++;
|
ptr ++;
|
||||||
|
}
|
||||||
|
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user