Register - Login
Views: 99390918
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
04-24-22 09:21:28 AM
Jul - The Cutting Room Floor - Undocumented Mega CD BIOS functions New poll - New thread - New reply
Next newer thread | Next older thread
Sik

Level: 23


Posts: 65/107
EXP: 64770
For next: 2953

Since: 12-07-12


Since last post: 3.3 years
Last activity: 1.2 years

Posted on 11-18-13 06:58:42 PM Link | Quote
Yesterday I was wondering about how does the Mega CD BIOS store filenames in the back-up RAM, since it only reserves 3 blocks (192 bytes) to store all that data (later it turned out to use only two blocks (128 bytes) for filenames, what?). At first I considered taking snapshots of the back-up RAM and looking at it to see if I could find a pattern to the data, but then I realized it'd be easier to just diassemble the BIOS.

So, I go dump the BIOS (savestate!), then load it in the disassembler, and look in cdbios.inc (the assembly file with all the BIOS definitions) to find where the back-up RAM functions are. I go there, and eventually end up in a jump table (one jump per function), but then...


ROM:00004836 @JumpTable:

ROM:00004836 bra.w BRMINIT
ROM:0000483A ; ---------------------------------------------------------------------------
ROM:0000483A bra.w BRMSTAT
ROM:0000483E ; ---------------------------------------------------------------------------
ROM:0000483E bra.w BRMSERCH
ROM:00004842 ; ---------------------------------------------------------------------------
ROM:00004842 bra.w BRMREAD
ROM:00004846 ; ---------------------------------------------------------------------------
ROM:00004846 bra.w BRMWRITE
ROM:0000484A ; ---------------------------------------------------------------------------
ROM:0000484A bra.w BRMDEL
ROM:0000484E ; ---------------------------------------------------------------------------
ROM:0000484E bra.w BRMFORMAT
ROM:00004852 ; ---------------------------------------------------------------------------
ROM:00004852 bra.w BRMDIR
ROM:00004856 ; ---------------------------------------------------------------------------
ROM:00004856 bra.w BRMVERIFY
ROM:0000485A ; ---------------------------------------------------------------------------
ROM:0000485A bra.w BRMUNK1 ; Doesn't have a name
ROM:0000485E ; ---------------------------------------------------------------------------
ROM:0000485E bra.w BRMUNK2 ; Doesn't have a name


Wut? There are two more functions in the jump table than are present in cdbios.inc. Huh, so yeah, looks like we have two "unused" functions in the Mega CD BIOS (this is from the "Mega-CD Model 1 BIOS V1.00 (J) [!].bin" firmware, just so you know).

Here's the code for the two functions. They're... pretty useless, and blatantly debug-like. BRMUNK1 simply reads the first block, while BRMUNK2 writes into it. This completely by-passes the filesystem, so you have been warned (though the BIOS seems to like skipping this block when storing files...)


ROM:00004862 ; BRMUNK1 (debug?)

ROM:00004862 ; Reads from the first block of BRAM
ROM:00004862 ;
ROM:00004862 ; in a0.l ... Buffer
ROM:00004862
ROM:00004862 ; =============== S U B R O U T I N E =======================================
ROM:00004862
ROM:00004862
ROM:00004862 BRMUNK1: ; CODE XREF: BURAM+3Cj
ROM:00004862 movea.l BRAMAddr,a1
ROM:00004866 move.w #$40,d1 ; '@'
ROM:0000486A exg a0,a1
ROM:0000486C bsr.w LongUnmovep
ROM:00004870 rts
ROM:00004870 ; End of function BRMUNK1
ROM:00004870
ROM:00004872 ; BRMUNK2 (debug?)
ROM:00004872 ; Writes into the first block of BRAM
ROM:00004872 ;
ROM:00004872 ; in a0.l ... Data
ROM:00004872
ROM:00004872 ; =============== S U B R O U T I N E =======================================
ROM:00004872
ROM:00004872
ROM:00004872 BRMUNK2: ; CODE XREF: BURAM+40j
ROM:00004872 movem.l a2-a3,-(sp) ; Save registers
ROM:00004876
ROM:00004876 movea.l a0,a3 ; Write to the first block
ROM:00004878 movea.l BRAMAddr,a1
ROM:0000487C movea.l a1,a2
ROM:0000487E move.w #$40,d1 ; '@'
ROM:00004882 exg a0,a1
ROM:00004884 bsr.w LongMovep
ROM:00004888
ROM:00004888 movep.l 0(a2),d0 ; Make sure the write worked
ROM:0000488C cmp.l (a3),d0
ROM:0000488E beq.s @Success
ROM:00004890 move #1,ccr
ROM:00004894
ROM:00004894 @Success: ; CODE XREF: BRMUNK2+1Cj
ROM:00004894 movem.l (sp)+,a2-a3 ; Restore registers
ROM:00004898 rts ; End of subroutine
ROM:00004898 ; End of function BRMUNK2


(ignore the names of LongMovep and LongUnmovep, those two are just functions that read/write arbitrary amount of data from every other byte, I called them like that because they are like the instruction MOVEP but for longer areas)

By the way, those addresses are from the viewpoint of the sub-CPU (i.e. the 68000 running in the Mega CD side). The BIOS is loaded at the beginning of PRG-RAM.
Next newer thread | Next older thread
Jul - The Cutting Room Floor - Undocumented Mega CD BIOS functions New poll - New thread - New reply


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

