VOGONS


AMI Color BIOS (1993 and earlier) modification in hex editor

Topic actions

Reply 60 of 65, by theelf

User metadata
Rank Oldbie
Rank
Oldbie

Thanks guy, understand!!

i made two script, to interleave in python and de interleave

interleave to flat

#!/usr/bin/env python3
# Compatible with Python 3.4.3

import sys

if len(sys.argv) != 3:
print("Usage: interleaved_to_flat.py input_interleaved.bin output_flat.bin")
sys.exit(1)

input_file = sys.argv[1]
output_file = sys.argv[2]

try:
with open(input_file, "rb") as f:
data = f.read()
except:
print("Error reading input file.")
sys.exit(1)

half = len(data) // 2
flat = bytearray(len(data))

for i in range(half):
flat[i*2] = data[i] # bytes pares (primer mitad)
flat[i*2 + 1] = data[half + i] # bytes impares (segunda mitad)

try:
with open(output_file, "wb") as f:
f.write(flat)
print("Conversion complete. File saved as:", output_file)
except:
print("Error writing output file.")

and flat to interleave

#!/usr/bin/env python3
# Compatible with Python 3.4.3

import sys

if len(sys.argv) != 3:
print("Usage: flat_to_interleaved.py input_flat.bin output_interleaved.bin")
sys.exit(1)

input_file = sys.argv[1]
output_file = sys.argv[2]

try:
with open(input_file, "rb") as f:
flat = f.read()
except:
print("Error reading input file.")
sys.exit(1)

even = flat[::2]
odd = flat[1::2]

interleaved = bytearray(even) + bytearray(odd)

try:
with open(output_file, "wb") as f:
f.write(interleaved)
print("Conversion complete. File saved as:", output_file)
except:
print("Error writing output file.")

Tested with a working interleave bios, i de-interleave, interleave again, burn in willem and works fine in motherboard

Now my question, if i de-interleave change 3230 to 3235 in hex, use amichksumcalc3.py,

"R:\test.bin" is 64 kB in size! Copying "R:\test.bin" to "R:\test.TMP"... Copying "R:\test.bin" file to "R:\test.TMP"... "R:\tes […]
Show full quote

"R:\test.bin" is 64 kB in size!
Copying "R:\test.bin" to "R:\test.TMP"...
Copying "R:\test.bin" file to "R:\test.TMP"...
"R:\test.bin" copied to "R:\test.TMP".
"R:\test.TMP" seems authentic 64 kB AMI "color" BIOS.
Checksum bytes at 0xFF50 (hex, LE): "1C B9"
Checksum != 0: 1280
Current checksum (hex, LE): "0500"
Fix needed: 64256 (hex, LE): "FB00"
Auto-patch "R:\test.TMP" now? Enter [y/N]: y
Renaming "R:\test.TMP" to "R:\test.PCH"...
Renamed "R:\test.TMP" to "R:\test.PCH".
Patched checksum at 0xFF50: "01 00"
Original "R:\test.bin" remains untouched.
You can now use "R:\test.PCH" with corrected checksum.

Interleave test.PCH and burn... motherboard do 9 beeps error, bios checksum

I think amichksumcalc3.py is doing something brong ?¿

Reply 61 of 65, by theelf

User metadata
Rank Oldbie
Rank
Oldbie
ahyeadude wrote on 2023-10-29, 20:27:
Thanks @jakethompson1 for this great guide. I used it to successfully add PS2 mouse support to my 386sx board. […]
Show full quote

Thanks @jakethompson1 for this great guide. I used it to successfully add PS2 mouse support to my 386sx board.

I decided to nerd out today and create a AMIBIOS checksum calculator in python based on your find. It can also calculate the 2-byte addition required to make the checksum equal to zero so that it passes that check.

Example output on my PS2 modified bios:

Checksum does not equal zero!!!
Checksum: 16
2 byte addition needed to validate checksum: F0 FF

I then added F0 FF to the middle of large blank area of the bios at 0x6000. Can run it again to verify:

Checksum equals zero
Checksum: 0

I flashed and it works great. Nice to know if there is a bit-flip down the road (unlikely, I know) the bios should catch it.

Python file attached.

ok! this script works!!!!!! perfect! thanks ahyeadude

here is addapted to python 3.4.3

