Skip to content

Commit

Permalink
again
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Apr 15, 2024
1 parent 84276b8 commit 0602ebc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/build_xbox360.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,26 @@ jobs:
# otherwise notify_failure doesn't work
- name: Install curl when necessary
if: ${{ always() && steps.compile.outcome == 'failure' }}
run: apt-get install -y curl
run: |
sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
apt-get update
apt-get install -y curl
- uses: ./.github/actions/notify_failure
if: ${{ always() && steps.compile.outcome == 'failure' }}
with:
NOTIFY_MESSAGE: 'Failed to compile Xbox 360 build'
WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}'
WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}'


- uses: ./.github/actions/upload_build
if: ${{ always() && steps.compile.outcome == 'success' }}
with:
SOURCE_FILE: 'ClassiCube-xbox360.elf'
DEST_NAME: 'ClassiCube-xbox360.elf'

- uses: ./.github/actions/upload_build
if: ${{ always() && steps.compile.outcome == 'success' }}
with:
SOURCE_FILE: 'ClassiCube-xbox360.elf32'
DEST_NAME: 'ClassiCube-xbox360.elf32'
26 changes: 12 additions & 14 deletions src/Graphics_Xbox360.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ void Gfx_DeleteTexture(GfxResourceID* texId) {
*texId = NULL;
}

void Gfx_SetTexturing(cc_bool enabled) { }

void Gfx_EnableMipmaps(void) { } // TODO

void Gfx_DisableMipmaps(void) { } // TODO
Expand Down Expand Up @@ -305,13 +303,13 @@ void Gfx_CalcOrthoMatrix(struct Matrix* matrix, float width, float height, float
// TODO verify this
*matrix = Matrix_Identity;

matrix->row1.X = 2.0f / width;
matrix->row2.Y = -2.0f / height;
matrix->row3.Z = 1.0f / (zNear - zFar);
matrix->row1.x = 2.0f / width;
matrix->row2.y = -2.0f / height;
matrix->row3.z = 1.0f / (zNear - zFar);

matrix->row4.X = -1.0f;
matrix->row4.Y = 1.0f;
matrix->row4.Z = zNear / (zNear - zFar);
matrix->row4.x = -1.0f;
matrix->row4.y = 1.0f;
matrix->row4.z = zNear / (zNear - zFar);
}

static double Cotangent(double x) { return Math_Cos(x) / Math_Sin(x); }
Expand All @@ -321,12 +319,12 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
float c = (float)Cotangent(0.5f * fov);
*matrix = Matrix_Identity;

matrix->row1.X = c / aspect;
matrix->row2.Y = c;
matrix->row3.Z = zFar / (zNear - zFar);
matrix->row3.W = -1.0f;
matrix->row4.Z = (zNear * zFar) / (zNear - zFar);
matrix->row4.W = 0.0f;
matrix->row1.x = c / aspect;
matrix->row2.y = c;
matrix->row3.z = zFar / (zNear - zFar);
matrix->row3.w = -1.0f;
matrix->row4.z = (zNear * zFar) / (zNear - zFar);
matrix->row4.w = 0.0f;
}


Expand Down
52 changes: 28 additions & 24 deletions src/Window_Xbox360.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,26 @@
#include <xenos/xenos.h>
#include <input/input.h>
#include <usb/usbmain.h>
#include <pci/io.h>

static cc_bool launcherMode;

struct _DisplayData DisplayInfo;
struct _WindowData WindowInfo;

// https://github.com/Free60Project/libxenon/blob/71a411cddfc26c9ccade08d054d87180c359797a/libxenon/drivers/console/console.c#L47
struct ati_info {
uint32_t unknown1[4];
uint32_t base;
uint32_t unknown2[8];
uint32_t width;
uint32_t height;
} __attribute__ ((__packed__)) ;
static uint32_t reg_read32(int reg)
{
return read32n(0xec800000 + reg);
}

void Window_Init(void) {
struct ati_info* ai = (struct ati_info*)0xec806100ULL;

DisplayInfo.Width = ai->width;
DisplayInfo.Height = ai->height;
DisplayInfo.Depth = 4; // 32 bit
DisplayInfo.Width = reg_read32(D1GRPH_X_END);
DisplayInfo.Height = reg_read32(D1GRPH_Y_END);
DisplayInfo.ScaleX = 1;
DisplayInfo.ScaleY = 1;

Window_Main.Width = ai->width;
Window_Main.Height = ai->height;
Window_Main.Width = DisplayInfo.Width;
Window_Main.Height = DisplayInfo.Height;
Window_Main.Focused = true;
Window_Main.Exists = true;

Expand Down Expand Up @@ -129,17 +123,27 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) {
}

void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) {
return;
//void* fb = XVideoGetFB();
//XVideoWaitForVBlank();

/*cc_uint32* src = (cc_uint32*)bmp->scan0 + r.X;
cc_uint32* dst = (cc_uint32*)fb + r.X;
// https://github.com/Free60Project/libxenon/blob/master/libxenon/drivers/console/console.c#L166
// https://github.com/Free60Project/libxenon/blob/master/libxenon/drivers/console/console.c#L57
uint32_t* fb = (uint32_t*)(reg_read32(D1GRPH_PRIMARY_SURFACE_ADDRESS) | 0x80000000);
/* round up size to tiles of 32x32 */
int width = ((DisplayInfo.Width + 31) >> 5) << 5;

#define FB_INDEX(x, y) (((y >> 5)*32*width + ((x >> 5)<<10) + (x&3) + ((y&1)<<2) + (((x&31)>>2)<<3) + (((y&31)>>1)<<6)) ^ ((y&8)<<2))

for (int y = r.Y; y < r.Y + r.Height; y++)
for (int y = r.y; y < r.y + r.height; y++)
{
Mem_Copy(dst + y * bmp->width, src + y * bmp->width, r.Width * 4);
}*/
cc_uint32* src = bmp->scan0 + y * bmp->width;

for (int x = r.x; x < r.x + r.width; x++) {
// TODO: Can the uint be copied directly ?
int R = BitmapCol_R(src[x]);
int G = BitmapCol_G(src[x]);
int B = BitmapCol_B(src[x]);

fb[FB_INDEX(x, y)] = (B << 24) | (G << 16) | (R << 8) | 0xFF;
}
}
}

void Window_FreeFramebuffer(struct Bitmap* bmp) {
Expand Down

0 comments on commit 0602ebc

Please sign in to comment.