#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\SETUP05.ICO #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region ;************ Includes ************ #Include #Include #EndRegion ;************ Includes ************ Global $hGui, $idEdit1[13], $idEdit2[13], $idEdit3[13], $idEdit4[13] Global $aAdress[13] = [ 'adress', '00', '04', '06', '08', '0A', '0C', '0E', '10', '12', '16', '36', '56' ] Global $aDescription[13] = [ 'Description', 'MagicID', 'Version', 'DataOffset', 'LoadAddress', 'InitAddress', 'PlayAddress', 'Songs Count', 'StartSong', 'Speed', 'Name', 'Author', 'Copyright' ] Global $bSid, $hFileOpen, $sHeader $hGui = GUICreate ( 'Sid Header Version 1 Viewer : Drag a Sid file on the Gui !', 910, 360, -1, -1, -1, BitOR ( $WS_EX_ACCEPTFILES, $WS_EX_TOPMOST ) ) GUICtrlCreateLabel ( '', 0, 0, 910, 360 ) GUICtrlSetState ( -1, $GUI_DROPACCEPTED ) For $i = 0 To 12 $idEdit1[$i] = GUICtrlCreateEdit ( $aAdress[$i], 20, 20 +$i*25, 45, 18, BitOR ( 2048, 1 ) ) ; $ES_READONLY, $ES_CENTER GUICtrlSetBkColor ( -1, 0xFFFFFF ) GUICtrlSetFont ( -1, 8, 600 ) $idEdit4[$i] = GUICtrlCreateEdit ( $aDescription[$i], 80, 20 +$i*25, 80, 18, BitOR ( 2048, 0 ) ) ; $ES_READONLY, $ES_LEFT GUICtrlSetBkColor ( -1, 0xFFFFFF ) GUICtrlSetFont ( -1, 8, 600 ) $idEdit2[$i] = GUICtrlCreateEdit ( '', 180, 20 +$i*25, 480, 18, BitOR ( 2048, 2 ) ) ; $ES_READONLY, $ES_RIGHT GUICtrlSetBkColor ( -1, 0xFFFFFF ) GUICtrlSetFont ( -1, 8, 600 ) If $i = 7 Then GUICtrlSetColor ( -1, 0xFF0000 ) If $i = 2 Then GUICtrlSetColor ( -1, 0x0000FF ) $idEdit3[$i] = GUICtrlCreateEdit ( '', 680, 20 +$i*25, 210, 18, BitOR ( 2048, 2 ) ) ; $ES_READONLY, $ES_RIGHT GUICtrlSetBkColor ( -1, 0xFFFFFF ) GUICtrlSetFont ( -1, 8, 600 ) Next GUICtrlSetData ( $idEdit2[0], 'Binary' ) GUICtrlSetData ( $idEdit3[0], 'Value' ) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $iCount = 128 $hFileOpen = FileOpen ( @GUI_DragFile, 16 ) If $hFileOpen <> -1 Then $bSid = FileRead ( $hFileOpen, $iCount ) FileClose ( $hFileOpen ) ; +00 four byte long ASCII character string $sHeader = StringTrimLeft ( BinaryMid ( $bSid, 1, 4 ), 2 ) Switch $sHeader Case 50534944, 52534944 ; PSID : 50534944, RSID = 52534944 WinSetTitle ( $hGui, '', 'Sid Header Version 1 Viewer : ' & @GUI_DragFile ) GUICtrlSetData ( $idEdit2[1], $sHeader ) GUICtrlSetData ( $idEdit3[1], BinaryToString ( BinaryMid ( $bSid, 1, 4 ), 1 ) ) ;~ +04 WORD version Available version number can either be 0001 or 0002. Headers of version 2 provide additional fields. RSID and PSID v2NG files must have 0002 here. GUICtrlSetData ( $idEdit2[2], StringTrimLeft ( BinaryMid ( $bSid, 5, 2 ), 2 ) ) GUICtrlSetData ( $idEdit3[2], Execute ( BinaryMid ( $bSid, 5, 2 ) ) ) ;~ +06 WORD dataOffset This is the offset from the start of the file to the C64 binary data area. Because of the fixed size of the header, this is either 0x0076 for version 1 and 0x007C for version 2. GUICtrlSetData ( $idEdit2[3], StringTrimLeft ( BinaryMid ( $bSid, 7, 2 ), 2 ) ) GUICtrlSetData ( $idEdit3[3], Execute ( BinaryMid ( $bSid, 7, 2 ) ) ) ;~ +08 WORD loadAddress The C64 memory location where to put the C64 data. 0 means the data are in original C64 binary file format, i.e. the first two bytes of the data contain the little-endian load address (low byte, high byte). ;~ This must always be true for RSID files. Furthermore, the actual load address must NOT be less than $07E8 in RSID files. GUICtrlSetData ( $idEdit2[4], StringTrimLeft ( BinaryMid ( $bSid, 9, 2 ), 2 ) ) GUICtrlSetData ( $idEdit3[4], Execute ( BinaryMid ( $bSid, 9, 2 ) ) ) ;~ +0A WORD initAddress The start address of the machine code subroutine that initializes a song, accepting the contents of the 8-bit 6510 Accumulator as the song number parameter. 0 means the address is equal to the effective load address. GUICtrlSetData ( $idEdit2[5], StringTrimLeft ( BinaryMid ( $bSid, 11, 2 ), 2 ) ) GUICtrlSetData ( $idEdit3[5], Execute ( BinaryMid ( $bSid, 11, 2 ) ) ) ;~ +0C WORD playAddress The start address of the machine code subroutine that can be called frequently to produce a continuous sound. 0 means the initialization subroutine is expected to install an interrupt handler, ;~ which then calls the music player at some place. This must always be true for RSID files. GUICtrlSetData ( $idEdit2[6], StringTrimLeft ( BinaryMid ( $bSid, 13, 2 ), 2 ) ) GUICtrlSetData ( $idEdit3[6], Execute ( BinaryMid ( $bSid, 13, 2 ) ) ) ;~ +0E WORD songs The number of songs (or sound effects) that can be initialized by calling the init address. The minimum is 1. The maximum is 256. GUICtrlSetData ( $idEdit2[7], StringTrimLeft ( BinaryMid ( $bSid, 15, 2 ), 2 ) ) ;~ GUICtrlSetData ( $idEdit3[7], BinaryToString ( BinaryMid ( $bSid, 15, 2 ), 1 ) ) GUICtrlSetData ( $idEdit3[7], Execute ( BinaryMid ( $bSid, 15, 2 ) ) ) ;~ +10 WORD startSong The song number to be played by default. This value is optional. It often specifies the first song you would hear upon starting the program is has been taken from. It has a default of 1. GUICtrlSetData ( $idEdit2[8], StringTrimLeft ( BinaryMid ( $bSid, 17, 2 ), 2 ) ) GUICtrlSetData ( $idEdit3[8], Execute ( BinaryMid ( $bSid, 17, 2 ) ) ) ;~ +12 LONGWORD speed GUICtrlSetData ( $idEdit2[9], StringTrimLeft ( BinaryMid ( $bSid, 19, 4 ), 2 ) ) GUICtrlSetData ( $idEdit3[9], Execute ( BinaryMid ( $bSid, 19, 4 ) ) ) ;~ +16 name GUICtrlSetData ( $idEdit2[10], StringTrimLeft ( BinaryMid ( $bSid, 23, 32 ), 2 ) ) GUICtrlSetData ( $idEdit3[10], BinaryToString ( BinaryMid ( $bSid, 23, 32 ), 1 ) ) ;~ +36 author GUICtrlSetData ( $idEdit2[11], StringTrimLeft ( BinaryMid ( $bSid, 55, 32 ), 2 ) ) GUICtrlSetData ( $idEdit3[11], BinaryToString ( BinaryMid ( $bSid, 55, 32 ), 1 ) ) ;~ +56 copyright GUICtrlSetData ( $idEdit2[12], StringTrimLeft ( BinaryMid ( $bSid, 87, 32 ), 2 ) ) GUICtrlSetData ( $idEdit3[12], BinaryToString ( BinaryMid ( $bSid, 87, 32 ), 1 ) ) Case Else MsgBox ( 262144+16, 'Error', 'It is not a SID file !', 5 ) EndSwitch Else MsgBox ( 262144+16, 'Error', 'Unable to read this file !', 5 ) EndIf EndSwitch WEnd