Skip to content

Commit

Permalink
v0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Jul 8, 2024
1 parent ebc71ed commit 1643cb4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 82 deletions.
4 changes: 2 additions & 2 deletions Makefile.3ds
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ INCLUDES := include source
GRAPHICS := assets/3ds
ROMFS := romfs/3ds
GFXBUILD := $(ROMFS)
APP_TITLE := uxnds v0.5.0
APP_TITLE := uxnds v0.5.1
ifeq ($(DEBUG),true)
APP_DESCRIPTION := tiny virtual machine (debug)
else
Expand Down Expand Up @@ -80,7 +80,7 @@ CFLAGS += -DDEBUG -DDEBUG_PROFILE -DCPU_ERROR_CHECKING
CXXFLAGS += -DDEBUG -DDEBUG_PROFILE -DCPU_ERROR_CHECKING
endif

ASFLAGS := -g $(ARCH)
ASFLAGS := -g $(ARCH) -D__3DS__
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lcitro2d -lcitro3d -lctru -lm
Expand Down
4 changes: 2 additions & 2 deletions Makefile.blocksds
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

NAME := uxnds

GAME_TITLE := uxnds v0.5.0
GAME_TITLE := uxnds v0.5.1
GAME_SUBTITLE := tiny virtual machine
GAME_AUTHOR := 06/07/2024
GAME_AUTHOR := 08/07/2024
GAME_ICON := misc/uxn32.png

#NAME := donsol
Expand Down
28 changes: 24 additions & 4 deletions source/uxngba-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <nds.h>
#else
#include <3ds.h>
#define DTCM_DATA
#define DTCM_BSS
#endif

Expand All @@ -33,12 +34,14 @@ extern void uxn_eval_asm(Uint32 pc);

DTCM_BSS u8 wst[256];
DTCM_BSS u8 rst[256];

#ifdef __3DS__
uintptr_t wst_ptr = (uintptr_t) wst;
uintptr_t rst_ptr = (uintptr_t) rst;
#else
extern uintptr_t wst_ptr;
extern uintptr_t rst_ptr;

extern uxn_deo_t deo_map[16];
extern uxn_dei_t dei_map[16];
DTCM_BSS u8 device_data[256];
#endif

// JSI and similar depend on a 64K alignment (!)
__attribute__((aligned(65536)))
Expand Down Expand Up @@ -72,6 +75,23 @@ uxn_uidiv(unsigned int num, unsigned int den) {
return den ? __aeabi_uidiv(num, den) : 0;
}

DTCM_DATA
uxn_deo_t deo_map[16] = {
deo_stub, deo_stub, deo_stub, deo_stub,
deo_stub, deo_stub, deo_stub, deo_stub,
deo_stub, deo_stub, deo_stub, deo_stub,
deo_stub, deo_stub, deo_stub, deo_stub
};

DTCM_DATA
uxn_dei_t dei_map[16] = {
dei_stub, dei_stub, dei_stub, dei_stub,
dei_stub, dei_stub, dei_stub, dei_stub,
dei_stub, dei_stub, dei_stub, dei_stub,
dei_stub, dei_stub, dei_stub, dei_stub
};
DTCM_BSS u8 device_data[256];

int
resetuxn(void)
{
Expand Down
107 changes: 33 additions & 74 deletions source/uxngba.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@
@ Core variables
@

#ifdef __3DS__
.macro restore_wst_rst_r1_r2 a
ldr \a, =wst_ptr
ldr r1, [\a]
ldr \a, =rst_ptr
ldr r2, [\a]
.endm
#else
.section .itcm, "ax", %progbits

.macro restore_wst_rst_r1_r2 a
ldr r1, wst_ptr
ldr r2, rst_ptr
.endm

.global wst_ptr
wst_ptr: .word wst
.global rst_ptr
rst_ptr: .word rst
#endif

@ UXN evaluation function.
@
Expand All @@ -25,8 +39,7 @@ uxn_eval_asm:

@ Initialization.
push {r4-r7}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
ldr r7, =uxn_ram
add r0, r0, r7

Expand All @@ -40,9 +53,9 @@ uxn_decode:

uxn_ret:
@ Update stack pointers and return.
adr r0, wst_ptr
ldr r0, =wst_ptr
str r1, [r0]
adr r0, rst_ptr
ldr r0, =rst_ptr
str r2, [r0]
pop {r4-r7}
bx lr
Expand Down Expand Up @@ -463,8 +476,7 @@ dei:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
wpush8 r0
ldmfd sp!, {r0, r7, lr}
b uxn_decode
Expand Down Expand Up @@ -500,8 +512,7 @@ dei2:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
wpush8 r5
wpush8 r0
ldmfd sp!, {r0, r7, lr}
Expand Down Expand Up @@ -540,8 +551,7 @@ deo:

@ Restore saved variables.
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deo2:
Expand Down Expand Up @@ -582,8 +592,7 @@ deo2:

@ Restore saved variables.
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deir:
Expand All @@ -607,8 +616,7 @@ deir:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
rpush8 r0
ldmfd sp!, {r0, r7, lr}
b uxn_decode
Expand Down Expand Up @@ -644,8 +652,7 @@ dei2r:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
rpush8 r5
rpush8 r0
ldmfd sp!, {r0, r7, lr}
Expand Down Expand Up @@ -684,8 +691,7 @@ deor:

@ Restore saved variables.
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deo2r:
Expand Down Expand Up @@ -726,8 +732,7 @@ deo2r:

@ Restore saved variables.
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deik:
Expand All @@ -751,8 +756,7 @@ deik:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
wpush8 r0
ldmfd sp!, {r0, r7, lr}
b uxn_decode
Expand Down Expand Up @@ -788,8 +792,7 @@ dei2k:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
wpush8 r5
wpush8 r0
ldmfd sp!, {r0, r7, lr}
Expand Down Expand Up @@ -819,8 +822,7 @@ deok:
bx r6
#endif
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deo2k:
Expand Down Expand Up @@ -852,8 +854,7 @@ deo2k:
bx r6
#endif
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deikr:
Expand All @@ -877,8 +878,7 @@ deikr:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
rpush8 r0
ldmfd sp!, {r0, r7, lr}
b uxn_decode
Expand Down Expand Up @@ -914,8 +914,7 @@ dei2kr:
mov lr, pc
bx r6
#endif
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
rpush8 r5
rpush8 r0
ldmfd sp!, {r0, r7, lr}
Expand Down Expand Up @@ -945,8 +944,7 @@ deokr:
bx r6
#endif
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

deo2kr:
Expand Down Expand Up @@ -978,51 +976,12 @@ deo2kr:
bx r6
#endif
ldmfd sp!, {r0, r7, lr}
ldr r1, wst_ptr
ldr r2, rst_ptr
restore_wst_rst_r1_r2 r6
b uxn_decode

.ltorg
.align 2

.global dei_map
dei_map:
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub
.word dei_stub

.global deo_map
deo_map:
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub
.word deo_stub

brk:
b uxn_ret

Expand Down

0 comments on commit 1643cb4

Please sign in to comment.