We could find the offset to patch in the CDI and then rebuild the EDC/ECC and provide a CDI patch though.
Dreamcast Widescreen Hacks
Sega Dreamcast Development and ResearchOtherwise, there are libraries for that in open source projects. The algorithm itself is pubic and known. I studied it a bit myself and I was able to make a python wrapper around a C library to do it. You need to know the mode and LBA of the block(s) to properly compute it. I don't have access to it right now, but I could share it once I do.
So far I've patched every single hex hack into cdis and they work on a real Dreamcast.
It's based on @SiZiOUS IMG4DC refactoring of libedc, but it's different than the current one. I couldn't get the current one to compile on my system, so my example is with this one.
You can use edc_ecc.c to add support for EDC/ECC in your code.
Here's a simple example on how to use it to convert a sector from iso to bin in python:
Go in the src folder and compile a shared lib this way:
Code:
gcc -fPIC -I"../inc" -shared edc_ecc.c -O3 -o edc_ecc.so
Code:
import ctypes
import os
edc_ecc = ctypes.cdll[os.path.abspath('edc_ecc.so')]
do_encode_L2 = edc_ecc.do_encode_L2
with open('/home/user/Folder/Sonic Adventure (GDI)/track03.bin', 'rb') as f:
bin = f.read(2352)
iso = bin[16:2048+16] # We just get the iso part from the bin
a = '\x00'*16 + iso+ '\x00'*(2352-2048-16) # Result buffer, 0s instead of MSF/EDC/ECC
do_encode_L2(a, 1, 45150) # Injects EDC/ECC, for mode1 and LBA+150=45150, in a.
a == bin # Output will be True
DISCLAIMER: I'm not a programmer, just an enthusiast.
Why no codes for RE: 2? Just curious.
It's very weird if padus bothered to put the EDC/ECC code in CDI images, but never actaully use it... Maybe it's just the compatibility dlls for imgburn that ignore it?
Mode2 Form1 sector structure is slightly different from mode 1. That results in a different error correction code. M1 and M2F1 have 4 bytes of EDC and 276 bytes of ECC, but M1 has 8 blank bytes between them whereas M2F1 has 8bytes of subheader before the 2048bytes of userdata and has ECC/EDC in a 280bytes chunk. It seems CDI doesn't store the first 16 sectors because they can easily be generated on the fly. Also, as per yellow book standard, the entire last 2336 bytes of the sector is considered user data in any form of mode2. They might use that so it is simpler to mix audio and data tracks.
See: http://www.ecma.ch/publications/files/ECMA-ST/Ecma-130 1st edition July 1988.pdf
And the tables in: https://en.wikipedia.org/wiki/CD-ROM
As its name suggest, mode 2 form1 is simply mode 2, but it has the *form* (look) of mode 1 from a user perspective. In the example I posted, put 3 instead of 1 in the L2 EDC/ECC computation to make M2F1, and put 24 null bytes before the user data in the "a" buffer (instead of 16), in fact the last 8 of those null bytes might have to be a subheader, but I don't remember its structure. To insert into a CDI, simply strip the first 16 bytes of the sector, resulting in 2336 bytes/sector. BTW, all the CDIs I have have a blank subheader.
See: http://www.ecma.ch/publications/files/ECMA-ST/Ecma-130 1st edition July 1988.pdf
And the tables in: https://en.wikipedia.org/wiki/CD-ROM
As its name suggest, mode 2 form1 is simply mode 2, but it has the *form* (look) of mode 1 from a user perspective. In the example I posted, put 3 instead of 1 in the L2 EDC/ECC computation to make M2F1, and put 24 null bytes before the user data in the "a" buffer (instead of 16), in fact the last 8 of those null bytes might have to be a subheader, but I don't remember its structure. To insert into a CDI, simply strip the first 16 bytes of the sector, resulting in 2336 bytes/sector. BTW, all the CDIs I have have a blank subheader.
Double posting so the new information doesn't get discarded.
@Aleron Ives, I just tested with a CDI I had laying around and I was right. Just put the 2048bytes of userdata at offset 24 instead of 16, compute edc/ecc and then discard the first 16 sectors. Sub-header can be blank, at least for CDI purposes.
I'm using python because I like it better and I think it's clearer, but the usage is very similar in C/C++ etc.
A shared object (.so), is the Linux equivalent of a Windows DLL. In fact just set the extension to dll to compile on Windows (and optionally remove -fPIC).
@Aleron Ives, I just tested with a CDI I had laying around and I was right. Just put the 2048bytes of userdata at offset 24 instead of 16, compute edc/ecc and then discard the first 16 sectors. Sub-header can be blank, at least for CDI purposes.
Code:
import ctypes
import os
edc_ecc = ctypes.cdll[os.path.abspath('edc_ecc.so')]
do_encode_L2 = edc_ecc.do_encode_L2
# Those are taken directly from a CDI, the name indicates their length
with open('2048.dat', 'rb') as f:
a = f.read()
with open('2336.dat', 'rb') as f:
b = f.read()
b[8:2048+8] == a # True
c = '\x00'*24 + a + '\x00'*(2352-2048-24) # 24 instead of 16
c[16:] == b # False, of course
do_encode_L2(c, 3, 11702+150) # 3 -> M2F1. Address irrelevant?
c[16:] == b # True
A shared object (.so), is the Linux equivalent of a Windows DLL. In fact just set the extension to dll to compile on Windows (and optionally remove -fPIC).
Code:
Head Hunter PAL 16:9 0204E9EC 44558000
4WHEELTHUNDER T-9708N V1.002 NTSC
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/6Lf9VlD.png)
Code:
VALUE 1 FIND D8D4098C E4D4098C 8002E001 AAAAAA3F REPLACE D8D4098C E4D4098C 8002E001 ABAA2A40 VALUE 2 FIND 8870F749 D742813F AD031EC4 3B354B47 REPLACE 701D2E4A D742813F AD031EC4 3B354B47
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/6Lf9VlD.png)
Could Cannon Spike or Dynamite Cop receive an ISO patch?
Thanks in advance.
Keep up the good work!
Thanks in advance.
Keep up the good work!
@-=FamilyGuy=-
Thanks for the information. Unfortunately I'm not a programmer either, so I can't do much with it.
Thanks for the information. Unfortunately I'm not a programmer either, so I can't do much with it.

DYNAMITE COP MK-51013 V1.005 (NTSCU)
VALUE 1," ELEVEN TIMES".
The value is present several times in the executable and every camera reads from one each.
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/J0PUrBF.png)
VALUE 1," ELEVEN TIMES".
Code:
FIND AAAAAA3F REPLACE 398EE33F
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/J0PUrBF.png)
BLUE STINGER., E T13001D-05 V1.000
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/yNoFhh7.png)
Code:
Value 1 Vert+ CCCC8C3F 9C41178C 20C2078C 94CC248C 0000FA43 00002044 0000F043 BBBBBB3F 9C41178C 20C2078C 94CC248C 0080BB43 00002044 0000F043 Value 2 Cuscenes zoom out 0000FA43 00002044 0000F043 00000040 B441178C BCCC248C C0CC248C 0080BB43 00002044 0000F043 00000040 B441178C BCCC248C C0CC248C Value3 Ingame Zoom out 0000FA43 94CC248C B441178C E001258C E101258C 20CD248C 1ACD248C 0080BB43 94CC248C B441178C E001258C E101258C 20CD248C 1ACD248C
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/yNoFhh7.png)
Original thread: https://assemblergames.com/threads/dreamcast-widescreen-hacks.58620/