Add game pad part and connecting parts together

This commit is contained in:
mkwong98 2016-11-25 19:39:14 +08:00
parent 6270e7db21
commit 3fef19c742
25 changed files with 412 additions and 174 deletions

View file

@ -67,6 +67,8 @@
<Unit filename="core/corePart.h" />
<Unit filename="core/cpu.cpp" />
<Unit filename="core/cpu.h" />
<Unit filename="core/gamepad.cpp" />
<Unit filename="core/gamepad.h" />
<Unit filename="core/mapper001.cpp" />
<Unit filename="core/mapper001.h" />
<Unit filename="core/memBus.cpp" />

View file

@ -3406,29 +3406,31 @@
1412631243 c:\work\include\wx\os2\notebook.h
"wx/control.h"
1479479589 source:c:\work\hdnesr\trunk\rewrite\wx\mainframeimp.cpp
1479809256 source:c:\work\hdnesr\trunk\rewrite\wx\mainframeimp.cpp
"mainFrameImp.h"
"../gameManager.h"
"../emu/gameFile.h"
"../emu/input.h"
"../emu/video.h"
"../emu/audio.h"
1479807588 source:c:\work\hdnesr\trunk\rewrite\emu\audio.cpp
1480069012 source:c:\work\hdnesr\trunk\rewrite\emu\audio.cpp
"audio.h"
"../gameManager.h"
1479807381 c:\work\hdnesr\trunk\rewrite\emu\audio.h
1480069012 c:\work\hdnesr\trunk\rewrite\emu\audio.h
"emuPart.h"
1479804745 source:c:\work\hdnesr\trunk\rewrite\emu\video.cpp
1480069099 source:c:\work\hdnesr\trunk\rewrite\emu\video.cpp
<GL/glew.h>
"video.h"
"../gameManager.h"
1479804745 c:\work\hdnesr\trunk\rewrite\emu\video.h
1480069099 c:\work\hdnesr\trunk\rewrite\emu\video.h
"../classList.h"
"emuPart.h"
1478583679 c:\work\hdnesr\trunk\rewrite\classlist.h
1480056573 c:\work\hdnesr\trunk\rewrite\classlist.h
1474972550 c:\work\include\gl\glew.h
<stddef.h>
@ -3442,7 +3444,7 @@
1478602156 c:\work\hdnesr\trunk\rewrite\emu\emupart.h
"../common.h"
1479806715 c:\work\hdnesr\trunk\rewrite\gamemanager.h
1480061170 c:\work\hdnesr\trunk\rewrite\gamemanager.h
<wx\wx.h>
"common.h"
"classList.h"
@ -3450,13 +3452,13 @@
1478310327 source:c:\work\hdnesr\trunk\rewrite\core\corepart.cpp
"corePart.h"
1478310327 c:\work\hdnesr\trunk\rewrite\core\corepart.h
1480071930 c:\work\hdnesr\trunk\rewrite\core\corepart.h
"../common.h"
1478602519 source:c:\work\hdnesr\trunk\rewrite\emu\emupart.cpp
"emuPart.h"
1479807381 source:c:\work\hdnesr\trunk\rewrite\gamemanager.cpp
1480069179 source:c:\work\hdnesr\trunk\rewrite\gamemanager.cpp
"gameManager.h"
"core\memBus.h"
"core\cart.h"
@ -3464,6 +3466,7 @@
"core\cpu.h"
"core\ppu.h"
"core\apu.h"
"core\gamepad.h"
"emu\video.h"
"emu\audio.h"
"emu\gameFile.h"
@ -3702,31 +3705,32 @@
"../classList.h"
"emuPart.h"
1478310327 source:c:\work\hdnesr\trunk\rewrite\core\cart.cpp
1480072054 source:c:\work\hdnesr\trunk\rewrite\core\cart.cpp
"../common.h"
"cart.h"
"mapper001.h"
"../emu/emuPart.h"
1478310327 c:\work\hdnesr\trunk\rewrite\core\cart.h
1480072003 c:\work\hdnesr\trunk\rewrite\core\cart.h
"corePart.h"
"../classList.h"
1478310327 c:\work\hdnesr\trunk\rewrite\core\mapper001.h
1480072003 c:\work\hdnesr\trunk\rewrite\core\mapper001.h
"cart.h"
1476429611 source:c:\work\hdnesr\trunk\rewrite\core\mapper001.cpp
1480072088 source:c:\work\hdnesr\trunk\rewrite\core\mapper001.cpp
"mapper001.h"
1478310327 source:c:\work\hdnesr\trunk\rewrite\core\membus.cpp
1480072139 source:c:\work\hdnesr\trunk\rewrite\core\membus.cpp
"memBus.h"
"../gameManager.h"
"cart.h"
"cpu.h"
"ppu.h"
"apu.h"
"gamepad.h"
1478310327 c:\work\hdnesr\trunk\rewrite\core\membus.h
1480072003 c:\work\hdnesr\trunk\rewrite\core\membus.h
"../classList.h"
<corePart.h>
@ -3791,22 +3795,23 @@
"../classList.h"
<emuPart.h>
1478310327 source:c:\work\hdnesr\trunk\rewrite\core\apu.cpp
1480072041 source:c:\work\hdnesr\trunk\rewrite\core\apu.cpp
"apu.h"
1478310327 c:\work\hdnesr\trunk\rewrite\core\apu.h
1480071957 c:\work\hdnesr\trunk\rewrite\core\apu.h
<corePart.h>
1478310327 source:c:\work\hdnesr\trunk\rewrite\core\cpu.cpp
1480063415 source:c:\work\hdnesr\trunk\rewrite\core\cpu.cpp
"cpu.h"
1478310327 c:\work\hdnesr\trunk\rewrite\core\cpu.h
1480072003 c:\work\hdnesr\trunk\rewrite\core\cpu.h
"../classList.h"
<corePart.h>
1478310327 c:\work\hdnesr\trunk\rewrite\core\ppu.h
1480072003 c:\work\hdnesr\trunk\rewrite\core\ppu.h
<corePart.h>
1478310327 source:c:\work\hdnesr\trunk\rewrite\core\ppu.cpp
1480072120 source:c:\work\hdnesr\trunk\rewrite\core\ppu.cpp
"ppu.h"
1478948230 c:\work\hdnesr\trunk\rewrite\emu\input.h
@ -3844,3 +3849,9 @@
1478613590 source:c:\work\hdnes\trunk\rewrite\wx\frmwaitinputimp.cpp
"frmWaitInputImp.h"
1480072088 source:c:\work\hdnesr\trunk\rewrite\core\gamepad.cpp
"gamepad.h"
1480072003 c:\work\hdnesr\trunk\rewrite\core\gamepad.h
<corePart.h>

