Browse Source

atari800 0.2.0

dirtyrect
asiekierka 2 years ago
parent
commit
f47b6a60f1

+ 7
- 8
Makefile.3ds View File

@@ -34,28 +34,28 @@ INCLUDES	:=	src
34 34
 ROMFS		:=	src/3ds/romfs
35 35
 
36 36
 APP_TITLE=atari800
37
-APP_DESCRIPTION=\"Atari 8-bit computer emulator (0.1.2)\"
37
+APP_DESCRIPTION=\"Atari 8-bit computer emulator (0.2.0)\"
38 38
 APP_AUTHOR=\"atari800 development team\"
39
-ICON = src/3ds/gfx/icon.png
39
+ICON = src/3ds/banner/atari800-icon.png
40 40
 
41 41
 #	src/af80.c \
42
+#	src/bit3.c \
42 43
 #	src/pbi_proto80.c \
43 44
 #	src/pbi_bb.c \
44 45
 #	src/pbi_mio.c \
45 46
 #	src/pbi_xld.c \
46 47
 #	src/xep80.c \
47 48
 #	src/xep80_fonts.c \
49
+#	src/atari_ntsc/atari_ntsc.c \
50
+#	src/filter_ntsc.c \
48 51
 
49
-GRAPHICS = \
50
-	src/3ds/gfx/kbd_mapping.png \
51
-
52
+GRAPHICS =
52 53
 
53 54
 SOURCES = \
54 55
 	src/afile.c \
55 56
 	src/antic.c \
56 57
 	src/artifact.c \
57 58
 	src/atari.c \
58
-	src/atari_ntsc/atari_ntsc.c \
59 59
 	src/binload.c \
60 60
 	src/cartridge.c \
61 61
 	src/cassette.c \
@@ -71,7 +71,6 @@ SOURCES = \
71 71
 	src/devices.c \
72 72
 	src/emuos.c \
73 73
 	src/esc.c \
74
-	src/filter_ntsc.c \
75 74
 	src/gtia.c \
76 75
 	src/ide.c \
77 76
 	src/img_tape.c \
@@ -111,7 +110,7 @@ SOURCES = \
111 110
 #---------------------------------------------------------------------------------
112 111
 ARCH	:=	-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
113 112
 
114
-CFLAGS	:=	-g -Wall -O2 -flto -mword-relocations -D_GNU_SOURCE \
113
+CFLAGS	:=	-g -Wall -O3 -flto -mword-relocations -D_GNU_SOURCE \
115 114
 			-fomit-frame-pointer -ffunction-sections \
116 115
 			$(ARCH)
117 116
 

+ 7
- 0
build-cia.sh View File

@@ -0,0 +1,7 @@
1
+#!/bin/sh
2
+bannertool makebanner -i src/3ds/banner/atari800-banner.png \
3
+	-a src/3ds/banner/silence.wav -o atari800-cia.bnr
4
+bannertool makesmdh -s "atari800" -l "atari800 computer emulator (0.2.0)" -p "atari800 team" \
5
+	-i src/3ds/banner/atari800-icon.png -o atari800-cia.smdh -r regionfree
6
+makerom -f cia -elf atari800-3ds.elf -icon atari800-cia.smdh -banner atari800-cia.bnr \
7
+	-desc app:4 -v -o atari800.cia -target t -exefslogo -rsf src/3ds/banner/atari800.rsf

BIN
src/3ds/banner/atari800-banner.png View File


BIN
src/3ds/banner/atari800-icon.png View File


+ 197
- 0
src/3ds/banner/atari800.rsf View File

