Skip to content

Commit

Permalink
Add video mode DTV 640x480, fix Center Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
infval committed Apr 24, 2018
1 parent 093aa3f commit a32368b
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 168 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ D-pad: D-pad
## Dependencies
* https://github.com/ps2dev/ps2sdk (use [ps2toolchain](https://github.com/ps2dev/ps2toolchain))
* https://github.com/ps2dev/gsKit
* https://github.com/ps2dev/ps2sdk-ports (libjpeg)
* https://github.com/ps2dev/ps2sdk-ports (libjpeg, libpng, libz)
* https://github.com/ps2dev/ps2-packer (optinal)

## Historical note
Expand Down
43 changes: 25 additions & 18 deletions src/drivers/ps2/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ extern GSFONTM *gsFontM;
extern u32 old_pad[4];
static struct padButtonStatus buttons[2];

extern int defaultx, defaulty;
int oldselect = -1;
s8 selected = 0;
u8 selected_dir = 0;
Expand All @@ -44,9 +43,11 @@ extern int FONT_WIDTH;
char path[4096] = "path";
int needed_path[2] = { -1, -1 };
char mpartitions[4][256];
u16 history[20]; // 20 levels should be enough
static u16 history[20]; // 20 levels should be enough
u8 h = 0;
int first_file_index;
static int first_file_index;

#define FILEENTRY_SIZE 2048

extern int Browser_Menu();

Expand Down Expand Up @@ -244,15 +245,15 @@ int listdir(char *path, entries *FileEntry, int files_too)
FileEntry[0].dircheck = 1;
n = 1;
while (fioDread(dd, &buf) > 0) {
if (n > 2046) { break; }
if (n > FILEENTRY_SIZE - 2) { break; }
if ((FIO_SO_ISDIR(buf.stat.mode)) && (!strcmp(buf.name, ".") || !strcmp(buf.name, "..")))
continue; // Makes sure no .. or .'s are listed since it's already there
if (FIO_SO_ISDIR(buf.stat.mode)) {
FileEntry[n].dircheck = 1;
strcpy(FileEntry[n].filename, buf.name);
strzncpy(FileEntry[n].displayname, FileEntry[n].filename, 63);
n++;
if (n >= 2046)
if (n >= FILEENTRY_SIZE - 2)
break;
}
}
Expand All @@ -266,7 +267,7 @@ int listdir(char *path, entries *FileEntry, int files_too)
dd = 0;
dd = fioDopen(path);
while (fioDread(dd, &buf) > 0) {
if (n > 2046) { break; }
if (n > FILEENTRY_SIZE - 2) { break; }
if (FIO_SO_ISREG(buf.stat.mode)) {
FileEntry[n].dircheck = 0;
strcpy(FileEntry[n].filename, buf.name);
Expand Down Expand Up @@ -337,7 +338,7 @@ int listpfs(char *path, entries *FileEntry, int files_too)
n++;
}

if (n > 2046) { break; }
if (n > FILEENTRY_SIZE - 2) { break; }
}
if (dd > 0) {
fileXioDclose(dd);
Expand All @@ -355,7 +356,7 @@ int listpfs(char *path, entries *FileEntry, int files_too)
strzncpy(FileEntry[n].displayname, FileEntry[n].filename, 63);
n++;
}
if (n > 2046) { break; }
if (n > FILEENTRY_SIZE - 2) { break; }
}
if (dd >= 0) {
fileXioDclose(dd);
Expand Down Expand Up @@ -519,8 +520,8 @@ char* Browser(int files_too, int menu_id)
int text_line = menu_y1 + 40;

oldselect = -1;
//entries FileEntry[2048]; // = malloc(sizeof(entries)*2048);
entries *FileEntry = calloc(sizeof(entries), 2048);
//entries FileEntry[FILEENTRY_SIZE]; // = malloc(sizeof(entries)*FILEENTRY_SIZE);
entries *FileEntry = calloc(sizeof(entries), FILEENTRY_SIZE);

int list_offset = text_line;

Expand Down Expand Up @@ -559,15 +560,20 @@ char* Browser(int files_too, int menu_id)
button_held = 0;
}

