├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── base.mk ├── libpsx ├── include │ ├── inttypes.h │ ├── limits.h │ ├── stdarg.h │ ├── stdbool.h │ ├── stddef.h │ ├── stdint.h │ ├── stdio.h │ ├── stdlib.h │ └── string.h ├── libc │ ├── printf.S │ ├── stdio.c │ ├── stdlib.c │ └── string.c ├── psx-exe.ld ├── psx │ ├── bios.h │ ├── crt0.S │ ├── gpu.c │ ├── gpu.h │ ├── gx.c │ ├── gx.h │ ├── interrupts.c │ ├── interrupts.h │ └── io.h └── tools │ └── bin2exe.py ├── template ├── makefile └── src │ └── main.c ├── test ├── main.c ├── makefile └── test.S ├── test_gx ├── makefile ├── res │ └── kid.tim.c └── src │ └── main.c └── triangle ├── main.c ├── makefile └── primitives.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | # http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/ 3 | * text=auto 4 | 5 | # Custom for Visual Studio 6 | *.sln text eol=crlf merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | 3 | *.elf 4 | *.exe 5 | *.psx 6 | *.iso 7 | *.bin 8 | *.cue 9 | *.rom 10 | *.map 11 | *.sym 12 | *.pcx 13 | 14 | .*~ 15 | *~ 16 | *.swp 17 | *.swo 18 | *.tmp 19 | *.bak 20 | .tags 21 | tags 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2015 ARM9 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Requires a GCC mips toolchain, GNU tools and python. 2 | 3 | 4 | GCC mips cross compiler for linux/windows x64 available here: 5 | 6 | http://downloads.cen64.com/n64chain/ 7 | 8 | -------------------------------------------------------------------------------- /base.mk: -------------------------------------------------------------------------------- 1 | prefix := mips64-elf- 2 | CC := $(prefix)gcc 3 | AS := $(prefix)as 4 | LD := $(prefix)ld 5 | OBJCOPY := $(prefix)objcopy 6 | OBJDUMP := $(prefix)objdump 7 | bin2exe = python $(libpsx)/tools/bin2exe.py 8 | 9 | emudir := $(DEVKITPRO)/emulators 10 | nopsx := $(emudir)/psx/nopsx/NO\$$PSX.EXE 11 | 12 | .DEFAULT_GOAL := all 13 | 14 | build/%.o : %.S 15 | $(CC) $(asflags) $(includes) -MMD -c $< -o $@ 16 | 17 | build/%.o : %.c 18 | $(CC) $(cflags) $(includes) -MMD -c $< -o $@ 19 | 20 | %.exe : %.bin 21 | $(bin2exe) $< $@ 22 | 23 | %.bin : %.elf 24 | $(OBJCOPY) -O binary $< $@ 25 | 26 | %.elf : 27 | $(CC) $(ldflags) -o $@ $(ofiles) 28 | 29 | -------------------------------------------------------------------------------- /libpsx/include/inttypes.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_INTTYPES_H 3 | #define LIBPSX_INTTYPES_H 4 | 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /libpsx/include/limits.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_LIMITS_H 3 | #define LIBPSX_LIMITS_H 4 | 5 | #define CHAR_BIT 8 6 | 7 | #define SCHAR_MIN (-128) 8 | #define SCHAR_MAX 127 9 | 10 | #define UCHAR_MAX 255 11 | 12 | #ifdef __CHAR_UNSIGNED__ 13 | # define CHAR_MIN 0 14 | # define CHAR_MAX UCHAR_MAX 15 | #else 16 | # define CHAR_MIN SCHAR_MIN 17 | # define CHAR_MAX SCHAR_MAX 18 | #endif 19 | 20 | #define SHRT_MIN (-32768) 21 | #define SHRT_MAX 32767 22 | #define USHRT_MAX 65535 23 | 24 | #undef __INT_MAX__ 25 | #define __INT_MAX__ 2147483647 26 | #define INT_MIN (-INT_MAX-1) 27 | #define INT_MAX __INT_MAX__ 28 | #define UINT_MAX 4294967295U 29 | 30 | #undef __LONG_MAX__ 31 | #define __LONG_MAX__ 2147483647L 32 | #define LONG_MIN (-LONG_MAX-1) 33 | #define LONG_MAX __LONG_MAX__ 34 | #define ULONG_MAX 4294967295UL 35 | 36 | #undef __LONG_LONG_MAX__ 37 | #define __LONG_LONG_MAX__ 9223372036854775807LL 38 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 39 | # define LLONG_MIN (-LLONG_MAX-1) 40 | # define LLONG_MAX __LONG_LONG_MAX__ 41 | # define ULLONG_MAX 18446744073709551615ULL 42 | #endif 43 | 44 | #if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) 45 | #define LONG_LONG_MIN (-LONG_LONG_MAX-1) 46 | #define LONG_LONG_MAX __LONG_LONG_MAX__ 47 | #define ULONG_LONG_MAX 18446744073709551615ULL 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /libpsx/include/stdarg.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STDARG_H 3 | #define LIBPSX_STDARG_H 4 | 5 | #define va_arg(v,type) __builtin_va_arg(v,type) 6 | 7 | #define va_start(v,parmN) __builtin_va_start(v,parmN) 8 | #define va_end(v) __builtin_va_end(v) 9 | #if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L || defined(__GXX_EXPERIMENTAL_CXX0X__) 10 | # define va_copy(d,s) __builtin_va_copy(d,s) 11 | #endif 12 | #define __va_copy(d,s) __builtin_va_copy(d,s) 13 | 14 | typedef __gnuc_va_list va_list; 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /libpsx/include/stdbool.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STDBOOL_H 3 | #define LIBPSX_STDBOOL_H 4 | 5 | #define bool _Bool 6 | #define true 1 7 | #define false 0 8 | 9 | #define __bool_true_false_are_defined 1 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /libpsx/include/stddef.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STDDEF_H 3 | #define LIBPSX_STDDEF_H 4 | 5 | #define NULL ((void *) 0) 6 | 7 | //#define offsetof(st, member) ((size_t) (&((st *) 0)->member)) 8 | #define offsetof(st, member) __builtin_offsetof(st, member) 9 | 10 | typedef int ptrdiff_t; 11 | 12 | typedef int ssize_t; 13 | typedef unsigned size_t; 14 | 15 | typedef int wchar_t; 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /libpsx/include/stdint.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STDINT_H 3 | #define LIBPSX_STDINT_H 4 | 5 | typedef signed char int8_t; 6 | typedef unsigned char uint8_t; 7 | typedef signed short int int16_t; 8 | typedef unsigned short int uint16_t; 9 | typedef signed int int32_t; 10 | typedef unsigned int uint32_t; 11 | typedef signed long long int int64_t; 12 | typedef unsigned long long int uint64_t; 13 | 14 | typedef int32_t intptr_t; 15 | typedef uint32_t uintptr_t; 16 | 17 | #undef __INT8_MAX__ 18 | #define __INT8_MAX__ 127 19 | #define INT8_MIN (-INT8_MAX-1) 20 | #define INT8_MAX __INT8_MAX__ 21 | #define UINT8_MAX (__INT8_MAX__ * 2U + 1) 22 | 23 | #undef __INT16_MAX__ 24 | #define __INT16_MAX__ 32767 25 | #define INT16_MIN (-INT16_MAX-1) 26 | #define INT16_MAX __INT16_MAX__ 27 | #define UINT16_MAX (__INT16_MAX__ * 2U + 1) 28 | 29 | #undef __INT32_MAX__ 30 | #define __INT32_MAX__ 2147483647 31 | #define INT32_MIN (-INT32_MAX-1) 32 | #define INT32_MAX __INT32_MAX__ 33 | #define UINT32_MAX (__INT32_MAX__ * 2U + 1) 34 | 35 | #undef __INT64_MAX__ 36 | #define __INT64_MAX__ 9223372036854775807LL 37 | #define INT64_MIN (-INT64_MAX-1) 38 | #define INT64_MAX __INT64_MAX__ 39 | #define UINT64_MAX (__INT64_MAX__ * 2ULL + 1) 40 | 41 | #define INTMAX_MAX INT64_MAX 42 | #define INTMAX_MIN INT64_MIN 43 | #define UINTMAX_MAX UINT64_MAX 44 | 45 | #undef __INTPTR_MAX__ 46 | #define __INTPTR_MAX__ __INT32_MAX__ 47 | #define INTPTR_MIN (-INTPTR_MAX-1) 48 | #define INTPTR_MAX __INTPTR_MAX__ 49 | 50 | #undef __UINTPTR_MAX__ 51 | #define __UINTPTR_MAX__ (__INT32_MAX__ * 2U + 1) 52 | #define UINTPTR_MAX __UINTPTR_MAX__ 53 | 54 | #define SIZE_MAX (__INT32_MAX__ * 2U + 1) 55 | 56 | #define PTRDIFF_MIN (-PTRDIFF_MAX-1) 57 | #define PTRDIFF_MAX __INT32_MAX__ 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /libpsx/include/stdio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STDIO_H 3 | #define LIBPSX_STDIO_H 4 | 5 | #include 6 | 7 | int printf(const char *restrict fmt, ...); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /libpsx/include/stdlib.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STDLIB_H 3 | #define LIBPSX_STDLIB_H 4 | 5 | #include 6 | 7 | #define EXIT_FAILURE (-1) 8 | #define EXIT_SUCCESS 0 9 | 10 | #define RAND_MAX 2147483647 11 | 12 | //#define MB_CUR_MAX 1 13 | 14 | typedef struct { 15 | int quot, rem; 16 | } div_t; 17 | 18 | typedef struct { 19 | long quot, rem; 20 | } ldiv_t; 21 | 22 | typedef int (*__compar_fn_t)(const void *, const void *); 23 | 24 | int abs(int); 25 | long labs(long); 26 | 27 | //void abort(void); 28 | //int atexit(void (*)(void)); 29 | //void exit(int); 30 | //getenv(); 31 | //int system(const char *); 32 | 33 | //double atof(const char *); 34 | int atoi(const char *); 35 | long atol(const char *); 36 | //double strtod(const char *, char **); 37 | long strtol(const char *, char **, int); 38 | unsigned long strtoul(const char *, char **, int); 39 | 40 | void *bsearch(const void *, const void *, size_t, size_t, 41 | int(*)(const void*, const void *)); 42 | void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); 43 | 44 | void *calloc(size_t, size_t); 45 | void free(void *); 46 | void *malloc(size_t); 47 | void *realloc(void *, size_t); 48 | 49 | div_t div(int, int); 50 | ldiv_t ldiv(long, long); 51 | 52 | int rand(void); 53 | long random(void); 54 | void srand(unsigned); 55 | void srandom(unsigned); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /libpsx/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_STRING_H 3 | #define LIBPSX_STRING_H 4 | 5 | #include 6 | 7 | void *memcpy(void * restrict, const void * restrict, size_t); 8 | void *memmove(void *, const void *, size_t); 9 | char *strcpy(char * restrict, const char * restrict); 10 | char *strncpy(char * restrict, const char * restrict, size_t); 11 | char *strcat(char * restrict, const char * restrict); 12 | char *strncat(char * restrict, const char * restrict, size_t); 13 | int memcmp(const void *, const void *, size_t); 14 | int strcmp(const char *, const char *); 15 | int strcoll(const char *, const char *); 16 | int strncmp(const char *, const char *, size_t); 17 | size_t strxfrm(char * restrict, const char * restrict, size_t); 18 | void *memchr(const void *, int, size_t); 19 | char *strchr(const char *, int); 20 | size_t strcspn(const char *, const char *); 21 | char *strpbrk(const char *, const char *); 22 | char *strrchr(const char *, int); 23 | size_t strspn(const char *, const char *); 24 | char *strstr(const char *, const char *); 25 | char *strtok(char * restrict, const char * restrict); 26 | void *memset(void *, int, size_t); 27 | char *strerror(int); 28 | size_t strlen(const char *); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /libpsx/libc/printf.S: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | .align 2 4 | .global printf 5 | .type printf, @function 6 | printf: 7 | .set noat; .set noreorder 8 | // if the assembler/linker complains, use this: 9 | //ori $t0, $0, 0x00A0 10 | //jr $t0 11 | //ori $t1, $0, 0x3F 12 | 13 | j 0x000000A0 14 | ori $t1, $0, 0x3F 15 | 16 | .size printf, .-printf 17 | 18 | // vim:ft=mips 19 | -------------------------------------------------------------------------------- /libpsx/libc/stdio.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /libpsx/libc/stdlib.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | inline int abs(int n) { 5 | int result, dummy; 6 | __asm__ __volatile__( 7 | "sra %[tmp], %[in], 31\n\t" 8 | "xor %[in], %[in], %[tmp]\n\t" 9 | "sub %[out], %[in], %[tmp]\n\t" 10 | :[out] "=r" (result), [tmp] "=r" (dummy) 11 | :[in] "r" (n) 12 | :); 13 | return result; 14 | } 15 | 16 | inline long labs(long n) { 17 | return n < 0L ? -n : n; 18 | } 19 | 20 | int atoi(const char *str) { 21 | return 0; 22 | } 23 | 24 | long atol(const char *str) { 25 | return 0L; 26 | } 27 | 28 | long strtol(const char *str, char **end, int base) { 29 | return 0L; 30 | } 31 | 32 | unsigned long strtoul(const char *str, char **end, int base) { 33 | return 0UL; 34 | } 35 | 36 | void *bsearch(const void *key, const void *base, size_t nitems, 37 | size_t item_size, int (*compar)(const void *, const void *)) 38 | { 39 | return NULL; 40 | } 41 | 42 | void qsort(void *base, size_t nitems, size_t item_size, 43 | int (*compar)(const void *, const void *)) 44 | { 45 | 46 | } 47 | 48 | void *malloc(size_t n) { 49 | return NULL; 50 | } 51 | 52 | void *calloc(size_t num, size_t n) { 53 | return NULL; 54 | } 55 | 56 | void *realloc(void *block, size_t n) { 57 | return NULL; 58 | } 59 | 60 | void free(void *block) { 61 | 62 | } 63 | 64 | div_t div(int num, int den) { 65 | return (div_t){.quot=num/den, .rem=num%den}; 66 | } 67 | 68 | ldiv_t ldiv(long num, long den) { 69 | return (ldiv_t){.quot=num/den, .rem=num%den}; 70 | } 71 | 72 | int rand(void) { 73 | return 4; 74 | } 75 | 76 | long random(void) { 77 | return 4L; 78 | } 79 | 80 | void srand(unsigned seed) { 81 | 82 | } 83 | 84 | void srandom(unsigned seed) { 85 | 86 | } 87 | 88 | -------------------------------------------------------------------------------- /libpsx/libc/string.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void *memcpy(void * restrict dst, const void * restrict src, size_t n) { 4 | return NULL; 5 | } 6 | 7 | void *memmove(void *dst, const void *src, size_t n) { 8 | return NULL; 9 | } 10 | 11 | char *strcpy(char * restrict dst, const char * restrict src) { 12 | return NULL; 13 | } 14 | 15 | char *strncpy(char * restrict dst, const char * restrict src, size_t n) { 16 | return NULL; 17 | } 18 | 19 | char *strcat(char * restrict dst, const char * restrict src) { 20 | return NULL; 21 | } 22 | 23 | char *strncat(char * restrict dst, const char * restrict src, size_t n) { 24 | return NULL; 25 | } 26 | 27 | int memcmp(const void *s1, const void *s2, size_t n) { 28 | return 0; 29 | } 30 | 31 | int strcmp(const char *s1, const char *s2) { 32 | return 0; 33 | } 34 | 35 | int strcoll(const char *s1, const char *s2) { 36 | return 0; 37 | } 38 | 39 | int strncmp(const char *s1, const char *s2, size_t n) { 40 | return 0; 41 | } 42 | 43 | size_t strxfrm(char * restrict dst, const char * restrict src, size_t n) { 44 | return 0; 45 | } 46 | 47 | void *memchr(const void *s, int c, size_t n) { 48 | return NULL; 49 | } 50 | 51 | char *strchr(const char *s, int c) { 52 | return NULL; 53 | } 54 | 55 | size_t strcspn(const char *s1, const char *s2) { 56 | return 0; 57 | } 58 | 59 | char *strpbrk(const char *s1, const char *s2) { 60 | return NULL; 61 | } 62 | 63 | char *strrchr(const char *s, int c) { 64 | return NULL; 65 | } 66 | 67 | size_t strspn(const char *s1, const char *s2) { 68 | return 0; 69 | } 70 | 71 | char *strstr(const char *haystack, const char *needle) { 72 | return NULL; 73 | } 74 | 75 | char *strtok(char * restrict s, const char * restrict delim) { 76 | return NULL; 77 | } 78 | 79 | void *memset(void *s, int c, size_t n) { 80 | return NULL; 81 | } 82 | 83 | char *strerror(int errnum) { 84 | return NULL; 85 | } 86 | 87 | size_t strlen(const char *s) { 88 | return 0; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /libpsx/psx-exe.ld: -------------------------------------------------------------------------------- 1 | 2 | OUTPUT_FORMAT("elf32-littlemips") 3 | OUTPUT_ARCH(mips) 4 | 5 | EXTERN(_start) 6 | ENTRY(_start) 7 | 8 | MEMORY { 9 | wram : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000 10 | dcache : ORIGIN = 0x1F800000, LENGTH = 0x400 11 | } 12 | 13 | __wram_top = ORIGIN(wram) + LENGTH(wram); 14 | __sp = __wram_top - 0x100; 15 | 16 | __dcache = ORIGIN(dcache); 17 | __dcache_top = ORIGIN(dcache) + LENGTH(dcache); 18 | 19 | SECTIONS { 20 | . = ORIGIN(wram); 21 | __text_start = .; 22 | .text : { 23 | *(.boot) 24 | . = ALIGN(4); 25 | *(.init) 26 | *(.text.unlikely .text.*_unlikely .text.unlikely.*) 27 | *(.text.exit .text.exit.*) 28 | *(.text.startup .text.startup.*) 29 | *(.text.hot .text.hot.*) 30 | *(.text .stub .text.* .gnu.linkonce.t.*) 31 | . = ALIGN(4); 32 | } > wram 33 | 34 | .fini : { 35 | KEEP (*(SORT_NONE(.fini))) 36 | } > wram 37 | . = ALIGN(4); 38 | __text_end = .; 39 | 40 | .rodata : { 41 | *(.rodata .rodata.* .rdata .rdata.* .gnu.linkonce.r.*) 42 | } > wram 43 | 44 | .rodata1 : { 45 | *(.rodata1) 46 | } > wram 47 | 48 | .sdata2 : { 49 | *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) 50 | } > wram 51 | 52 | __sbss2_start = .; 53 | .sbss2 : { 54 | *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) 55 | } > wram 56 | __sbss2_end = .; 57 | 58 | .jcr : { 59 | KEEP (*(.jcr)) 60 | } > wram 61 | 62 | .data.rel.ro : { 63 | *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) 64 | } > wram 65 | 66 | __data_start = .; 67 | .data : { 68 | *(.data .data.* .gnu.linkonce.d.*) 69 | } > wram 70 | 71 | .data1 : { 72 | *(.data1) 73 | } > wram 74 | 75 | .got.plt : { 76 | *(.got.plt) 77 | } > wram 78 | 79 | HIDDEN (_gp = ALIGN(16) + 0x7FF0); 80 | 81 | .got : { 82 | *(.got) 83 | } > wram 84 | 85 | .sdata : { 86 | *(.sdata .sdata.* .gnu.linkonce.s.*) 87 | } > wram 88 | . = ALIGN(4); 89 | __data_end = .; 90 | 91 | __bss_start = .; 92 | .sbss : { 93 | *(.dynsbss) 94 | *(.sbss .sbss.* .gnu.linkonce.sb.*) 95 | *(.scommon) 96 | } > wram 97 | 98 | .bss : { 99 | *(.dynbss) 100 | *(.bss .bss.* .gnu.linkonce.b.*) 101 | *(COMMON) 102 | } > wram 103 | . = ALIGN(4); 104 | __bss_end = .; 105 | 106 | __end = .; 107 | 108 | /DISCARD/ : { *(.MIPS.abiflags) } 109 | 110 | /* Everything is statically linked, so discard PLTs. */ 111 | /DISCARD/ : { *(.rel.iplt) *(.rela.iplt) *(.rel.plt) *(.rela.plt) *(.plt) *(.iplt) } 112 | 113 | /* We don't make use of debugging information, so drop that, too. */ 114 | /DISCARD/ : { *(.debug) *(.debug_srcinfo) *(.debug_sfnames) *(.debug_aranges) *(.debug_pubnames) *(.debug_info .gnu.linkonce.wi.*) *(.debug_abbrev) *(.debug_line .debug_line.* .debug_line_end ) *(.debug_frame) *(.debug_str) *(.debug_loc) *(.debug_macinfo) *(.debug_weaknames) *(.debug_funcnames) *(.debug_typenames) *(.debug_varnames) *(.debug_pubtypes) *(.debug_ranges) *(.debug_macro) *(.mdebug.abi32) *(.mdebug.abiN32) *(.mdebug.abi64) *(.mdebug.abiO64) *(.mdebug.eabi32) *(.mdebug.eabi64) } 115 | 116 | /* Discard things that the standard link script drops, too. */ 117 | /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } 118 | } 119 | -------------------------------------------------------------------------------- /libpsx/psx/bios.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_BIOS_H 3 | #define LIBPSX_BIOS_H 4 | 5 | #define BIOS_CALL(x) __asm__ __volatile__ (\ 6 | "ori $t1, $0, " #x "\n\t"\ 7 | "j 0x000000A0\n\t":::"t1"); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /libpsx/psx/crt0.S: -------------------------------------------------------------------------------- 1 | 2 | .section .boot,"ax",@progbits 3 | .align 2 4 | .global _start 5 | .type _start, @function 6 | _start: 7 | .set noat; .set noreorder 8 | 9 | la $sp, __sp 10 | la $gp, _gp 11 | 12 | li $t0, 1<<30 // Enable COP2, COP0 in kernel mode 13 | mtc0 $t0,$12 // Status register 14 | 15 | jal main 16 | mtc0 $0,$13 // Clear irq pending bits 8-9 17 | 18 | 0: j 0b 19 | nop 20 | 21 | // vim:ft=mips 22 | -------------------------------------------------------------------------------- /libpsx/psx/gpu.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | void setDisplayMode(unsigned mode) { 6 | GP1_DO(DisplayMode, mode); 7 | } 8 | 9 | void setDisplayOrigin(uint16_t x, uint16_t y) { 10 | //((y & 0x1FF)<<10) | (x & 0x3FF) 11 | GP1_DO(DisplayArea, (y<<10) | x); 12 | } 13 | 14 | inline void waitGpu(unsigned status) { 15 | while((GP[1] & status) == 0); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /libpsx/psx/gpu.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_GPU_H 3 | #define LIBPSX_GPU_H 4 | 5 | #include 6 | 7 | // 15bpp format: bbbbb---ggggg---rrrrr--- 8 | // 24bpp format: bbbbbbbbggggggggrrrrrrrr 9 | 10 | // GPU Registers 11 | #define GP ((volatile unsigned*)0x1F801810) 12 | 13 | // Send command c with parameter(s) p 14 | #define GP0_DO(c,p) GP[0] = (((c)<<24)|(p)) 15 | #define GP1_DO(c,p) GP[1] = (((c)<<24)|(p)) 16 | 17 | #define GP0NOP GP0_DO(0x00,0) 18 | 19 | // GPUSTAT flags 20 | #define Gp0CmdReady 0x04000000 21 | #define Gp0DmaReady 0x10000000 22 | 23 | void waitGpu(unsigned status); 24 | 25 | 26 | // GP0 drawing commands 27 | #define FlatTriOpaque 0x20 28 | #define FlatTri 0x22 29 | #define FlatQuadOpaque 0x28 30 | #define FlatQuad 0x2A 31 | 32 | #define TexTriOpaqueBlend 0x24 33 | #define TexTriOpaqueRaw 0x25 34 | #define TexTriBlend 0x26 35 | #define TexTriRaw 0x27 36 | #define TexQuadOpaqueBlend 0x24 37 | #define TexQuadOpaqueRaw 0x25 38 | #define TexQuadBlend 0x26 39 | #define TexQuadRaw 0x27 40 | 41 | #define ShadedTriOpaque 0x30 42 | #define ShadedTri 0x32 43 | #define ShadedQuadOpaque 0x38 44 | #define ShadedQuad 0x3A 45 | 46 | #define ShadedTexTriOpaqueBlend 0x34 47 | #define ShadedTexTriBlend 0x36 48 | #define ShadedTexQuadOpaqueBlend 0x3C 49 | #define ShadedTexQuadBlend 0x3E 50 | 51 | #define FlatLineOpaque 0x40 52 | #define FlatLine 0x42 53 | #define FlatPolyLineOpaque 0x48 54 | #define FlatPolyLine 0x4A 55 | 56 | #define ShadedLineOpaque 0x50 57 | #define ShadedLine 0x52 58 | #define ShadedPolyLineOpaque 0x58 59 | #define ShadedPolyLine 0x5A 60 | 61 | #define FlatRectVarOpaque 0x60 62 | #define FlatRectVar 0x62 63 | #define FlatRect1x1Opaque 0x68 64 | #define FlatRect1x1 0x6A 65 | #define FlatRect8x8Opaque 0x70 66 | #define FlatRect8x8 0x72 67 | #define FlatRect16x16Opaque 0x78 68 | #define FlatRect16x16 0x7A 69 | 70 | #define TexRectVarOpaqueBlend 0x64 71 | #define TexRectVarOpaqueRaw 0x65 72 | #define TexRectVarBlend 0x66 73 | #define TexRectVarRaw 0x67 74 | // "nonsense" instructions 75 | //#define TexRect1x1OpaqueBlend 0x6C 76 | //#define TexRect1x1OpaqueRaw 0x6D 77 | //#define TexRect1x1Blend 0x6E 78 | //#define TexRect1x1Raw 0x6F 79 | #define TexRect8x8OpaqueBlend 0x74 80 | #define TexRect8x8OpaqueRaw 0x75 81 | #define TexRect8x8Blend 0x76 82 | #define TexRect8x8Raw 0x77 83 | #define TexRect16x16OpaqueBlend 0x7C 84 | #define TexRect16x16OpaqueRaw 0x7D 85 | #define TexRect16x16Blend 0x7E 86 | #define TexRect16x16Raw 0x7F 87 | 88 | // GP0 memory transfer commands 89 | #define ClearCache 0x01 90 | #define FillRectVram 0x02 91 | #define CopyRectVramVram 0x80 92 | #define CopyRectCpuVram 0xA0 93 | #define CopyRectVramCpu 0xC0 94 | 95 | // GP0 rendering attribute commands 96 | #define DrawMode 0xE1 97 | #define TextureWindow 0xE2 98 | #define DrawAreaTopLeft 0xE3 99 | #define DrawAreaBottomRight 0xE4 100 | #define DrawOffset 0xE5 101 | #define DrawMaskBit 0xE6 102 | 103 | // GP1 display commands 104 | #define ResetGpu 0x00 105 | #define ResetCommandBuffer 0x01 106 | #define AcknowledgeGpuIrq 0x02 107 | #define EnableDisplay 0x03 108 | #define DmaDirection 0x04 109 | #define DisplayArea 0x05 110 | #define DisplayRangeH 0x06 111 | #define DisplayRangeV 0x07 112 | #define DisplayMode 0x08 113 | #define TextureDisable 0x09 114 | #define GetGpuInfo 0x10 115 | 116 | #define DMODE_HRES_256 0x00 117 | #define DMODE_HRES_320 0x01 118 | #define DMODE_HRES_512 0x02 119 | #define DMODE_HRES_640 0x03 120 | #define DMODE_VRES_240 0x00 121 | #define DMODE_VRES_480 0x04 122 | 123 | void setDisplayMode(unsigned mode); 124 | 125 | void setDisplayOrigin(uint16_t x, uint16_t y); 126 | 127 | #endif 128 | 129 | -------------------------------------------------------------------------------- /libpsx/psx/gx.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | PSX GPU Graphics Wrapper 3 | ***************************************************************************/ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | /* Private utility macros */ 15 | #define GX_DRAWMODE_DISPLAY GX_BIT(10) 16 | #define GX_MAX_TEXTURES 16 17 | #define GX_CLUT(x, y) (x | (y << 6)) 18 | 19 | 20 | /* gx_texture */ 21 | typedef struct gx_texture 22 | { 23 | uint32_t occupied; 24 | uint32_t clut_x, clut_y; 25 | uint32_t texpage_x, texpage_y; 26 | uint32_t texpage_mode; 27 | uint16_t width; 28 | uint16_t height; 29 | } 30 | gx_texture_t; 31 | 32 | 33 | /* Internal state */ 34 | static uint16_t gx_res_w; 35 | static uint16_t gx_res_h; 36 | static gx_rgb24 gx_clear_color; 37 | static gx_rgb24 gx_draw_color; 38 | static gx_texture_t gx_textures[GX_MAX_TEXTURES]; 39 | static gx_texture_t *gx_active_texture; 40 | 41 | 42 | /* Determine width in pixels of display mode */ 43 | static int GetHResWidth(uint8_t hres) 44 | { 45 | switch (hres) 46 | { 47 | case GX_HRES_256: return 256; 48 | case GX_HRES_320: return 320; 49 | case GX_HRES_512: return 512; 50 | case GX_HRES_640: return 640; 51 | } 52 | return 0; 53 | } 54 | 55 | /* Determine height in pixels of display mode */ 56 | static int GetVResHeight(uint8_t vres) 57 | { 58 | switch (vres) 59 | { 60 | case GX_VRES_240: return 240; 61 | case GX_VRES_480: return 480; 62 | } 63 | return 0; 64 | } 65 | 66 | 67 | //---------------------------------------------------------------------------- 68 | // GX_Init 69 | //---------------------------------------------------------------------------- 70 | void GX_Init(uint8_t hres, uint8_t vres) 71 | { 72 | // Bootstrap 73 | GP1_DO(ResetGpu, 0); 74 | GP1_DO(EnableDisplay, 0); 75 | 76 | // Drawing to display 77 | GP0_DO(DrawMode, GX_DRAWMODE_DISPLAY); 78 | 79 | // Set display mode 80 | GP1_DO(DisplayMode, (vres << 2) | hres); 81 | gx_res_w = GetHResWidth(hres); 82 | gx_res_h = GetVResHeight(vres); 83 | 84 | // Setup initial scissor 85 | GX_SetScissorRect(0, 0, gx_res_w, gx_res_h); 86 | 87 | // Initially we draw in white 88 | GX_SetDrawColor(0xFFFFFF); 89 | 90 | // Clear to black 91 | GX_SetClearColor(0x000000); 92 | 93 | uint8_t i; 94 | for (i = 0; i < GX_MAX_TEXTURES; ++i) 95 | gx_textures[i].occupied = 0; 96 | 97 | gx_active_texture = 0; 98 | } 99 | 100 | //---------------------------------------------------------------------------- 101 | // GX_GetResolution 102 | //---------------------------------------------------------------------------- 103 | void GX_GetResolution(uint16_t *width, uint16_t *height) 104 | { 105 | if (width) *width = gx_res_w; 106 | if (height) *height = gx_res_h; 107 | } 108 | 109 | //---------------------------------------------------------------------------- 110 | // GX_SetClearColor 111 | //---------------------------------------------------------------------------- 112 | void GX_SetClearColor(gx_rgb24 color) 113 | { 114 | gx_clear_color = color; 115 | } 116 | 117 | //---------------------------------------------------------------------------- 118 | // GX_Clear 119 | //---------------------------------------------------------------------------- 120 | void GX_Clear(void) 121 | { 122 | GP0_DO(FillRectVram, gx_clear_color); 123 | GP[0] = GX_XY32(0, 0); 124 | GP[0] = GX_XY32(gx_res_w, gx_res_h); 125 | } 126 | 127 | //---------------------------------------------------------------------------- 128 | // GX_Sync 129 | //---------------------------------------------------------------------------- 130 | void GX_Sync(void) 131 | { 132 | waitVblank(); 133 | GP1_DO(ResetCommandBuffer, 0); 134 | } 135 | 136 | //---------------------------------------------------------------------------- 137 | // GX_SetScissorRect 138 | //---------------------------------------------------------------------------- 139 | void GX_SetScissorRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h) 140 | { 141 | GP0_DO(DrawAreaTopLeft, GX_XY20( x, y )); 142 | GP0_DO(DrawAreaBottomRight, GX_XY20( x+w, y+h )); 143 | GP0NOP; 144 | } 145 | 146 | //---------------------------------------------------------------------------- 147 | // GX_SetPalette 148 | //---------------------------------------------------------------------------- 149 | void GX_SetPalette(uint16_t clut_x, uint8_t clut_y, const uint32_t *palette, uint16_t size) 150 | { 151 | GP0_DO(CopyRectCpuVram, 0); 152 | GP[0] = GX_XY32(clut_x << 4, clut_y); 153 | GP[0] = GX_XY32(size << 1, 1); 154 | // TODO: Replace with efficient DMA transfer 155 | uint16_t i; 156 | for (i = 0; i < size; ++i) 157 | GP[0] = palette[i]; 158 | } 159 | 160 | //---------------------------------------------------------------------------- 161 | // GX_SetImage 162 | //---------------------------------------------------------------------------- 163 | void GX_SetImage( 164 | uint32_t page_x, 165 | uint32_t page_y, 166 | const uint8_t *image, 167 | uint32_t w, 168 | uint32_t h 169 | ) 170 | { 171 | GP0_DO(CopyRectCpuVram, 0); 172 | GP[0] = GX_XY32(0, page_y << 8); 173 | GP[0] = GX_XY32(w >> 1, h); 174 | // TODO: Replace with efficient DMA transfer 175 | for (uint32_t i = 0, s = w * h; i < s; i += 4) 176 | GP[0] = *((uint32_t*)&image[i]); 177 | } 178 | 179 | /* Reads a 32-bit integer from a memory buffer */ 180 | static uint32_t ReadU32(const uint8_t **buf) 181 | { 182 | uint32_t x = *((uint32_t*)*buf); 183 | (*buf) += 4; 184 | return x; 185 | } 186 | 187 | /* TIM flags */ 188 | #define TIM_CF GX_BIT(3) // CLUT flag 189 | 190 | /* Reads a TIM image from RAM to VRAM */ 191 | static int ReadTIM(const uint8_t *in, gx_texture_t *out) 192 | { 193 | const uint8_t *p = in; 194 | 195 | uint32_t id = ReadU32(&p); 196 | if (id != 0x10) 197 | { 198 | printf("Invalid TIM ID! (%d)\n", id); 199 | return 0; 200 | } 201 | 202 | uint32_t flag = ReadU32(&p); 203 | uint8_t mode = flag & GX_BITS(3); 204 | uint8_t hasCLUT = (flag & TIM_CF) ? 1 : 0; 205 | 206 | if (mode != 0x01) 207 | { 208 | printf("Non 8-bit TIMs are not supported at the moment (mode=%d)\n", mode); 209 | return 0; 210 | } 211 | 212 | // Read CLUT 213 | if (hasCLUT) 214 | { 215 | uint32_t *clutOrigin = p; 216 | uint32_t clutSize = ReadU32(&p); // size of the CLUT section 217 | uint32_t offset = ReadU32(&p); // x, y 218 | uint32_t size = ReadU32(&p); // width, height 219 | uint32_t width = (size & GX_BITS(16)) << 1; 220 | uint32_t height = size >> 16; 221 | out->clut_x = 20; 222 | out->clut_y = 0; 223 | GX_SetPalette(out->clut_x, out->clut_y, p, width >> 1); 224 | p = clutOrigin + (clutSize >> 2); 225 | printf("CLUT loaded (%dx%d)\n", width, height); 226 | } 227 | 228 | // Read image 229 | { 230 | ReadU32(&p); // size of the image section 231 | uint32_t offset = ReadU32(&p); // x, y 232 | uint32_t size = ReadU32(&p); // width, height 233 | out->texpage_x = 0; 234 | out->texpage_y = 1; 235 | out->width = (size & GX_BITS(16)) << 1; 236 | out->height = size >> 16; 237 | out->texpage_mode = mode; 238 | GX_SetImage(out->texpage_x, out->texpage_y, p, out->width, out->height); 239 | printf("TIM loaded (%dx%d)\n", out->width, out->height); 240 | } 241 | 242 | return 1; 243 | } 244 | 245 | //---------------------------------------------------------------------------- 246 | // GX_LoadTIM 247 | //---------------------------------------------------------------------------- 248 | struct gx_texture *GX_LoadTIM(const uint8_t *data) 249 | { 250 | int i; 251 | gx_texture_t *tex; 252 | for(i = 0; i < GX_MAX_TEXTURES; ++i) 253 | { 254 | tex = &gx_textures[i]; 255 | if (!tex->occupied) 256 | { 257 | if (ReadTIM(data, tex)) 258 | { 259 | tex->occupied = 1; 260 | return tex; 261 | } 262 | break; 263 | } 264 | } 265 | printf("Texture limit exhaused (limit: %d)\n", GX_MAX_TEXTURES); 266 | return 0; 267 | } 268 | 269 | //---------------------------------------------------------------------------- 270 | // GX_FreeTexture 271 | //---------------------------------------------------------------------------- 272 | void GX_FreeTexture(struct gx_texture *tex) 273 | { 274 | tex->occupied = 0; 275 | } 276 | 277 | //---------------------------------------------------------------------------- 278 | // GX_GetTextureDims 279 | //---------------------------------------------------------------------------- 280 | void GX_GetTextureDims(struct gx_texture *tex, uint16_t *w, uint16_t *h) 281 | { 282 | if (w) *w = tex->width; 283 | if (h) *h = tex->height; 284 | } 285 | 286 | //---------------------------------------------------------------------------- 287 | // GX_SetDrawColor 288 | //---------------------------------------------------------------------------- 289 | void GX_SetDrawColor(gx_rgb24 color) 290 | { 291 | gx_draw_color = color; 292 | } 293 | 294 | //---------------------------------------------------------------------------- 295 | // GX_SelectTexture 296 | //---------------------------------------------------------------------------- 297 | void GX_SelectTexture(struct gx_texture *tex) 298 | { 299 | if (gx_active_texture == tex) return; // Is this any good? 300 | uint32_t drawMode = GX_DRAWMODE_DISPLAY; 301 | drawMode |= (tex->texpage_x << 0); 302 | drawMode |= (tex->texpage_y << 4); 303 | drawMode |= (tex->texpage_mode << 7); 304 | GP0_DO(DrawMode, drawMode); 305 | gx_active_texture = tex; 306 | } 307 | 308 | //---------------------------------------------------------------------------- 309 | // GX_DrawTriangleMonotone 310 | //---------------------------------------------------------------------------- 311 | void GX_DrawTriangleMonotone( 312 | gx_vec2_t v0, 313 | gx_vec2_t v1, 314 | gx_vec2_t v2 315 | ) 316 | { 317 | GP0_DO(FlatTriOpaque, gx_draw_color); 318 | GP[0] = GX_PACK_VEC2(v0); 319 | GP[0] = GX_PACK_VEC2(v1); 320 | GP[0] = GX_PACK_VEC2(v2); 321 | } 322 | 323 | //---------------------------------------------------------------------------- 324 | // GX_DrawQuadMonotone 325 | //---------------------------------------------------------------------------- 326 | void GX_DrawQuadMonotone( 327 | gx_vec2_t v0, 328 | gx_vec2_t v1, 329 | gx_vec2_t v2, 330 | gx_vec2_t v3 331 | ) 332 | { 333 | GP0_DO(FlatQuadOpaque, gx_draw_color); 334 | GP[0] = GX_PACK_VEC2(v0); 335 | GP[0] = GX_PACK_VEC2(v1); 336 | GP[0] = GX_PACK_VEC2(v2); 337 | GP[0] = GX_PACK_VEC2(v3); 338 | } 339 | 340 | //---------------------------------------------------------------------------- 341 | // GX_DrawRectangleMonotone 342 | //---------------------------------------------------------------------------- 343 | void GX_DrawRectangleMonotone( 344 | uint16_t x, 345 | uint16_t y, 346 | uint16_t w, 347 | uint16_t h 348 | ) 349 | { 350 | GP0_DO(FlatRectVarOpaque, gx_draw_color); 351 | GP[0] = GX_XY32(x, y); 352 | GP[0] = GX_XY32(w, h); 353 | } 354 | 355 | //---------------------------------------------------------------------------- 356 | // GX_DrawRectangleTextured 357 | //---------------------------------------------------------------------------- 358 | void GX_DrawRectangleTextured( 359 | uint16_t x, 360 | uint16_t y, 361 | uint16_t w, 362 | uint16_t h, 363 | uint8_t u, 364 | uint8_t v 365 | ) 366 | { 367 | GP0_DO(TexRectVarOpaqueRaw, gx_draw_color); 368 | GP[0] = GX_XY32(x, y); 369 | GP[0] = (GX_CLUT(gx_active_texture->clut_x, gx_active_texture->clut_y) << 16) | GX_XY16(u, v); 370 | GP[0] = GX_XY32(w, h); 371 | } 372 | 373 | 374 | 375 | -------------------------------------------------------------------------------- /libpsx/psx/gx.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | PSX GPU Graphics Wrapper 3 | ***************************************************************************/ 4 | 5 | #ifndef LIBPSX_GX_H 6 | #define LIBPSX_GX_H 7 | 8 | #include 9 | 10 | 11 | /* Utility macros for both private and public use */ 12 | #define GX_BIT(n) (1 << (n)) 13 | #define GX_BITS(n) ((1 << (n)) - 1) 14 | #define GX_BGR(b, g, r) (((r) << 16) | ((g) << 8) | (b)) 15 | #define GX_RGB(r, g, b) (((b) << 16) | ((g) << 8) | (r)) 16 | #define GX_RGB16(r, g, b) (((b) << 10) | ((g) << 5) | (r)) 17 | #define GX_XY16(x, y) (((y) << 8) | (x)) 18 | #define GX_XY20(x, y) (((y) << 10) | (x)) 19 | #define GX_XY24(x, y) (((y) << 12) | (x)) 20 | #define GX_XY32(x, y) (((y) << 16) | (x)) 21 | #define GX_F16(integer, frac) (((frac) << 8) | (integer)) 22 | #define GX_F32(integer, frac) (((frac) << 16) | (integer)) 23 | #define GX_PACK_VEC2(v) GX_XY32((v).x, (v).y) 24 | 25 | 26 | /* Horizontal Display Modes */ 27 | #define GX_HRES_256 DMODE_HRES_256 28 | #define GX_HRES_320 DMODE_HRES_320 29 | #define GX_HRES_512 DMODE_HRES_512 30 | #define GX_HRES_640 DMODE_HRES_640 31 | 32 | /* Vertical Display Modes */ 33 | #define GX_VRES_240 DMODE_VRES_240 34 | #define GX_VRES_480 DMODE_VRES_480 35 | 36 | 37 | /* RGB Colors */ 38 | #define GX_WHITE 0xFFFFFF 39 | #define GX_BLACK 0x000000 40 | #define GX_GRAY 0x7F7F7F 41 | #define GX_RED 0x0000FF 42 | #define GX_GREEN 0x00FF00 43 | #define GX_BLUE 0xFF0000 44 | #define GX_CYAN 0xFFFF00 45 | 46 | 47 | /* Typedefs to serve for easy understanding of parameters */ 48 | typedef uint32_t gx_xy32; // 32-bit x y coordinate (each component is 16 bits) 49 | typedef uint32_t gx_xy20; // 20-bit x y coordinate (each component is 10 bits) 50 | typedef uint16_t gx_f16; // 16-bit fixed-point decimal 51 | typedef uint32_t gx_f32; // 32-bit fixed-point decimal 52 | typedef uint32_t gx_rgb24; // 24-bit RGB color 53 | typedef uint32_t gx_bgr24; // 24-bit BGR color 54 | typedef uint32_t gx_texcoord; // Texture coordinate packed as 32-bit integer 55 | 56 | 57 | /* Represents a fixed-point 2D vector */ 58 | typedef struct 59 | { 60 | gx_f16 x; 61 | gx_f16 y; 62 | } 63 | gx_vec2_t; 64 | 65 | 66 | /* Represents a fixed-point 3D vector */ 67 | typedef struct 68 | { 69 | gx_f16 x; 70 | gx_f16 y; 71 | gx_f16 z; 72 | } 73 | gx_vec3_t; 74 | 75 | 76 | /* Represents a texture in VRAM */ 77 | struct gx_texture; 78 | 79 | 80 | /* Initializes the GPU and the library 81 | * hres corresponds to one of GX_HRES_* 82 | * vres corresponds to one of GX_VRES_* 83 | */ 84 | void GX_Init(uint8_t hres, uint8_t vres); 85 | 86 | 87 | /* Get display resolution */ 88 | void GX_GetResolution(uint16_t *width, uint16_t *height); 89 | 90 | 91 | /* Sets clear color */ 92 | void GX_SetClearColor(gx_rgb24 color); 93 | 94 | 95 | /* Clears the framebuffer */ 96 | void GX_Clear(void); 97 | 98 | 99 | /* Syncs to V-blank */ 100 | void GX_Sync(void); 101 | 102 | 103 | /* Sets area to clip drawing to (optional) */ 104 | void GX_SetScissorRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h); 105 | 106 | 107 | /* Copies a palette to VRAM 108 | * clut_x determines where in VRAM to place the palette horizontally (clut_x * 16 = x offset) 109 | * clut_y determines where in VRAM to place the palette vertically (clut_y = y offset) 110 | * size is how many words are in the palette 111 | */ 112 | void GX_SetPalette(uint16_t clut_x, uint8_t clut_y, const uint32_t *palette, uint16_t size); 113 | 114 | 115 | /* Copies an image to VRAM 116 | * page_x is the horizontal page (page_x * 64 = x offset, 0 to 3) 117 | * page_y is the vertical page (page_y * 256 = y offset, 0 or 1) 118 | * w is the width in half words (how many half words wide) 119 | * h is the height in lines (how many lines tall) 120 | */ 121 | void GX_SetImage( 122 | uint32_t page_x, 123 | uint32_t page_y, 124 | const uint8_t *image, 125 | uint32_t w, 126 | uint32_t h 127 | ); 128 | 129 | 130 | /* Loads a texture from a TIM file in RAM into VRAM */ 131 | struct gx_texture *GX_LoadTIM(const uint8_t *data); 132 | 133 | 134 | /* Frees a texture from VRAM */ 135 | void GX_FreeTexture(struct gx_texture *tex); 136 | 137 | 138 | /* Get texture's dimensions */ 139 | void GX_GetTextureDims(struct gx_texture *tex, uint16_t *w, uint16_t *h); 140 | 141 | 142 | /* Sets the draw color */ 143 | void GX_SetDrawColor(gx_rgb24 color); 144 | 145 | 146 | /* Selects a texture for use in subsequent rendering operations */ 147 | void GX_SelectTexture(struct gx_texture *tex); 148 | 149 | 150 | /* Draws a single color triangle */ 151 | void GX_DrawTriangleMonotone(gx_vec2_t v0, gx_vec2_t v1, gx_vec2_t v2); 152 | 153 | 154 | /* Draws a single color quad 155 | Vertex order: 156 | v0--------------v1 157 | | | 158 | | | 159 | | | 160 | | | 161 | | | 162 | | | 163 | v2--------------v3 164 | 165 | */ 166 | void GX_DrawQuadMonotone(gx_vec2_t v0, gx_vec2_t v1, gx_vec2_t v2, gx_vec2_t v3); 167 | 168 | 169 | /* Draws a single color rectangle (faster than quad) */ 170 | void GX_DrawRectangleMonotone(uint16_t x, uint16_t y, uint16_t w, uint16_t h); 171 | 172 | 173 | /* Draws a textured rectangle (faster than quad) 174 | * u and v are the origin in the texture area 175 | */ 176 | void GX_DrawRectangleTextured( 177 | uint16_t x, 178 | uint16_t y, 179 | uint16_t w, 180 | uint16_t h, 181 | uint8_t u, 182 | uint8_t v 183 | ); 184 | 185 | 186 | #endif 187 | -------------------------------------------------------------------------------- /libpsx/psx/interrupts.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // todo determine cop0r12[8:15] exception field 6 | void initIrq(uint16_t mask) { 7 | IRQ_MASK = mask; 8 | } 9 | 10 | void enableIrq(uint16_t mask) { 11 | IRQ_MASK |= mask; 12 | } 13 | 14 | void waitVblank(void) { 15 | while(!(IRQ_STAT & IrqVblank)); 16 | IRQ_STAT = ~IrqVblank; 17 | /*unsigned cop0_sr_flag = 1<<8;*/ 18 | /*__asm__ __volatile__ (*/ 19 | /*"mtc0 %[t], $12\n\t"*/ 20 | /*::[t] "r" (cop0_sr_flag)*/ 21 | /*:);*/ 22 | } 23 | 24 | -------------------------------------------------------------------------------- /libpsx/psx/interrupts.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_INTERRUPTS_H 3 | #define LIBPSX_INTERRUPTS_H 4 | 5 | #include 6 | 7 | // IRQ_STAT and IRQ_MASK flags 8 | #define IrqVblank 0x001 9 | #define IrqGpu 0x002 10 | #define IrqCdrom 0x004 11 | #define IrqDma 0x008 12 | #define IrqTimer0 0x010 13 | #define IrqTimer1 0x020 14 | #define IrqTimer2 0x040 15 | #define IrqMemcard 0x080 16 | #define IrqSio 0x100 17 | #define IrqSpu 0x200 18 | #define IrqPio 0x400 19 | 20 | void initIrq(uint16_t); 21 | 22 | void waitVblank(void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libpsx/psx/io.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBPSX_IO_H 3 | #define LIBPSX_IO_H 4 | 5 | #ifndef __LANGUAGE_ASSEMBLY 6 | # define IO_8(x) (*(volatile unsigned char *)(x)) 7 | # define IO_16(x) (*(volatile unsigned short *)(x)) 8 | # define IO_32(x) (*(volatile unsigned int *)(x)) 9 | # define IO_S8(x) (*(volatile char *)(x)) 10 | # define IO_S16(x) (*(volatile short *)(x)) 11 | # define IO_S32(x) (*(volatile int *)(x)) 12 | #else 13 | # define IO_8(x) (x) 14 | # define IO_16(x) (x) 15 | # define IO_32(x) (x) 16 | # define IO_S8(x) (x) 17 | # define IO_S16(x) (x) 18 | # define IO_S32(x) (x) 19 | #endif 20 | 21 | #define IO_BASE 0x1F801000 // Various io 22 | #define IO_BASE_EXP2 0x1F802000 // Expansion region 2 23 | 24 | // Memory Control 1 25 | // probably don't need to touch these 26 | // 0x1F801000 4 Expansion 1 Base Address (usually 1F000000h) 27 | // 0x1F801004 4 Expansion 2 Base Address (usually 1F802000h) 28 | // 0x1F801008 4 Expansion 1 Delay/Size (usually 0013243Fh; 512Kbytes 8bit-bus) 29 | // 0x1F80100C 4 Expansion 3 Delay/Size (usually 00003022h; 1 byte) 30 | // 0x1F801010 4 BIOS ROM Delay/Size (usually 0013243Fh; 512Kbytes 8bit-bus) 31 | // 0x1F801014 4 SPU_DELAY Delay/Size (usually 200931E1h) 32 | // 0x1F801018 4 CDROM_DELAY Delay/Size (usually 00020843h or 00020943h) 33 | // 0x1F80101C 4 Expansion 2 Delay/Size (usually 00070777h; 128-bytes 8bit-bus) 34 | // 0x1F801020 4 COM_DELAY / COMMON_DELAY (00031125h or 0000132Ch or 00001325h) 35 | 36 | // Peripheral I/O Ports 37 | #define JOY_DATA IO_32(0x1F801040) // 1/4 Joypad/Memory Card Data (R/W) 38 | #define JOY_STAT IO_32(0x1F801044) // 4 Joypad/Memory Card Status (R) 39 | #define JOY_MODE IO_16(0x1F801048) // 2 Joypad/Memory Card Mode (R/W) 40 | #define JOY_CTRL IO_16(0x1F80104A) // 2 Joypad/Memory Card Control (R/W) 41 | #define JOY_BAUD IO_16(0x1F80104E) // 2 Joypad/Memory Card Baudrate (R/W) 42 | #define SIO_DATA IO_32(0x1F801050) // 1/4 Serial Port Data (R/W) 43 | #define SIO_STAT IO_32(0x1F801054) // 4 Serial Port Status (R) 44 | #define SIO_MODE IO_16(0x1F801058) // 2 Serial Port Mode (R/W) 45 | #define SIO_CTRL IO_16(0x1F80105A) // 2 Serial Port Control (R/W) 46 | #define SIO_MISC IO_16(0x1F80105C) // 2 Serial Port Internal Register (R/W) 47 | #define SIO_BAUD IO_16(0x1F80105E) // 2 Serial Port Baudrate (R/W) 48 | // Memory Control 2 49 | #define RAM_SIZE IO_32(0x1F801060) // 4/2 (usually 00000B88h; 2MB RAM mirrored in first 8MB) 50 | // Interrupt Control 51 | #define IRQ_STAT IO_16(0x1F801070) // 2 Interrupt status register 52 | #define IRQ_MASK IO_16(0x1F801074) // 2 Interrupt mask register 53 | 54 | #define DMA_MADR(ch) IO_32(0x1F801080 + (ch * 0x10)) 55 | #define DMA_BCR(ch) IO_32(0x1F801084 + (ch * 0x10)) 56 | #define DMA_CHCR(ch) IO_32(0x1F801088 + (ch * 0x10)) 57 | 58 | #define DMA_DPCR IO_32(0x1F8010F0) // 4 DMA contrl register 59 | #define DMA_DICR IO_32(0x1F8010F4) // 4 DMA interrupt register 60 | 61 | /* 62 | // DMA Registers 63 | 0x1F80108x DMA0 channel 0 - MDECin 64 | 0x1F80109x DMA1 channel 1 - MDECout 65 | 0x1F8010Ax DMA2 channel 2 - GPU (lists + image data) 66 | 0x1F8010Bx DMA3 channel 3 - CDROM 67 | 0x1F8010Cx DMA4 channel 4 - SPU 68 | 0x1F8010Dx DMA5 channel 5 - PIO (Expansion Port) 69 | 0x1F8010Ex DMA6 channel 6 - OTC (reverse clear OT) (GPU related) 70 | // Timers (aka Root counters) 71 | 0x1F80110x Timer 0 Dotclock 72 | 0x1F80111x Timer 1 Horizontal Retrace 73 | 0x1F80112x Timer 2 1/8 system clock 74 | // CDROM Registers (Address.Read/Write.Index) 75 | 0x1F801800.x.x 1 CD Index/Status Register (Bit0-1 R/W, Bit2-7 Read Only) 76 | 0x1F801801.R.x 1 CD Response Fifo (R) (usually with Index1) 77 | 0x1F801802.R.x 1/2 CD Data Fifo - 8bit/16bit (R) (usually with Index0..1) 78 | 0x1F801803.R.0 1 CD Interrupt Enable Register (R) 79 | 0x1F801803.R.1 1 CD Interrupt Flag Register (R/W) 80 | 0x1F801803.R.2 1 CD Interrupt Enable Register (R) (Mirror) 81 | 0x1F801803.R.3 1 CD Interrupt Flag Register (R/W) (Mirror) 82 | 0x1F801801.W.0 1 CD Command Register (W) 83 | 0x1F801802.W.0 1 CD Parameter Fifo (W) 84 | 0x1F801803.W.0 1 CD Request Register (W) 85 | 0x1F801801.W.1 1 Unknown/unused 86 | 0x1F801802.W.1 1 CD Interrupt Enable Register (W) 87 | 0x1F801803.W.1 1 CD Interrupt Flag Register (R/W) 88 | 0x1F801801.W.2 1 Unknown/unused 89 | 0x1F801802.W.2 1 CD Audio Volume for Left-CD-Out to Left-SPU-Input (W) 90 | 0x1F801803.W.2 1 CD Audio Volume for Left-CD-Out to Right-SPU-Input (W) 91 | 0x1F801801.W.3 1 CD Audio Volume for Right-CD-Out to Right-SPU-Input (W) 92 | 0x1F801802.W.3 1 CD Audio Volume for Right-CD-Out to Left-SPU-Input (W) 93 | 0x1F801803.W.3 1 CD Audio Volume Apply Changes (by writing bit5=1) 94 | */ 95 | #define GP0 IO_32(0x1F801810) 96 | // Write 4 GP0 Send GP0 Commands/Packets (Rendering and VRAM Access) 97 | // Read 4 GPUREAD Read responses to GP0(C0h) and GP1(10h) commands 98 | #define GP1 IO_32(0x1F801814) 99 | // Write 4 GP1 Send GP1 Commands (Display Control) 100 | // Read 4 GPUSTAT Read GPU Status Register 101 | 102 | /* 103 | MDEC Registers 104 | 0x1F801820.Write 4 MDEC Command/Parameter Register (W) 105 | 0x1F801820.Read 4 MDEC Data/Response Register (R) 106 | 0x1F801824.Write 4 MDEC Control/Reset Register (W) 107 | 0x1F801824.Read 4 MDEC Status Register (R) 108 | SPU Voice 0..23 Registers 109 | 0x1F801C00+N*10h 4 Voice 0..23 Volume Left/Right 110 | 0x1F801C04+N*10h 2 Voice 0..23 ADPCM Sample Rate 111 | 0x1F801C06+N*10h 2 Voice 0..23 ADPCM Start Address 112 | 0x1F801C08+N*10h 4 Voice 0..23 ADSR Attack/Decay/Sustain/Release 113 | 0x1F801C0C+N*10h 2 Voice 0..23 ADSR Current Volume 114 | 0x1F801C0E+N*10h 2 Voice 0..23 ADPCM Repeat Address 115 | SPU Control Registers 116 | 0x1F801D80 4 Main Volume Left/Right 117 | 0x1F801D84 4 Reverb Output Volume Left/Right 118 | 0x1F801D88 4 Voice 0..23 Key ON (Start Attack/Decay/Sustain) (W) 119 | 0x1F801D8C 4 Voice 0..23 Key OFF (Start Release) (W) 120 | 0x1F801D90 4 Voice 0..23 Channel FM (pitch lfo) mode (R/W) 121 | 0x1F801D94 4 Voice 0..23 Channel Noise mode (R/W) 122 | 0x1F801D98 4 Voice 0..23 Channel Reverb mode (R/W) 123 | 0x1F801D9C 4 Voice 0..23 Channel ON/OFF (status) (R) 124 | 0x1F801DA0 2 Unknown? (R) or (W) 125 | 0x1F801DA2 2 Sound RAM Reverb Work Area Start Address 126 | 0x1F801DA4 2 Sound RAM IRQ Address 127 | 0x1F801DA6 2 Sound RAM Data Transfer Address 128 | 0x1F801DA8 2 Sound RAM Data Transfer Fifo 129 | 0x1F801DAA 2 SPU Control Register (SPUCNT) 130 | 0x1F801DAC 2 Sound RAM Data Transfer Control 131 | 0x1F801DAE 2 SPU Status Register (SPUSTAT) (R) 132 | 0x1F801DB0 4 CD Volume Left/Right 133 | 0x1F801DB4 4 Extern Volume Left/Right 134 | 0x1F801DB8 4 Current Main Volume Left/Right 135 | 0x1F801DBC 4 Unknown? (R/W) 136 | SPU Reverb Configuration Area 137 | 0x1F801DC0 2 dAPF1 Reverb APF Offset 1 138 | 0x1F801DC2 2 dAPF2 Reverb APF Offset 2 139 | 0x1F801DC4 2 vIIR Reverb Reflection Volume 1 140 | 0x1F801DC6 2 vCOMB1 Reverb Comb Volume 1 141 | 0x1F801DC8 2 vCOMB2 Reverb Comb Volume 2 142 | 0x1F801DCA 2 vCOMB3 Reverb Comb Volume 3 143 | 0x1F801DCC 2 vCOMB4 Reverb Comb Volume 4 144 | 0x1F801DCE 2 vWALL Reverb Reflection Volume 2 145 | 0x1F801DD0 2 vAPF1 Reverb APF Volume 1 146 | 0x1F801DD2 2 vAPF2 Reverb APF Volume 2 147 | 0x1F801DD4 4 mSAME Reverb Same Side Reflection Address 1 Left/Right 148 | 0x1F801DD8 4 mCOMB1 Reverb Comb Address 1 Left/Right 149 | 0x1F801DDC 4 mCOMB2 Reverb Comb Address 2 Left/Right 150 | 0x1F801DE0 4 dSAME Reverb Same Side Reflection Address 2 Left/Right 151 | 0x1F801DE4 4 mDIFF Reverb Different Side Reflection Address 1 Left/Right 152 | 0x1F801DE8 4 mCOMB3 Reverb Comb Address 3 Left/Right 153 | 0x1F801DEC 4 mCOMB4 Reverb Comb Address 4 Left/Right 154 | 0x1F801DF0 4 dDIFF Reverb Different Side Reflection Address 2 Left/Right 155 | 0x1F801DF4 4 mAPF1 Reverb APF Address 1 Left/Right 156 | 0x1F801DF8 4 mAPF2 Reverb APF Address 2 Left/Right 157 | 0x1F801DFC 4 vIN Reverb Input Volume Left/Right 158 | SPU Internal Registers 159 | 0x1F801E00+N*04h 4 Voice 0..23 Current Volume Left/Right 160 | 0x1F801E60 20h Unknown? (R/W) 161 | 0x1F801E80 180h Unknown? (Read: FFh-filled) (Unused or Write only?) 162 | Expansion Region 2 (default 128 bytes, max 8 KBytes) 163 | 0x1F802000 80h Expansion Region (8bit data bus, crashes on 16bit access?) 164 | Expansion Region 2 - Dual Serial Port (for TTY Debug Terminal) 165 | 0x1F802020/1st DUART Mode Register 1.A (R/W) 166 | 0x1F802020/2nd DUART Mode Register 2.A (R/W) 167 | 0x1F802021/Read DUART Status Register A (R) 168 | 0x1F802021/Write DUART Clock Select Register A (W) 169 | 0x1F802022/Read DUART Toggle Baud Rate Generator Test Mode (Read=Strobe) 170 | 0x1F802022/Write DUART Command Register A (W) 171 | 0x1F802023/Read DUART Rx Holding Register A (FIFO) (R) 172 | 0x1F802023/Write DUART Tx Holding Register A (W) 173 | 0x1F802024/Read DUART Input Port Change Register (R) 174 | 0x1F802024/Write DUART Aux. Control Register (W) 175 | 0x1F802025/Read DUART Interrupt Status Register (R) 176 | 0x1F802025/Write DUART Interrupt Mask Register (W) 177 | 0x1F802026/Read DUART Counter/Timer Current Value, Upper/Bit15-8 (R) 178 | 0x1F802026/Write DUART Counter/Timer Reload Value, Upper/Bit15-8 (W) 179 | 0x1F802027/Read DUART Counter/Timer Current Value, Lower/Bit7-0 (R) 180 | 0x1F802027/Write DUART Counter/Timer Reload Value, Lower/Bit7-0 (W) 181 | 0x1F802028/1st DUART Mode Register 1.B (R/W) 182 | 0x1F802028/2nd DUART Mode Register 2.B (R/W) 183 | 0x1F802029/Read DUART Status Register B (R) 184 | 0x1F802029/Write DUART Clock Select Register B (W) 185 | 0x1F80202A/Read DUART Toggle 1X/16X Test Mode (Read=Strobe) 186 | 0x1F80202A/Write DUART Command Register B (W) 187 | 0x1F80202B/Read DUART Rx Holding Register B (FIFO) (R) 188 | 0x1F80202B/Write DUART Tx Holding Register B (W) 189 | 0x1F80202C/None DUART Reserved Register (neither R nor W) 190 | 0x1F80202D/Read DUART Input Port (R) 191 | 0x1F80202D/Write DUART Output Port Configuration Register (W) 192 | 0x1F80202E/Read DUART Start Counter Command (Read=Strobe) 193 | 0x1F80202E/Write DUART Set Output Port Bits Command (Set means Out=LOW) 194 | 0x1F80202F/Read DUART Stop Counter Command (Read=Strobe) 195 | 0x1F80202F/Write DUART Reset Output Port Bits Command (Reset means Out=HIGH) 196 | Expansion Region 2 - Int/Dip/Post 197 | 0x1F802000 1 DTL-H2000: ATCONS STAT (R) 198 | 0x1F802002 1 DTL-H2000: ATCONS DATA (R and W) 199 | 0x1F802004 2 DTL-H2000: Whatever 16bit data ? 200 | 0x1F802030 1/4 DTL-H2000: Secondary IRQ10 Flags 201 | 0x1F802032 1 DTL-H2000: Whatever IRQ Control ? 202 | 0x1F802040 1 DTL-H2000: Bootmode "Dip switches" (R) 203 | 0x1F802041 1 PSX: POST (external 7 segment display, indicate BIOS boot status) 204 | 0x1F802042 1 DTL-H2000: POST/LED (similar to POST) (other addr, 2-digit wide) 205 | 0x1F802070 1 PS2: POST2 (similar to POST, but PS2 BIOS uses this address) 206 | Expansion Region 2 - Nocash Emulation Expansion 207 | 0x1F802060 Emu-Expansion ID1 "E" (R) 208 | 0x1F802061 Emu-Expansion ID2 "X" (R) 209 | 0x1F802062 Emu-Expansion ID3 "P" (R) 210 | 0x1F802063 Emu-Expansion Version (01h) (R) 211 | 0x1F802064 Emu-Expansion Enable1 "O" (R/W) 212 | 0x1F802065 Emu-Expansion Enable2 "N" (R/W) 213 | 0x1F802066 Emu-Expansion Halt (R) 214 | 0x1F802067 Emu-Expansion Turbo Mode Flags (R/W) 215 | 216 | Expansion Region 3 (default 1 byte, max 2 MBytes) 217 | 0x1FA00000 - Not used by BIOS or any PSX games 218 | 0x1FA00000 - POST3 (similar to POST, but PS2 BIOS uses this address) 219 | BIOS Region (default 512 Kbytes, max 4 MBytes) 220 | 0x1FC00000 0x80000 BIOS ROM (512Kbytes) (Reset Entrypoint at BFC00000h) 221 | 222 | Coprocessor Registers 223 | COP0 System Control Coprocessor - 32 registers (not all used) 224 | COP1 N/A 225 | COP2 Geometry Transformation Engine (GTE) - 64 registers (most are used) 226 | COP3 N/A 227 | */ 228 | 229 | // Memory Control 3 (Cache Control) 230 | #define CACHE_CTRL 0xFFFE0130 // Cache control io 231 | 232 | #endif 233 | 234 | -------------------------------------------------------------------------------- /libpsx/tools/bin2exe.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import os 4 | import sys 5 | import struct 6 | import math 7 | 8 | usage = ''' 9 | python bin2exe.py infile outfile 10 | ''' 11 | 12 | def main(argv): 13 | if len(argv) != 2: 14 | print(usage, file=sys.stderr) 15 | sys.exit(1) 16 | 17 | max_size = 0x200000 18 | infile_size = os.path.getsize(argv[0]) 19 | if infile_size > max_size: 20 | print("Error: Input file %s longer than %d bytes" % (argv[0], max_size), file=sys.stderr) 21 | sys.exit(1) 22 | 23 | ofile = open(argv[1], 'wb') 24 | 25 | with open(argv[0], 'rb') as ifile: 26 | # Write header 27 | if sys.version_info >= (3, 0): 28 | ofile.write(bytes('PS-X EXE', 'ascii')) 29 | else: 30 | ofile.write('PS-X EXE') 31 | # Entry point 32 | ofile.seek(0x10) 33 | ofile.write(struct.pack(' 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int foo[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; 8 | char *bar = "HELLO WORLD!!!!!"; 9 | static char *aaa = "Your face has healed nicely"; 10 | static long long int slli = 5ULL; 11 | static short ss; 12 | static int many[100]; 13 | const int ci = 0xcacebeef; 14 | 15 | int lolgcc[] = {[0 ... 9] = 1, [10 ... 99] = 2, [100] = 3}; 16 | char mucha[] = {[0 ... 10] = 'a', 0}; 17 | 18 | extern void sectionTest(void); 19 | 20 | struct myStruct_s { 21 | int first; 22 | char second; 23 | char third; 24 | char *fourth; 25 | long long fifth; 26 | char sixth; 27 | }; 28 | 29 | int main(int argc, char *argv[]) 30 | { 31 | static char *laz = "don't raise your voice in public"; 32 | static short lss; 33 | char *baz = "pigs\non\rthe wing "; 34 | const int lci = 0xbeefcace; 35 | 36 | int a = sizeof(int8_t); 37 | int b = sizeof(uint32_t); 38 | int b2 = sizeof(size_t); 39 | int c = sizeof(int64_t); 40 | int c2 = sizeof(long) == sizeof(int); 41 | 42 | int d = INT_MAX; 43 | bool cool = sizeof(int32_t) != sizeof(int64_t); 44 | long long e = LLONG_MAX; 45 | struct myStruct_s mys = {.first=42, .sixth='a', .second='2', .fourth=baz}; 46 | size_t f = offsetof(struct myStruct_s, second); 47 | size_t g = offsetof(struct myStruct_s, third); 48 | size_t h = offsetof(struct myStruct_s, fourth); 49 | 50 | printf("%s\n%s\n%s\n%s\n%s\n%d %x", bar, aaa, laz, baz, mucha, mys.first, mys.sixth); 51 | 52 | printf("\n%d %d %d", a, b, b2); 53 | printf("\n%x %X %U %X", c, baz[2], baz[2], baz[3]); 54 | 55 | while(1){ 56 | 57 | } 58 | return 0x42; 59 | } 60 | -------------------------------------------------------------------------------- /test/makefile: -------------------------------------------------------------------------------- 1 | include ../base.mk 2 | 3 | libpsx := ../libpsx 4 | 5 | target := $(shell basename $(CURDIR)) 6 | output := $(target) 7 | build := build 8 | sources := . $(libpsx)/libc $(libpsx)/psx 9 | incdirs := . $(libpsx) $(libpsx)/include $(build) 10 | includes:= $(foreach dir,$(incdirs),-I$(dir)) 11 | 12 | arch := -march=r3000 -mabi=32 -EL -msoft-float -Wa,-msoft-float 13 | asflags := -g $(arch) 14 | cflags := -g -std=c99 -Wall -Wextra -Wpadded -pedantic -mgpopt -mno-extern-sdata -pipe $(arch) 15 | ldflags := $(cflags) -Wl,-Map=$(target).map -nostdlib -T$(libpsx)/psx-exe.ld 16 | 17 | sfiles := $(foreach dir,$(sources),$(notdir $(wildcard $(dir)/*.S))) 18 | cfiles := $(foreach dir,$(sources),$(notdir $(wildcard $(dir)/*.c))) 19 | 20 | ofiles := $(cfiles:%.c=$(build)/%.o) $(sfiles:%.S=$(build)/%.o) 21 | depfiles:= $(ofiles:.o=.d) 22 | 23 | VPATH := $(foreach dir,$(sources),$(CURDIR)/$(dir)) 24 | 25 | .PHONY: all clean debug release run 26 | 27 | all: release 28 | 29 | debug: asflags += -DDEBUG 30 | debug: cflags += -O0 -DDEBUG 31 | debug: ldflags += 32 | debug: $(output).exe 33 | 34 | release: asflags += 35 | release: cflags += -Os -flto -ffat-lto-objects 36 | release: ldflags += -flto -ffat-lto-objects 37 | release: $(output).exe 38 | 39 | $(output).exe : $(output).bin 40 | 41 | $(output).bin : $(output).elf 42 | 43 | $(output).elf : $(build) $(ofiles) 44 | 45 | $(build): 46 | @mkdir -p $@ 47 | 48 | clean: 49 | rm -rf $(output).exe $(output).bin $(output).elf $(output).map $(build) 50 | 51 | run: 52 | $(nopsx) $(output).exe 53 | 54 | dump: 55 | $(OBJDUMP) -b binary -mmips:3000 -EL -D $(output).bin 56 | 57 | -include $(depfiles) 58 | 59 | -------------------------------------------------------------------------------- /test/test.S: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | .align 2 4 | .global sectionTest 5 | sectionTest: 6 | .set noat; .set noreorder 7 | la $1, car 8 | la $2, baz 9 | lw $3,0($1) 10 | lw $4,0($2) 11 | j sectionTest 12 | nop 13 | 14 | .data 15 | .align 2 16 | foo: 17 | .byte 0xfeedbacc 18 | .byte 0xfeedbacc>>8 19 | .word 0xfeedbacc 20 | .int 0xabad1dea 21 | 22 | .rdata 23 | .align 2 24 | bar: 25 | .hword 0xfeed 26 | .hword 0xbacc 27 | .hword -1 28 | 29 | .bss 30 | .align 2 31 | car: 32 | .word -1 33 | .word 55 34 | 35 | .section .sbss,"aw",@nobits 36 | .align 3 37 | baz: 38 | .dword 0xfeedbacccafe 39 | 40 | // vim:ft=mips 41 | -------------------------------------------------------------------------------- /test_gx/makefile: -------------------------------------------------------------------------------- 1 | include ../base.mk 2 | 3 | libpsx := ../libpsx 4 | 5 | target := $(shell basename $(CURDIR)) 6 | output := $(target) 7 | build := build 8 | sources := src $(libpsx)/libc $(libpsx)/psx 9 | incdirs := src $(libpsx) $(libpsx)/include $(build) 10 | includes:= $(foreach dir,$(incdirs),-I$(dir)) 11 | 12 | arch := -march=r3000 -mabi=32 -EL -msoft-float -Wa,-msoft-float 13 | asflags := -g $(arch) 14 | cflags := -g -std=c99 -Wall -Wextra -pedantic -mgpopt -mno-extern-sdata -pipe $(arch) 15 | ldflags := $(cflags) -Wl,-Map=$(target).map -nostdlib -T$(libpsx)/psx-exe.ld 16 | 17 | sfiles := $(foreach dir,$(sources),$(notdir $(wildcard $(dir)/*.S))) 18 | cfiles := $(foreach dir,$(sources),$(notdir $(wildcard $(dir)/*.c))) 19 | 20 | ofiles := $(cfiles:%.c=$(build)/%.o) $(sfiles:%.S=$(build)/%.o) 21 | depfiles:= $(ofiles:.o=.d) 22 | 23 | VPATH := $(foreach dir,$(sources),$(CURDIR)/$(dir)) 24 | 25 | .PHONY: all clean debug release run 26 | 27 | all: release 28 | 29 | debug: asflags += -DDEBUG 30 | debug: cflags += -O2 -DDEBUG 31 | debug: ldflags += 32 | debug: $(output).exe 33 | 34 | release: asflags += 35 | release: cflags += -O2 -flto -ffat-lto-objects 36 | release: ldflags += -flto -ffat-lto-objects 37 | release: $(output).exe 38 | 39 | $(output).exe : $(output).bin 40 | 41 | $(output).bin : $(output).elf 42 | 43 | $(output).elf : $(build) $(ofiles) 44 | 45 | $(build): 46 | @mkdir -p $@ 47 | 48 | clean: 49 | rm -rf $(output).exe $(output).bin $(output).elf $(output).map $(build) 50 | 51 | run: 52 | $(nopsx) $(output).exe 53 | 54 | dump: 55 | $(OBJDUMP) -b binary -mmips:3000 -EL -D $(output).bin 56 | 57 | -include $(depfiles) 58 | 59 | -------------------------------------------------------------------------------- /test_gx/res/kid.tim.c: -------------------------------------------------------------------------------- 1 | const unsigned char kid_tim[] = { 2 | 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 3 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x80, 4 | 0x22, 0x04, 0xa3, 0x1c, 0xc2, 0x1c, 0xc3, 0x1c, 0x84, 0x0c, 0xa4, 5 | 0x14, 0x85, 0x10, 0xa5, 0x10, 0xa5, 0x14, 0xa4, 0x18, 0xc5, 0x14, 6 | 0xc5, 0x18, 0xe5, 0x18, 0xa7, 0x10, 0xa7, 0x18, 0xc7, 0x14, 0xe7, 7 | 0x14, 0xc6, 0x18, 0xc6, 0x1c, 0xe6, 0x18, 0xe6, 0x1c, 0xe7, 0x18, 8 | 0xe7, 0x1c, 0xc2, 0x20, 0xc3, 0x20, 0xa4, 0x20, 0xc4, 0x20, 0xc4, 9 | 0x24, 0xe4, 0x24, 0xe5, 0x24, 0xe5, 0x28, 0xa7, 0x28, 0xe6, 0x20, 10 | 0x05, 0x19, 0x06, 0x1d, 0x04, 0x25, 0x05, 0x29, 0x05, 0x2d, 0x25, 11 | 0x2d, 0x45, 0x2d, 0x06, 0x25, 0x07, 0x21, 0x26, 0x2d, 0x47, 0x25, 12 | 0x45, 0x31, 0x26, 0x31, 0x47, 0x35, 0x67, 0x39, 0x87, 0x29, 0x87, 13 | 0x39, 0xa8, 0x1c, 0xe8, 0x18, 0xe9, 0x18, 0xe9, 0x1c, 0xa8, 0x20, 14 | 0xa8, 0x2c, 0xc8, 0x20, 0xab, 0x28, 0xca, 0x24, 0xca, 0x28, 0xa9, 15 | 0x30, 0xaa, 0x30, 0x8b, 0x34, 0xac, 0x2c, 0xad, 0x2c, 0xcc, 0x28, 16 | 0xae, 0x2c, 0xee, 0x2c, 0xad, 0x30, 0x8c, 0x38, 0xad, 0x3c, 0xae, 17 | 0x30, 0xae, 0x34, 0xaf, 0x30, 0x8f, 0x38, 0xcf, 0x30, 0xef, 0x30, 18 | 0x08, 0x19, 0x08, 0x1d, 0x09, 0x19, 0x09, 0x1d, 0x29, 0x1d, 0x0a, 19 | 0x1d, 0x2a, 0x1d, 0x4a, 0x1d, 0x2d, 0x1d, 0x08, 0x21, 0x28, 0x21, 20 | 0x28, 0x25, 0x29, 0x21, 0x29, 0x25, 0x28, 0x2d, 0x68, 0x2d, 0x0a, 21 | 0x21, 0x2a, 0x21, 0x2b, 0x21, 0x4a, 0x21, 0x6a, 0x21, 0x4b, 0x21, 22 | 0x4b, 0x25, 0x6b, 0x21, 0x6b, 0x25, 0x4a, 0x29, 0x6a, 0x29, 0x6b, 23 | 0x2d, 0x68, 0x31, 0x4a, 0x31, 0x89, 0x31, 0x88, 0x3d, 0xc9, 0x35, 24 | 0xaa, 0x35, 0xab, 0x39, 0xca, 0x35, 0xcb, 0x39, 0x2c, 0x21, 0x4c, 25 | 0x25, 0x6c, 0x25, 0x4d, 0x25, 0x6d, 0x29, 0x6e, 0x25, 0x6e, 0x2d, 26 | 0x6f, 0x29, 0x8e, 0x2d, 0x8c, 0x31, 0xac, 0x39, 0xcc, 0x3d, 0xae, 27 | 0x40, 0x4f, 0x41, 0xed, 0x41, 0xaf, 0x49, 0xef, 0x41, 0x2b, 0x3e, 28 | 0x0d, 0x42, 0x2e, 0x46, 0x0f, 0x42, 0x0f, 0x46, 0x2e, 0x4a, 0x4e, 29 | 0x46, 0x4e, 0x4a, 0xd0, 0x34, 0xd1, 0x38, 0xf1, 0x38, 0xf2, 0x3c, 30 | 0x10, 0x35, 0x11, 0x39, 0x90, 0x29, 0xb0, 0x2d, 0xb1, 0x2d, 0xb2, 31 | 0x29, 0xb2, 0x2d, 0xb3, 0x2d, 0xd3, 0x2d, 0xd3, 0x31, 0xf2, 0x3d, 32 | 0xf3, 0x39, 0xd4, 0x31, 0xd5, 0x31, 0xf5, 0x31, 0xf8, 0x31, 0x73, 33 | 0x44, 0xd3, 0x40, 0x74, 0x44, 0x75, 0x48, 0x56, 0x4c, 0x37, 0x50, 34 | 0x57, 0x50, 0xd4, 0x44, 0xb0, 0x49, 0xd0, 0x49, 0xd7, 0x59, 0x5a, 35 | 0x58, 0x79, 0x60, 0x5a, 0x60, 0x1d, 0x64, 0x3e, 0x6c, 0x1f, 0x6c, 36 | 0x5f, 0x6c, 0x1f, 0x70, 0x1f, 0x74, 0xdc, 0x51, 0xdc, 0x55, 0xfc, 37 | 0x55, 0xfd, 0x55, 0xdd, 0x59, 0x13, 0x3e, 0x14, 0x3e, 0x15, 0x3a, 38 | 0x15, 0x3e, 0x35, 0x3e, 0x36, 0x3e, 0x18, 0x36, 0x19, 0x36, 0x39, 39 | 0x36, 0x39, 0x3a, 0x59, 0x3e, 0x3a, 0x36, 0x3a, 0x3a, 0x5a, 0x3a, 40 | 0x5a, 0x3e, 0x51, 0x4a, 0x72, 0x4e, 0x93, 0x52, 0x34, 0x42, 0x54, 41 | 0x42, 0x36, 0x42, 0x56, 0x42, 0x56, 0x46, 0x57, 0x42, 0x76, 0x4a, 42 | 0x75, 0x56, 0x77, 0x5a, 0x95, 0x56, 0xd4, 0x52, 0xd7, 0x5a, 0x17, 43 | 0x63, 0x78, 0x4a, 0x5a, 0x42, 0x7a, 0x42, 0x7a, 0x46, 0x7b, 0x42, 44 | 0x7b, 0x46, 0x98, 0x4e, 0x9b, 0x46, 0x9b, 0x4a, 0xbb, 0x4e, 0xdb, 45 | 0x4a, 0xf8, 0x5a, 0xda, 0x56, 0x9c, 0x46, 0xbc, 0x4e, 0xdc, 0x4e, 46 | 0xdc, 0x52, 0xdc, 0x56, 0xfd, 0x5a, 0xfe, 0x52, 0xfe, 0x56, 0x1d, 47 | 0x5b, 0x1e, 0x5f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0xb0, 351 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 352 | 0xb0, 0xb0, 0x5d, 0x70, 0x5d, 0xd4, 0xd4, 0xd4, 0xf5, 0xfc, 0xf5, 353 | 0xd6, 0x2b, 0x13, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 354 | 0x67, 0x67, 0x5b, 0x5b, 0x4f, 0x2a, 0x5b, 0x2a, 0x39, 0x5b, 0x5b, 355 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x61, 0x5d, 0x58, 0x45, 0xb2, 0xb0, 356 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 357 | 0xb0, 0xb0, 0xb0, 0xb0, 0x5d, 0x85, 0x85, 0x85, 0x70, 0x5d, 0xc9, 358 | 0xd4, 0xf5, 0xd4, 0xd6, 0x5a, 0x39, 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 359 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x5b, 0x57, 0x4f, 0x5b, 0x57, 360 | 0x23, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x5c, 0x61, 0x67, 361 | 0x58, 0x40, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 362 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0x5d, 0x70, 0x85, 0x89, 0x89, 363 | 0x85, 0x85, 0x70, 0x5d, 0xc9, 0xd5, 0xb1, 0x40, 0x58, 0x5b, 0x5b, 364 | 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x5b, 0x5b, 0x57, 365 | 0x2a, 0x57, 0x57, 0x39, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 366 | 0x67, 0x67, 0x67, 0x58, 0x40, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 367 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0x5d, 0x6f, 368 | 0x6f, 0x85, 0x85, 0x8b, 0x8b, 0x8b, 0x85, 0x84, 0xaf, 0x3a, 0x57, 369 | 0x57, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 370 | 0x67, 0x5b, 0x5b, 0x57, 0x16, 0x2a, 0x58, 0x5b, 0x5b, 0x5b, 0x5b, 371 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x5b, 0x3c, 0xb2, 0xb0, 372 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 373 | 0xb0, 0x5d, 0x70, 0x85, 0x89, 0x89, 0x8b, 0x8b, 0x8b, 0x89, 0x8b, 374 | 0x85, 0x58, 0x57, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 375 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x5b, 0x5b, 0x21, 0x4f, 0x5b, 0x5b, 376 | 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 377 | 0x5b, 0x3c, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 378 | 0xb0, 0xb0, 0xb0, 0xb0, 0x5d, 0x6f, 0x85, 0x89, 0x8b, 0x8b, 0x8b, 379 | 0x85, 0x89, 0x8b, 0x86, 0x57, 0x57, 0x59, 0x5b, 0x5b, 0x5b, 0x69, 380 | 0x7c, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x57, 381 | 0x39, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5a, 0x5b, 0x67, 0x68, 382 | 0x69, 0x67, 0x67, 0x69, 0x3c, 0xb3, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 383 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0x5d, 0x6f, 0x85, 384 | 0x8b, 0x8b, 0x8b, 0x85, 0x8b, 0x8b, 0x85, 0x57, 0x57, 0x5b, 0x5b, 385 | 0x5b, 0x7c, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 386 | 0x67, 0x67, 0x57, 0x23, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 387 | 0x67, 0x67, 0x67, 0x67, 0x7c, 0x69, 0x67, 0x69, 0x3c, 0xb2, 0xb0, 388 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 389 | 0xb0, 0x5d, 0x6f, 0x85, 0x89, 0x8b, 0x85, 0x89, 0x8b, 0x85, 0x59, 390 | 0x57, 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 391 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x57, 0x39, 0x5b, 0x5b, 0x5b, 0x5b, 392 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x7c, 0x58, 393 | 0x3c, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 394 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0x6b, 0x6f, 0x85, 0x8b, 0x70, 0x89, 395 | 0x8b, 0x8a, 0x57, 0x57, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 396 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x5b, 0x23, 0x5b, 397 | 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 398 | 0x67, 0x67, 0x67, 0x59, 0x3c, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 399 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0x6b, 0x6f, 400 | 0x85, 0x72, 0x70, 0x72, 0x21, 0x17, 0x57, 0x59, 0x5b, 0x5b, 0x5b, 401 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 402 | 0x5b, 0x17, 0x57, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 403 | 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x5b, 0x3c, 0xb2, 0xb0, 0xb0, 404 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 405 | 0xb0, 0xb0, 0x6b, 0x6f, 0x6c, 0xaf, 0x3c, 0x17, 0x21, 0x21, 0x57, 406 | 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 407 | 0x67, 0x67, 0x67, 0x23, 0xa3, 0xa4, 0x23, 0x5b, 0x5b, 0x5b, 0x5b, 408 | 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x67, 0x59, 409 | 0x3b, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 410 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb2, 0x3b, 0x17, 0x17, 411 | 0x17, 0x17, 0x5b, 0x5b, 0x5b, 0x39, 0x17, 0x5b, 0x67, 0x67, 0x67, 412 | 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x23, 0xa3, 0xa4, 0x23, 0x5b, 413 | 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x57, 0x17, 0x17, 0x57, 0x67, 0x67, 414 | 0x67, 0x67, 0x67, 0x67, 0x39, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 415 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb3, 0x39, 416 | 0x23, 0x17, 0x17, 0x4f, 0x17, 0x17, 0x5b, 0x21, 0x17, 0x17, 0x4f, 417 | 0x17, 0x17, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x68, 0x67, 0x23, 0xa0, 418 | 0xb3, 0xa3, 0x23, 0x5b, 0x17, 0x17, 0x4f, 0x17, 0x17, 0x57, 0x67, 419 | 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x5c, 0x39, 0xb2, 0xb0, 420 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 421 | 0xb2, 0x39, 0x17, 0x39, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x4f, 422 | 0x12, 0x9c, 0xc2, 0xc5, 0x76, 0x15, 0x5a, 0x67, 0x67, 0x67, 0x67, 423 | 0x67, 0x58, 0xa0, 0xb3, 0xb2, 0xa3, 0x14, 0x17, 0x17, 0x17, 0x17, 424 | 0x39, 0x67, 0x67, 0x5b, 0x5b, 0x5b, 0x67, 0x67, 0x67, 0x67, 0x5b, 425 | 0x3b, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 426 | 0xb0, 0xb0, 0xb2, 0x39, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 427 | 0x17, 0x57, 0x58, 0x15, 0xcd, 0xe7, 0xe8, 0xdc, 0x76, 0x21, 0x5b, 428 | 0x5b, 0x5b, 0x67, 0x23, 0xa0, 0xb2, 0xb2, 0xa3, 0x14, 0x17, 0x17, 429 | 0x17, 0x17, 0x57, 0x67, 0x5b, 0x5b, 0x5b, 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0, 0xb0, 0xb0, 0xb0, 537 | 0xb0, 0xb2, 0x33, 0x09, 0x09, 0x5b, 0x5b, 0x5b, 0x5b, 0x59, 0x2c, 538 | 0xab, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 539 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 540 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 541 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 542 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb2, 0x37, 0x09, 0x57, 0x5b, 0x5b, 543 | 0x5b, 0x23, 0xab, 0xb2, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 544 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 545 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 546 | 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 547 | 0xb0 548 | }; 549 | -------------------------------------------------------------------------------- /test_gx/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../res/kid.tim.c" 3 | 4 | typedef struct sprite 5 | { 6 | int occupied; 7 | int tx, ty; // Texture coordinates 8 | int x, y; // Position on screen 9 | uint8_t w, h; // Size 10 | int vx, vy; // Velocity 11 | } 12 | sprite_t; 13 | 14 | uint16_t res_w; 15 | uint16_t res_h; 16 | struct gx_texture *texture; 17 | uint16_t tex_w; 18 | uint16_t tex_h; 19 | sprite_t sprites[32]; 20 | 21 | sprite_t *InitSprite(int x, int y, int tx, int ty, int vx, int vy) 22 | { 23 | for (int i = 0; i < 32; ++i) 24 | { 25 | sprite_t *spr = &sprites[i]; 26 | if (!spr->occupied) 27 | { 28 | spr->occupied = 1; 29 | spr->x = x; 30 | spr->y = y; 31 | spr->vx = vx; 32 | spr->vy = vy; 33 | spr->tx = tx; 34 | spr->ty = ty; 35 | spr->w = tex_w; 36 | spr->h = tex_h; 37 | return spr; 38 | } 39 | } 40 | return 0; 41 | } 42 | 43 | void UpdateSprite(sprite_t *spr) 44 | { 45 | int newx = spr->x + spr->vx; 46 | int newy = spr->y + spr->vy; 47 | spr->x=newx; 48 | spr->y=newy; 49 | 50 | if ((newx + spr->w) >= res_w || (newy + spr->h) >= res_h || newx <= 0 || newy <= 0) 51 | { 52 | int vx = spr->vx; 53 | spr->vx = -spr->vy; 54 | spr->vy = vx; 55 | } 56 | else 57 | { 58 | spr->x = newx; 59 | spr->y = newy; 60 | } 61 | } 62 | 63 | int main(void) 64 | { 65 | GX_Init(GX_HRES_320, GX_VRES_240); 66 | 67 | GX_SetClearColor(GX_GRAY); 68 | 69 | GX_GetResolution(&res_w, &res_h); 70 | 71 | texture = GX_LoadTIM(kid_tim); 72 | GX_GetTextureDims(texture, &tex_w, &tex_h); 73 | 74 | for (int i = 0; i < 32; ++i) 75 | sprites[i].occupied = 0; 76 | 77 | InitSprite(50, 50, 0, 0, -1, 1); 78 | InitSprite(60, 30, 0, 0, 1, 1); 79 | InitSprite(120, 20, 0, 0, -1, -1); 80 | InitSprite(100, 80, 0, 0, 1, -1); 81 | 82 | while (1) 83 | { 84 | GX_Clear(); 85 | 86 | GX_SelectTexture(texture); 87 | 88 | for (int i = 0; i < 32; ++i) 89 | { 90 | sprite_t *spr = &sprites[i]; 91 | if (spr->occupied) 92 | { 93 | UpdateSprite(&sprites[i]); 94 | GX_DrawRectangleTextured( 95 | spr->x, 96 | spr->y, 97 | spr->w, 98 | spr->h, 99 | spr->tx, 100 | spr->ty 101 | ); 102 | } 103 | } 104 | 105 | GX_Sync(); 106 | } 107 | 108 | return 0; 109 | } 110 | -------------------------------------------------------------------------------- /triangle/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "primitives.h" 11 | 12 | #define BIT(x) (1<color); 29 | GP[0] = tri->verts[0].yx; 30 | GP[0] = tri->verts[1].yx; 31 | GP[0] = tri->verts[2].yx; 32 | } 33 | 34 | inline void glFlatQuad2fp(const quad_t *quad){ 35 | GP0_DO(0x20, quad->color); 36 | GP[0] = quad->verts[0].yx; 37 | GP[0] = quad->verts[1].yx; 38 | GP[0] = quad->verts[2].yx; 39 | GP[0] = quad->verts[3].yx; 40 | } 41 | 42 | inline void glFlatLine2fp(const line_t *line) { 43 | GP0_DO(ShadedLineOpaque, line->color0); 44 | GP[0] = line->v0.yx; 45 | GP[0] = line->color1; 46 | GP[0] = line->v1.yx; 47 | /*GP[0] = 0x55555555;*/ 48 | } 49 | 50 | inline void glShadedQuad2fp(const line_t *line) { 51 | GP0_DO(ShadedQuadOpaque, line->color0); 52 | GP[0] = line->v0.yx; 53 | GP[0] = line->color1; 54 | GP[0] = line->v1.yx; 55 | ++line; 56 | GP[0] = line->color0; 57 | GP[0] = line->v0.yx; 58 | GP[0] = line->color1; 59 | GP[0] = line->v1.yx; 60 | } 61 | 62 | inline void glShadedWireframe2fp(const line_t *line, size_t n_lines) { 63 | const line_t *linep = line; 64 | 65 | GP0_DO(ShadedPolyLineOpaque, linep->color0); 66 | GP[0] = (unsigned)linep->v0.yx; 67 | GP[0] = linep->color1; 68 | GP[0] = (unsigned)linep->v1.yx; 69 | ++linep; 70 | for(size_t i = 0; i < n_lines-1; i++) { 71 | GP[0] = linep->color0; 72 | GP[0] = (unsigned)linep->v0.yx; 73 | GP[0] = linep->color1; 74 | GP[0] = (unsigned)linep->v1.yx; 75 | ++linep; 76 | } 77 | GP[0] = (unsigned)line->color0; 78 | GP[0] = line->v0.yx; 79 | GP[0] = (unsigned)line->color1; 80 | GP[0] = line->v1.yx; 81 | 82 | GP[0] = 0x55555555; 83 | } 84 | 85 | void glDrawTris(const triangle_t *tris, size_t len) { 86 | for(size_t i = 0; i < len; i++) { 87 | glFlatTri2fp(tris++); 88 | } 89 | } 90 | 91 | // todo don't use linked lists 92 | struct list_node { 93 | struct list_node *tail; 94 | int head; 95 | }; 96 | 97 | size_t length(const struct list_node *p) { 98 | size_t length = 0; 99 | if(p != NULL) { 100 | do { 101 | length++; 102 | } while((p = p->tail)); 103 | } 104 | return length; 105 | } 106 | 107 | struct list_node l5 = {.tail=NULL}; 108 | struct list_node l4 = {.tail=&l5}; 109 | struct list_node l3 = {.tail=&l4}; 110 | struct list_node l2 = {.tail=&l3}; 111 | struct list_node l1 = {.tail=&l2}; 112 | struct list_node mylist = {.tail=&l1}; 113 | 114 | void initIRQ(short); 115 | 116 | int main(void) 117 | { 118 | //initIRQ(IRQ_VBLANK); 119 | //IRQ_MASK |= IRQ_VBLANK; 120 | initGpu(); 121 | 122 | printf("yx: 0x%08X x: %04x y: %04x\n", tri1.verts[2].yx, tri1.verts[2].p.x, tri1.verts[2].p.y); 123 | printf("Length of list: %d\n", length((struct list_node*)&mylist)); 124 | printf("Length of list: %d\n", length((struct list_node*)mylist.tail)); 125 | printf("Length of list: %d\n", length((struct list_node*)mylist.tail->tail)); 126 | printf("Length of list: %d\n", length((struct list_node*)&l5)); 127 | printf("Length of list: %d\n", length(NULL)); 128 | 129 | //uint16_t fb_page = 0; 130 | 131 | while(1) { 132 | waitVblank(); 133 | 134 | GP1_DO(DmaDirection,0); // Disable DMA 135 | GP1_DO(ResetCommandBuffer,0); 136 | GP0_DO(ClearCache,0); 137 | 138 | waitGpu(Gp0CmdReady); 139 | GP0_DO(FillRectVram, 0x101010); 140 | GP[0] = 0x00000000; 141 | GP[0] = (230<<16) | (256); 142 | 143 | waitGpu(Gp0CmdReady); 144 | // 15bpp format: bbbbb---ggggg---rrrrr--- 145 | glFlatTri2fp(&tri1); 146 | //waitGpu(Gp0CmdReady); 147 | 148 | glDrawTris(pyramid, pyramid_size); 149 | /*glFlatLine2fp(&myline);*/ 150 | 151 | glShadedWireframe2fp(cube_face0, 152 | sizeof(cube_face0)/sizeof(*cube_face0)); 153 | glShadedQuad2fp(cube_face1); 154 | /*glShadedWireframe2fp(cube_face1, 155 | sizeof(cube_face1)/sizeof(*cube_face1));*/ 156 | glShadedWireframe2fp(cube_face2, 157 | sizeof(cube_face2)/sizeof(*cube_face2)); 158 | glShadedWireframe2fp(cube_face3, 159 | sizeof(cube_face3)/sizeof(*cube_face3)); 160 | 161 | //while (1); 162 | //fb_page ^= 224; 163 | //setDisplayOrigin(0, fb_page); 164 | } 165 | return 0; 166 | } 167 | 168 | -------------------------------------------------------------------------------- /triangle/makefile: -------------------------------------------------------------------------------- 1 | include ../base.mk 2 | 3 | libpsx := ../libpsx 4 | 5 | target := $(shell basename $(CURDIR)) 6 | output := $(target) 7 | build := build 8 | sources := . $(libpsx)/libc $(libpsx)/psx 9 | incdirs := . $(libpsx) $(libpsx)/include $(build) 10 | includes:= $(foreach dir,$(incdirs),-I$(dir)) 11 | 12 | arch := -march=r3000 -mabi=32 -EL -msoft-float -Wa,-msoft-float 13 | asflags := -g $(arch) 14 | cflags := -g -std=c99 -Wall -Wextra -Wpadded -pedantic -mgpopt -mno-extern-sdata -pipe -nostdinc $(arch) 15 | ldflags := $(cflags) -Wl,-Map=$(target).map -nostdlib -T$(libpsx)/psx-exe.ld 16 | 17 | sfiles := $(foreach dir,$(sources),$(notdir $(wildcard $(dir)/*.S))) 18 | cfiles := $(foreach dir,$(sources),$(notdir $(wildcard $(dir)/*.c))) 19 | 20 | ofiles := $(cfiles:%.c=$(build)/%.o) $(sfiles:%.S=$(build)/%.o) 21 | depfiles:= $(ofiles:.o=.d) 22 | 23 | VPATH := $(foreach dir,$(sources),$(CURDIR)/$(dir)) 24 | 25 | .PHONY: all clean debug release run 26 | 27 | all: release 28 | 29 | debug: asflags += -DDEBUG 30 | debug: cflags += -O0 -DDEBUG 31 | debug: ldflags += 32 | debug: $(output).exe 33 | 34 | release: asflags += 35 | release: cflags += -O2 -flto -ffat-lto-objects 36 | release: ldflags += -flto -ffat-lto-objects 37 | release: $(output).exe 38 | 39 | $(output).exe : $(output).bin 40 | 41 | $(output).bin : $(output).elf 42 | 43 | $(output).elf : $(build) $(ofiles) 44 | 45 | $(build): 46 | @mkdir -p $@ 47 | 48 | clean: 49 | rm -rf $(output).exe $(output).bin $(output).elf $(output).map $(build) 50 | 51 | run: 52 | $(nopsx) $(output).exe 53 | 54 | dump: 55 | $(OBJDUMP) -b binary -mmips:3000 -EL -D $(output).bin 56 | 57 | -include $(depfiles) 58 | 59 | -------------------------------------------------------------------------------- /triangle/primitives.h: -------------------------------------------------------------------------------- 1 | #ifndef PRIMITIVES_H 2 | #define PRIMITIVES_H 3 | 4 | typedef struct { 5 | short x, y, z; 6 | } vec3fp; 7 | 8 | typedef union { 9 | unsigned yx; 10 | struct { 11 | short x, y; 12 | } p; 13 | } vec2fp; 14 | 15 | typedef struct { 16 | unsigned color0; 17 | vec2fp v0; 18 | unsigned color1; 19 | vec2fp v1; 20 | } line_t; 21 | 22 | typedef struct { 23 | unsigned color; 24 | vec2fp verts[3]; 25 | } triangle_t; 26 | 27 | typedef struct { 28 | unsigned color; 29 | vec2fp verts[4]; 30 | } quad_t; 31 | 32 | triangle_t tri1 = { 0x808080,{ {.p={240, 100}}, {.p={540+40, 140}}, {.p={240-40, 140}} } }; 33 | 34 | triangle_t pyramid[] = { 35 | { 0xA08000,{ {.p={0x24, 0x20}}, {.p={0x44, 0x40}}, {.p={-20 , 0x49}} } }, 36 | { 0x008000,{ {.p={0x80, -20 }}, {.p={0xa0, 0x20}}, {.p={0x60, 0x20}} } }, 37 | { 0x000080,{ {.p={0x60, 210 }}, {.p={0xa0, 360 }}, {.p={0x20, 360 }} } } 38 | }; 39 | 40 | size_t pyramid_size = sizeof(pyramid)*sizeof(*pyramid); 41 | 42 | quad_t quad1 = { 0x000080, { {.p={0x10, 0x10}}, {.p={0x30, 0x10}}, {.p={0x30, 0x30}}, {.p={0x10, 0x30}} } }; 43 | 44 | line_t cube_face0[] = 45 | { 46 | { 47 | 0x0000ff, 48 | .v0.p={100, 100}, 49 | 0x00ff00, 50 | .v1.p={150, 100} 51 | }, 52 | { 53 | 0xff0000, 54 | .v0.p={150, 150}, 55 | 0xffff00, 56 | .v1.p={100, 150} 57 | } 58 | }; 59 | line_t cube_face1[] = 60 | { 61 | { 62 | 0x00ffff, 63 | .v0.p={110, 110}, 64 | 0xff00ff, 65 | .v1.p={140, 110} 66 | }, 67 | { 68 | 0x0000ff, 69 | .v0.p={110, 140}, 70 | 0xf0f00f, 71 | .v1.p={140, 140} 72 | } 73 | }; 74 | line_t cube_face2[] = 75 | { 76 | { 77 | 0x0000ff, 78 | .v0.p={100, 100}, 79 | 0x00ffff, 80 | .v1.p={110, 110} 81 | }, 82 | { 83 | 0xf0f00f, 84 | .v0.p={110, 140}, 85 | 0xffff00, 86 | .v1.p={100, 150} 87 | } 88 | }; 89 | line_t cube_face3[] = 90 | { 91 | { 92 | 0xff00ff, 93 | .v0.p={140, 110}, 94 | 0x00ff00, 95 | .v1.p={150, 100} 96 | }, 97 | { 98 | 0xff0000, 99 | .v0.p={150, 150}, 100 | 0x0000ff, 101 | .v1.p={140, 140} 102 | } 103 | }; 104 | 105 | line_t myline = { .color0=0x00ff0000, .v0={.p.x=20,.p.y=20}, 106 | .color1=0x000000ff, .v1={.p.x=50,.p.y=40} }; 107 | 108 | #endif 109 | --------------------------------------------------------------------------------