PS2: Launcher drawing somewhat works

This commit is contained in:
UnknownShadow200 2023-11-18 10:56:31 +11:00
parent 07d2438d5a
commit b437554fa7
6 changed files with 44 additions and 21 deletions

View file

@ -5,9 +5,8 @@ OBJS :=$(patsubst %.c, %.o, $(CFILES))
EE_BIN = ClassiCube-ps2.elf
EE_OBJS = $(OBJS)
EE_LIBS = -ldebug -lpad -lc $(PS2DEV)/gsKit/lib/libgskit.a
EE_LIBS = -lpad -lpacket -ldma -lgraph -ldraw -lc
EE_CFLAGS = -DPLAT_PS2
EE_INCS = -I$(PS2DEV)/gsKit/include
all: $(EE_BIN)

View file

@ -8,7 +8,7 @@ struct Stream;
/* Represents a packed 32 bit RGBA colour, suitable for native graphics API texture pixels. */
typedef cc_uint32 BitmapCol;
#if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID || defined CC_BUILD_PSP || defined CC_BUILD_PSVITA
#if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID || defined CC_BUILD_PSP || defined CC_BUILD_PSVITA || defined CC_BUILD_PS2
#define BITMAPCOLOR_R_SHIFT 0
#define BITMAPCOLOR_G_SHIFT 8
#define BITMAPCOLOR_B_SHIFT 16

View file

@ -222,6 +222,7 @@ static void ToMortonTexture(C3D_Tex* tex, int originX, int originY,
dst[(mortonX | mortonY) + (tileX * 8) + (tileY * tex->width)] = pixel;
}
}
// TODO flush data cache GSPGPU_FlushDataCache
}
@ -406,7 +407,8 @@ static GfxResourceID Gfx_AllocStaticVb(VertexFormat fmt, int count) {
}
void Gfx_BindVb(GfxResourceID vb) {
gfx_vertices = vb; // https://github.com/devkitPro/citro3d/issues/47
gfx_vertices = vb;
// https://github.com/devkitPro/citro3d/issues/47
// "Fyi the permutation specifies the order in which the attributes are stored in the buffer, LSB first. So 0x210 indicates attributes 0, 1 & 2."
C3D_BufInfo* bufInfo = C3D_GetBufInfo();
BufInfo_Init(bufInfo);

View file

@ -42,15 +42,10 @@ const char* Platform_AppNameSuffix = " PS2";
*------------------------------------------------------Logging/Time-------------------------------------------------------*
*#########################################################################################################################*/
void Platform_Log(const char* msg, int len) {
//u32 done = 0;
//sysTtyWrite(STDOUT_FILENO, msg, len, &done);
//sysTtyWrite(STDOUT_FILENO, "\n", 1, &done);
char tmp[2048 + 1];
len = min(len, 2048);
Mem_Copy(tmp, msg, len); tmp[len] = '\0';
scr_printf("%s\n", tmp);
_print("%s\n", tmp);
}
@ -372,7 +367,6 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
void Platform_Init(void) {
//InitDebug();
SifInitRpc(0);
init_scr();
//netInitialize();
// Create root directory
Directory_Create(&String_Empty);

View file

@ -138,7 +138,7 @@ void android_main(void) {
SetupProgram(0, NULL);
for (;;) { RunProgram(0, NULL); }
}
#elif defined CC_BUILD_3DS || defined CC_BUILD_PSP || defined CC_BUILD_GCWII || defined CC_BUILD_DREAMCAST || defined CC_BUILD_XBOX || defined CC_BUILD_PSVITA || defined CC_BUILD_PS3 || defined CC_BUILD_N64
#elif defined CC_BUILD_3DS || defined CC_BUILD_PSP || defined CC_BUILD_GCWII || defined CC_BUILD_DREAMCAST || defined CC_BUILD_XBOX || defined CC_BUILD_PSVITA || defined CC_BUILD_PS3 || defined CC_BUILD_N64 || defined CC_BUILD_PS2
int main(int argc, char** argv) {
SetupProgram(argc, argv);
while (WindowInfo.Exists) {

View file

@ -13,11 +13,19 @@
#include "Logger.h"
#include <loadfile.h>
#include <libpad.h>
#include <gsKit.h>
#include <packet.h>
#include <dma_tags.h>
#include <gif_tags.h>
#include <gs_psm.h>
#include <dma.h>
#include <graph.h>
#include <draw.h>
#include <draw3d.h>
static cc_bool launcherMode;
static char padBuf[256] __attribute__((aligned(64)));
static GSGLOBAL *gsGlobal = NULL;
static framebuffer_t win_fb;
static void InitFramebuffer(void);
struct _DisplayData DisplayInfo;
struct _WinData WindowInfo;
@ -34,24 +42,22 @@ static void LoadModules(void) {
}
void Window_Init(void) {
gsGlobal = gsKit_init_global();
DisplayInfo.Width = gsGlobal->Width;
DisplayInfo.Height = gsGlobal->Height;
InitFramebuffer();
DisplayInfo.Width = win_fb.width;
DisplayInfo.Height = win_fb.height;
DisplayInfo.Depth = 4; // 32 bit
DisplayInfo.ScaleX = 1;
DisplayInfo.ScaleY = 1;
WindowInfo.Width = gsGlobal->Width;
WindowInfo.Height = gsGlobal->Height;
WindowInfo.Width = win_fb.width;
WindowInfo.Height = win_fb.height;
WindowInfo.Focused = true;
WindowInfo.Exists = true;
Input.Sources = INPUT_SOURCE_GAMEPAD;
DisplayInfo.ContentOffset = 10;
Platform_Log2("SIZE: %i x %i", &WindowInfo.Width, &WindowInfo.Height);
LoadModules();
padInit(0);
padPortOpen(0, 0, padBuf);
@ -157,12 +163,34 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
*------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/
static struct Bitmap fb_bmp;
static void InitFramebuffer(void) {
win_fb.width = 640;
win_fb.height = graph_get_region() == GRAPH_MODE_PAL ? 512 : 448;
win_fb.mask = 0;
win_fb.psm = GS_PSM_32;
win_fb.address = graph_vram_allocate(win_fb.width, win_fb.height, win_fb.psm, GRAPH_ALIGN_PAGE);
graph_initialize(win_fb.address, win_fb.width, win_fb.height, win_fb.psm, 0, 0);
}
void Window_AllocFramebuffer(struct Bitmap* bmp) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
fb_bmp = *bmp;
}
void Window_DrawFramebuffer(Rect2D r) {
packet_t* packet = packet_init(50,PACKET_NORMAL);
qword_t* q = packet->data;
q = draw_texture_transfer(q, fb_bmp.scan0, fb_bmp.width, fb_bmp.height, GS_PSM_32,
win_fb.address, win_fb.width);
q = draw_texture_flush(q);
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
dma_wait_fast();
packet_free(packet);
}
void Window_FreeFramebuffer(struct Bitmap* bmp) {