testing and unfinished changes to main

This commit is contained in:
franchiopin 2024-05-20 23:42:37 +01:00
parent cc6dd3bc0b
commit edda7eefb6
26 changed files with 126 additions and 44 deletions

View File

@ -1,16 +1,24 @@
{ {
"configurations": [ "configurations": [
{ {
"name": "Linux", "name": "nspire",
"includePath": [ "includePath": [
"${workspaceFolder}/**", "/home/franchioping/NSpire/Nespire/**",
"/home/franchioping/NSpire/Ndless/ndless-sdk/include/*" "/home/franchioping/NSpire/Ndless/ndless-sdk/include/*"
], ],
"defines": [], "defines": [],
"compilerPath": "/usr/bin/clang", "compilerPath": "/home/franchioping/NSpire/Ndless/ndless-sdk/bin/nspire-gcc",
"cStandard": "c17", "cStandard": "c17",
"cppStandard": "c++17", "cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm" "compilerPathInCppPropertiesJson": "/home/franchioping/NSpire/Ndless/ndless-sdk/bin/nspire-gcc",
"mergeConfigurations": false,
"browse": {
"path": [
"/home/franchioping/NSpire/Ndless/ndless-sdk/include/*",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
} }
], ],
"version": 4 "version": 4

View File

@ -1,3 +1,7 @@
{ {
"makefile.makefilePath": "" "makefile.makefilePath": "",
"files.associations": {
"platform-nspire.h": "c",
"*.inc": "c"
}
} }

1
source/.buildver Normal file
View File

@ -0,0 +1 @@
4

View File

@ -1,22 +1,60 @@
PREFIX=nspire- DEBUG = FALSE
all: nes_emu.tns clean_p BLD_FILE ?= .buildver
@echo DONE
nes_emu.tns : nespire.elf # Initiate BLD_FILE if not exists
genzehn --input $< --output $@ --name "nes_emu" buildver_create := $(shell if ! test -f $(BLD_FILE); then echo 0 > $(BLD_FILE); fi)
make-prg $@ ./nes_emu.prg.tns
nespire.elf : main.o cpu.o debug.o memory.o ppu.o rom.o menu.o # Prepare callable function. This function updates BLD_FILE
$(PREFIX)ld main.o cpu.o debug.o memory.o ppu.o rom.o menu.o -o $@ buildver = $(shell echo $$(($$(cat $(BLD_FILE)) + 1)) > $(BLD_FILE))
%.o : %.S VER = buildver
$(PREFIX)gcc -Wall -W -marm -Os -c $< -o $@
GCC = nspire-gcc
AS = nspire-as
GXX = nspire-g++
LD = nspire-ld
GENZEHN = genzehn
EXE = nespire$(shell cat $(BLD_FILE))
clean_p: GCCFLAGS = -Wall -W -marm
@rm -f *.o nespire.elf LDFLAGS =
ZEHNFLAGS = --name "$(EXE)"
ifeq ($(DEBUG),FALSE)
GCCFLAGS += -Os
else
GCCFLAGS += -O0 -g
endif
OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c))
OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp))
OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S))
DISTDIR = builds
clean: clean_p all:$(DISTDIR)/$(EXE).tns
@rm -f nes_emu.tns nes_emu.prg.tns
%.o: %.c
$(GCC) $(GCCFLAGS) -c $< -o $@
%.o: %.cpp
$(GXX) $(GCCFLAGS) -c $< -o $@
%.o: %.S
$(AS) -c $< -o $@
$(DISTDIR)/$(EXE).elf: $(OBJS)
mkdir -p $(DISTDIR)
$(LD) $^ -o $@ $(LDFLAGS)
$(DISTDIR)/$(EXE).tns: $(DISTDIR)/$(EXE).elf
$(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS)
$(call buildver)
make-prg $@.zehn $@
rm $@.zehn
clean:
rm -f $(OBJS)

BIN
source/builds/nespire2.elf Executable file

Binary file not shown.

BIN
source/builds/nespire_mod_0.elf Executable file

Binary file not shown.

Binary file not shown.

BIN
source/builds/nespire_mod_1.elf Executable file

Binary file not shown.

Binary file not shown.

View File

