Skip to content

Commit

Permalink
v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
steward-fu committed Oct 26, 2023
1 parent 837b45e commit d84ce29
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sdl2/include/SDL_revision.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define SDL_REVISION "ssh://[email protected]/steward-fu/sdl@85ee93157fc6884470f82a820839f09b64672d01"
#define SDL_REVISION "ssh://[email protected]/steward-fu/sdl@187ee058ea392750cdc1aa73cf613ee719ea6b9f"
#define SDL_REVISION_NUMBER 0
41 changes: 35 additions & 6 deletions sdl2/src/video/mmiyoo/SDL_event_mmiyoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ MMIYOO_EventInfo MMiyooEventInfo = {0};

extern NDS nds;
extern MMIYOO_VideoInfo MMiyooVideoInfo;
extern int down_scale;

static int running = 0;
static int event_fd = -1;
Expand Down Expand Up @@ -88,15 +89,42 @@ static int get_move_interval(int type)

int EventUpdate(void *data)
{
const uint32_t L1 = 18;
const uint32_t L2 = 15;
const uint32_t R1 = 20;
const uint32_t R2 = 14;

struct input_event ev = {0};
uint32_t bit = 0, hotkey = 0;
uint32_t l1 = L1;
uint32_t l2 = L2;
uint32_t r1 = R1;
uint32_t r2 = R2;

if (nds.swap_l1l2) {
l1 = L2;
l2 = L1;
printf("Swap L1 and L2 keys\n");
}

if (nds.swap_r1r2) {
r1 = R2;
r2 = R1;
printf("Swap R1 and R2 keys\n");
}

while (running) {
SDL_SemWait(event_sem);
if (event_fd > 0) {
if (read(event_fd, &ev, sizeof(struct input_event))) {
if ((ev.type == EV_KEY) && (ev.value != 2)) {
//printf("%s, code:%d\n", __func__, ev.code);

if (ev.code == l1) { bit = (1 << MYKEY_L1); }
if (ev.code == l2) { bit = (1 << MYKEY_L2); }
if (ev.code == r1) { bit = (1 << MYKEY_R1); }
if (ev.code == r2) { bit = (1 << MYKEY_R2); }

switch (ev.code) {
case 103: bit = (1 << MYKEY_UP); break;
case 108: bit = (1 << MYKEY_DOWN); break;
Expand All @@ -109,10 +137,6 @@ int EventUpdate(void *data)
case 28: bit = (1 << MYKEY_START); break;
case 97: bit = (1 << MYKEY_SELECT); break;
case 1: bit = (1 << MYKEY_MENU); break;
case 18: bit = (1 << MYKEY_L1); break;
case 15: bit = (1 << MYKEY_L2); break;
case 20: bit = (1 << MYKEY_R1); break;
case 14: bit = (1 << MYKEY_R2); break;
case 116: bit = (1 << MYKEY_POWER); break;
case 115: bit = (1 << MYKEY_VOLUP);
if (is_stock_system && (ev.value == 0)) {
Expand Down Expand Up @@ -171,6 +195,11 @@ int EventUpdate(void *data)
MMiyooEventInfo.keypad.bitmaps&= ~(1 << MYKEY_A);
}

if (hotkey && (MMiyooEventInfo.keypad.bitmaps & (1 << MYKEY_B))) {
down_scale = down_scale ? 0 : 1;
MMiyooEventInfo.keypad.bitmaps&= ~(1 << MYKEY_B);
}

if (hotkey && (MMiyooEventInfo.keypad.bitmaps & (1 << MYKEY_Y))) {
if (MMiyooEventInfo.mode == MMIYOO_KEYPAD_MODE) {
if ((nds.overlay.sel >= nds.overlay.max) &&
Expand Down Expand Up @@ -432,8 +461,8 @@ void MMIYOO_PumpEvents(_THIS)
switch (nds.dis_mode) {
case NDS_DIS_MODE_VH_T0:
case NDS_DIS_MODE_VH_T1:
case NDS_DIS_MODE_S0:
case NDS_DIS_MODE_S1:
//case NDS_DIS_MODE_S0:
//case NDS_DIS_MODE_S1:
addy = -120;
break;
}
Expand Down
71 changes: 68 additions & 3 deletions sdl2/src/video/mmiyoo/SDL_video_mmiyoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
NDS nds = {0};
MMIYOO_VideoInfo MMiyooVideoInfo={0};

int down_scale = 1;

static GFX gfx = {0};
static SDL_Surface *cvt = NULL;

Expand Down Expand Up @@ -206,6 +208,18 @@ static int read_config(void)
}
}

json_object_object_get_ex(jfile, JSON_NDS_SWAP_L1L2, &jval);
if (jval) {
nds.swap_l1l2 = json_object_get_int(jval) ? 1 : 0;
printf("[json] nds.swap_l1l2: %d\n", nds.swap_l1l2);
}

json_object_object_get_ex(jfile, JSON_NDS_SWAP_R1R2, &jval);
if (jval) {
nds.swap_r1r2 = json_object_get_int(jval) ? 1 : 0;
printf("[json] nds.swap_r1r2: %d\n", nds.swap_r1r2);
}

reload_pen();
reload_overlay();
json_object_put(jfile);
Expand Down Expand Up @@ -633,8 +647,8 @@ int draw_pen(const void *pixels, int width, int pitch)
switch (nds.dis_mode) {
case NDS_DIS_MODE_VH_T0:
case NDS_DIS_MODE_VH_T1:
case NDS_DIS_MODE_S0:
case NDS_DIS_MODE_S1:
//case NDS_DIS_MODE_S0:
//case NDS_DIS_MODE_S1:
sub = sh;
break;
}
Expand Down Expand Up @@ -868,6 +882,57 @@ int GFX_Copy(const void *pixels, SDL_Rect srcrect, SDL_Rect dstrect, int pitch,
}
}

if ((copy_it) && (down_scale)) {
do {
if (nds.hres_mode != 0) {
break;
}

if ((srcrect.w != 256) || (srcrect.h != 192)) {
break;
}

asm volatile (
"1: mov r8, %2 ;"
" add r9, %1, %3 ;"
"2: vldmia %0!, {q8-q11} ;"
" vdup.32 d31, d23[1] ;"
" vdup.32 d30, d23[0] ;"
" vdup.32 d29, d22[1] ;"
" vdup.32 d28, d22[0] ;"
" vdup.32 d27, d21[1] ;"
" vdup.32 d26, d21[0] ;"
" vdup.32 d25, d20[1] ;"
" vdup.32 d24, d20[0] ;"
" vdup.32 d23, d19[1] ;"
" vdup.32 d22, d19[0] ;"
" vdup.32 d21, d18[1] ;"
" vdup.32 d20, d18[0] ;"
" vdup.32 d19, d17[1] ;"
" vdup.32 d18, d17[0] ;"
" vdup.32 d17, d16[1] ;"
" vdup.32 d16, d16[0] ;"
" vstmia %1!, {q8-q15} ;"
" vstmia r9!, {q8-q15} ;"
" subs r8, #1 ;"
" bne 2b ;"
" add %1, %1, %3 ;"
" subs %4, #1 ;"
" bne 1b ;"
:
: "r"(pixels), "r"(gfx.tmp.virAddr), "r"(16), "r"(512 * 4), "r"(192)
: "r8", "r9", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory", "cc"
);

copy_it = 0;
srcrect.x = 0;
srcrect.y = 0;
srcrect.w = 512;
srcrect.h = 384;
pitch = srcrect.w * 4;
} while(0);
}

if (copy_it) {
neon_memcpy(gfx.tmp.virAddr, pixels, srcrect.h * pitch);
}
Expand Down Expand Up @@ -1349,8 +1414,8 @@ int MMIYOO_VideoInit(_THIS)
SDL_AddVideoDisplay(&display, SDL_FALSE);

GFX_Init();
MMIYOO_EventInit();
read_config();
MMIYOO_EventInit();
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions sdl2/src/video/mmiyoo/SDL_video_mmiyoo.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
#define JSON_NDS_MIN_CPU "mincpu"
#define JSON_NDS_OVERLAY "overlay"
#define JSON_NDS_ALT_MODE "alt"
#define JSON_NDS_SWAP_L1L2 "swap_l1l2"
#define JSON_NDS_SWAP_R1R2 "swap_r1r2"

typedef struct MMIYOO_VideoInfo {
SDL_Window *window;
Expand Down Expand Up @@ -147,6 +149,8 @@ typedef struct _NDS {
int dis_mode;
int alt_mode;
int hres_mode;
int swap_l1l2;
int swap_r1r2;
int defer_update_bg;
char cfg_path[MAX_PATH];

Expand Down

0 comments on commit d84ce29

Please sign in to comment.