Hello everyone.
I actually got a SegaCD manual, and I finally got a small project running correcly; however, the manual doesn't explains anything related to how to use the BRAM.
Anyone could give me a clue about this?
BRAM's usage
Moderator: Mask of Destiny
I don't know what I'm talking about. At all. But, until a proper answer comes along here is a quote from Eidolon's Inn:
The Genesis 68K has access to the BB RAM at 0x600000 through 0x603FFF on odd addresses and can read it at any time, but must set bit 0 of 0x7FFFFF to a 1 to write enable the BB RAM and a 0 to write protect it.
Apparently that answer only applies to the back RAM cart and not internal. Also, everyone thinks accessing BRAM directly is a big no-no. BIOS calls seem to be the way to go.
The Genesis 68K has access to the BB RAM at 0x600000 through 0x603FFF on odd addresses and can read it at any time, but must set bit 0 of 0x7FFFFF to a 1 to write enable the BB RAM and a 0 to write protect it.
Apparently that answer only applies to the back RAM cart and not internal. Also, everyone thinks accessing BRAM directly is a big no-no. BIOS calls seem to be the way to go.
Internal Backup RAM is 8KB and can be accessed at $FE0000-$FE1FFFF (and presumably mirrored in neighbor areas since for example, Wonder Mega / X'Eye BIOS access it at $FD0000-$FD1FFFF).
However, it is normally formatted (last chunk of backup RAM holds a basic entry table) so you can't directly write to it without messing with existing files.
That's why the manual states you must use BIOS calls (BRMXXXX) to access it and they are described, look better (chap 7 of MEGA-CD BIOS MANUAL, whole doc can be found in this thread: viewtopic.php?t=375)
However, it is normally formatted (last chunk of backup RAM holds a basic entry table) so you can't directly write to it without messing with existing files.
That's why the manual states you must use BIOS calls (BRMXXXX) to access it and they are described, look better (chap 7 of MEGA-CD BIOS MANUAL, whole doc can be found in this thread: viewtopic.php?t=375)
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
For the BRAM in the SCD, you must call the BIOS functions.
Code: Select all
BRMINIT EQU $0000
BRMSTAT EQU $0001
BRMSERCH EQU $0002
BRMREAD EQU $0003
BRMWRITE EQU $0004
BRMDEL EQU $0005
BRMFORMAT EQU $0006
BRMDIR EQU $0007
BRMVERIFY EQU $0008
_BURAM EQU $00005F16
;-----------------------------------------------------------------------
; Back-Up RAM
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; NOTE: The backup ram on the super target devlopment systems is write
; protected if the production Boot Rom is being used. A
; Development Boot Rom must be obtained before the backup ram can
; be used.
;
; The name of the save game files must be registered with SOJ before
; a game can be shipped.
;
; Please make sure to read the CD Software Standards section in the
; manual. There is a section on backup ram standards that must be
; followed.
;
; For a full description of each Back-Up Ram function, see the BIOS
; section of the CD manual.
;
; Some of the Back-Up RAM functions require a string buffer to
; be passed into the function. Some of these functions return
; 0 terminated text strings.
;-------------------------------------------------------------------------
;-----------------------------------------------------------------------
; BURAM - Calls the Backup Ram with a specified function number.
; Assumes that all preparatory and cleanup work is done externally.
;
; input:
; fcode Backup Ram function code
;
; returns:
; nothing
;-----------------------------------------------------------------------
BURAM macro fcode
move.w \fcode,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMINIT - Prepares to write into and read from Back-Up Ram.
;
; input:
; a0.l pointer to scratch ram (size $640 bytes).
;
; a1.l pointer to the buffer for display strings (size: 12 bytes)
;
; returns:
; cc SEGA formatted RAM is present
; cs Not formatted or no RAM
; d0.w size of backup RAM $2(000) ~ $100(000) bytes
; d1.w 0 : No RAM
; 1 : Not Formatted
; 2 : Other Format
; a1.l pointer to display strings
;-----------------------------------------------------------------------
BIOS_BRMINIT macro
BURAM #BRMINIT
endm
;-----------------------------------------------------------------------
; BIOS_BRMSTAT - Returns how much Back-Up RAM has been used.
;
; input:
; a1.l pointer to display string buffer (size: 12 bytes)
;
; returns:
; d0.w number of blocks of free area
; d1.w number of files in directory
;-----------------------------------------------------------------------
BIOS_BRMSTAT macro
BURAM #BRMSTAT
endm
;-----------------------------------------------------------------------
; BIOS_BRMSERCH - Searches for the desired file in Back-Up Ram. The file
; names are 11 ASCII characters terminated with a 0.
;
; input:
; a0.l pointer to parameter (file name) table
; file name = 11 ASCII chars [0~9 A~Z_] 0 terminated
;
; returns:
; cc file name found
; cs file name not found
; d0.w number of blocks
; d1.b MODE
; 0 : normal
; -1 : data protected (with protect function)
; a0.l backup ram start address for search
;-----------------------------------------------------------------------
BIOS_BRMSERCH macro
BURAM #BRMSERCH
endm
;-----------------------------------------------------------------------
; BIOS_BRMREAD - reads data from Back-Up RAM.
;
; input:
; a0.l pointer to parameter (file name) table
; a1.l pointer to write buffer
;
; returns:
; cc Read Okay
; cs Error
; d0.w number of blocks
; d1.b MODE
; 0 : normal
; -1 : data protected
;-----------------------------------------------------------------------
BIOS_BRMREAD macro
BURAM #BRMREAD
endm
;-----------------------------------------------------------------------
; BIOS_BRMWRITE - Writes data in Back-Up RAM.
;
; input:
; a0.l pointer to parameter (file name) table
; flag.b $00: normal
; $FF: encoded (with protect function)
; block_size.w $00: 1 block = $40 bytes
; $FF: 1 block = $20 bytes
; a1.l pointer to save data
;
; returns:
; cc Okay, complete
; cs Error, cannot write in the file
;-----------------------------------------------------------------------
BIOS_BRMWRITE macro
BURAM #BRMWRITE
endm
;-----------------------------------------------------------------------
; BIOS_BRMDEL - Deletes data on Back-Up Ram.
;
; input:
; a0.l pointer to parameter (file name) table
;
; returns:
; cc deleted
; cs not found
;-----------------------------------------------------------------------
BIOS_BRMDEL macro
BURAM #BRMDEL
endm
;-----------------------------------------------------------------------
; BIOS_BRMFORMAT - First initializes the directory and then formats the
; Back-Up RAM
;
; Call BIOS_BRMINIT before calling this function
;
; input:
; none
;
; returns:
; cc Okay, formatted
; cs Error, cannot format
;-----------------------------------------------------------------------
BIOS_BRMFORMAT macro
BURAM #BRMFORMAT
endm
;-----------------------------------------------------------------------
; BIOS_BRMDIR - Reads directory
;
; input:
; d1.l H: number of files to skip when all files cannot be read in one try
; L: size of directory buffer (# of files that can be read in the
; directory buffer)
; a0.l pointer to parameter (file name) table
; a1.l pointer to directory buffer
;
; returns:
; cc Okay, complete
; cs Full, too much to read into directory buffer
;-----------------------------------------------------------------------
BIOS_BRMDIR macro
BURAM #BRMDIR
endm
;-----------------------------------------------------------------------
; BIOS_BRMVERIFY - Checks data written on Back-Up Ram.
;
; input:
; a0.l pointer to parameter (file name) table
; flag.b $00: normal
; $FF: encoded (with protect function)
; block_size.w $00: 1 block = $40 bytes
; $FF: 1 block = $20 bytes
; a1.l pointer to save data
;
; returns:
; cc Okay
; cs Error
; d0.w Error Number
; -1 : Data does not match
; 0 : File not found
;-----------------------------------------------------------------------
BIOS_BRMVERIFY macro
BURAM #BRMVERIFY
endm