mirror of https://github.com/mgba-emu/mgba.git
GB: Support CGB lockout
This commit is contained in:
parent
b11171c6f1
commit
d3d7b9606c
|
@ -167,6 +167,7 @@ void GBVideoWriteLYC(struct GBVideo* video, uint8_t value);
|
|||
void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value);
|
||||
void GBVideoSwitchBank(struct GBVideo* video, uint8_t value);
|
||||
|
||||
void GBVideoDisableCGB(struct GBVideo* video);
|
||||
void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint32_t color);
|
||||
|
||||
void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data);
|
||||
|
|
|
@ -424,6 +424,10 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
|
|||
free(gb->memory.romBase);
|
||||
gb->memory.romBase = gb->memory.rom;
|
||||
}
|
||||
if (gb->model >= GB_MODEL_CGB && gb->memory.io[0x6C]) {
|
||||
gb->model = GB_MODEL_DMG;
|
||||
GBVideoDisableCGB(&gb->video);
|
||||
}
|
||||
break;
|
||||
case REG_IE:
|
||||
gb->memory.ie = value;
|
||||
|
|
|
@ -561,6 +561,23 @@ void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint32_t color) {
|
|||
video->dmgPalette[index] = M_RGB8_TO_RGB5(color);
|
||||
}
|
||||
|
||||
void GBVideoDisableCGB(struct GBVideo* video) {
|
||||
video->dmgPalette[0] = video->palette[0];
|
||||
video->dmgPalette[1] = video->palette[1];
|
||||
video->dmgPalette[2] = video->palette[2];
|
||||
video->dmgPalette[3] = video->palette[3];
|
||||
video->dmgPalette[4] = video->palette[8 * 4 + 0];
|
||||
video->dmgPalette[5] = video->palette[8 * 4 + 1];
|
||||
video->dmgPalette[6] = video->palette[8 * 4 + 2];
|
||||
video->dmgPalette[7] = video->palette[8 * 4 + 3];
|
||||
video->dmgPalette[8] = video->palette[9 * 4 + 0];
|
||||
video->dmgPalette[9] = video->palette[9 * 4 + 1];
|
||||
video->dmgPalette[10] = video->palette[9 * 4 + 2];
|
||||
video->dmgPalette[11] = video->palette[9 * 4 + 3];
|
||||
video->renderer->deinit(video->renderer);
|
||||
video->renderer->init(video->renderer, video->p->model, video->sgbBorders);
|
||||
}
|
||||
|
||||
void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data) {
|
||||
int i;
|
||||
if (!(video->sgbCommandHeader & 7)) {
|
||||
|
|
Loading…
Reference in New Issue