├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .github └── workflows │ └── build.yml ├── .gitignore ├── .prettierrc.json ├── .vscode └── settings.json ├── LICENSE ├── Makefile ├── README.md ├── assemblyscript ├── asconfig.json ├── assembly │ ├── apple.ts │ ├── index.ts │ ├── nds.ts │ ├── snake.ts │ └── tsconfig.json ├── package-lock.json └── package.json ├── compile.sh ├── icon.bmp ├── nitrofiles ├── backgrounds │ ├── bg.img │ ├── bg.map │ ├── bg.pal │ ├── wasm.img │ ├── wasm.map │ └── wasm.pal ├── credits.md ├── fonts │ ├── font.fnt │ └── font.pal ├── palettes │ ├── apple.pal │ └── segment.pal └── sprites │ └── tile.img ├── source ├── main.cpp ├── nds.cpp └── nds.h └── wasm-ds.jpg /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM devkitpro/devkitarm:20210726 2 | 3 | RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \ 4 | apt-get install -y nodejs xxd vim 5 | 6 | RUN mkdir -p /root/opt/ && \ 7 | wget -c https://github.com/moxon6/nds-dependencies/releases/download/0.1/wasm3-nds.tar.gz -O - | tar -xz -C /root/opt && \ 8 | wget -c https://github.com/moxon6/nds-dependencies/releases/download/0.1/nflib-nds.tar.gz -O - | tar -xz -C /root/opt 9 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NDS / Assemblyscript Dev Environment", 3 | "build": { 4 | "dockerfile": "Dockerfile", 5 | }, 6 | "runArgs": [ 7 | "--cap-add=SYS_PTRACE", 8 | "--security-opt", 9 | "seccomp=unconfined" 10 | ], 11 | "settings": {}, 12 | "extensions": [ 13 | "ms-vscode.cpptools" 14 | ] 15 | } -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build Snake AssemblyScript DS for use on nds 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - uses: actions/checkout@v2 10 | 11 | - uses: addnab/docker-run-action@v3 12 | with: 13 | image: devkitpro/devkitarm:20210726 14 | options: -v ${{ github.workspace }}:/workspace 15 | run: | 16 | set -e 17 | apt-get update 18 | curl -fsSL https://deb.nodesource.com/setup_14.x | bash - 19 | apt-get install -y nodejs xxd 20 | 21 | mkdir -p /root/opt/ 22 | wget -c https://github.com/moxon6/nds-dependencies/releases/download/0.1/wasm3-nds.tar.gz -O - | tar -xz -C /root/opt 23 | wget -c https://github.com/moxon6/nds-dependencies/releases/download/0.1/nflib-nds.tar.gz -O - | tar -xz -C /root/opt 24 | cd /workspace 25 | ( cd assemblyscript ; npm ci ; npm run build ) 26 | ( make clean; make ) 27 | 28 | - name: Upload snake_assemblyscript 29 | uses: svenstaro/upload-release-action@v2 30 | with: 31 | repo_token: ${{ secrets.GITHUB_TOKEN }} 32 | file: snake_assemblyscript.nds 33 | tag: snake-assemblyscript 34 | overwrite: true 35 | body: "snake_assemblyscript" 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | libwasm3 2 | nflib 3 | node_modules 4 | source/app.wasm.h 5 | build 6 | snake_assemblyscript.elf 7 | snake_assemblyscript.nds -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.defaultFormatter": "esbenp.prettier-vscode", 3 | "editor.formatOnSave": true 4 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. 2 | 3 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Makefile for NightFox's Lib Projects 3 | #--------------------------------------------------------------------------------- 4 | 5 | 6 | 7 | #--------------------------------------------------------------------------------- 8 | .SUFFIXES: 9 | #--------------------------------------------------------------------------------- 10 | ifeq ($(strip $(DEVKITARM)),) 11 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 12 | endif 13 | 14 | 15 | #--------------------------------------------------------------------------------- 16 | # This part substitutes this include: 17 | # include $(DEVKITARM)/ds_rules 18 | # This allows you to set ROM info and icon easy 19 | # Please update this block from DS_RULES file at every DEVKITARM update 20 | #--------------------------------------------------------------------------------- 21 | include $(DEVKITARM)/base_rules 22 | 23 | LIBNDS := $(DEVKITPRO)/libnds 24 | 25 | GAME_TITLE := Snake (Assemblyscript) 26 | GAME_SUBTITLE1 := moxon6 27 | GAME_ICON := $(CURDIR)/../icon.bmp 28 | 29 | _ADDFILES := -d $(NITRO_FILES) 30 | 31 | 32 | #--------------------------------------------------------------------------------- 33 | %.nds: %.arm9 34 | @ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES) 35 | @echo built ... $(notdir $@) 36 | 37 | #--------------------------------------------------------------------------------- 38 | %.nds: %.elf 39 | @ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES) 40 | @echo built ... $(notdir $@) 41 | 42 | #--------------------------------------------------------------------------------- 43 | %.arm9: %.elf 44 | @$(OBJCOPY) -O binary $< $@ 45 | @echo built ... $(notdir $@) 46 | 47 | #--------------------------------------------------------------------------------- 48 | %.arm7: %.elf 49 | @$(OBJCOPY) -O binary $< $@ 50 | @echo built ... $(notdir $@) 51 | 52 | #--------------------------------------------------------------------------------- 53 | %.elf: 54 | @echo linking $(notdir $@) 55 | @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ 56 | 57 | 58 | #--------------------------------------------------------------------------------- 59 | # TARGET is the name of the output 60 | # BUILD is the directory where object files & intermediate files will be placed 61 | # SOURCES is a list of directories containing source code 62 | # INCLUDES is a list of directories containing extra header files 63 | # DATA is a list of directories containing binary files embedded using bin2o 64 | # NITRODATA is the directory where files for NitroFS will be placed 65 | #--------------------------------------------------------------------------------- 66 | TARGET := snake_assemblyscript 67 | BUILD := build 68 | SOURCES := source 69 | INCLUDES := include 70 | DATA := data 71 | NITRODATA := nitrofiles 72 | 73 | #--------------------------------------------------------------------------------- 74 | # options for code generation 75 | #--------------------------------------------------------------------------------- 76 | ARCH := -mthumb -mthumb-interwork 77 | 78 | CFLAGS := -g -Wall -O2\ 79 | -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ 80 | -ffast-math \ 81 | $(ARCH) 82 | 83 | CFLAGS += $(INCLUDE) -DARM9 84 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 85 | 86 | ASFLAGS := -g $(ARCH) 87 | LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # any extra libraries we wish to link with the project 91 | #--------------------------------------------------------------------------------- 92 | LIBS := -lnflib -lfilesystem -lfat -lnds9 -lwasm3 93 | 94 | 95 | #--------------------------------------------------------------------------------- 96 | # list of directories containing libraries, this must be the top level containing 97 | # include and lib 98 | #--------------------------------------------------------------------------------- 99 | LIBDIRS := $(LIBNDS) /root/opt 100 | 101 | #--------------------------------------------------------------------------------- 102 | # no real need to edit anything past this point unless you need to add additional 103 | # rules for different file extensions 104 | #--------------------------------------------------------------------------------- 105 | ifneq ($(BUILD),$(notdir $(CURDIR))) 106 | #--------------------------------------------------------------------------------- 107 | 108 | export OUTPUT := $(CURDIR)/$(TARGET) 109 | 110 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 111 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 112 | 113 | export DEPSDIR := $(CURDIR)/$(BUILD) 114 | 115 | export NITRO_FILES := $(CURDIR)/$(NITRODATA) 116 | 117 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 118 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 119 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 120 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 121 | 122 | #--------------------------------------------------------------------------------- 123 | # use CXX for linking C++ projects, CC for standard C 124 | #--------------------------------------------------------------------------------- 125 | ifeq ($(strip $(CPPFILES)),) 126 | #--------------------------------------------------------------------------------- 127 | export LD := $(CC) 128 | #--------------------------------------------------------------------------------- 129 | else 130 | #--------------------------------------------------------------------------------- 131 | export LD := $(CXX) 132 | #--------------------------------------------------------------------------------- 133 | endif 134 | #--------------------------------------------------------------------------------- 135 | 136 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 137 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 138 | 139 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 140 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 141 | -I$(CURDIR)/$(BUILD) 142 | 143 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 144 | 145 | icons := $(wildcard *.bmp) 146 | 147 | ifneq (,$(findstring $(TARGET).bmp,$(icons))) 148 | export GAME_ICON := $(CURDIR)/$(TARGET).bmp 149 | else 150 | ifneq (,$(findstring icon.bmp,$(icons))) 151 | export GAME_ICON := $(CURDIR)/icon.bmp 152 | endif 153 | endif 154 | 155 | .PHONY: $(BUILD) clean 156 | 157 | #--------------------------------------------------------------------------------- 158 | $(BUILD): 159 | @[ -d $@ ] || mkdir -p $@ 160 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 161 | 162 | #--------------------------------------------------------------------------------- 163 | clean: 164 | @echo clean ... 165 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 166 | 167 | #--------------------------------------------------------------------------------- 168 | else 169 | 170 | #--------------------------------------------------------------------------------- 171 | # main targets 172 | #--------------------------------------------------------------------------------- 173 | $(OUTPUT).nds : $(OUTPUT).elf 174 | $(OUTPUT).elf : $(OFILES) 175 | 176 | #--------------------------------------------------------------------------------- 177 | %.bin.o : %.bin 178 | #--------------------------------------------------------------------------------- 179 | @echo $(notdir $<) 180 | $(bin2o) 181 | 182 | #--------------------------------------------------------------------------------------- 183 | endif 184 | #--------------------------------------------------------------------------------------- 185 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Snake-AssemblyScript-DS 2 | 3 | This is an AssemblyScript partial rewrite of [Snake-DS by PolyMars](https://github.com/PolyMarsDev/Snake-DS) for the Nintendo DS. 4 | 5 | ![logo](./wasm-ds.jpg) 6 | 7 | Some files in `./nitrofiles` are taken directly from [Snake-DS](https://github.com/PolyMarsDev/Snake-DS) and not created by me. 8 | 9 | Disclaimer: This project is for proof-of-concept only. Some game features were skipped for code brevity. 10 | -------------------------------------------------------------------------------- /assemblyscript/asconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": { 3 | "debug": { 4 | "binaryFile": "build/untouched.wasm", 5 | "textFile": "build/untouched.wat", 6 | "sourceMap": true, 7 | "debug": true 8 | }, 9 | "release": { 10 | "binaryFile": "build/optimized.wasm", 11 | "textFile": "build/optimized.wat", 12 | "sourceMap": true, 13 | "optimizeLevel": 3, 14 | "shrinkLevel": 0, 15 | "converge": false, 16 | "noAssert": false 17 | } 18 | }, 19 | "options": {} 20 | } -------------------------------------------------------------------------------- /assemblyscript/assembly/apple.ts: -------------------------------------------------------------------------------- 1 | import * as nds from "./nds"; 2 | 3 | export default class Apple { 4 | x: u8; 5 | y: u8; 6 | constructor() { 7 | this.shuffle(); 8 | } 9 | 10 | shuffle(): void { 11 | this.x = (nds.rand() % 32) * 8; 12 | this.y = (nds.rand() % 24) * 8; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /assemblyscript/assembly/index.ts: -------------------------------------------------------------------------------- 1 | import Apple from "./apple"; 2 | import * as nds from "./nds"; 3 | import { Snake, SnakeDirection } from "./snake"; 4 | 5 | const SCREEN_TOP: u8 = 0; 6 | 7 | function drawScore(score: u32): void { 8 | nds.NF_ClearTextLayer(SCREEN_TOP, 0); 9 | nds.NF_WriteText(SCREEN_TOP, 0, 2, 2, `SCORE: ${score}`); 10 | nds.NF_UpdateTextLayers(); 11 | } 12 | 13 | function getDirectionFromKeys(direction: SnakeDirection): SnakeDirection { 14 | if (nds.keysHeld() & nds.KEYS.LEFT && direction !== SnakeDirection.RIGHT) { 15 | return SnakeDirection.LEFT; 16 | } else if ( 17 | nds.keysHeld() & nds.KEYS.RIGHT && 18 | direction !== SnakeDirection.LEFT 19 | ) { 20 | return SnakeDirection.RIGHT; 21 | } else if ( 22 | nds.keysHeld() & nds.KEYS.UP && 23 | direction !== SnakeDirection.DOWN 24 | ) { 25 | return SnakeDirection.UP; 26 | } else if ( 27 | nds.keysHeld() & nds.KEYS.DOWN && 28 | direction !== SnakeDirection.UP 29 | ) { 30 | return SnakeDirection.DOWN; 31 | } else { 32 | return direction; 33 | } 34 | } 35 | 36 | function updateDisplay(): void { 37 | nds.NF_SpriteOamSet(SCREEN_TOP); 38 | nds.swiWaitForVBlank(); 39 | nds.oamUpdate(); 40 | } 41 | 42 | const shouldQuit = (): boolean => (nds.keysHeld() & nds.KEYS.SELECT) !== 0; 43 | 44 | export function start(): void { 45 | nds.consoleDemoInit(); 46 | nds.consoleClear(); 47 | nds.NF_Set2D(SCREEN_TOP, 0); 48 | nds.NF_SetRootFolder("NITROFS"); 49 | 50 | nds.NF_InitTiledBgBuffers(); 51 | nds.NF_InitTiledBgSys(SCREEN_TOP); 52 | 53 | nds.NF_LoadTiledBg("backgrounds/wasm", "wasm", 256, 256); 54 | nds.NF_CreateTiledBg(SCREEN_TOP, 3, "wasm"); 55 | 56 | nds.NF_InitSpriteBuffers(); 57 | nds.NF_InitSpriteSys(SCREEN_TOP); 58 | 59 | nds.NF_LoadSpriteGfx("sprites/tile", 0, 8, 8); 60 | 61 | const SEGMENT_ID: u8 = 0; 62 | const APPLE_ID: u8 = 1; 63 | 64 | nds.NF_LoadSpritePal("palettes/segment", 0); 65 | nds.NF_LoadSpritePal("palettes/apple", 1); 66 | 67 | nds.NF_VramSpriteGfx(SCREEN_TOP, 0, 0, true); 68 | nds.NF_VramSpritePal(SCREEN_TOP, 0, 0); 69 | nds.NF_VramSpritePal(SCREEN_TOP, 1, 1); 70 | 71 | nds.NF_InitTextSys(SCREEN_TOP); 72 | 73 | nds.NF_LoadTextFont("fonts/font", "default", 256, 256, 0); 74 | nds.NF_CreateTextLayer(SCREEN_TOP, 0, 0, "default"); 75 | 76 | let snake = new Snake(); 77 | let apple = new Apple(); 78 | 79 | let frame: u8 = 0; 80 | let score: u32 = 0; 81 | 82 | let done: bool = false; 83 | 84 | let direction: SnakeDirection = SnakeDirection.RIGHT; 85 | 86 | while (1) { 87 | if (!done) { 88 | frame += 1; 89 | nds.scanKeys(); 90 | 91 | nds.NF_CreateSprite(SCREEN_TOP, 0, 0, APPLE_ID, apple.x, apple.y); 92 | for (let i: i32 = 0; i < snake.segments.length; i++) { 93 | const seg = snake.segments[i]; 94 | nds.NF_CreateSprite(SCREEN_TOP, (i as u8) + 1, 0, SEGMENT_ID, seg.x, seg.y); 95 | } 96 | 97 | direction = getDirectionFromKeys(direction); 98 | 99 | if (shouldQuit()) { 100 | break; 101 | } 102 | 103 | if (frame === 5) { 104 | frame = 0; 105 | 106 | if (!snake.advanceHead(direction)) { 107 | done = true; 108 | nds.print("Game Over. \nPress start to continue.\n"); 109 | } 110 | 111 | if (snake.hasEatenApple(apple)) { 112 | apple.shuffle(); 113 | score++; 114 | } else { 115 | snake.removeTail(); 116 | } 117 | 118 | drawScore(score); 119 | } 120 | 121 | updateDisplay(); 122 | } else { 123 | nds.scanKeys(); 124 | if (nds.keysHeld() & nds.KEYS.START) { 125 | nds.NF_DeleteSprite(SCREEN_TOP, 0); 126 | for (let i: i32 = 0; i < snake.segments.length; i++) { 127 | nds.NF_DeleteSprite(SCREEN_TOP, (i + 1) as u8); 128 | } 129 | snake = new Snake(); 130 | apple = new Apple(); 131 | score = 0; 132 | frame = 0; 133 | done = false; 134 | direction = SnakeDirection.RIGHT; 135 | nds.consoleClear(); 136 | } 137 | updateDisplay(); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /assemblyscript/assembly/nds.ts: -------------------------------------------------------------------------------- 1 | export declare function swiWaitForVBlank(): void; 2 | 3 | const encode = (str: string): ArrayBuffer => String.UTF8.encode(str, true); 4 | 5 | declare function _print(ptr: ArrayBuffer): void; 6 | export function print(str: string): void { 7 | _print(encode(str)); 8 | } 9 | 10 | export declare function NF_Set2D(screen: u8, mode: u8): void; 11 | 12 | export declare function _NF_SetRootFolder(a: ArrayBuffer): void; 13 | export function NF_SetRootFolder(root: string): void { 14 | _NF_SetRootFolder(encode(root)); 15 | } 16 | 17 | export declare function NF_InitTiledBgBuffers(): void; 18 | export declare function NF_InitTiledBgSys(screen: u8): void; 19 | 20 | declare function _NF_LoadTiledBg( 21 | file: ArrayBuffer, 22 | name: ArrayBuffer, 23 | width: u32, 24 | height: u32 25 | ): void; 26 | export function NF_LoadTiledBg( 27 | file: string, 28 | name: string, 29 | width: u32, 30 | height: u32 31 | ): void { 32 | _NF_LoadTiledBg(encode(file), encode(name), width, height); 33 | } 34 | 35 | export declare function _NF_CreateTiledBg( 36 | screen: u32, 37 | layer: u32, 38 | name: ArrayBuffer 39 | ): void; 40 | export function NF_CreateTiledBg(screen: u32, layer: u32, name: string): void { 41 | _NF_CreateTiledBg(screen, layer, encode(name)); 42 | } 43 | 44 | export declare function NF_InitSpriteBuffers(): void; 45 | export declare function NF_InitSpriteSys(screen: u8): void; 46 | export declare function NF_InitTextSys(screen: u8): void; 47 | 48 | declare function _NF_LoadTextFont( 49 | file: ArrayBuffer, 50 | name: ArrayBuffer, 51 | width: u32, 52 | height: u32, 53 | rotation: u32 54 | ): void; 55 | export function NF_LoadTextFont( 56 | file: string, 57 | name: string, 58 | width: u32, 59 | height: u32, 60 | rotation: u32 61 | ): void { 62 | _NF_LoadTextFont(encode(file), encode(name), width, height, rotation); 63 | } 64 | 65 | declare function _NF_CreateTextLayer( 66 | screen: u8, 67 | layer: u8, 68 | rotation: u8, 69 | name: ArrayBuffer 70 | ): void; 71 | export function NF_CreateTextLayer( 72 | screen: u8, 73 | layer: u8, 74 | rotation: u8, 75 | name: string 76 | ): void { 77 | _NF_CreateTextLayer(screen, layer, rotation, encode(name)); 78 | } 79 | 80 | declare function _NF_WriteText( 81 | screen: u8, 82 | layer: u8, 83 | x: u16, 84 | y: u16, 85 | text: ArrayBuffer 86 | ): void; 87 | export function NF_WriteText( 88 | screen: u8, 89 | layer: u8, 90 | x: u16, 91 | y: u16, 92 | text: string 93 | ): void { 94 | _NF_WriteText(screen, layer, x, y, encode(text)); 95 | } 96 | 97 | export declare function NF_UpdateTextLayers(): void; 98 | 99 | export declare function consoleDemoInit(): void; 100 | export declare function consoleClear(): void; 101 | 102 | declare function _NF_LoadSpriteGfx( 103 | file: ArrayBuffer, 104 | id: u16, 105 | width: u16, 106 | height: u16 107 | ): void; 108 | export function NF_LoadSpriteGfx( 109 | file: string, 110 | id: u16, 111 | width: u16, 112 | height: u16 113 | ): void { 114 | _NF_LoadSpriteGfx(encode(file), id, width, height); 115 | } 116 | 117 | declare function _NF_LoadSpritePal(file: ArrayBuffer, id: u8): void; 118 | export function NF_LoadSpritePal(file: string, id: u8): void { 119 | _NF_LoadSpritePal(encode(file), id); 120 | } 121 | 122 | export declare function NF_VramSpriteGfx( 123 | screen: u8, 124 | vram: u16, 125 | ram: u16, 126 | keepframes: boolean 127 | ): void; 128 | export declare function NF_VramSpritePal(screen: u8, id: u8, slot: u8): void; 129 | 130 | export declare function NF_CreateSprite( 131 | screen: u8, 132 | id: u8, 133 | gfx: u16, 134 | pal: u8, 135 | x: i16, 136 | y: i16 137 | ): void; 138 | export declare function NF_SpriteOamSet(screen: u8): void; 139 | export declare function oamUpdate(): void; 140 | export declare function NF_ClearTextLayer(screen: u8, layer: u8): void; 141 | export declare function NF_DeleteSprite(screen: u8, layer: u8): void; 142 | export declare function keysHeld(): u32; 143 | export declare function scanKeys(): void; 144 | 145 | export enum KEYS { 146 | SELECT = 1 << 2, 147 | START = 1 << 3, 148 | RIGHT = 1 << 4, 149 | LEFT = 1 << 5, 150 | UP = 1 << 6, 151 | DOWN = 1 << 7, 152 | } 153 | 154 | export declare function rand(): u8; 155 | -------------------------------------------------------------------------------- /assemblyscript/assembly/snake.ts: -------------------------------------------------------------------------------- 1 | import Apple from "./apple"; 2 | 3 | export enum SnakeDirection { 4 | LEFT = 1, 5 | RIGHT = -1, 6 | UP = 2, 7 | DOWN = -2, 8 | } 9 | 10 | class Segment { 11 | x: u8; 12 | y: u8; 13 | constructor(x: u8, y: u8) { 14 | this.x = x; 15 | this.y = y; 16 | } 17 | } 18 | 19 | const nextSegment = (segment: Segment, direction: SnakeDirection): Segment => { 20 | switch (direction) { 21 | case SnakeDirection.LEFT: 22 | return new Segment(segment.x - 8, segment.y); 23 | case SnakeDirection.RIGHT: 24 | return new Segment(segment.x + 8, segment.y); 25 | case SnakeDirection.UP: 26 | return new Segment(segment.x, segment.y > 0 ? segment.y - 8 : 184); 27 | case SnakeDirection.DOWN: 28 | return new Segment(segment.x, segment.y < 184 ? segment.y + 8 : 0); 29 | default: 30 | return segment; 31 | } 32 | }; 33 | 34 | export class Snake { 35 | segments: Segment[]; 36 | direction: SnakeDirection; 37 | 38 | constructor() { 39 | this.segments = [new Segment(8, 0), new Segment(0, 0)]; 40 | this.direction = SnakeDirection.RIGHT; 41 | } 42 | 43 | advanceHead(direction: SnakeDirection): boolean { 44 | if (direction !== this.direction * -1) { 45 | this.direction = direction; 46 | } 47 | this.segments.unshift(nextSegment(this.segments[0], this.direction)); 48 | return this.checkCollision(); 49 | } 50 | 51 | hasEatenApple(apple: Apple): boolean { 52 | return this.segments[0].x === apple.x && this.segments[0].y === apple.y; 53 | } 54 | 55 | removeTail(): void { 56 | this.segments.pop(); 57 | } 58 | 59 | private checkCollision(): boolean { 60 | const head = this.segments[0]; 61 | for (let i: i32 = 1; i < this.segments.length; i++) { 62 | const seg = this.segments[i]; 63 | if (head.x === seg.x && head.y === seg.y) { 64 | return false; 65 | } 66 | } 67 | return true; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /assemblyscript/assembly/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "assemblyscript/std/assembly.json", 3 | "include": [ 4 | "./**/*.ts" 5 | ] 6 | } -------------------------------------------------------------------------------- /assemblyscript/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "helloworld-assemblyscript", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "assemblyscript": { 8 | "version": "0.19.11", 9 | "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.11.tgz", 10 | "integrity": "sha512-Z121H4rHkrHhOswQQ6Nvv0y3UVqBm3Z6ZSYKF7dNDoR608Axd/gJPkPLGI6fVnqZT+fH6s3/erx4P2vUseMa7w==", 11 | "dev": true, 12 | "requires": { 13 | "binaryen": "101.0.0-nightly.20210723", 14 | "long": "^4.0.0" 15 | } 16 | }, 17 | "binaryen": { 18 | "version": "101.0.0-nightly.20210723", 19 | "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz", 20 | "integrity": "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==", 21 | "dev": true 22 | }, 23 | "long": { 24 | "version": "4.0.0", 25 | "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", 26 | "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", 27 | "dev": true 28 | }, 29 | "prettier": { 30 | "version": "2.3.2", 31 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", 32 | "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", 33 | "dev": true 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /assemblyscript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "helloworld-assemblyscript", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node tests", 8 | "build": "npm run asbuild:optimized && xxd -i build/optimized.wasm > ../source/app.wasm.h", 9 | "asbuild:untouched": "asc assembly/index.ts --target debug", 10 | "asbuild:optimized": "asc assembly/index.ts -O3z --runtime stub --noAssert --use abort=", 11 | "asbuild": "npm run asbuild:untouched && npm run asbuild:optimized" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "devDependencies": { 16 | "assemblyscript": "^0.19.11", 17 | "prettier": "^2.3.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | ( cd assemblyscript ; npm run build ) 2 | ( make clean; make ) -------------------------------------------------------------------------------- /icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/icon.bmp -------------------------------------------------------------------------------- /nitrofiles/backgrounds/bg.img: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /nitrofiles/backgrounds/bg.map: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /nitrofiles/backgrounds/bg.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/nitrofiles/backgrounds/bg.pal -------------------------------------------------------------------------------- /nitrofiles/backgrounds/wasm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/nitrofiles/backgrounds/wasm.img -------------------------------------------------------------------------------- /nitrofiles/backgrounds/wasm.map: -------------------------------------------------------------------------------- 1 |   2 |           !"#$$%&'()*+,-./012345%67777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 -------------------------------------------------------------------------------- /nitrofiles/backgrounds/wasm.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/nitrofiles/backgrounds/wasm.pal -------------------------------------------------------------------------------- /nitrofiles/credits.md: -------------------------------------------------------------------------------- 1 | The contents of palletes,sprites,fonts are taken from https://github.com/PolyMarsDev/Snake-DS 2 | -------------------------------------------------------------------------------- /nitrofiles/fonts/font.fnt: -------------------------------------------------------------------------------- 1 | GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG -------------------------------------------------------------------------------- /nitrofiles/fonts/font.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/nitrofiles/fonts/font.pal -------------------------------------------------------------------------------- /nitrofiles/palettes/apple.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/nitrofiles/palettes/apple.pal -------------------------------------------------------------------------------- /nitrofiles/palettes/segment.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/nitrofiles/palettes/segment.pal -------------------------------------------------------------------------------- /nitrofiles/sprites/tile.img: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "wasm3.h" 11 | #include "m3_env.h" 12 | #include "app.wasm.h" 13 | #include "nds.h" 14 | 15 | int main(void) { 16 | IM3Environment env = m3_NewEnvironment (); 17 | IM3Runtime runtime = m3_NewRuntime (env, 1024, NULL); 18 | IM3Module module; 19 | m3_ParseModule (env, &module, build_optimized_wasm, build_optimized_wasm_len); 20 | m3_LoadModule (runtime, module); 21 | LinkNDSFunctions(module); 22 | IM3Function f; 23 | m3_FindFunction (&f, runtime, "start"); 24 | m3_CallV (f, 10); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /source/nds.cpp: -------------------------------------------------------------------------------- 1 | #include "m3_env.h" 2 | #include 3 | #include 4 | 5 | m3ApiRawFunction(m3_swiWaitForVBlank) { 6 | swiWaitForVBlank(); 7 | m3ApiSuccess(); 8 | } 9 | 10 | m3ApiRawFunction(_print) 11 | { 12 | m3ApiGetArgMem (const char *, str) 13 | iprintf(str); 14 | m3ApiSuccess(); 15 | } 16 | 17 | m3ApiRawFunction(m3_NF_Set2D) { 18 | m3ApiGetArg (uint8_t, screen) 19 | m3ApiGetArg (uint8_t, mode) 20 | NF_Set2D(screen, mode); 21 | m3ApiSuccess(); 22 | } 23 | 24 | m3ApiRawFunction(m3_NF_SetRootFolder) { 25 | m3ApiGetArgMem (const char *, root) 26 | NF_SetRootFolder( root); 27 | m3ApiSuccess(); 28 | } 29 | 30 | m3ApiRawFunction(m3_NF_InitTiledBgBuffers) { 31 | NF_InitTiledBgBuffers(); 32 | m3ApiSuccess(); 33 | } 34 | 35 | m3ApiRawFunction(m3_NF_InitTiledBgSys) { 36 | m3ApiGetArg (uint8_t, screen) 37 | NF_InitTiledBgSys(screen); 38 | m3ApiSuccess(); 39 | } 40 | 41 | m3ApiRawFunction(m3_NF_LoadTiledBg) { 42 | m3ApiGetArgMem (const char *, path) 43 | m3ApiGetArgMem (const char *, name) 44 | m3ApiGetArg (uint32_t, width) 45 | m3ApiGetArg (uint32_t, height) 46 | NF_LoadTiledBg(path, name, width, height); 47 | m3ApiSuccess(); 48 | } 49 | 50 | m3ApiRawFunction(m3_NF_CreateTiledBg) { 51 | m3ApiGetArg (uint32_t, screen) 52 | m3ApiGetArg (uint32_t, layer) 53 | m3ApiGetArgMem (const char *, name) 54 | NF_CreateTiledBg(screen, layer, name); 55 | m3ApiSuccess(); 56 | } 57 | 58 | m3ApiRawFunction(m3_NF_InitSpriteBuffers) { 59 | NF_InitSpriteBuffers(); 60 | m3ApiSuccess(); 61 | } 62 | 63 | m3ApiRawFunction(m3_NF_InitSpriteSys) { 64 | m3ApiGetArg (uint8_t, screen) 65 | NF_InitSpriteSys(screen); 66 | m3ApiSuccess(); 67 | } 68 | 69 | m3ApiRawFunction(m3_NF_InitTextSys) { 70 | m3ApiGetArg (uint8_t, screen) 71 | NF_InitTextSys(screen); 72 | m3ApiSuccess(); 73 | } 74 | 75 | m3ApiRawFunction(m3_NF_LoadTextFont) { 76 | m3ApiGetArgMem (const char *, file) 77 | m3ApiGetArgMem (const char *, name) 78 | m3ApiGetArg (uint32_t, width) 79 | m3ApiGetArg (uint32_t, height) 80 | m3ApiGetArg (uint32_t, rotation) 81 | NF_LoadTextFont(file, name, width, height, rotation); 82 | m3ApiSuccess(); 83 | } 84 | 85 | m3ApiRawFunction(m3_NF_CreateTextLayer) { 86 | m3ApiGetArg (uint8_t, screen) 87 | m3ApiGetArg (uint8_t, layer) 88 | m3ApiGetArg (uint8_t, rotation) 89 | m3ApiGetArgMem (const char *, name) 90 | NF_CreateTextLayer(screen, layer, rotation, name); 91 | m3ApiSuccess(); 92 | } 93 | 94 | m3ApiRawFunction(m3_NF_WriteText) { 95 | m3ApiGetArg (uint8_t, screen) 96 | m3ApiGetArg (uint8_t, layer) 97 | m3ApiGetArg (uint16_t, x) 98 | m3ApiGetArg (uint16_t, y) 99 | m3ApiGetArgMem (const char *, text) 100 | NF_WriteText(screen, layer, x, y, text); 101 | m3ApiSuccess(); 102 | } 103 | 104 | m3ApiRawFunction(m3_NF_UpdateTextLayers) { 105 | NF_UpdateTextLayers(); 106 | m3ApiSuccess(); 107 | } 108 | 109 | m3ApiRawFunction(m3_consoleDemoInit) { 110 | consoleDemoInit(); 111 | m3ApiSuccess(); 112 | }; 113 | 114 | m3ApiRawFunction(m3_consoleClear) { 115 | consoleClear(); 116 | m3ApiSuccess(); 117 | }; 118 | 119 | m3ApiRawFunction(m3_NF_LoadSpriteGfx) { 120 | m3ApiGetArgMem (const char *, file) 121 | m3ApiGetArg (uint16_t, id) 122 | m3ApiGetArg (uint16_t, width) 123 | m3ApiGetArg (uint16_t, height) 124 | NF_LoadSpriteGfx(file, id, width, height); 125 | m3ApiSuccess(); 126 | }; 127 | 128 | m3ApiRawFunction(m3_NF_LoadSpritePal) { 129 | m3ApiGetArgMem (const char *, file) 130 | m3ApiGetArg (uint8_t, id) 131 | NF_LoadSpritePal(file, id); 132 | m3ApiSuccess(); 133 | }; 134 | 135 | m3ApiRawFunction(m3_NF_VramSpriteGfx) { 136 | m3ApiGetArg (uint8_t, screen) 137 | m3ApiGetArg (uint16_t, ram) 138 | m3ApiGetArg (uint16_t, vram) 139 | m3ApiGetArg (bool, keepframes) 140 | NF_VramSpriteGfx(screen, ram, vram, keepframes); 141 | m3ApiSuccess(); 142 | }; 143 | 144 | m3ApiRawFunction(m3_NF_VramSpritePal) { 145 | m3ApiGetArg (uint8_t, screen) 146 | m3ApiGetArg (uint8_t, id) 147 | m3ApiGetArg (uint8_t, slot) 148 | NF_VramSpritePal(screen, id, slot); 149 | m3ApiSuccess(); 150 | }; 151 | 152 | 153 | m3ApiRawFunction(m3_NF_CreateSprite) { 154 | m3ApiGetArg (uint8_t, screen) 155 | m3ApiGetArg (uint8_t, id) 156 | m3ApiGetArg (uint8_t, gfx) 157 | m3ApiGetArg (uint8_t, pal) 158 | m3ApiGetArg (uint8_t, x) 159 | m3ApiGetArg (uint8_t, y) 160 | NF_CreateSprite(screen, id, gfx, pal, x, y); 161 | m3ApiSuccess(); 162 | }; 163 | 164 | m3ApiRawFunction(m3_NF_SpriteOamSet) { 165 | m3ApiGetArg (uint8_t, screen) 166 | NF_SpriteOamSet(screen); 167 | m3ApiSuccess(); 168 | }; 169 | 170 | m3ApiRawFunction(m3_oamUpdate) { 171 | oamUpdate(&oamMain); 172 | m3ApiSuccess(); 173 | } 174 | 175 | m3ApiRawFunction(m3_NF_ClearTextLayer) { 176 | m3ApiGetArg (uint8_t, screen) 177 | m3ApiGetArg (uint8_t, layer) 178 | NF_ClearTextLayer(screen, layer); 179 | m3ApiSuccess(); 180 | }; 181 | 182 | m3ApiRawFunction(m3_NF_DeleteSprite) { 183 | m3ApiGetArg (uint8_t, screen) 184 | m3ApiGetArg (uint8_t, layer) 185 | NF_DeleteSprite(screen, layer); 186 | m3ApiSuccess(); 187 | }; 188 | 189 | m3ApiRawFunction(m3_keysHeld) { 190 | m3ApiReturnType (uint32_t) 191 | m3ApiReturn(keysHeld()); 192 | }; 193 | 194 | m3ApiRawFunction(m3_rand) { 195 | m3ApiReturnType (uint32_t) 196 | m3ApiReturn(rand()); 197 | }; 198 | 199 | m3ApiRawFunction(m3_scanKeys) { 200 | scanKeys(); 201 | m3ApiSuccess(); 202 | }; 203 | 204 | void LinkNDSFunctions(IM3Module module) { 205 | m3_LinkRawFunction (module, "nds", "swiWaitForVBlank", "v()", &m3_swiWaitForVBlank); 206 | m3_LinkRawFunction (module, "nds", "_print", "v(i)", &_print); 207 | m3_LinkRawFunction (module, "nds", "NF_Set2D", "v(ii)", &m3_NF_Set2D); 208 | m3_LinkRawFunction (module, "nds", "_NF_SetRootFolder", "v(i)", &m3_NF_SetRootFolder); 209 | m3_LinkRawFunction (module, "nds", "NF_InitTiledBgBuffers", "v()", &m3_NF_InitTiledBgBuffers); 210 | m3_LinkRawFunction (module, "nds", "NF_InitTiledBgSys", "v(i)", &m3_NF_InitTiledBgSys); 211 | m3_LinkRawFunction (module, "nds", "_NF_LoadTiledBg", "v(iiii)", &m3_NF_LoadTiledBg); 212 | m3_LinkRawFunction (module, "nds", "_NF_CreateTiledBg", "v(iii)", &m3_NF_CreateTiledBg); 213 | m3_LinkRawFunction (module, "nds", "NF_InitSpriteBuffers", "v()", &m3_NF_InitSpriteBuffers); 214 | m3_LinkRawFunction (module, "nds", "NF_InitSpriteSys", "v(i)", &m3_NF_InitSpriteSys); 215 | m3_LinkRawFunction (module, "nds", "NF_InitTextSys", "v(i)", &m3_NF_InitTextSys); 216 | m3_LinkRawFunction (module, "nds", "_NF_LoadTextFont", "v(iiiii)", &m3_NF_LoadTextFont); 217 | m3_LinkRawFunction (module, "nds", "_NF_CreateTextLayer", "v(iiii)", &m3_NF_CreateTextLayer); 218 | m3_LinkRawFunction (module, "nds", "_NF_WriteText", "v(iiiii)", &m3_NF_WriteText); 219 | m3_LinkRawFunction (module, "nds", "NF_UpdateTextLayers", "v()", &m3_NF_UpdateTextLayers); 220 | m3_LinkRawFunction (module, "nds", "consoleDemoInit", "v()", &m3_consoleDemoInit); 221 | m3_LinkRawFunction (module, "nds", "consoleClear", "v()", &m3_consoleClear); 222 | m3_LinkRawFunction (module, "nds", "_NF_LoadSpriteGfx", "v(iiii)", &m3_NF_LoadSpriteGfx); 223 | m3_LinkRawFunction (module, "nds", "_NF_LoadSpritePal", "v(ii)", &m3_NF_LoadSpritePal); 224 | m3_LinkRawFunction (module, "nds", "NF_VramSpriteGfx", "v(iiii)", &m3_NF_VramSpriteGfx); 225 | m3_LinkRawFunction (module, "nds", "NF_VramSpritePal", "v(iii)", &m3_NF_VramSpritePal); 226 | m3_LinkRawFunction (module, "nds", "NF_CreateSprite", "v(iiiiii)", &m3_NF_CreateSprite); 227 | m3_LinkRawFunction (module, "nds", "NF_SpriteOamSet", "v(i)", &m3_NF_SpriteOamSet); 228 | m3_LinkRawFunction (module, "nds", "oamUpdate", "v()", &m3_oamUpdate); 229 | m3_LinkRawFunction (module, "nds", "NF_ClearTextLayer", "v(ii)", &m3_NF_ClearTextLayer); 230 | m3_LinkRawFunction (module, "nds", "NF_DeleteSprite", "v(ii)", &m3_NF_DeleteSprite); 231 | m3_LinkRawFunction (module, "nds", "keysHeld", "i()", &m3_keysHeld); 232 | m3_LinkRawFunction (module, "nds", "scanKeys", "v()", &m3_scanKeys); 233 | m3_LinkRawFunction (module, "nds", "rand", "i()", &m3_rand); 234 | } -------------------------------------------------------------------------------- /source/nds.h: -------------------------------------------------------------------------------- 1 | void LinkNDSFunctions(IM3Module module); -------------------------------------------------------------------------------- /wasm-ds.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxon6/snake-assemblyscript-ds/c3df4b2489e29ab0db52dfec9f6c4bc0e67a9f2a/wasm-ds.jpg --------------------------------------------------------------------------------