26 database queries.
Query execution time:  0.073384 seconds
Script execution time:  0.005428 seconds
Total render time:  0.078812 seconds


TidyHTML vomit below
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 119 column 11 - Warning: <form> isn't allowed in <table> elements
line 118 column 10 - Info: <table> previously mentioned
line 120 column 11 - Warning: missing <tr>
line 120 column 119 - Warning: missing </font> before </td>
line 124 column 16 - Warning: plain text isn't allowed in <tr> elements
line 120 column 11 - Info: <tr> previously mentioned
line 125 column 68 - Warning: missing </nobr> before </td>
line 141 column 68 - Warning: missing </nobr> before <tr>
line 147 column 35 - Warning: missing <tr>
line 147 column 50 - Warning: missing </font> before </td>
line 148 column 37 - Warning: unescaped & or unknown entity "&id"
line 147 column 206 - Warning: missing </font> before </table>
line 149 column 35 - Warning: missing <tr>
line 149 column 50 - Warning: missing </font> before </td>
line 149 column 91 - Warning: missing </font> before </table>
line 156 column 9 - Warning: <div> isn't allowed in <table> elements
line 152 column 17 - Info: <table> previously mentioned
line 158 column 9 - Warning: missing <tr>
line 176 column 13 - Warning: missing <tr>
line 177 column 102 - Warning: unescaped & or unknown entity "&postid"
line 258 column 17 - Warning: missing <tr>
line 258 column 17 - Warning: discarding unexpected <table>
line 261 column 35 - Warning: missing <tr>
line 261 column 50 - Warning: missing </font> before </td>
line 261 column 91 - Warning: missing </font> before </table>
line 263 column 35 - Warning: missing <tr>
line 263 column 50 - Warning: missing </font> before </td>
line 264 column 37 - Warning: unescaped & or unknown entity "&id"
line 263 column 206 - Warning: missing </font> before </table>
line 265 column 17 - Warning: discarding unexpected </textarea>
line 265 column 28 - Warning: discarding unexpected </form>
line 265 column 35 - Warning: discarding unexpected </embed>
line 265 column 43 - Warning: discarding unexpected </noembed>
line 265 column 53 - Warning: discarding unexpected </noscript>
line 265 column 64 - Warning: discarding unexpected </noembed>
line 265 column 74 - Warning: discarding unexpected </embed>
line 265 column 82 - Warning: discarding unexpected </table>
line 265 column 90 - Warning: discarding unexpected </table>
line 267 column 9 - Warning: missing </font> before <table>
line 279 column 25 - Warning: discarding unexpected </font>
line 288 column 37 - Warning: discarding unexpected </font>
line 266 column 1 - Warning: missing </center>
line 120 column 63 - Warning: <img> lacks "alt" attribute
line 125 column 19 - Warning: <td> attribute "width" has invalid value "120px"
line 125 column 93 - Warning: <img> lacks "alt" attribute
line 141 column 19 - Warning: <td> attribute "width" has invalid value "120px"
line 141 column 98 - Warning: <img> lacks "alt" attribute
line 148 column 44 - Warning: <img> proprietary attribute value "absmiddle"
line 148 column 142 - Warning: <img> proprietary attribute value "absmiddle"
line 148 column 246 - Warning: <img> proprietary attribute value "absmiddle"
line 161 column 22 - Warning: <img> lacks "alt" attribute
line 161 column 63 - Warning: <img> lacks "alt" attribute
line 161 column 112 - Warning: <img> lacks "alt" attribute
line 161 column 162 - Warning: <img> lacks "alt" attribute
line 172 column 15 - Warning: <img> lacks "alt" attribute
line 264 column 44 - Warning: <img> proprietary attribute value "absmiddle"
line 264 column 142 - Warning: <img> proprietary attribute value "absmiddle"
line 264 column 246 - Warning: <img> proprietary attribute value "absmiddle"
line 273 column 25 - Warning: <img> lacks "alt" attribute
line 278 column 267 - Warning: <img> lacks "alt" attribute
line 149 column 50 - Warning: trimming empty <font>
line 258 column 17 - Warning: trimming empty <tr>
line 261 column 50 - Warning: trimming empty <font>
line 125 column 68 - Warning: <nobr> is not approved by W3C
line 141 column 68 - Warning: <nobr> is not approved by W3C
line 177 column 27 - Warning: <nobr> is not approved by W3C
Info: Document content looks like HTML5
Info: No system identifier in emitted doctype
Tidy found 64 warnings and 0 errors!


The alt attribute should be used to give a short description
of an image; longer descriptions should be given with the
longdesc attribute which takes a URL linked to the description.
These measures are needed for people using non-graphical browsers.

For further advice on how to make your pages accessible
see http://www.w3.org/WAI/GL.
You are recommended to use CSS to specify the font and
properties such as its size and color. This will reduce
the size of HTML files and make them easier to maintain
compared with using <FONT> elements.

You are recommended to use CSS to control line wrapping.
Use "white-space: nowrap" to inhibit wrapping in place
of inserting <NOBR>...</NOBR> into the markup.

About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
Latest HTML specification: http://dev.w3.org/html5/spec-author-view/
Validate your HTML documents: http://validator.w3.org/nu/
Lobby your company to join the W3C: http://www.w3.org/Consortium

Do you speak a language other than English, or a different variant of
English? Consider helping us to localize HTML Tidy. For details please see
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md