#!/usr/bin/env python3
# loads amibios and calculates checksum (16 bit sequential) and value needed to validate (if checksum != 0)

import sys

try:
bios_file = sys.argv[1]
with open(bios_file, mode='rb') as file:
bios_data = file.read()
except:
print("Usage: amichksum.py path_to_rom.bin")
sys.exit()

block_count = int(len(bios_data) / 16)
checksum = 0
for block in range(0, block_count):
bios_block = bios_data[block*16:block*16+16]
block_checksum = 0
for byte_pair in range(0, 8):
hi = bios_block[byte_pair*2+1]
lo = bios_block[byte_pair*2]
byte_pair_hex = '{:02X}{:02X}'.format(hi, lo)
byte_pair_dec = int(byte_pair_hex, 16)
block_checksum += byte_pair_dec
block_checksum %= 65536
checksum += block_checksum

checksum %= 65536
if checksum != 0:
print("Checksum does not equal zero!!!")
print("Checksum:", checksum)
two_byte_addition = '{:02X} {:02X}'.format((65536 - checksum) & 0xFF, ((65536 - checksum) >> 8) & 0xFF)
print("2 byte addition needed to validate checksum:", two_byte_addition)
else:
print("Checksum equals zero")
print("Checksum:", checksum)

Reply 62 of 65, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie
theelf wrote on 2025-07-19, 21:30:

I think amichksumcalc3.py is doing something brong ?¿

My script uses the very same checksum algorithm from ahyeadude's amichksum.py. Of course it won't work witch ROM dumps created from two concatenated ROM dump-files (copy /b dump1.rom+dump1.rom bios.rom). I'll check on what BIOS dump you're trying to use it and I'll give you feedback later today.

The word Idiot refers to a person with many ideas, especially stupid and harmful ideas.
This world goes south since everything's run by financiers and economists.
This isn't voice chat, yet some people overusing online communications talk and hear voices.

Reply 63 of 65, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie
theelf wrote on 2025-07-19, 21:30:
Now my question, if i de-interleave change 3230 to 3235 in hex, use amichksumcalc3.py, […]
Show full quote

Now my question, if i de-interleave change 3230 to 3235 in hex, use amichksumcalc3.py,

"R:\test.bin" is 64 kB in size! Copying "R:\test.bin" to "R:\test.TMP"... Copying "R:\test.bin" file to "R:\test.TMP"... "R:\tes […]
Show full quote

"R:\test.bin" is 64 kB in size!
Copying "R:\test.bin" to "R:\test.TMP"...
Copying "R:\test.bin" file to "R:\test.TMP"...
"R:\test.bin" copied to "R:\test.TMP".
"R:\test.TMP" seems authentic 64 kB AMI "color" BIOS.
Checksum bytes at 0xFF50 (hex, LE): "1C B9"
Checksum != 0: 1280
Current checksum (hex, LE): "0500"
Fix needed: 64256 (hex, LE): "FB00"
Auto-patch "R:\test.TMP" now? Enter [y/N]: y
Renaming "R:\test.TMP" to "R:\test.PCH"...
Renamed "R:\test.TMP" to "R:\test.PCH".
Patched checksum at 0xFF50: "01 00"
Original "R:\test.bin" remains untouched.
You can now use "R:\test.PCH" with corrected checksum.

Interleave test.PCH and burn... motherboard do 9 beeps error, bios checksum

I think amichksumcalc3.py is doing something brong ?¿

Just took your BIOS from the attached "zida1.zip" - "zida1.BIN". It's not a valid AMI "color" BIOS in this state. It's 32 kB "low" + 32kB "high" ROMs concatenated into 64 kB "zida1.BIN" file!

So, I splitted "zida1.BIN" in half and merged (deinterlaced) the two halves into valid AMI "color" BIOS ROM - "ZIDA.BIN":

The attachment ZIDA.zip is no longer available

And auto-corrected the wrong checksum bytes in "ZIDA.BIN" by using my perfectly fine working script:

