util.h (1328B)
1 #pragma once 2 3 #include "types.h" 4 #include "sr.h" 5 6 #define BIOS_SIZE 512 * 1024 7 #define BIOS_START 0x1FC00000 8 9 #define SYSCONTROL_SIZE 36 10 #define SYSCONTROL_START 0x1F801000 11 12 #define RAM_SIZE_SIZE 4 13 #define RAM_SIZE_START 0x1F801060 14 15 #define CACHECONTROL_SIZE 4 16 #define CACHECONTROL_START 0xFFFE0130 17 18 #define RAM_SIZE 2 * 1024 * 1024 19 #define RAM_START 0x00000000 20 21 #define SPU_SIZE 640 22 #define SPU_START 0x1F801C00 23 24 #define EXPANSION2_SIZE 66 25 #define EXPANSION2_START 0x1F802000 26 27 #define EXPANSION1_START 0x1F000000 28 #define EXPANSION1_SIZE 512*1024 29 30 #define IRQ_CONTROL_START 0x1F801070 31 #define IRQ_CONTROL_SIZE 8 32 33 #define TIMERS_START 0x1F801100 34 #define TIMERS_SIZE 0x30 35 36 #define DMA_START 0x1F801080 37 #define DMA_SIZE 0x80 38 39 #define GPU_START 0x1F801810 40 #define GPU_SIZE 8 41 42 #define CDROM_START 0x1F801800 43 #define CDROM_SIZE 12 44 45 static inline u32 46 UTIL_contains(u32 start, u32 length, u32 addr, u32 *res) 47 { 48 *res = addr-start; 49 return (addr >= start && addr < start + length) ? 1 : 0; 50 } 51 52 u8 checked_addi32(i32, i32, i32*); 53 u8 checked_subi32(i32, i32, i32*); 54 55 56 57 extern const u32 REGION_MASK[8]; 58 59 static inline u32 mask_region(u32 addr) 60 { 61 return addr & REGION_MASK[addr >> 29]; 62 } 63 64 /* Misc */ 65 void swap_int(int*, int*); 66 void swap_color(C*, C*); 67 void swap_vec2(ivec2*, ivec2*); 68 69 void UTIL_bin8(u8); 70 void UTIL_bin32(u32);