Browse Source

Initial 3DS port

dirtyrect
asiekierka 2 years ago
parent
commit
b5b462dfee

+ 3
- 0
.gitignore View File

@@ -1,6 +1,8 @@
1 1
 **/CVS
2 2
 autom4te.cache/
3 3
 *.o
4
+*.d
5
+*.bin
4 6
 /src/Makefile
5 7
 /src/atari800
6 8
 /src/config.h
@@ -8,3 +10,4 @@ autom4te.cache/
8 10
 /src/config.log
9 11
 /src/config.status
10 12
 /src/configure
13
+

+ 259
- 0
Makefile.3ds View File

@@ -0,0 +1,259 @@
1
+#---------------------------------------------------------------------------------
2
+.SUFFIXES:
3
+#---------------------------------------------------------------------------------
4
+
5
+ifeq ($(strip $(DEVKITARM)),)
6
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
7
+endif
8
+
9
+TOPDIR ?= $(CURDIR)
10
+include $(DEVKITARM)/3ds_rules
11
+
12
+#---------------------------------------------------------------------------------
13
+# TARGET is the name of the output
14
+# BUILD is the directory where object files & intermediate files will be placed
15
+# SOURCES is a list of directories containing source code
16
+# DATA is a list of directories containing data files
17
+# INCLUDES is a list of directories containing header files
18
+#
19
+# NO_SMDH: if set to anything, no SMDH file is generated.
20
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
21
+# APP_TITLE is the name of the app stored in the SMDH file (Optional)
22
+# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
23
+# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
24
+# ICON is the filename of the icon (.png), relative to the project folder.
25
+#   If not set, it attempts to use one of the following (in this order):
26
+#     - <Project name>.png
27
+#     - icon.png
28
+#     - <libctru folder>/default_icon.png
29
+#---------------------------------------------------------------------------------
30
+TARGET		:=	$(notdir $(CURDIR))
31
+BUILD		:=	build
32
+#DATA		:=	data
33
+INCLUDES	:=	src
34
+ROMFS		:=	src/3ds/romfs
35
+
36
+APP_TITLE=atari800
37
+APP_DESCRIPTION=\"Atari 8-bit computer emulator\"
38
+APP_AUTHOR=\"atari800 development team\"
39
+ICON = src/3ds/gfx/icon.png
40
+
41
+#	src/af80.c \
42
+#	src/pbi_proto80.c \
43
+#	src/xep80.c \
44
+#	src/xep80_fonts.c \
45
+
46
+GRAPHICS = \
47
+	src/3ds/gfx/kbd_mapping.png \
48
+
49
+
50
+SOURCES = \
51
+	src/afile.c \
52
+	src/antic.c \
53
+	src/artifact.c \
54
+	src/atari.c \
55
+	src/atari_ntsc/atari_ntsc.c \
56
+	src/binload.c \
57
+	src/cartridge.c \
58
+	src/cassette.c \
59
+	src/compfile.c \
60
+	src/cfg.c \
61
+	src/colours.c \
62
+	src/colours_external.c \
63
+	src/colours_ntsc.c \
64
+	src/colours_pal.c \
65
+	src/cpu.c \
66
+	src/crc32.c \
67
+	src/cycle_map.c \
68
+	src/devices.c \
69
+	src/emuos.c \
70
+	src/esc.c \
71
+	src/filter_ntsc.c \
72
+	src/gtia.c \
73
+	src/ide.c \
74
+	src/img_tape.c \
75
+	src/input.c \
76
+	src/log.c \
77
+	src/memory.c \
78
+	src/monitor.c \
79
+	src/mzpokeysnd.c \
80
+	src/pal_blending.c \
81
+	src/pbi.c \
82
+	src/pbi_bb.c \
83
+	src/pbi_mio.c \
84
+	src/pbi_scsi.c \
85
+	src/pbi_xld.c \
86
+	src/pia.c \
87
+	src/pokey.c \
88
+	src/pokeysnd.c \
89
+	src/remez.c \
90
+	src/rtime.c \
91
+	src/screen.c \
92
+	src/sio.c \
93
+	src/sndsave.c \
94
+	src/sound.c \
95
+	src/statesav.c \
96
+	src/sysrom.c \
97
+	src/ui.c \
98
+	src/ui_basic.c \
99
+	src/util.c \
100
+	src/videomode.c \
101
+	src/voicebox.c \
102
+	src/votrax.c \
103
+	src/votraxsnd.c \
104
+	src/3ds/input.c \
105
+	src/3ds/main.c \
106
+	src/3ds/sound_ndsp.c \
107
+	src/3ds/video.c
108
+
109
+#---------------------------------------------------------------------------------
110
+# options for code generation
111
+#---------------------------------------------------------------------------------
112
+ARCH	:=	-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
113
+
114
+CFLAGS	:=	-g -Wall -O2 -mword-relocations -D_GNU_SOURCE \
115
+			-fomit-frame-pointer -ffunction-sections \
116
+			$(ARCH)
117
+
118
+CFLAGS	+=	$(INCLUDE) -DARM11 -D_3DS
119
+
120
+CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
121
+
122
+ASFLAGS	:=	-g $(ARCH)
123
+LDFLAGS	=	-specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
124
+
125
+LIBS := -lsfil -lpng -lz -lsf2d -lcitro3d -lctru -lm
126
+
127
+#---------------------------------------------------------------------------------
128
+# list of directories containing libraries, this must be the top level containing
129
+# include and lib
130
+#---------------------------------------------------------------------------------
131
+LIBDIRS	:= $(CTRULIB) $(DEVKITPRO)/portlibs/3ds $(DEVKITPRO)/portlibs/armv6k
132
+
133
+
134
+#---------------------------------------------------------------------------------
135
+# no real need to edit anything past this point unless you need to add additional
136
+# rules for different file extensions
137
+#---------------------------------------------------------------------------------
138
+ifneq ($(BUILD),$(notdir $(CURDIR)))
139
+#---------------------------------------------------------------------------------
140
+
141
+export OUTPUT	:=	$(CURDIR)/$(TARGET)
142
+export TOPDIR	:=	$(CURDIR)
143
+
144
+export VPATH	:=	$(CURDIR)
145
+
146
+export DEPSDIR	:=	
147
+
148
+CFILES		:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
149
+PNGFILES	:=	$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
150
+
151
+export LD	:=	$(CC)
152
+export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
153
+			$(PNGFILES:.png=.bin.o) \
154
+			$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
155
+			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
156
+
157
+
158
+export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
159
+			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
160
+			-I$(CURDIR)/$(BUILD) -I$(DEVKITPRO)/portlibs/3ds/include/SDL2 \
161
+			-I$(CURDIR)/src/3ds
162
+
163
+export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib)
164
+
165
+ifeq ($(strip $(ICON)),)
166
+	icons := $(wildcard *.png)
167
+	ifneq (,$(findstring $(TARGET).png,$(icons)))
168
+		export APP_ICON := $(TOPDIR)/$(TARGET).png
169
+	else
170
+		ifneq (,$(findstring icon.png,$(icons)))
171
+			export APP_ICON := $(TOPDIR)/icon.png
172
+		endif
173
+	endif
174
+else
175
+	export APP_ICON := $(TOPDIR)/$(ICON)
176
+endif
177
+
178
+ifeq ($(strip $(NO_SMDH)),)
179
+	export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
180
+endif
181
+
182
+ifneq ($(ROMFS),)
183
+	export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
184
+endif
185
+
186
+.PHONY: $(BUILD) clean all
187
+
188
+#---------------------------------------------------------------------------------
189
+all: $(BUILD)
190
+
191
+$(BUILD):
192
+	@[ -d $@ ] || mkdir -p $@
193
+	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.3ds
194
+
195
+#---------------------------------------------------------------------------------
196
+clean:
197
+	@echo clean ...
198
+	@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
199
+
200
+
201
+#---------------------------------------------------------------------------------
202
+else
203
+
204
+DEPENDS	:=	$(OFILES:.o=.d)
205
+
206
+#---------------------------------------------------------------------------------
207
+# main targets
208
+#---------------------------------------------------------------------------------
209
+ifeq ($(strip $(NO_SMDH)),)
210
+$(OUTPUT).3dsx	:	$(OUTPUT).elf $(OUTPUT).smdh
211
+else
212
+$(OUTPUT).3dsx	:	$(OUTPUT).elf
213
+endif
214
+
215
+$(OUTPUT).elf	:	$(OFILES)
216
+
217
+#---------------------------------------------------------------------------------
218
+# you need a rule like this for each extension you use as binary data
219
+#---------------------------------------------------------------------------------
220
+%.bin.o	:	%.bin
221
+#---------------------------------------------------------------------------------
222
+	@echo $(notdir $<)
223
+	@$(bin2o)
224
+
225
+#---------------------------------------------------------------------------------
226
+%.bin: %.png
227
+#---------------------------------------------------------------------------------
228
+	@echo $(notdir $<)
229
+	@convert $< rgba:$@
230
+
231
+#---------------------------------------------------------------------------------
232
+# rules for assembling GPU shaders
233
+#---------------------------------------------------------------------------------
234
+define shader-as
235
+	$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
236
+	picasso -o $(CURBIN) $1
237
+	bin2s $(CURBIN) | $(AS) -o $@
238
+	echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
239
+	echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
240
+	echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
241
+endef
242
+
243
+%.shbin.o : %.v.pica %.g.pica
244
+	@echo $(notdir $^)
245
+	@$(call shader-as,$^)
246
+
247
+%.shbin.o : %.v.pica
248
+	@echo $(notdir $<)
249
+	@$(call shader-as,$<)
250
+
251
+%.shbin.o : %.shlist
252
+	@echo $(notdir $<)
253
+	@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
254
+
255
+-include $(DEPENDS)
256
+
257
+#---------------------------------------------------------------------------------------
258
+endif
259
+#---------------------------------------------------------------------------------------