@@ -0,0 +1,197 @@
1
+BasicInfo:
2
+  Title                   : "atari800"
3
+  CompanyCode             : "00"
4
+  ProductCode             : "CTR-P-AXED"
5
+  ContentType             : Application
6
+  Logo                    : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
7
+
8
+RomFs:
9
+  RootPath                : src/3ds/romfs
10
+
11
+TitleInfo:
12
+  Category                : Application
13
+  UniqueId                : 0xa51e80
14
+  
15
+CardInfo:
16
+  MediaSize               : 128MB # 128MB / 256MB / 512MB / 1GB / 2GB / 4GB
17
+  MediaType               : Card1 # Card1 / Card2
18
+  CardDevice              : NorFlash # NorFlash(Pick this if you use savedata) / None
19
+
20
+Option:
21
+  UseOnSD                 : true # true if App is to be installed to SD
22
+  FreeProductCode         : true # Removes limitations on ProductCode
23
+  MediaFootPadding        : false # If true CCI files are created with padding
24
+  EnableCrypt             : false # Enables encryption for NCCH and CIA
25
+  EnableCompress          : true # Compresses exefs code
26
+  
27
+AccessControlInfo:
28
+  #UseExtSaveData : true
29
+  #ExtSaveDataId: 0xff3ff
30
+  #UseExtendedSaveDataAccessControl: true
31
+  #AccessibleSaveDataIds: [0x101, 0x202, 0x303, 0x404, 0x505, 0x606]
32
+
33
+SystemControlInfo:
34
+  SaveDataSize: 128KB
35
+  RemasterVersion: 0
36
+  StackSize: 0x40000
37
+  
38
+# DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely)
39
+
40
+AccessControlInfo:
41
+  FileSystemAccess:
42
+   - Debug
43
+   - DirectSdmc
44
+   - DirectSdmcWrite
45
+   
46
+  IdealProcessor                : 0
47
+  AffinityMask                  : 1
48
+  
49
+  Priority                      : 16
50
+   
51
+  MaxCpu                        : 0x9E # Default
52
+  DisableDebug                  : false
53
+  EnableForceDebug              : false
54
+  CanWriteSharedPage            : false
55
+  CanUsePrivilegedPriority      : false
56
+  CanUseNonAlphabetAndNumber    : false
57
+  PermitMainFunctionArgument    : false
58
+  CanShareDeviceMemory          : false
59
+  RunnableOnSleep               : false
60
+  SpecialMemoryArrange          : false
61
+  CoreVersion                   : 2
62
+  DescVersion                   : 2
63
+  
64
+  ReleaseKernelMajor            : "02"
65
+  ReleaseKernelMinor            : "33" 
66
+  MemoryType                    : Application
67
+  HandleTableSize: 512
68
+  
69
+  SystemModeExt                 : Legacy # Legacy(Default)/124MB/178MB  Legacy:Use Old3DS SystemMode
70
+  CpuSpeed                      : 804MHz # 268MHz(Default)/804MHz
71
+  EnableL2Cache                 : true # false(default)/true
72
+  CanAccessCore2                : true 
73
+  
74
+  IORegisterMapping: 
75
+   - 1ff50000-1ff57fff
76
+   - 1ff70000-1ff77fff
77
+  MemoryMapping: 
78
+   - 1f000000-1f5fffff:r
79
+  SystemCallAccess: 
80
+    ArbitrateAddress: 34
81
+    Break: 60
82
+    CancelTimer: 28
83
+    ClearEvent: 25
84
+    ClearTimer: 29
85
+    CloseHandle: 35
86
+    ConnectToPort: 45
87
+    ControlMemory: 1
88
+    CreateAddressArbiter: 33
89
+    CreateEvent: 23
90
+    CreateMemoryBlock: 30
91
+    CreateMutex: 19
92
+    CreateSemaphore: 21
93
+    CreateThread: 8
94
+    CreateTimer: 26
95
+    DuplicateHandle: 39
96
+    ExitProcess: 3
97
+    ExitThread: 9
98
+    GetCurrentProcessorNumber: 17
99
+    GetHandleInfo: 41
100
+    GetProcessId: 53
101
+    GetProcessIdOfThread: 54
102
+    GetProcessIdealProcessor: 6
103
+    GetProcessInfo: 43
104
+    GetResourceLimit: 56
105
+    GetResourceLimitCurrentValues: 58
106
+    GetResourceLimitLimitValues: 57
107
+    GetSystemInfo: 42
108
+    GetSystemTick: 40
109
+    GetThreadContext: 59
110
+    GetThreadId: 55
111
+    GetThreadIdealProcessor: 15
112
+    GetThreadInfo: 44
113
+    GetThreadPriority: 11
114
+    MapMemoryBlock: 31
115
+    OutputDebugString: 61
116
+    QueryMemory: 2
117
+    ReleaseMutex: 20
118
+    ReleaseSemaphore: 22
119
+    SendSyncRequest1: 46
120
+    SendSyncRequest2: 47
121
+    SendSyncRequest3: 48
122
+    SendSyncRequest4: 49
123
+    SendSyncRequest: 50
124
+    SetThreadPriority: 12
125
+    SetTimer: 27
126
+    SignalEvent: 24
127
+    SleepThread: 10
128
+    UnmapMemoryBlock: 32
129
+    WaitSynchronization1: 36
130
+    WaitSynchronizationN: 37
131
+  InterruptNumbers:
132
+  ServiceAccessControl: 
133
+   - APT:U
134
+   - $hioFIO
135
+   - $hostio0
136
+   - $hostio1
137
+   - ac:u
138
+   - boss:U
139
+   - cam:u
140
+   - ir:rst
141
+   - cfg:u
142
+   - dlp:FKCL
143
+   - dlp:SRVR
144
+   - dsp::DSP
145
+   - ssl:C
146
+   - fs:USER
147
+   - gsp::Gpu
148
+   - hid:USER
149
+   - http:C
150
+   - mic:u
151
+   - ndm:u
152
+   - news:s
153
+   - nwm::UDS
154
+   - ptm:u
155
+   - pxi:dev
156
+   - soc:U
157
+   - gsp::Lcd
158
+   - y2r:u
159
+   - ldr:ro
160
+   - ir:USER
161
+   - ir:u
162
+   - csnd:SND
163
+   - am:u
164
+   - ns:s
165
+   
166
+SystemControlInfo:
167
+  Dependency: 
168
+    ac: 0x0004013000002402L
169
+    am: 0x0004013000001502L
170
+    boss: 0x0004013000003402L
171
+    camera: 0x0004013000001602L
172
+    cecd: 0x0004013000002602L
173
+    cfg: 0x0004013000001702L
174
+    codec: 0x0004013000001802L
175
+    csnd: 0x0004013000002702L
176
+    dlp: 0x0004013000002802L
177
+    dsp: 0x0004013000001a02L
178
+    friends: 0x0004013000003202L
179
+    gpio: 0x0004013000001b02L
180
+    gsp: 0x0004013000001c02L
181
+    hid: 0x0004013000001d02L
182
+    http: 0x0004013000002902L
183
+    i2c: 0x0004013000001e02L
184
+    ir: 0x0004013000003302L
185
+    mcu: 0x0004013000001f02L
186
+    mic: 0x0004013000002002L
187
+    ndm: 0x0004013000002b02L
188
+    news: 0x0004013000003502L
189
+    nim: 0x0004013000002c02L
190
+    nwm: 0x0004013000002d02L
191
+    pdn: 0x0004013000002102L
192
+    ps: 0x0004013000003102L
193
+    ptm: 0x0004013000002202L
194
+    ro: 0x0004013000003702L
195
+    socket: 0x0004013000002e02L
196
+    spi: 0x0004013000002302L
197
+    ssl: 0x0004013000002f02L

