| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		ccovell Regular
  
 
  Joined: 19 Dec 2005 Posts: 100 Location: Japan
  | 
		
			
				 Posted: Wed Nov 15, 2006 3:42 am    Post subject: BRAM code | 
				     | 
			 
			
				
  | 
			 
			
				I'm going to try adding some BRAM-accessing code to my game, so...
 
 
Has anyone ever done any programming to interface with the BRAM area?  Like, searching through it, adding/deleting files?  Are there any pitfalls I should be worrying about? _________________ http://www.chrismcovell.com | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		David Shadoff Regular
  
 
  Joined: 10 May 2002 Posts: 83 Location: Toronto, Ontario, Canada
  | 
		
			
				 Posted: Wed Nov 15, 2006 7:43 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				How are you planning on accessing it - directly, or via CDROM system card routines ?
 
 
If you are accessing it directly, you need to be in CSL slow CPU mode... but I've never tried using the system card's routines.
 
 
I also have information on the link-list format somewhere, but I'm pretty sure you can figure that out for yourself without my help...
 
 
Oh yeah, and I recall while single-stepping through games a while back that there appeared to be a write-protect latch that needed to be hit... although that didn't appear to do anything (it seemed like maybe something from a preliminary devkit maybe, which wasn't implemented in the commercial design).
 
 
Maybe Bt has done some of this stuff... | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ccovell Regular
  
 
  Joined: 19 Dec 2005 Posts: 100 Location: Japan
  | 
		
			
				 Posted: Wed Nov 15, 2006 2:31 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				I'm going to be implementing it directly (through my own code).  I know I have to switch to slow CPU mode, but I'm wondering if it's possible to do BRAM-RAM DMA transfers in that mode...?
 
 
I think I understand the format OK; I remember chatting with you on IRC as I looked at it.  I think I understand the header info, and checksum (which is actually a checksubtract, since it subtracts all bytes in a save file from $0000.  I'll have to refresh my memory on stuff like that.
 
 
I guess looking at how some games do it wouldn't hurt. _________________ http://www.chrismcovell.com | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		dmichel Admin
  
 
  Joined: 04 Apr 2002 Posts: 1166 Location: France
  | 
		
			
				 Posted: Wed Nov 15, 2006 11:57 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				I don't remember who wrote it but don't we have a BRAM lib in HuC? It's written in ASM if I remember right. _________________ David Michel | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		David Shadoff Regular
  
 
  Joined: 10 May 2002 Posts: 83 Location: Toronto, Ontario, Canada
  | 
		
			
				 Posted: Thu Nov 16, 2006 4:39 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Geez David, I think you're right.
 
 
What's really strange is... I think I wrote part of it (but I didn't work too hard at testing it). | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		nodtveidt Elder
  
 
  Joined: 27 Dec 2004 Posts: 414 Location: Isla del Encanto
  | 
		
			
				 Posted: Thu Nov 16, 2006 1:19 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Yes, HuC has BRAM functions in the clib (since version 1.5, with some functions appearing in 3.03). I've used them for ages. _________________ Frozen Utopia
 
Retro gaming was never this cool. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ccovell Regular
  
 
  Joined: 19 Dec 2005 Posts: 100 Location: Japan
  | 
		
			
				 Posted: Fri Dec 08, 2006 2:59 pm    Post subject: HuC BRAM libs have a bug!? | 
				     | 
			 
			
				
  | 
			 
			
				Hi, I'm having fun (?) using the BRAM interfacing routines from HuC, but I think I've discovered a serious bug in the routines that use bm_open().
 
The function goes like this: 	  | Code: | 	 		  ; bm_open(char *name [bx])
 
; ---
 
; Internal function to obtain access to a named file
 
...
 
     ; -- compare names
 
     cly
 
     ldx   #4
 
.l2:     lda   [_bx],Y
 
     sxy
 
     cmp   [_si],Y
 
... | 	  
 
 
But the functions bm_delete(), bm_read(), and bm_write() store the name in AX (comments mine):
 
 	  | Code: | 	 		  lib2_bm_delete:
 
   __stw   <_ax      ;Is this for real????
 
     jsr   lib2_bm_open
 
     bcs   .out
 
... | 	  
 
 
I was getting file deletion errors every time I tried, and then I noticed this mistake in the HuC Libs.  Actually, several other functions also say that parameters are passed through [bx] but the functions that call them pass them through AX.  Whoever actually wrote the BRAM libs might want to look into this. _________________ http://www.chrismcovell.com | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |