generated from Eeems-Org/remarkable-template-qt-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,857 additions
and
1,857 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
#ifndef GBGPU_H | ||
#define GBGPU_H | ||
|
||
#include "libqboy_global.h" | ||
#include "z80mmu.h" | ||
#include <vector> | ||
|
||
const int _GBGPU_W = 160; | ||
const int _GBGPU_H = 144; | ||
const int _GBGPU_VRAMBASE = 0x8000; | ||
const int _GBGPU_VREGBASE = 0xFF40; | ||
const int _GBGPU_VREGSIZE = 0xC; | ||
const int _GBGPU_VOAMBASE = 0xFE00; | ||
|
||
union gbgpu_oamflags { | ||
struct { | ||
quint8 reserved : 4; | ||
bool pal1 : 1; | ||
bool xflip : 1; | ||
bool yflip : 1; | ||
bool belowbg : 1; | ||
} flags; | ||
quint8 byte; | ||
}; | ||
|
||
class gbgpu { | ||
public: | ||
gbgpu(z80mmu *mmu); | ||
void reset(); | ||
void step(int z80m); | ||
bool is_updated(); | ||
quint8 *getLCD(); | ||
private: | ||
z80mmu *mmu; | ||
quint8 screen_buffer[_GBGPU_H][_GBGPU_W][4]; | ||
|
||
int mode; | ||
int modeclock; | ||
int line; | ||
bool scanlinetransfered; | ||
int oldmode; | ||
int oldline; | ||
|
||
bool updated; | ||
|
||
quint8 pallete_bg[4], pallete_obj0[4], pallete_obj1[4]; | ||
std::vector<quint8> registers; | ||
|
||
bool lcd_on(); | ||
bool bg_on(); | ||
bool win_on(); | ||
quint16 bg_mapbase(); | ||
quint16 win_mapbase(); | ||
bool tileset1(); | ||
bool sprite_on(); | ||
bool sprite_large(); | ||
quint8 yscroll(); | ||
quint8 xscroll(); | ||
quint8 linecmp(); | ||
quint8 winxpos(); | ||
quint8 winypos(); | ||
|
||
|
||
void renderscan(); | ||
void drawbackground(); | ||
void drawwindow(); | ||
void drawsprites(); | ||
void updatebuffer(); | ||
void preprocessram(); | ||
void postprocessram(); | ||
void setcolour(int x, quint8 value); | ||
quint8 getcolour(int x); | ||
}; | ||
|
||
#endif // GBGPU_H | ||
#ifndef GBGPU_H | ||
#define GBGPU_H | ||
|
||
#include "libqboy_global.h" | ||
#include "z80mmu.h" | ||
#include <vector> | ||
|
||
const int _GBGPU_W = 160; | ||
const int _GBGPU_H = 144; | ||
const int _GBGPU_VRAMBASE = 0x8000; | ||
const int _GBGPU_VREGBASE = 0xFF40; | ||
const int _GBGPU_VREGSIZE = 0xC; | ||
const int _GBGPU_VOAMBASE = 0xFE00; | ||
|
||
union gbgpu_oamflags { | ||
struct { | ||
quint8 reserved : 4; | ||
bool pal1 : 1; | ||
bool xflip : 1; | ||
bool yflip : 1; | ||
bool belowbg : 1; | ||
} flags; | ||
quint8 byte; | ||
}; | ||
|
||
class gbgpu { | ||
public: | ||
gbgpu(z80mmu *mmu); | ||
void reset(); | ||
void step(int z80m); | ||
bool is_updated(); | ||
quint8 *getLCD(); | ||
private: | ||
z80mmu *mmu; | ||
quint8 screen_buffer[_GBGPU_H][_GBGPU_W][4]; | ||
|
||
int mode; | ||
int modeclock; | ||
int line; | ||
bool scanlinetransfered; | ||
int oldmode; | ||
int oldline; | ||
|
||
bool updated; | ||
|
||
quint8 pallete_bg[4], pallete_obj0[4], pallete_obj1[4]; | ||
std::vector<quint8> registers; | ||
|
||
bool lcd_on(); | ||
bool bg_on(); | ||
bool win_on(); | ||
quint16 bg_mapbase(); | ||
quint16 win_mapbase(); | ||
bool tileset1(); | ||
bool sprite_on(); | ||
bool sprite_large(); | ||
quint8 yscroll(); | ||
quint8 xscroll(); | ||
quint8 linecmp(); | ||
quint8 winxpos(); | ||
quint8 winypos(); | ||
|
||
|
||
void renderscan(); | ||
void drawbackground(); | ||
void drawwindow(); | ||
void drawsprites(); | ||
void updatebuffer(); | ||
void preprocessram(); | ||
void postprocessram(); | ||
void setcolour(int x, quint8 value); | ||
quint8 getcolour(int x); | ||
}; | ||
|
||
#endif // GBGPU_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
#include "gbkeypad.h" | ||
|
||
gbkeypad::gbkeypad(z80mmu *mmu) { | ||
this->mmu = mmu; | ||
reset(); | ||
} | ||
|
||
void gbkeypad::step() { | ||
quint8 mem = mmu->readbyte(_GBKEYPAD_MEMADDR); | ||
mem &= 0x30; | ||
if (mem & 0x10) mem |= row0; | ||
if (mem & 0x20) mem |= row1; | ||
mmu->writebyte(_GBKEYPAD_MEMADDR, mem); | ||
|
||
if (interrupt) { | ||
mmu->writebyte(0xFF0F, mmu->readbyte(0xFF0F) | 0x10); | ||
} | ||
interrupt = false; | ||
} | ||
|
||
void gbkeypad::keydown(GBKeypadKey key) { | ||
switch (key) { | ||
case GBKeypadKey_RIGHT: row1 &= 0xE; break; | ||
case GBKeypadKey_LEFT: row1 &= 0xD; break; | ||
case GBKeypadKey_UP: row1 &= 0xB; break; | ||
case GBKeypadKey_DOWN: row1 &= 0x7; break; | ||
case GBKeypadKey_A: row0 &= 0xE; break; | ||
case GBKeypadKey_B: row0 &= 0xD; break; | ||
case GBKeypadKey_SELECT: row0 &= 0xB; break; | ||
case GBKeypadKey_START: row0 &= 0x7; break; | ||
case GBKeypadKey_NONE: | ||
default: | ||
break; | ||
} | ||
interrupt = true; | ||
} | ||
|
||
void gbkeypad::keyup(GBKeypadKey key) { | ||
switch (key) { | ||
case GBKeypadKey_RIGHT: row1 |= 0x1; break; | ||
case GBKeypadKey_LEFT: row1 |= 0x2; break; | ||
case GBKeypadKey_UP: row1 |= 0x4; break; | ||
case GBKeypadKey_DOWN: row1 |= 0x8; break; | ||
case GBKeypadKey_A: row0 |= 0x1; break; | ||
case GBKeypadKey_B: row0 |= 0x2; break; | ||
case GBKeypadKey_SELECT: row0 |= 0x4; break; | ||
case GBKeypadKey_START: row0 |= 0x8; break; | ||
case GBKeypadKey_NONE: | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void gbkeypad::reset() { | ||
row0 = row1 = 0x0F; | ||
column = 0x30; | ||
interrupt = false; | ||
} | ||
#include "gbkeypad.h" | ||
|
||
gbkeypad::gbkeypad(z80mmu *mmu) { | ||
this->mmu = mmu; | ||
reset(); | ||
} | ||
|
||
void gbkeypad::step() { | ||
quint8 mem = mmu->readbyte(_GBKEYPAD_MEMADDR); | ||
mem &= 0x30; | ||
if (mem & 0x10) mem |= row0; | ||
if (mem & 0x20) mem |= row1; | ||
mmu->writebyte(_GBKEYPAD_MEMADDR, mem); | ||
|
||
if (interrupt) { | ||
mmu->writebyte(0xFF0F, mmu->readbyte(0xFF0F) | 0x10); | ||
} | ||
interrupt = false; | ||
} | ||
|
||
void gbkeypad::keydown(GBKeypadKey key) { | ||
switch (key) { | ||
case GBKeypadKey_RIGHT: row1 &= 0xE; break; | ||
case GBKeypadKey_LEFT: row1 &= 0xD; break; | ||
case GBKeypadKey_UP: row1 &= 0xB; break; | ||
case GBKeypadKey_DOWN: row1 &= 0x7; break; | ||
case GBKeypadKey_A: row0 &= 0xE; break; | ||
case GBKeypadKey_B: row0 &= 0xD; break; | ||
case GBKeypadKey_SELECT: row0 &= 0xB; break; | ||
case GBKeypadKey_START: row0 &= 0x7; break; | ||
case GBKeypadKey_NONE: | ||
default: | ||
break; | ||
} | ||
interrupt = true; | ||
} | ||
|
||
void gbkeypad::keyup(GBKeypadKey key) { | ||
switch (key) { | ||
case GBKeypadKey_RIGHT: row1 |= 0x1; break; | ||
case GBKeypadKey_LEFT: row1 |= 0x2; break; | ||
case GBKeypadKey_UP: row1 |= 0x4; break; | ||
case GBKeypadKey_DOWN: row1 |= 0x8; break; | ||
case GBKeypadKey_A: row0 |= 0x1; break; | ||
case GBKeypadKey_B: row0 |= 0x2; break; | ||
case GBKeypadKey_SELECT: row0 |= 0x4; break; | ||
case GBKeypadKey_START: row0 |= 0x8; break; | ||
case GBKeypadKey_NONE: | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void gbkeypad::reset() { | ||
row0 = row1 = 0x0F; | ||
column = 0x30; | ||
interrupt = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
#ifndef GBKEYPAD_H | ||
#define GBKEYPAD_H | ||
|
||
#include "libqboy_global.h" | ||
#include "z80mmu.h" | ||
|
||
enum GBKeypadKey { | ||
GBKeypadKey_RIGHT, | ||
GBKeypadKey_LEFT, | ||
GBKeypadKey_UP, | ||
GBKeypadKey_DOWN, | ||
GBKeypadKey_A, | ||
GBKeypadKey_B, | ||
GBKeypadKey_SELECT, | ||
GBKeypadKey_START, | ||
GBKeypadKey_NONE | ||
}; | ||
|
||
const int _GBKEYPAD_MEMADDR = 0xFF00; | ||
|
||
class gbkeypad { | ||
public: | ||
gbkeypad(z80mmu *mmu); | ||
void reset(); | ||
void keyup(GBKeypadKey key); | ||
void keydown(GBKeypadKey key); | ||
void step(); | ||
private: | ||
z80mmu *mmu; | ||
quint8 row0, row1; | ||
quint8 column; | ||
bool interrupt; | ||
}; | ||
|
||
#endif // GBKEYPAD_H | ||
#ifndef GBKEYPAD_H | ||
#define GBKEYPAD_H | ||
|
||
#include "libqboy_global.h" | ||
#include "z80mmu.h" | ||
|
||
enum GBKeypadKey { | ||
GBKeypadKey_RIGHT, | ||
GBKeypadKey_LEFT, | ||
GBKeypadKey_UP, | ||
GBKeypadKey_DOWN, | ||
GBKeypadKey_A, | ||
GBKeypadKey_B, | ||
GBKeypadKey_SELECT, | ||
GBKeypadKey_START, | ||
GBKeypadKey_NONE | ||
}; | ||
|
||
const int _GBKEYPAD_MEMADDR = 0xFF00; | ||
|
||
class gbkeypad { | ||
public: | ||
gbkeypad(z80mmu *mmu); | ||
void reset(); | ||
void keyup(GBKeypadKey key); | ||
void keydown(GBKeypadKey key); | ||
void step(); | ||
private: | ||
z80mmu *mmu; | ||
quint8 row0, row1; | ||
quint8 column; | ||
bool interrupt; | ||
}; | ||
|
||
#endif // GBKEYPAD_H |
Oops, something went wrong.