From 0855f283fc1200ef75b00bd6136aab1a70e578b1 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Wed, 12 Apr 2023 17:02:52 +0200 Subject: [PATCH] Additional fixes for FDISK after the migration to SDCC 4.2: - Assembler functions now return values iin DE, not HL; so CallFunctionInExtraBank is modified accordingly. - Bank 5 code and bank 6 code were sharing the same RAM and this was causing issues, now they use different RAM areas. - Apply "chmod +x" to the mknexrom tool. --- buildtools/linux/mknexrom | Bin source/kernel/Makefile | 49 +++++++++++++++++++++++++----------- source/kernel/bank5/fdisk.c | 6 ++--- 3 files changed, 38 insertions(+), 17 deletions(-) mode change 100644 => 100755 buildtools/linux/mknexrom diff --git a/buildtools/linux/mknexrom b/buildtools/linux/mknexrom old mode 100644 new mode 100755 diff --git a/source/kernel/Makefile b/source/kernel/Makefile index 7221205a..6692ca78 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -4,7 +4,7 @@ # See the "all" main rule for some handy aliases to generate specific ROMs # (e.g. you can run "make base" or "make ide"). -# The N80 and LK80 binaries to use can be overriden with environment variables, e.g.: +# The N80, LK80, LB80 and MKNEXROM binaries to use can be overriden with environment variables, e.g.: # N80=/path/to/N80 make @@ -28,6 +28,10 @@ endif export LB80_ARGS=--no-show-banner --verbosity 0 +ifeq ($(strip $(MKNEXROM)),) +MKNEXROM=mknexrom +endif + define SymToEqus $(eval REGEX:=([0-9A-F]{4}) ($(3))) cat $(1) | grep -Eo "$(REGEX)" | sed -r "s/$(REGEX)/\2 equ \1h\n\tpublic \2\n/g" > $(2) @@ -62,7 +66,7 @@ endef all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm -TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc mknexrom dd +TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc $(MKNEXROM) dd .phony: prerequisites @@ -95,7 +99,7 @@ drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.ROM: \ drivers/SunriseIDE/sunride.bin \ drivers/SunriseIDE/chgbnk.bin - mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.bin /m:drivers/SunriseIDE/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.bin /m:drivers/SunriseIDE/chgbnk.bin $(call copy_to_bin,$@) drivers/SunriseIDE/sunride.bin: \ @@ -113,7 +117,7 @@ drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.MasterOnly.ROM: \ drivers/SunriseIDE/sunride.masteronly.bin \ drivers/SunriseIDE/chgbnk.bin - mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.masteronly.bin /m:drivers/SunriseIDE/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.masteronly.bin /m:drivers/SunriseIDE/chgbnk.bin $(call copy_to_bin,$@) drivers/SunriseIDE/sunride.masteronly.bin: \ @@ -133,7 +137,7 @@ drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.emulators.ROM: \ 256.bytes cat 256.bytes drivers/SunriseIDE/driver.bin > drivers/SunriseIDE/_driver.BIN - mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/chgbnk.bin $(call copy_to_bin,$@) drivers/SunriseIDE/driver.bin: \ @@ -153,7 +157,7 @@ drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.MasterOnly.emulators.ROM: \ 256.bytes cat 256.bytes drivers/SunriseIDE/drvmonly.bin > drivers/SunriseIDE/_driver.BIN - mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/chgbnk.bin $(call copy_to_bin,$@) drivers/SunriseIDE/drvmonly.bin: \ @@ -181,7 +185,7 @@ drivers/StandaloneASCII8/Nextor-$(VERSION).StandaloneASCII8.ROM: \ 256.bytes cat 256.bytes drivers/StandaloneASCII8/driver.bin > drivers/StandaloneASCII8/_driver.bin - mknexrom nextor_base.dat $@ /d:drivers/StandaloneASCII8/_driver.bin /m:drivers/StandaloneASCII8/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/StandaloneASCII8/_driver.bin /m:drivers/StandaloneASCII8/chgbnk.bin $(call copy_to_bin,$@) drivers/StandaloneASCII8/driver.bin: \ @@ -206,7 +210,7 @@ drivers/StandaloneASCII16/Nextor-$(VERSION).StandaloneASCII16.ROM: \ 256.bytes cat 256.bytes drivers/StandaloneASCII8/driver.bin > drivers/StandaloneASCII16/_driver.bin - mknexrom nextor_base.dat $@ /d:drivers/StandaloneASCII16/_driver.bin /m:drivers/StandaloneASCII16/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/StandaloneASCII16/_driver.bin /m:drivers/StandaloneASCII16/chgbnk.bin $(call copy_to_bin,$@) drivers/StandaloneASCII16/chgbnk.bin: \ @@ -243,7 +247,7 @@ drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.ROM: \ drivers/StandaloneASCII8/chgbnk.bin \ drivers/MegaFlashRomSD/mfrsd-1slot.bin - mknexrom nextor_base.dat $@ /d:drivers/MegaFlashRomSD/mfrsd-1slot.bin /m:drivers/StandaloneASCII8/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/MegaFlashRomSD/mfrsd-1slot.bin /m:drivers/StandaloneASCII8/chgbnk.bin $(call copy_to_bin,$@) drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.Recovery.ROM: \ @@ -261,7 +265,7 @@ drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.ROM: \ drivers/StandaloneASCII8/chgbnk.bin \ drivers/MegaFlashRomSD/mfrsd-2slots.bin - mknexrom nextor_base.dat $@ /d:drivers/MegaFlashRomSD/mfrsd-2slots.bin /m:drivers/StandaloneASCII8/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/MegaFlashRomSD/mfrsd-2slots.bin /m:drivers/StandaloneASCII8/chgbnk.bin $(call copy_to_bin,$@) drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.Recovery.ROM: \ @@ -289,7 +293,7 @@ drivers/Flashjacks/Nextor-$(VERSION).Flashjacks.ROM: \ drivers/Flashjacks/flashjacks.bin \ drivers/SunriseIDE/chgbnk.bin - mknexrom nextor_base.dat $@ /d:drivers/Flashjacks/flashjacks.bin /m:drivers/SunriseIDE/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/Flashjacks/flashjacks.bin /m:drivers/SunriseIDE/chgbnk.bin $(call copy_to_bin,$@) @@ -301,7 +305,7 @@ drivers/OCM/Nextor-$(VERSION).OCM.ROM: \ nextor_base.dat \ drivers/StandaloneASCII8/chgbnk.bin - mknexrom nextor_base.dat $@ /d:drivers/OCM/driver.dat /m:drivers/StandaloneASCII8/chgbnk.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/OCM/driver.dat /m:drivers/StandaloneASCII8/chgbnk.bin $(call copy_to_bin,$@) @@ -533,11 +537,10 @@ bank6/B6.BIN: \ --code 40FFh ../codes.rel ../kvar.rel ../data.rel b6.rel \ --code 7fd0h ../chgbnk.rel -bank5/fdisk.dat bank5/fdisk2.dat: \ +bank5/fdisk.dat: \ bank5/fdisk_crt0.rel \ bank5/fdisk.h \ bank5/fdisk.c \ - $(patsubst %.dat,%.c,$@) \ bank5/drivercall.h \ bank5/drivercall.c \ ../tools/C/system.h \ @@ -552,6 +555,24 @@ bank5/fdisk.dat bank5/fdisk2.dat: \ --max-allocs-per-node 1000 --allow-unsafe-read --opt-code-size --no-std-crt0 bank5/fdisk_crt0.rel $(patsubst %.dat,%.c,$@) $(call hex2bin,$(patsubst %.dat,%.ihx,$@),$@) +bank5/fdisk2.dat: \ + bank5/fdisk_crt0.rel \ + bank5/fdisk.h \ + bank5/fdisk2.c \ + bank5/drivercall.h \ + bank5/drivercall.c \ + ../tools/C/system.h \ + ../tools/C/dos.h \ + ../tools/C/types.h \ + ../tools/C/asmcall.h \ + ../tools/C/printf.c \ + ../tools/C/asmcall.c \ + ../tools/C/partit.h + + sdcc -o bank5/ --code-loc 0x4120 --data-loc 0xA020 -mz80 --disable-warning 196 --disable-warning 84 --disable-warning 85 \ + --max-allocs-per-node 1000 --allow-unsafe-read --opt-code-size --no-std-crt0 bank5/fdisk_crt0.rel $(patsubst %.dat,%.c,$@) + $(call hex2bin,$(patsubst %.dat,%.ihx,$@),$@) + bank5/fdisk_crt0.rel: \ bank5/fdisk_crt0.s diff --git a/source/kernel/bank5/fdisk.c b/source/kernel/bank5/fdisk.c index 676019e6..42b50f8b 100644 --- a/source/kernel/bank5/fdisk.c +++ b/source/kernel/bank5/fdisk.c @@ -784,13 +784,13 @@ void GoPartitioningMainMenuScreen() AddAutoPartition(); } else if(key == 'u' && !partitionsExistInDisk && partitionsCount > 0) { UndoAddPartition(); - }else if(key == 't') { + } else if(key == 't') { TestDeviceAccess(); } else if(key == 'f' && canDoDirectFormat) { if(FormatWithoutPartitions()) { mustRetrievePartitionInfo = true; } - }else if(key == 'w' && !partitionsExistInDisk && partitionsCount > 0) { + } else if(key == 'w' && !partitionsExistInDisk && partitionsCount > 0) { if(WritePartitionTable()) { mustRetrievePartitionInfo = true; } @@ -1679,7 +1679,7 @@ int CallFunctionInExtraBank(int functionNumber, void* parametersBuffer) regs.Words.HL = (int)parametersBuffer; regs.Words.IX = (int)0x4100; //Address of "main" for extra functions program AsmCall(CALBNK, ®s, REGS_ALL, REGS_MAIN); - return regs.Words.HL; + return regs.Words.DE; }