@ -373,6 +373,8 @@ touchpad_read_input:
.pool .pool
.extern write_save_state
save_state: save_state:
str lr, saved_state_cpu_status+56 str lr, saved_state_cpu_status+56
adr lr, saved_state_cpu_status adr lr, saved_state_cpu_status
@ -392,8 +394,11 @@ save_state:
cmp r1, #0 cmp r1, #0
bne sstate_loop bne sstate_loop
mov r0, #1
str r0, save_state_exists
mov r0, saved_state_cpu_status
str r1, saved_state_cpu_cpsr
bl write_save_state
ldr lr, saved_state_cpu_status+56 // subroutine return ldr lr, saved_state_cpu_status+56 // subroutine return

25
source/save_state.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdint.h>
#include <stdlib.h>
#include <libndls.h>
#include <stdio.h>
#define s_SIZE 0x4600;
void write_save_state(uint32_t saved_state_cpu_status_addr, uint32_t saved_state_cpu_cpsr);
void write_save_state(uint32_t saved_state_cpu_status_addr, uint32_t saved_state_cpu_cpsr){
size_t lenght = s_SIZE;
size_t data_size = s_SIZE + sizeof(uint32_t);
uint32_t *data = malloc(data_size);
memcpy(data, saved_state_cpu_status_addr, lenght);
data[data_size-1] = saved_state_cpu_cpsr;
FILE* savefile = fopen("/documents/ndless/test.tns", "wb");
fwrite(data, data_size, 1, savefile);
fclose(savefile);
}

BIN
source/save_state.o Normal file

Binary file not shown.

View File

@ -1 +1 @@
6 10

View File

@ -32,11 +32,10 @@ endif
OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c)) OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c))
OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp)) OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp))
OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S)) OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S))
DISTDIR = . DISTDIR = builds
vpath %.tns $(DISTDIR)
vpath %.elf $(DISTDIR)
all: $(EXE).tns
all:$(DISTDIR)/$(EXE).tns
%.o: %.c %.o: %.c
$(GCC) $(GCCFLAGS) -c $< -o $@ $(GCC) $(GCCFLAGS) -c $< -o $@
@ -47,15 +46,15 @@ all: $(EXE).tns
%.o: %.S %.o: %.S
$(AS) -c $< -o $@ $(AS) -c $< -o $@
$(EXE).elf: $(OBJS) $(DISTDIR)/$(EXE).elf: $(OBJS)
mkdir -p $(DISTDIR) mkdir -p $(DISTDIR)
$(LD) $^ -o $@ $(LDFLAGS) $(LD) $^ -o $@ $(LDFLAGS)
$(EXE).tns: $(EXE).elf $(DISTDIR)/$(EXE).tns: $(DISTDIR)/$(EXE).elf
$(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS) $(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS)
$(call buildver) $(call buildver)
make-prg $@.zehn $@ make-prg $@.zehn $@
rm $@.zehn rm $@.zehn
clean: clean:
rm -f $(OBJS) $(DISTDIR)/$(EXE).tns $(DISTDIR)/$(EXE).elf $(DISTDIR)/$(EXE).zehn nespire_mod_*.elf nespire_mod_*.tns rm -f $(OBJS)

BIN
testing/builds/nespire_mod_7.elf Executable file

Binary file not shown.

Binary file not shown.

BIN
testing/builds/nespire_mod_8.elf Executable file

Binary file not shown.

Binary file not shown.

BIN
testing/builds/nespire_mod_9.elf Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,22 +1,24 @@
#include <stdio.h> #include <nspireio/nspireio.h>
#include <errno.h>
#include <stdlib.h>
#include <dirent.h>
#include <libndls.h> #include <libndls.h>
#include <nspireio/platform-nspire.h>
void util_stuff(); void util_stuff(int argc, char **argv);
int KEYS_TO_QUIT = 2; void util_stuff(int argc, char **argv){
void util_stuff(){ // init console
nio_console console;
printf("Hello World!\n"); nio_init(&console, NIO_MAX_COLS , NIO_MAX_ROWS, 0, 0, NIO_COLOR_BLACK, NIO_COLOR_WHITE, true);
puts("TEST"); nio_set_default(&console);
nio_printf("test\n");
nio_printf("argc: %d\n", argc);
for(int i = 0; i < KEYS_TO_QUIT; i++){ for(int i = 0; i < argc; i++){
wait_key_pressed(); nio_printf("arg %d: %s\n", i, argv[i]);
} }
wait_key_pressed();
return; return;
} }

Binary file not shown.