View file

@ -2,139 +2,34 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="core\ppu.cpp" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="309" topLine="0" />
</Cursor>
</File>
<File name="emu\gameFile.h" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="323" topLine="2" />
</Cursor>
</File>
<File name="emu\emuPart.cpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="225" topLine="0" />
</Cursor>
</File>
<File name="core\corePart.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="161" topLine="0" />
</Cursor>
</File>
<File name="gameManager.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="486" topLine="55" />
</Cursor>
</File>
<File name="wx\mainFrameImp.cpp" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="wx\mainFrameImp.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5380" topLine="162" />
</Cursor>
</File>
<File name="emu\input.cpp" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="core\ppu.cpp" open="1" top="0" tabpos="31" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10799" topLine="0" />
<Cursor1 position="89" topLine="21" />
</Cursor>
</File>
<File name="core\ppu.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="core\ppu.h" open="1" top="0" tabpos="29" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="228" topLine="0" />
<Cursor1 position="363" topLine="14" />
</Cursor>
</File>
<File name="emu\gameFile.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="emu\audio.cpp" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1333" topLine="24" />
<Cursor1 position="933" topLine="37" />
</Cursor>
</File>
<File name="emu\input.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="core\cpu.cpp" open="1" top="0" tabpos="34" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1949" topLine="0" />
<Cursor1 position="163" topLine="0" />
</Cursor>
</File>
<File name="emu\audio.h" open="1" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="476" topLine="19" />
</Cursor>
</File>
<File name="core\cpu.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="136" topLine="0" />
</Cursor>
</File>
<File name="emu\video.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="595" topLine="13" />
</Cursor>
</File>
<File name="core\apu.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="229" topLine="0" />
</Cursor>
</File>
<File name="mainApp.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="352" topLine="1" />
</Cursor>
</File>
<File name="core\cart.cpp" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2580" topLine="84" />
</Cursor>
</File>
<File name="emu\video.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2316" topLine="106" />
</Cursor>
</File>
<File name="core\cart.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="86" topLine="0" />
</Cursor>
</File>
<File name="wx\frmWaitInputImp.cpp" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="wx\mainFrameImp.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1047" topLine="26" />
</Cursor>
</File>
<File name="core\corePart.cpp" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="82" topLine="0" />
</Cursor>
</File>
<File name="gameManager.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6572" topLine="258" />
</Cursor>
</File>
<File name="emu\emuPart.h" open="0" top="0" tabpos="22" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="40" topLine="0" />
</Cursor>
</File>
<File name="core\mapper001.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="142" topLine="0" />
</Cursor>
</File>
<File name="wx\frmWaitInputImp.h" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="418" topLine="0" />
</Cursor>
</File>
<File name="mainApp.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="158" topLine="0" />
</Cursor>
</File>
<File name="core\memBus.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="850" topLine="14" />
<Cursor1 position="552" topLine="13" />
</Cursor>
</File>
<File name="wx\mainFrame.cpp" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -142,14 +37,74 @@
<Cursor1 position="26945" topLine="586" />
</Cursor>
</File>
<File name="wx\mainGUI.fbp" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="emu\input.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="74" topLine="0" />
<Cursor1 position="140" topLine="0" />
</Cursor>
</File>
<File name="classList.h" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="core\apu.cpp" open="1" top="0" tabpos="30" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="259" topLine="0" />
<Cursor1 position="467" topLine="0" />
</Cursor>
</File>
<File name="emu\gameFile.h" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="323" topLine="2" />
</Cursor>
</File>
<File name="core\cart.cpp" open="1" top="0" tabpos="33" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2582" topLine="92" />
</Cursor>
</File>
<File name="wx\frmWaitInputImp.cpp" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="core\cart.h" open="1" top="0" tabpos="25" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1164" topLine="31" />
</Cursor>
</File>
<File name="wx\mainFrameImp.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1047" topLine="22" />
</Cursor>
</File>
<File name="core\apu.h" open="1" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="340" topLine="12" />
</Cursor>
</File>
<File name="gameManager.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="580" topLine="26" />
</Cursor>
</File>
<File name="core\corePart.cpp" open="1" top="0" tabpos="35" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="82" topLine="0" />
</Cursor>
</File>
<File name="emu\gameFile.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1333" topLine="24" />
</Cursor>
</File>
<File name="core\corePart.h" open="1" top="0" tabpos="26" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="362" topLine="5" />
</Cursor>
</File>
<File name="mainApp.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="352" topLine="1" />
</Cursor>
</File>
<File name="core\cpu.h" open="1" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="500" topLine="16" />
</Cursor>
</File>
<File name="wx\mainFrame.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -157,9 +112,59 @@
<Cursor1 position="5968" topLine="171" />
</Cursor>
</File>
<File name="emu\audio.cpp" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="core\gamepad.h" open="1" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="795" topLine="41" />
<Cursor1 position="302" topLine="7" />
</Cursor>
</File>
<File name="classList.h" open="1" top="0" tabpos="32" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="161" topLine="0" />
</Cursor>
</File>
<File name="mainApp.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="158" topLine="0" />
</Cursor>
</File>
<File name="core\mapper001.cpp" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="375" topLine="6" />
</Cursor>
</File>
<File name="emu\emuPart.h" open="0" top="0" tabpos="22" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="40" topLine="0" />
</Cursor>
</File>
<File name="core\mapper001.h" open="1" top="0" tabpos="27" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="304" topLine="3" />
</Cursor>
</File>
<File name="core\memBus.h" open="1" top="0" tabpos="28" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="488" topLine="16" />
</Cursor>
</File>
<File name="core\memBus.cpp" open="1" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="862" topLine="30" />
</Cursor>
</File>
<File name="emu\input.cpp" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10799" topLine="0" />
</Cursor>
</File>
<File name="core\gamepad.cpp" open="1" top="0" tabpos="22" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="388" topLine="0" />
</Cursor>
</File>
<File name="wx\mainGUI.fbp" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="74" topLine="0" />
</Cursor>
</File>
<File name="common.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -167,24 +172,29 @@
<Cursor1 position="155" topLine="0" />
</Cursor>
</File>
<File name="core\apu.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="emu\emuPart.cpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="194" topLine="0" />
<Cursor1 position="225" topLine="0" />
</Cursor>
</File>
<File name="core\cpu.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="emu\video.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="204" topLine="0" />
<Cursor1 position="1014" topLine="28" />
</Cursor>
</File>
<File name="core\mapper001.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="emu\video.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="152" topLine="0" />
<Cursor1 position="2772" topLine="101" />
</Cursor>
</File>
<File name="core\memBus.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="gameManager.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="317" topLine="0" />
<Cursor1 position="1920" topLine="36" />
</Cursor>
</File>
<File name="wx\frmWaitInputImp.h" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="418" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View file

