mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-06-01 18:41:13 -07:00
wip: attempting to do gp_display_frame and gp_screen_init in asm
This commit is contained in:
Vendored
+2
-1
@@ -23,6 +23,7 @@
|
||||
"initializer_list": "c",
|
||||
"string_view": "c",
|
||||
"functional": "c",
|
||||
"tuple": "c"
|
||||
"tuple": "c",
|
||||
"hello_gpu.h": "c"
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -97,8 +97,8 @@
|
||||
# 13 Textured Rectangle Y-Flip (BIOS does set it equal to GPUSTAT.13...?)
|
||||
# 14 - 23 Not used (should be 0)
|
||||
# 24 - 31 Command (E1h)
|
||||
.equiv gp_SetDisplayMode_DrawAllowed, 10
|
||||
.equiv gp_SetDisplayMode_DipArea, gcmd_SetDrawMode << gcmd_offset | 0x1 << gp_SetDisplayMode_DrawAllowed
|
||||
.equiv gp_DrawMode_DrawAllowed, 10
|
||||
.equiv gp_SetDrawMode_DrawAllowed, (gcmd_SetDrawMode << gcmd_offset | 0x1 << gp_DrawMode_DrawAllowed)
|
||||
|
||||
# GP0(E3h) - Set Drawing Area top left (X1,Y1)
|
||||
# GP0(E4h) - Set Drawing Area bottom right (X2,Y2)
|
||||
|
||||
@@ -4,17 +4,62 @@
|
||||
#include "duffle/gp.h"
|
||||
#include "hello_gpu.h"
|
||||
|
||||
#include "libgpu.h"
|
||||
#include "libetc.h"
|
||||
|
||||
DoubleBuffer screen_buffer;
|
||||
S16 active_screen_buffer;
|
||||
|
||||
void gp_screen_init_c11(void)
|
||||
{
|
||||
ResetGraph(0);
|
||||
// First buffer area
|
||||
SetDefDispEnv((DISPENV*)& screen_buffer.display[0], 0, 0, ScreenRes_X, ScreenRes_Y);
|
||||
SetDefDrawEnv((DRAWENV*)& screen_buffer.draw [0], 0, ScreenRes_Y, ScreenRes_X, ScreenRes_Y);
|
||||
// Second buffer rea
|
||||
SetDefDispEnv((DISPENV*)& screen_buffer.display[1], 0, ScreenRes_Y, ScreenRes_X, ScreenRes_Y);
|
||||
SetDefDrawEnv((DRAWENV*)& screen_buffer.draw [1], 0, 0, ScreenRes_X, ScreenRes_Y);
|
||||
// Set the back/drawing buffer
|
||||
screen_buffer.draw[0].enable_auto_clear = true;
|
||||
screen_buffer.draw[1].enable_auto_clear = true;
|
||||
// Set the background clear color
|
||||
screen_buffer.draw[0].initial_bg_color = (RGB8){ .r = 63, .g = 0, .b = 127 };
|
||||
screen_buffer.draw[1].initial_bg_color = (RGB8){ .r = 127, .g = 63, .b = 0 };
|
||||
// Set the current initial buffer
|
||||
active_screen_buffer = 0;
|
||||
PutDispEnv((DISPENV*)& screen_buffer.display[active_screen_buffer]);
|
||||
PutDrawEnv((DRAWENV*)& screen_buffer.draw [active_screen_buffer]);
|
||||
// Initialize and setup the GTE geometry offsets
|
||||
InitGeom();
|
||||
SetGeomOffset(ScreenRes_CenterX, ScreenRes_CenterY);
|
||||
SetGeomScreen(ScreenRes_CenterX);
|
||||
// Enable display
|
||||
SetDispMask(1);
|
||||
}
|
||||
|
||||
void gp_display_frame_c11(void) {
|
||||
DrawSync(0);
|
||||
VSync(0);
|
||||
PutDispEnv((DISPENV*)& screen_buffer.display[active_screen_buffer]);
|
||||
PutDrawEnv((DRAWENV*)& screen_buffer.draw [active_screen_buffer]);
|
||||
{
|
||||
// TODO: Sort objects in ordering table
|
||||
}
|
||||
active_screen_buffer = !active_screen_buffer; // Swap current buffer
|
||||
}
|
||||
|
||||
void render_c11(void) {
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
gp_screen_init();
|
||||
// gp_screen_init();
|
||||
gp_screen_init_c11();
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
render_c11();
|
||||
gp_display_frame_c11();
|
||||
};
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
typedef def_struct(DrawEnv_Packed) { U32 tag; U32 code[15]; };
|
||||
typedef def_struct(DrawEnv) {
|
||||
Rect_S16 clip_area;
|
||||
A2_S16 drawwing_offset;
|
||||
Rect_S16 texture_page;
|
||||
A2_S16 drawing_offset;
|
||||
Rect_S16 texture_window;
|
||||
S16 texture_page;
|
||||
BYTE flag_dither;
|
||||
BYTE flag_draw_on_display;
|
||||
BYTE enable_auto_clear;
|
||||
|
||||
@@ -5,38 +5,22 @@
|
||||
.include "./asmdd/io.s"
|
||||
.include "./asmdd/gp.s"
|
||||
|
||||
# DrawEnv_Packed { U32 tag; U32 code[15]; }
|
||||
# DrawEnv_Packed
|
||||
.equ DrawEnv_Packed_tag, 0
|
||||
.equ DrawEnv_Packed_code, 4
|
||||
.equ sizeof_DrawEnv_Packed, 64
|
||||
# DrawEnv {
|
||||
# Rect_S16 clip_area;
|
||||
# A2_S16 drawwing_offset;
|
||||
# Rect_S16 texture_page;
|
||||
# BYTE flag_dither;
|
||||
# BYTE flag_draw_on_display;
|
||||
# BYTE enable_auto_clear;
|
||||
# RGB8 initial_bg_color;
|
||||
# // 2 bytes padding
|
||||
# DrawEnv_Packed dr_env;
|
||||
# };
|
||||
.equ DrawEnv_clip_area, 0
|
||||
.equ DrawEnv_drawwing_offset, 8
|
||||
.equ DrawEnv_texture_page, 12
|
||||
.equ DrawEnv_flag_dither, 20
|
||||
.equ DrawEnv_flag_draw_on_display, 21
|
||||
.equ DrawEnv_enable_auto_clear, 22
|
||||
.equ DrawEnv_initial_bg_color, 23
|
||||
# DrawEnv
|
||||
.equ DrawEnv_clip_area, 0
|
||||
.equ DrawEnv_drawing_offset, 8
|
||||
.equ DrawEnv_texture_window, 12
|
||||
.equ DrawEnv_texture_page, 20
|
||||
.equ DrawEnv_flag_dither, 22
|
||||
.equ DrawEnv_flag_draw_on_display, 23
|
||||
.equ DrawEnv_enable_auto_clear, 24
|
||||
.equ DrawEnv_initial_bg_color, 25
|
||||
.equ DrawEnv_dr_env, 28
|
||||
.equ sizeof_DrawEnv, 92
|
||||
# DisplayEnv {
|
||||
# Rect_S16 display_area;
|
||||
# Rect_S16 screen;
|
||||
# BYTE vinterlace;
|
||||
# BYTE color24;
|
||||
# BYTE pad0;
|
||||
# BYTE pad1;
|
||||
# };
|
||||
# DisplayEnv
|
||||
.equ DisplayEnv_display_area, 0
|
||||
.equ DisplayEnv_screen, 8
|
||||
.equ DisplayEnv_vinterlace, 16
|
||||
@@ -44,10 +28,7 @@
|
||||
.equ DisplayEnv_pad0, 18
|
||||
.equ DisplayEnv_pad1, 19
|
||||
.equ sizeof_DisplayEnv, 20
|
||||
# DoubleBuffer {
|
||||
# DrawEnv draw[2];
|
||||
# DisplayEnv display[2];
|
||||
# };
|
||||
# DoubleBuffer
|
||||
.equ DoubleBuffer_draw, 0
|
||||
.equ DoubleBuffer_draw_0, 0
|
||||
.equ DoubleBuffer_draw_1, 92 # 0 + sizeof_DrawEnv
|
||||
@@ -58,8 +39,9 @@
|
||||
# Screen Constants
|
||||
.equ ScreenRes_X, 320
|
||||
.equ ScreenRes_Y, 240
|
||||
.equ ScreenRes_CenterX, (ScreenRes_X >> 2)
|
||||
.equ ScreenRes_CenterY, (ScreenRes_Y >> 2)
|
||||
.equ ScreenRes_CenterX, (ScreenRes_X >> 1)
|
||||
.equ ScreenRes_CenterY, (ScreenRes_Y >> 1)
|
||||
|
||||
|
||||
|
||||
.global gp_screen_init
|
||||
@@ -72,7 +54,20 @@ gp_screen_init:
|
||||
|
||||
gcmd_push gp1, rtmp_1, gp_Reset
|
||||
gcmd_push gp1, rtmp_1, gp_DisplayEnabled
|
||||
gcmd_push gp1, rtmp_1, gp_DisplayMode_320x240_15bit_NTSC
|
||||
gcmd_push gp1, rtmp_1, gp_HorizontalDisplayRange_3168_608
|
||||
gcmd_push gp1, rtmp_1, gp_VerticalDisplayRange_264_24
|
||||
|
||||
jump_reg rret_addr; nop
|
||||
|
||||
.Lgp_screen_init_end:
|
||||
.size gp_screen_init, . - gp_screen_init
|
||||
|
||||
.global gp_display_frame
|
||||
.type gp_display_frame, @function
|
||||
gp_display_frame:
|
||||
// TODO(Ed): Time to read docs
|
||||
|
||||
.Lgp_display_frame_end:
|
||||
.size gp_display_frame, . - gp_display_frame
|
||||
|
||||
|
||||
Reference in New Issue
Block a user