Browse Source

core, structural cleanup, fixes and improvements for type issues #2

kub 3 years ago
parent
commit
f821bb7011
64 changed files with 140 additions and 150 deletions
  1. 1 1
      Makefile
  2. 1 1
      Makefile.libretro
  3. 1 1
      cpu/DrZ80/drz80.S
  4. 1 1
      cpu/debug.c
  5. 3 0
      cpu/fame/famec.c
  6. 2 2
      cpu/sh2/compiler.c
  7. 6 6
      cpu/sh2/mame/sh2pico.c
  8. 2 2
      cpu/sh2/sh2.h
  9. 1 1
      pico/32x/32x.c
  10. 10 10
      pico/32x/draw.c
  11. 2 2
      pico/32x/draw_arm.S
  12. 1 1
      pico/32x/memory.c
  13. 1 1
      pico/32x/memory_arm.S
  14. 9 9
      pico/32x/sh2soc.c
  15. 2 2
      pico/cart.c
  16. 3 3
      pico/carthw/svp/compiler.c
  17. 2 2
      pico/carthw/svp/memory.c
  18. 1 1
      pico/carthw/svp/ssp16.c
  19. 1 1
      pico/carthw/svp/stub_arm.S
  20. 6 6
      pico/cd/genplus_macros.h
  21. 1 1
      pico/cd/gfx.c
  22. 1 1
      pico/cd/gfx_dma.c
  23. 2 2
      pico/cd/memory_arm.S
  24. 0 1
      pico/debugCPU.c
  25. 3 3
      pico/draw.c
  26. 0 1
      pico/pico/memory.c
  27. 8 9
      pico/pico_int.h
  28. 1 1
      pico/sek.c
  29. 1 1
      pico/sound/mix.c
  30. 8 8
      pico/sound/ym2612.h
  31. 1 1
      pico/sound/ym2612_arm.S
  32. 1 1
      pico/state.c
  33. 1 1
      pico/videoport.c
  34. 6 7
      platform/common/main.c
  35. 4 4
      platform/common/menu_pico.c
  36. 1 1
      platform/common/plat_sdl.c
  37. 1 1
      platform/gizmondo/emu.c
  38. 1 1
      platform/gizmondo/giz.c
  39. 1 1
      platform/gizmondo/main.c
  40. 5 7
      platform/gizmondo/menu.c
  41. 3 3
      platform/gp2x/940ctl.c
  42. 1 1
      platform/gp2x/code940/940.c
  43. 1 1
      platform/gp2x/code940/940shared.h
  44. 1 4
      platform/gp2x/code940/Makefile
  45. 1 1
      platform/gp2x/code940/mp3test.c
  46. 3 2
      platform/libretro/libretro.c
  47. 0 0
      platform/libretro/ps2/Draw_mips_r5900.s
  48. 0 0
      platform/libretro/ps2/Memory_mips_r5900.s
  49. 0 0
      platform/libretro/ps2/asm.h
  50. 0 0
      platform/libretro/ps2/asm.s
  51. 0 0
      platform/libretro/switch/mman.h
  52. 3 3
      platform/linux/emu.c
  53. 1 1
      platform/linux/io.c
  54. 0 1
      platform/psp/emu.c
  55. 1 1
      platform/psp/main.c
  56. 1 4
      platform/psp/menu.c
  57. 3 3
      platform/psp/mp3.c
  58. 2 2
      platform/psp/psp.c
  59. 2 3
      platform/win32/main.c
  60. 2 3
      platform/win32/plat.c
  61. 9 8
      tools/bin_to_cso_mp3/bin_to_cso_mp3.c
  62. 1 1
      tools/drctest.c
  63. 1 1
      tools/mkoffsets.c
  64. 1 1
      tools/mkoffsets.sh

+ 1 - 1
Makefile

@@ -1,7 +1,7 @@
 $(LD) ?= $(CC)
 TARGET ?= PicoDrive
 DEBUG ?= 0
-CFLAGS += -I.
+CFLAGS += -I$(PWD)
 CYCLONE_CC ?= gcc
 CYCLONE_CXX ?= g++
 

+ 1 - 1
Makefile.libretro

@@ -205,7 +205,7 @@ else ifeq ($(platform), ps2)
 
 	ARCH = mipsel
 	asm_render = 1
-	OBJS += platform/ps2/asm.o
+	OBJS += platform/libretro/ps2/asm.o
 
 # CTR (3DS)
 else ifeq ($(platform), ctr)

+ 1 - 1
cpu/DrZ80/drz80.S

@@ -5,7 +5,7 @@
 
 ;@ For commercial use, separate licencing terms must be obtained.
 
-#include "../../pico/arm_features.h"
+#include <pico/arm_features.h>
 
       .data
       .align 4

+ 1 - 1
cpu/debug.c

@@ -8,7 +8,7 @@
 #define _GNU_SOURCE
 #include <stdio.h>
 