if (Settings.display) {
if (Settings.display == 0) {
max_item = 21;
if (gsGlobal->Interlace == GS_NONINTERLACED)
max_item = 9;
}
else if (Settings.display == 1) {
max_item = 25;
if (gsGlobal->Interlace == GS_NONINTERLACED)
max_item = 9;
}
else {
max_item = 21;
else if (Settings.display == 2) {
max_item = 23;
}
if (gsGlobal->Interlace == GS_NONINTERLACED)
max_item = 9;



// Scan for direct commands from input function
if (oldselect == -4) { // Just pushed triangle so go up a dir
Expand Down Expand Up @@ -600,7 +606,7 @@ char* Browser(int files_too, int menu_id)

// List files below
if (strcmp(path, oldpath) != 0) {
first_file_index = 2048;
first_file_index = FILEENTRY_SIZE;
if (!strncmp(path, "hdd0:/", 6)) {
if (!strcmp(path, "hdd0:/")) { // hdd0: selected so list partitions
n = listpartitions(FileEntry);
Expand Down Expand Up @@ -639,7 +645,7 @@ char* Browser(int files_too, int menu_id)
if (selection != oldselect) {

gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00, 0x00, 0x00, 0x80, 0x00));
browser_primitive("FCEUltra PS2 B0.93 [x.3.1]", "Browser", &BG_TEX, menu_x1, menu_y1, menu_x2, menu_y2);
browser_primitive("FCEUltra PS2 B0.93 [x.3.2]", "Browser", &BG_TEX, menu_x1, menu_y1, menu_x2, menu_y2);

if (selection > max_item) {
list_offset = text_line - (selection - max_item) * FONT_HEIGHT;
Expand Down Expand Up @@ -730,6 +736,7 @@ char* Browser(int files_too, int menu_id)
}
}
else if (!FileEntry[selection].dircheck) { // If file
first_file_index = FILEENTRY_SIZE;
sprintf(path, "%s%s", path, FileEntry[selection].filename);
printf("rompath = %s\n", path);
history[h] = selection;
Expand Down
84 changes: 34 additions & 50 deletions src/drivers/ps2/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#include "ps2fceu.h"
extern vars Settings;
int defaultx;
int defaulty;

// Input
#define NEW_PADMAN
Expand Down Expand Up @@ -72,6 +70,8 @@ extern unsigned int size_cdvd_irx;
extern unsigned char SMSUTILS_irx;
extern unsigned int size_SMSUTILS_irx;

static int VCK;

void poweroffps2(int i)
{
poweroffShutdown();
Expand All @@ -80,18 +80,10 @@ void poweroffps2(int i)
void SetupGSKit()
{
/* detect and set screentype */
//gsGlobal = gsKit_init_global(GS_MODE_PAL);
//gsGlobal = gsKit_init_global_custom(GS_RENDER_QUEUE_OS_POOLSIZE+GS_RENDER_QUEUE_OS_POOLSIZE/2, GS_RENDER_QUEUE_PER_POOLSIZE+GS_RENDER_QUEUE_PER_POOLSIZE/2);
if (gsGlobal != NULL) gsKit_deinit_global(gsGlobal);
gsGlobal = gsKit_init_global();

//gsGlobal->Height = 512; // No need for it

defaultx = gsGlobal->StartX;
defaulty = gsGlobal->StartY;

/* initialize dmaKit */
//dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8);
dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);

dmaKit_chan_init(DMA_CHANNEL_GIF);
Expand All @@ -103,8 +95,6 @@ void SetupGSKit()

// 640x448, ntsc, tv
// 640x512, pal, tv
//gsGlobal->Width = 640; // No need for it

}

void InitPS2()
Expand Down Expand Up @@ -174,56 +164,50 @@ printf("Failed to load module: cdInit2\n");
mtapPortOpen(0);
}

void normalize_screen()
{
GS_SET_DISPLAY1(gsGlobal->StartX, // X position in the display area (in VCK unit
gsGlobal->StartY, // Y position in the display area (in Raster u
gsGlobal->MagH, // Horizontal Magnification
gsGlobal->MagV, // Vertical Magnification
gsGlobal->DW - 1, // Display area width
gsGlobal->DH - 1); // Display area height

GS_SET_DISPLAY2(gsGlobal->StartX, // X position in the display area (in VCK units)
gsGlobal->StartY, // Y position in the display area (in Raster units)
gsGlobal->MagH, // Horizontal Magnification
gsGlobal->MagV, // Vertical Magnification
gsGlobal->DW - 1, // Display area width
gsGlobal->DH - 1); // Display area height
}

void init_custom_screen()
{
// Init real non-interlaced mode
if (Settings.display) {
if (Settings.display == 0) {
gsGlobal->Mode = GS_MODE_NTSC;
gsGlobal->Interlace = GS_INTERLACED;
gsGlobal->Field = GS_FIELD;
gsGlobal->Width = 640;
gsGlobal->Height = 448;
VCK = 4;
}
else if (Settings.display == 1) {
gsGlobal->Mode = GS_MODE_PAL;
gsGlobal->Interlace = GS_INTERLACED;
gsGlobal->Field = GS_FIELD;
gsGlobal->Width = 640;
gsGlobal->Height = 512;
defaulty = 72;
VCK = 4;
}
else {
gsGlobal->Mode = GS_MODE_NTSC;
gsGlobal->Height = 448;
defaulty = 50;
else if (Settings.display == 2) {
gsGlobal->Mode = GS_MODE_DTV_480P;
gsGlobal->Interlace = GS_NONINTERLACED;
gsGlobal->Field = GS_FRAME;
gsGlobal->Width = 640;
gsGlobal->Height = 480;
VCK = 2;
}
gsGlobal->Field = GS_FIELD;
gsGlobal->Width = 640;

gsGlobal->StartX = defaultx + Settings.offset_x;
gsGlobal->StartY = defaulty + Settings.offset_y;

if (!Settings.interlace) {
gsGlobal->Interlace = GS_NONINTERLACED;
gsGlobal->Height = gsGlobal->Height / 2;
gsGlobal->StartY = gsGlobal->StartY / 2 + 1;
if (Settings.display == 0 || Settings.display == 1) {
if (!Settings.interlace) {
gsGlobal->Interlace = GS_NONINTERLACED;
gsGlobal->Height = gsGlobal->Height / 2;
VCK = 2;
}
}
//else if (gsGlobal->Mode == GS_MODE_NTSC)
//gsGlobal->StartY = gsGlobal->StartY + 22;

// SetGsCrt(gsGlobal->Interlace, gsGlobal->Mode, gsGlobal->Field);
gsKit_vram_clear(gsGlobal);
gsKit_init_screen(gsGlobal); /* Apply settings. */
gsKit_set_display_offset(gsGlobal, Settings.offset_x * VCK, Settings.offset_y);
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
}

// normalize_screen();

void SetDisplayOffset()
{
gsKit_set_display_offset(gsGlobal, Settings.offset_x * VCK, Settings.offset_y);
}

void DrawScreen(GSGLOBAL *gsGlobal)
Expand Down
19 changes: 17 additions & 2 deletions src/drivers/ps2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,27 @@ void SetupNESGS()
width = newWidth;
}
}
else {
else if (gsGlobal->Mode == GS_MODE_PAL) {
v1 = 0;
v2 = NES_TEX.Height;
y2 = NES_TEX.Height;

if (Settings.aspect_ratio == 1) {
offsetX = 80;
width = 480;
}
}
else if (gsGlobal->Mode == GS_MODE_DTV_480P) {
v1 = 0;
v2 = NES_TEX.Height;
y2 = gsGlobal->Height;

if (Settings.aspect_ratio == 1) {
offsetX = 64;
width = 512;
}
}
if (gsGlobal->Interlace == GS_INTERLACED)
if (gsGlobal->Interlace == GS_INTERLACED && (gsGlobal->Mode == GS_MODE_NTSC || gsGlobal->Mode == GS_MODE_PAL))
y2 = y2*2;
//gsKit_prim_sprite_striped_texture(gsGlobal, &NES_TEX, // Thought this might be needed for different modes, but it just looks bad

Expand Down
Loading

0 comments on commit a32368b

Please sign in to comment.