-
Notifications
You must be signed in to change notification settings - Fork 42
[PS2] HD Support, video mode selector, make iso script #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ps2
Are you sure you want to change the base?
Changes from 2 commits
ab72fcb
decdfef
d9c1ff3
e62a282
7600db4
d6ec5f4
f088d3f
021c387
35dd6d4
9abab4f
4ee642a
e22594d
ec2267d
8d46c4a
2da8221
14051a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| BOOT2 = cdrom0:\SLUS_064.64;1 | ||
| VER = 1.00 | ||
| VMODE = NTSC |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -316,6 +316,10 @@ static void gfx_ps2_set_viewport(int x, int y, int width, int height) { | |
| r_view.x = x; | ||
| r_view.y = y; | ||
| r_view.w = width; | ||
| // 1080i requires the view point is half height | ||
| if (gs_global->Mode == GS_MODE_DTV_1080I) { | ||
| height /= 2; | ||
| } | ||
| r_view.h = height; | ||
| r_view.hw = r_view.w * 0.5f; | ||
| r_view.hh = r_view.h * 0.5f; | ||
|
|
@@ -324,6 +328,11 @@ static void gfx_ps2_set_viewport(int x, int y, int width, int height) { | |
| } | ||
|
|
||
| static inline void draw_set_scissor(const int x0, const int y0, const int x1, const int y1) { | ||
| // scissor doesn't work with gskit hires | ||
| if (gs_global->Mode == GS_MODE_DTV_720P || gs_global->Mode == GS_MODE_DTV_1080I) { | ||
| return; | ||
| } | ||
|
|
||
| u64 *p_data = gsKit_heap_alloc(gs_global, 1, 16, GIF_AD); | ||
|
|
||
| *p_data++ = GIF_TAG_AD(1); | ||
|
|
@@ -645,7 +654,6 @@ static void draw_clear(const u64 color) { | |
|
|
||
| u32 pos = 0; | ||
|
|
||
| strips++; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was one of the major bugs, doesn't show up on low res but hires it makes lines all over the screen. It's possibly something which was left in by mistake. |
||
| while (strips--) { | ||
| gsKit_prim_sprite(gs_global, pos, 0, pos + 64, gs_global->Height, 0, color); | ||
| pos += 64; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,12 +8,16 @@ | |
|
|
||
| #include <kernel.h> | ||
| #include <gsKit.h> | ||
| #include <gsHires.h> | ||
| #include <dmaKit.h> | ||
|
|
||
| #include "gfx_window_manager_api.h" | ||
| #include "gfx_screen_config.h" | ||
| #include "gfx_ps2.h" | ||
|
|
||
| #define FRAMERATE_SHIFT 1 | ||
| #define FRAMESKIP 10 | ||
|
|
||
| struct VidMode { | ||
| const char *name; | ||
| s16 mode; | ||
|
|
@@ -24,20 +28,21 @@ struct VidMode { | |
| int width; | ||
| int height; | ||
| int vck; | ||
| int iPassCount; | ||
| int x_off; | ||
| int y_off; | ||
| }; | ||
|
|
||
| static const struct VidMode vid_modes[] = { | ||
| // NTSC | ||
| { "480i", GS_MODE_NTSC, GS_INTERLACED, GS_FIELD, 704, 480, 704, 452, 4, 0, 0 }, | ||
| { "480p", GS_MODE_DTV_480P, GS_NONINTERLACED, GS_FRAME, 704, 480, 704, 452, 2, 0, 0 }, | ||
| { "480i", GS_MODE_NTSC, GS_INTERLACED, GS_FIELD, 704, 480, 704, 452, 4, 1, 0, 0 }, | ||
| { "480p", GS_MODE_DTV_480P, GS_NONINTERLACED, GS_FRAME, 704, 480, 704, 452, 2, 1, 0, 0 }, | ||
| // PAL | ||
| { "576i", GS_MODE_PAL, GS_INTERLACED, GS_FIELD, 704, 576, 704, 536, 4, 0, 0 }, | ||
| { "576p", GS_MODE_DTV_576P, GS_NONINTERLACED, GS_FRAME, 704, 576, 704, 536, 2, 0, 0 }, | ||
| { "576i", GS_MODE_PAL, GS_INTERLACED, GS_FIELD, 704, 576, 704, 536, 4, 1, 0, 0 }, | ||
| { "576p", GS_MODE_DTV_576P, GS_NONINTERLACED, GS_FRAME, 704, 576, 704, 536, 2, 1, 0, 0 }, | ||
| // HDTV | ||
| { "720p", GS_MODE_DTV_720P, GS_NONINTERLACED, GS_FRAME, 1280, 720, 1280, 698, 1, 0, 0 }, | ||
| {"1080i", GS_MODE_DTV_1080I, GS_INTERLACED, GS_FIELD, 1920, 1080, 1920, 1080, 1, 0, 0 }, | ||
| { "720p", GS_MODE_DTV_720P, GS_NONINTERLACED, GS_FRAME, 1280, 720, 1280, 720, 1, 2, 0, 0 }, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 passes works fine |
||
| {"1080i", GS_MODE_DTV_1080I, GS_INTERLACED, GS_FIELD, 1920, 1080, 1920, 1080, 1, 2, 0, 0 }, | ||
| }; | ||
|
|
||
| GSGLOBAL *gs_global; | ||
|
|
@@ -47,6 +52,7 @@ static int vsync_sema_2nd_id; | |
| static int vsync_sema_id = -1; | ||
|
|
||
| static const struct VidMode *vid_mode; | ||
| static bool use_hires = false; | ||
|
|
||
| /* Copy of gsKit_sync_flip, but without the 'flip' */ | ||
| static void gsKit_sync(GSGLOBAL *gsGlobal) | ||
|
|
@@ -99,31 +105,51 @@ static void prepare_sema() { | |
| } | ||
|
|
||
| static void gfx_ps2_init(const char *game_name, bool start_in_fullscreen) { | ||
| gs_global = gsKit_init_global(); | ||
|
|
||
| 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); | ||
|
|
||
| #if defined(VERSION_EU) | ||
| vid_mode = &vid_modes[2]; // PAL | ||
| #else | ||
| vid_mode = &vid_modes[0]; // NTCS | ||
| // change to 5 for 1080i | ||
| // vid_mode = &vid_modes[5]; | ||
| #endif | ||
| use_hires = (vid_mode->mode == GS_MODE_DTV_720P || vid_mode->mode == GS_MODE_DTV_1080I); | ||
|
|
||
| if (use_hires) { | ||
| gs_global = gsKit_hires_init_global(); | ||
| } else { | ||
| gs_global = gsKit_init_global(); | ||
| } | ||
|
|
||
| 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); | ||
|
|
||
| gs_global->Mode = vid_mode->mode; | ||
| gs_global->Width = vid_mode->width; | ||
| gs_global->Height = vid_mode->height; | ||
| if (gs_global->Mode == GS_MODE_DTV_1080I) { | ||
| gs_global->Height /= 2; | ||
| } | ||
|
|
||
| gs_global->Interlace = vid_mode->interlace; | ||
| gs_global->Field = vid_mode->field; | ||
| gs_global->ZBuffering = GS_SETTING_ON; | ||
| gs_global->DoubleBuffering = GS_SETTING_ON; | ||
| gs_global->PrimAAEnable = GS_SETTING_OFF; | ||
| gs_global->PSM = GS_PSM_CT24; | ||
| // this could be enabled for hires, but I don't like it | ||
| gs_global->Dithering = GS_SETTING_OFF; | ||
| // hires runs out of VRAM if using more than 16bit color | ||
| gs_global->PSM = use_hires ? GS_PSM_CT16 : GS_PSM_CT24; | ||
| gs_global->PSMZ = GS_PSMZ_16; // 16-bit unsigned zbuffer | ||
|
|
||
| gsKit_init_screen(gs_global); | ||
| if (use_hires) { | ||
| gsKit_hires_init_screen(gs_global, vid_mode->iPassCount); | ||
| } else { | ||
| gsKit_init_screen(gs_global); | ||
| } | ||
| // hires sets the texture pointer to the wrong location. Ensure it's correct. | ||
| gs_global->TexturePointer = gs_global->CurrentPointer; | ||
| gsKit_TexManager_init(gs_global); | ||
| } | ||
|
|
||
|
|
@@ -146,6 +172,11 @@ static void gfx_ps2_main_loop(void (*run_one_game_iter)(void)) { | |
| static void gfx_ps2_get_dimensions(uint32_t *width, uint32_t *height) { | ||
| *width = gs_global->Width; | ||
| *height = gs_global->Height; | ||
| // the game doesn't need to know that we are | ||
| // rendering at half height for 1080i | ||
| if (gs_global->Mode == GS_MODE_DTV_1080I) { | ||
| *height *= 2; | ||
| } | ||
| } | ||
|
|
||
| static void gfx_ps2_handle_events(void) { | ||
|
|
@@ -167,8 +198,12 @@ static void gfx_ps2_swap_buffers_begin(void) { | |
| static void gfx_ps2_swap_buffers_end(void) { | ||
| /* How SM64 expect to run at 30 PFS we need to wait for 2 vsync */ | ||
| gsKit_sync(gs_global); | ||
| if (use_hires) { | ||
| gsKit_hires_flip(gs_global); | ||
| } else { | ||
| gsKit_flip(gs_global); | ||
| } | ||
|
|
||
| gsKit_flip(gs_global); | ||
| gsKit_queue_exec(gs_global); | ||
| gsKit_TexManager_nextFrame(gs_global); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convinient way to create an ISO, perhaps mkiosfs needs to be added to the docker image?