BIN
src/3ds/banner/silence.wav View File


+ 2
- 2
src/3ds/config.h View File

@@ -370,7 +370,7 @@
370 370
 #define NONLINEAR_MIXING 1
371 371
 
372 372
 /* Use NTSC video filter. */
373
-#define NTSC_FILTER 1
373
+/* #undef NTSC_FILTER */
374 374
 
375 375
 /* Define to the address where bug reports for this package should be sent. */
376 376
 #define PACKAGE_BUGREPORT "pstehlik@sophics.cz"
@@ -517,7 +517,7 @@
517 517
 #define VOICEBOX 1
518 518
 
519 519
 /* Define to allow volume only sound. */
520
-/* #undef VOL_ONLY_SOUND */
520
+#define VOL_ONLY_SOUND 1
521 521
 
522 522
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
523 523
    significant byte first (like Motorola and SPARC, unlike Intel). */

BIN
src/3ds/gfx/icon.png View File


BIN
src/3ds/gfx/kbd_mapping.png View File


+ 281
- 71
src/3ds/input.c View File

@@ -23,21 +23,166 @@
23 23
 */
24 24
 
25 25
 #include <3ds.h>
26
+#include <sf2d.h>
26 27
 
27 28
 #include "config.h"
28 29
 #include "akey.h"
29 30
 #include "input.h"
31
+#include "input_3ds.h"
30 32
 #include "log.h"
31 33
 #include "platform.h"
32 34
 #include "ui.h"
33 35
 
34
-#include "kbd_mapping_bin.h"
35
-
36 36
 int key_control;
37
+int current_key_down = AKEY_NONE;
38
+u64 key_down_time = 0;
39
+
40
+#define WARMSTART_HOLD_TIME 3*1000
41
+
42
+touch_area_t N3DS_touch_areas_key[] = {
43
+	{ 2, 130, 22, 22, AKEY_ESCAPE, 0 },
44
+	{ 23, 130, 22, 22, AKEY_1, 0 },
45
+	{ 44, 130, 22, 22, AKEY_2, 0 },
46
+	{ 65, 130, 22, 22, AKEY_3, 0 },
47
+	{ 86, 130, 22, 22, AKEY_4, 0 },
48
+	{ 107, 130, 22, 22, AKEY_5, 0 },
49
+	{ 128, 130, 22, 22, AKEY_6, 0 },
50
+	{ 149, 130, 22, 22, AKEY_7, 0 },
51
+	{ 170, 130, 22, 22, AKEY_8, 0 },
52
+	{ 191, 130, 22, 22, AKEY_9, 0 },
53
+	{ 212, 130, 22, 22, AKEY_0, 0 },
54
+	{ 233, 130, 22, 22, AKEY_LESS, 0 },
55
+	{ 254, 130, 22, 22, AKEY_GREATER, 0 },
56
+	{ 275, 130, 22, 22, AKEY_BACKSPACE, 0 },
57
+	{ 296, 130, 22, 22, AKEY_BREAK, 0 },
58
+
59
+	{ 2, 151, 34, 22, AKEY_TAB, 0 },
60
+	{ 35, 151, 22, 22, AKEY_q, 0 },
61
+	{ 56, 151, 22, 22, AKEY_w, 0 },
62
+	{ 77, 151, 22, 22, AKEY_e, 0 },
63
+	{ 98, 151, 22, 22, AKEY_r, 0 },
64
+	{ 119, 151, 22, 22, AKEY_t, 0 },
65
+	{ 140, 151, 22, 22, AKEY_y, 0 },
66
+	{ 161, 151, 22, 22, AKEY_u, 0 },
67
+	{ 182, 151, 22, 22, AKEY_i, 0 },
68
+	{ 203, 151, 22, 22, AKEY_o, 0 },
69
+	{ 224, 151, 22, 22, AKEY_p, 0 },
70
+	{ 245, 151, 22, 22, AKEY_MINUS, 0 },
71
+	{ 266, 151, 22, 22, AKEY_EQUAL, 0 },
72
+	{ 287, 151, 31, 22, AKEY_RETURN, 0 },
73
+
74
+	{ 2, 172, 37, 22, AKEY_CTRL, 0 },
75
+	{ 38, 172, 22, 22, AKEY_a, 0 },
76
+	{ 59, 172, 22, 22, AKEY_s, 0 },
77
+	{ 80, 172, 22, 22, AKEY_d, 0 },
78
+	{ 101, 172, 22, 22, AKEY_f, 0 },
79
+	{ 122, 172, 22, 22, AKEY_g, 0 },
80
+	{ 143, 172, 22, 22, AKEY_h, 0 },
81
+	{ 164, 172, 22, 22, AKEY_j, 0 },
82
+	{ 185, 172, 22, 22, AKEY_k, 0 },
83
+	{ 206, 172, 22, 22, AKEY_l, 0 },
84
+	{ 227, 172, 22, 22, AKEY_SEMICOLON, 0 },
85
+	{ 248, 172, 22, 22, AKEY_PLUS, 0 },
86
+	{ 279, 172, 22, 22, AKEY_ASTERISK, 0 },
87
+	{ 290, 172, 28, 22, AKEY_CAPSTOGGLE, 0 },
88
+
89
+	{ 2, 193, 43, 22, AKEY_SHFT, 0 },
90
+	{ 44, 193, 22, 22, AKEY_z, 0 },
91
+	{ 65, 193, 22, 22, AKEY_x, 0 },
92
+	{ 86, 193, 22, 22, AKEY_c, 0 },
93
+	{ 107, 193, 22, 22, AKEY_v, 0 },
94
+	{ 128, 193, 22, 22, AKEY_b, 0 },
95
+	{ 159, 193, 22, 22, AKEY_n, 0 },
96
+	{ 170, 193, 22, 22, AKEY_m, 0 },
97
+	{ 191, 193, 22, 22, AKEY_COMMA, 0 },
98
+	{ 212, 193, 22, 22, AKEY_FULLSTOP, 0 },
99
+	{ 233, 193, 22, 22, AKEY_SLASH, 0 },
100
+	{ 254, 193, 43, 22, AKEY_SHFT, 0 },
101
+	{ 296, 193, 22, 22, AKEY_ATARI, 0 },
102
+
103
+	{ 64, 214, 190, 22, AKEY_SPACE, 0 },
104
+
105
+	{ 153, 98, 32, 16, AKEY_HELP, TA_FLAG_SLANTED },
106
+	{ 186, 98, 32, 16, AKEY_START, TA_FLAG_SLANTED },
107
+	{ 219, 98, 32, 16, AKEY_SELECT, TA_FLAG_SLANTED },
108
+	{ 252, 98, 32, 16, AKEY_OPTION, TA_FLAG_SLANTED },
109
+	{ 285, 98, 32, 16, AKEY_WARMSTART, TA_FLAG_SLANTED }
110
+};
111
+
112
+#define N3DS_TOUCH_AREA_MAX (sizeof(N3DS_touch_areas_key) / sizeof(touch_area_t))
113
+
114
+bool N3DS_IsControlPressed()
115
+{
116
+	return key_control != 0;
117
+}
118
+
119
+static bool isKeyTouched(touchPosition* pos, touch_area_t* area)
120
+{
121
+	if (area->flags & TA_FLAG_SLANTED)
122
+	{
123
+		if (pos->py >= area->y && pos->py < (area->y + area->h))
124
+		{
125
+			int slx = pos->px + (pos->py - area->y);
126
+			return slx >= area->x && slx < (area->x + area->w);
127
+		}
128
+
129
+		return false;
130
+	} else
131
+	{
132
+		return pos->px >= area->x && pos->py >= area->y
133
+			&& pos->px < (area->x + area->w)
134
+			&& pos->py < (area->y + area->h);
135
+	}
136
+}
37 137
 
