-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit, corresponds to uxn/ea0584a2
- Loading branch information
0 parents
commit b1d7c49
Showing
15 changed files
with
1,380 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) Devine Lu Linvega | ||
Copyright (c) 2021 Adrian "asie" Siekierka | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | ||
endif | ||
|
||
export TARGET := $(shell basename $(CURDIR)) | ||
export TOPDIR := $(CURDIR) | ||
|
||
# specify a directory which contains the nitro filesystem | ||
# this is relative to the Makefile | ||
NITRO_FILES := | ||
|
||
# These set the information text in the nds file | ||
#GAME_TITLE := My Wonderful Homebrew | ||
#GAME_SUBTITLE1 := built with devkitARM | ||
#GAME_SUBTITLE2 := http://devitpro.org | ||
|
||
include $(DEVKITARM)/ds_rules | ||
|
||
.PHONY: checkarm7 checkarm9 clean | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
all: checkarm7 checkarm9 $(TARGET).nds | ||
|
||
#--------------------------------------------------------------------------------- | ||
checkarm7: | ||
$(MAKE) -C arm7 | ||
|
||
#--------------------------------------------------------------------------------- | ||
checkarm9: | ||
$(MAKE) -C arm9 | ||
|
||
#--------------------------------------------------------------------------------- | ||
$(TARGET).nds : $(NITRO_FILES) arm7/$(TARGET).elf arm9/$(TARGET).elf | ||
ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ | ||
-b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ | ||
$(_ADDFILES) | ||
|
||
#--------------------------------------------------------------------------------- | ||
arm7/$(TARGET).elf: | ||
$(MAKE) -C arm7 | ||
|
||
#--------------------------------------------------------------------------------- | ||
arm9/$(TARGET).elf: | ||
$(MAKE) -C arm9 | ||
|
||
#--------------------------------------------------------------------------------- | ||
clean: | ||
$(MAKE) -C arm9 clean | ||
$(MAKE) -C arm7 clean | ||
rm -f $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# uxnds | ||
|
||
Quick and simple port of the [uxn virtual machine](https://wiki.xxiivv.com/site/uxn.html) to the | ||
NDS console. | ||
|
||
By default, uxnds will run /uxn/boot.rom. | ||
|
||
Use the latest devkitARM toolchain from the devkitPro organization to compile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | ||
endif | ||
|
||
include $(DEVKITARM)/ds_rules | ||
|
||
#--------------------------------------------------------------------------------- | ||
# BUILD is the directory where object files & intermediate files will be placed | ||
# SOURCES is a list of directories containing source code | ||
# INCLUDES is a list of directories containing extra header files | ||
# DATA is a list of directories containing binary files | ||
# all directories are relative to this makefile | ||
#--------------------------------------------------------------------------------- | ||
BUILD := build | ||
SOURCES := source | ||
INCLUDES := include build | ||
DATA := | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
ARCH := -mthumb-interwork | ||
|
||
CFLAGS := -g -Wall -O2\ | ||
-mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ | ||
-ffast-math \ | ||
$(ARCH) | ||
|
||
CFLAGS += $(INCLUDE) -DARM7 | ||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti | ||
|
||
|
||
ASFLAGS := -g $(ARCH) | ||
LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,--nmagic -Wl,-Map,$(notdir $*).map | ||
|
||
LIBS := -lnds7 | ||
|
||
#--------------------------------------------------------------------------------- | ||
# list of directories containing libraries, this must be the top level containing | ||
# include and lib | ||
#--------------------------------------------------------------------------------- | ||
LIBDIRS := $(LIBNDS) | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
# no real need to edit anything past this point unless you need to add additional | ||
# rules for different file extensions | ||
#--------------------------------------------------------------------------------- | ||
ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
#--------------------------------------------------------------------------------- | ||
|
||
export ARM7ELF := $(CURDIR)/$(TARGET).elf | ||
export DEPSDIR := $(CURDIR)/$(BUILD) | ||
|
||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) | ||
|
||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | ||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) | ||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) | ||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) | ||
|
||
export OFILES := $(addsuffix .o,$(BINFILES)) \ | ||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) | ||
|
||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
-I$(CURDIR)/$(BUILD) | ||
|
||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# use CXX for linking C++ projects, CC for standard C | ||
#--------------------------------------------------------------------------------- | ||
ifeq ($(strip $(CPPFILES)),) | ||
#--------------------------------------------------------------------------------- | ||
export LD := $(CC) | ||
#--------------------------------------------------------------------------------- | ||
else | ||
#--------------------------------------------------------------------------------- | ||
export LD := $(CXX) | ||
#--------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------- | ||
|
||
.PHONY: $(BUILD) clean | ||
|
||
#--------------------------------------------------------------------------------- | ||
$(BUILD): | ||
@[ -d $@ ] || mkdir -p $@ | ||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
|
||
#--------------------------------------------------------------------------------- | ||
clean: | ||
@echo clean ... | ||
@rm -fr $(BUILD) *.elf | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
else | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
$(ARM7ELF) : $(OFILES) | ||
@echo linking $(notdir $@) | ||
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
# you need a rule like this for each extension you use as binary data | ||
#--------------------------------------------------------------------------------- | ||
%.bin.o : %.bin | ||
#--------------------------------------------------------------------------------- | ||
@echo $(notdir $<) | ||
@$(bin2o) | ||
|
||
-include $(DEPENDS) | ||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "../../include/uxn.h" | ||
#include "../../include/apu.h" | ||
|
||
/* | ||
Copyright (c) 2021 Devine Lu Linvega | ||
Copyright (c) 2021 Andrew Alderwick | ||
Copyright (c) 2021 Adrian "asie" Siekierka | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE. | ||
*/ | ||
|
||
static Sint32 | ||
envelope(Apu *c, Uint32 age) | ||
{ | ||
if(!c->r) return 0x0888; | ||
if(age < c->a) return 0x0888 * age / c->a; | ||
if(age < c->d) return 0x0444 * (2 * c->d - c->a - age) / (c->d - c->a); | ||
if(age < c->s) return 0x0444; | ||
if(age < c->r) return 0x0444 * (c->r - age) / (c->r - c->s); | ||
c->advance = 0; | ||
return 0x0000; | ||
} | ||
|
||
void | ||
apu_render(Apu *c, Sint16 *sample_left, Sint16 *sample_right, int samples) | ||
{ | ||
Sint32 s, i; | ||
if(!c->advance || !c->period) return; | ||
for(i = 0; i < samples; i++) { | ||
c->count += c->advance; | ||
c->i += c->count / c->period; | ||
c->count %= c->period; | ||
if(c->i >= c->len) { | ||
if(!c->repeat) { | ||
c->advance = 0; | ||
return; | ||
} | ||
c->i %= c->len; | ||
} | ||
s = (Sint8)(c->addr[c->i] + 0x80) * envelope(c, c->age++); | ||
*sample_left++ += s * c->volume[0] / 0x180; | ||
*sample_right++ += s * c->volume[1] / 0x180; | ||
} | ||
} |
Oops, something went wrong.