Port of the atari800 emulator to the 3DS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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