├── .gitignore ├── Makefile ├── README.md ├── audio ├── Makefile ├── PlayBoyScout │ ├── Makefile │ ├── data │ │ └── tune.bgf │ ├── gfx │ │ ├── ScoutSplash.grit │ │ └── ScoutSplash.png │ └── source │ │ └── PlayBoyScout.c └── maxmod │ ├── Makefile │ └── basic_sound │ ├── Makefile │ ├── maxmod_data │ ├── Ambulance.wav │ ├── Boom.wav │ └── FlatOutLies.mod │ └── source │ └── MaxModExample.c ├── graphics ├── Makefile ├── PCXView │ ├── Makefile │ ├── data │ │ └── splash.pcx │ └── source │ │ ├── pcx.c │ │ ├── pcx.h │ │ └── pcx_view.c ├── SimpleBGScroll │ ├── Makefile │ ├── font │ │ └── r6502_portfont.bin │ ├── readme.txt │ └── source │ │ └── main.c └── ansi_console │ ├── Makefile │ └── source │ └── console.c ├── img ├── PCXView.png ├── PlayBoyScout.png ├── SimpleBGScroll.gif ├── XbooLoad.png ├── ansi_console.png ├── basic_sound.png └── template.png ├── mbv2 ├── Makefile └── mbv2print │ ├── Makefile │ └── src │ └── mbv2print.c ├── template ├── Makefile └── source │ └── template.c ├── utility ├── Makefile └── biosdumper │ ├── Makefile │ └── source │ └── biosdumper.c └── xboo ├── Makefile ├── XbooLoad ├── Makefile ├── data │ └── splash.pcx └── src │ ├── XbooLoad.c │ ├── pcx.c │ └── pcx.h └── XbooPrint ├── Makefile └── source └── xbooprint.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.gba 2 | *.elf 3 | build 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 3 | 4 | DATESTRING := $(shell date +%Y%m%d) 5 | 6 | all: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 8 | clean: 9 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 10 | install: 11 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 12 | 13 | #--------------------------------------------------------------------------------- 14 | dist: clean 15 | #--------------------------------------------------------------------------------- 16 | @tar --exclude=*CVS* --exclude=.svn -cvjf gba-examples-$(DATESTRING).tar.bz2 * 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gba-examples 2 | 3 | Game Boy Advance examples using [libgba](https://github.com/devkitPro/libgba). 4 | 5 | Authors: Christer Andersson, r6502, [WinterMute](https://github.com/WinterMute) 6 | 7 | ## Audio 8 | 9 | `basic_sound.gba` plays a background music in a loop. Press and hold button A to play an ambulance sound on left speaker. Press button B to play a boom sound on right speaker. 10 | 11 | ![MaxMod Audio Demo](img/basic_sound.png) 12 | 13 | `PlayBoyScout.gba` displays a static background image and plays a song repeatedly. 14 | 15 | > BoyScout was a PC Windows softwaresynth that emulated the GameBoy Advance sound chip. It let you compose your songs in Windows through a tracker style interface with seamless transfer to GameBoy Advance. 16 | [boyscout archive](http://web.archive.org/web/20170503190240/http://pidelipom.com/boyscout) 17 | 18 | ![PlayBoyScout](img/PlayBoyScout.png) 19 | 20 | ## Graphics 21 | 22 | `ansi_console.gba` displays 'Hello World' at the center of the screen and 4 strings at each corner. 23 | 24 | ![ansi_console](img/ansi_console.png) 25 | 26 | `PCXView.gba` displays a image PCX format with a fade-in effect (splash screen). 27 | 28 | ![PCXView.gba](img/PCXView.png) 29 | 30 | `SimpleBGScroll.gba`: displays a long scrolling text on the screen, from right to left. 31 | 32 | ![SimpleBGScroll](img/SimpleBGScroll.gif) 33 | 34 | ## MBV2 35 | 36 | `mbv2print.gba` sends a 'Hello World' using the [MultiBoot Version 2 (MBV2)](http://www.devrs.com/gba/files/mbv2faqs.php) cable. 37 | 38 | ## Template 39 | 40 | `template.gba` prints a 'Hello World' at the center of the screen. 41 | 42 | ![template](img/template.png) 43 | 44 | ## Utility 45 | 46 | `biosdumper_mb.gba` reads the Game Boy Advance BIOS and saves it to the SD/CF card using [libfat](https://github.com/devkitPro/libfat). 47 | 48 | ## Xboo 49 | 50 | `XbooLoad_mb.gba` demonstrate the use of the Xboo Communicator file server and debug console. The example shows an image on screen. If button A is pressed, image fades out and reappears. 51 | 52 | ![XbooLoad](img/XbooLoad.png) 53 | 54 | `XbooPrint_mb.gba` sends a 'Hello World' using the Xboo cable. -------------------------------------------------------------------------------- /audio/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /audio/PlayBoyScout/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # INCLUDES is a list of directories containing extra header files 16 | # DATA is a list of directories containing binary data 17 | # GRAPHICS is a list of directories containing files to be processed by grit 18 | # 19 | # All directories are specified relative to the project directory where 20 | # the makefile is found 21 | # 22 | #--------------------------------------------------------------------------------- 23 | TARGET := $(notdir $(CURDIR)) 24 | BUILD := build 25 | SOURCES := source 26 | INCLUDES := include 27 | DATA := data 28 | GRAPHICS := gfx 29 | MUSIC := 30 | 31 | #--------------------------------------------------------------------------------- 32 | # options for code generation 33 | #--------------------------------------------------------------------------------- 34 | ARCH := -mthumb -mthumb-interwork 35 | 36 | CFLAGS := -g -Wall -O3\ 37 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 38 | -fomit-frame-pointer\ 39 | -ffast-math \ 40 | $(ARCH) 41 | 42 | CFLAGS += $(INCLUDE) 43 | 44 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 45 | 46 | ASFLAGS := -g $(ARCH) 47 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 48 | 49 | #--------------------------------------------------------------------------------- 50 | # any extra libraries we wish to link with the project 51 | #--------------------------------------------------------------------------------- 52 | LIBS := -lmm -lgba 53 | 54 | 55 | #--------------------------------------------------------------------------------- 56 | # list of directories containing libraries, this must be the top level containing 57 | # include and lib 58 | #--------------------------------------------------------------------------------- 59 | LIBDIRS := $(LIBGBA) 60 | 61 | #--------------------------------------------------------------------------------- 62 | # no real need to edit anything past this point unless you need to add additional 63 | # rules for different file extensions 64 | #--------------------------------------------------------------------------------- 65 | 66 | 67 | ifneq ($(BUILD),$(notdir $(CURDIR))) 68 | #--------------------------------------------------------------------------------- 69 | 70 | export OUTPUT := $(CURDIR)/$(TARGET) 71 | 72 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 73 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 74 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 75 | 76 | export DEPSDIR := $(CURDIR)/$(BUILD) 77 | 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 82 | PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) 83 | 84 | ifneq ($(strip $(MUSIC)),) 85 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 86 | BINFILES += soundbank.bin 87 | endif 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | #--------------------------------------------------------------------------------- 94 | export LD := $(CC) 95 | #--------------------------------------------------------------------------------- 96 | else 97 | #--------------------------------------------------------------------------------- 98 | export LD := $(CXX) 99 | #--------------------------------------------------------------------------------- 100 | endif 101 | #--------------------------------------------------------------------------------- 102 | 103 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) $(PNGFILES:.png=.o) 104 | 105 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 106 | 107 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 108 | 109 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 110 | 111 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 112 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 113 | -I$(CURDIR)/$(BUILD) 114 | 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 116 | 117 | .PHONY: $(BUILD) clean 118 | 119 | #--------------------------------------------------------------------------------- 120 | $(BUILD): 121 | @[ -d $@ ] || mkdir -p $@ 122 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 123 | 124 | #--------------------------------------------------------------------------------- 125 | clean: 126 | @echo clean ... 127 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 128 | 129 | 130 | #--------------------------------------------------------------------------------- 131 | else 132 | 133 | #--------------------------------------------------------------------------------- 134 | # main targets 135 | #--------------------------------------------------------------------------------- 136 | 137 | $(OUTPUT).gba : $(OUTPUT).elf 138 | 139 | $(OUTPUT).elf : $(OFILES) 140 | 141 | $(OFILES_SOURCES) : $(HFILES) 142 | 143 | #--------------------------------------------------------------------------------- 144 | # The bin2o rule should be copied and modified 145 | # for each extension used in the data directories 146 | #--------------------------------------------------------------------------------- 147 | 148 | #--------------------------------------------------------------------------------- 149 | # rule to build soundbank from music files 150 | #--------------------------------------------------------------------------------- 151 | soundbank.bin soundbank.h : $(AUDIOFILES) 152 | #--------------------------------------------------------------------------------- 153 | @mmutil $^ -osoundbank.bin -hsoundbank.h 154 | 155 | #--------------------------------------------------------------------------------- 156 | %.bgf.o %_bgf.h : %.bgf 157 | #--------------------------------------------------------------------------------- 158 | @echo $(notdir $<) 159 | @$(bin2o) 160 | 161 | #--------------------------------------------------------------------------------- 162 | # This rule creates assembly source files using grit 163 | # grit takes an image file and a .grit describing how the file is to be processed 164 | # add additional rules like this for each image extension 165 | # you use in the graphics folders 166 | #--------------------------------------------------------------------------------- 167 | %.s %.h : %.png %.grit 168 | #--------------------------------------------------------------------------------- 169 | grit $< -fts -o$*.png 170 | 171 | -include $(DEPSDIR)/*.d 172 | 173 | #--------------------------------------------------------------------------------------- 174 | endif 175 | #--------------------------------------------------------------------------------------- 176 | -------------------------------------------------------------------------------- /audio/PlayBoyScout/data/tune.bgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/audio/PlayBoyScout/data/tune.bgf -------------------------------------------------------------------------------- /audio/PlayBoyScout/gfx/ScoutSplash.grit: -------------------------------------------------------------------------------- 1 | # 8 bit bitmap 2 | -gB8 3 | 4 | # bitmap format 5 | -gb 6 | 7 | # use lz77 compression 8 | -gzl -------------------------------------------------------------------------------- /audio/PlayBoyScout/gfx/ScoutSplash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/audio/PlayBoyScout/gfx/ScoutSplash.png -------------------------------------------------------------------------------- /audio/PlayBoyScout/source/PlayBoyScout.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | // GBA BoyScout sample code for devkitARM - http://www.devkitpro.org 3 | //--------------------------------------------------------------------------------- 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | //--------------------------------------------------------------------------------- 10 | // header for binary data generated by bin2o macro in makefile 11 | //--------------------------------------------------------------------------------- 12 | #include "tune_bgf.h" 13 | #define TUNE tune_bgf 14 | 15 | 16 | //--------------------------------------------------------------------------------- 17 | // header for generated by grit. 18 | //--------------------------------------------------------------------------------- 19 | #include "ScoutSplash.h" 20 | 21 | 22 | //--------------------------------------------------------------------------------- 23 | // Program entry point 24 | //--------------------------------------------------------------------------------- 25 | int main(void) 26 | //--------------------------------------------------------------------------------- 27 | { 28 | 29 | // Set up the interrupt handlers 30 | irqInit(); 31 | 32 | unsigned int nBSSongSize; 33 | // Initialize BoyScout 34 | BoyScoutInitialize(); 35 | 36 | // Get needed song memory 37 | nBSSongSize = BoyScoutGetNeededSongMemory(TUNE); 38 | 39 | // Allocate and set BoyScout memory area 40 | BoyScoutSetMemoryArea((unsigned int)malloc(nBSSongSize)); 41 | 42 | // Open song 43 | BoyScoutOpenSong(TUNE); 44 | 45 | // Play song and loop 46 | BoyScoutPlaySong(1); 47 | 48 | // Enable Vblank Interrupt to allow VblankIntrWait 49 | irqEnable(IRQ_VBLANK); 50 | // Allow Interrupts 51 | REG_IME = 1; 52 | 53 | SetMode( MODE_4 | BG2_ON ); // screen mode & background to display 54 | 55 | LZ77UnCompVram(ScoutSplashBitmap,(void *)VRAM); 56 | 57 | FadeToPalette( ScoutSplashPal, 60); 58 | 59 | while (1) 60 | { 61 | VBlankIntrWait(); 62 | } 63 | 64 | // This part will never be reached but just for completion 65 | // Free memory 66 | free((void *)BoyScoutGetMemoryArea()); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /audio/maxmod/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # INCLUDES is a list of directories containing extra header files 16 | # DATA is a list of directories containing binary data 17 | # GRAPHICS is a list of directories containing files to be processed by grit 18 | # 19 | # All directories are specified relative to the project directory where 20 | # the makefile is found 21 | # 22 | #--------------------------------------------------------------------------------- 23 | TARGET := $(notdir $(CURDIR)) 24 | BUILD := build 25 | SOURCES := source 26 | INCLUDES := include 27 | DATA := 28 | MUSIC := maxmod_data 29 | 30 | #--------------------------------------------------------------------------------- 31 | # options for code generation 32 | #--------------------------------------------------------------------------------- 33 | ARCH := -mthumb -mthumb-interwork 34 | 35 | CFLAGS := -g -Wall -O3\ 36 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 37 | -fomit-frame-pointer\ 38 | -ffast-math \ 39 | $(ARCH) 40 | 41 | CFLAGS += $(INCLUDE) 42 | 43 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 44 | 45 | ASFLAGS := -g $(ARCH) 46 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 47 | 48 | #--------------------------------------------------------------------------------- 49 | # any extra libraries we wish to link with the project 50 | #--------------------------------------------------------------------------------- 51 | LIBS := -lmm -lgba 52 | 53 | 54 | #--------------------------------------------------------------------------------- 55 | # list of directories containing libraries, this must be the top level containing 56 | # include and lib 57 | #--------------------------------------------------------------------------------- 58 | LIBDIRS := $(LIBGBA) 59 | 60 | #--------------------------------------------------------------------------------- 61 | # no real need to edit anything past this point unless you need to add additional 62 | # rules for different file extensions 63 | #--------------------------------------------------------------------------------- 64 | 65 | 66 | ifneq ($(BUILD),$(notdir $(CURDIR))) 67 | #--------------------------------------------------------------------------------- 68 | 69 | export OUTPUT := $(CURDIR)/$(TARGET) 70 | 71 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 72 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 73 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 74 | 75 | export DEPSDIR := $(CURDIR)/$(BUILD) 76 | 77 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 78 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 79 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 80 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 81 | 82 | ifneq ($(strip $(MUSIC)),) 83 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 84 | BINFILES += soundbank.bin 85 | endif 86 | 87 | #--------------------------------------------------------------------------------- 88 | # use CXX for linking C++ projects, CC for standard C 89 | #--------------------------------------------------------------------------------- 90 | ifeq ($(strip $(CPPFILES)),) 91 | #--------------------------------------------------------------------------------- 92 | export LD := $(CC) 93 | #--------------------------------------------------------------------------------- 94 | else 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CXX) 97 | #--------------------------------------------------------------------------------- 98 | endif 99 | #--------------------------------------------------------------------------------- 100 | 101 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 102 | 103 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 104 | 105 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 106 | 107 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 108 | 109 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 110 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 111 | -I$(CURDIR)/$(BUILD) 112 | 113 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 114 | 115 | .PHONY: $(BUILD) clean 116 | 117 | #--------------------------------------------------------------------------------- 118 | $(BUILD): 119 | @[ -d $@ ] || mkdir -p $@ 120 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 121 | 122 | #--------------------------------------------------------------------------------- 123 | clean: 124 | @echo clean ... 125 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 126 | 127 | 128 | #--------------------------------------------------------------------------------- 129 | else 130 | 131 | #--------------------------------------------------------------------------------- 132 | # main targets 133 | #--------------------------------------------------------------------------------- 134 | 135 | $(OUTPUT).gba : $(OUTPUT).elf 136 | 137 | $(OUTPUT).elf : $(OFILES) 138 | 139 | $(OFILES_SOURCES) : $(HFILES) 140 | 141 | #--------------------------------------------------------------------------------- 142 | # The bin2o rule should be copied and modified 143 | # for each extension used in the data directories 144 | #--------------------------------------------------------------------------------- 145 | 146 | #--------------------------------------------------------------------------------- 147 | # rule to build soundbank from music files 148 | #--------------------------------------------------------------------------------- 149 | soundbank.bin soundbank.h : $(AUDIOFILES) 150 | #--------------------------------------------------------------------------------- 151 | @mmutil $^ -osoundbank.bin -hsoundbank.h 152 | 153 | #--------------------------------------------------------------------------------- 154 | # This rule links in binary data with the .bin extension 155 | #--------------------------------------------------------------------------------- 156 | %.bin.o %_bin.h : %.bin 157 | #--------------------------------------------------------------------------------- 158 | @echo $(notdir $<) 159 | @$(bin2o) 160 | 161 | 162 | 163 | -include $(DEPSDIR)/*.d 164 | 165 | #--------------------------------------------------------------------------------------- 166 | endif 167 | #--------------------------------------------------------------------------------------- 168 | -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/maxmod_data/Ambulance.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/audio/maxmod/basic_sound/maxmod_data/Ambulance.wav -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/maxmod_data/Boom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/audio/maxmod/basic_sound/maxmod_data/Boom.wav -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/maxmod_data/FlatOutLies.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/audio/maxmod/basic_sound/maxmod_data/FlatOutLies.mod -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/source/MaxModExample.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "soundbank.h" 8 | #include "soundbank_bin.h" 9 | 10 | int main() { 11 | 12 | irqInit(); 13 | 14 | // Maxmod requires the vblank interrupt to reset sound DMA. 15 | // Link the VBlank interrupt to mmVBlank, and enable it. 16 | irqSet( IRQ_VBLANK, mmVBlank ); 17 | irqEnable(IRQ_VBLANK); 18 | 19 | consoleDemoInit(); 20 | 21 | // ansi escape sequence to clear screen and home cursor 22 | // /x1b[line;columnH 23 | iprintf("\x1b[2J"); 24 | 25 | // initialise maxmod with soundbank and 8 channels 26 | mmInitDefault( (mm_addr)soundbank_bin, 8 ); 27 | 28 | // Start playing module 29 | mmStart( MOD_FLATOUTLIES, MM_PLAY_LOOP ); 30 | 31 | mm_sound_effect ambulance = { 32 | { SFX_AMBULANCE } , // id 33 | (int)(1.0f * (1<<10)), // rate 34 | 0, // handle 35 | 255, // volume 36 | 0, // panning 37 | }; 38 | 39 | mm_sound_effect boom = { 40 | { SFX_BOOM } , // id 41 | (int)(1.0f * (1<<10)), // rate 42 | 0, // handle 43 | 255, // volume 44 | 255, // panning 45 | }; 46 | 47 | // ansi escape sequence to clear screen and home cursor 48 | // /x1b[line;columnH 49 | iprintf("\x1b[2J"); 50 | 51 | // ansi escape sequence to set print co-ordinates 52 | // /x1b[line;columnH 53 | iprintf("\x1b[0;8HMaxMod Audio demo"); 54 | iprintf("\x1b[3;0HHold A for ambulance sound"); 55 | iprintf("\x1b[4;0HPress B for boom sound"); 56 | 57 | // sound effect handle (for cancelling it later) 58 | mm_sfxhand amb = 0; 59 | 60 | do { 61 | 62 | int keys_pressed, keys_released; 63 | 64 | VBlankIntrWait(); 65 | mmFrame(); 66 | 67 | scanKeys(); 68 | 69 | keys_pressed = keysDown(); 70 | keys_released = keysUp(); 71 | 72 | // Play looping ambulance sound effect out of left speaker if A button is pressed 73 | if ( keys_pressed & KEY_A ) { 74 | amb = mmEffectEx(&ambulance); 75 | } 76 | 77 | // stop ambulance sound when A button is released 78 | if ( keys_released & KEY_A ) { 79 | mmEffectCancel(amb); 80 | } 81 | 82 | // Play explosion sound effect out of right speaker if B button is pressed 83 | if ( keys_pressed & KEY_B ) { 84 | mmEffectEx(&boom); 85 | } 86 | 87 | } while( 1 ); 88 | } 89 | -------------------------------------------------------------------------------- /graphics/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | 9 | -------------------------------------------------------------------------------- /graphics/PCXView/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # INCLUDES is a list of directories containing extra header files 16 | # DATA is a list of directories containing binary data 17 | # GRAPHICS is a list of directories containing files to be processed by grit 18 | # 19 | # All directories are specified relative to the project directory where 20 | # the makefile is found 21 | # 22 | #--------------------------------------------------------------------------------- 23 | TARGET := $(notdir $(CURDIR)) 24 | BUILD := build 25 | SOURCES := source 26 | INCLUDES := include 27 | DATA := data 28 | MUSIC := 29 | 30 | #--------------------------------------------------------------------------------- 31 | # options for code generation 32 | #--------------------------------------------------------------------------------- 33 | ARCH := -mthumb -mthumb-interwork 34 | 35 | CFLAGS := -g -Wall -O3\ 36 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 37 | -fomit-frame-pointer\ 38 | -ffast-math \ 39 | $(ARCH) 40 | 41 | CFLAGS += $(INCLUDE) 42 | 43 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 44 | 45 | ASFLAGS := -g $(ARCH) 46 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 47 | 48 | #--------------------------------------------------------------------------------- 49 | # any extra libraries we wish to link with the project 50 | #--------------------------------------------------------------------------------- 51 | LIBS := -lmm -lgba 52 | 53 | 54 | #--------------------------------------------------------------------------------- 55 | # list of directories containing libraries, this must be the top level containing 56 | # include and lib 57 | #--------------------------------------------------------------------------------- 58 | LIBDIRS := $(LIBGBA) 59 | 60 | #--------------------------------------------------------------------------------- 61 | # no real need to edit anything past this point unless you need to add additional 62 | # rules for different file extensions 63 | #--------------------------------------------------------------------------------- 64 | 65 | 66 | ifneq ($(BUILD),$(notdir $(CURDIR))) 67 | #--------------------------------------------------------------------------------- 68 | 69 | export OUTPUT := $(CURDIR)/$(TARGET) 70 | 71 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 72 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 73 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 74 | 75 | export DEPSDIR := $(CURDIR)/$(BUILD) 76 | 77 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 78 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 79 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 80 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 81 | 82 | ifneq ($(strip $(MUSIC)),) 83 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 84 | BINFILES += soundbank.bin 85 | endif 86 | 87 | #--------------------------------------------------------------------------------- 88 | # use CXX for linking C++ projects, CC for standard C 89 | #--------------------------------------------------------------------------------- 90 | ifeq ($(strip $(CPPFILES)),) 91 | #--------------------------------------------------------------------------------- 92 | export LD := $(CC) 93 | #--------------------------------------------------------------------------------- 94 | else 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CXX) 97 | #--------------------------------------------------------------------------------- 98 | endif 99 | #--------------------------------------------------------------------------------- 100 | 101 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 102 | 103 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 104 | 105 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 106 | 107 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 108 | 109 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 110 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 111 | -I$(CURDIR)/$(BUILD) 112 | 113 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 114 | 115 | .PHONY: $(BUILD) clean 116 | 117 | #--------------------------------------------------------------------------------- 118 | $(BUILD): 119 | @[ -d $@ ] || mkdir -p $@ 120 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 121 | 122 | #--------------------------------------------------------------------------------- 123 | clean: 124 | @echo clean ... 125 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 126 | 127 | 128 | #--------------------------------------------------------------------------------- 129 | else 130 | 131 | #--------------------------------------------------------------------------------- 132 | # main targets 133 | #--------------------------------------------------------------------------------- 134 | 135 | $(OUTPUT).gba : $(OUTPUT).elf 136 | 137 | $(OUTPUT).elf : $(OFILES) 138 | 139 | $(OFILES_SOURCES) : $(HFILES) 140 | 141 | #--------------------------------------------------------------------------------- 142 | # The bin2o rule should be copied and modified 143 | # for each extension used in the data directories 144 | #--------------------------------------------------------------------------------- 145 | 146 | #--------------------------------------------------------------------------------- 147 | # rule to build soundbank from music files 148 | #--------------------------------------------------------------------------------- 149 | soundbank.bin soundbank.h : $(AUDIOFILES) 150 | #--------------------------------------------------------------------------------- 151 | @mmutil $^ -osoundbank.bin -hsoundbank.h 152 | 153 | #--------------------------------------------------------------------------------- 154 | %.pcx.o %_pcx.h : %.pcx 155 | #--------------------------------------------------------------------------------- 156 | @echo $(notdir $<) 157 | @$(bin2o) 158 | 159 | 160 | 161 | -include $(DEPSDIR)/*.d 162 | 163 | #--------------------------------------------------------------------------------------- 164 | endif 165 | #--------------------------------------------------------------------------------------- 166 | -------------------------------------------------------------------------------- /graphics/PCXView/data/splash.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/graphics/PCXView/data/splash.pcx -------------------------------------------------------------------------------- /graphics/PCXView/source/pcx.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | #include "gba_types.h" 3 | #include "pcx.h" 4 | //--------------------------------------------------------------------------------- 5 | 6 | u8 Buf[240]; 7 | 8 | //--------------------------------------------------------------------------------- 9 | // Screen address must be 16 bit boundary for VRAM 10 | // Can be RAM buffer for later copying 11 | // Palette can be direct to hardware or RAM buffer for fading 12 | //--------------------------------------------------------------------------------- 13 | void DecodePCX(const u8 *PCXBuffer, u16 * ScreenAddr, u16* Palette) 14 | //--------------------------------------------------------------------------------- 15 | { 16 | int c,l,r,g,b; 17 | int i; 18 | 19 | u16 *Scrn = ScreenAddr; 20 | pcx_header *header = (pcx_header *)PCXBuffer; 21 | u8 *Data = (u8*)PCXBuffer + sizeof(pcx_header); 22 | 23 | int Width = (header->x2 - header->x1)+1; 24 | int Height = (header->y2 - header->y1)+1; 25 | 26 | Width = ((Width+1)>>1)<<1; // PCX width is always even regardless of image 27 | 28 | if (Width>240 || Height>160) return; // too big for VRAM :) 29 | 30 | 31 | u8 *wptr = Buf; 32 | 33 | int j,k; 34 | for (j=0; j>1;i++) 59 | { 60 | *(Scrn++)=*(ptr++); 61 | } 62 | wptr = Buf; 63 | } 64 | 65 | 66 | Data++; // skip palette ID byte 67 | u16 * GBA_Palette = Palette; 68 | u16 color; 69 | 70 | // convert RGB triplets to GBA format 5:5:5 71 | for (i=0; i<256; i++) 72 | { 73 | r = *(Data++); 74 | g = *(Data++); 75 | b = *(Data++); 76 | 77 | color = ((r>>3)|((g>>3)<<5)|((b>>3)<<10)); 78 | *(GBA_Palette++) = color; 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /graphics/PCXView/source/pcx.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | #ifndef _pcx_h_ 3 | #define _pcx_h_ 4 | //--------------------------------------------------------------------------------- 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | //--------------------------------------------------------------------------------- 11 | 12 | typedef struct{ 13 | char manufacturer; 14 | char version; 15 | char encoding; 16 | char bpp; 17 | short int x1,y1; 18 | short int x2,y2; 19 | short int hres; 20 | short int vres; 21 | char palette[48]; 22 | char reserved; 23 | char color_planes; 24 | short int BytesPerLine; 25 | short int PaletteType; 26 | char dummy[58]; 27 | }__attribute__ ((packed)) pcx_header; 28 | 29 | void DecodePCX(const u8 *PCXBuffer, u16 *ScreenAddr, u16 *Palette); 30 | 31 | //--------------------------------------------------------------------------------- 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | //--------------------------------------------------------------------------------- 36 | 37 | //--------------------------------------------------------------------------------- 38 | #endif // _pcx_h_ 39 | //--------------------------------------------------------------------------------- 40 | -------------------------------------------------------------------------------- /graphics/PCXView/source/pcx_view.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | // GBA PCXView sample code for devkitARM - http://www.devkit.tk 3 | // Suitable for a splash screen for a game 4 | //--------------------------------------------------------------------------------- 5 | #include "gba_video.h" 6 | #include "gba_systemcalls.h" 7 | #include "gba_input.h" 8 | #include "gba_interrupt.h" 9 | #include "pcx.h" 10 | #include "fade.h" 11 | 12 | #include 13 | 14 | //--------------------------------------------------------------------------------- 15 | // header for binary data generated by bin2o macro in makefile 16 | //--------------------------------------------------------------------------------- 17 | #include "splash_pcx.h" 18 | 19 | //--------------------------------------------------------------------------------- 20 | // storage space for palette data 21 | //--------------------------------------------------------------------------------- 22 | u16 PaletteBuffer[256]; 23 | 24 | unsigned int frame; 25 | 26 | //--------------------------------------------------------------------------------- 27 | void VblankInterrupt() 28 | //--------------------------------------------------------------------------------- 29 | { 30 | frame += 1; 31 | scanKeys(); 32 | } 33 | 34 | //--------------------------------------------------------------------------------- 35 | // Program entry point 36 | //--------------------------------------------------------------------------------- 37 | int main(void) 38 | //--------------------------------------------------------------------------------- 39 | { 40 | // Set up the interrupt handlers 41 | irqInit(); 42 | 43 | irqSet( IRQ_VBLANK, VblankInterrupt); 44 | 45 | // Enable Vblank Interrupt to allow VblankIntrWait 46 | irqEnable(IRQ_VBLANK); 47 | 48 | // Allow Interrupts 49 | REG_IME = 1; 50 | 51 | SetMode( MODE_4 | BG2_ON ); // screen mode & background to display 52 | 53 | DecodePCX(splash_pcx, (u16*)VRAM , PaletteBuffer); 54 | 55 | FadeToPalette( PaletteBuffer, 60); 56 | 57 | while (1) 58 | { 59 | VBlankIntrWait(); 60 | } 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /graphics/SimpleBGScroll/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # INCLUDES is a list of directories containing extra header files 16 | # DATA is a list of directories containing binary data 17 | # GRAPHICS is a list of directories containing files to be processed by grit 18 | # 19 | # All directories are specified relative to the project directory where 20 | # the makefile is found 21 | # 22 | #--------------------------------------------------------------------------------- 23 | TARGET := $(notdir $(CURDIR)) 24 | BUILD := build 25 | SOURCES := source 26 | INCLUDES := include 27 | DATA := font 28 | MUSIC := 29 | 30 | #--------------------------------------------------------------------------------- 31 | # options for code generation 32 | #--------------------------------------------------------------------------------- 33 | ARCH := -mthumb -mthumb-interwork 34 | 35 | CFLAGS := -g -Wall -O3\ 36 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 37 | -fomit-frame-pointer\ 38 | -ffast-math \ 39 | $(ARCH) 40 | 41 | CFLAGS += $(INCLUDE) 42 | 43 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 44 | 45 | ASFLAGS := -g $(ARCH) 46 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 47 | 48 | #--------------------------------------------------------------------------------- 49 | # any extra libraries we wish to link with the project 50 | #--------------------------------------------------------------------------------- 51 | LIBS := -lmm -lgba 52 | 53 | 54 | #--------------------------------------------------------------------------------- 55 | # list of directories containing libraries, this must be the top level containing 56 | # include and lib 57 | #--------------------------------------------------------------------------------- 58 | LIBDIRS := $(LIBGBA) 59 | 60 | #--------------------------------------------------------------------------------- 61 | # no real need to edit anything past this point unless you need to add additional 62 | # rules for different file extensions 63 | #--------------------------------------------------------------------------------- 64 | 65 | 66 | ifneq ($(BUILD),$(notdir $(CURDIR))) 67 | #--------------------------------------------------------------------------------- 68 | 69 | export OUTPUT := $(CURDIR)/$(TARGET) 70 | 71 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 72 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 73 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 74 | 75 | export DEPSDIR := $(CURDIR)/$(BUILD) 76 | 77 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 78 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 79 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 80 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 81 | 82 | ifneq ($(strip $(MUSIC)),) 83 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 84 | BINFILES += soundbank.bin 85 | endif 86 | 87 | #--------------------------------------------------------------------------------- 88 | # use CXX for linking C++ projects, CC for standard C 89 | #--------------------------------------------------------------------------------- 90 | ifeq ($(strip $(CPPFILES)),) 91 | #--------------------------------------------------------------------------------- 92 | export LD := $(CC) 93 | #--------------------------------------------------------------------------------- 94 | else 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CXX) 97 | #--------------------------------------------------------------------------------- 98 | endif 99 | #--------------------------------------------------------------------------------- 100 | 101 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 102 | 103 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 104 | 105 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 106 | 107 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 108 | 109 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 110 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 111 | -I$(CURDIR)/$(BUILD) 112 | 113 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 114 | 115 | .PHONY: $(BUILD) clean 116 | 117 | #--------------------------------------------------------------------------------- 118 | $(BUILD): 119 | @[ -d $@ ] || mkdir -p $@ 120 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 121 | 122 | #--------------------------------------------------------------------------------- 123 | clean: 124 | @echo clean ... 125 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 126 | 127 | 128 | #--------------------------------------------------------------------------------- 129 | else 130 | 131 | #--------------------------------------------------------------------------------- 132 | # main targets 133 | #--------------------------------------------------------------------------------- 134 | 135 | $(OUTPUT).gba : $(OUTPUT).elf 136 | 137 | $(OUTPUT).elf : $(OFILES) 138 | 139 | $(OFILES_SOURCES) : $(HFILES) 140 | 141 | #--------------------------------------------------------------------------------- 142 | # The bin2o rule should be copied and modified 143 | # for each extension used in the data directories 144 | #--------------------------------------------------------------------------------- 145 | 146 | #--------------------------------------------------------------------------------- 147 | # rule to build soundbank from music files 148 | #--------------------------------------------------------------------------------- 149 | soundbank.bin soundbank.h : $(AUDIOFILES) 150 | #--------------------------------------------------------------------------------- 151 | @mmutil $^ -osoundbank.bin -hsoundbank.h 152 | 153 | #--------------------------------------------------------------------------------- 154 | # This rule links in binary data with the .bin extension 155 | #--------------------------------------------------------------------------------- 156 | %.bin.o %_bin.h : %.bin 157 | #--------------------------------------------------------------------------------- 158 | @echo $(notdir $<) 159 | @$(bin2o) 160 | 161 | 162 | 163 | -include $(DEPSDIR)/*.d 164 | 165 | #--------------------------------------------------------------------------------------- 166 | endif 167 | #--------------------------------------------------------------------------------------- 168 | -------------------------------------------------------------------------------- /graphics/SimpleBGScroll/font/r6502_portfont.bin: -------------------------------------------------------------------------------- 1 | "3`U` &bb033dd``f ""66D@FdPUUfffaf&b36@dFdff 3`dDPU`f``bc@`bc@``f"b0c3Df@`f ""6f@3DP ""ffDU`af b3f@dPffa"& b36cDf@dPUUfffaa&b0c@dPef`fa ""f3ffDUUU`fff`fa""f`6@dUUUf`ffaa ""bf6c@dPeffff"""`f6@dUUUf`ffff"""3f6D@dPUUfff`faa b0c@dPeffa ""f3f6D@dPUUffffa ""bf6c@dPUUfff`3D``3DPaa "b3c@de`ff033ff""3cDfe`f`a""f3f`U`ffaabbbbc33cd`ffPUUfffa"""b3f6cD@dUPe`ffa"""f3f6D@dUUUf`ffff"3D@PUUffffa" b30cD@dUUUf`fffff""3ffDUUU`ffffff""3ffDU`ff""30cD@dPUUfffaa"""b3f6cD@dUPe`f`f"3DUUU`ffaa" b30cD@dPUUfffaf""b3f3D@UPe`f"3DUUU`fffaa"&&b36cD@dUPe`faa"&"b33cD@dUPe`ffa" b30cD@dPUUffffa"""f3ffDU`fa" b30cDDdPUUeffffa"""f36cDDUP`fff ""f6D@dPUUfffafa b0c@dPefaa" b30cD@dPUUfffaa" b30c@DfUe`faa"& b333cDdDdUfPe`faf"b0c3Df@UPe`faaaa""f0c@dPeffaf b3f@dPUUfffafa b0c@dPUff @`aa b0c@dPUeff`UUU`fff"f"33DDPUPff"f"33DDUUe`ff"ff3DPUUff"f"33DDPUUff"f"333DffPUUfff"""`3fDU`f""033fDPUeff""3f3DDUU``f 0c@dPeff 0cD@dPUff"&b33fDFUU``aa b0c@dPef"& 366cDFFdUVVe`f"f"33DDUU``"f"33DDPUeff"f"33DDdUff`"f"33@DDfU`"f3fDU`"ff03fDUUe`ff`"f3DPUf""33DDPUeff""33@DdUf`"& b366cDFFdPUff` "f3c@dDUfP`f""03cDfPef`&b3f@dUUU`ff`bbcc@@`U`f` `@`@``aa ` 00UUUe`fffaffaaabbccddUUUe`fffffaabbfbc3cd`fdPUU`ff -------------------------------------------------------------------------------- /graphics/SimpleBGScroll/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | A demonstration of a simple background tile scroller for the Gameboy Advance. 4 | Very oldschool. Every once in a while someone comes along and either wonders 5 | how to do it or has a problem with theirs, so I wrote this to help them out 6 | a bit, or rather, help them understand the concept. The source is commented 7 | (hopefully well enough). 8 | 9 | This was built using Wintermute's GCC toolchain for win32 environment, and 10 | that can be found here: 11 | 12 | http://www.devkit.tk/ 13 | 14 | or 15 | 16 | http://homepage.ntlworld.com/wintermute2002/ 17 | 18 | Yes, you should be using this, NOT outdated toolchains. 19 | It is leaner, faster, up to date and uses MingW env. 20 | 21 | 22 | Code and font by: 23 | r6502 (r6502ATphokos.com) 24 | 2004-04-02 25 | 26 | Happy Coding! -------------------------------------------------------------------------------- /graphics/SimpleBGScroll/source/main.c: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------- 2 | // 3 | // Super Simple Background Text Scroller v1.0 4 | // 5 | // Not terribly unlike how we did it in the c64 days. Although this 6 | // is C and on the c64 we used asm, the concept is very much similar. 7 | // This source is set up so you can tweak the speed and the row to 8 | // scroll the text on... In actuality there are a number of ways 9 | // to perform a scroller like this, but I tried to break it down 10 | // in a simple fashion to make it easier to understand (hopefully!) 11 | // 12 | // r6502 - 2004-04-02 13 | // 14 | // Note: tabs == 4 on my setup 15 | // 16 | // -------------------------------------------------------------------- 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "r6502_portfont_bin.h" 24 | 25 | // -------------------------------------------------------------------- 26 | 27 | #define MAPADDRESS MAP_BASE_ADR(31) // our base map address 28 | #define DELAY 2 // slow things down 29 | #define TILEWIDTH 8 // how much to scroll 30 | #define ROW 10 // what row to place text at 31 | 32 | // -------------------------------------------------------------------- 33 | 34 | const u16 palette[] = { 35 | RGB8(0x40,0x80,0xc0), 36 | RGB8(0xFF,0xFF,0xFF), 37 | RGB8(0xF5,0xFF,0xFF), 38 | RGB8(0xDF,0xFF,0xF2), 39 | RGB8(0xCA,0xFF,0xE2), 40 | RGB8(0xB7,0xFD,0xD8), 41 | RGB8(0x2C,0x4F,0x8B) 42 | }; 43 | 44 | // -------------------------------------------------------------------- 45 | 46 | const u8 message[] = { 47 | " " \ 48 | "Hello, this is an example of an oldschool simple tile scroller " \ 49 | "not unlike how it was done in days of yore. The '@' symbol " \ 50 | "at the top of your screen is intentional, to dispel the illusion " \ 51 | "of this scroller, to demonstrate the simple concept behind it. " \ 52 | "Check out the source to learn how it works. It is very simple! " \ 53 | "This exercise brought to you by r6502... " \ 54 | "Text is about to restart... " 55 | }; 56 | 57 | // -------------------------------------------------------------------- 58 | 59 | 60 | void updatescrolltext(u32 idx) 61 | { 62 | u32 i; 63 | u16 *temppointer; 64 | 65 | temppointer = (u16 *)MAPADDRESS + (ROW * 32); 66 | 67 | // write out a whole row of text to the map 68 | for(i=0; i<32; i++) 69 | { 70 | // check for end of message so we can wrap around properly 71 | if(message[idx] == 0) idx = 0; 72 | 73 | // write a character - we subtract 32, because the font graphics 74 | // start at tile 0, but our text is in ascii (starting at 32 and up) 75 | // in other words, tile 0 is a space in our font, but in ascii a 76 | // space is 32 so we must account for that difference between the two. 77 | *temppointer++ = message[idx++] - 32; 78 | } 79 | } 80 | 81 | 82 | int main() { 83 | // Set up the interrupt handlers 84 | irqInit(); 85 | // Enable Vblank Interrupt to allow VblankIntrWait 86 | irqEnable(IRQ_VBLANK); 87 | 88 | // Allow Interrupts 89 | REG_IME = 1; 90 | 91 | u32 i, scrollx, scrolldelay, textindex; 92 | u16 *temppointer; 93 | 94 | 95 | // load the palette for the background, 7 colors 96 | temppointer = BG_COLORS; 97 | for(i=0; i<7; i++) { 98 | *temppointer++ = palette[i]; 99 | } 100 | 101 | // load the font into gba video mem (48 characters, 4bit tiles) 102 | 103 | CpuFastSet(r6502_portfont_bin, (u16*)VRAM,(r6502_portfont_bin_size/4) | COPY32); 104 | 105 | // clear screen map with tile 0 ('space' tile) (256x256 halfwords) 106 | 107 | *((u32 *)MAP_BASE_ADR(31)) =0; 108 | CpuFastSet( MAP_BASE_ADR(31), MAP_BASE_ADR(31), FILL | COPY32 | (0x800/4)); 109 | 110 | // set screen H and V scroll positions 111 | BG_OFFSET[0].x = 0; BG_OFFSET[0].y = 0; 112 | 113 | // initialize our variables 114 | scrollx = 0; 115 | textindex = 0; 116 | scrolldelay = 0; 117 | 118 | // put the '@' symbol on the top of the screen to show how 119 | // the screen is only scrolling 7 pixels - to reveal the 120 | // illusion of how the scroller works 121 | *((u16 *)MAPADDRESS + 1) = 0x20; // 0x20 == '@' 122 | 123 | // draw a row of text from beginning of message 124 | updatescrolltext(0); 125 | 126 | // set the screen base to 31 (0x600F800) and char base to 0 (0x6000000) 127 | BGCTRL[0] = SCREEN_BASE(31); 128 | 129 | // screen mode & background to display 130 | SetMode( MODE_0 | BG0_ON ); 131 | 132 | while(1) { 133 | VBlankIntrWait(); 134 | 135 | // check if we reached our delay 136 | if(scrolldelay == DELAY) { 137 | // yes, the delay is complete, so let's reset it 138 | scrolldelay = 0; 139 | 140 | // check if we reached our scrollcount 141 | if(scrollx == (TILEWIDTH-1)) { 142 | // yes, we've scrolled enough, so let's reset the count 143 | scrollx = 0; 144 | 145 | // check if we reached the end of our scrolltext 146 | // and if so we need to restart our index 147 | if(message[textindex] == 0) textindex = 0; 148 | else textindex++; 149 | 150 | // finally, let's update the scrolltext with the current text index 151 | updatescrolltext(textindex); 152 | } 153 | else scrollx++; 154 | } 155 | else scrolldelay++; 156 | 157 | // update the hardware horizontal scroll register 158 | BG_OFFSET[0].x = scrollx; 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /graphics/ansi_console/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 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 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | INCLUDES := 24 | 25 | #--------------------------------------------------------------------------------- 26 | # options for code generation 27 | #--------------------------------------------------------------------------------- 28 | ARCH := -mthumb -mthumb-interwork 29 | 30 | CFLAGS := -g -Wall -O3\ 31 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 32 | -fomit-frame-pointer\ 33 | -ffast-math \ 34 | $(ARCH) 35 | 36 | CFLAGS += $(INCLUDE) 37 | 38 | ASFLAGS := $(ARCH) 39 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 40 | 41 | #--------------------------------------------------------------------------------- 42 | # path to tools - this can be deleted if you set the path to the toolchain in windows 43 | #--------------------------------------------------------------------------------- 44 | export PATH := $(DEVKITARM)/bin:$(PATH) 45 | 46 | #--------------------------------------------------------------------------------- 47 | # any extra libraries we wish to link with the project 48 | #--------------------------------------------------------------------------------- 49 | LIBS := -lgba 50 | 51 | #--------------------------------------------------------------------------------- 52 | # list of directories containing libraries, this must be the top level containing 53 | # include and lib 54 | #--------------------------------------------------------------------------------- 55 | LIBDIRS := $(LIBGBA) 56 | 57 | #--------------------------------------------------------------------------------- 58 | # no real need to edit anything past this point unless you need to add additional 59 | # rules for different file extensions 60 | #--------------------------------------------------------------------------------- 61 | ifneq ($(BUILD),$(notdir $(CURDIR))) 62 | #--------------------------------------------------------------------------------- 63 | 64 | export OUTPUT := $(CURDIR)/$(TARGET) 65 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 66 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 67 | 68 | export DEPSDIR := $(CURDIR)/$(BUILD) 69 | 70 | #--------------------------------------------------------------------------------- 71 | # automatically build a list of object files for our project 72 | #--------------------------------------------------------------------------------- 73 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 74 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 75 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 76 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 77 | 78 | #--------------------------------------------------------------------------------- 79 | # use CXX for linking C++ projects, CC for standard C 80 | #--------------------------------------------------------------------------------- 81 | ifeq ($(strip $(CPPFILES)),) 82 | #--------------------------------------------------------------------------------- 83 | export LD := $(CC) 84 | #--------------------------------------------------------------------------------- 85 | else 86 | #--------------------------------------------------------------------------------- 87 | export LD := $(CXX) 88 | #--------------------------------------------------------------------------------- 89 | endif 90 | #--------------------------------------------------------------------------------- 91 | 92 | export OFILES := $(addsuffix .o,$(BINFILES)) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 93 | 94 | #--------------------------------------------------------------------------------- 95 | # build a list of include paths 96 | #--------------------------------------------------------------------------------- 97 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 98 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 99 | -I$(CURDIR)/$(BUILD) 100 | 101 | #--------------------------------------------------------------------------------- 102 | # build a list of library paths 103 | #--------------------------------------------------------------------------------- 104 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 105 | 106 | .PHONY: $(BUILD) clean 107 | 108 | #--------------------------------------------------------------------------------- 109 | $(BUILD): 110 | @[ -d $@ ] || mkdir -p $@ 111 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 112 | 113 | all : $(BUILD) 114 | #--------------------------------------------------------------------------------- 115 | clean: 116 | @echo clean ... 117 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 118 | 119 | #--------------------------------------------------------------------------------- 120 | else 121 | 122 | DEPENDS := $(OFILES:.o=.d) 123 | 124 | #--------------------------------------------------------------------------------- 125 | # main targets 126 | #--------------------------------------------------------------------------------- 127 | $(OUTPUT).gba : $(OUTPUT).elf 128 | 129 | $(OUTPUT).elf : $(OFILES) 130 | 131 | %.o : %.pcx 132 | @echo $(notdir $<) 133 | @$(bin2o) 134 | 135 | -include $(DEPENDS) 136 | 137 | #--------------------------------------------------------------------------------- 138 | endif 139 | #--------------------------------------------------------------------------------- 140 | -------------------------------------------------------------------------------- /graphics/ansi_console/source/console.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | //--------------------------------------------------------------------------------- 10 | // Program entry point 11 | //--------------------------------------------------------------------------------- 12 | int main(void) { 13 | //--------------------------------------------------------------------------------- 14 | 15 | // the vblank interrupt must be enabled for VBlankIntrWait() to work 16 | // since the default dispatcher handles the bios flags no vblank handler 17 | // is required 18 | irqInit(); 19 | irqEnable(IRQ_VBLANK); 20 | 21 | consoleDemoInit(); 22 | 23 | // ansi escape sequence to clear screen and home cursor 24 | // /x1b[line;columnH 25 | iprintf("\x1b[2J"); 26 | 27 | // ansi escape sequence to set print co-ordinates 28 | // /x1b[line;columnH 29 | iprintf("\x1b[10;10HHello World!"); 30 | 31 | // ansi escape sequence to move cursor up 32 | // /x1b[linesA 33 | iprintf("\x1b[10ALine 0"); 34 | 35 | // ansi escape sequence to move cursor left 36 | // /x1b[columnsD 37 | iprintf("\x1b[28DColumn 0"); 38 | 39 | // ansi escape sequence to move cursor down 40 | // /x1b[linesB 41 | iprintf("\x1b[19BLine 19"); 42 | 43 | // ansi escape sequence to move cursor right 44 | // /x1b[columnsC 45 | iprintf("\x1b[5CColumn 20"); 46 | 47 | while (1) { 48 | VBlankIntrWait(); 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /img/PCXView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/PCXView.png -------------------------------------------------------------------------------- /img/PlayBoyScout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/PlayBoyScout.png -------------------------------------------------------------------------------- /img/SimpleBGScroll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/SimpleBGScroll.gif -------------------------------------------------------------------------------- /img/XbooLoad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/XbooLoad.png -------------------------------------------------------------------------------- /img/ansi_console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/ansi_console.png -------------------------------------------------------------------------------- /img/basic_sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/basic_sound.png -------------------------------------------------------------------------------- /img/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/img/template.png -------------------------------------------------------------------------------- /mbv2/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /mbv2/mbv2print/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb generates a multiboot image 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # INCLUDES is a list of directories containing extra header files 17 | #--------------------------------------------------------------------------------- 18 | TARGET := mbv2print 19 | BUILD := build 20 | SOURCES := src data 21 | INCLUDES := 22 | 23 | #--------------------------------------------------------------------------------- 24 | # options for code generation 25 | #--------------------------------------------------------------------------------- 26 | ARCH := -mthumb -mthumb-interwork 27 | 28 | CFLAGS := -g -Wall -O3\ 29 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 30 | -fomit-frame-pointer\ 31 | -ffast-math \ 32 | $(ARCH) 33 | 34 | CFLAGS += $(INCLUDE) 35 | 36 | ASFLAGS := $(ARCH) 37 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 38 | 39 | #--------------------------------------------------------------------------------- 40 | # path to tools - this can be deleted if you set the path in windows 41 | #--------------------------------------------------------------------------------- 42 | export PATH := $(DEVKITARM)/bin:$(PATH) 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | 64 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) 65 | export PATH := $(DEVKITARM)/bin:$(PATH) 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # use CXX for linking C++ projects, CC for standard C 77 | #--------------------------------------------------------------------------------- 78 | ifeq ($(strip $(CPPFILES)),) 79 | #--------------------------------------------------------------------------------- 80 | export LD := $(CC) 81 | #--------------------------------------------------------------------------------- 82 | else 83 | #--------------------------------------------------------------------------------- 84 | export LD := $(CXX) 85 | #--------------------------------------------------------------------------------- 86 | endif 87 | #--------------------------------------------------------------------------------- 88 | 89 | export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 90 | 91 | #--------------------------------------------------------------------------------- 92 | # build a list of include paths 93 | #--------------------------------------------------------------------------------- 94 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 95 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 96 | -I$(CURDIR)/$(BUILD) 97 | 98 | #--------------------------------------------------------------------------------- 99 | # build a list of library paths 100 | #--------------------------------------------------------------------------------- 101 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 102 | 103 | .PHONY: $(BUILD) clean 104 | 105 | #--------------------------------------------------------------------------------- 106 | $(BUILD): 107 | @[ -d $@ ] || mkdir -p $@ 108 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 109 | 110 | #--------------------------------------------------------------------------------- 111 | clean: 112 | @echo clean ... 113 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 114 | 115 | #--------------------------------------------------------------------------------- 116 | else 117 | 118 | DEPENDS := $(OFILES:.o=.d) 119 | 120 | #--------------------------------------------------------------------------------- 121 | # main targets 122 | #--------------------------------------------------------------------------------- 123 | $(OUTPUT).gba : $(OUTPUT).elf 124 | 125 | $(OUTPUT).elf : $(OFILES) $(LIBGBA)/lib/libgba.a 126 | 127 | -include $(DEPENDS) 128 | 129 | #--------------------------------------------------------------------------------- 130 | endif 131 | #--------------------------------------------------------------------------------- 132 | -------------------------------------------------------------------------------- /mbv2/mbv2print/src/mbv2print.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | // GBA sample code for devkitARM - http://www.devkitpro.org 3 | // mbv2 hello world 4 | // 5 | // mb -s mbv2print_mb.gba -w 25 -x 150 -c 6 | //--------------------------------------------------------------------------------- 7 | #include 8 | #include 9 | #include "gba_systemcalls.h" 10 | 11 | 12 | // for Xboo Communicator use xcomms.h 13 | // for vba/mappy use mappy.h 14 | 15 | #include "mbv2.h" 16 | 17 | //--------------------------------------------------------------------------------- 18 | // Program entry point 19 | //--------------------------------------------------------------------------------- 20 | int main(void) 21 | //--------------------------------------------------------------------------------- 22 | { 23 | 24 | dprintf("Hello World!\n"); 25 | 26 | while (1); 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /template/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # INCLUDES is a list of directories containing extra header files 16 | # DATA is a list of directories containing binary data 17 | # GRAPHICS is a list of directories containing files to be processed by grit 18 | # 19 | # All directories are specified relative to the project directory where 20 | # the makefile is found 21 | # 22 | #--------------------------------------------------------------------------------- 23 | TARGET := $(notdir $(CURDIR)) 24 | BUILD := build 25 | SOURCES := source 26 | INCLUDES := include 27 | DATA := 28 | MUSIC := 29 | 30 | #--------------------------------------------------------------------------------- 31 | # options for code generation 32 | #--------------------------------------------------------------------------------- 33 | ARCH := -mthumb -mthumb-interwork 34 | 35 | CFLAGS := -g -Wall -O2\ 36 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 37 | $(ARCH) 38 | 39 | CFLAGS += $(INCLUDE) 40 | 41 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 42 | 43 | ASFLAGS := -g $(ARCH) 44 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 45 | 46 | #--------------------------------------------------------------------------------- 47 | # any extra libraries we wish to link with the project 48 | #--------------------------------------------------------------------------------- 49 | LIBS := -lmm -lgba 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := $(LIBGBA) 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | 63 | 64 | ifneq ($(BUILD),$(notdir $(CURDIR))) 65 | #--------------------------------------------------------------------------------- 66 | 67 | export OUTPUT := $(CURDIR)/$(TARGET) 68 | 69 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 70 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 71 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 72 | 73 | export DEPSDIR := $(CURDIR)/$(BUILD) 74 | 75 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 76 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 77 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 78 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 79 | 80 | ifneq ($(strip $(MUSIC)),) 81 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 82 | BINFILES += soundbank.bin 83 | endif 84 | 85 | #--------------------------------------------------------------------------------- 86 | # use CXX for linking C++ projects, CC for standard C 87 | #--------------------------------------------------------------------------------- 88 | ifeq ($(strip $(CPPFILES)),) 89 | #--------------------------------------------------------------------------------- 90 | export LD := $(CC) 91 | #--------------------------------------------------------------------------------- 92 | else 93 | #--------------------------------------------------------------------------------- 94 | export LD := $(CXX) 95 | #--------------------------------------------------------------------------------- 96 | endif 97 | #--------------------------------------------------------------------------------- 98 | 99 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 100 | 101 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 102 | 103 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 104 | 105 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 106 | 107 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | -I$(CURDIR)/$(BUILD) 110 | 111 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 112 | 113 | .PHONY: $(BUILD) clean 114 | 115 | #--------------------------------------------------------------------------------- 116 | $(BUILD): 117 | @[ -d $@ ] || mkdir -p $@ 118 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 119 | 120 | #--------------------------------------------------------------------------------- 121 | clean: 122 | @echo clean ... 123 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 124 | 125 | 126 | #--------------------------------------------------------------------------------- 127 | else 128 | 129 | #--------------------------------------------------------------------------------- 130 | # main targets 131 | #--------------------------------------------------------------------------------- 132 | 133 | $(OUTPUT).gba : $(OUTPUT).elf 134 | 135 | $(OUTPUT).elf : $(OFILES) 136 | 137 | $(OFILES_SOURCES) : $(HFILES) 138 | 139 | #--------------------------------------------------------------------------------- 140 | # The bin2o rule should be copied and modified 141 | # for each extension used in the data directories 142 | #--------------------------------------------------------------------------------- 143 | 144 | #--------------------------------------------------------------------------------- 145 | # rule to build soundbank from music files 146 | #--------------------------------------------------------------------------------- 147 | soundbank.bin soundbank.h : $(AUDIOFILES) 148 | #--------------------------------------------------------------------------------- 149 | @mmutil $^ -osoundbank.bin -hsoundbank.h 150 | 151 | #--------------------------------------------------------------------------------- 152 | # This rule links in binary data with the .bin extension 153 | #--------------------------------------------------------------------------------- 154 | %.bin.o %_bin.h : %.bin 155 | #--------------------------------------------------------------------------------- 156 | @echo $(notdir $<) 157 | @$(bin2o) 158 | 159 | 160 | -include $(DEPSDIR)/*.d 161 | #--------------------------------------------------------------------------------------- 162 | endif 163 | #--------------------------------------------------------------------------------------- 164 | -------------------------------------------------------------------------------- /template/source/template.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | //--------------------------------------------------------------------------------- 11 | // Program entry point 12 | //--------------------------------------------------------------------------------- 13 | int main(void) { 14 | //--------------------------------------------------------------------------------- 15 | 16 | 17 | // the vblank interrupt must be enabled for VBlankIntrWait() to work 18 | // since the default dispatcher handles the bios flags no vblank handler 19 | // is required 20 | irqInit(); 21 | irqEnable(IRQ_VBLANK); 22 | 23 | consoleDemoInit(); 24 | 25 | // ansi escape sequence to set print co-ordinates 26 | // /x1b[line;columnH 27 | iprintf("\x1b[10;10HHello World!\n"); 28 | 29 | while (1) { 30 | VBlankIntrWait(); 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /utility/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /utility/biosdumper/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 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 | TARGET := $(shell basename $(CURDIR))_mb 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | INCLUDES := 24 | 25 | #--------------------------------------------------------------------------------- 26 | # options for code generation 27 | #--------------------------------------------------------------------------------- 28 | ARCH := -mthumb -mthumb-interwork 29 | 30 | CFLAGS := -g -Wall -O3\ 31 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 32 | -fomit-frame-pointer\ 33 | -ffast-math \ 34 | $(ARCH) 35 | 36 | CFLAGS += $(INCLUDE) 37 | 38 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 39 | 40 | ASFLAGS := $(ARCH) 41 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 42 | 43 | #--------------------------------------------------------------------------------- 44 | # path to tools - this can be deleted if you set the path to the toolchain in windows 45 | #--------------------------------------------------------------------------------- 46 | export PATH := $(DEVKITARM)/bin:$(PATH) 47 | 48 | #--------------------------------------------------------------------------------- 49 | # any extra libraries we wish to link with the project 50 | #--------------------------------------------------------------------------------- 51 | LIBS := -lfat -lgba 52 | 53 | #--------------------------------------------------------------------------------- 54 | # list of directories containing libraries, this must be the top level containing 55 | # include and lib 56 | #--------------------------------------------------------------------------------- 57 | LIBDIRS := $(LIBGBA) 58 | 59 | #--------------------------------------------------------------------------------- 60 | # no real need to edit anything past this point unless you need to add additional 61 | # rules for different file extensions 62 | #--------------------------------------------------------------------------------- 63 | ifneq ($(BUILD),$(notdir $(CURDIR))) 64 | #--------------------------------------------------------------------------------- 65 | 66 | export OUTPUT := $(CURDIR)/$(TARGET) 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 69 | 70 | export DEPSDIR := $(CURDIR)/$(BUILD) 71 | 72 | #--------------------------------------------------------------------------------- 73 | # automatically build a list of object files for our project 74 | #--------------------------------------------------------------------------------- 75 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 76 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 77 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 78 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 79 | 80 | #--------------------------------------------------------------------------------- 81 | # use CXX for linking C++ projects, CC for standard C 82 | #--------------------------------------------------------------------------------- 83 | ifeq ($(strip $(CPPFILES)),) 84 | #--------------------------------------------------------------------------------- 85 | export LD := $(CC) 86 | #--------------------------------------------------------------------------------- 87 | else 88 | #--------------------------------------------------------------------------------- 89 | export LD := $(CXX) 90 | #--------------------------------------------------------------------------------- 91 | endif 92 | #--------------------------------------------------------------------------------- 93 | 94 | export OFILES := $(addsuffix .o,$(BINFILES)) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 95 | 96 | #--------------------------------------------------------------------------------- 97 | # build a list of include paths 98 | #--------------------------------------------------------------------------------- 99 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 100 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 101 | -I$(CURDIR)/$(BUILD) 102 | 103 | #--------------------------------------------------------------------------------- 104 | # build a list of library paths 105 | #--------------------------------------------------------------------------------- 106 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 107 | 108 | .PHONY: $(BUILD) clean 109 | 110 | #--------------------------------------------------------------------------------- 111 | $(BUILD): 112 | @[ -d $@ ] || mkdir -p $@ 113 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 114 | 115 | all : $(BUILD) 116 | #--------------------------------------------------------------------------------- 117 | clean: 118 | @echo clean ... 119 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 120 | 121 | #--------------------------------------------------------------------------------- 122 | else 123 | 124 | DEPENDS := $(OFILES:.o=.d) 125 | 126 | #--------------------------------------------------------------------------------- 127 | # main targets 128 | #--------------------------------------------------------------------------------- 129 | $(OUTPUT).gba : $(OUTPUT).elf 130 | 131 | $(OUTPUT).elf : $(OFILES) 132 | 133 | -include $(DEPENDS) 134 | 135 | #--------------------------------------------------------------------------------- 136 | endif 137 | #--------------------------------------------------------------------------------- 138 | -------------------------------------------------------------------------------- /utility/biosdumper/source/biosdumper.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Some emulators need the bios from your gba in order to use SWI calls 4 | 5 | This little piece of code will read the bios and save it to your 6 | SD/CF card device using the magic of libfat. 7 | 8 | Some cards are supported be default, the binary will need patched with 9 | the appropriate DLDI file for newer cards. 10 | 11 | ---------------------------------------------------------------------------------*/ 12 | 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | //--------------------------------------------------------------------------------- 21 | void waitForever() { 22 | //--------------------------------------------------------------------------------- 23 | while (1) 24 | VBlankIntrWait(); 25 | } 26 | 27 | //--------------------------------------------------------------------------------- 28 | // Program entry point 29 | //--------------------------------------------------------------------------------- 30 | int main(void) { 31 | //--------------------------------------------------------------------------------- 32 | 33 | 34 | // the vblank interrupt must be enabled for VBlankIntrWait() to work 35 | // since the default dispatcher handles the bios flags no vblank handler 36 | // is required 37 | irqInit(); 38 | irqEnable(IRQ_VBLANK); 39 | 40 | consoleDemoInit(); 41 | 42 | iprintf("GBA Bios Dumper\n\n"); 43 | 44 | if (fatInitDefault()) { 45 | iprintf("FAT system initialised\n"); 46 | } else { 47 | iprintf("FAT system failed!\n"); 48 | waitForever(); 49 | } 50 | 51 | u32 *bios = (u32 *)malloc(0x4000); 52 | 53 | if ( bios ) { 54 | iprintf("Memory allocated\n"); 55 | } else { 56 | iprintf("Memory allocation failure!\n"); 57 | waitForever(); 58 | } 59 | 60 | int i; 61 | 62 | iprintf("dumping "); 63 | 64 | for (i=0; i<0x4000; i+=4) 65 | { 66 | // The MidiKey2Freq bios call allows us to read from bios 67 | // the lower bits are inaccurate, so just get it four times :) 68 | u32 a = MidiKey2Freq((WaveData *)(i-4), 180-12, 0) * 2; 69 | u32 b = MidiKey2Freq((WaveData *)(i-3), 180-12, 0) * 2; 70 | u32 c = MidiKey2Freq((WaveData *)(i-2), 180-12, 0) * 2; 71 | u32 d = MidiKey2Freq((WaveData *)(i-1), 180-12, 0) * 2; 72 | 73 | // rebuild a 32bit word from the 4 words we read 74 | u32 abcd = ( a & 0xff000000 ) | 75 | ( d & 0xff000000 ) >> 8 | 76 | ( c & 0xff000000 ) >> 16 | 77 | ( b & 0xff000000 ) >> 24; 78 | bios[i/4] = abcd; 79 | 80 | //print a dot every 256 bytes 81 | if ( (i & 0xff) == 0 ) iprintf("."); 82 | 83 | } 84 | 85 | iprintf("\nBios dumped, saving file\n"); 86 | 87 | FILE *biosFile = fopen("biosgba.rom","wb"); 88 | if (biosFile ) { 89 | fwrite(bios,16384,1,biosFile); 90 | fclose(biosFile); 91 | iprintf("bios saved!"); 92 | } else { 93 | iprintf("file creation failed!"); 94 | } 95 | 96 | waitForever(); 97 | 98 | return 0; 99 | } 100 | 101 | 102 | -------------------------------------------------------------------------------- /xboo/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /xboo/XbooLoad/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb generates a multiboot image 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # INCLUDES is a list of directories containing extra header files 17 | #--------------------------------------------------------------------------------- 18 | TARGET := XbooLoad_mb 19 | BUILD := build 20 | SOURCES := src data 21 | INCLUDES := 22 | 23 | #--------------------------------------------------------------------------------- 24 | # options for code generation 25 | #--------------------------------------------------------------------------------- 26 | ARCH := -mthumb -mthumb-interwork 27 | 28 | CFLAGS := -g -Wall -O3\ 29 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 30 | -fomit-frame-pointer\ 31 | -ffast-math \ 32 | $(ARCH) 33 | 34 | CFLAGS += $(INCLUDE) 35 | 36 | ASFLAGS := $(ARCH) 37 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 38 | 39 | #--------------------------------------------------------------------------------- 40 | # path to tools - this can be deleted if you set the path in windows 41 | #--------------------------------------------------------------------------------- 42 | export PATH := $(DEVKITARM)/bin:$(PATH) 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | 64 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) 65 | export PATH := $(DEVKITARM)/bin:$(PATH) 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # use CXX for linking C++ projects, CC for standard C 77 | #--------------------------------------------------------------------------------- 78 | ifeq ($(strip $(CPPFILES)),) 79 | #--------------------------------------------------------------------------------- 80 | export LD := $(CC) 81 | #--------------------------------------------------------------------------------- 82 | else 83 | #--------------------------------------------------------------------------------- 84 | export LD := $(CXX) 85 | #--------------------------------------------------------------------------------- 86 | endif 87 | #--------------------------------------------------------------------------------- 88 | 89 | export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 90 | 91 | #--------------------------------------------------------------------------------- 92 | # build a list of include paths 93 | #--------------------------------------------------------------------------------- 94 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 95 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 96 | -I$(CURDIR)/$(BUILD) 97 | 98 | #--------------------------------------------------------------------------------- 99 | # build a list of library paths 100 | #--------------------------------------------------------------------------------- 101 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 102 | 103 | .PHONY: $(BUILD) clean 104 | 105 | #--------------------------------------------------------------------------------- 106 | $(BUILD): 107 | @[ -d $@ ] || mkdir -p $@ 108 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 109 | 110 | #--------------------------------------------------------------------------------- 111 | clean: 112 | @echo clean ... 113 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 114 | 115 | #--------------------------------------------------------------------------------- 116 | else 117 | 118 | DEPENDS := $(OFILES:.o=.d) 119 | 120 | #--------------------------------------------------------------------------------- 121 | # main targets 122 | #--------------------------------------------------------------------------------- 123 | $(OUTPUT).gba : $(OUTPUT).elf 124 | 125 | $(OUTPUT).elf : $(OFILES) $(LIBGBA)/lib/libgba.a 126 | 127 | -include $(DEPENDS) 128 | 129 | #--------------------------------------------------------------------------------- 130 | endif 131 | #--------------------------------------------------------------------------------- 132 | -------------------------------------------------------------------------------- /xboo/XbooLoad/data/splash.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/gba-examples/435346171d820c0a6eb021b90e58032d88d30244/xboo/XbooLoad/data/splash.pcx -------------------------------------------------------------------------------- /xboo/XbooLoad/src/XbooLoad.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | // GBA sample code for devkitARM - http://www.devkit.tk 3 | // demonstrates use of Xboo Communicator file server 4 | //--------------------------------------------------------------------------------- 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include "pcx.h" 16 | 17 | //--------------------------------------------------------------------------------- 18 | // storage space for palette data 19 | //--------------------------------------------------------------------------------- 20 | u16 PaletteBuffer[256]; 21 | 22 | 23 | unsigned int frame = 0; 24 | 25 | //--------------------------------------------------------------------------------- 26 | void LoadPic(void) { 27 | //--------------------------------------------------------------------------------- 28 | int handle = dfopen("data\\splash.pcx","rb"); 29 | 30 | dfseek(handle,0,SEEK_END); 31 | u32 size = dftell(handle); 32 | dprintf("File size is %d\n",size); 33 | 34 | void *splash = malloc(size); 35 | 36 | dfseek(handle,0,SEEK_SET); 37 | 38 | dfread(splash, 1, size, handle); 39 | 40 | dfclose(handle); 41 | 42 | SetMode( MODE_4 | BG2_ON ); // screen mode & background to display 43 | 44 | DecodePCX(splash, (u16*)VRAM , PaletteBuffer); 45 | 46 | free(splash); 47 | 48 | FadeToPalette( PaletteBuffer, 60); 49 | 50 | } 51 | //--------------------------------------------------------------------------------- 52 | // Program entry point 53 | //--------------------------------------------------------------------------------- 54 | int main(void) { 55 | //--------------------------------------------------------------------------------- 56 | 57 | // Set up the interrupt handlers 58 | irqInit(); 59 | 60 | // Enable Vblank Interrupt to allow VblankIntrWait 61 | irqEnable(IRQ_VBLANK); 62 | 63 | // Allow Interrupts 64 | REG_IME = 1; 65 | 66 | xcomms_init(); 67 | 68 | LoadPic(); 69 | 70 | while (1) { 71 | 72 | VBlankIntrWait(); 73 | 74 | u16 keys = keysDown(); 75 | 76 | if (keys & KEY_A) { 77 | FadeToBlack(30); 78 | LoadPic(); 79 | } 80 | } 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /xboo/XbooLoad/src/pcx.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | #include "gba_types.h" 3 | #include "pcx.h" 4 | //--------------------------------------------------------------------------------- 5 | 6 | u8 Buf[240]; 7 | 8 | //--------------------------------------------------------------------------------- 9 | // Screen address must be 16 bit boundary for VRAM 10 | // Can be RAM buffer for later copying 11 | // Palette can be direct to hardware or RAM buffer for fading 12 | //--------------------------------------------------------------------------------- 13 | void DecodePCX(const u8 *PCXBuffer, u16 * ScreenAddr, u16* Palette) 14 | //--------------------------------------------------------------------------------- 15 | { 16 | int c,l,r,g,b; 17 | int i; 18 | 19 | u16 *Scrn = ScreenAddr; 20 | pcx_header *header = (pcx_header *)PCXBuffer; 21 | u8 *Data = (u8*)PCXBuffer + sizeof(pcx_header); 22 | 23 | int Width = (header->x2 - header->x1)+1; 24 | int Height = (header->y2 - header->y1)+1; 25 | 26 | Width = ((Width+1)>>1)<<1; // PCX width is always even regardless of image 27 | 28 | if (Width>240 || Height>160) return; // too big for VRAM :) 29 | 30 | 31 | u8 *wptr = Buf; 32 | 33 | int j,k; 34 | for (j=0; j>1;i++) 59 | { 60 | *(Scrn++)=*(ptr++); 61 | } 62 | wptr = Buf; 63 | } 64 | 65 | 66 | Data++; // skip palette ID byte 67 | u16 * GBA_Palette = Palette; 68 | u16 color; 69 | 70 | // convert RGB triplets to GBA format 5:5:5 71 | for (i=0; i<256; i++) 72 | { 73 | r = *(Data++); 74 | g = *(Data++); 75 | b = *(Data++); 76 | 77 | color = ((r>>3)|((g>>3)<<5)|((b>>3)<<10)); 78 | *(GBA_Palette++) = color; 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /xboo/XbooLoad/src/pcx.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | #ifndef _pcx_h_ 3 | #define _pcx_h_ 4 | //--------------------------------------------------------------------------------- 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | //--------------------------------------------------------------------------------- 11 | 12 | typedef struct{ 13 | char manufacturer; 14 | char version; 15 | char encoding; 16 | char bpp; 17 | short int x1,y1; 18 | short int x2,y2; 19 | short int hres; 20 | short int vres; 21 | char palette[48]; 22 | char reserved; 23 | char color_planes; 24 | short int BytesPerLine; 25 | short int PaletteType; 26 | char dummy[58]; 27 | }__attribute__ ((packed)) pcx_header; 28 | 29 | void DecodePCX(const u8 *PCXBuffer, u16 *ScreenAddr, u16 *Palette); 30 | 31 | //--------------------------------------------------------------------------------- 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | //--------------------------------------------------------------------------------- 36 | 37 | //--------------------------------------------------------------------------------- 38 | #endif // _pcx_h_ 39 | //--------------------------------------------------------------------------------- 40 | -------------------------------------------------------------------------------- /xboo/XbooPrint/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 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 | TARGET := XbooPrint_mb 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | INCLUDES := 24 | 25 | #--------------------------------------------------------------------------------- 26 | # options for code generation 27 | #--------------------------------------------------------------------------------- 28 | ARCH := -mthumb -mthumb-interwork 29 | 30 | CFLAGS := -g -std=gnu99 -Wall -O3\ 31 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 32 | -fomit-frame-pointer\ 33 | -ffast-math \ 34 | $(ARCH) 35 | 36 | CFLAGS += $(INCLUDE) 37 | 38 | ASFLAGS := $(ARCH) 39 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 40 | 41 | #--------------------------------------------------------------------------------- 42 | # path to tools - this can be deleted if you set the path to the toolchain in windows 43 | #--------------------------------------------------------------------------------- 44 | export PATH := $(DEVKITARM)/bin:$(PATH) 45 | 46 | #--------------------------------------------------------------------------------- 47 | # any extra libraries we wish to link with the project 48 | #--------------------------------------------------------------------------------- 49 | LIBS := -lgba 50 | 51 | #--------------------------------------------------------------------------------- 52 | # list of directories containing libraries, this must be the top level containing 53 | # include and lib 54 | #--------------------------------------------------------------------------------- 55 | LIBDIRS := $(LIBGBA) 56 | 57 | #--------------------------------------------------------------------------------- 58 | # no real need to edit anything past this point unless you need to add additional 59 | # rules for different file extensions 60 | #--------------------------------------------------------------------------------- 61 | ifneq ($(BUILD),$(notdir $(CURDIR))) 62 | #--------------------------------------------------------------------------------- 63 | 64 | export OUTPUT := $(CURDIR)/$(TARGET) 65 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 66 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 67 | 68 | export DEPSDIR := $(CURDIR)/$(BUILD) 69 | 70 | #--------------------------------------------------------------------------------- 71 | # automatically build a list of object files for our project 72 | #--------------------------------------------------------------------------------- 73 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 74 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 75 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 76 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 77 | 78 | #--------------------------------------------------------------------------------- 79 | # use CXX for linking C++ projects, CC for standard C 80 | #--------------------------------------------------------------------------------- 81 | ifeq ($(strip $(CPPFILES)),) 82 | #--------------------------------------------------------------------------------- 83 | export LD := $(CC) 84 | #--------------------------------------------------------------------------------- 85 | else 86 | #--------------------------------------------------------------------------------- 87 | export LD := $(CXX) 88 | #--------------------------------------------------------------------------------- 89 | endif 90 | #--------------------------------------------------------------------------------- 91 | 92 | export OFILES := $(addsuffix .o,$(BINFILES)) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 93 | 94 | #--------------------------------------------------------------------------------- 95 | # build a list of include paths 96 | #--------------------------------------------------------------------------------- 97 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 98 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 99 | -I$(CURDIR)/$(BUILD) 100 | 101 | #--------------------------------------------------------------------------------- 102 | # build a list of library paths 103 | #--------------------------------------------------------------------------------- 104 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 105 | 106 | .PHONY: $(BUILD) clean 107 | 108 | #--------------------------------------------------------------------------------- 109 | $(BUILD): 110 | @[ -d $@ ] || mkdir -p $@ 111 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 112 | 113 | all : $(BUILD) 114 | #--------------------------------------------------------------------------------- 115 | clean: 116 | @echo clean ... 117 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 118 | 119 | #--------------------------------------------------------------------------------- 120 | else 121 | 122 | DEPENDS := $(OFILES:.o=.d) 123 | 124 | #--------------------------------------------------------------------------------- 125 | # main targets 126 | #--------------------------------------------------------------------------------- 127 | $(OUTPUT).gba : $(OUTPUT).elf 128 | 129 | $(OUTPUT).elf : $(OFILES) 130 | 131 | %.o : %.pcx 132 | @echo $(notdir $<) 133 | @$(bin2o) 134 | 135 | -include $(DEPENDS) 136 | 137 | #--------------------------------------------------------------------------------- 138 | endif 139 | #--------------------------------------------------------------------------------- 140 | -------------------------------------------------------------------------------- /xboo/XbooPrint/source/xbooprint.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | // GBA sample code for devkitARM - http://www.devkitpro.org 3 | // xboo hello world 4 | // 5 | //--------------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include "gba_systemcalls.h" 9 | 10 | 11 | // for mbv2 use mbv2.h 12 | // for vba/mappy use mappy.h 13 | 14 | #include "xcomms.h" 15 | 16 | void u8loop(u8 *src, u8 *dst) { 17 | 18 | for ( u8 i = 0; i< 32; i++) { 19 | dst[i] = src[i]; 20 | } 21 | } 22 | 23 | void intloop(u8 *src, u8 *dst) { 24 | 25 | for ( int i = 0; i< 32; i++) { 26 | dst[i] = src[i]; 27 | } 28 | } 29 | 30 | //--------------------------------------------------------------------------------- 31 | // Program entry point 32 | //--------------------------------------------------------------------------------- 33 | int main(void) 34 | //--------------------------------------------------------------------------------- 35 | { 36 | xcomms_init(); 37 | 38 | dprintf("Hello World!\n"); 39 | 40 | while (1); 41 | } 42 | 43 | 44 | --------------------------------------------------------------------------------