38
-int N3DS_IsControlPressed()
138
+void N3DS_DrawKeyboard(sf2d_texture *tex)
39 139
 {
40
-	return key_control;
140
+	touch_area_t* keyTable = N3DS_touch_areas_key;
141
+	int keyTableLen = N3DS_TOUCH_AREA_MAX;
142
+
143
+	touchPosition pos;
144
+	bool isTouch = ((hidKeysDown() | hidKeysHeld()) & KEY_TOUCH) != 0;
145
+
146
+	sf2d_draw_texture_part(tex, 0, 0, 0, 0, 320, 240);
147
+
148
+	if (INPUT_key_shift != 0)
149
+	{
150
+		sf2d_draw_texture_part(tex, 2, 194, 322, 194, 43, 22);
151
+		sf2d_draw_texture_part(tex, 254, 194, 574, 194, 43, 22);
152
+	}
153
+
154
+	if (N3DS_IsControlPressed())
155
+	{
156
+		sf2d_draw_texture_part(tex, 2, 172, 322, 172, 37, 22);
157
+	}
158
+
159
+	int key_down = current_key_down;
160
+	if (key_down == AKEY_SHFT || key_down == AKEY_CTRL) key_down = AKEY_NONE;
161
+	if (key_down >= 0) key_down &= ~AKEY_SHFTCTRL;
162
+
163
+	hidTouchRead(&pos);
164
+	for (int i = 0; i < keyTableLen; i++)
165
+	{
166
+		touch_area_t* area = &keyTable[i];
167
+		if (key_down == area->keycode
168
+			|| (isTouch && (
169
+				(area->keycode == AKEY_START) ||
170
+				(area->keycode == AKEY_SELECT) ||
171
+				(area->keycode == AKEY_OPTION)
172
+			) && isKeyTouched(&pos, area))
173
+		)
174
+		{
175
+			if (area->flags & TA_FLAG_SLANTED)
176
+			{
177
+				for (int i = 0; i < area->h; i++)
178
+					sf2d_draw_texture_part(tex, area->x - i, area->y + i,
179
+						area->x + 320 - i, area->y + i, area->w, 1);
180
+			}
181
+			else
182
+				sf2d_draw_texture_part(tex, area->x, area->y,
183
+					area->x + 320, area->y, area->w, area->h);
184
+		}
185
+	}
41 186
 }
42 187
 
43 188
 void PLATFORM_SetJoystickKey(int joystick, int direction, int value)
@@ -56,15 +201,28 @@ int PLATFORM_GetRawKey(void)
56 201
 int PLATFORM_Keyboard(void)