"ZIDA.BIN" file is 64 kB in size!
Original "ZIDA.BIN" will be copied to "ZIDA.TMP" file.
Copying "ZIDA.BIN" file to "ZIDA.TMP" file...
"ZIDA.BIN" file was copied to "ZIDA.TMP" file.
"ZIDA.TMP" file seems like authentic 64 kB AMI "color" BIOS.
Checksum bytes read from "ZIDA.TMP" file at address 0xFF50 (hex, LE): "39 4A".
Checksum for "ZIDA.TMP" file does not equals zero.
Current checksum (dec): 12240; (hex, LE): "D0 2F".
2 bytes addition to current checksum needed to validate it (dec) 53296; (hex, LE): "30 D0".
Do you want to auto-patch the checksum bytes in "ZIDA.TMP" file? Enter [y/N]: y
Renaming "ZIDA.TMP" file to "ZIDA.PCH"...
Original "ZIDA.TMP" file was renamed to "ZIDA.PCH".
Checksum bytes replaced in "ZIDA.PCH" file at address 0xFF50 with these values (hex, LE): "69 1A".
Original unmodified "ZIDA.BIN" file is still intact.
Now you can use freshly created "ZIDA.PCH" file with corrected checksum bytes.
Do you see the big difference in read and calculated values in the checksum bytes with the output from your adapted version?
"R:\test.bin" is 64 kB in size!
Copying "R:\test.bin" to "R:\test.TMP"...
Copying "R:\test.bin" file to "R:\test.TMP"...
"R:\test.bin" copied to "R:\test.TMP".
"R:\test.TMP" seems authentic 64 kB AMI "color" BIOS.
Checksum bytes at 0xFF50 (hex, LE): "1C B9"
Checksum != 0: 1280
Current checksum (hex, LE): "0500"
Fix needed: 64256 (hex, LE): "FB00"
Auto-patch "R:\test.TMP" now? Enter [y/N]: y
Renaming "R:\test.TMP" to "R:\test.PCH"...
Renamed "R:\test.TMP" to "R:\test.PCH".
Patched checksum at 0xFF50: "01 00"
Original "R:\test.bin" remains untouched.
You can now use "R:\test.PCH" with corrected checksum.

Even did a second run on the fresh copy with corrected checksum "ZIDA.PCH", just to be sure:

"ZIDA.PCH" file is 64 kB in size!
Original "ZIDA.PCH" will be copied to "ZIDA.TMP" file.
Copying "ZIDA.PCH" file to "ZIDA.TMP" file...
"ZIDA.PCH" file was copied to "ZIDA.TMP" file.
"ZIDA.TMP" file seems like authentic 64 kB AMI "color" BIOS.
Checksum bytes read from "ZIDA.TMP" file at address 0xFF50 (hex, LE): "69 1A".
Checksum for "ZIDA.TMP" file equals zero.
Deleting "ZIDA.TMP"...
"ZIDA.TMP" file was deleted.
No actions needed.
Original unmodified "ZIDA.PCH" file is still intact.

And here is hex comparison between the original dump with the wrong checksum bytes "ZIDA.BIN" and auto-corrected one (by "amichksumcalc3.py" script) "ZIDA.PCH":

The attachment wrong checksum - corrected checksum.jpg is no longer available

Once again - my original "amichksumcalc3.py" script just works fine. I don't know what you're adapting for older Python versions, but in this case it's your call to not introduce bugs, not mine.

Attaching "ZIDA.BIN" ROM dump in correct unsplitted and merged (deinterlaced) AMI "color" BIOS form - with and without the corrected checksum bytes:

The attachment ZIDA.zip is no longer available

I don't know if you have to split (interlace) "ZIDA.PCH" and concatenate the two resulting "low" ("even") and "high" ("odd") ROM parts into one file to work with you mobo - it's also your response.

P.S. Thanks for the feedback based on "I don't know what I'm dealing with, but your script s*cks". Now for sure no one will try to use my script after reading the first given negative feedback. And I knew it - I didn't have to optimize and improve anything for "amichksumcalc3.py" to be usable and easily readable by everyone.

The word Idiot refers to a person with many ideas, especially stupid and harmful ideas.
This world goes south since everything's run by financiers and economists.
This isn't voice chat, yet some people overusing online communications talk and hear voices.

Reply 64 of 65, by theelf

User metadata
Rank Oldbie
Rank
Oldbie

Cool, thanks confirm it works, then maybe is something in conversion to 3.4.3, erase from my message not to confuse. Thanks!