-#include "../pico/pico_int.h"
+#include <pico/pico_int.h>
 #include "debug.h"
 
 static char pdb_pending_cmds[128];

+ 3 - 0
cpu/fame/famec.c

@@ -60,6 +60,8 @@
 #define FAMEC_EXTRA_INLINE INLINE
 #endif
 
+#include <pico/pico_types.h>
+/*
 #ifdef u8
 #undef u8
 #endif
@@ -95,6 +97,7 @@
 #define u32	unsigned int
 #define s32	signed int
 #define uptr	uintptr_t
+*/
 
 /*
 typedef unsigned char	u8;

+ 2 - 2
cpu/sh2/compiler.c

@@ -32,8 +32,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "../../pico/pico_int.h"
-#include "../../pico/arm_features.h"
+#include <pico/pico_int.h>
+#include <pico/arm_features.h>
 #include "sh2.h"
 #include "compiler.h"
 #include "../drc/cmn.h"

+ 6 - 6
cpu/sh2/mame/sh2pico.c

@@ -9,12 +9,12 @@
 
 // MAME types
 #ifndef INT8
-typedef signed char  INT8;
-typedef signed short INT16;
-typedef signed int   INT32;
-typedef unsigned int   UINT32;
-typedef unsigned short UINT16;
-typedef unsigned char  UINT8;
+typedef s8  INT8;
+typedef s16 INT16;
+typedef s32 INT32;
+typedef u32 UINT32;
+typedef u16 UINT16;
+typedef u8  UINT8;
 #endif
 
 #ifdef DRC_SH2

+ 2 - 2
cpu/sh2/sh2.h

@@ -1,8 +1,8 @@
 #ifndef __SH2_H__
 #define __SH2_H__
 
-#include "../../pico/pico_types.h"
-#include "../../pico/pico_port.h"
+#include <pico/pico_types.h>
+#include <pico/pico_port.h>
 
 // registers - matches structure order
 typedef enum {

+ 1 - 1
pico/32x/32x.c

@@ -7,7 +7,7 @@
  */
 #include "../pico_int.h"
 #include "../sound/ym2612.h"
-#include "../../cpu/sh2/compiler.h"
+#include <cpu/sh2/compiler.h>
 
 struct Pico32x Pico32x;
 SH2 sh2s[2];

+ 10 - 10
pico/32x/draw.c

