summaryrefslogtreecommitdiff
path: root/gp2x
diff options
context:
space:
mode:
Diffstat (limited to 'gp2x')
-rw-r--r--gp2x/Makefile87
-rw-r--r--gp2x/gp2x.c545
-rw-r--r--gp2x/gp2x.h62
-rwxr-xr-xgp2x/gpsp_caanoo.gpe9
-rw-r--r--gp2x/gpsp_caanoo.ini4
-rw-r--r--gp2x/pollux_dpc_set.c168
-rw-r--r--gp2x/pollux_dpc_set.h10
-rw-r--r--gp2x/readme_gp2x.txt340
-rw-r--r--gp2x/test/align_test.c48
-rw-r--r--gp2x/test/load_imm_test.c135
-rw-r--r--gp2x/upscale_aspect.s579
11 files changed, 0 insertions, 1987 deletions
diff --git a/gp2x/Makefile b/gp2x/Makefile
deleted file mode 100644
index 5e8a906..0000000
--- a/gp2x/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-# gpSP makefile
-# Gilead Kutnick - Exophase
-# GP2X port(ion) - Z
-
-# Global definitions
-
-CC = $(CROSS_COMPILE)gcc
-
-OBJS = main.o cpu.o memory.u video.o input.o sound.o gp2x.o gui.o \
- cheats.o zip.o cpu_threaded.z arm_stub.o video_blend.o \
- warm.o upscale_aspect.o
-ifeq ($(WIZ),1)
-POLLUX = 1
-OBJS += pollux_dpc_set.o
-BIN = gpsp_wiz
-endif
-ifeq ($(CAANOO),1)
-POLLUX = 1
-OBJS += pollux_dpc_set.o
-BIN = gpsp_caanoo
-endif
-ifeq ($(BIN),)
-BIN = gpsp_gp2x
-endif
-
--include Makefile.local
-
-# Platform specific definitions
-
-VPATH += .. ../arm
-CFLAGS += -DARM_ARCH -DGP2X_BUILD
-ifeq ($(WIZ),1)
-CFLAGS += -DWIZ_BUILD
-endif
-ifeq ($(POLLUX),1)
-CFLAGS += -DPOLLUX_BUILD
-endif
-CFLAGS += -std=c99 -msoft-float -funsigned-char -Wall -ggdb
-ifndef DEBUG
-CFLAGS += -O2
-endif
-
-INCLUDES = `sdl-config --cflags`
-LIBS = `sdl-config --libs` \
- -lm -ldl -lpthread -lz
-ifeq ($(WIZ)$(CAANOO),)
-LIBS += -static
-endif
-
-# Compilation:
-
-.SUFFIXES: .c
-
-all: $(BIN)
-
-cpu.o cpu_threaded.z: CFLAGS += -Wno-unused-variable -Wno-unused-label
-
-%.z: %.c
- $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
-
-%.u: %.c
- $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
-
-%.o: %.c
- $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
-
-%.o: %.S
- $(CC) $(ASFLAGS) $(INCLUDES) -c -o $@ $<
-
-%.o: %.s
- $(CC) $(ASFLAGS) $(INCLUDES) -c -o $@ $<
-
-$(BIN): $(OBJS)
- $(CC) $(OBJS) $(LIBS) -o $(BIN)
-
-clean:
- rm -f *.o *.u *.z $(BIN)
-
-rel: gpsp_caanoo gpsp_caanoo.ini gpsp_caanoo.gpe warm_2.6.24.ko \
- ../COPYING.DOC ../readme.txt readme_gp2x.txt ../game_config.txt
- rm -rf out
- mkdir -p out/gpsp_caanoo
- cp $^ out/gpsp_caanoo/
- mv out/gpsp_caanoo/gpsp_caanoo.ini out/
- mv out/gpsp_caanoo/readme_gp2x.txt out/gpsp_caanoo/readme_caanoo.txt
- echo -n '/mnt/sd' > out/gpsp_caanoo/romdir.txt
- cd out && zip -9 -r ../gpsp_caanoo.zip *
diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c
deleted file mode 100644
index b80315c..0000000
--- a/gp2x/gp2x.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- Parts used from cpuctrl, Copyright (C) 2005 Hermes/PS2Reality
- Portions Copyright (C) 2009 notaz
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-
-#define _GNU_SOURCE 1
-#include "../common.h"
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/soundcard.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <linux/input.h>
-#include "gp2x.h"
-#include "pollux_dpc_set.h"
-
-static u32 gpsp_gp2x_dev_audio;
-static u32 gpsp_gp2x_dev;
-#ifdef POLLUX_BUILD
-static u32 gpsp_gp2x_indev;
-static u32 saved_405c, saved_4060, saved_4058;
-#endif
-
-static u32 gp2x_audio_volume = 74/2;
-
-static volatile u16 *gpsp_gp2x_memregs;
-static volatile u32 *gpsp_gp2x_memregl;
-
-u32 button_plat_mask_to_config[PLAT_BUTTON_COUNT] =
-{
- GP2X_UP,
- GP2X_LEFT,
- GP2X_DOWN,
- GP2X_RIGHT,
- GP2X_START,
- GP2X_SELECT,
- GP2X_L,
- GP2X_R,
- GP2X_A,
- GP2X_B,
- GP2X_X,
- GP2X_Y,
-#if defined(POLLUX_BUILD) && !defined(WIZ_BUILD)
- 0,
- 0,
- GP2X_PUSH,
- GP2X_HOME,
-#else
- GP2X_VOL_DOWN,
- GP2X_VOL_UP,
- GP2X_PUSH,
- GP2X_VOL_MIDDLE
-#endif
-};
-
-u32 gamepad_config_map[PLAT_BUTTON_COUNT] =
-{
- BUTTON_ID_UP, // Up
- BUTTON_ID_LEFT, // Left
- BUTTON_ID_DOWN, // Down
- BUTTON_ID_RIGHT, // Right
- BUTTON_ID_START, // Start
- BUTTON_ID_SELECT, // Select
- BUTTON_ID_L, // Ltrigger
- BUTTON_ID_R, // Rtrigger
- BUTTON_ID_FPS, // A
- BUTTON_ID_A, // B
- BUTTON_ID_B, // X
- BUTTON_ID_MENU, // Y
- BUTTON_ID_VOLDOWN, // Vol down
- BUTTON_ID_VOLUP, // Vol up
- BUTTON_ID_FPS, // Push
- BUTTON_ID_MENU // Vol middle / Home
-};
-
-#ifdef POLLUX_BUILD
-#include <linux/fb.h>
-void *gpsp_gp2x_screen;
-#define fb_buf_count 4
-static u32 fb_paddr[fb_buf_count];
-static void *fb_vaddr[fb_buf_count];
-static u32 fb_work_buf;
-static int fb_buf_use;
-static int fbdev;
-
-static void fb_video_init()
-{
- struct fb_fix_screeninfo fbfix;
- unsigned int r;
- int i, ret;
-
- fbdev = open("/dev/fb0", O_RDWR);
- if (fbdev < 0) {
- perror("can't open fbdev");
- exit(1);
- }
-
- ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
- if (ret == -1)
- {
- perror("ioctl(fbdev) failed");
- exit(1);
- }
-
- printf("framebuffer: \"%s\" @ %08lx\n", fbfix.id, fbfix.smem_start);
- fb_paddr[0] = fbfix.smem_start;
-
- fb_vaddr[0] = mmap(0, 320*240*2*fb_buf_count, PROT_READ|PROT_WRITE,
- MAP_SHARED, gpsp_gp2x_dev, fb_paddr[0]);
- if (fb_vaddr[0] == MAP_FAILED)
- {
- perror("mmap(fb_vaddr) failed");
- exit(1);
- }
- memset(fb_vaddr[0], 0, 320*240*2*fb_buf_count);
-
- printf(" %p -> %08x\n", fb_vaddr[0], fb_paddr[0]);
- for (i = 1; i < fb_buf_count; i++)
- {
- fb_paddr[i] = fb_paddr[i-1] + 320*240*2;
- fb_vaddr[i] = (char *)fb_vaddr[i-1] + 320*240*2;
- printf(" %p -> %08x\n", fb_vaddr[i], fb_paddr[i]);
- }
- fb_work_buf = 0;
- fb_buf_use = fb_buf_count;
-
- saved_405c = gpsp_gp2x_memregl[0x405c>>2];
- saved_4060 = gpsp_gp2x_memregl[0x4060>>2];
- saved_4058 = gpsp_gp2x_memregl[0x4058>>2];
-
- // set mode; program both MLCs so that TV-out works
- gpsp_gp2x_memregl[0x405c>>2] = gpsp_gp2x_memregl[0x445c>>2] = 2;
- gpsp_gp2x_memregl[0x4060>>2] = gpsp_gp2x_memregl[0x4460>>2] = 320 * 2;
-
- r = gpsp_gp2x_memregl[0x4058>>2];
- r = (r & 0xffff) | (0x4432 << 16) | 0x10;
- gpsp_gp2x_memregl[0x4058>>2] = r;
-
- r = gpsp_gp2x_memregl[0x4458>>2];
- r = (r & 0xffff) | (0x4432 << 16) | 0x10;
- gpsp_gp2x_memregl[0x4458>>2] = r;
-
- pollux_video_flip();
- warm_change_cb_upper(WCB_C_BIT|WCB_B_BIT, 1);
-}
-
-void pollux_video_flip()
-{
- gpsp_gp2x_memregl[0x406C>>2] =
- gpsp_gp2x_memregl[0x446C>>2] = fb_paddr[fb_work_buf];
- gpsp_gp2x_memregl[0x4058>>2] |= 0x10;
- gpsp_gp2x_memregl[0x4458>>2] |= 0x10;
- fb_work_buf++;
- if (fb_work_buf >= fb_buf_use)
- fb_work_buf = 0;
- gpsp_gp2x_screen = fb_vaddr[fb_work_buf];
-}
-
-void fb_use_buffers(int count)
-{
- if (count < 1)
- count = 1;
- else if (count > fb_buf_count)
- count = fb_buf_count;
- fb_buf_use = count;
- memset(fb_vaddr[0], 0, 320*240*2*count);
-}
-
-void wiz_lcd_set_portrait(int y)
-{
- char *dpc_settings;
-#ifdef WIZ_BUILD
- static int old_y = -1;
- int cmd[2] = { 0, 0 };
-
- if (old_y == y)
- return;
- cmd[0] = y ? 6 : 5;
- ioctl(fbdev, _IOW('D', 90, int[2]), cmd);
- gpsp_gp2x_memregl[0x4004>>2] = y ? 0x013f00ef : 0x00ef013f;
- gpsp_gp2x_memregl[0x4000>>2] |= 1 << 3;
- old_y = y;
-
- /* the above ioctl resets LCD timings, so set them here */
-#endif
-
- dpc_settings = getenv("pollux_dpc_set");
- if (dpc_settings != NULL)
- pollux_dpc_set(gpsp_gp2x_memregs, dpc_settings);
-}
-
-static void fb_video_exit()
-{
- /* switch to default fb mem, turn portrait off */
- gpsp_gp2x_memregl[0x406c>>2] = fb_paddr[0];
- gpsp_gp2x_memregl[0x405c>>2] = saved_405c;
- gpsp_gp2x_memregl[0x4060>>2] = saved_4060;
- gpsp_gp2x_memregl[0x4058>>2] = saved_4058 | 0x10;
- wiz_lcd_set_portrait(0);
- close(fbdev);
-}
-
-static int wiz_gamepak_fd = -1;
-static u32 wiz_gamepak_size;
-
-static void wiz_gamepak_cleanup()
-{
- if (wiz_gamepak_size)
- munmap(gamepak_rom, wiz_gamepak_size);
- if (wiz_gamepak_fd >= 0)
- close(wiz_gamepak_fd);
- gamepak_rom = NULL;
- wiz_gamepak_size = 0;
- wiz_gamepak_fd = -1;
-}
-
-u32 wiz_load_gamepak(char *name)
-{
- char *dot_position = strrchr(name, '.');
- u32 ret;
-
- if (!strcasecmp(dot_position, ".zip"))
- {
- if (wiz_gamepak_fd >= 0)
- {
- wiz_gamepak_cleanup();
- printf("switching to ROM malloc\n");
- init_gamepak_buffer();
- }
- return load_file_zip(name);
- }
-
- if (wiz_gamepak_fd < 0)
- {
- extern void *gamepak_memory_map;
- free(gamepak_rom);
- free(gamepak_memory_map);
- gamepak_memory_map = NULL;
- printf("switching to ROM mmap\n");
- }
- else
- wiz_gamepak_cleanup();
-
- wiz_gamepak_fd = open(name, O_RDONLY|O_NOATIME, S_IRUSR);
- if (wiz_gamepak_fd < 0)
- {
- perror("wiz_load_gamepak: open failed");
- return -1;
- }
-
- ret = lseek(wiz_gamepak_fd, 0, SEEK_END);
- wiz_gamepak_size = gamepak_ram_buffer_size = ret;
-
- gamepak_rom = mmap(0, ret, PROT_READ, MAP_SHARED, wiz_gamepak_fd, 0);
- if (gamepak_rom == MAP_FAILED)
- {
- perror("wiz_load_gamepak: mmap failed");
- return -1;
- }
-
- return ret;
-}
-
-#define KEYBITS_BIT(x) (keybits[(x)/sizeof(keybits[0])/8] & \
- (1 << ((x) & (sizeof(keybits[0])*8-1))))
-
-static int abs_min, abs_max, lzone_step;
-
-static int open_caanoo_pad(void)
-{
- long keybits[KEY_CNT / sizeof(long) / 8];
- long absbits[(ABS_MAX+1) / sizeof(long) / 8];
- struct input_absinfo ainfo;
- int fd = -1, i;
-
- memset(keybits, 0, sizeof(keybits));
- memset(absbits, 0, sizeof(absbits));
-
- for (i = 0;; i++)
- {
- int support = 0, need;
- int ret;
- char name[64];
-
- snprintf(name, sizeof(name), "/dev/input/event%d", i);
- fd = open(name, O_RDONLY|O_NONBLOCK);
- if (fd == -1)
- break;
-
- /* check supported events */
- ret = ioctl(fd, EVIOCGBIT(0, sizeof(support)), &support);
- if (ret == -1) {
- printf("in_evdev: ioctl failed on %s\n", name);
- goto skip;
- }
-
- need = (1 << EV_KEY) | (1 << EV_ABS);
- if ((support & need) != need)
- goto skip;
-
- ret = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits);
- if (ret == -1) {
- printf("in_evdev: ioctl failed on %s\n", name);
- goto skip;
- }
-
- if (!KEYBITS_BIT(BTN_JOYSTICK))
- goto skip;
-
- ret = ioctl(fd, EVIOCGABS(ABS_X), &ainfo);
- if (ret == -1)
- goto skip;
-
- abs_min = ainfo.minimum;
- abs_max = ainfo.maximum;
- lzone_step = (abs_max - abs_min) / 2 / 9;
-
- ioctl(fd, EVIOCGNAME(sizeof(name)), name);
- printf("using \"%s\" (type %08x)\n", name, support);
- break;
-
-skip:
- close(fd);
- fd = -1;
- }
-
- if (fd == -1) {
- printf("missing input device\n");
- exit(1);
- }
-
- return fd;
-}
-#endif // POLLUX_BUILD
-
-void gpsp_plat_init(void)
-{
- gpsp_gp2x_dev = open("/dev/mem", O_RDWR);
- gpsp_gp2x_dev_audio = open("/dev/mixer", O_RDWR);
- gpsp_gp2x_memregl = (u32 *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED,
- gpsp_gp2x_dev, 0xc0000000);
- gpsp_gp2x_memregs = (u16 *)gpsp_gp2x_memregl;
- warm_init();
-#ifdef POLLUX_BUILD
-#ifdef WIZ_BUILD
- gpsp_gp2x_indev = open("/dev/GPIO", O_RDONLY);
-#else
- gpsp_gp2x_indev = open_caanoo_pad();
-#endif
- fb_video_init();
- (void)open_caanoo_pad;
-#endif
-
- gp2x_sound_volume(1);
-}
-
-void gpsp_plat_quit(void)
-{
- chdir(main_path);
-
- warm_finish();
-#ifdef POLLUX_BUILD
- wiz_gamepak_cleanup();
- close(gpsp_gp2x_indev);
- fb_video_exit();
-#endif
- munmap((void *)gpsp_gp2x_memregl, 0x10000);
- close(gpsp_gp2x_dev_audio);
- close(gpsp_gp2x_dev);
-
- fcloseall();
- sync();
- exit(0);
-}
-
-void gp2x_sound_volume(u32 volume_up)
-{
- u32 volume;
- if((volume_up == 0) && (gp2x_audio_volume > 0))
- gp2x_audio_volume--;
-
- if((volume_up != 0) && (gp2x_audio_volume < 100))
- gp2x_audio_volume++;
-
- volume = (gp2x_audio_volume * 0x50) / 100;
- volume = (gp2x_audio_volume << 8) | gp2x_audio_volume;
- ioctl(gpsp_gp2x_dev_audio, SOUND_MIXER_WRITE_PCM, &volume);
-}
-
-u32 gpsp_plat_joystick_read(void)
-{
-#ifdef WIZ_BUILD
- u32 value = 0;
- read(gpsp_gp2x_indev, &value, 4);
- if(value & 0x02)
- value |= 0x05;
- if(value & 0x08)
- value |= 0x14;
- if(value & 0x20)
- value |= 0x50;
- if(value & 0x80)
- value |= 0x41;
- return value;
-#elif defined(POLLUX_BUILD)
- // caanoo
- static const int evdev_to_gp2x[] = {
- GP2X_A, GP2X_X, GP2X_B, GP2X_Y, GP2X_L, GP2X_R,
- GP2X_HOME, 0, GP2X_START, GP2X_SELECT, GP2X_PUSH
- };
- int keybits[KEY_CNT / sizeof(int)];
- struct input_absinfo ainfo;
- int lzone = analog_sensitivity_level * lzone_step;
- u32 retval = 0;
- int i, ret;
-
- ret = ioctl(gpsp_gp2x_indev, EVIOCGKEY(sizeof(keybits)), keybits);
- if (ret == -1) {
- perror("EVIOCGKEY ioctl failed");
- sleep(1);
- return 0;
- }
-
- for (i = 0; i < sizeof(evdev_to_gp2x) / sizeof(evdev_to_gp2x[0]); i++) {
- if (KEYBITS_BIT(BTN_TRIGGER + i))
- retval |= evdev_to_gp2x[i];
- }
-
- if (lzone != 0)
- lzone--;
-
- ret = ioctl(gpsp_gp2x_indev, EVIOCGABS(ABS_X), &ainfo);
- if (ret != -1) {
- if (ainfo.value <= abs_min + lzone) retval |= GP2X_LEFT;
- else if (ainfo.value >= abs_max - lzone) retval |= GP2X_RIGHT;
- }
- ret = ioctl(gpsp_gp2x_indev, EVIOCGABS(ABS_Y), &ainfo);
- if (ret != -1) {
- if (ainfo.value <= abs_min + lzone) retval |= GP2X_UP;
- else if (ainfo.value >= abs_max - lzone) retval |= GP2X_DOWN;
- }
-
- return retval;
-#else
- // GP2X
- u32 value = (gpsp_gp2x_memregs[0x1198 >> 1] & 0x00FF);
-
- if(value == 0xFD)
- value = 0xFA;
- if(value == 0xF7)
- value = 0xEB;
- if(value == 0xDF)
- value = 0xAF;
- if(value == 0x7F)
- value = 0xBE;
-
- return ~((gpsp_gp2x_memregs[0x1184 >> 1] & 0xFF00) | value |
- (gpsp_gp2x_memregs[0x1186 >> 1] << 16));
-#endif
-}
-
-u32 gpsp_plat_buttons_to_cursor(u32 buttons)
-{
- gui_action_type new_button = CURSOR_NONE;
-
- if(buttons & GP2X_A)
- new_button = CURSOR_BACK;
-
- if(buttons & GP2X_X)
- new_button = CURSOR_EXIT;
-
- if(buttons & GP2X_B)
- new_button = CURSOR_SELECT;
-
- if(buttons & GP2X_UP)
- new_button = CURSOR_UP;
-
- if(buttons & GP2X_DOWN)
- new_button = CURSOR_DOWN;
-
- if(buttons & GP2X_LEFT)
- new_button = CURSOR_LEFT;
-
- if(buttons & GP2X_RIGHT)
- new_button = CURSOR_RIGHT;
-
- if(buttons & GP2X_L)
- new_button = CURSOR_L;
-
- if(buttons & GP2X_R)
- new_button = CURSOR_R;
-
- return new_button;
-}
-
-// Fout = (m * Fin) / (p * 2^s)
-void set_FCLK(u32 MHZ)
-{
- u32 v;
- u32 mdiv, pdiv, sdiv = 0;
-#ifdef POLLUX_BUILD
- int i;
- #define SYS_CLK_FREQ 27
- // m = MDIV, p = PDIV, s = SDIV
- pdiv = 9;
- mdiv = (MHZ * pdiv) / SYS_CLK_FREQ;
- if (mdiv & ~0x3ff)
- return;
- v = (pdiv<<18) | (mdiv<<8) | sdiv;
-
- gpsp_gp2x_memregl[0xf004>>2] = v;
- gpsp_gp2x_memregl[0xf07c>>2] |= 0x8000;
- for (i = 0; (gpsp_gp2x_memregl[0xf07c>>2] & 0x8000) && i < 0x100000; i++)
- ;
-
- // must restart sound as it's PLL is shared with CPU one
- sound_exit();
- init_sound(0);
-#else
- #define SYS_CLK_FREQ 7372800
- // m = MDIV + 8, p = PDIV + 2, s = SDIV
- pdiv = 3;
- mdiv = (MHZ * pdiv * 1000000) / SYS_CLK_FREQ;
- mdiv &= 0xff;
- v = ((mdiv-8)<<8) | ((pdiv-2)<<2) | sdiv;
- gpsp_gp2x_memregs[0x910>>1] = v;
-#endif
-}
-
diff --git a/gp2x/gp2x.h b/gp2x/gp2x.h
deleted file mode 100644
index 9a72eae..0000000
--- a/gp2x/gp2x.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef GP2X_H
-#define GP2X_H
-
-enum
-{
- GP2X_UP = 1 << 0,
- GP2X_LEFT = 1 << 2,
- GP2X_DOWN = 1 << 4,
- GP2X_RIGHT = 1 << 6,
- GP2X_START = 1 << 8, // Wiz: Menu, Caanoo: I
- GP2X_SELECT = 1 << 9, // Caanoo: II
- GP2X_L = 1 << 10,
- GP2X_R = 1 << 11,
- GP2X_A = 1 << 12,
- GP2X_B = 1 << 13,
- GP2X_X = 1 << 14,
- GP2X_Y = 1 << 15,
-#ifdef WIZ_BUILD
- GP2X_VOL_UP = 1 << 16,
- GP2X_VOL_DOWN = 1 << 17,
- GP2X_PUSH = 1 << 18,
-#elif defined(POLLUX_BUILD)
- GP2X_HOME = 1 << 16,
- GP2X_PUSH = 1 << 17,
- GP2X_VOL_UP = 1 << 30, // dummy
- GP2X_VOL_DOWN = 1 << 29,
-#else
- GP2X_VOL_DOWN = 1 << 22,
- GP2X_VOL_UP = 1 << 23,
- GP2X_PUSH = 1 << 27,
-#endif
- GP2X_VOL_MIDDLE = (1 << 24), // fake, menu enter
-};
-
-void gpsp_plat_init(void);
-void gpsp_plat_quit(void);
-
-u32 gpsp_plat_joystick_read(void);
-u32 gpsp_plat_buttons_to_cursor(u32 buttons);
-
-#define PLAT_BUTTON_COUNT 16
-#define PLAT_MENU_BUTTON 15
-extern u32 button_plat_mask_to_config[PLAT_BUTTON_COUNT];
-
-void gp2x_sound_volume(u32 volume_up);
-void gp2x_quit();
-
-void set_FCLK(u32 MHZ);
-
-void upscale_aspect(u16 *dst, u16 *src);
-
-/* wiz only */
-extern void *gpsp_gp2x_screen;
-void fb_use_buffers(int count);
-void pollux_video_flip();
-void wiz_lcd_set_portrait(int y);
-u32 wiz_load_gamepak(char *name);
-
-void do_rotated_blit(void *dst, void *linesx4, u32 y);
-void upscale_aspect_row(void *dst, void *linesx3, u32 row);
-
-#endif
diff --git a/gp2x/gpsp_caanoo.gpe b/gp2x/gpsp_caanoo.gpe
deleted file mode 100755
index 288ca4b..0000000
--- a/gp2x/gpsp_caanoo.gpe
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-# if you know good LCD settings, set them here
-# export pollux_dpc_set='lcd_timings=397,1,37,277,341,0,17,337;clkdiv0=9'
-
-./gpsp_caanoo "$@"
-
-cd /usr/gp2x
-exec ./gp2xmenu
diff --git a/gp2x/gpsp_caanoo.ini b/gp2x/gpsp_caanoo.ini
deleted file mode 100644
index 251ada4..0000000
--- a/gp2x/gpsp_caanoo.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[info]
-name="gpSP Caanoo"
-path="/gpsp_caanoo/gpsp_caanoo.gpe"
-group="GAMES"
diff --git a/gp2x/pollux_dpc_set.c b/gp2x/pollux_dpc_set.c
deleted file mode 100644
index beddc21..0000000
--- a/gp2x/pollux_dpc_set.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * quick tool to set LCD timings for Wiz
- * (c) notaz, 2009
- * code dedicated to public domain.
- *
- * HTOTAL: X VTOTAL: 341
- * HSWIDTH: 1 VSWIDTH: 0
- * HASTART: 37 VASTART: 17
- * HAEND: 277 VAEND: 337
- *
- * 120Hz
- * pcd 8, 447: + 594us
- * pcd 9, 397: + 36us
- * pcd 10, 357: - 523us
- * pcd 11, 325: +1153us
- *
- * 'lcd_timings=397,1,37,277,341,0,17,337;clkdiv0=9'
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "pollux_dpc_set.h"
-
-/*
- * set LCD timings based on preformated string (see usage() below for params).
- * returns 0 on success.
- */
-int pollux_dpc_set(volatile unsigned short *memregs, const char *str)
-{
- int timings[8], have_timings = 0;
- int pcd = 0, have_pcd = 0;
- const char *p;
- int i, ret;
-
- if (str == NULL)
- return -1;
-
- p = str;
- while (1)
- {
- if (strncmp(p, "lcd_timings=", 12) == 0)
- {
- int c;
- p += 12;
- ret = sscanf(p, "%d,%d,%d,%d,%d,%d,%d,%d",
- &timings[0], &timings[1], &timings[2], &timings[3],
- &timings[4], &timings[5], &timings[6], &timings[7]);
- if (ret != 8)
- break;
- /* skip seven commas */
- for (c = 0; c < 7 && *p != 0; p++)
- if (*p == ',')
- c++;
- if (c != 7)
- break;
- /* skip last number */
- while ('0' <= *p && *p <= '9')
- p++;
- have_timings = 1;
- }
- else if (strncmp(p, "clkdiv0=", 8) == 0)
- {
- char *ep;
- p += 8;
- pcd = strtoul(p, &ep, 10);
- if (p == ep)
- break;
- p = ep;
- have_pcd = 1;
- }
- else
- break;
-
- while (*p == ';' || *p == ' ')
- p++;
- if (*p == 0)
- goto parse_done;
- }
-
- fprintf(stderr, "dpc_set parser: error at '%s'\n", p);
- return -1;
-
-parse_done:
- /* some validation */
- if (have_timings)
- {
- for (i = 0; i < 8; i++)
- if (timings[i] & ~0xffff) {
- fprintf(stderr, "dpc_set: invalid timing %d: %d\n", i, timings[i]);
- return -1;
- }
- }
-
- if (have_pcd)
- {
- if ((pcd - 1) & ~0x3f) {
- fprintf(stderr, "dpc_set: invalid clkdiv0: %d\n", pcd);
- return -1;
- }
- }
-
- /* write */
- if (have_timings)
- {
- for (i = 0; i < 8; i++)
- memregs[(0x307c>>1) + i] = timings[i];
- }
-
- if (have_pcd)
- {
- int tmp;
- pcd = (pcd - 1) & 0x3f;
- tmp = memregs[0x31c4>>1];
- memregs[0x31c4>>1] = (tmp & ~0x3f0) | (pcd << 4);
- }
-
- return 0;
-}
-
-#ifdef BINARY
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-static void usage(const char *binary)
-{
- printf("usage:\n%s <set_str[;set_str[;...]]>\n"
- "set_str:\n"
- " lcd_timings=<htotal,hswidth,hastart,haend,vtotal,vswidth,vastart,vaend>\n"
- " clkdiv0=<divider>\n", binary);
-}
-
-int main(int argc, char *argv[])
-{
- volatile unsigned short *memregs;
- int ret, memdev;
-
- if (argc != 2) {
- usage(argv[0]);
- return 1;
- }
-
- memdev = open("/dev/mem", O_RDWR);
- if (memdev == -1)
- {
- perror("open(/dev/mem) failed");
- return 1;
- }
-
- memregs = mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000);
- if (memregs == MAP_FAILED)
- {
- perror("mmap(memregs) failed");
- close(memdev);
- return 1;
- }
-
- ret = pollux_dpc_set(memregs, argv[1]);
-
- munmap((void *)memregs, 0x10000);
- close(memdev);
-
- return ret;
-}
-#endif
diff --git a/gp2x/pollux_dpc_set.h b/gp2x/pollux_dpc_set.h
deleted file mode 100644
index 53155d1..0000000
--- a/gp2x/pollux_dpc_set.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-int pollux_dpc_set(volatile unsigned short *memregs, const char *str);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/gp2x/readme_gp2x.txt b/gp2x/readme_gp2x.txt
deleted file mode 100644
index 26a5a87..0000000
--- a/gp2x/readme_gp2x.txt
+++ /dev/null
@@ -1,340 +0,0 @@
--- porter's foreword --
-
-Even though ZX-81 ported my Wiz version to Caanoo, some people kept
-asking me to do the port instead because of apparent sound problems,
-so here it is. Note that I did not use ZX-81's work for this release,
-because I had various changes for Pandora version and wanted to have
-them in, so different set of bugs then in ZX-81's version are
-possible. Savestates might also be incompatible.
-
-To use this, you'll first need to copy authentic GBA BIOS to gpSP
-directory. It must be named gba_bios.bin and should be 16kB in size.
-
-I've appended the original gpSP GP2X readme file as it contains lots
-of information that is still relevant for this version, as well as
-development history of this project.
-
-- notaz
-
-Changelog:
-
-0.9-2xb u8
-- Caanoo port
-- fixed tv-out for pandora
-- integrated M-HT's neon scalers (pandora only)
-- merged an assortment of calc84maniac's bugfixes
-
-0.9-2xb u7
-- Pandora port, using hardware scaler for video output.
-- Fixed a few portablility issues in ARM asm and sound code.
-- Tweaked timing to suit pandora's LCD refresh nicely.
-- Maybe fixed GBC/digital sound channel desync over time.
-- Some other not-that-relevant cleanups and tweaks.
-
-Source code should be available at:
-http://notaz.gp2x.de/cgi-bin/gitweb.cgi
-
-
--- gameplaySP2X Gameboy Advance emulator for GP2X --
-
-gpSP2X is a version of my (Exophase)'s emulator originally for Sony PSP.
-A large amount of effort has been done to make it more optimized for the
-ARM CPU present in the GP2X, however it is still very much a work in
-progress.
-
-See readme.txt for the PSP version readme, which contains a lot of
-information relevant to the GP2X version (note that some of it does
-not apply however).
-
-
-Changelog:
-
-0.9-2xb u6
-- Fixed clock and scaling config saving.
-- Fixed occasional crash on first ROM load on 1.1 firmware.
-- Added LCD timing setup code, which can be controlled through
- 'pollux_dpc_set' environment vatiable (see gpsp.gpe wrapper script).
-
-0.9-2xb u5
-- Added portrait drawing modes. They eliminate tearing but are slightly
- slower.
-- Added page scrolling in ROM browser with L/R.
-- 32MB ROM support fixed.
-
-0.9-2xb u4 (unofficial notaz release, done on Exophase's request)
-- Wiz port. No emulation related changes.
-- Wiz: dropped SDL for video and hitting hardware directly (GPH SDL can't
- be trusted, it doesn't do double buffering as of firmware 1.0).
-- Added new optimized software scaler with interpolation.
-- gpSP is now saving ROM dir on exit. Delete romdir.txt if you don't
- want that.
-- gpSP now comes with wARM, new kernel module+lib for ARM cache control
- (replaces mmuhack).
-- gpSP no longer invalidates whole icache after recompilation, might
- cause minor speedup.
-
-0.9-2xb u3 (unofficial notaz release, released with permission):
-- Removed built-in CPU/LCD/RAM-Tweaker.
-- Improved usability of volume control.
-- Removed PSP-specific GUI options, adjusted help text.
-- Overclocking from menu now works, keep it at 200 if you don't want that
- (if you want to overclock using launcher, for example).
-- Fixed centering-on-first-run problem.
-- 3:2 scaled option now does what it says.
-
-0.9-2xb u2 (unofficial notaz release):
-- Replaced non-working mmuhack.o with proper one, added cache flush calls
- to avoid artifacts.
-
-0.9-2xb u1 (unofficial notaz release):
-- Fixed a problen in thread synchronization which caused deadlock after
- some time.
-
-0.9-2xb:
--- IMPORTANT-- If you're overwriting an old version, be sure to delete the
- gpsp.cfg file first, or be prepared to have a bunch of weird button
- settings that would require fixing.
-
-- Fixed some bugs stunting compatability.
-- Optimized alpha blends in renderer.
-- Some more optimizations to dynarec output.
-- Savestates should work better now.
-- Cheat/misc menu won't crash the emulator.
-- Main button config window works (not all buttons are in yet)
-
-0.9-2Xa: (Exophase release)
-- Redid autoframeskip. Should work more reliably.
-- Rewrote dynamic recompiler from x86 source (arm_emit.h, arm_stub.S).
- Has some more sophisticated behavior than the last version, more is
- still to come... Should notice a slight speed improvement over the
- last version.
-- Tweaked GUI to be a little more useable. Buttons are now mirroring the
- PSP version's.
-- Code unification + cleanup amongst versions.
-
-
-v9008: (zodttd release)
-- Updated the way autoframeskip works. Should be better now. Still has a max
- frameskip value.
-- Added a slight performance increase to the dynarec.
-- Added sync() to make sure files such as savestates and in-game saves are
- saved properly to the GP2X.
-
-v9006: (zodttd release)
-- Initial public release
-
-
-Installation:
-
-1. Place the "gpsp.gpe" and "game_config.txt" file in a directory on your SD
- card used with the GP2X.
-
-2. Place your GBA BIOS in the directory from step 1. This file must be named
- "gba_bios.bin" in all lowercase as shown, so rename it if needed.
-
- -- NOTE --
-
- There are two commonly available BIOSes - one is the correct one used in
- production GBA's worldwide and the other is a prototype BIOS. The latter
- will not cause some games to not work correctly or crash. If you attempt
- to use this BIOS you will be presented with a warning before being
- allowed to continue. This screen will give you a checksum of the real
- BIOS image (see readme.txt for further information).
-
-3. Place your GBA games in the directory from step 1. These files should have
- a ".gba" or ".bin" file extension. Zip compressed games should be supported
- and are recognized with the ".zip" file extension. Note that 32MB ROMs will
- probably not run if zipped. 16MB and smaller should be OK.
-
-4. Done. Run gpsp.gpe.
-
-
-Controls:
-
-How to use gpSP on the GP2X:
-Buttons are mapped as follows (GBA/ingame buttons can be changed in the menu):
-
-GP2X--------------------GBA
-X -> A
-B -> B
-L TRIG -> L TRIG
-R TRIG -> R TRIG
-START -> START
-SELECT -> SELECT
-
-GP2X--------------------------------gpSP
-
--- IN-GAME --
-
-VOL MIDDLE (UP + DOWN) -> menu
-PUSH STICK -> fps display toggle (second number is
- frames actually drawn)
-
--- IN-MENU --
-B -> select option
-X -> cancel/exit menu
-A -> escape (up one director level in the
- file selector)
-
-When gpSP is started, you are presented with the option to overclock your
-GP2X. Use the L/R TRIG to change the CPU clockspeed and press START to
-continue. You may also change RAM timings here - experiment with what
-works well. Note that going too high on overclocking or low on RAM
-timings can cause the game to crash or the GP2X to outright freeze up.
-
-If you do not want to overclock, press START without using L/R.
-You will now be presented with a menu to choose a game. Press the IN-MENU
-"SELECT" button shown above to pick a game to load.
-
-If you would like to test gpSP for the GP2X with a homebrew (free public
-domain) game, a game by Russ Prince works very well with gpSP. It is called
-Bust-A-Move and is a remake of the classic game it's named after.
-
-
-How to build from source:
-
-The makefile included in the source is geared towards the Open2x toolchain.
-If you use Open2x and installed it in the way recommended then it should
-work okay, assuming you also have up to date HW-SDL (and have
-arm-linux-sdl-config installed in the right place). The makefile is in the
-gp2x directory, so go there first then just type make to build gpsp.gpe.
-Might need a little tweaking if your setup is different. If you need help
-you can ask me, but I'll probably nag you about why you want to build it in
-the first place.
-
-
-GP2X version FAQ:
-
-Q) Help! This game doesn't work. Am I using a bad version of the ROM?
-
-A) First, make sure you're using the correct BIOS version. If you aren't
- gpSP should tell you. Other than that, there are some games that are
- known to not work now (and will probably work later), and perhaps
- many more games that I don't know about that don't work. I haven't
- launched a full scale compatability test at this version, so it might
- take a while before the compatability levels are high.
-
-
-Q) Why is this version slower than the PSP version?
-
-A) gpSP is still a work in progress. It might be possible to obtain more
- speed from both this version and the PSP one too (and others in the
- future). With that in mind, know that even a very agressively overclocked
- GP2X is still less powerful than a PSP, generally speaking. Still, I
- have a lot of ideas. It's unlikely that the GP2X version will ever be as
- fast/faster than the PSP version for anyone but anything's possible.
-
-
-Q) How high does my GP2X have to overclock to enjoy gpSP?
-
-A) That depends on you. Higher overclocking will mean less frames skipped
- on autoframeskip, or less frameskip needed if on manual. Or it can
- make the difference between whether or not virtual 60fps can be reached.
- For some games no GP2X in the world will be able to run them fullspeed,
- with any amount of frameskip. A few might run well with no overclocking
- and a generous level of frameskip (probably manual). If you don't care
- about battery life (or you're plugged into an outlet) you should push
- it as high as you can while still maintaining stability, because
- chances are high that whatever you play will benefit from it. Right now
- you'll probably want 260MHz if you can achieve it, but with a lot of
- luck this number will lower slightly in the future (and is just a vague
- ballpark figure anyway). I don't want to scare anyone off from using the
- emulator, you should give it a try and see how it plays for you
- regardless of how high you can overclock. Just note that this is far
- from a locked smooth experience for everyone on every game.
-
-
-Q) GBA has an ARM processor, GP2X has an ARM processor. GP2X is more
- powerful than GBA. This emulator should run great without overclocking,
- so therefore you're doing it wrong.
-
-A) That's not a question, but I'll field it anyway. Two things: first,
- "virtualization", or running the GBA code "natively" on the GP2X is
- probably not possible, at least not with the way I want to do things.
- For reasons why go read my blog (see below). So yes, you actually
- do need more than 16.7MHz of ARM9 power to emulate the GBA's CPU.
- Second: there is a whole lot of work behind emulating the pretty 2D
- graphics on the GBA, something it can do in hardware a lot better than
- this platform can.
- End result: GBA emulation on GP2X isn't as easy as you think it is.
-
-
-Q) What are you working on now? When will you release the next version?
-
-A) See the gpSP development blog:
-
- http://gpsp-dev.blogspot.com/
-
- Note that I don't give release dates, ever, unless I'm right on the verge
- of releasing. Be grateful that I've decided to be much more open about
- the development of the emulator now.
-
-
-Q) Thanks to your blog I heard that you made some improvement. Can I have
- a copy of the new code?
-
-A) No. Builds in transition often have a lot of problems, and I like for
- releases to be relatively substantial. I can probably be bribed out of
- them with donations though. :P
-
-
-Q) Why do the menu suck so much? Why do half the options not work or not
- make any sense?
-
-A) Sorry, the menu still hasn't been modified very much to fit the GP2X
- version instead of the PSP version.. hopefully this will improve in the
- future.
-
-
-Q) Who's in charge of the GP2X version anyway?
-
-A) Originally, zodttd was. I, Exophase, have basically usurped control of it
- now to encourage zodttd to work more on his PS1 emulator (that and I'm
- possessive of gpSP and get nervous when people work on it too heavily).
- zodttd will most likely still be around to work on things though.
-
-
-Q) I'm a super nice person and would like to donate some of my hard earned
- money to this one-off GBA emulator. Where do I send my money to?
-
-A) Exophase: exophase@gmail.com on PayPal
- zodttd: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=heirloomer
- %40pobox%2ecom&item_number=1&no_shipping=1&no_note=1&tax=0&cy_code=USD&bn=
- PP%2dDonationsBF&charset=UTF%2d8
- ^ Click there for donating on PayPal (remove whitespace/linebreaks).
-
- GP2X people have already donated a lot more to me than PSP people have,
- even though there's an order of magnitude or two less users. And they've
- donated far more to zodttd than they have to me. So I'm not going to ask
- people to donate..
-
- However I won't lie: donating ups the chances of me actually working on the
- next version (for which I have a lot of ideas, but not necessarily time to
- dedicate to.. that time might need more incentive to be allotted from other
- things). This could change depending on my employment situation, but right
- now I feel guilty doing anything that doesn't help guarantee that I'll be
- able to buy food a year from now.
-
-
-Q) Tell me all of your personal information.
-
-A) Again not a question, but why not. I'm Exophase, real name: Gilead Kutnick,
- male, 23 years old, current residence Bloomington, IN; straight/single/not
- actively looking, almost have an MS in Computer Science (do have a BS
- underneath it), likes PSP more than GP2X, will not write a Nintendo DS
- emulator for either, am currently looking for a job for after I graduate.
-
-
-Q) You said you're looking for a job.
-
-A) Yes. If you have one or know someone who needs a low level oriented
- programmer then I'm up for grabs. And this is my resume:
- http://exophase.devzero.co.uk/resume.pdf
-
-
-Credits:
-
-Original codebase: Exophase (exophase@gmail.com)
-Foundation gp2x code: zodttd
-GP2X dynarec/stubs + current code maintainance: Exophase
-
diff --git a/gp2x/test/align_test.c b/gp2x/test/align_test.c
deleted file mode 100644
index b7b3512..0000000
--- a/gp2x/test/align_test.c
+++ /dev/null
@@ -1,48 +0,0 @@
-// Betting on GCC aligning this for efficiency.
-#include <stdio.h>
-
-int main()
-{
- unsigned short int read_16 = 0xF1F2;
- unsigned int read_32 = 0xF1F2F3F4;
-
- unsigned short int write_16 = 0xF00D;
- unsigned int write_32 = 0xF00DFEED;
- // 16bit unsigned reads, we expect 0xF1F2 and 0xF20000F1
- fprintf(stderr, "%04x %04x\n",
- *((unsigned short int *)((char *)&read_16)),
- *((unsigned short int *)((char *)&read_16 + 1)));
-
- // 16bit signed reads, we expect 0xFFFFF1F2 and 0xFFFFFFF1
- fprintf(stderr, "%04x %04x\n",
- *((short int *)((char *)&read_16)),
- *((short int *)((char *)&read_16 + 1)));
-
- // 32bit reads, we expect 0xF1F2F3F4, 0xF4F1F2F3, 0xF3F4F1F2,
- // and 0xF2F3F4F1
-
- fprintf(stderr, "%08x %08x %08x %08x\n",
- *((int *)((char *)&read_32)),
- *((int *)((char *)&read_32 + 1)),
- *((int *)((char *)&read_32 + 2)),
- *((int *)((char *)&read_32 + 3)));
-
- // 16bit writes, we expect write_16 to remain 0xF00D
-
- *((short int *)((char *)&write_16)) = 0xF00D;
- *((short int *)((char *)&write_16) + 1) = 0xF00D;
-
- fprintf(stderr, "%04x\n", write_16);
-
- // 32bit writes, we expect write_32 to remain 0xF00DFEED
-
- *((int *)((char *)&write_16)) = 0xF00DFEED;
- *((int *)((char *)&write_16) + 1) = 0xF00DFEED;
- *((int *)((char *)&write_16) + 2) = 0xF00DFEED;
- *((int *)((char *)&write_16) + 3) = 0xF00DFEED;
-
- fprintf(stderr, "%08x\n", write_32);
-
- return 0;
-}
-
diff --git a/gp2x/test/load_imm_test.c b/gp2x/test/load_imm_test.c
deleted file mode 100644
index b850d56..0000000
--- a/gp2x/test/load_imm_test.c
+++ /dev/null
@@ -1,135 +0,0 @@
-#include <stdio.h>
-
-typedef unsigned int u32;
-
-u32 arm_imm_find_nonzero(u32 imm, u32 start_bit)
-{
- u32 i;
-
- for(i = start_bit; i < 32; i += 2)
- {
- if((imm >> i) & 0x03)
- break;
- }
-
- return i;
-}
-
-u32 arm_disect_imm_32bit(u32 imm, u32 *stores, u32 *rotations)
-{
- u32 store_count = 0;
- u32 left_shift = 0;
-
- // Otherwise it'll return 0 things to store because it'll never
- // find anything.
- if(imm == 0)
- {
- rotations[0] = 0;
- stores[0] = 0;
- return 1;
- }
-
- // Find chunks of non-zero data at 2 bit alignments.
- while(1)
- {
- left_shift = arm_imm_find_nonzero(imm, left_shift);
-
- if(left_shift == 32)
- {
- // We've hit the end of the useful data.
- return store_count;
- }
-
- // Hit the end, it might wrap back around to the beginning.
- if(left_shift >= 24)
- {
- // Make a mask for the residual bits. IE, if we have
- // 5 bits of data at the end we can wrap around to 3
- // bits of data in the beginning. Thus the first
- // thing, after being shifted left, has to be less
- // than 111b, 0x7, or (1 << 3) - 1.
- u32 top_bits = 32 - left_shift;
- u32 residual_bits = 8 - top_bits;
- u32 residual_mask = (1 << residual_bits) - 1;
-
- if((store_count > 1) && (left_shift > 24) &&
- ((stores[0] << (32 - rotations[0])) < residual_mask))
- {
- // Then we can throw out the last bit and tack it on
- // to the first bit.
- u32 initial_bits = rotations[0];
- stores[0] = (stores[0] << (top_bits + (32 - rotations[0]))) |
- ((imm >> left_shift) & 0xFF);
- rotations[0] = top_bits;
-
- return store_count;
- }
- else
- {
- // There's nothing to wrap over to in the beginning
- stores[store_count] = (imm >> left_shift) & 0xFF;
- rotations[store_count] = (32 - left_shift) & 0x1F;
- return store_count + 1;
- }
- break;
- }
-
- stores[store_count] = (imm >> left_shift) & 0xFF;
- rotations[store_count] = (32 - left_shift) & 0x1F;
-
- store_count++;
- left_shift += 8;
- }
-}
-
-#define ror(value, shift) \
- ((value) >> shift) | ((value) << (32 - shift)) \
-
-u32 arm_assemble_imm_32bit(u32 *stores, u32 *rotations, u32 store_count)
-{
- u32 n = ror(stores[0], rotations[0]);
- u32 i;
- printf("%x : %x\n", stores[0], rotations[0]);
-
- for(i = 1; i < store_count; i++)
- {
- printf("%x : %x\n", stores[i], rotations[i]);
- n |= ror(stores[i], rotations[i]);
- }
-
- return n;
-}
-
-
-int main(int argc, char *argv[])
-{
- u32 n = 0;
- u32 stores[4];
- u32 rotations[4];
- u32 store_count;
- u32 n2;
-
- if(argc != 1)
- {
- n = strtoul(argv[1], NULL, 16);
- store_count = arm_disect_imm_32bit(n, stores, rotations);
- n2 = arm_assemble_imm_32bit(stores, rotations, store_count);
- printf("%08x -> %08x (%d stores)\n", n, n2, store_count);
- return 0;
- }
-
- do
- {
- store_count = arm_disect_imm_32bit(n, stores, rotations);
- n2 = arm_assemble_imm_32bit(stores, rotations, store_count);
- if(n != n2)
- {
- printf("Failure: %08x -/-> %08x\n", n, n2);
- return -1;
- }
- n++;
- } while(n != 0);
-
- printf("Done!\n");
- return 0;
-}
diff --git a/gp2x/upscale_aspect.s b/gp2x/upscale_aspect.s
deleted file mode 100644
index 41bcf0e..0000000
--- a/gp2x/upscale_aspect.s
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * 240x160 -> 320x213 upscaler for ARM with interpolation
- *
- * Written by GraÅžvydas "notaz" Ignotas
- * Prototyped by Rokas
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the organization nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * 0 1 2 : 3 4 5
- * 6 7 8 : 9 10 11
- * 12 13 14 : 15 16 17
- * v
- * 0 1 2 3 : 4 5 6 7
- * 8 9 10 11 : 12 13 14 15
- * 16 17 18 19 : 20 21 22 23
- * 24 25 26 27 : 28 29 30 31
- */
-
-.macro unpack_hi dst, src
- mov \dst, \src, lsr #16
- orr \dst, \dst, \dst, lsl #16
- and \dst, \dst, lr
-.endm
-
-.macro unpack_lo dst, src
- mov \dst, \src, lsl #16
- orr \dst, \dst, \dst, lsr #16
- and \dst, \dst, lr
-.endm
-
-@ do 3:5 summing: r2 = (s1*3 + s2*5 + 4) / 8
-@ s2 != r2
-.macro do_3_5 s1, s2
- add r2,\s1,\s1, lsl #1 @ r2 = s1 * 3
- add r2, r2,\s2, lsl #2
- add r2, r2,\s2 @ r2 += s2 * 5
- add r2, r2, r12,lsl #2 @ sum += round * 4
- and r2, lr, r2, lsr #3 @ mask_to_unpacked(sum / 8)
-.endm
-
-@ do 14:7:7:4: r2 = (s1*14 + s2*7 + s3*7 + s4*4 + 16) / 32
-@ {s2,s3,s4} != r2
-.macro do_14_7_7_4 s1, s2, s3, s4
- mov r2,\s1, lsl #4
- sub r2, r2,\s1, lsl #1 @ r2 = s1 * 14
- add r2, r2,\s2, lsl #3
- sub r2, r2,\s2 @ r2 += s2 * 7
- add r2, r2,\s3, lsl #3
- sub r2, r2,\s3 @ r2 += s3 * 7
- add r2, r2,\s4, lsl #2 @ r2 += s4 * 4
- add r2, r2, r12,lsl #3 @ sum += round * 16
- and r2, lr, r2, lsr #5 @ mask_to_unpacked(sum / 32)
-.endm
-
-.global upscale_aspect @ u16 *dst, u16 *src
-upscale_aspect:
- stmfd sp!,{r4-r11,lr}
- mov lr, #0x0000001f
- orr lr, lr, #0x0000f800 @ for "unpacked" form of
- orr lr, lr, #0x07e00000 @ 00000ggg'ggg00000'rrrrr000'000bbbbb
- mov r12, #0x00000001
- orr r12,r12,#0x00000800
- orr r12,r12,#0x00200000 @ rounding constant
-
- mov r8, #((240/6)-1) << 24 @ cols
- orr r8, r8, #160/3 @ rows
-
- add r0, r0, #320*2*13
-loop1:
- ldr r10,[r1]
- ldr r11,[r1, #320*2*1]
-
- unpack_lo r4, r10
- unpack_hi r5, r10
- unpack_lo r6, r11
- unpack_hi r7, r11
-
- ldr r11,[r1, #4]
-
- do_3_5 r4, r5
- orr r2, r2, r2, lsr #16
- mov r3, r10, lsl #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0] @ 0,1
-
- ldr r10,[r1, #320*2*2]
-
- do_3_5 r4, r6
- orr r3, r2, r2, lsl #16
- mov r3, r3, lsr #16 @ 8
-
- do_14_7_7_4 r7, r5, r6, r4
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*1] @ 8,9
-
- unpack_lo r4, r10
- unpack_hi r9, r10
-
- do_3_5 r4, r6
- orr r3, r2, r2, lsl #16
- mov r3, r3, lsr #16
-
- do_14_7_7_4 r7, r9, r6, r4
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*2] @ 16,17
-
- do_3_5 r4, r9
- orr r2, r2, r2, lsr #16
- mov r3, r10, lsl #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*3] @ 24,25
-
- ldr r10,[r1, #320*2*1+4]
-
- unpack_lo r6, r11
- unpack_lo r4, r10
-
- do_3_5 r6, r5
- orr r2, r2, r2, lsl #16
- mov r3, r11, lsl #16
- orr r2, r3, r2, lsr #16
- str r2, [r0, #4] @ 2,3
-
- do_14_7_7_4 r7, r4, r5, r6
- orr r2, r2, r2, lsl #16
- mov r3, r2, lsr #16
-
- ldr r5, [r1, #320*2*2+4]
-
- do_3_5 r6, r4
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*1+4] @ 10,11
-
- unpack_lo r6, r5
-
- do_14_7_7_4 r7, r4, r9, r6
- orr r2, r2, r2, lsl #16
- mov r3, r2, lsr #16
-
- do_3_5 r6, r4
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*2+4] @ 18,19
-
- unpack_hi r4, r10
-
- ldr r10,[r1, #8]
-
- do_3_5 r6, r9
- orr r2, r2, r2, lsl #16
- mov r2, r2, lsr #16
- orr r2, r2, r5, lsl #16
- str r2, [r0, #320*2*3+4] @ 26,27
-
- unpack_hi r6, r11
- unpack_lo r7, r10
-
- do_3_5 r6, r7
- orr r2, r2, r2, lsr #16
- mov r2, r2, lsl #16
- orr r2, r2, r11,lsr #16
- str r2, [r0, #8] @ 4,5
-
- ldr r11,[r1, #320*2*1+8]
-
- unpack_hi r9, r10
-
- do_3_5 r9, r7
- orr r2, r2, r2, lsr #16
- mov r2, r2, lsl #16
- orr r2, r2, r10,lsr #16
- mov r2, r2, ror #16
- str r2, [r0, #12] @ 6,7
-
- unpack_lo r10,r11
-
- do_3_5 r6, r4
- orr r2, r2, r2, lsl #16
- mov r3, r2, lsr #16
-
- do_14_7_7_4 r10, r4, r7, r6
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*1+8] @ 12,13
-
- unpack_hi r6, r11
-
- ldr r11,[r1, #320*2*2+8]
-
- do_14_7_7_4 r10, r6, r7, r9
- orr r2, r2, r2, lsl #16
- mov r3, r2, lsr #16
-
- do_3_5 r9, r6
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*1+12] @ 14,15
-
- unpack_hi r7, r5
- unpack_lo r9, r11
-
- do_3_5 r7, r4
- orr r2, r2, r2, lsl #16
- mov r3, r2, lsr #16
-
- do_14_7_7_4 r10, r4, r9, r7
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*2+8] @ 20,21
-
- do_3_5 r7, r9
- orr r2, r2, r2, lsr #16
- mov r2, r2, lsl #16
- orr r2, r2, r5, lsr #16
- str r2, [r0, #320*2*3+8] @ 28,29
-
- unpack_hi r5, r11
-
- do_14_7_7_4 r10, r6, r9, r5
- orr r2, r2, r2, lsl #16
- mov r3, r2, lsr #16
-
- do_3_5 r5, r6
- orr r2, r2, r2, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #320*2*2+12] @ 22,23
-
- do_3_5 r5, r9
- orr r2, r2, r2, lsr #16
- mov r3, r11, lsr #16
- orr r2, r3, r2, lsl #16
- mov r2, r2, ror #16
- str r2, [r0, #320*2*3+12] @ 30,31
-
- add r0, r0, #16
- add r1, r1, #12
-
- subs r8, r8, #1<<24
- bpl loop1
-
- add r0, r0, #320*3*2
- add r1, r1, #(320*2+80)*2
- sub r8, r8, #1
- tst r8, #0xff
- add r8, r8, #(240/6) << 24 @ cols
- bne loop1
-
- @@ last line
- mov r8, #240/6
-
-loop2:
- ldmia r1!,{r9,r10,r11}
-
- unpack_lo r4, r9
- unpack_hi r5, r9
-
- do_3_5 r4, r5
- orr r2, r2, r2, lsr #16
- mov r3, r9, lsl #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0], #4
-
- unpack_lo r6, r10
- unpack_hi r7, r10
-
- do_3_5 r6, r5
- orr r2, r2, r2, lsl #16
- mov r2, r2, lsr #16
- orr r2, r2, r10,lsl #16
- str r2, [r0], #4
-
- unpack_lo r4, r11
- unpack_hi r5, r11
-
- do_3_5 r7, r4
- orr r2, r2, r2, lsr #16
- mov r3, r10, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0], #4
-
- do_3_5 r5, r4
- orr r2, r2, r2, lsr #16
- mov r3, r11, lsr #16
- orr r2, r3, r2, lsl #16
- mov r2, r2, ror #16
- str r2, [r0], #4
-
- subs r8, r8, #1
- bne loop2
-
- ldmfd sp!,{r4-r11,pc}
-
-
-.global upscale_aspect_row @ void *dst, void *linesx4, u32 row
-upscale_aspect_row:
- stmfd sp!,{r4-r11,lr}
- mov lr, #0x0000001f
- orr lr, lr, #0x0000f800 @ for "unpacked" form of
- orr lr, lr, #0x07e00000 @ 00000ggg'ggg00000'rrrrr000'000bbbbb
- mov r12, #0x00000001
- orr r12,r12,#0x00000800
- orr r12,r12,#0x00200000 @ rounding constant
-
- mov r8, #(240/6) @ cols
-
- add r0, r0, #(240*320)*2
- add r0, r0, #12*2
- add r0, r0, r2, lsl #3
-
-uar_loop:
- ldr r10,[r1]
- ldr r11,[r1, #240*2*1]
-
- unpack_lo r4, r10
- unpack_hi r5, r10
- unpack_lo r6, r11
- unpack_hi r7, r11
-
- ldr r11,[r1, #240*2*2]
-
- do_3_5 r4, r6
- orr r2, r2, r2, lsr #16
- mov r3, r10, lsl #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #-240*2]! @ 0,8
-
- unpack_lo r10,r11
- unpack_hi r9, r11
-
- do_3_5 r10,r6
- orr r2, r2, r2, lsl #16
- mov r3, r11, lsl #16
- orr r2, r3, r2, lsr #16
- str r2, [r0, #4] @ 16,24
-
- do_3_5 r4, r5
- orr r3, r2, r2, lsl #16
-
- do_14_7_7_4 r7, r5, r6, r4
- orr r2, r2, r2, lsr #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #-240*2]! @ 1,9
-
- ldr r11,[r1, #4]
-
- do_14_7_7_4 r7, r6, r9, r10
- orr r3, r2, r2, lsl #16
-
- do_3_5 r10,r9
- orr r2, r2, r2, lsr #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #4] @ 17,25
-
- ldr r10,[r1, #240*2*1+4]
-
- unpack_lo r4, r11
- unpack_lo r6, r10
-
- do_3_5 r4, r5
- orr r3, r2, r2, lsl #16
-
- do_14_7_7_4 r7, r5, r6, r4
- orr r2, r2, r2, lsr #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #-240*2]! @ 2,10
-
- do_3_5 r4, r6
-
- ldr r4, [r1, #240*2*2+4]
-
- orr r2, r2, r2, lsr #16
- mov r3, r11, lsl #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #-240*2] @ 3,11
-
- unpack_lo r5, r4
-
- do_14_7_7_4 r7, r6, r9, r5
- orr r3, r2, r2, lsl #16
-
- do_3_5 r5, r9
- orr r2, r2, r2, lsr #16
- mov r2, r2, lsl #16
- orr r2, r2, r3, lsr #16
- str r2, [r0, #4] @ 18,26
-
- do_3_5 r5, r6
- orr r2, r2, r2, lsl #16
- mov r3, r4, lsl #16
- orr r2, r3, r2, lsr #16
- str r2, [r0, #-240*2+4] @ 19,27
-
- unpack_hi r5, r11
- unpack_hi r6, r10
- unpack_hi r7, r4
-
- ldr r10,[r1, #8]
-
- do_3_5 r5, r6
- orr r2, r2, r2, lsr #16
- mov r3, r11, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #-240*2*2]! @ 4,12
-
- ldr r11,[r1, #240*2*1+8]
-
- do_3_5 r7, r6
- orr r2, r2, r2, lsl #16
- mov r3, r4, lsr #16
- mov r3, r3, lsl #16
- orr r2, r3, r2, lsr #16
- str r2, [r0, #4] @ 20,28
-
- unpack_lo r4, r10
- unpack_lo r9, r11
-
- ldr r11,[r1, #240*2*2+8]
-
- do_3_5 r5, r4
- orr r3, r2, r2, lsl #16
-
- do_14_7_7_4 r9, r4, r6, r5
- orr r2, r2, r2, lsr #16
- mov r2, r2, lsl #16
- orr r2, r2, r3, lsr #16
- str r2, [r0, #-240*2]! @ 5,13
-
- unpack_lo r5, r11
-
- do_14_7_7_4 r9, r5, r6, r7
- orr r3, r2, r2, lsl #16
-
- do_3_5 r7, r5
- orr r2, r2, r2, lsr #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #4] @ 21,29
-
- ldr r7, [r1, #240*2*1+8]
-
- unpack_hi r6, r10
- unpack_hi r7, r7
-
- do_3_5 r6, r4
- orr r3, r2, r2, lsl #16
-
- do_14_7_7_4 r9, r4, r7, r6
- orr r2, r2, r2, lsr #16
- mov r2, r2, lsl #16
- orr r2, r2, r3, lsr #16
- str r2, [r0, #-240*2]! @ 6,14
-
- unpack_hi r4, r11
-
- do_14_7_7_4 r9, r5, r7, r4
- orr r3, r2, r2, lsl #16
-
- do_3_5 r4, r5
- orr r2, r2, r2, lsr #16
- mov r3, r3, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #4] @ 22,30
-
- do_3_5 r6, r7
- orr r2, r2, r2, lsr #16
- mov r3, r10, lsr #16
- orr r2, r3, r2, lsl #16
- str r2, [r0, #-240*2]! @ 7,15
-
- do_3_5 r4, r7
- orr r2, r2, r2, lsl #16
- mov r3, r11, lsr #16
- mov r3, r3, lsl #16
- orr r2, r3, r2, lsr #16
- str r2, [r0, #4] @ 23,31
-
- subs r8, r8, #1
- add r1, r1, #12
- bne uar_loop
-
- ldmfd sp!,{r4-r11,pc}
-
-
-@ bonus function
-
-@ input: r2-r5
-@ output: r7,r8
-@ trash: r6
-.macro rb_line_low
- mov r6, r2, lsl #16
- mov r7, r3, lsl #16
- orr r7, r7, r6, lsr #16
- mov r6, r4, lsl #16
- mov r8, r5, lsl #16
- orr r8, r8, r6, lsr #16
-.endm
-
-.macro rb_line_hi
- mov r6, r2, lsr #16
- mov r7, r3, lsr #16
- orr r7, r6, r7, lsl #16
- mov r6, r4, lsr #16
- mov r8, r5, lsr #16
- orr r8, r6, r8, lsl #16
-.endm
-
-.global do_rotated_blit @ void *dst, void *linesx4, u32 y
-do_rotated_blit:
- stmfd sp!,{r4-r8,lr}
-
- add r0, r0, #(240*320)*2
- sub r0, r0, #(240*40)*2
- sub r0, r0, #(240-40+4)*2 @ y starts from 4
- add r0, r0, r2, lsl #1
-
- mov lr, #240/4
-
-rotated_blit_loop:
- ldr r2, [r1, #240*0*2]
- ldr r3, [r1, #240*1*2]
- ldr r4, [r1, #240*2*2]
- ldr r5, [r1, #240*3*2]
- rb_line_low
- stmia r0, {r7,r8}
- sub r0, r0, #240*2
- rb_line_hi
- stmia r0, {r7,r8}
- sub r0, r0, #240*2
-
- ldr r2, [r1, #240*0*2+4]
- ldr r3, [r1, #240*1*2+4]
- ldr r4, [r1, #240*2*2+4]
- ldr r5, [r1, #240*3*2+4]
- rb_line_low
- stmia r0, {r7,r8}
- sub r0, r0, #240*2
- rb_line_hi
- stmia r0, {r7,r8}
- sub r0, r0, #240*2
-
- subs lr, lr, #1
- add r1, r1, #8
- bne rotated_blit_loop
-
- ldmfd sp!,{r4-r8,pc}
-
-@ vim:filetype=armasm
-