Skip to content

Commit

Permalink
Merge branch 'v0.2' of https://github.com/PSI-Rockin/CorgiDS into v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon committed Jan 21, 2018
2 parents 47e3d56 + 28a0370 commit 5f447b7
Show file tree
Hide file tree
Showing 14 changed files with 489 additions and 33 deletions.
5 changes: 5 additions & 0 deletions src/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ void NDS_Cart::power_on()
spi_params = 0;
}

bool NDS_Cart::game_loaded()
{
return ROM != nullptr;
}

int NDS_Cart::load_database(string file_name)
{
save_database = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/cartridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class NDS_Cart
public:
NDS_Cart(Emulator* e);
void power_on();
bool game_loaded();
int load_database(std::string file_name);
int load_ROM(std::string file_name);
void save_check();
Expand Down
16 changes: 16 additions & 0 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,22 @@ void ARM_CPU::add_s16_data(uint32_t address, int cycles)
timestamp += (1 + data_waitstates[(address & 0x0F000000) >> 24][3]) * cycles;
}

void ARM_CPU::update_code_waitstate(uint8_t region, int n32_cycles, int s32_cycles, int n16_cycles, int s16_cycles)
{
code_waitstates[region][0] = n32_cycles;
code_waitstates[region][1] = s32_cycles;
code_waitstates[region][2] = n16_cycles;
code_waitstates[region][3] = s16_cycles;
}

void ARM_CPU::update_data_waitstate(uint8_t region, int n32_cycles, int s32_cycles, int n16_cycles, int s16_cycles)
{
data_waitstates[region][0] = n32_cycles;
data_waitstates[region][1] = s32_cycles;
data_waitstates[region][2] = n16_cycles;
data_waitstates[region][3] = s16_cycles;
}

void ARM_CPU::andd(int destination, int source, int operand, bool set_condition_codes)
{
uint32_t result = source & operand;
Expand Down
3 changes: 3 additions & 0 deletions src/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class ARM_CPU
void add_s32_data(uint32_t address, int cycles);
void add_n16_data(uint32_t address, int cycles);
void add_s16_data(uint32_t address, int cycles);

void update_code_waitstate(uint8_t region, int n32_cycles, int s32_cycles, int n16_cycles, int s16_cycles);
void update_data_waitstate(uint8_t region, int n32_cycles, int s32_cycles, int n16_cycles, int s16_cycles);

void add_internal_cycles(int cycles);
void add_cop_cycles(int cycles);
Expand Down
10 changes: 7 additions & 3 deletions src/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Emulator::power_on()
int9_reg.IE = 0;
int9_reg.IF = 0;

if (Config::direct_boot_enabled)
if (Config::direct_boot_enabled && cart.game_loaded())
direct_boot();
}

Expand Down Expand Up @@ -355,9 +355,10 @@ bool Emulator::is_gba()
//Only use throw_exception when emulation has started
void Emulator::start_gba_mode(bool throw_exception)
{
power_on();
WAITCNT = 0;
gba_mode = true;
arm7.gba_boot(true);
gba_dma.power_on();
//debug();
//Allocate VRAM C and D as 256 KB work RAM
gpu.set_VRAMCNT_C(0x82);
Expand All @@ -376,7 +377,10 @@ uint64_t Emulator::get_timestamp()

void Emulator::HBLANK_DMA_request()
{
dma.HBLANK_request();
if (!gba_mode)
dma.HBLANK_request();
else
gba_dma.HBLANK_request();
}

void Emulator::gamecart_DMA_request()
Expand Down
2 changes: 2 additions & 0 deletions src/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class Emulator
uint64_t SQRT_PARAM;
uint8_t POSTFLG7, POSTFLG9; //0x04000300
uint32_t BIOSPROT; //0x04000308

uint16_t WAITCNT;

bool hstep_even; //Debugging purposes

Expand Down
13 changes: 11 additions & 2 deletions src/gba/gbadma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ void GBA_DMA::write_CNT(int index, uint16_t CNT)
dmas[index].internal_source = dmas[index].source;
dmas[index].internal_dest = dmas[index].destination;
dmas[index].internal_len = 0;
if (dmas[index].CNT.timing)
/*if (dmas[index].CNT.timing)
{
printf("\nDMA%d activated", index);
printf("\nSource: $%08X", dmas[index].source);
printf("\nDest: $%08X", dmas[index].destination);
printf("\nLen: %d", dmas[index].length);
printf("\nCNT: $%04X", dmas[index].CNT.get());
printf("\nTiming: %d", dmas[index].CNT.timing);
}
}*/

if (dmas[index].CNT.timing == 0)
{
Expand All @@ -152,3 +152,12 @@ void GBA_DMA::write_len_CNT(int index, uint32_t word)
write_len(index, word & 0xFFFF);
write_CNT(index, word >> 16);
}

void GBA_DMA::HBLANK_request()
{
for (int i = 0; i < 4; i++)
{
if (dmas[i].CNT.enabled && (dmas[i].CNT.timing & 0x4) != 0)
handle_DMA(i);
}
}
2 changes: 2 additions & 0 deletions src/gba/gbadma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class GBA_DMA
void write_len(int index, uint32_t len);
void write_CNT(int index, uint16_t CNT);
void write_len_CNT(int index, uint32_t word);

void HBLANK_request();
};

#endif // GBADMA_HPP
Loading

0 comments on commit 5f447b7

Please sign in to comment.