57 202
 {
58 203
 	u32 kDown, kHeld, kUp;
59
-	u32* kMapping;
60 204
 	touchPosition pos;
61
-	int posPixel;
205
+	int shiftctrl = (INPUT_key_shift != 0 ? AKEY_SHFT : 0) | (key_control != 0 ? AKEY_CTRL : 0);
62 206
 
63 207
 	hidScanInput();
64 208
 	kDown = hidKeysDown();
65 209
 	kHeld = hidKeysHeld();
66 210
 	kUp = hidKeysUp();
67 211
 
212
+	// reset
213
+	INPUT_key_consol = INPUT_CONSOL_NONE;
214
+
215
+	if (kUp & KEY_TOUCH)
216
+	{
217
+		if (current_key_down != AKEY_CTRL && current_key_down != AKEY_SHFT)
218
+		{
219
+			INPUT_key_shift = 0;
220
+			key_control = 0;
221
+		}
222
+		current_key_down = AKEY_NONE;
223
+		PLATFORM_DisplayScreen();
224
+	}
225
+
68 226
 	if (UI_is_active)
69 227
 	{
70 228
 		if (kDown & KEY_A)
@@ -89,85 +247,137 @@ int PLATFORM_Keyboard(void)
89 247
 			return AKEY_WARMSTART;
90 248
 	}
91 249
 
92
-	INPUT_key_consol = INPUT_CONSOL_NONE;
93
-
94
-	if (kHeld & KEY_START)
95
-		INPUT_key_consol &= ~INPUT_CONSOL_START;
96
-	if (kHeld & KEY_SELECT)
97
-		INPUT_key_consol &= ~INPUT_CONSOL_SELECT;
98
-	if (kHeld & KEY_R)
99
-		INPUT_key_consol &= ~INPUT_CONSOL_OPTION;
100
-	if (kHeld & KEY_B)
101
-		return AKEY_RETURN;
102
-	if (kHeld & KEY_Y)
103
-		return AKEY_SPACE;
104
-	if (kHeld & KEY_L)
105
-		return AKEY_UI;
106
-	if (kHeld & KEY_DUP)
107
-		return AKEY_UP;
108
-	if (kHeld & KEY_DLEFT)
109
-		return AKEY_LEFT;
110
-	if (kHeld & KEY_DRIGHT)
111
-		return AKEY_RIGHT;
112
-	if (kHeld & KEY_DDOWN)
113
-		return AKEY_DOWN;
250
+	if (Atari800_machine_type == Atari800_MACHINE_5200) {
251
+		if (kHeld & KEY_START)
252
+			return AKEY_5200_START;
253
+		if (kHeld & KEY_SELECT)
254
+			return AKEY_5200_PAUSE;
255
+		if (kHeld & KEY_R)
256
+			return AKEY_5200_RESET;
257
+		if (kHeld & KEY_L)
258
+			return AKEY_UI;
259
+	} else
260
+	{
261
+		if (kHeld & KEY_START)
262
+			INPUT_key_consol &= ~INPUT_CONSOL_START;
263
+		if (kHeld & KEY_SELECT)
264
+			INPUT_key_consol &= ~INPUT_CONSOL_SELECT;
265
+		if (kHeld & KEY_R)
266
+			INPUT_key_consol &= ~INPUT_CONSOL_OPTION;
267
+		if (kHeld & KEY_B)
268
+			return AKEY_RETURN;
269
+		if (kHeld & KEY_Y)
270
+			return AKEY_SPACE;
271
+		if (kHeld & KEY_L)
272
+			return AKEY_UI;
273
+		if (kHeld & KEY_DUP)
274
+			return AKEY_UP;
275
+		if (kHeld & KEY_DLEFT)
276
+			return AKEY_LEFT;
277
+		if (kHeld & KEY_DRIGHT)
278
+			return AKEY_RIGHT;
279
+		if (kHeld & KEY_DDOWN)
280
+			return AKEY_DOWN;
281
+	}
114 282
 
115 283
 	if ((kDown | kHeld) & KEY_TOUCH)
116 284
 	{
117 285
 		hidTouchRead(&pos);
118
-		kMapping = (u32*) kbd_mapping_bin;
119
-		if (pos.px >= 0 && pos.px < 320 && pos.py >= 0 && pos.py < 240)
286
+		touch_area_t* keyTable = N3DS_touch_areas_key;
287
+		int keyTableLen = N3DS_TOUCH_AREA_MAX;
288
+		bool down = (kDown & KEY_TOUCH) != 0;
289
+		bool touching = ((kDown | kHeld) & KEY_TOUCH) != 0;
290
+		bool refresh = false;
291
+
292
+		if (down) current_key_down = AKEY_NONE;
293
+
294
+		for (int i = 0; i < keyTableLen; i++)
120 295
 		{
121
-			posPixel = kMapping[pos.py * 320 + pos.px] & 0xFFFFFF;
122
-			if (kDown & KEY_TOUCH)
296
+			touch_area_t* area = &keyTable[i];
297
+			if (isKeyTouched(&pos, area))
123 298
 			{
124
-				if ((posPixel & 0xff00ff) == 0)
299
+				refresh |= down;
300
+				switch (area->keycode)
125 301
 				{
126
-					int val = (posPixel >> 10) | (INPUT_key_shift != 0 ? AKEY_SHFT : 0)
127
-						| (key_control != 0 ? AKEY_CTRL : 0);
302
+					case AKEY_SHFT:
303
+						if (down)
304
+						{
305
+							INPUT_key_shift = 1;
306
+							PLATFORM_DisplayScreen();
307
+							current_key_down = AKEY_SHFT;
308
+						}
309
+						break;
310
+					case AKEY_CTRL:
311
+						if (down)
312
+						{
313
+							key_control = 1;
314
+							PLATFORM_DisplayScreen();
315
+							current_key_down = AKEY_CTRL;
316
+						}
317
+						break;
318
+					case AKEY_START:
319
+						if (touching) INPUT_key_consol &= ~INPUT_CONSOL_START;
320
+						break;
321
+					case AKEY_SELECT:
322
+						if (touching) INPUT_key_consol &= ~INPUT_CONSOL_SELECT;
323
+						break;
324
+					case AKEY_OPTION:
325
+						if (touching) INPUT_key_consol &= ~INPUT_CONSOL_OPTION;
326
+						break;
327
+					case AKEY_WARMSTART:
328
+						if (down)
329
+						{
330
+							key_down_time = osGetTime();
331
+							current_key_down = AKEY_WARMSTART;
332
+							break;
333
+						} else if (touching && (osGetTime() - key_down_time) > WARMSTART_HOLD_TIME)
334
+						{
335
+							return AKEY_WARMSTART;
336
+						}
337
+					default:
338
+						if (down) current_key_down = area->keycode >= 0
339
+							? (area->keycode | shiftctrl)
340
+							: area->keycode;
341
+						break;
342
+				}
343
+				break;
344
+			}
345
+		}
128 346
 
129
-					if (INPUT_key_shift != 0 || key_control != 0)
130
-					{
131
-						INPUT_key_shift = 0;
132
-						key_control = 0;
133
-						PLATFORM_DisplayScreen();
134
-					}
347
+		if (refresh) PLATFORM_DisplayScreen();
348
+		if (current_key_down == AKEY_SHFT || current_key_down == AKEY_CTRL || current_key_down == AKEY_WARMSTART)
349
+			return AKEY_NONE;
350
+		else
351
+			return current_key_down;
352
+	}
135 353
 
136
-					return val;
137
-				}
354
+	return AKEY_NONE;
355
+}
138 356
 
