14 November 2008, 13:54 | #41 |
HOL/FTP busy bee
Join Date: Sep 2006
Location: Germany
Age: 46
Posts: 31,960
|
|
15 November 2008, 15:10 | #42 |
ABR Creator
Join Date: Mar 2006
Location: Australia
Age: 44
Posts: 179
|
I cant decypher the checksum routine shown in the adflib documentation.
- I understand that byte 04 - 08 is a 'long', but i dont know how to correctly read and display them eg. byte values 255 37 45 82, how are they correctly translated? I have no reference to check if im right or wrong checksum+=long(buf+i*4) - i dont know whats happening here I cant check whether a checksum is correct without the correct checksum to check it against |
15 November 2008, 15:49 | #43 |
Awesome to the max
Join Date: Mar 2007
Location: Gothenburg / Sweden
Age: 48
Posts: 1,007
|
Don't know how the code looks, but if you have a long on 4 bytes you calculate the value either with
255^1*255+*255^2*37+255^3*45+255^4*82 or 255^4*255+*255^3*37+255^2*45+255^1*82 |
15 November 2008, 18:14 | #44 |
Tik Gora :D
Join Date: Oct 2001
Location: Round yo momma's
Posts: 1,273
|
Say 'i' contains 3 .. then you would get the value from location of 'buf' + 12 (cast to long) and add it to 'checksum' (also defined as long).
Code:
buf : 444F5300 'D' 'O' 'S' 00000000 *checksum* 00000370 43FA003E 70254EAE FDD84A80 so checksum would be checksum plus 43FA003E. |
15 November 2008, 19:54 | #45 | |
Zone Friend
|
Quote:
I really do think that Laurent Clevy sometimes only explains for die-hard coders in tech drivel, but misses to explain important parts. If his explanations were perfect, I would not have felt the need to ask on here about the algorithm. |
|
16 November 2008, 07:41 | #46 | |
Registered User
Join Date: Jul 2005
Location: Australia
Age: 47
Posts: 666
|
Quote:
The real way to do it in decimal is 16^6*255+16^4*37+16^2*45+16^0*82 which I think is expressed in VB notation as &HFF252D52. At a guess I would say you are currently holding the bootblock in a byte array and trying to convert to an array of ULongs so you can proceed with checksum calculation. VB.Net confuses the hell out of me with it's mess of datatype aliases and .Net intrinsics, I can only wish the best of luck with getting this to work. You mean like how the bitmap flag is a supposedly a ULONG but with a note next to it that says -1 means VALID |
|
16 November 2008, 12:24 | #47 | |
Posts: n/a
|
Amiga ADF BootBlock CheckSum
Quote:
I'd read the problems to calculate a correct checksum for a BootBlock, I can't give you a VB example coz I've never coded in VB but perhaps this code will help you? It's coded in Amiga Assembler and converted to PureBasic: Code:
;******************************************************* ;* Amiga ASM source to calculate checksum of BootBlock * ;******************************************************* ;* Calculate checksum of BootBlock ;* In: A0 => Ptr to BootBlock ;* Out: D0 => CheckSum ; ;CalcBBCkSum ; clr.l 4(a0) ;clear old checksum ; moveq #0,d0 ;clear new checkSum ; move.w #255,d1 ;255 x DWORD ;1$ add.l (a0)+,d0 ;add DWORD ; bcc.s 2$ ;Caryflag? ; addq.l #1,d0 ;correct checksum ;2$ dbf d1,1$ ;loop until D0 = FALSE ; not.l d0 ;negate checksum ; rts ;******************************************************* ;* PureBasic source to calculate checksum of BootBlock * ;******************************************************* ;Macro to correct handling of DWORD Macro AmigaLong(LONG) ((LONG>>24)&$FF)|((LONG>>8)&$FF00)|((LONG<<8)&$FF0000)|((LONG<<24)&$FF000000) EndMacro ;Name of ADF discimage adf.s = "C:\Amiga\ASM\DevPac3.adf" ;Open ADF for read If ReadFile(0, adf) ;Allocate memory for BootBlock (=1024 bytes) *bb_Mem = AllocateMemory(1024) ReadData(0, *bb_Mem, 1024) CloseFile(0) ;Get old checksum for test only ;LONG = PeekL(*bb_Mem + 4) ;LONG = AmigaLong(LONG) ;Debug "Old Checksum: " + Hex(LONG) ;Clear old checksum (must!) PokeL(*bb_Mem + 4, 0) ;Calculate new checksum (see ASM 1$ to 2$) For i = 0 To 255 LONG = PeekL(*bb_Mem + i * 4) bb_Sum+ AmigaLong(LONG) If bb_Sum < 0 bb_Sum + 1 EndIf Next bb_Sum = AmigaLong(bb_Sum) bb_Sum = bb_Sum!-1 bb_Sum = AmigaLong(bb_Sum) ;New calculated checksum in bb_Sum Debug "New Checksum: " + Hex(bb_Sum) EndIf |
|
16 November 2008, 14:02 | #48 | |
Tik Gora :D
Join Date: Oct 2001
Location: Round yo momma's
Posts: 1,273
|
Quote:
Here is my go... Code:
C# .net: uint checksum = 0; uint precsum = 0; for (int i = 0; i < 0x100; i++) // 0x100 = 1024 byte bootblock / 4 { precsum = checksum; if ((checksum += (uint)(((byteArray[i * 4]) << 24) | ((byteArray[(i * 4) + 1]) << 16) | ((byteArray[(i * 4) + 2]) << 8) | byteArray[(i * 4) + 3])) < precsum) ++checksum; } checksum = ~checksum; Last edited by mr_0rga5m; 16 November 2008 at 14:20. |
|
19 November 2008, 13:25 | #49 |
ABR Creator
Join Date: Mar 2006
Location: Australia
Age: 44
Posts: 179
|
New version of my program - 1st post
Feedback welcome - If you dont like something tell me and ill change it Last edited by jasonver2.0; 20 November 2008 at 03:03. |
09 December 2008, 22:49 | #50 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
Ive dug up my old code from few years back when I was writing stuff like this.
Source code is in Delphi 6 so you may not be able to compile it. However, the code is quite well commented and may interest you All usefull code is in *.pas files. Read with notepad or similar. |
09 December 2008, 22:53 | #51 |
Banned
Join Date: Aug 2005
Location: London / Sydney
Age: 47
Posts: 20,420
|
|
09 December 2008, 23:49 | #52 | |
Registered User
Join Date: Aug 2007
Location: UK
Posts: 446
|
Quote:
Windows '95 whats that!! Available for use with xp would be of more use. |
|
10 December 2008, 03:14 | #53 | |
Zone Friend
|
ehm, have you checked out my tool at all? This would be that way along, please *points finger*
This is jason's tool ... someone must have illegally given the wooden signpost a spin then Quote:
Last edited by andreas; 10 December 2008 at 06:02. |
|
10 December 2008, 03:30 | #54 |
ABR Creator
Join Date: Mar 2006
Location: Australia
Age: 44
Posts: 179
|
@andreas - hehe
Your program checks disk integrity and mine is all about the bootblocks - if we stay in our own respective camps we'll all be hunky dory @bigbyte - thank you, ill have a look btw - new version coming soon Last edited by jasonver2.0; 10 December 2008 at 03:43. |
10 December 2008, 16:10 | #55 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
blimey! reading that old thread really brought back some memories.. I cannot believe I wrote those utils that long ago!
Unfortunately I lost 99% of all my Amiga related stuff due to a hard drive crash a few years ago.. and kind of gave up and just lurked around this board like an old ghost never really posting much. Last thing I remember doing was that I was able to extract files from the adf image and save them in windows then add files back into the adf but can never remember if it worked correctly (the disk still appeared valid in my program but I never tried using any of the disks I modified with Winuae) |
10 December 2008, 16:17 | #56 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Big-Byte I found your altfinder on my HD
|
10 December 2008, 22:29 | #57 |
Registered User
Join Date: Aug 2007
Location: UK
Posts: 446
|
NP i had a mind fluck for a moment i was thinking of win3.1 as win'95 as you can see if was win3.1 for me asking the question why.!
I'll have a look at the url you linked Andreas. It's very easy to miss new progs on this site. |
10 December 2008, 22:37 | #58 |
Long time member
Join Date: Jul 2001
Location: UK
Posts: 754
|
Really glad you still find it useful. Amazingly Ive now got to do some changes to an old Delphi app at work (last time app was worked on was in 2000 !)
What Im really after is my 'Singing Skulls' demo.. If anyone who has it could either upload it to the zone or better still make an avi of it and stick it on youtube that would be great |
09 January 2009, 02:40 | #59 |
ABR Creator
Join Date: Mar 2006
Location: Australia
Age: 44
Posts: 179
|
Program updated again...see 1st post
Maybe I should create a new thread, I dont want people to think it doesnt have a HEX View! May have bugs still intact, sorry in advance |
01 May 2010, 21:05 | #60 |
Amiga User
Join Date: Dec 2006
Location: Delft / The Netherlands
Posts: 327
|
Hi.
Nice work, since i'm not a programmer can i add multiple files (append) in NDOS mode with this? In the past for example you had "Multiboot v1.0 by SPY from Sensor" which was able to do this. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Amiga Bootblock Reader v2 | jasonver2.0 | News | 40 | 29 April 2021 20:57 |
SCSI Card reader amiga?? | jimbobrocks92 | support.Hardware | 15 | 26 August 2018 15:21 |
Replace Amiga's Floppy Drive with USB Reader? | xaind | support.Hardware | 6 | 29 April 2010 18:29 |
Super Low Cost Amiga CF Card Reader | AmigaMAD75 | support.Hardware | 5 | 26 January 2010 18:41 |
Amiga pdf reader | RickyD-II | request.Other | 6 | 16 May 2007 19:14 |
|
|