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": [
{
"name": "Linux",
"name": "nspire",
"includePath": [
"${workspaceFolder}/**",
"/home/franchioping/NSpire/Nespire/**",
"/home/franchioping/NSpire/Ndless/ndless-sdk/include/*"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"compilerPath": "/home/franchioping/NSpire/Ndless/ndless-sdk/bin/nspire-gcc",
"cStandard": "c17",
"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

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
@echo DONE
BLD_FILE ?= .buildver
nes_emu.tns : nespire.elf
genzehn --input $< --output $@ --name "nes_emu"
make-prg $@ ./nes_emu.prg.tns
# Initiate BLD_FILE if not exists
buildver_create := $(shell if ! test -f $(BLD_FILE); then echo 0 > $(BLD_FILE); fi)
nespire.elf : main.o cpu.o debug.o memory.o ppu.o rom.o menu.o
$(PREFIX)ld main.o cpu.o debug.o memory.o ppu.o rom.o menu.o -o $@
# Prepare callable function. This function updates BLD_FILE
buildver = $(shell echo $$(($$(cat $(BLD_FILE)) + 1)) > $(BLD_FILE))
%.o : %.S
$(PREFIX)gcc -Wall -W -marm -Os -c $< -o $@
VER = buildver
GCC = nspire-gcc
AS = nspire-as
GXX = nspire-g++
LD = nspire-ld
GENZEHN = genzehn
EXE = nespire$(shell cat $(BLD_FILE))
clean_p:
@rm -f *.o nespire.elf
GCCFLAGS = -Wall -W -marm
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
@rm -f nes_emu.tns nes_emu.prg.tns
all:$(DISTDIR)/$(EXE).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
.extern write_save_state
save_state:
str lr, saved_state_cpu_status+56
adr lr, saved_state_cpu_status
@ -392,8 +394,11 @@ save_state:
cmp r1, #0
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

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 %.cpp, %.o, $(shell find . -name \*.cpp))
OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S))
DISTDIR = .
vpath %.tns $(DISTDIR)
vpath %.elf $(DISTDIR)
DISTDIR = builds
all: $(EXE).tns
all:$(DISTDIR)/$(EXE).tns
%.o: %.c
$(GCC) $(GCCFLAGS) -c $< -o $@
@ -47,15 +46,15 @@ all: $(EXE).tns
%.o: %.S
$(AS) -c $< -o $@
$(EXE).elf: $(OBJS)
$(DISTDIR)/$(EXE).elf: $(OBJS)
mkdir -p $(DISTDIR)
$(LD) $^ -o $@ $(LDFLAGS)
$(EXE).tns: $(EXE).elf
$(DISTDIR)/$(EXE).tns: $(DISTDIR)/$(EXE).elf
$(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS)
$(call buildver)
make-prg $@.zehn $@
rm $@.zehn
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 <errno.h>
#include <stdlib.h>
#include <dirent.h>
#include <nspireio/nspireio.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(){
printf("Hello World!\n");
puts("TEST");
for(int i = 0; i < KEYS_TO_QUIT; i++){
wait_key_pressed();
// init console
nio_console console;
nio_init(&console, NIO_MAX_COLS , NIO_MAX_ROWS, 0, 0, NIO_COLOR_BLACK, NIO_COLOR_WHITE, true);
nio_set_default(&console);
nio_printf("test\n");
nio_printf("argc: %d\n", argc);
for(int i = 0; i < argc; i++){
nio_printf("arg %d: %s\n", i, argv[i]);
}
wait_key_pressed();
return;
}
}

Binary file not shown.