![]() |
![]() |
![]() |
#1 |
Registered User
![]() Join Date: Sep 2016
Location: Deventer - Netherlands
Posts: 558
|
Bootblock
Which program is the best to write a binary to the bootblock, and is instant werking, include boot checksum etc etc....
|
![]() |
![]() |
#2 |
Natteravn
![]() Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,801
|
What is your goal? Do you have a specific boot block which you want to write once to a disk, or do want to write a boot block, or even a whole ADF, as an automated part of a build process?
There may be tools for the first case. You can also write blocks to disk with AsmOne, for example. For both cases it might be best to write a small, portable C program to perform that task. So you can even use it on other architectures, in case you are cross-developing, and include it in a Makefile. When I am building an ADF for one of my games, I have one source which contains the whole disk, starting with the boot block and using INCBIN to include the remaining disk contents (for a trackloader). Then I have a portable C tool which takes this image, pads it to 880K with zeros and calculates the boot block checksum. The result is a working ADF. Maybe this helps: Code:
/* * Makes a disk image of 901120 (0xdc000) bytes. * Calculates boot block checksum. */ #include <stdio.h> #include <string.h> #include <stdint.h> #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[1]); } else fprintf(stderr,"Usage: %s <image data>\n",argv[0]); return rc; } |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Writing a non-bootblock | mcgeezer | support.Apps | 7 | 22 February 2019 00:50 |
Bootblock Games | Dan | support.Games | 3 | 18 January 2018 17:14 |
bootblock | mai | support.Apps | 7 | 25 September 2012 12:28 |
Anyone like to help understanding this bootblock ??? | Joe Maroni | Coders. Tutorials | 2 | 15 February 2007 18:33 |
Bootblock checksum | -Rob- | Coders. General | 5 | 17 April 2006 16:49 |
|
|