Welcome to the Sogna Digital Museum Forum!Notice to New Forum Registrants:If you register and don't get the validation email, you may contact us at sognadigitalmuseum@gmail.com for manual activation.
SGSFILE.COM - is the main SGS.DAT file loader, stays in memory, loads chunks into memory, looks like 8kb blocks (actually SGS requests 8kb blocks)SGS.COM - main game engineSGS.COM hands off data load requests to SGSFILE.COM to read in data from the SGS.DAT file.The opcodes are different in the PC98 version of the SGS engine, they don't seem to match up with the WIN version.-I only followed the flow of data through the first couple of bytes so i didn't really see how it handled the end of the file.-I don't know if this handles the other file types the same way, i'm guessing it might. Only tested on the STARTUP.SZH file which is ID'd as 'SIL'
STARTING POINT===================RAW DATA: Start of STARTUP.SZH [data read in started after FileIdentifier'SIL']1400 11C4 1110 9C18 4111 8E81 8000REG:EAX=00002000 EBX=00000005 ECX=00002000 EDX=0000e000ESP=00008376 EBP=60002000 ESI=0000e000 EDI=0000a000DS=263f ES=263f SS=263f CS=263f EIP=00001477 ASM: @1477 mov dl, 7 ; DX = e007 lodsb ; READ BYTE from DS:SI into AX (RB==14h) ;AX=2014dec bp ; decrease counter? ;BP = 2000 > 1FFFmov dh, al ; DX = RB07 ; RB==ReadByte; ;DX = 1407shl dh, 1 ; ;DX = 2807==================File Data Manipulation:VV1400 11C4 1110 9C18 4111 8E81 80000x14 ==> 0x280x00 ==>==================lodsb ; Reads from DS:SI into AX [Read byte: 0x00]mov cl, 8 ; CX = 2000 > 2008 ; DX = 0007sub cl, dl ; CX = 2008 > 2001xor ah, ah ; AX = 2000 > 0000shl ax, cl ; AX = 0000 > 0000 or ah, dh ; DX = 2807 ; AX = 2800mov dh, al ; DX = 2807 > 0007mov al, ah ; AX = 2800 > 2828dec bp ; BP = 1FFF > 1FFEretn==================stosb ; Store byte into ES:DI [AL = 0x28]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:28===================================lodsb ; Reads from DS:SI into AX [Read byte: 0x11]mov cl, 8 ; CX = 2001 > 2008 ; DX = 0006sub cl, dl ; CX = 2001 > 2002 xor ah, ah ; AX = 2811 > 0011 shl ax, cl ; AX = 0011 > 0044 ; DX = 0006or ah, dh ; AX = 0044 > 0044mov dh, al ; DX = 0006 > 4406mov al, ah ; AX = 0044 > 0000dec bp ; BP = 1FFE > 1FFDretn==================stosb ; Store byte into ES:DI [AL = 0x00]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 ==================dec dl ;DX = 4406 > 4405shl dh, 1 ; ;DX = 4405 > 8805retn==================lodsb ; Reads from DS:SI into AX [Read byte: 0xC4] ; AX = 0000 > 00C4mov cl, 8 ; CX = 2002 > 2008 ; DX = 8805sub cl, dl ; CX = 2002 > 2003 xor ah, ah ; AX = 00C4 > 00C4 shl ax, cl ; AX = 00C4 > 0620 ; DX = 8805or ah, dh ; AX = 0620 > 8E20mov dh, al ; DX = 8805 > 2005mov al, ah ; AX = 8E20 > 8E8Edec bp ; BP = 1FFD > 1FFCretn==================stosb ; Store byte into ES:DI [AL = 0x8E]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E==================dec dl ;DX = 2005 > 2004shl dh, 1 ; ;DX = 2004 > 4004retn==================lodsb ; Reads from DS:SI into AX [Read byte: 0x11] ; AX = 8E20 > 8E11mov cl, 8 ; CX = 2003 > 2008 ; DX = 4004sub cl, dl ; CX = 2008 > 2004 xor ah, ah ; AX = 8E11 > 0011 shl ax, cl ; AX = 0011 > 0110 ; DX = 4004or ah, dh ; AX = 0110 > 4110mov dh, al ; DX = 4004 > 1004mov al, ah ; AX = 4110 > 4141dec bp ; BP = 1FFC > 1FFBretn==================stosb ; Store byte into ES:DI [AL = 0x41]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41==================dec dl ;DX = 1004 > 1003shl dh, 1 ; ;DX = 1003 > 2003retn==================lodsb ; Reads from DS:SI into AX [Read byte: 0x10] ; AX = 4141 > 4110mov cl, 8 ; CX = 2004 > 2008 ; DX = 2003sub cl, dl ; CX = 2008 > 2005 xor ah, ah ; AX = 4110 > 0010 shl ax, cl ; AX = 0010 > 0200 ; DX = 2003or ah, dh ; AX = 0200 > 2200mov dh, al ; DX = 2003 > 0003mov al, ah ; AX = 2200 > 2222dec bp ; BP = 1FFB > 1FFAretn==================stosb ; Store byte into ES:DI [AL = 0x22]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 22==================dec dl ;DX = 0003 > 0002shl dh, 1 ; ;DX = 0002 > 0002retn==================lodsb ; Reads from DS:SI into AX [Read byte: 0x9C] ; AX = 2222 > 229Cmov cl, 8 ; CX = 2005 > 2008 ; DX = 0002sub cl, dl ; CX = 2008 > 2006xor ah, ah ; AX = 229C > 009Cshl ax, cl ; AX = 009C > 2700 ; DX = 0002or ah, dh ; AX = 2700 > 2700mov dh, al ; DX = 0002 > 0002mov al, ah ; AX = 2700 > 2727dec bp ; BP = 1FFA > 1FF9retn==================stosb ; Store byte into ES:DI [AL = 0x27]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 2227==================dec dl ;DX = 0002 > 0001shl dh, 1 ; ;DX = 0001 > 0001retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x18] ; AX = 2727 > 2718mov cl, 8 ; CX = 2006 > 2008 ; DX = 0001sub cl, dl ; CX = 2008 > 2007xor ah, ah ; AX = 2718 > 0018shl ax, cl ; AX = 0018 > 0C00 ; DX = 0001or ah, dh ; AX = 0C00 > 0C00mov dh, al ; DX = 0001 > 0001mov al, ah ; AX = 0C00 > 0C0Cdec bp ; BP = 1FF9 > 1FF8retn==================stosb ; Store byte into ES:DI [AL = 0x0C]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 2227 0C==================dec dl ;DX = 0001 > 0000shl dh, 1 ; ;DX = 0000 > 0000retn==================lodsb ; Reads from DS:SI into AX [Read byte: 0x41] ; AX = 0C0C > 0C41dec bp ; BP = 1FF8 > 1FF7retn==================stosb ; Store byte into ES:DI [AL = 0x41]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 2227 0C41 ================= (DL == 0)loc_11477: mov dl, 7 ; DX = 0000 > 0007lodsb ; Reads from DS:SI into AX [Read byte: 0x11] ; AX = 0C41>0C11dec bp ; BP = 1FF8 > 1FF7mov dh, al ; DX = 0007 > 1107shl dh, 1 ; DX = 1107 > 2207retn==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 2227 0C41 ================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x8E] ; AX = 0C11 > 0C8Emov cl, 8 ; CX = 2006 > 2008 ; DX = 2207sub cl, dl ; CX = 2008 > 2001xor ah, ah ; AX = 0C8E > 008Eshl ax, cl ; AX = 008E > 011C ; DX = 2207or ah, dh ; AX = 011C > 231Cmov dh, al ; DX = 2207 > 1C07mov al, ah ; AX = 231C > 2323dec bp ; BP = 1FF8 > 1FF7retn==================stosb ; Store byte into ES:DI [AL = 0x23]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 2227 0C41 23 ==================dec dl ;DX = 1C07 > 1C06shl dh, 1 ; ;DX = 1C06 > 3806retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x81] ; AX = 2323 > 2381mov cl, 8 ; CX = 2001 > 2008 ; DX = 3806sub cl, dl ; CX = 2008 > 2002xor ah, ah ; AX = 2381 > 0081shl ax, cl ; AX = 0081 > 0204 ; DX = 3806or ah, dh ; AX = 0204 > 3A04mov dh, al ; DX = 3806 > 0406mov al, ah ; AX = 3A04 > 3A3Adec bp ; BP = 1FF7 > 1FF6retn==================stosb ; Store byte into ES:DI [AL = 0x3A]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000Stored:2800 8E41 2227 0C41 233A==================dec dl ;DX = 0406 > 0405shl dh, 1 ; ;DX = 0405 > 0805retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x80] ; AX = 3A3A > 3A80mov cl, 8 ; CX = 2002 > 2008 ; DX = 0805sub cl, dl ; CX = 2008 > 2003xor ah, ah ; AX = 3A80 > 0080shl ax, cl ; AX = 0080 > 0400 ; DX = 0805or ah, dh ; AX = 0400 > 0C00mov dh, al ; DX = 0805 > 0005mov al, ah ; AX = 0C00 > 0C0Cdec bp ; BP = 1FF6 > 1FF5retn==================stosb ; Store byte into ES:DI [AL = 0x0C]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C==================dec dl ;DX = 0005 > 0004shl dh, 1 ; ;DX = 0004 > 0004retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x00] ; AX = 0C0C > 0C00mov cl, 8 ; CX = 2003 > 2008 ; DX = 0004sub cl, dl ; CX = 2008 > 2004xor ah, ah ; AX = 0C00 > 0000shl ax, cl ; AX = 0000 > 0000 ; DX = 0004or ah, dh ; AX = 0000 > 0000mov dh, al ; DX = 0004 > 0004mov al, ah ; AX = 0000 > 0000dec bp ; BP = 1FF5 > 1FF4retn==================stosb ; Store byte into ES:DI [AL = 0x00]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C00 ==================dec dl ;DX = 0004 > 0003shl dh, 1 ; ;DX = 0003 > 0003retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0xA0] ; AX = 0000 > 00A0mov cl, 8 ; CX = 2004 > 2008 ; DX = 0003sub cl, dl ; CX = 2008 > 2005xor ah, ah ; AX = 00A0 > 00A0shl ax, cl ; AX = 00A0 > 0000 ; DX = 0003or ah, dh ; AX = 00A0 > 1400mov dh, al ; DX = 0003 > 0003mov al, ah ; AX = 1400 > 1414dec bp ; BP = 1FF? > 1FF1retn==================stosb ; Store byte into ES:DI [AL = 0x14]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C00 14==================dec dl ;DX = 0003 > 0002shl dh, 1 ; ;DX = 0002 > 0002retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x04] ; AX = 1414 > 1404mov cl, 8 ; CX = 2005 > 2008 ; DX = 0002sub cl, dl ; CX = 2008 > 2006xor ah, ah ; AX = 1404 > 0004shl ax, cl ; AX = 0004 > 0100 ; DX = 0002or ah, dh ; AX = 0100 > 0100mov dh, al ; DX = 0002 > 0002mov al, ah ; AX = 0100 > 0101dec bp ; BP = 1FF1 > 1FF0retn==================stosb ; Store byte into ES:DI [AL = 0x01]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C00 1401==================dec dl ;DX = 0002 > 0001shl dh, 1 ; ;DX = 0001 > 0001retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x2A] ; AX = 0101 > 012Amov cl, 8 ; CX = 2006 > 2008 ; DX = 0001sub cl, dl ; CX = 2008 > 2007xor ah, ah ; AX = 012A > 002Ashl ax, cl ; AX = 002A > 1500 ; DX = 0001or ah, dh ; AX = 1500 > 1500mov dh, al ; DX = 0001 > 0001mov al, ah ; AX = 1500 > 1515dec bp ; BP = 1FF0 > 1FEF==================stosb ; Store byte into ES:DI [AL = 0x15]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C00 1401 15==================dec dl ;DX = 0001 > 0000shl dh, 1 ; ;DX = 0000 > 0000retn================lodsb ; Reads from DS:SI into AX [Read byte: 0x00] ; AX = 1515 > 1500dec bp ; BP = 1FEF > 1FEEretn==================stosb ; Store byte into ES:DI [AL = 0x00]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C00 1401 1500================= (DL == 0)loc_11477: mov dl, 7 ; DX = 0000 > 0007lodsb ; Reads from DS:SI into AX [Read byte: 0x0C] ; AX = 1500>150Cdec bp ; BP = 1FEE > 1FEDmov dh, al ; DX = 0007 > 0C07shl dh, 1 ; DX = 0C07 > 1807retn================== (DL > 0)lodsb ; Reads from DS:SI into AX [Read byte: 0x00] ; AX = 150C > 1500mov cl, 8 ; CX = 2007 > 2008 ; DX = 1807sub cl, dl ; CX = 2008 > 2001xor ah, ah ; AX = 1500 > 0000shl ax, cl ; AX = 0000 > 0000 ; DX = 1807or ah, dh ; AX = 0000 > 1800mov dh, al ; DX = 1807 > 0007mov al, ah ; AX = 1800 > 1818dec bp ; BP = 1FED > 1FEC==================stosb ; Store byte into ES:DI [AL = 0x18]==================File Data Manipulation: VV1400 11C4 1110 9C18 4111 8E81 8000 A004 2A00 0C00 00AF 1000 1560 000A 8044 4000 2AFC 0605 5800 02A0 2530 0046 B100Stored:2800 8E41 2227 0C41 233A 0C00 1401 1500
5000 9001 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F 0000 008F
0000 008F 0000 7E01 0000 0102 0000 0304