139
-				if (posPixel == 0xff00ff || posPixel == 0x7f007f)
140
-					if (INPUT_key_shift != 0 || key_control != 0)
141
-					{
142
-						INPUT_key_shift = 0;
143
-						key_control = 0;
144
-						PLATFORM_DisplayScreen();
145
-					}
357
+int Atari_POT(int num)
358
+{
359
+	circlePosition pos;
146 360
 
147
-				if (posPixel == 0x8080ff)
148
-				{
149
-					key_control = 1;
150
-					PLATFORM_DisplayScreen();
151
-				}
152
-				if (posPixel == 0xa0a0ff)
153
-				{
154
-					INPUT_key_shift = 1;
155
-					PLATFORM_DisplayScreen();
156
-				}
157
-				if (posPixel == 0xe0e0ff)
158
-					return AKEY_BREAK;
159
-			}
361
+	if (Atari800_machine_type == Atari800_MACHINE_5200)
362
+	{
363
+		int cid = num >> 1;
364
+		int caxis = num & 1;
365
+		if (cid != 0)
366
+			return INPUT_joy_5200_center;
160 367
 
161
-			if (posPixel == 0x2020ff)
162
-				INPUT_key_consol &= ~INPUT_CONSOL_START;
163
-			if (posPixel == 0x4040ff)
164
-				INPUT_key_consol &= ~INPUT_CONSOL_SELECT;
165
-			if (posPixel == 0x6060ff)
166
-				INPUT_key_consol &= ~INPUT_CONSOL_OPTION;
368
+		hidScanInput();
369
+		hidCircleRead(&pos);
370
+		int val = caxis ? pos.dy : pos.dx;
371
+		if (val == 0) return INPUT_joy_5200_center;
372
+		else if (val > 0) {
373
+			return (INPUT_joy_5200_max - INPUT_joy_5200_center) * val / 0x9C + INPUT_joy_5200_center;
374
+		} else {
375
+			return (INPUT_joy_5200_min - INPUT_joy_5200_center) * val / 0x9C + INPUT_joy_5200_center;
167 376
 		}
377
+	} else
378
+	{
379
+		return 228;
168 380
 	}
169
-
170
-	return AKEY_NONE;
171 381
 }
172 382
 
173 383
 int PLATFORM_PORT(int num)

+ 18
- 0
src/3ds/input_3ds.h View File

@@ -0,0 +1,18 @@
1
+#ifndef _INPUT_3DS_H_
2
+#define _INPUT_3DS_H_
3
+
4
+#include "akey.h"
5
+
6
+bool N3DS_IsControlPressed();
7
+void N3DS_DrawKeyboard(sf2d_texture *tex);
8
+
9
+typedef struct
10
+{
11
+	u16 x, y, w, h;
12
+	s16 keycode;
13
+	u8 flags;
14
+} touch_area_t;
15
+
16
+#define TA_FLAG_SLANTED 1
17
+
18
+#endif /* _INPUT_3DS_H */

BIN
src/3ds/romfs/kbd_ctrl_pressed.png View File


BIN
src/3ds/romfs/kbd_display.png View File


BIN
src/3ds/romfs/kbd_shift_pressed.png View File


+ 26
- 30
src/3ds/sound_ndsp.c View File

@@ -32,9 +32,10 @@
32 32
 #include "sound.h"
33 33
 
34 34
 int N3DS_soundFreq;
35
-ndspWaveBuf N3DS_audioBuf;
35
+bool N3DS_soundFillBlock;
36
+ndspWaveBuf N3DS_audioBuf[2];
36 37
 u8*	N3DS_audioData;
37
-u32	N3DS_bufferSize, N3DS_sampleSize, N3DS_lastPos;
38
+u32	N3DS_bufferSize, N3DS_sampleSize;
38 39
 Sound_setup_t *N3DS_sound;
39 40
 
40 41
 void N3DS_ClearAudioData(void);
@@ -65,31 +66,24 @@ int PLATFORM_SoundSetup(Sound_setup_t *setup)
65 66
 
66 67
 void N3DS_SoundCallback(void* dud)