+ 559
- 0
src/3ds/config.h View File

@@ -0,0 +1,559 @@
1
+/* config.h.  Generated from config.h.in by configure.  */
2
+/* config.h.in.  Generated from configure.ac by autoheader.  */
3
+
4
+/* Define if building universal (internal helper macro) */
5
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
6
+
7
+/* The Austin Franklin 80 column card. */
8
+// #define AF80 1
9
+
10
+/* Target: Android */
11
+/* #undef ANDROID */
12
+
13
+/* Target: standard I/O. */
14
+/* #undef BASIC */
15
+
16
+/* Define to use buffered debug output. */
17
+/* #undef BUFFERED_LOG */
18
+
19
+/* Define to allow sound clipping. */
20
+// #define CLIP_SOUND 1
21
+#undef CLIP_SOUND
22
+
23
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
24
+/* #undef CLOSEDIR_VOID */
25
+
26
+/* Define to allow console sound (keyboard clicks). */
27
+#define CONSOLE_SOUND 1
28
+
29
+/* Define to activate crash menu after CIM instruction. */
30
+#define CRASH_MENU 1
31
+
32
+/* Define to disable bitmap graphics emulation in CURSES target. */
33
+/* #undef CURSES_BASIC */
34
+
35
+/* Alternate config filename due to 8+3 fs limit. */
36
+#define DEFAULT_CFG_NAME "/3ds/atari800/atari800.cfg"
37
+
38
+/* Target: Windows with DirectX. */
39
+/* #undef DIRECTX */
40
+
41
+/* Define to use dirty screen partial repaints. */
42
+/* #undef DIRTYRECT */
43
+
44
+/* Define to use back slash as directory separator. */
45
+/* #undef DIR_SEP_BACKSLASH */
46
+
47
+/* Target: DOS VGA. */
48
+/* #undef DOSVGA */
49
+
50
+/* Define to enable DOS style drives support. */
51
+/* #undef DOS_DRIVES */
52
+
53
+/* Define to enable event recording. */
54
+#define EVENT_RECORDING 1
55
+
56
+/* Target: Atari Falcon system. */
57
+/* #undef FALCON */
58
+
59
+/* Define to use m68k assembler CPU core for Falcon target. */
60
+/* #undef FALCON_CPUASM */
61
+
62
+/* Use SDL for graphics and input. */
63
+/* #undef GUI_SDL */
64
+
65
+/* Define to 1 if you have the <arpa/inet.h> header file. */
66
+#define HAVE_ARPA_INET_H 1
67
+
68
+/* Define to 1 if you have the `atexit' function. */
69
+#define HAVE_ATEXIT 1
70
+
71
+/* Define to 1 if you have the `chmod' function. */
72
+/* #undef HAVE_CHMOD */
73
+
74
+/* Define to 1 if you have the `clock' function. */
75
+#define HAVE_CLOCK 1
76
+
77
+/* Define to 1 if you have the <direct.h> header file. */
78
+/* #undef HAVE_DIRECT_H */
79
+
80
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
81
+   */
82
+#define HAVE_DIRENT_H 1
83
+
84
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
85
+/* #undef HAVE_DOPRNT */
86
+
87
+/* Define to 1 if you have the <errno.h> header file. */
88
+#define HAVE_ERRNO_H 1
89
+
90
+/* Define to 1 if you have the <fcntl.h> header file. */
91
+#define HAVE_FCNTL_H 1
92
+
93
+/* Define to 1 if you have the `fdopen' function. */
94
+#define HAVE_FDOPEN 1
95
+
96
+/* Define to 1 if you have the `fflush' function. */
97
+#define HAVE_FFLUSH 1
98
+
99
+/* Define to 1 if you have the <file.h> header file. */
100
+/* #undef HAVE_FILE_H */
101
+
102
+/* Define to 1 if you have the `floor' function. */
103
+#define HAVE_FLOOR 1
104
+
105
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
106
+/* #undef HAVE_FSEEKO */
107
+
108
+/* Define to 1 if you have the `fstat' function. */
109
+#define HAVE_FSTAT 1
110
+
111
+/* Define to 1 if you have the `getcwd' function. */
112
+#define HAVE_GETCWD 1
113
+
114
+/* Define to 1 if you have the `gethostbyaddr' function. */
115
+/* #undef HAVE_GETHOSTBYADDR */
116
+
117
+/* Define to 1 if you have the `gethostbyname' function. */
118
+/* #undef HAVE_GETHOSTBYNAME */
119
+
120
+/* Define to 1 if you have the `gettimeofday' function. */
121
+#define HAVE_GETTIMEOFDAY 1
122
+
123
+/* Define to 1 if you have the `inet_ntoa' function. */
124
+#define HAVE_INET_NTOA 1
125
+
126
+/* Define to 1 if you have the <inttypes.h> header file. */
127
+#define HAVE_INTTYPES_H 1
128
+
129
+/* Define to 1 if you have the `gem' library (-lgem). */
130
+/* #undef HAVE_LIBGEM */
131
+
132
+/* Define to 1 if you have the `png' library (-lpng). */
133
+#define HAVE_LIBPNG 1
134
+
135
+/* Define to 1 if you have the `z' library (-lz). */
136
+#define HAVE_LIBZ 1
137
+
138
+/* Define to 1 if you have the `localtime' function. */
139
+#define HAVE_LOCALTIME 1
140
+
141
+/* Define to 1 if you have the `memmove' function. */
142
+#define HAVE_MEMMOVE 1
143
+
144
+/* Define to 1 if you have the <memory.h> header file. */
145
+#define HAVE_MEMORY_H 1
146
+
147
+/* Define to 1 if you have the `memset' function. */
148
+#define HAVE_MEMSET 1
149
+
150
+/* Define to 1 if you have the `mkdir' function. */
151
+#define HAVE_MKDIR 1
152
+
153
+/* Define to 1 if you have the `mkstemp' function. */
154
+#define HAVE_MKSTEMP 1
155
+
156
+/* Define to 1 if you have the `mktemp' function. */
157
+#define HAVE_MKTEMP 1
158
+
159
+/* Define to 1 if you have the `modf' function. */
160
+#define HAVE_MODF 1
161
+
162
+/* Define to 1 if you have the `nanosleep' function. */
163
+/* #undef HAVE_NANOSLEEP */
164
+
165
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
166
+/* #undef HAVE_NDIR_H */
167
+
168
+/* Define to 1 if you have the <netdb.h> header file. */
169
+#define HAVE_NETDB_H 1
170
+
171
+/* Define to 1 if you have the <netinet/in.h> header file. */
172
+#define HAVE_NETINET_IN_H 1
173
+
174
+/* Define to 1 if you have the `opendir' function. */
175
+#define HAVE_OPENDIR 1
176
+
177
+/* Support for OpenGL graphics acceleration. */
178
+/* #undef HAVE_OPENGL */
179
+
180
+/* Define to 1 if you have the `rename' function. */
181
+#define HAVE_RENAME 1
182
+
183
+/* Define to 1 if you have the `rewind' function. */
184
+#define HAVE_REWIND 1
185
+
186
+/* Define to 1 if you have the `rmdir' function. */
187
+#define HAVE_RMDIR 1
188
+
189
+/* Define to 1 if you have the `select' function. */
190
+#define HAVE_SELECT 1
191
+
192
+/* Define to 1 if you have the `signal' function. */
193
+/* #undef HAVE_SIGNAL */
194
+
195
+/* Define to 1 if you have the <signal.h> header file. */
196
+#define HAVE_SIGNAL_H 1
197
+
198
+/* Define to 1 if you have the `snprintf' function. */
199
+#define HAVE_SNPRINTF 1
200
+
201
+/* Define to 1 if you have the `socket' function. */
202
+#define HAVE_SOCKET 1
203
+
204
+/* Define to 1 if you have the `stat' function. */
205
+#define HAVE_STAT 1
206
+
207
+/* Define to 1 if `stat' has the bug that it succeeds when given the
208
+   zero-length file name argument. */
209
+/* #undef HAVE_STAT_EMPTY_STRING_BUG */
210
+
211
+/* Define to 1 if you have the <stdint.h> header file. */
212
+#define HAVE_STDINT_H 1
213
+
214
+/* Define to 1 if you have the <stdlib.h> header file. */
215
+#define HAVE_STDLIB_H 1
216
+
217
+/* Define to 1 if you have the `strcasecmp' function. */
218
+#define HAVE_STRCASECMP 1
219
+
220
+/* Define to 1 if you have the `strchr' function. */
221
+#define HAVE_STRCHR 1
222
+
223
+/* Define to 1 if you have the `strdup' function. */
224
+#define HAVE_STRDUP 1
225
+
226
+/* Define to 1 if you have the `strerror' function. */
227
+#define HAVE_STRERROR 1
228
+
229
+/* Define to 1 if you have the <strings.h> header file. */
230
+#define HAVE_STRINGS_H 1
231
+
232
+/* Define to 1 if you have the <string.h> header file. */
233
+#define HAVE_STRING_H 1
234
+
235
+/* Define to 1 if you have the `strncpy' function. */
236
+#define HAVE_STRNCPY 1
237
+
238
+/* Define to 1 if you have the `strrchr' function. */
239
+#define HAVE_STRRCHR 1
240
+
241
+/* Define to 1 if you have the `strstr' function. */
242
+#define HAVE_STRSTR 1
243
+
244
+/* Define to 1 if you have the `strtol' function. */
245
+#define HAVE_STRTOL 1
246
+
247
+/* Define to 1 if you have the `system' function. */
248
+#define HAVE_SYSTEM 1
249
+
250
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
251
+   */
252
+/* #undef HAVE_SYS_DIR_H */
253
+
254
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
255
+/* #undef HAVE_SYS_IOCTL_H */
256
+
257
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
258
+   */
259
+/* #undef HAVE_SYS_NDIR_H */
260
+
261
+/* Define to 1 if you have the <sys/select.h> header file. */
262
+#define HAVE_SYS_SELECT_H 1
263
+
264
+/* Define to 1 if you have the <sys/socket.h> header file. */
265
+#define HAVE_SYS_SOCKET_H 1
266
+
267
+/* Define to 1 if you have the <sys/soundcard.h> header file. */
268
+/* #undef HAVE_SYS_SOUNDCARD_H */
269
+
270
+/* Define to 1 if you have the <sys/stat.h> header file. */
271
+#define HAVE_SYS_STAT_H 1
272
+
273
+/* Define to 1 if you have the <sys/time.h> header file. */
274
+#define HAVE_SYS_TIME_H 1
275
+
276
+/* Define to 1 if you have the <sys/types.h> header file. */
277
+#define HAVE_SYS_TYPES_H 1
278
+
279
+/* Define to 1 if you have the <termios.h> header file. */
280
+#define HAVE_TERMIOS_H 1
281
+
282
+/* Define to 1 if you have the `time' function. */
283
+#define HAVE_TIME 1
284
+
285
+/* Define to 1 if you have the <time.h> header file. */
286
+#define HAVE_TIME_H 1
287
+
288
+/* Define to 1 if you have the `tmpfile' function. */
289
+#define HAVE_TMPFILE 1
290
+
291
+/* Define to 1 if you have the `tmpnam' function. */
292
+#define HAVE_TMPNAM 1
293
+
294
+/* Define to 1 if you have the `uclock' function. */
295
+/* #undef HAVE_UCLOCK */
296
+
297
+/* Define to 1 if you have the <unistd.h> header file. */
298
+#define HAVE_UNISTD_H 1
299
+
300
+/* Define to 1 if you have the <unixio.h> header file. */
301
+/* #undef HAVE_UNIXIO_H */
302
+
303
+/* Define to 1 if you have the `unlink' function. */
304
+#define HAVE_UNLINK 1
305
+
306
+/* Define to 1 if you have the `usleep' function. */
307
+#define HAVE_USLEEP 1
308
+
309
+/* Define to 1 if you have the `vprintf' function. */
310
+#define HAVE_VPRINTF 1
311
+
312
+/* Define to 1 if you have the `vsnprintf' function. */
313
+#define HAVE_VSNPRINTF 1
314
+
315
+/* Define to 1 if you have the <windows.h> header file. */
316
+/* #undef HAVE_WINDOWS_H */
317
+
318
+/* Define to 1 if you have the <winsock2.h> header file. */
319
+/* #undef HAVE_WINSOCK2_H */
320
+
321
+/* Define to 1 if you have the `_mkdir' function. */
322
+/* #undef HAVE__MKDIR */
323
+
324
+/* Define to add IDE harddisk emulation. */
325
+#define IDE 1
326
+
327
+/* Define to allow sound interpolation. */
328
+#define INTERPOLATE_SOUND 1
329
+
330
+/* Define to use LINUX joystick. */
331
+/* #undef LINUX_JOYSTICK */
332
+
333
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
334
+   slash. */
335
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
336
+
337
+/* Define if mkdir takes only one argument. */
338
+/* #undef MKDIR_TAKES_ONE_ARG */
339
+
340
+/* Define to activate assembler in monitor. */
341
+// #define MONITOR_ASSEMBLER 1
342
+
343
+/* Define to activate code breakpoints and execution history. */
344
+// #define MONITOR_BREAK 1
345
+
346
+/* Define to activate user-defined breakpoints. */
347
+/* #undef MONITOR_BREAKPOINTS */
348
+
349
+/* Define to activate hints in disassembler. */
350
+// #define MONITOR_HINTS 1
351
+
352
+/* Define to activate 6502 opcode profiling. */
353
+/* #undef MONITOR_PROFILE */
354
+
355
+/* Define to activate readline support in monitor. */
356
+/* #undef MONITOR_READLINE */
357
+
358
+/* Define to activate TRACE command in monitor. */
359
+/* #undef MONITOR_TRACE */
360
+
361
+/* Target: X11 with Motif. */
362
+/* #undef MOTIF */
363
+
364
+/* Define to allow color changes inside a scanline. */
365
+#define NEW_CYCLE_EXACT 1
366
+
367
+/* Define to use nonlinear POKEY mixing. */
368
+#define NONLINEAR_MIXING 1
369
+
370
+/* Use NTSC video filter. */
371
+#define NTSC_FILTER 1
372
+
373
+/* Define to the address where bug reports for this package should be sent. */
374
+#define PACKAGE_BUGREPORT "pstehlik@sophics.cz"
375
+
376
+/* Define to the full name of this package. */
377
+#define PACKAGE_NAME "Atari800"
378
+
379
+/* Define to the full name and version of this package. */
380
+#define PACKAGE_STRING "Atari800 3.1.0"
381
+
382
+/* Define to the one symbol short name of this package. */
383
+#define PACKAGE_TARNAME "atari800"
384
+
385
+/* Define to the home page for this package. */
386
+#define PACKAGE_URL ""
387
+
388
+/* Define to the version of this package. */
389
+#define PACKAGE_VERSION "3.1.0"
390
+
391
+/* Define to use page-based attribute array. */
392
+/* #undef PAGED_ATTRIB */
393
+
394
+/* Use accurate PAL color blending. */
395
+#define PAL_BLENDING 1
396
+
397
+/* Define to emulate the Black Box. */
398
+#define PBI_BB 1
399
+
400
+/* Define to emulate the MIO board. */
401
+#define PBI_MIO 1
402
+
403
+/* A prototype 80 column card for the 1090 expansion box. */
404
+// #define PBI_PROTO80 1
405
+
406
+/* Define to emulate the 1400XL/1450XLD. */
407
+#define PBI_XLD 1
408
+
409
+/* Platform-specific mapping of RGB palette to display surface. */
410
+#define PLATFORM_MAP_PALETTE 1
411
+
412
+/* Target: Sony PlayStation 2. */
413
+/* #undef PS2 */
414
+
415
+/* Define as the return type of signal handlers (`int' or `void'). */
416
+#define RETSIGTYPE void
417
+
418
+/* Target: Raspberry Pi. */
419
+/* #undef RPI */
420
+
421
+/* Define to use R: device. */
422
+/* #undef R_IO_DEVICE */
423
+
424
+/* Define to use IP network connection with the R: device. */
425
+/* #undef R_NETWORK */
426
+
427
+/* Define to use the host serial port with the R: device. */
428
+/* #undef R_SERIAL */
429
+
430
+/* Target: SDL library. */
431
+/* #undef SDL */
432
+
433
+/* Define to the type of arg 1 for `select'. */
434
+#define SELECT_TYPE_ARG1 int
435
+
436
+/* Define to the type of args 2, 3 and 4 for `select'. */
437
+#define SELECT_TYPE_ARG234 (fd_set *)
438
+
439
+/* Define to the type of arg 5 for `select'. */
440
+#define SELECT_TYPE_ARG5 (struct timeval *)
441
+
442
+/* Define to allow serial in/out sound. */
443
+/* #undef SERIO_SOUND */
444
+
445
+/* Target: X11 with shared memory extensions. */
446
+/* #undef SHM */
447
+
448
+/* Define to activate sound support. */
449
+#define SOUND 1
450
+
451
+/* Platform updates sound buffer by callback function. */
452
+#define SOUND_CALLBACK 1
453
+
454
+/* Use new sound API. */
455
+#define SOUND_THIN_API 1
456
+
457
+/* Define to 1 if you have the ANSI C header files. */
458
+#define STDC_HEADERS 1
459
+
460
+/* Define to allow stereo sound. */
461
+#define STEREO_SOUND 1
462
+
463
+/* Can change video modes on the fly. */
464
+#define SUPPORTS_CHANGE_VIDEOMODE 1
465
+
466
+/* Save additional config file options. */
467
+/* #define SUPPORTS_PLATFORM_CONFIGSAVE 1 */
468
+
469
+/* Additional config file options. */
470
+/* #define SUPPORTS_PLATFORM_CONFIGURE 1 */
471
+
472
+/* Update the Palette if it changed. */
473
+#define SUPPORTS_PLATFORM_PALETTEUPDATE 1
474
+
475
+/* Platform-specific sleep function. */
476
+#define SUPPORTS_PLATFORM_SLEEP 1
477
+
478
+/* Platform-specific time function. */
479
+#define SUPPORTS_PLATFORM_TIME 1
480
+
481
+/* Can display the screen rotated sideways. */
482
+/* #undef SUPPORTS_ROTATE_VIDEOMODE */
483
+
484
+/* Reinitialise the sound system. */
485
+#define SUPPORTS_SOUND_REINIT 1
486
+
487
+/* Define to use synchronized sound. */
488
+#define SYNCHRONIZED_SOUND 1
489
+
490
+/* Alternate system-wide config file for non-Unix OS. */
491
+/* #undef SYSTEM_WIDE_CFG_FILE */
492
+
493
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
494
+#define TIME_WITH_SYS_TIME 1
495
+
496
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
497
+/* #undef TM_IN_SYS_TIME */
498
+
499
+/* Target: Curses-compatible library. */
500
+/* #undef USE_CURSES */
501
+
502
+/* Define for using cursor/ctrl keys for keyboard joystick. */
503
+/* #undef USE_CURSORBLOCK */
504
+
505
+/* Target: Ncurses library. */
506
+/* #undef USE_NCURSES */
507
+
508
+/* Define to enable on-screen keyboard. */
509
+/* #undef USE_UI_BASIC_ONSCREEN_KEYBOARD */
510
+
511
+/* Define to use very slow computer support (faster -refresh). */
512
+/* #undef VERY_SLOW */
513
+
514
+/* Define to emulate the Alien Group Voice Box. */
515
+#define VOICEBOX 1
516
+
517
+/* Define to allow volume only sound. */
518
+/* #undef VOL_ONLY_SOUND */
519
+
520
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
521
+   significant byte first (like Motorola and SPARC, unlike Intel). */
522
+/* #undef WORDS_BIGENDIAN */
523
+
524
+/* Define if unaligned word access is ok. */
525
+#define WORDS_UNALIGNED_OK 1
526
+
527
+/* Target: Standard X11. */
528
+/* #undef X11 */
529
+
530
+/* Emulate the XEP80. */
531
+// #define XEP80_EMULATION 1
532
+
533
+/* Target: X11 with XView. */
534
+/* #undef XVIEW */
535
+
536
+/* Number of bits in a file offset, on hosts where this is settable. */
537
+/* #undef _FILE_OFFSET_BITS */
538
+
539
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
540
+/* #undef _LARGEFILE_SOURCE */
541
+
542
+/* Define for large files, on AIX-style hosts. */
543
+/* #undef _LARGE_FILES */
544
+
545
+/* Define to empty if `const' does not conform to ANSI C. */
546
+/* #undef const */
547
+
548
+/* Define to `__inline__' or `__inline' if that's what the C compiler
549
+   calls it, or to nothing if 'inline' is not supported under any name.  */
550
+#ifndef __cplusplus
551
+#define inline __inline__
552
+#endif
553
+
554
+/* Define to `unsigned int' if <sys/types.h> does not define. */
555
+/* #undef size_t */
556
+
557
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
558
+   code using `volatile' can become incorrect without. Disable with care. */
559
+/* #undef volatile */

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


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


+ 199
- 0
src/3ds/input.c View File

@@ -0,0 +1,199 @@
1
+/*
2
+ * 3ds/input.c - Nintendo 3DS input device support
3
+ *
4
+ * Copyright (c) 2001-2002 Jacek Poplawski
5
+ * Copyright (C) 2001-2016 Atari800 development team (see DOC/CREDITS)
6
+ *
7
+ * This file is part of the Atari800 emulator project which emulates
8
+ * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
9
+ *
10
+ * Atari800 is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Atari800 is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Atari800; if not, write to the Free Software
22
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
+*/
24
+
25
+#include <3ds.h>
26
+
27
+#include "config.h"
28
+#include "akey.h"
29
+#include "input.h"
30
+#include "log.h"
31
+#include "platform.h"
32
+#include "ui.h"
33
+
34
+#include "kbd_mapping_bin.h"
35
+
36
+int key_control;
37
+
38
+int N3DS_IsControlPressed()
39
+{
40
+	return key_control;
41
+}
42
+
43
+void PLATFORM_SetJoystickKey(int joystick, int direction, int value)
44
+{
45
+}
46
+
47
+void PLATFORM_GetJoystickKeyName(int joystick, int direction, char *buffer, int bufsize)
48
+{
49
+}
50
+
51
+int PLATFORM_GetRawKey(void)
52
+{
53
+	return 0;
54
+}
55
+
56
+int PLATFORM_Keyboard(void)
57
+{
58
+	u32 kDown, kHeld, kUp;
59
+	u32* kMapping;
60
+	touchPosition pos;
61
+	int posPixel;
62
+
63
+	hidScanInput();
64
+	kDown = hidKeysDown();
65
+	kHeld = hidKeysHeld();
66
+	kUp = hidKeysUp();
67
+
68
+	if (UI_is_active)
69
+	{
70
+		if (kDown & KEY_A)
71
+			return AKEY_RETURN;
72
+		if (kDown & KEY_B)
73
+			return AKEY_ESCAPE;
74
+		if (kDown & KEY_X)
75
+			return AKEY_SPACE;
76
+		if (kDown & KEY_Y)
77
+			return AKEY_BACKSPACE;
78
+		if (kHeld & KEY_UP)
79
+			return AKEY_UP;
80
+		if (kHeld & KEY_LEFT)
81
+			return AKEY_LEFT;
82
+		if (kHeld & KEY_RIGHT)
83
+			return AKEY_RIGHT;
84
+		if (kHeld & KEY_DOWN)
85
+			return AKEY_DOWN;
86
+		if (kDown & KEY_L)
87
+			return AKEY_COLDSTART;
88
+		if (kDown & KEY_R)
89
+			return AKEY_WARMSTART;
90
+	}
91
+
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;
114
+
115
+	if ((kDown | kHeld) & KEY_TOUCH)
116
+	{
117
+		hidTouchRead(&pos);
118
+		kMapping = (u32*) kbd_mapping_bin;
119
+		if (pos.px >= 0 && pos.px < 320 && pos.py >= 0 && pos.py < 240)
120
+		{
121
+			posPixel = kMapping[pos.py * 320 + pos.px] & 0xFFFFFF;
122
+			if (kDown & KEY_TOUCH)
123
+			{
124
+				if ((posPixel & 0xff00ff) == 0)
125
+				{
126
+					int val = (posPixel >> 10) | (INPUT_key_shift != 0 ? AKEY_SHFT : 0)
127
+						| (key_control != 0 ? AKEY_CTRL : 0);
128
+
129
+					if (INPUT_key_shift != 0 || key_control != 0)
130
+					{
131
+						INPUT_key_shift = 0;
132
+						key_control = 0;
133
+						PLATFORM_DisplayScreen();
134
+					}
135
+
136
+					return val;
137
+				}
138
+
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
+					}
146
+
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
+			}
160
+
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;
167
+		}
168
+	}
169
+
170
+	return AKEY_NONE;
171
+}
172
+
173
+int PLATFORM_PORT(int num)
174
+{
175
+	int ret = 0xff;
176
+	if (num == 0) {
177
+		hidScanInput();
178
+		u32 kDown = hidKeysHeld();
179
+		if (kDown & KEY_CPAD_LEFT)
180
+			ret &= 0xf0 | INPUT_STICK_LEFT;
181
+		if (kDown & KEY_CPAD_RIGHT)
182
+			ret &= 0xf0 | INPUT_STICK_RIGHT;
183
+		if (kDown & KEY_CPAD_UP)
184
+			ret &= 0xf0 | INPUT_STICK_FORWARD;
185
+		if (kDown & KEY_CPAD_DOWN)
186
+			ret &= 0xf0 | INPUT_STICK_BACK;
187
+	}
188
+	return ret;
189
+}
190
+
191
+int PLATFORM_TRIG(int num)
192
+{
193
+	if (num == 0) {
194
+		hidScanInput();
195
+		if (hidKeysHeld() & KEY_A)
196
+			return 0;
197
+	}
198
+	return 1;
199
+}

+ 117
- 0
src/3ds/main.c View File

@@ -0,0 +1,117 @@
1
+/*
2
+ * 3ds/main.c - Nintendo 3DS port main code
3
+ *
4
+ * Copyright (c) 2001-2002 Jacek Poplawski
5
+ * Copyright (C) 2001-2016 Atari800 development team (see DOC/CREDITS)
6
+ *
7
+ * This file is part of the Atari800 emulator project which emulates
8
+ * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
9
+ *
10
+ * Atari800 is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Atari800 is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Atari800; if not, write to the Free Software
22
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
+*/
24
+
25
+#include <3ds.h>
26
+#include <sf2d.h>
27
+#include <stdio.h>
28
+#include <string.h>
29
+
30
+/* Atari800 includes */
31
+#include "atari.h"
32
+#include "config.h"
33
+#include "../input.h"
34
+#include "log.h"
35
+#include "monitor.h"
36
+#include "platform.h"
37
+#include "pokeysnd.h"
38
+#ifdef SOUND
39
+#include "../sound.h"
40
+#endif
41
+#include "videomode.h"
42
+
43
+static bool PLATFORM_IsNew3DS;
44
+
45
+int PLATFORM_Configure(char *option, char *parameters)
46
+{
47
+	return 0;
48
+}
49
+
50
+void PLATFORM_ConfigSave(FILE *fp)
51
+{
52
+
53
+}
54
+
55
+int PLATFORM_Initialise(int *argc, char *argv[])
56
+{
57
+	return TRUE;
58
+}
59
+
60
+void PLATFORM_Sleep(double s)
61
+{
62
+	if (s > 0) {
63
+		svcSleepThread(s * 1e9);
64
+	}
65
+}
66
+
67
+double PLATFORM_Time(void)
68
+{
69
+	return osGetTime() * 1e-3;
70
+}
71
+
72
+int PLATFORM_Exit(int run_monitor)
73
+{
74
+	Log_flushlog();
75
+
76
+	if (run_monitor) {
77
+		return 1;
78
+	} else {
79
+		sf2d_fini();
80
+		ptmSysmExit();
81
+		romfsExit();
82
+	}
83
+
84
+	return 0;
85
+}
86
+
87
+int main(int argc, char **argv)
88
+{
89
+	romfsInit();
90
+
91
+	ptmSysmInit();
92
+	osSetSpeedupEnable(1);
93
+
94
+	sf2d_init();
95
+	// consoleInit(GFX_BOTTOM, NULL);
96
+
97
+	// sane defaults...
98
+	PLATFORM_IsNew3DS = PTMSYSM_CheckNew3DS();
99
+	POKEYSND_enable_new_pokey = PLATFORM_IsNew3DS;
100
+
101
+	if (!Atari800_Initialise(&argc, argv))
102
+	{
103
+		printf("Atari initialisation failed!");
104
+		return 0;
105
+	}
106
+
107
+	while (aptMainLoop()) {
108
+		INPUT_key_code = PLATFORM_Keyboard();
109
+		Atari800_Frame();
110
+		if (Atari800_display_screen)
111
+			PLATFORM_DisplayScreen();
112
+	}
113
+}
114
+
115
+/*
116
+vim:ts=4:sw=4:
117
+*/

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


+ 138
- 0
src/3ds/sound_ndsp.c View File

@@ -0,0 +1,138 @@
1
+/*
2
+ * 3ds/sound_ndsp.c - Nintendo 3DS NDSP audio backend
3
+ *
4
+ * Copyright (c) 2001-2002 Jacek Poplawski
5
+ * Copyright (C) 2001-2016 Atari800 development team (see DOC/CREDITS)
6
+ *
7
+ * This file is part of the Atari800 emulator project which emulates
8
+ * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
9
+ *
10
+ * Atari800 is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Atari800 is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Atari800; if not, write to the Free Software
22
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
+*/
24
+
25
+#include <3ds.h>
26
+#include <stdlib.h>
27
+#include <string.h>
28
+
29
+#include "atari.h"
30
+#include "log.h"
31
+#include "platform.h"
32
+#include "sound.h"
33
+
34
+int N3DS_soundFreq;
35
+ndspWaveBuf N3DS_audioBuf;
36
+u8*	N3DS_audioData;
37
+u32	N3DS_bufferSize, N3DS_sampleSize, N3DS_lastPos;
38
+Sound_setup_t *N3DS_sound;
39
+
40
+void N3DS_ClearAudioData(void);
41
+
42
+int PLATFORM_SoundSetup(Sound_setup_t *setup)
43
+{
44
+	setup->sample_size = 1;
45
+
46
+	if (setup->buffer_frames == 0)
47
+	{
48
+		setup->buffer_frames = 4096;
49
+	}
50
+
51
+	N3DS_bufferSize = setup->buffer_frames;
52
+	N3DS_sampleSize = setup->sample_size * setup->channels;
53
+
54
+	N3DS_audioData = (u8*) linearAlloc(N3DS_bufferSize * 2 * N3DS_sampleSize);
55
+	N3DS_ClearAudioData();
56
+
57
+	ndspInit();
58
+
59
+	N3DS_sound = setup;
60
+	PLATFORM_SoundContinue();
61
+
62
+	return TRUE;
63
+}
64
+
65
+void N3DS_SoundCallback(void* dud)
66
+{
67
+	u32 pos = ndspChnGetSamplePos(0);
68
+	if (pos >= N3DS_bufferSize && N3DS_lastPos < N3DS_bufferSize)
69
+	{
70
+		Sound_Callback(&N3DS_audioData[0], N3DS_bufferSize * N3DS_sampleSize);
71
+		for(int i = 0; i < N3DS_bufferSize * N3DS_sampleSize; i++)
72
+			N3DS_audioData[i] ^= 0x80;
73
+	}
74
+	else if (pos < N3DS_bufferSize && N3DS_lastPos >= N3DS_bufferSize)
75
+	{
76
+		Sound_Callback(&N3DS_audioData[N3DS_bufferSize * N3DS_sampleSize], N3DS_bufferSize * N3DS_sampleSize);
77
+		for(int i = N3DS_bufferSize * N3DS_sampleSize; i < N3DS_bufferSize * N3DS_sampleSize * 2; i++)
78
+			N3DS_audioData[i] ^= 0x80;
79
+	}
80
+	N3DS_lastPos = pos;
81
+}
82
+
83
+void N3DS_ClearAudioData(void)
84
+{
85
+	memset(N3DS_audioData, 0, N3DS_bufferSize * 2 * N3DS_sampleSize);
86
+	DSP_FlushDataCache(N3DS_audioData, N3DS_bufferSize * 2 * N3DS_sampleSize);
87
+	N3DS_lastPos = 0;
88
+}
89
+
90
+void PLATFORM_SoundLock(void)
91
+{
92
+	// TODO
93
+}
94
+
95
+void PLATFORM_SoundUnlock(void)
96
+{
97
+	// TODO
98
+}
99
+
100
+void PLATFORM_SoundExit(void)
101
+{
102
+	linearFree(N3DS_audioData);
103
+	ndspExit();
104
+}
105
+
106
+void PLATFORM_SoundPause(void)
107
+{
108
+	ndspChnWaveBufClear(0);
109
+	N3DS_ClearAudioData();
110
+}
111
+
112
+void PLATFORM_SoundContinue(void)
113
+{
114
+	float mix[12];
115
+	memset(mix, 0, sizeof(mix));
116
+	mix[0] = mix[1] = 1.0f;
117
+
118
+	ndspSetOutputMode(N3DS_sound->channels == 2 ? NDSP_OUTPUT_STEREO : NDSP_OUTPUT_MONO);
119
+	ndspSetOutputCount(1);
120
+	ndspSetMasterVol(1.0f);
121
+	ndspSetCallback(N3DS_SoundCallback, N3DS_audioData);
122
+
123
+	memset(&N3DS_audioBuf, 0, sizeof(ndspWaveBuf));
124
+	ndspChnReset(0);
125
+	ndspChnSetInterp(0, NDSP_INTERP_POLYPHASE);
126
+	ndspChnSetRate(0, N3DS_sound->freq);
127
+	ndspChnSetFormat(0, NDSP_CHANNELS(N3DS_sound->channels) | NDSP_ENCODING(N3DS_sound->sample_size == 2 ? NDSP_ENCODING_PCM16 : NDSP_ENCODING_PCM8));
128
+	ndspChnSetMix(0, mix);
129
+
130
+	N3DS_audioBuf.data_vaddr = N3DS_audioData;
131
+	N3DS_audioBuf.nsamples = N3DS_bufferSize * 2;
132
+	N3DS_audioBuf.looping = true;
133
+	N3DS_audioBuf.status = NDSP_WBUF_FREE;
134
+
135
+	N3DS_ClearAudioData();
136
+
137
+	ndspChnWaveBufAdd(0, &N3DS_audioBuf);
138
+}

+ 215
- 0
src/3ds/video.c View File

@@ -0,0 +1,215 @@
1
+/*
2
+ * 3ds/video.c - Nintendo 3DS video backend
3
+ *
4
+ * Copyright (c) 2001-2002 Jacek Poplawski
5
+ * Copyright (C) 2001-2016 Atari800 development team (see DOC/CREDITS)
6
+ *
7
+ * This file is part of the Atari800 emulator project which emulates
8
+ * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
9
+ *
10
+ * Atari800 is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * Atari800 is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with Atari800; if not, write to the Free Software
22
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
+*/
24
+
25
+#include <3ds.h>
26
+#include <sf2d.h>
27
+#include <sfil.h>
28
+
29
+#include "artifact.h"
30
+#include "atari.h"
31
+#include "colours.h"
32
+#include "config.h"
33
+#include "filter_ntsc.h"
34
+#include "input.h"
35
+#include "log.h"
36
+#ifdef PAL_BLENDING
37
+#include "pal_blending.h"
38
+#endif /* PAL_BLENDING */
39
+#include "platform.h"
40
+#include "screen.h"
41
+#include "util.h"
42
+#include "videomode.h"
43
+
44
+int texInitialized = 0;
45
+sf2d_texture *tex, *kbd_display, *kbd_ctrl_pressed, *kbd_shift_pressed;
46
+u32 *texBuf;
47
+VIDEOMODE_MODE_t N3DS_VIDEO_mode;
48
+int ctable[256];
49
+
50
+void PLATFORM_PaletteUpdate(void)
51
+{
52
+#ifdef PAL_BLENDING
53
+	if (N3DS_VIDEO_mode == VIDEOMODE_MODE_NORMAL && ARTIFACT_mode == ARTIFACT_PAL_BLEND)
54
+		PAL_BLENDING_UpdateLookup();
55
+#endif
56
+	N3DS_VIDEO_PaletteUpdate();
57
+}
58
+
59
+void N3DS_VIDEO_PaletteUpdate()
60
+{
61
+	int i;
62
+
63
+	for (i = 0; i < 256; i++)
64
+	{
65
+		ctable[i] = Colours_table[i] << 8 | 0xFF;
66
+	}
67
+}
68
+
69
+void PLATFORM_GetPixelFormat(PLATFORM_pixel_format_t *format)
70
+{
71
+	format->bpp = 32;
72
+	format->rmask = 0xFF000000;
73
+	format->gmask = 0x00FF0000;
74
+	format->bmask = 0x0000FF00;
75
+}
76
+
77
+void PLATFORM_MapRGB(void *dest, int const *palette, int size)
78
+{
79
+	int i;
80
+	u32* target = (u32*) dest;
81
+	for (i = 0; i < 256; i++)
82
+	{
83
+		target[i] = (palette[i] << 8) | 0xFF;
84
+	}
85
+}
86
+
87
+static void UpdateNtscFilter(VIDEOMODE_MODE_t mode)
88
+{
89
+
90
+}
91
+
92
+void PLATFORM_SetVideoMode(VIDEOMODE_resolution_t const *res, int windowed, VIDEOMODE_MODE_t mode, int rotate90)
93
+{
94
+	N3DS_VIDEO_mode = mode;
95
+	N3DS_InitTexture();
96
+
97
+	PLATFORM_PaletteUpdate();
98
+	memset(texBuf, 0, tex->tex.width * tex->tex.height * 4);
99
+	PLATFORM_DisplayScreen();
100
+}
101
+
102
+VIDEOMODE_resolution_t *PLATFORM_AvailableResolutions(unsigned int *size)
103
+{
104
+	VIDEOMODE_resolution_t *resolutions;
105
+	resolutions = Util_malloc(1 * sizeof(VIDEOMODE_resolution_t));
106
+	resolutions[0].width = 400;
107
+	resolutions[0].height = 240;
108
+	*size = 1;
109
+	return resolutions;
110
+}
111
+
112
+VIDEOMODE_resolution_t *PLATFORM_DesktopResolution(void)
113
+{
114
+	VIDEOMODE_resolution_t *resolutions;
115
+	resolutions = Util_malloc(1 * sizeof(VIDEOMODE_resolution_t));
116
+	resolutions[0].width = 400;
117
+	resolutions[0].height = 240;
118
+	return resolutions;
119
+}
120
+
121
+int PLATFORM_SupportsVideomode(VIDEOMODE_MODE_t mode, int stretch, int rotate90)
122
+{
123
+	if (rotate90 != 0)
124
+		return false;
125
+
126
+	return mode == VIDEOMODE_MODE_NORMAL;
127
+}
128
+
129
+int PLATFORM_WindowMaximised(void)
130
+{
131
+	return 1;
132
+}
133
+
134
+void N3DS_RenderNormal(u8 *src, u32 *dest)
135
+{
136
+	int x, y;
137
+	int spitch = Screen_WIDTH - VIDEOMODE_src_width;
138
+	int dpitch = 512 - VIDEOMODE_src_width;
139
+
140
+	for (y = 0; y < VIDEOMODE_src_height; y++) {
141
+		for (x = 0; x < VIDEOMODE_src_width; x++) {
142
+			*(dest++) = ctable[*(src++)];
143
+		}
144
+		src += spitch;
145
+		dest += dpitch;
146
+	}
147
+}
148
+
149
+void N3DS_InitTexture(void)
150
+{
151
+	if (texInitialized == 0)
152
+	{
153
+		sf2d_swapbuffers();
154
+		sf2d_set_3D(0);
155
+
156
+		tex = sf2d_create_texture(512, 256, TEXFMT_RGBA8, SF2D_PLACE_RAM);
157
+		texBuf = linearAlloc(512 * 256 * 4);
158
+
159
+		kbd_display = sfil_load_PNG_file("romfs:/kbd_display.png", SF2D_PLACE_RAM);
160
+		kbd_ctrl_pressed = sfil_load_PNG_file("romfs:/kbd_ctrl_pressed.png", SF2D_PLACE_RAM);
161
+		kbd_shift_pressed = sfil_load_PNG_file("romfs:/kbd_shift_pressed.png", SF2D_PLACE_RAM);
162
+		texInitialized = 1;
163
+	}
164
+}
165
+
166
+void PLATFORM_DisplayScreen(void)
167
+{
168
+	u8 *src;
169
+	u32 *dest;
170
+	float xs, ys;
171
+
172
+	src = (u8*) Screen_atari;
173
+	src += Screen_WIDTH * VIDEOMODE_src_offset_top + VIDEOMODE_src_offset_left;
174
+	dest = texBuf;
175
+
176
+	N3DS_InitTexture();
177
+
178
+#ifdef PAL_BLENDING
179
+	if (N3DS_VIDEO_mode == VIDEOMODE_MODE_NORMAL && ARTIFACT_mode == ARTIFACT_PAL_BLEND)
180
+		PAL_BLENDING_Blit32(dest, src, tex->tex.width, VIDEOMODE_src_width, VIDEOMODE_src_height, VIDEOMODE_src_offset_top % 2);
181
+	else
182
+#endif
183
+		N3DS_RenderNormal(src, dest);
184
+
185
+	sf2d_start_frame(GFX_TOP, GFX_LEFT);
186
+	tex->tiled = 0;
187
+	sf2d_texture_tile32_hardware(tex, texBuf, 512, 256);
188
+	if (VIDEOMODE_dest_width <= 400 && VIDEOMODE_dest_height <= 240 && VIDEOMODE_src_width == VIDEOMODE_dest_width && VIDEOMODE_src_height == VIDEOMODE_dest_height)
189
+		sf2d_draw_texture_part(tex,
190
+			(400 - VIDEOMODE_dest_width) / 2, (240 - VIDEOMODE_dest_height) / 2,
191
+			0, 0, VIDEOMODE_dest_width, VIDEOMODE_dest_height
192
+		);
193
+	else
194
+	{
195
+		xs = (float) VIDEOMODE_dest_width / VIDEOMODE_src_width;
196
+		ys = (float) VIDEOMODE_dest_height / VIDEOMODE_src_height;
197
+		sf2d_draw_texture_part_scale(tex,
198
+			(400 - VIDEOMODE_dest_width) / 2, (240 - VIDEOMODE_dest_height) / 2,
199
+			0, 0, VIDEOMODE_src_width, VIDEOMODE_src_height,
200
+			xs, ys
201
+		);
202
+	}
203
+	sf2d_end_frame();
204
+
205
+	/* Keyboard rendering */
206
+	sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
207
+	sf2d_draw_texture(kbd_display, 0, 0);
208
+	if (INPUT_key_shift != 0)
209
+		sf2d_draw_texture(kbd_shift_pressed, 0, 0);
210
+	if (N3DS_IsControlPressed() != 0)
211
+		sf2d_draw_texture(kbd_ctrl_pressed, 0, 0);
212
+	sf2d_end_frame();
213
+
214
+	sf2d_swapbuffers();
215
+}

+ 8
- 0
src/3ds/video.h View File

@@ -0,0 +1,8 @@
1
+#ifndef 3DS_VIDEO_H_
2
+#define 3DS_VIDEO_H_
3
+
4
+#include <stdio.h>
5
+#include "config.h"
6
+#include "videomode.h"
7
+
8
+#endif /* 3DS_VIDEO_H_ */

+ 5
- 0
src/atari.c View File

@@ -424,6 +424,11 @@ int Atari800_Initialise(int *argc, char *argv[])
424 424
 		}
425 425
 		*argc = j;
426 426
 	}
427
+
428
+#ifdef _3DS
429
+	SYSROM_FindInDir("/3ds/atari800", FALSE);
430
+#endif
431
+
427 432
 #ifndef ANDROID
428 433
 	got_config = CFG_LoadConfig(rtconfig_filename);
429 434
 #else

+ 1
- 1
src/ui.c View File

@@ -4060,7 +4060,7 @@ void UI_Run(void)
4060 4060
 		UI_MENU_ACTION(UI_MENU_MONITOR, "About AtariDC"),
4061 4061
 #elif defined(DIRECTX)
4062 4062
 		UI_MENU_ACTION_ACCEL(UI_MENU_MONITOR, monitor_label, "F8"),
4063
-#else
4063
+#elif !defined(_3DS)
4064 4064
 		UI_MENU_ACTION_ACCEL(UI_MENU_MONITOR, "Enter Monitor", "F8"),
4065 4065
 #endif
4066 4066
 		UI_MENU_ACTION_ACCEL(UI_MENU_ABOUT, "About the Emulator", "Alt+A"),

Loading…
Cancel
Save