@ -8,6 +8,7 @@ class cpu;
class ppu;
class apu;
class memBus;
class gamepad;
class emuPart;
class audio;

View file

@ -18,6 +18,15 @@ void apu::writeReg(Uint8 idx, Uint8 value){
registers[idx] = value;
}
Uint8 apu::read4015(){
}
void apu::write4015(Uint8 value){
}
void apu::runCycle(){
}
void apu::reset(){
}
@ -27,4 +36,7 @@ void apu::saveState(fstream* statefile){
void apu::loadState(fstream* statefile){
}
void apu::init(){
}

View file

@ -16,11 +16,15 @@ class apu : public corePart
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
Uint8 readReg(Uint8 idx);
void writeReg(Uint8 idx, Uint8 value);
Uint8 read4015(Uint8 idx);
void write4015(Uint8 idx, Uint8 value);
Uint8 read4015();
void write4015(Uint8 value);
void runCycle();
protected:
private:

View file

@ -84,6 +84,8 @@ void cart::readROMFile(fstream* fs, Uint8* header, const string& fileName){
loadBat();
}
void cart::loadBat(){
fstream romfile;
string filename = emuPart::getConfigLineVal(romFileName) + ".sav";
@ -108,11 +110,3 @@ void cart::saveBat(){
}
}
void cart::reset(){
}
void cart::saveState(fstream* statefile){
}
void cart::loadState(fstream* statefile){
}

View file

@ -30,12 +30,19 @@ class cart : public corePart
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
static cart* getCartFromROMFile(const string& fileName);
void readROMFile(fstream* fs, Uint8* header, const string& fileName);
void loadBat();
void saveBat();
virtual Uint8 readPRGData(Uint16 address) = 0;
virtual void writePRGData(Uint16 address, Uint8 value) = 0;
virtual Uint8 readCHRData(Uint16 address) = 0;
virtual void writeCHRData(Uint16 address, Uint8 value) = 0;
protected:
private:

View file

@ -14,6 +14,8 @@ class corePart
virtual void reset() = 0;
virtual void saveState(fstream* statefile) = 0;
virtual void loadState(fstream* statefile) = 0;
virtual void init() = 0;
protected:

View file

@ -1,8 +1,9 @@
#include "cpu.h"
#include "memBus.h"
#include "../gameManager.h"
cpu::cpu()
{
//ctor
}
cpu::~cpu()
@ -10,7 +11,18 @@ cpu::~cpu()
//dtor
}
Uint8 cpu::getNextInstructionLength(){
}
void cpu::runInstruction(){
}
void cpu::reset(){
stackPointer -= 3;
statusRegister |= 0x04;
programCounter = ((mb->memRead(0xFFFD) << 8) | mb->memRead(0xFFFC));
}
void cpu::saveState(fstream* statefile){
@ -19,3 +31,14 @@ void cpu::saveState(fstream* statefile){
void cpu::loadState(fstream* statefile){
}
void cpu::init(){
mb = gameManager::gm->mb;
statusRegister = 0x34;
accumulator = 0;
indexX = 0;
indexY = 0;
stackPointer = 0xFD;
programCounter = ((mb->memRead(0xFFFD) << 8) | mb->memRead(0xFFFC));
}

View file

@ -1,18 +1,32 @@
#ifndef CPU_H
#define CPU_H
#include "../classList.h"
#include <corePart.h>
class cpu : public corePart
{
public:
Uint8 accumulator;
Uint8 indexX;
Uint8 indexY;
Uint16 programCounter;
Uint8 stackPointer;
Uint8 statusRegister;
memBus* mb;
cpu();
virtual ~cpu();
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
Uint8 getNextInstructionLength();
void runInstruction();
protected:

35
Rewrite/core/gamepad.cpp Normal file
View file

@ -0,0 +1,35 @@
#include "gamepad.h"
gamepad::gamepad()
{
//ctor
}
gamepad::~gamepad()
{
//dtor
}
Uint8 gamepad::read4016(){
}
void gamepad::write4016(Uint8 value){
}
Uint8 gamepad::read4017(){
}
void gamepad::write4017(Uint8 value){
}
void gamepad::reset(){
}
void gamepad::saveState(fstream* statefile){
}
void gamepad::loadState(fstream* statefile){
}
void gamepad::init(){
}

28
Rewrite/core/gamepad.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef GAMEPAD_H
#define GAMEPAD_H
#include <corePart.h>
class gamepad : public corePart
{
public:
gamepad();
virtual ~gamepad();
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
Uint8 read4016();
void write4016(Uint8 value);
Uint8 read4017();
void write4017(Uint8 value);
protected:
private:
};
#endif // GAMEPAD_H

View file

@ -10,6 +10,19 @@ mapper001::~mapper001()
//dtor
}
Uint8 mapper001::readPRGData(Uint16 address){
}
void mapper001::writePRGData(Uint16 address, Uint8 value){
}
Uint8 mapper001::readCHRData(Uint16 address){
}
void mapper001::writeCHRData(Uint16 address, Uint8 value){
}
void mapper001::reset(){
}
@ -18,3 +31,6 @@ void mapper001::saveState(fstream* statefile){
void mapper001::loadState(fstream* statefile){
}
void mapper001::init(){
}

View file

@ -13,6 +13,7 @@ class mapper001 : public cart
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
protected:

View file

@ -4,13 +4,11 @@
#include "cpu.h"
#include "ppu.h"
#include "apu.h"
#include "gamepad.h"
memBus::memBus()
{
rom = gameManager::gm->rom;
cp = gameManager::gm->cp;
pp = gameManager::gm->pp;
ap = gameManager::gm->ap;
}
memBus::~memBus()
@ -34,8 +32,14 @@ Uint8 memBus::memRead(Uint16 address){
else if(address == 0x4015){
return ap->read4015();
}
else if(address == 0x4015){
return ap->read4015();
else if(address == 0x4016){
return gp->read4016();
}
else if(address == 0x4017){
return gp->read4017();
}
else if(address >= 0x4020){
return rom->readData(address);
}
}
@ -48,4 +52,14 @@ void memBus::saveState(fstream* statefile){
void memBus::loadState(fstream* statefile){
}
void memBus::init(){
rom = gameManager::gm->rom;
cp = gameManager::gm->cp;
pp = gameManager::gm->pp;
ap = gameManager::gm->ap;
gp = gameManager::gm->gp;
for(int i = 0; i < 0x800; ++i){
internalRAM[i] = rand() % 0x100;
}
}

View file

@ -15,6 +15,7 @@ class memBus : public corePart
cpu* cp;
ppu* pp;
apu* ap;
gamepad* gp;
memBus();
virtual ~memBus();
@ -22,6 +23,7 @@ class memBus : public corePart
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
Uint8 readByte();
Uint8 memRead(Uint16 address);

View file

@ -1,8 +1,7 @@
#include "ppu.h"
ppu::ppu()
{
//ctor
ppu::ppu(){
frameReady = false;
}
ppu::~ppu()
@ -18,6 +17,17 @@ void ppu::writeReg(Uint8 idx, Uint8 value){
registers[idx] = value;
}
Uint8 ppu::read4014(){
}
void ppu::write4014(Uint8 value){
}
void ppu::runCycle(){
}
void ppu::reset(){
}
@ -27,3 +37,5 @@ void ppu::saveState(fstream* statefile){
void ppu::loadState(fstream* statefile){
}
void ppu::init(){
}

View file

@ -9,18 +9,24 @@ class ppu : public corePart
public:
Uint8 registers[8];
Uint8 reg4014;
bool frameReady;
ppu();
virtual ~ppu();
void reset();
void saveState(fstream* statefile);
void loadState(fstream* statefile);
void init();
Uint8 readReg(Uint8 idx);
void writeReg(Uint8 idx, Uint8 value);
Uint8 read4014(Uint8 idx);
void write4014(Uint8 idx, Uint8 value);
Uint8 read4014();
void write4014(Uint8 value);
void runCycle();
protected:
private:

View file

@ -53,3 +53,5 @@ void audio::setVolume(int vol){
void audio::setUseHDPack(bool use){
useHDPack = use;
}

View file

@ -25,7 +25,6 @@ class audio : public emuPart
void setVolume(int vol);
void setUseHDPack(bool use);
protected:
private:

View file

@ -117,3 +117,5 @@ void video::setIgnoreEdge(bool use){

View file

@ -4,6 +4,14 @@
#include "../classList.h"
#include "emuPart.h"
#define TICKS_PER_FRAME_NTSC 16
#define TICKS_PER_FRAME_PAL 20
#define TICKS_REMAIN_NTSC 3
#define TICKS_REMAIN_PAL 1
#define TICKS_FRACTION_NTSC 2
#define TICKS_FRACTION_PAL 0
class video : public emuPart
{
public:

View file

@ -5,6 +5,7 @@
#include "core\cpu.h"
#include "core\ppu.h"
#include "core\apu.h"
#include "core\gamepad.h"
#include "emu\video.h"
#include "emu\audio.h"
#include "emu\gameFile.h"
@ -53,6 +54,11 @@ void gameManager::showUI(){
}
void gameManager::runGame(){
Uint32 frameTicks;
Uint8 ticksRemain;
Uint8 instructLen;
Uint8 cyclesToRun;
//load rom
//init core parts
rom = cart::getCartFromROMFile(romF->romPath);
@ -60,6 +66,7 @@ void gameManager::runGame(){
cp = new cpu();
pp = new ppu();
ap = new apu();
gp = new gamepad();
mb = new memBus();
//init emu parts
@ -69,13 +76,37 @@ void gameManager::runGame(){
inp->startGame();
gameState = GAME_STATE_RUNNING;
frameTicks = SDL_GetTicks();
ticksRemain = 0;
while(gameState != GAME_STATE_STOPPED){
inp->handleUserInput();
if(gameState != GAME_STATE_PAUSED){
if(!pp->frameReady){
cyclesToRun = cp->getNextInstructionLength();
for(Uint8 i = 0; i < cyclesToRun; ++i){
ap->runCycle();
pp->runCycle();
pp->runCycle();
pp->runCycle();
}
cp->runInstruction();
}
if(pp->frameReady && (frameTicks < SDL_GetTicks())){
//output frame
//calculate the time of next frame
frameTicks += TICKS_PER_FRAME_NTSC;
//add one tick for fractional part of ticks per frame
if(ticksRemain >= TICKS_REMAIN_NTSC){
++frameTicks;
ticksRemain -= TICKS_REMAIN_NTSC;
}
ticksRemain += TICKS_FRACTION_NTSC;
}
}
//while is running
// handle input
// handle game ui events like save and load state
@ -98,6 +129,7 @@ void gameManager::runGame(){
delete(cp);
delete(pp);
delete(ap);
delete(gp);
delete(mb);
}

View file

@ -29,6 +29,7 @@ class gameManager
ppu* pp;
apu* ap;
memBus* mb;
gamepad* gp;
int gameState;