notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clarify PicoDrive's license
[picodrive.git]
/
platform
/
gp2x
/
soc_mmsp2.c
diff --git
a/platform/gp2x/soc_mmsp2.c
b/platform/gp2x/soc_mmsp2.c
index
c136287
..
9ef1e9b
100644
(file)
--- a/
platform/gp2x/soc_mmsp2.c
+++ b/
platform/gp2x/soc_mmsp2.c
@@
-1,3
+1,10
@@
+/*
+ * PicoDrive
+ * (C) notaz, 2006-2009
+ *
+ * This work is licensed under the terms of MAME license.
+ * See COPYING file in the top-level directory.
+ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-12,6
+19,7
@@
#include "soc_mmsp2.h"
#include "plat_gp2x.h"
#include "../common/emu.h"
#include "soc_mmsp2.h"
#include "plat_gp2x.h"
#include "../common/emu.h"
+#include "../common/plat.h"
#include "../common/arm_utils.h"
#include "940ctl.h"
#include "../common/arm_utils.h"
#include "940ctl.h"
@@
-33,8
+41,12
@@
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
static const int gp2x_screenaddrs[4] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };
static int gp2x_screenaddrs_use[4];
static const int gp2x_screenaddrs[4] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };
static int gp2x_screenaddrs_use[4];
-static unsigned short gp2x_screenaddr_old[4];
+static char gamma_was_changed = 0;
+static char cpuclk_was_changed = 0;
+static unsigned short gp2x_screenaddr_old[4];
+static unsigned short memtimex_old[2];
+static unsigned short reg0910;
/* video stuff */
static void gp2x_video_flip_(void)
/* video stuff */
static void gp2x_video_flip_(void)
@@
-166,11
+178,11
@@
static void gp2x_set_cpuclk_(unsigned int mhz)
for (i = 0; i < 10000; i++)
if (!(gp2x_memregs[0x902>>1] & 1))
break;
for (i = 0; i < 10000; i++)
if (!(gp2x_memregs[0x902>>1] & 1))
break;
+
+ cpuclk_was_changed = 1;
}
/* RAM timings */
}
/* RAM timings */
-static unsigned short memtimex[2];
-
#define TIMING_CHECK(t, adj, mask) \
t += adj; \
if (t & ~mask) \
#define TIMING_CHECK(t, adj, mask) \
t += adj; \
if (t & ~mask) \
@@
-214,8
+226,8
@@
static void set_ram_timings_(void)
static void unset_ram_timings_(void)
{
static void unset_ram_timings_(void)
{
- gp2x_memregs[0x3802>>1] = memtimex[0];
- gp2x_memregs[0x3804>>1] = memtimex[1] | 0x8000;
+ gp2x_memregs[0x3802>>1] = memtimex
_old
[0];
+ gp2x_memregs[0x3804>>1] = memtimex
_old
[1] | 0x8000;
printf("RAM timings reset to startup values.\n");
}
printf("RAM timings reset to startup values.\n");
}
@@
-344,8
+356,14
@@
static void set_lcd_gamma_(int g100, int A_SNs_curve)
gp2x_memregs[0x295E>>1]= s;
gp2x_memregs[0x295E>>1]= g;
}
gp2x_memregs[0x295E>>1]= s;
gp2x_memregs[0x295E>>1]= g;
}
+
+ gamma_was_changed = 1;
}
}
+static int gp2x_read_battery_(void)
+{
+ return -1; /* TODO? */
+}
/* these are not quite MMSP2 related,
* more to GP2X F100/F200 consoles themselves. */
/* these are not quite MMSP2 related,
* more to GP2X F100/F200 consoles themselves. */
@@
-454,12
+472,13
@@
void mmsp2_init(void)
memcpy(gp2x_screenaddrs_use, gp2x_screenaddrs, sizeof(gp2x_screenaddrs));
memcpy(gp2x_screenaddrs_use, gp2x_screenaddrs, sizeof(gp2x_screenaddrs));
- /*
default
LCD refresh */
+ /*
save startup values:
LCD refresh */
get_reg_setting(lcd_rate_defaults);
get_reg_setting(lcd_rate_defaults);
- /* RAM timings */
- memtimex[0] = gp2x_memregs[0x3802>>1];
- memtimex[1] = gp2x_memregs[0x3804>>1];
+ /* CPU and RAM timings */
+ reg0910 = gp2x_memregs[0x0910>>1];
+ memtimex_old[0] = gp2x_memregs[0x3802>>1];
+ memtimex_old[1] = gp2x_memregs[0x3804>>1];
/* touchscreen */
touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);
/* touchscreen */
touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);
@@
-495,6
+514,10
@@
void mmsp2_init(void)
set_ram_timings = set_ram_timings_;
unset_ram_timings = unset_ram_timings_;
set_ram_timings = set_ram_timings_;
unset_ram_timings = unset_ram_timings_;
+ gp2x_read_battery = gp2x_read_battery_;
+
+ gp2x_get_ticks_ms = plat_get_ticks_ms_good;
+ gp2x_get_ticks_us = plat_get_ticks_us_good;
}
void mmsp2_finish(void)
}
void mmsp2_finish(void)
@@
-503,13
+526,20
@@
void mmsp2_finish(void)
pause940(1);
sharedmem940_finish();
pause940(1);
sharedmem940_finish();
+ gp2x_video_RGB_setscaling_(0, 320, 240);
+ gp2x_video_changemode_ll_(16);
+
gp2x_memregs[0x290E>>1] = gp2x_screenaddr_old[0];
gp2x_memregs[0x2910>>1] = gp2x_screenaddr_old[1];
gp2x_memregs[0x2912>>1] = gp2x_screenaddr_old[2];
gp2x_memregs[0x2914>>1] = gp2x_screenaddr_old[3];
gp2x_memregs[0x290E>>1] = gp2x_screenaddr_old[0];
gp2x_memregs[0x2910>>1] = gp2x_screenaddr_old[1];
gp2x_memregs[0x2912>>1] = gp2x_screenaddr_old[2];
gp2x_memregs[0x2914>>1] = gp2x_screenaddr_old[3];
- unset_ram_timings_();
unset_lcd_custom_rate_();
unset_lcd_custom_rate_();
+ if (gamma_was_changed)
+ set_lcd_gamma_(100, 0);
+ unset_ram_timings_();
+ if (cpuclk_was_changed)
+ gp2x_memregs[0x910>>1] = reg0910;
munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE);
munmap((void *)gp2x_memregs, 0x10000);
munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE);
munmap((void *)gp2x_memregs, 0x10000);