@@ -26,19 +26,19 @@ int DrawLineDestIncrement32x;
 
 static void convert_pal555(int invert_prio)
 {
-  unsigned int *ps = (void *)Pico32xMem->pal;
-  unsigned int *pd = (void *)Pico32xMem->pal_native;
-  unsigned int m1 = 0x001f001f;
-  unsigned int m2 = 0x03e003e0;
-  unsigned int m3 = 0xfc00fc00; // includes prio bit
-  unsigned int inv = 0;
+  u32 *ps = (void *)Pico32xMem->pal;
+  u32 *pd = (void *)Pico32xMem->pal_native;
+  u32 m1 = 0x001f001f;
+  u32 m2 = 0x03e003e0;
+  u32 m3 = 0xfc00fc00; // includes prio bit
+  u32 inv = 0;
   int i;
 
   if (invert_prio)
     inv = 0x80008000;
 
   for (i = 0x100/2; i > 0; i--, ps++, pd++) {
-    unsigned int t = *ps ^ inv;
+    u32 t = *ps ^ inv;
     *pd = PXCONV(t);
   }
 
@@ -48,9 +48,9 @@ static void convert_pal555(int invert_prio)
 // direct color mode
 #define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code)             \
 {                                                                 \
-  const unsigned int m1 = 0x001f;                                 \
-  const unsigned int m2 = 0x03e0;                                 \
-  const unsigned int m3 = 0x7c00;                                 \
+  const u16 m1 = 0x001f;                                          \
+  const u16 m2 = 0x03e0;                                          \
+  const u16 m3 = 0x7c00;                                          \
   unsigned short t;                                               \
   int i = 320;                                                    \
                                                                   \

+ 2 - 2
pico/32x/draw_arm.S

@@ -7,8 +7,8 @@
 @* See COPYING file in the top-level directory.
 @*
 
-#include "pico/arm_features.h"
-#include "pico/pico_int_offs.h"
+#include <pico/arm_features.h>
+#include <pico/pico_int_offs.h>
 
 .extern Pico32x
 .extern Pico

+ 1 - 1
pico/32x/memory.c

@@ -42,7 +42,7 @@
 #include "../pico_int.h"
 #include "../memory.h"
 
-#include "../../cpu/sh2/compiler.h"
+#include <cpu/sh2/compiler.h>
 DRC_DECLARE_SR;
 
 static const char str_mars[] = "MARS";

+ 1 - 1
pico/32x/memory_arm.S

@@ -6,7 +6,7 @@
  * See COPYING file in the top-level directory.
  */
 
-#include "../pico_int_offs.h"
+#include <pico/pico_int_offs.h>
 
 @ 32X bank sizes... TODO this should somehow come from an include file
 .equ SH2_ROM_SHIFT, 10      @ 0x003fffff

+ 9 - 9
pico/32x/sh2soc.c

@@ -25,14 +25,14 @@
 #include "../pico_int.h"
 #include "../memory.h"
 
-#include "../../cpu/sh2/compiler.h"
+#include <cpu/sh2/compiler.h>
 DRC_DECLARE_SR;
 
 // DMAC handling
 struct dma_chan {
-  unsigned int sar, dar;  // src, dst addr
-  unsigned int tcr;       // transfer count
-  unsigned int chcr;      // chan ctl
+  u32 sar, dar;  // src, dst addr
+  u32 tcr;       // transfer count
+  u32 chcr;      // chan ctl
   // -- dm dm sm sm  ts ts ar am  al ds dl tb  ta ie te de
   // ts - transfer size: 1, 2, 4, 16 bytes
   // ar - auto request if 1, else dreq signal
@@ -47,11 +47,11 @@ struct dma_chan {
 
 struct dmac {
   struct dma_chan chan[2];
-  unsigned int vcrdma0;
-  unsigned int unknown0;
-  unsigned int vcrdma1;
-  unsigned int unknown1;
-  unsigned int dmaor;
+  u32 vcrdma0;
+  u32 unknown0;
+  u32 vcrdma1;
+  u32 unknown1;
+  u32 dmaor;
   // -- pr ae nmif dme
   // pr - priority: chan0 > chan1 or round-robin
   // ae - address error

+ 2 - 2
pico/cart.c

@@ -8,8 +8,8 @@
  */
 
 #include "pico_int.h"
-#include "../cpu/debug.h"
-#include "../unzip/unzip.h"
+#include <cpu/debug.h>
+#include <unzip/unzip.h>
 #include <zlib.h>
 
 #ifdef USE_LIBRETRO_VFS

+ 3 - 3
pico/carthw/svp/compiler.c

@@ -6,8 +6,8 @@
  * See COPYING file in the top-level directory.
  */
 
-#include "../../pico_int.h"
-#include "../../../cpu/drc/cmn.h"
+#include <pico/pico_int.h>
+#include <cpu/drc/cmn.h>
 #include "compiler.h"
 
 // FIXME: asm has these hardcoded
@@ -39,7 +39,7 @@ void ssp_drc_end(void){}
 #endif
 
 #define COUNT_OP
-#include "../../../cpu/drc/emit_arm.c"
+#include <cpu/drc/emit_arm.c>
 
 // -----------------------------------------------------
 

+ 2 - 2
pico/carthw/svp/memory.c

@@ -26,8 +26,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "../../pico_int.h"
-#include "../../memory.h"
+#include <pico/pico_int.h>
+#include <pico/memory.h>
 
 // for wait loop det
 static void PicoWrite16_dram(u32 a, u32 d)

+ 1 - 1
pico/carthw/svp/ssp16.c

@@ -206,7 +206,7 @@
  *   ops not used by VR are not implemented
  */
 
-#include "../../pico_int.h"
+#include <pico/pico_int.h>
 
 #define u32 unsigned int
 

+ 1 - 1
pico/carthw/svp/stub_arm.S

@@ -6,7 +6,7 @@
 @* See COPYING file in the top-level directory.
 @*
 
-#include "../../arm_features.h"
+#include <pico/arm_features.h>
 
 @.syntax unified
 .text

+ 6 - 6
pico/cd/genplus_macros.h

@@ -5,12 +5,12 @@
 #undef int16
 #undef int32
 
-#define uint8  unsigned char
-#define uint16 unsigned short
-#define uint32 unsigned int
-#define int8  signed char
-#define int16 signed short
-#define int32 signed int
+#define uint8  u8
+#define uint16 u16
+#define uint32 u32
+#define int8   s8
+#define int16  s16
+#define int32  s32
 
 #define READ_BYTE(BASE, ADDR) (BASE)[(ADDR)^1]
 #define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[(ADDR)^1] = (VAL)

+ 1 - 1
pico/cd/gfx.c

@@ -311,7 +311,7 @@ static void gfx_render(uint32 bufferIndex, uint32 width)
   }
 }
 
-void gfx_start(unsigned int base)
+void gfx_start(uint32 base)
 {
   /* make sure 2M mode is enabled */
   if (!(Pico_mcd->s68k_regs[3] & 0x04))

+ 1 - 1
pico/cd/gfx_dma.c

@@ -14,7 +14,7 @@
 PICO_INTERNAL void DmaSlowCell(u32 source, u32 a, int len, unsigned char inc)
 {
   unsigned char *base;
-  unsigned int asrc, a2;
+  u32 asrc, a2;
   u16 *r;
 
   base = Pico_mcd->word_ram1M[Pico_mcd->s68k_regs[3]&1];

+ 2 - 2
pico/cd/memory_arm.S

@@ -6,8 +6,8 @@
 @* See COPYING file in the top-level directory.
 @*
 
-#include "../arm_features.h"
-#include "../pico_int_offs.h"
+#include <pico/arm_features.h>
+#include <pico/pico_int_offs.h>
 
 .equiv PCM_STEP_SHIFT, 11
 

+ 0 - 1
pico/debugCPU.c

@@ -8,7 +8,6 @@
 
 #include "pico_int.h"
 
-typedef unsigned char  u8;
 
 static unsigned int pppc, ops=0;
 extern unsigned int lastread_a, lastread_d[16], lastwrite_cyc_d[16], lastwrite_mus_d[16];

+ 3 - 3
pico/draw.c

@@ -53,7 +53,7 @@ static unsigned char DefHighCol[8+320+8];
 unsigned char *HighColBase = DefHighCol;
 int HighColIncrement;
 
-static u16 DefOutBuff[320*2];
+static u16 DefOutBuff[320*2] ALIGNED(4);
 void *DrawLineDestBase = DefOutBuff;
 int DrawLineDestIncrement;
 
@@ -200,7 +200,7 @@ TileFlipMaker(TileFlipNonSH, pix_nonsh)
 // draw sprite pixels, process operator colors
 #define pix_sh(x) \
   if (likely(t)) \
-    pd[x]=(likely(t<0xe) ? pal|t : pd[x]|((t-1)<<6));
+    pd[x]=(likely(t<0xe) ? pal|t : pd[x]|((t-1)<<6))
 
 TileNormMaker(TileNormSH, pix_sh)
 TileFlipMaker(TileFlipSH, pix_sh)
@@ -208,7 +208,7 @@ TileFlipMaker(TileFlipSH, pix_sh)
 // draw sprite pixels, mark but don't process operator colors
 #define pix_sh_markop(x) \
   if (likely(t)) \
-    pd[x]=(likely(t<0xe) ? pal|t : pd[x]|0x40);
+    pd[x]=(likely(t<0xe) ? pal|t : pd[x]|0x40)
 
 TileNormMaker(TileNormSH_markop, pix_sh_markop)
 TileFlipMaker(TileFlipSH_markop, pix_sh_markop)

+ 0 - 1
pico/pico/memory.c

@@ -7,7 +7,6 @@
  */
 #include "../pico_int.h"
 #include "../memory.h"
-#include "../sound/sn76496.h"
 
 /*
 void dump(u16 w)

+ 8 - 9
pico/pico_int.h

@@ -11,6 +11,7 @@
 #define PICO_INTERNAL_INCLUDED
 #include <stdio.h>
 #include <string.h>
+#include "pico_types.h"
 #include "pico_port.h"
 #include "pico.h"
 #include "carthw/carthw.h"
@@ -31,11 +32,9 @@
 extern "C" {
 #endif
 
-#include "pico_types.h"
-
 // ----------------------- 68000 CPU -----------------------
 #ifdef EMU_C68K
-#include "../cpu/cyclone/Cyclone.h"
+#include <cpu/cyclone/Cyclone.h>
 extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;
 #define SekCyclesLeft     PicoCpuCM68k.cycles // cycles left for this run
 #define SekCyclesLeftS68k PicoCpuCS68k.cycles
@@ -60,7 +59,7 @@ extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;
 #endif
 
 #ifdef EMU_F68K
-#include "../cpu/fame/fame.h"
+#include <cpu/fame/fame.h>
 extern M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;
 #define SekCyclesLeft     PicoCpuFM68k.io_cycle_counter
 #define SekCyclesLeftS68k PicoCpuFS68k.io_cycle_counter
@@ -91,7 +90,7 @@ extern M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;
 #endif
 
 #ifdef EMU_M68K
-#include "../cpu/musashi/m68kcpu.h"
+#include <cpu/musashi/m68kcpu.h>
 extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
 #ifndef SekCyclesLeft
 #define SekCyclesLeft     PicoCpuMM68k.cyc_remaining_cycles
@@ -160,7 +159,7 @@ extern unsigned int SekCycleAimS68k;
 // ----------------------- Z80 CPU -----------------------
 
 #if defined(_USE_DRZ80)
-#include "../cpu/DrZ80/drz80.h"
+#include <cpu/DrZ80/drz80.h>
 
 extern struct DrZ80 drZ80;
 
@@ -175,7 +174,7 @@ extern struct DrZ80 drZ80;
 #define z80_pc()           (drZ80.Z80PC - drZ80.Z80PC_BASE)
 
 #elif defined(_USE_CZ80)
-#include "../cpu/cz80/cz80.h"
+#include <cpu/cz80/cz80.h>
 
 #define z80_run(cycles)    Cz80_Exec(&CZ80, cycles)
 #define z80_run_nr(cycles) Cz80_Exec(&CZ80, cycles)
@@ -209,7 +208,7 @@ extern struct DrZ80 drZ80;
 
 // ----------------------- SH2 CPU -----------------------
 
-#include "cpu/sh2/sh2.h"
+#include <cpu/sh2/sh2.h>
 
 extern SH2 sh2s[2];
 #define msh2 sh2s[0]
@@ -721,7 +720,7 @@ int load_cd_image(const char *cd_img_name, int *type);
 
 // cd/gfx.c
 void gfx_init(void);
-void gfx_start(unsigned int base);
+void gfx_start(u32 base);
 void gfx_update(unsigned int cycles);
 int gfx_context_save(unsigned char *state);
 int gfx_context_load(const unsigned char *state);

+ 1 - 1
pico/sek.c

@@ -270,7 +270,7 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
 
 /* idle loop detection, not to be used in CD mode */
 #ifdef EMU_C68K
-#include "cpu/cyclone/tools/idle.h"
+#include <cpu/cyclone/tools/idle.h>
 #endif
 
 static unsigned short **idledet_ptrs = NULL;

+ 1 - 1
pico/sound/mix.c

@@ -7,7 +7,7 @@
  * See COPYING file in the top-level directory.
  */
 
-#include "string.h"
+#include <string.h>
 
 #define MAXOUT		(+32767)
 #define MINOUT		(-32768)

+ 8 - 8
pico/sound/ym2612.h

@@ -6,16 +6,16 @@
 #define _H_FM_FM_
 
 /* compiler dependence */
-#include <stdint.h>
+#include "../pico_types.h"
 #ifndef UINT8
-typedef uint8_t		UINT8;   /* unsigned  8bit */
-typedef uint16_t	UINT16;  /* unsigned 16bit */
-typedef uint32_t	UINT32;  /* unsigned 32bit */
+typedef u8		UINT8;   /* unsigned  8bit */
+typedef u16		UINT16;  /* unsigned 16bit */
+typedef u32		UINT32;  /* unsigned 32bit */
 #endif
 #ifndef INT8
-typedef int8_t		INT8;    /* signed  8bit   */
-typedef int16_t		INT16;   /* signed 16bit   */
-typedef int32_t		INT32;   /* signed 32bit   */
+typedef s8		INT8;    /* signed  8bit   */
+typedef s16		INT16;   /* signed 16bit   */
+typedef s32		INT32;   /* signed 32bit   */
 #endif
 
 #if 1
@@ -183,7 +183,7 @@ int  YM2612PicoStateLoad2(int *tat, int *tbt);
 #define YM2612PicoStateLoad YM2612PicoStateLoad_
 #else
 /* GP2X specific */
-#include "../../platform/gp2x/940ctl.h"
+#include <platform/gp2x/940ctl.h>
 #define YM2612Init(baseclock,rate,ssg) do { \
 	if (PicoIn.opt&POPT_EXT_FM) YM2612Init_940(baseclock, rate, ssg); \
 	else               YM2612Init_(baseclock, rate, ssg); \

+ 1 - 1
pico/sound/ym2612_arm.S

@@ -13,7 +13,7 @@
 
 @ vim:filetype=armasm
 
-#include "../arm_features.h"
+#include <pico/arm_features.h>
 
 @ very simple YM2612 output rate to sample rate adaption (~500k cycles @44100)
 #define INTERPOL

+ 1 - 1
pico/state.c

@@ -9,7 +9,7 @@
 #include "pico_int.h"
 #include <zlib.h>
 
-#include "../cpu/sh2/sh2.h"
+#include <cpu/sh2/sh2.h>
 #include "sound/ym2612.h"
 #include "sound/emu2413/emu2413.h"
 #include "state.h"

+ 1 - 1
pico/videoport.c

@@ -22,7 +22,7 @@ static int blankline;           // display disabled for this line
 
 u32 SATaddr, SATmask;      // VRAM addr of sprite attribute table
 
-int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask) = NULL;
+int (*PicoDmaHook)(u32 source, int len, unsigned short **base, unsigned int *mask) = NULL;
 
 
 /* VDP FIFO implementation

+ 6 - 7
platform/common/main.c

@@ -96,10 +96,6 @@ int main(int argc, char *argv[])
 
 	emu_init();
 
-#ifdef GPERF
-	ProfilerStart("gperf.out");
-#endif
-
 	engineState = PGS_Menu;
 
 	if (argc > 1)
@@ -142,7 +138,13 @@ int main(int argc, char *argv[])
 				/* vvv fallthrough */
 
 			case PGS_Running:
+#ifdef GPERF
+	ProfilerStart("gperf.out");
+#endif
 				emu_loop();
+#ifdef GPERF
+	ProfilerStop();
+#endif
 				break;
 
 			case PGS_Quit:
@@ -155,9 +157,6 @@ int main(int argc, char *argv[])
 	}
 
 	endloop:
-#ifdef GPERF
-	ProfilerStop();
-#endif
 
 	emu_finish();
 	plat_finish();

+ 4 - 4
platform/common/menu_pico.c

@@ -55,15 +55,15 @@ static unsigned short fname2color(const char *fname)
 	return 0xffff;
 }
 
-#include "../libpicofe/menu.c"
+#include <platform/libpicofe/menu.c>
 
 static const char *men_dummy[] = { NULL };
 
 /* platform specific options and handlers */
 #if   defined(__GP2X__)
-#include "../gp2x/menu.c"
+#include <platform/gp2x/menu.c>
 #elif defined(PANDORA)
-#include "../pandora/menu.c"
+#include <platform/pandora/menu.c>
 #else
 #define MENU_OPTIONS_GFX
 #define MENU_OPTIONS_ADV
@@ -84,7 +84,7 @@ static void make_bg(int no_scale)
 
 	if (!no_scale && g_menuscreen_w / w >= 2 && g_menuscreen_h / h >= 2)
 	{
-		unsigned int t, *d = g_menubg_ptr;
+		u32 t, *d = g_menubg_ptr;
 		d += (g_menuscreen_h / 2 - h * 2 / 2)
 			* g_menuscreen_w / 2;
 		d += (g_menuscreen_w / 2 - w * 2 / 2) / 2;

+ 1 - 1
platform/common/plat_sdl.c

@@ -33,7 +33,7 @@ static struct in_pdata in_sdl_platform_data = {
 static int yuv_ry[32], yuv_gy[32], yuv_by[32];
 static unsigned char yuv_u[32 * 2], yuv_v[32 * 2];
 static unsigned char yuv_y[256];
-static struct uyvy {  unsigned int y:8; unsigned int vyu:24; } yuv_uyvy[65536];
+static struct uyvy { uint32_t y:8; uint32_t vyu:24; } yuv_uyvy[65536];
 
 void bgr_to_uyvy_init(void)
 {

+ 1 - 1
platform/gizmondo/emu.c

@@ -8,9 +8,9 @@
 #include "kgsdk/Framework2D.h"
 #include "kgsdk/FrameworkAudio.h"
 #include "../common/emu.h"
-#include "../common/lprintf.h"
 #include "../common/arm_utils.h"
 #include "../common/config.h"
+#include "../libpicofe/lprintf.h"
 #include "emu.h"
 #include "menu.h"
 #include "giz.h"

+ 1 - 1
platform/gizmondo/giz.c

@@ -11,7 +11,7 @@
 #include "kgsdk/Framework.h"
 #include "kgsdk/Framework2D.h"
 #include "giz.h"
-#include "version.h"
+#include "../common/version.h"
 
 #define LOG_FILE "log.log"
 

+ 1 - 1
platform/gizmondo/main.c

@@ -14,7 +14,7 @@
 #include "../common/menu.h"
 #include "../common/emu.h"
 #include "../common/config.h"
-#include "version.h"
+#include "../common/version.h"
 
 
 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)

+ 5 - 7
platform/gizmondo/menu.c

@@ -28,7 +28,7 @@
 #include "../common/emu.h"
 #include "../common/readpng.h"
 #include "../common/input.h"
-#include "version.h"
+#include "../common/version.h"
 
 #include <pico/pico_int.h>
 #include <pico/patch.h>
@@ -49,8 +49,6 @@ unsigned char *menu_screen = gfx_buffer; /* draw here and blit later, to avoid f
 void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
 static void menu_prepare_bg(int use_game_bg);
 
-static unsigned int inp_prev = 0;
-
 void menu_draw_begin(int use_bgbuff)
 {
 	if (use_bgbuff)
@@ -1457,14 +1455,14 @@ static void menu_loop_root(void)
 // warning: alignment
 void menu_darken_bg(void *dst, const void *src, int pixels, int darker)
 {
-	unsigned int *dest = dst;
-	const unsigned int *srce = src;
+	u32 *dest = dst;
+	const u32 *srce = src;
 	pixels /= 2;
 	if (darker)
 	{
 		while (pixels--)
 		{
-			unsigned int p = *srce++;
+			u32 p = *srce++;
 			*dest++ = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3);
 		}
 	}
@@ -1472,7 +1470,7 @@ void menu_darken_bg(void *dst, const void *src, int pixels, int darker)
 	{
 		while (pixels--)
 		{
-			unsigned int p = *srce++;
+			u32 p = *srce++;
 			*dest++ = (p&0xf79ef79e)>>1;
 		}
 	}

+ 3 - 3
platform/gp2x/940ctl.c

@@ -22,9 +22,9 @@
 #include "../common/arm_utils.h"
 #include "../common/menu_pico.h"
 #include "../common/emu.h"
-#include "../../pico/pico_int.h"
-#include "../../pico/sound/ym2612.h"
-#include "../../pico/sound/mix.h"
+#include <pico/pico_int.h>
+#include <pico/sound/ym2612.h>
+#include <pico/sound/mix.h>
 #include "code940/940shared.h"
 #include "plat.h"
 #include "940ctl.h"

+ 1 - 1
platform/gp2x/code940/940.c

@@ -2,7 +2,7 @@
 // (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas
 
 #include "940shared.h"
-#include "../../common/helix/pub/mp3dec.h"
+#include <platform/common/helix/pub/mp3dec.h>
 
 static _940_data_t *shared_data = (_940_data_t *)   0x00100000;
 static _940_ctl_t  *shared_ctl  = (_940_ctl_t *)    0x00200000;

+ 1 - 1
platform/gp2x/code940/940shared.h

@@ -1,4 +1,4 @@
-#include "../../../pico/sound/ym2612.h"
+#include <pico/sound/ym2612.h>
 
 // max 16 jobs, lower num means higher prio
 enum _940_job_t {

+ 1 - 4
platform/gp2x/code940/Makefile

@@ -14,7 +14,7 @@ CROSS ?= arm-linux-gnueabi-
 # settings
 #up = 1
 
-CFLAGS += -O2 -Wall -mno-thumb-interwork -fstrict-aliasing -ffast-math
+CFLAGS += -O3 -Wall -mno-thumb-interwork -fstrict-aliasing -fno-stack-protector -fno-common -ffast-math
 CFLAGS += -I../../common/helix/pub -I../../.. -I. -D__GP2X__ -DARM
 CFLAGS += -mcpu=arm940t -mtune=arm940t -mabi=apcs-gnu -mfloat-abi=soft -mfpu=fpa
 LDFLAGS = -static -e code940 -Ttext 0x0 -L$(lgcc_path) -lgcc
@@ -66,9 +66,6 @@ code940.elf : $(OBJS940) $(LIBHELIX)
 	@echo ">>>" $@
 	$(GCC) $(CFLAGS) -Os -DEXTERNAL_YM2612 -c $< -o $@
 
-mix.o : ../../../pico/sound/mix.s
-	@echo ">>>" $@
-	$(GCC) $(CFLAGS) -DEXTERNAL_YM2612 -c $< -o $@
 misc_arm.o : ../../../pico/misc_arm.s
 	@echo ">>>" $@
 	$(GCC) $(CFLAGS) -DEXTERNAL_YM2612 -c $< -o $@

+ 1 - 1
platform/gp2x/code940/mp3test.c

@@ -13,7 +13,7 @@
 //#include "emu.h"
 //#include "menu.h"
 #include "../asmutils.h"
-#include "../../helix/pub/mp3dec.h"
+#include <platform/common/helix/pub/mp3dec.h>
 
 /* we will need some gp2x internals here */
 extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */

+ 3 - 2
platform/libretro/libretro.c

@@ -17,7 +17,7 @@
 #ifndef _WIN32
 #ifndef NO_MMAP
 #ifdef __SWITCH__
-#include "../switch/mman.h"
+#include "switch/mman.h"
 #else
 #include <sys/mman.h>
 #endif
@@ -37,8 +37,9 @@
 #endif
 
 #if defined(RENDER_GSKIT_PS2)
+#include <malloc.h>
 #include "libretro-common/include/libretro_gskit_ps2.h"
-#include "../ps2/asm.h"
+#include "ps2/asm.h"
 #endif
 
 #ifdef _3DS

+ 0 - 0
platform/ps2/Draw_mips_r5900.s → platform/libretro/ps2/Draw_mips_r5900.s


+ 0 - 0
platform/ps2/Memory_mips_r5900.s → platform/libretro/ps2/Memory_mips_r5900.s


+ 0 - 0
platform/ps2/asm.h → platform/libretro/ps2/asm.h


+ 0 - 0
platform/ps2/asm.s → platform/libretro/ps2/asm.s


+ 0 - 0
platform/switch/mman.h → platform/libretro/switch/mman.h


+ 3 - 3
platform/linux/emu.c

@@ -47,9 +47,9 @@ static void draw_cd_leds(void)
 
 #define p(x) px[(x)*2 >> 2] = px[((x)*2 >> 2) + 1]
 	// 16-bit modes
-	unsigned int *px = (unsigned int *)((short *)g_screen_ptr + scr_offs);
-	unsigned int col_g = (led_reg & 2) ? 0x06000600 : 0;
-	unsigned int col_r = (led_reg & 1) ? 0xc000c000 : 0;
+	uint32_t *px = (uint32_t *)((short *)g_screen_ptr + scr_offs);
+	uint32_t col_g = (led_reg & 2) ? 0x06000600 : 0;
+	uint32_t col_r = (led_reg & 1) ? 0xc000c000 : 0;
 	p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;
 	p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;
 #undef p

+ 1 - 1
platform/linux/io.c

@@ -13,7 +13,7 @@
 #include "../libpicofe/input.h"
 #include "../common/emu.h"
 #include "../common/input_pico.h"
-#include "version.h"
+#include "../common/version.h"
 
 #include "log_io.h"
 

+ 0 - 1
platform/psp/emu.c

@@ -23,7 +23,6 @@
 #include "asm_utils.h"
 #include "../common/emu.h"
 #include "../common/config.h"
-#include "../common/lprintf.h"
 #include <pico/pico_int.h>
 #include <pico/cd/cue.h>
 

+ 1 - 1
platform/psp/main.c

@@ -14,7 +14,7 @@
 #include "../common/menu.h"
 #include "../common/emu.h"
 #include "../common/config.h"
-#include "../common/lprintf.h"
+#include "../libpicofe/lprintf.h"
 
 #ifdef GPROF
 #include <pspprof.h>

+ 1 - 4
platform/psp/menu.c

@@ -27,9 +27,8 @@
 #include "../common/menu.h"
 #include "../common/emu.h"
 #include "../common/readpng.h"
-#include "../common/lprintf.h"
 #include "../common/input.h"
-#include "version.h"
+#include "../common/version.h"
 
 #include <pico/pico_int.h>
 #include <pico/patch.h>
@@ -51,8 +50,6 @@ void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
 static void menu_prepare_bg(int use_game_bg, int use_fg);
 
 
-static unsigned int inp_prev = 0;
-
 void menu_draw_begin(void)
 {
 	// short *src = (short *)bg_buffer, *dst = (short *)menu_screen;

+ 3 - 3
platform/psp/mp3.c

@@ -14,9 +14,9 @@
 #include <pspaudiocodec.h>
 #include <kubridge.h>
 
-#include "../../pico/pico_int.h"
-#include "../../pico/sound/mix.h"
-#include "../common/lprintf.h"
+#include <pico/pico_int.h>
+#include <pico/sound/mix.h>
+#include "../libpicofe/lprintf.h"
 
 int mp3_last_error = 0;
 

+ 2 - 2
platform/psp/psp.c

@@ -21,8 +21,8 @@
 
 #include "psp.h"
 #include "emu.h"
-#include "../common/lprintf.h"
-#include "version.h"
+#include <pico/pico_int.h>
+#include "../common/version.h"
 
 extern int pico_main(void);
 

+ 2 - 3
platform/win32/main.c

@@ -2,15 +2,14 @@
 #include <commdlg.h>
 #include <stdio.h>
 
-#include "../../pico/pico.h"
+#include <pico/pico.h>
 #include "../common/readpng.h"
 #include "../common/config.h"
-#include "../common/lprintf.h"
 #include "../common/emu.h"
 #include "../common/menu.h"
 #include "../common/input.h"
 #include "../common/plat.h"
-#include "version.h"
+#include "../common/version.h"
 #include "direct.h"
 #include "in_vk.h"
 

+ 2 - 3
platform/win32/plat.c

@@ -8,11 +8,10 @@
 #include <windows.h>
 #include <stdio.h>
 
-#include "../common/lprintf.h"
 #include "../common/plat.h"
 #include "../common/emu.h"
-#include "../../pico/pico.h"
-#include "version.h"
+#include "../common/version.h"
+#include <pico/pico.h>
 #include "direct.h"
 #include "dsnd.h"
 #include "main.h"

+ 9 - 8
tools/bin_to_cso_mp3/bin_to_cso_mp3.c

@@ -10,6 +10,7 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <ctype.h>
+#include <stdint.h>
 
 #ifndef MAX_PATH
 #define MAX_PATH 1024
@@ -34,14 +35,14 @@
 
 #define LAME_OPTIONS "-h --cbr"
 
-typedef unsigned char u8;
-typedef unsigned short int u16;
-typedef unsigned int u32;
-typedef unsigned long long int u64;
-typedef signed char s8;
-typedef signed short int s16;
-typedef signed int s32;
-typedef signed long long int s64;
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+typedef int8_t s8;
+typedef int16_t s16;
+typedef int32_t s32;
+typedef int64_t s64;
 
 typedef enum
 {

+ 1 - 1
tools/drctest.c

@@ -3,7 +3,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "cpu/sh2/compiler.c"
+#include <cpu/sh2/compiler.c>
 
 struct Pico Pico;
 SH2 sh2s[2];

+ 1 - 1
tools/mkoffsets.c

@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stddef.h>
 
-#include "../pico/pico_int.h"
+#include <pico/pico_int.h>
 
 #define DUMP(f, prefix, type, field) \
   fprintf(f, "#define %-20s 0x%02x\n", \

+ 1 - 1
tools/mkoffsets.sh

@@ -103,7 +103,7 @@ get_define () # prefix struct member member...
 	field=$(echo $* | sed 's/ /./g')
 	name=$(echo $* | sed 's/ /_/g')
 	echo '#include <stdint.h>' > /tmp/getoffs.c
-	echo '#include "pico/pico_int.h"' >> /tmp/getoffs.c
+	echo '#include <pico/pico_int.h>' >> /tmp/getoffs.c
 	echo "static struct $struct p;" >> /tmp/getoffs.c
 	echo "const int32_t val = (char *)&p.$field - (char*)&p;" >>/tmp/getoffs.c
 	compile_rodata