I found a new bios for my motherboard that work after modding https://theretroweb.com/motherboards/s/zida-td60c#bios 2cgm001.bin

Out.bin is after deinterleaving and change 20MHz to 25Mhz with hex, out.PCH is after using the amichksumcalc3.py script i ported to 3.4.3, it change 1CB9 to 0100

amichksum.py backported too, tellme this

C:\>R:\amichksum.py R:\out.bin Checksum does not equal zero!!! Checksum: 1280 2 byte addition needed to validate checksum: 00 FB […]
Show full quote

C:\>R:\amichksum.py R:\out.bin
Checksum does not equal zero!!!
Checksum: 1280
2 byte addition needed to validate checksum: 00 FB

IF i add 00 FB and burn works well

But anyways, if the problem is a mistake in backport to 3.4.3 there no need to check anything else, cool. I can´t test original scripts, im using Win XP

I think for now i is end of the road for me with this 286 motherboard, i dont found any new bios and the mods i made works fine with it

thanks to help to everybody

Reply 65 of 65, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie
theelf wrote on Yesterday, 08:21:

Cool, thanks confirm it works, then maybe is something in conversion to 3.4.3, erase from my message not to confuse. Thanks!

I don't mind your adapted version for older Python. Maybe you've made a mistake with the Zida's BIOS ROM conversion as it comes in pretty messed state (32 kB "low" + 32kB "high" ROMs concatenated into 64 kB "zida1.BIN").

I don't remember what "PEP8 standard" recommends for such an old Python version as 3.4.3. If the script only needs conversion in (print) formatted strings, then there's nothing to be wrong with it.

P.S. To clarify the situation with all the script versions, just tried your Python 3.4.3 adapted script from your post. I'm on Linux with Python 3.10.12 and here's what I got with using it on "ZIDA.BIN" (the restored one, but with the wrong checksum bytes):

"ZIDA.BIN" is 64 kB in size!
Copying "ZIDA.BIN" to "ZIDA.TMP"...
Copying "ZIDA.BIN" file to "ZIDA.TMP"...
"ZIDA.BIN" copied to "ZIDA.TMP".
"ZIDA.TMP" seems authentic 64 kB AMI "color" BIOS.
Checksum bytes at 0xFF50 (hex, LE): "39 4A"
Checksum != 0: 12240
Current checksum (hex, LE): "D02F"
Fix needed: 53296 (hex, LE): "30D0"
Traceback (most recent call last):
File "./adaptedcalc3.py", line 186, in <module>
new_first_checksum_byte = hex_str2int(int2hex_str(two_byte_addition, 0)) + byte2int(first_checksum_byte)
File "./adaptedcalc3.py", line 43, in hex_str2int
return int(bytearray.fromhex(hex_str)[0]) + (int(bytearray.fromhex(hex_str)[1]) << 8)
IndexError: bytearray index out of range

Before the thrown error, at least it managed to correctly read and calculate the checksum bytes for the "ZIDA.BIN" file, and also manage to calculate the right addition needed - just like the original scrip does 😉

I can assure you, that I've already lost more than a day (summary) in testing (including today's tests with your Zida BIOS dump-file) and I've never ever published in this forum some bull*hit code/software written (and/or compiled) by me. I don't know if this "bytearray index out of range" error is due to Python versions syntax or functional incompatibility or there's a bug in your adapted version for Python 3.4.3. I guarantee at 100% that my original "amichksumcalc3.py" script works fine with Python 3.10.xx+ (probably even with Python 3.8.something), but still it's not an "AMI BIOS magic wand". Unfortunately (fortunately for me 😀 ) I've totally lost interest to improve it further, even for compatibility with older Python interpreter versions. I didn't expect the first feedback from someone's real usage to be - "nah, the thing doesn't work right", even if "the thing" is not the original thing, but altered one 😁

The f*ckin' "amichksumcalc3.py" script will remain here as is (in case if I lost it source code and still need to use it) and can be used and altered by anyone as he/she decides. Just don't blame me, if your upgraded/improved/downgraded/whatever-changed version doesn't work as expected anymore 😉

The word Idiot refers to a person with many ideas, especially stupid and harmful ideas.
This world goes south since everything's run by financiers and economists.
This isn't voice chat, yet some people overusing online communications talk and hear voices.