Skip to content

Commit

Permalink
dos2unix
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Jan 12, 2024
1 parent 89aff2d commit 79b7954
Show file tree
Hide file tree
Showing 19 changed files with 1,857 additions and 1,857 deletions.
764 changes: 382 additions & 382 deletions src/vendor/libqboy/gbgpu.cpp

Large diffs are not rendered by default.

150 changes: 75 additions & 75 deletions src/vendor/libqboy/gbgpu.h
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
116 changes: 58 additions & 58 deletions src/vendor/libqboy/gbkeypad.cpp
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;
}
70 changes: 35 additions & 35 deletions src/vendor/libqboy/gbkeypad.h
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
Loading

0 comments on commit 79b7954

Please sign in to comment.