diff --git a/000.trackdisk/Makefile b/000.trackdisk/Makefile index 64cc409..3b85472 100644 --- a/000.trackdisk/Makefile +++ b/000.trackdisk/Makefile @@ -1,4 +1,3 @@ -MAKEADF=../tools/makeadf FLOPPY=bin/test.adf MODULE=main.s diff --git a/Makefile b/Makefile index cf4828f..7b299a8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SUBDIRS=000.trackdisk 001.simple_image 002.sprite_display 003.music 004.copper_bars 005.copper_vert +SUBDIRS=tools/makeadf tools/imagecon 000.trackdisk 001.simple_image 002.sprite_display 003.music 004.copper_bars 005.copper_vert .PHONY: subdirs $(SUBDIRS) diff --git a/base.mk b/base.mk index e2935c4..7d80d2c 100644 --- a/base.mk +++ b/base.mk @@ -1,3 +1,5 @@ +MAKEADFDIR=../tools/makeadf/ +MAKEADF=$(MAKEADFDIR)/bin/makeadf HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow HOST_CFLAGS=-g $(HOST_WARNINGS) IMAGECONDIR=../tools/imagecon @@ -26,8 +28,8 @@ out: $(IMAGECON): make -C $(IMAGECONDIR) -$(MAKEADF): ../tools/makeadf.c - gcc ../tools/makeadf.c -o $(MAKEADF) +$(MAKEADF): + make -C $(MAKEADFDIR) $(FLOPPY): out/bootblock.bin $(MAKEADF) out/bootblock.bin > $(FLOPPY) diff --git a/tools/bitmap.pyc b/tools/bitmap.pyc deleted file mode 100644 index 748acdb..0000000 Binary files a/tools/bitmap.pyc and /dev/null differ diff --git a/tools/makeadf.c b/tools/makeadf.c deleted file mode 100644 index 52d151c..0000000 --- a/tools/makeadf.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * http://eab.abime.net/showpost.php?p=895070&postcount=6 - * Makes a disk image of 901120 (0xdc000) bytes. - * Calculates boot block checksum. - */ - -#include -#include -#include - -#define DISKSIZE (0xdc000) - -uint8_t image[DISKSIZE]; - - -static void boot_chksum(uint8_t *p) -{ - uint32_t oldchk,chk=0; - int i; - - memset(p+4,0,4); - for (i=0; i<1024; i+=4) { - oldchk = chk; - chk += ((uint32_t)p[i+0] << 24) | ((uint32_t)p[i+1] << 16) | - ((uint32_t)p[i+2] << 8) | p[i+3]; - if (chk < oldchk) - ++chk; /* carry */ - } - - chk = ~chk; - p[4] = (uint8_t)((chk >> 24) & 0xff); - p[5] = (uint8_t)((chk >> 16) & 0xff); - p[6] = (uint8_t)((chk >> 8) & 0xff); - p[7] = (uint8_t)(chk & 0xff); -} - - -int main(int argc,char *argv[]) -{ - FILE *f; - int rc = 1; - size_t len; - - if (argc == 2) { - if (f = fopen(argv[1],"rb")) { - len = fread(image,1,DISKSIZE,f); - if (len > 0) { - if (len < DISKSIZE) - memset(image+len,0,DISKSIZE-len); - boot_chksum(image); - fwrite(image,1,DISKSIZE,stdout); - rc = 0; - } - else - fprintf(stderr,"Image read error!\n"); - } - else - fprintf(stderr,"Cannot open '%s'!\n",argv[0]); - } - else - fprintf(stderr,"Usage: %s \n",argv[0]); - - return rc; -} diff --git a/tools/sum-bootblock.py b/tools/sum-bootblock.py deleted file mode 100755 index 65a4433..0000000 --- a/tools/sum-bootblock.py +++ /dev/null @@ -1,29 +0,0 @@ -#! /usr/bin/env python - -import sys -import struct - -def splice_checksum(block, chksum): - return block[0:4] + struct.pack('>I', chksum) + block[8:] - -def makeit(fn, ofn): - with open(fn, 'rb') as f: data = f.read() - - data = data + '\0' * (1024 - len(data)) - - chksum = 0 - for w in xrange(0, 1024, 4): - chksum += struct.unpack('>I', data[w:w+4])[0] - if chksum > 0xffffffff: - chksum = (chksum + 1) & 0xffffffff - - chksum = (~chksum) & 0xffffffff - - data2 = splice_checksum(data, chksum) - - with open(ofn, 'wb') as f: f.write(data2) - -if len(sys.argv) == 3: - makeit(sys.argv[1], sys.argv[2]) -else: - sys.stderr.write('need two args\n')