{"id":11,"date":"2011-05-18T18:02:43","date_gmt":"2011-05-18T18:02:43","guid":{"rendered":"https:\/\/blogs.scummvm.org\/tiqpit\/?p=11"},"modified":"2022-05-22T13:11:23","modified_gmt":"2022-05-22T13:11:23","slug":"briefly-about-boot-sequences","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/tiqpit\/2011\/05\/18\/briefly-about-boot-sequences\/","title":{"rendered":"Briefly about boot sequences"},"content":{"rendered":"<p>Generally, once the BIOS, the start-up program of PC, has performed its initialization procedures and found a bootable device, in this case a floppy disk drive, it loads the first sector of a floppy to the address\u00a0<b>0000:7C00<\/b>\u00a0and transfers execution to that address (or any other address that points to the same physical location, I guess, which would mean that you cannot be sure of the exact Code Segment at this point). After this, the boot sector program loads the main program into memory, typically by using\u00a0<b>INT 13H<\/b>\u00a0to read sectors from disk, and finally begins to execute the main program.<\/p>\n<p>I expected that the one 512-byte boot sector would be enough to load the main program into memory, but alas, all of the three games seem to be wastefully loading an intermediate program from another sector (or even sectors) to do the loading! By the way, the data on the disk is ordered so that the &#8220;head&#8221; is flipped after a track (9 sectors) is read. The disk format is 5.25-inch, 40-track, double-density (40 tracks, 2 heads, 9 sectors per track) with the total capacity of 360KB. There are probably a lot of details to be found about the loader program, some of them maybe explaining why it spans multiple sectors, but I figured it is easier to just let the loader do its job, and when the game is running use the DosBox debugger to dump the one 64KB segment, containing the whole main interpreter program, to a file.<\/p>\n<p>A tested algorithm to find the AGI core with pointer tables to instruction handlers is to do the following in DosBox debugger:\u00a0<b>(1)<\/b>\u00a0Set breakpoints to memory locations that contain INT 13H (used to load data from disk),\u00a0<b>(2)<\/b>\u00a0in the game move to another room so that new data needs to be loaded, firing a breakpoint, and\u00a0<b>(3)<\/b>\u00a0step through, possibly using breakpoints, until the core is found.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generally, once the BIOS, the start-up program of PC, has performed its initialization procedures and found a bootable device, in this case a floppy disk drive, it loads the first sector of a floppy to the address\u00a00000:7C00\u00a0and transfers execution to that address (or any other address that points to the same physical location, I guess, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":12,"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/posts\/11\/revisions\/12"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tiqpit\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}