Skip to content

Commit

Permalink
== N64 ==
Browse files Browse the repository at this point in the history
- Prepared for tentative PAL resolutions at 288, not yet enabled
  • Loading branch information
ArtemioUrbina committed Aug 22, 2024
1 parent cc44526 commit 5b1b936
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 10 deletions.
4 changes: 2 additions & 2 deletions 240psuite/N64/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ int copyMenuFB() {
// resolution changes deallocate and reallocate libDragon's
// framebuffers (safe buffer)

if(getDispHeight() > 240 && (get_memory_size() / 0x100000) < 8)
if(getDispHeight() > 288 && (get_memory_size() / 0x100000) < 8)
return 0;

__menu_fb = (surface_t *)malloc(sizeof(surface_t));
Expand Down Expand Up @@ -690,7 +690,7 @@ int drawSplash(char *name, int delay, int paleteSize) {
return 0;

logo->center = true;
if(getDispHeight() > 240 && logo->tiles->height > 240)
if(getDispHeight() > 288 && logo->tiles->height > 240)
logo->scale = 0;
logo->palSize = paleteSize;

Expand Down
94 changes: 86 additions & 8 deletions 240psuite/N64/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ unsigned int current_gamma = 0;
filter_options_t current_antialias = 0;
rdpq_antialias_t current_rdp_aa_filter = AA_NONE;
unsigned int enablePAL60 = 0;
unsigned int enablePAL288 = 0;
unsigned int vMode = SUITE_NONE;

// PAL Video modes
const resolution_t RESOLUTION_320x288 = {320, 288, INTERLACE_OFF, true};
const resolution_t RESOLUTION_640x576 = {640, 576, INTERLACE_HALF, true};
const resolution_t RESOLUTION_256x288 = {256, 288, INTERLACE_OFF, true};
const resolution_t RESOLUTION_512x576 = {512, 576, INTERLACE_HALF, true};

#define TICKS_SINCE_MS(time) TICKS_SINCE(time) / (TICKS_PER_SECOND / 1000.0f)
unsigned int videoSet = 0;
Expand Down Expand Up @@ -233,6 +239,7 @@ void initVideo() {
current_antialias = FILTERS_RESAMPLE;
current_rdp_aa_filter = AA_NONE;
enablePAL60 = 0;
enablePAL288 = 0;
vMode = SUITE_NONE;

__newInternalBPPChange = DEPTH_16_BPP;
Expand All @@ -258,10 +265,15 @@ void setVideoInternal(resolution_t newRes) {
videoSet = 0;
}

if(enablePAL60)
newRes.pal60 = 1;
else
newRes.pal60 = 0;
if(isPAL) {
if(enablePAL288)
newRes.height = 288;

if(enablePAL60)
newRes.pal60 = 1;
else
newRes.pal60 = 0;
}
current_resolution = newRes;
current_bitdepth = __newInternalBPPChange;

Expand All @@ -288,15 +300,25 @@ int is50Hz() {
void changeToH256onVBlank() {
if(__changeInternalRes)
return;
if(current_resolution.height == 240)
if(current_resolution.width == 320) {
if(current_resolution.height == 240) {
if(current_resolution.width == 320)
changeVMode(RESOLUTION_256x240);
}

if(current_resolution.height == 480) {
if(current_resolution.width == 640)
changeVMode(RESOLUTION_512x480);
}

if(current_resolution.height == 288) {
if(current_resolution.width == 320)
changeVMode(RESOLUTION_256x288);
}

if(current_resolution.height == 576) {
if(current_resolution.width == 640)
changeVMode(RESOLUTION_512x576);
}
}

void changeToH320onVBlank() {
Expand All @@ -311,6 +333,16 @@ void changeToH320onVBlank() {
if(current_resolution.width == 512)
changeVMode(RESOLUTION_640x480);
}

if(current_resolution.height == 288) {
if(current_resolution.width == 256)
changeVMode(RESOLUTION_320x288);
}

if(current_resolution.height == 576) {
if(current_resolution.width == 512)
changeVMode(RESOLUTION_640x576);
}
}

void changeVMode(resolution_t newRes) {
Expand All @@ -325,6 +357,10 @@ int isVMode256() {
return 1;
if(vMode == SUITE_512x480)
return 1;
if(vMode == SUITE_256x288)
return 1;
if(vMode == SUITE_512x576)
return 1;
return 0;
}

Expand All @@ -333,6 +369,10 @@ int isVMode480() {
return 1;
if(vMode == SUITE_512x480)
return 1;
if(vMode == SUITE_640x576)
return 1;
if(vMode == SUITE_512x576)
return 1;
return 0;
}

Expand All @@ -343,8 +383,11 @@ int isSameRes(resolution_t *res1, const resolution_t *res2) {
return 0;
if(res1->interlaced != res2->interlaced)
return 0;
/*
// We don't check PAL60 atm
if(res1->pal60 != res2->pal60)
return 0;
*/
return 1;
}

Expand All @@ -361,6 +404,15 @@ int videoModeToInt(resolution_t *res) {
return SUITE_512x480;
if(isSameRes(res, &RESOLUTION_256x240))
return SUITE_256x240;

if(isSameRes(res, &RESOLUTION_320x288))
return SUITE_320x288;
if(isSameRes(res, &RESOLUTION_640x576))
return SUITE_640x576;
if(isSameRes(res, &RESOLUTION_256x288))
return SUITE_256x288;
if(isSameRes(res, &RESOLUTION_512x576))
return SUITE_512x576;
return SUITE_NONE;
}

Expand All @@ -375,10 +427,23 @@ void getVideoModeStr(char *res, int shortdesc) {
sprintf(res, "640x480i");
break;
case SUITE_256x240:
sprintf(res, "256x240");
sprintf(res, "256x240p");
break;
case SUITE_512x480:
sprintf(res, "512x480");
sprintf(res, "512x480i");
break;

case SUITE_320x288:
sprintf(res, "320x288p");
break;
case SUITE_640x576:
sprintf(res, "640x576i");
break;
case SUITE_256x288:
sprintf(res, "256x288p");
break;
case SUITE_512x576:
sprintf(res, "512x576i");
break;
}
}
Expand All @@ -396,6 +461,19 @@ void getVideoModeStr(char *res, int shortdesc) {
case SUITE_512x480:
sprintf(res, "[512]");
break;

case SUITE_320x288:
sprintf(res, "[288]");
break;
case SUITE_640x576:
sprintf(res, "[576i]");
break;
case SUITE_256x288:
sprintf(res, "[256]");
break;
case SUITE_512x576:
sprintf(res, "[512]");
break;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions 240psuite/N64/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#define SUITE_256x240 3
#define SUITE_512x480 4
#define SUITE_512x240 5
#define SUITE_320x288 6
#define SUITE_640x576 7
#define SUITE_256x288 8
#define SUITE_512x576 9

#define SUITE_NONE -1

Expand All @@ -42,6 +46,7 @@ extern unsigned int current_gamma;
extern filter_options_t current_antialias;
extern rdpq_antialias_t current_rdp_aa_filter;
extern unsigned int enablePAL60;
extern unsigned int enablePAL288;
extern unsigned int vMode;

int is50Hz();
Expand Down

0 comments on commit 5b1b936

Please sign in to comment.