67 68
 {
68
-	u32 pos = ndspChnGetSamplePos(0);
69 69
 	u32 flen = (N3DS_bufferSize * N3DS_sampleSize);
70
-	u32 fmax = flen >> 2;
71
-	if (pos >= N3DS_bufferSize && N3DS_lastPos < N3DS_bufferSize)
72
-	{
73
-		Sound_Callback(&N3DS_audioData[0], flen);
74
-		u32* audioDataPtr = (u32*) &N3DS_audioData[0];
75
-		for(int i = 0; i < fmax; i++)
76
-			*(audioDataPtr++) ^= 0x80808080;
77
-	}
78
-	else if (pos < N3DS_bufferSize && N3DS_lastPos >= N3DS_bufferSize)
79
-	{
80
-		Sound_Callback(&N3DS_audioData[flen], flen);
81
-		u32* audioDataPtr = (u32*) &N3DS_audioData[flen];
82
-		for(int i = 0; i < fmax; i++)
83
-			*(audioDataPtr++) ^= 0x80808080;
70
+
71
+	if (N3DS_audioBuf[N3DS_soundFillBlock].status == NDSP_WBUF_DONE) {
72
+		Sound_Callback((u8*) N3DS_audioBuf[N3DS_soundFillBlock].data_pcm8, flen);
73
+		for(int i = 0; i < flen; i++)
74
+			N3DS_audioBuf[N3DS_soundFillBlock].data_pcm8[i] ^= 0x80;
75
+
76
+		DSP_FlushDataCache(N3DS_audioBuf[N3DS_soundFillBlock].data_pcm8, flen);
77
+
78
+		ndspChnWaveBufAdd(0, &N3DS_audioBuf[N3DS_soundFillBlock]);
79
+		N3DS_soundFillBlock = !N3DS_soundFillBlock;
84 80
 	}
85
-	N3DS_lastPos = pos;
86 81
 }
87 82
 
88 83
 void N3DS_ClearAudioData(void)
89 84
 {
90 85
 	memset(N3DS_audioData, 0, N3DS_bufferSize * 2 * N3DS_sampleSize);
91
-	DSP_FlushDataCache(N3DS_audioData, N3DS_bufferSize * 2 * N3DS_sampleSize);
92
-	N3DS_lastPos = 0;
86
+	N3DS_soundFillBlock = false;
93 87
 }
94 88
 
95 89
 void PLATFORM_SoundLock(void)
@@ -121,23 +115,25 @@ void PLATFORM_SoundContinue(void)
121 115
 	mix[0] = mix[1] = 1.0f;
122 116
 
123 117
 	ndspSetOutputMode(N3DS_sound->channels == 2 ? NDSP_OUTPUT_STEREO : NDSP_OUTPUT_MONO);
124
-	ndspSetOutputCount(1);
125
-	ndspSetMasterVol(1.0f);
126
-	ndspSetCallback(N3DS_SoundCallback, N3DS_audioData);
127 118
 
128
-	memset(&N3DS_audioBuf, 0, sizeof(ndspWaveBuf));
129 119
 	ndspChnReset(0);
130
-	ndspChnSetInterp(0, NDSP_INTERP_POLYPHASE);
120
+	ndspChnSetInterp(0, NDSP_INTERP_LINEAR);
131 121
 	ndspChnSetRate(0, N3DS_sound->freq);
132 122
 	ndspChnSetFormat(0, NDSP_CHANNELS(N3DS_sound->channels) | NDSP_ENCODING(N3DS_sound->sample_size == 2 ? NDSP_ENCODING_PCM16 : NDSP_ENCODING_PCM8));
133 123
 	ndspChnSetMix(0, mix);
134 124
 
135
-	N3DS_audioBuf.data_vaddr = N3DS_audioData;
136
-	N3DS_audioBuf.nsamples = N3DS_bufferSize * 2;
137
-	N3DS_audioBuf.looping = true;
138
-	N3DS_audioBuf.status = NDSP_WBUF_FREE;
125
+	ndspSetOutputCount(1);
126
+	ndspSetMasterVol(1.0f);
127
+	ndspSetCallback(N3DS_SoundCallback, N3DS_audioBuf);
128
+
129
+	memset(N3DS_audioBuf, 0, sizeof(N3DS_audioBuf));
130
+	N3DS_audioBuf[0].data_vaddr = &N3DS_audioData[0];
131
+	N3DS_audioBuf[0].nsamples = N3DS_bufferSize;
132
+	N3DS_audioBuf[1].data_vaddr = &N3DS_audioData[N3DS_bufferSize];
133
+	N3DS_audioBuf[1].nsamples = N3DS_bufferSize;
139 134
 
140 135
 	N3DS_ClearAudioData();
141 136
 
142
-	ndspChnWaveBufAdd(0, &N3DS_audioBuf);
137
+	ndspChnWaveBufAdd(0, &N3DS_audioBuf[0]);
138
+	ndspChnWaveBufAdd(0, &N3DS_audioBuf[1]);
143 139
 }

+ 15
- 30
src/3ds/video.c View File

@@ -30,8 +30,8 @@
30 30
 #include "atari.h"
31 31
 #include "colours.h"
32 32
 #include "config.h"
33
-#include "filter_ntsc.h"
34 33
 #include "input.h"
34
+#include "input_3ds.h"
35 35
 #include "log.h"
36 36
 #ifdef PAL_BLENDING
37 37
 #include "pal_blending.h"
@@ -42,7 +42,7 @@
42 42
 #include "videomode.h"
43 43
 
44 44
 int texInitialized = 0;
45
-sf2d_texture *tex, *kbd_display, *kbd_ctrl_pressed, *kbd_shift_pressed;
45
+sf2d_texture *tex, *kbd_display;
46 46
 u32 *texBuf;
47 47
 VIDEOMODE_MODE_t N3DS_VIDEO_mode;
48 48
 int ctable[256];
@@ -79,12 +79,10 @@ void N3DS_InitTexture(void)
79 79
 		sf2d_swapbuffers();
