From 075820bd49610a63d89ccd12212e4a10d76f93b1 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Tue, 30 May 2017 15:17:58 +0800 Subject: [PATCH] Moar optimizations. Atm at 23% real speed. --- components/tme-esp32/adns9500.c | 5 +++-- components/tme-esp32/mipi_lcd.c | 2 +- components/tme/component.mk | 33 +++++++++++++++++++++++++++++++- components/tme/m68kconf.h | 2 +- components/tme/musashi/m68k_in.c | 8 +++++--- components/tme/musashi/m68kops.c | 5 +++-- components/tme/musashi/m68kops.h | 3 ++- 7 files changed, 47 insertions(+), 11 deletions(-) diff --git a/components/tme-esp32/adns9500.c b/components/tme-esp32/adns9500.c index 63fed89..c8994da 100644 --- a/components/tme-esp32/adns9500.c +++ b/components/tme-esp32/adns9500.c @@ -98,8 +98,9 @@ void adns900_get_dxdybtn(int *x, int *y, int *btn) { sx|=adnsRead(0x4)<<8; sy=adnsRead(0x5); sy|=adnsRead(0x6)<<8; -// printf("Mouse: %d %d\n", sx, sy); + ets_delay_us(100); + *btn=gpio_get_level(ADNS_MISO)?0:1; +// printf("Mouse: %d %d %d\n", sx, sy, *btn); *x=sx; *y=sy; - *btn=gpio_get_level(ADNS_MISO)?0:1; } diff --git a/components/tme-esp32/mipi_lcd.c b/components/tme-esp32/mipi_lcd.c index 60f8679..c05272c 100644 --- a/components/tme-esp32/mipi_lcd.c +++ b/components/tme-esp32/mipi_lcd.c @@ -168,7 +168,7 @@ static void initLcd() { printf("Display inited.\n"); } -void IRAM_ATTR displayTask(void *arg) { +void displayTask(void *arg) { uint8_t *img=malloc((LINESPERBUF*320*2)+1); assert(img); calcLut(); diff --git a/components/tme/component.mk b/components/tme/component.mk index c7d3deb..62dc335 100644 --- a/components/tme/component.mk +++ b/components/tme/component.mk @@ -7,7 +7,20 @@ COMPONENT_SRCDIRS := . musashi MUSASHI_GEN_SRC := musashi/m68kops_pre.c musashi/m68kopac.c musashi/m68kopdm.c musashi/m68kopnz.c MUSASHI_GEN_OBJ := $(MUSASHI_GEN_SRC:%.c=%.o) -COMPONENT_OBJS := $(MUSASHI_GEN_OBJ) musashi/m68kcpu.o emu.o iwm.o via.o rtc.o ncr.o scc.o mouse.o +COMPONENT_OBJS := musashi/m68kops_pre.o musashi/m68kopac.o musashi/m68kopdm-iram.o musashi/m68kopnz.o musashi/m68kcpu.o emu.o iwm.o via.o rtc.o ncr.o scc.o mouse.o + +#nothing in iram: 16% +#ac nz in iram: 19% +#dm nz in iram: 19% +#ac dm in iram: 23% +#dm in iram: 23% + +#-O3: +#nothing: 13% +#dm in iram: 23% +#ac in iram: 19% +#nz in iram: 14% +#dm/ac ac/nz: ng CFLAGS += -Wno-error=implicit-function-declaration @@ -17,6 +30,24 @@ CFLAGS += -Wno-error=implicit-function-declaration COMPONENT_EXTRA_CLEAN := $(addprefix $(COMPONENT_PATH)/musashi/,$(MUSASHI_GEN_SRC) m68kmake) +#musashi/m68kops_pre.o: CFLAGS += -O3 +#musashi/m68kopac.o: CFLAGS += -O3 +#musashi/m68kopdm.o: CFLAGS += -O3 +#musashi/m68kopnz.o: CFLAGS += -O3 + +define makeiram +$(1): $(2) + $$(summary) OBJCOPY $(2) + $$(OBJCOPY) --rename-section .text=.iram1 --rename-section .literal=.iram1 $(2) $(1) + +$(2): $(COMPONENT_PATH)/$(2:%.o=%.c) + $$(summary) CC $$@ + $$(CC) $$(CFLAGS:-ffunction-sections=) $$(CPPFLAGS) -O3 $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -c $$< -o $$@ +endef + +$(foreach obj, $(MUSASHI_GEN_OBJ) musashi/m68kcpu.o, $(eval $(call makeiram, $(obj:%.o=%-iram.o), $(obj)))) + + #Using wildcard magic here because otherwise Make will invoke this multiple times. #$(COMPONENT_PATH)/musashi/ $(COMPONENT_PATH)/musashi/m68kop%.c: $(COMPONENT_PATH)/musashi/m68kmake diff --git a/components/tme/m68kconf.h b/components/tme/m68kconf.h index 4ca9682..9f497d0 100644 --- a/components/tme/m68kconf.h +++ b/components/tme/m68kconf.h @@ -166,7 +166,7 @@ void m68k_instruction(); /* If ON, the enulation core will use 64-bit integers to speed up some * operations. */ -#define M68K_USE_64_BIT OPT_OFF +#define M68K_USE_64_BIT OPT_ON /* Set to your compiler's static inline keyword to enable it, or diff --git a/components/tme/musashi/m68k_in.c b/components/tme/musashi/m68k_in.c index f980f30..df431f0 100755 --- a/components/tme/musashi/m68k_in.c +++ b/components/tme/musashi/m68k_in.c @@ -116,7 +116,8 @@ typedef void (*m68ki_instruction_jump_call)(void); extern const m68ki_instruction_jump_call m68ki_instruction_jump_table[]; //extern void (*m68ki_instruction_jump_table)(void); /* opcode handler jump table */ -extern const unsigned char m68ki_cycles[3][0x10000]; +//extern const unsigned char m68ki_cycles[1][0x10000]; +extern const unsigned char m68ki_cycles[1][0x10000]; /* ======================================================================== */ @@ -183,8 +184,9 @@ int main(int argc, char **argv) { } printf("};\n\n"); - printf("const unsigned char m68ki_cycles[%d][0x10000]={\n", NUM_CPU_TYPES); - for (int x=0; x