Skip to content

Commit d6b7e70

Browse files
committed
Attempt to reach compatibility with upstream nxdk
1 parent c4e7991 commit d6b7e70

File tree

6 files changed

+22
-245
lines changed

6 files changed

+22
-245
lines changed

Makefile.xbox renamed to Makefile.nxdk

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
NXDK_DIR = $(CURDIR)/../nxdk
21
//NXDK_SDL = y
32

43
XBE_TITLE = OpenSWE1R
@@ -20,8 +19,7 @@ SRCS += $(CURDIR)/com/dplay.c
2019

2120
SRCS += $(CURDIR)/uc_native.c
2221

23-
SRCS += $(CURDIR)/xbox-hacks/qsort.c
24-
SRCS += $(CURDIR)/xbox-hacks/bsearch.c
22+
CFLAGS += -isystem$(CURDIR)/xbox-hacks
2523

2624
CFLAGS += -DUC_NATIVE=1 -DUC_KVM=1
2725
CFLAGS += -I/usr/include/unicorn

main.c

+13-23
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <stdlib.h>
1717
#include <inttypes.h>
1818
#include <assert.h>
19+
#include <ctype.h>
1920

2021
#include "common.h"
2122
#include "descriptor.h"
@@ -32,6 +33,17 @@
3233
#endif
3334

3435

36+
//FIXME: REMOVE THIS BLOCK! Only used during development
37+
#ifdef XBOX
38+
#define debugPrint(fmt, ...)
39+
#else
40+
#include <xboxrt/debug.h>
41+
#endif
42+
#ifdef XBOX
43+
#include <pbkit/pbkit.h>
44+
#include <hal/video.h>
45+
#endif
46+
3547
#include "SDL.h"
3648
static SDL_Window* sdlWindow;
3749

@@ -4284,23 +4296,6 @@ asm("_get_idt@4:\n"
42844296

42854297
#endif
42864298

4287-
#ifdef XBOX
4288-
// Stolen from https://gist.github.com/mmozeiko/ae38aeb10add7cb66be4c00f24f8e688
4289-
4290-
// C initializers
4291-
__attribute__((section(".CRT$XCA"))) _PVFV __xc_a[] = { 0 };
4292-
__attribute__((section(".CRT$XCZ"))) _PVFV __xc_z[] = { 0 };
4293-
4294-
static void win32_crt_call(_PVFV* a, _PVFV* b) {
4295-
while (a != b) {
4296-
if (*a) {
4297-
(**a)();
4298-
}
4299-
a++;
4300-
}
4301-
}
4302-
#endif
4303-
43044299
int main(int argc, char* argv[]) {
43054300
#ifdef XBOX
43064301

@@ -4312,6 +4307,7 @@ int main(int argc, char* argv[]) {
43124307
//FIXME: Seems to crash without pb_init?!
43134308
// As workaround, we use pb to show debug buffer, but then kill it.
43144309
// We simply don't need pbkit right now.
4310+
XVideoSetMode(640, 480, 32, REFRESH_DEFAULT);
43154311
pb_init();
43164312
pb_show_debug_screen();
43174313
//pb_kill();
@@ -4345,12 +4341,6 @@ for(int i = 0; i <= 0x13; i++) {
43454341

43464342
#endif
43474343

4348-
#ifdef XBOX
4349-
printf("-- Running CRT functions ()\n");
4350-
win32_crt_call(__xc_a, __xc_z);
4351-
#endif
4352-
4353-
43544344
printf("-- Initializing\n");
43554345
printf("Version: %s\n", APP_VERSION_STRING);
43564346
InitializeEmulation();

xbox-hacks/GL

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/usr/include/GL

xbox-hacks/bsearch.c

-64
This file was deleted.

xbox-hacks/qsort.c

-149
This file was deleted.

xbox.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
#include <stdio.h>
88

9-
#include <GL/glew.h>
10-
9+
#include <stddef.h>
1110
#include <assert.h>
1211
#include <stdbool.h>
13-
12+
#include <string.h>
1413
#include <stdint.h>
1514
#include <stdlib.h>
1615

16+
#define _PTRDIFF_T_DEFINED
17+
#include <GL/glew.h>
1718

1819
#include "xbox.h"
1920

@@ -560,7 +561,7 @@ GLEWAPI GLboolean glewExperimental = GL_FALSE;
560561

561562
GLEWAPI const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error) {
562563
printf("%s\n", __func__);
563-
return "<glew error string>";
564+
return (GLubyte*)"<glew error string>";
564565
}
565566

566567
GLEWAPI GLenum GLEWAPIENTRY glewInit (void) {
@@ -603,7 +604,7 @@ SDL_Window* SDL_CreateWindow(const char* title,
603604
int h,
604605
Uint32 flags) {
605606
printf("%s\n", __func__);
606-
return 1;
607+
return (SDL_Window*)1;
607608
}
608609

609610
void SDL_Delay(Uint32 ms) {
@@ -641,7 +642,7 @@ Uint64 SDL_GetPerformanceFrequency(void) {
641642

642643
SDL_GLContext SDL_GL_CreateContext(SDL_Window* window) {
643644
printf("%s\n", __func__);
644-
return 1;
645+
return (SDL_GLContext)1;
645646
}
646647

647648
int SDL_GL_SetAttribute(SDL_GLattr attr, int value) {

0 commit comments

Comments
 (0)