80 80
 		sf2d_set_3D(0);
81 81
 
82
-		tex = sf2d_create_texture(512, Screen_HEIGHT, TEXFMT_RGBA8, SF2D_PLACE_VRAM);
83
-		texBuf = linearAlloc((tex->tex.width * tex->tex.height) << 2);
82
+		tex = sf2d_create_texture(512, 256, TEXFMT_RGBA8, SF2D_PLACE_RAM);
83
+		texBuf = linearAlloc(512 * 256 * 4);
84 84
 
85
-		kbd_display = sfil_load_PNG_file("romfs:/kbd_display.png", SF2D_PLACE_VRAM);
86
-		kbd_ctrl_pressed = sfil_load_PNG_file("romfs:/kbd_ctrl_pressed.png", SF2D_PLACE_VRAM);
87
-		kbd_shift_pressed = sfil_load_PNG_file("romfs:/kbd_shift_pressed.png", SF2D_PLACE_VRAM);
85
+		kbd_display = sfil_load_PNG_file("romfs:/kbd_display.png", SF2D_PLACE_RAM);
88 86
 		texInitialized = 1;
89 87
 	}
90 88
 }
@@ -116,10 +114,10 @@ void PLATFORM_MapRGB(void *dest, int const *palette, int size)
116 114
 	}
117 115
 }
118 116
 
119
-static void UpdateNtscFilter(VIDEOMODE_MODE_t mode)
117
+/* static void UpdateNtscFilter(VIDEOMODE_MODE_t mode)
120 118
 {
121 119
 
122
-}
120
+} */
123 121
 
124 122
 void PLATFORM_SetVideoMode(VIDEOMODE_resolution_t const *res, int windowed, VIDEOMODE_MODE_t mode, int rotate90)
125 123
 {
@@ -182,18 +180,21 @@ void PLATFORM_DisplayScreen(void)
182 180
 #endif
183 181
 		N3DS_RenderNormal(src, dest);
184 182
 
183
+	GSPGPU_FlushDataCache(texBuf, 512 * 256 * 4);
184
+
185 185
 	const u32 sdtFlags = (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) |
186 186
 		GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGBA8) |
187 187
 		GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO));
188 188
 
189
-	GSPGPU_FlushDataCache(texBuf, 512 * 256 * 4);
190
-	GSPGPU_FlushDataCache(tex->tex.data, tex->tex.size);
191
-
192
-	C3D_SafeDisplayTransfer(texBuf, GX_BUFFER_DIM(512, 256), tex->tex.data,
189
+	GX_DisplayTransfer(texBuf, GX_BUFFER_DIM(512, 256), tex->tex.data,
193 190
 		GX_BUFFER_DIM(tex->tex.width, tex->tex.height), sdtFlags);
194 191
 
195
-	tex->tiled = 1;
196 192
 	gspWaitForPPF();
193
+	tex->tiled = 1;
194
+
195
+	sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
196
+	N3DS_DrawKeyboard(kbd_display);
197
+	sf2d_end_frame();
197 198
 
198 199
 	sf2d_start_frame(GFX_TOP, GFX_LEFT);
199 200
 	if (VIDEOMODE_dest_width <= 400 && VIDEOMODE_dest_height <= 240 && VIDEOMODE_src_width == VIDEOMODE_dest_width && VIDEOMODE_src_height == VIDEOMODE_dest_height)
@@ -202,9 +203,6 @@ void PLATFORM_DisplayScreen(void)
202 203
 			(400 - VIDEOMODE_dest_width) / 2, (240 - VIDEOMODE_dest_height) / 2,
203 204
 			0, 0, VIDEOMODE_dest_width, VIDEOMODE_dest_height
204 205
 		);
205
-//		sf2d_draw_texture(tex,
206
-//			(400 - VIDEOMODE_dest_width) / 2, (240 - VIDEOMODE_dest_height) / 2
207
-//		);
208 206
 	}
209 207
 	else
210 208
 	{
@@ -215,21 +213,8 @@ void PLATFORM_DisplayScreen(void)
215 213
 			0, 0, VIDEOMODE_src_width, VIDEOMODE_src_height,
216 214
 			xs, ys
217 215
 		);
218
-//		sf2d_draw_texture_scale(tex,
219
-//			(400 - VIDEOMODE_dest_width) / 2, (240 - VIDEOMODE_dest_height) / 2,
220
-//			xs, ys
221
-//		);
222 216
 	}
223 217
 	sf2d_end_frame();
224 218
 
225
-	/* Keyboard rendering */
226
-	sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
227
-	sf2d_draw_texture(kbd_display, 0, 0);
228
-	if (INPUT_key_shift != 0)
229
-		sf2d_draw_texture(kbd_shift_pressed, 0, 0);
230
-	if (N3DS_IsControlPressed() != 0)
231
-		sf2d_draw_texture(kbd_ctrl_pressed, 0, 0);
232
-	sf2d_end_frame();
233
-
234 219
 	sf2d_swapbuffers();
235 220
 }

+ 1
- 1
src/input.c View File

@@ -625,7 +625,7 @@ void INPUT_Frame(void)
625 625
 	}
626 626
 	else {
627 627
 		for (i = 0; i < 4; i++) {
628
-#ifdef DREAMCAST
628
+#if defined(DREAMCAST) || defined(_3DS)
629 629
 			/* first get analog js data */
630 630
 			POKEY_POT_input[2 * i] = Atari_POT(2 * i);         /* x */
631 631
 			POKEY_POT_input[2 * i + 1] = Atari_POT(2 * i + 1); /* y */

Loading…
Cancel
Save