Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.beginners Subject: Re: Linking Data files Date: Fri, 28 Nov 1997 14:19:43 +1300 Organization: Peace Computers NZ Ltd Lines: 93 Message-ID: <347E1C2F.167E@peace.co.nz> References: <01bcfb8f$d2e5c560$LocalHost@petecom> NNTP-Posting-Host: intro.peace.co.nz Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (X11; I; IRIX 6.2 IP22) Pete wrote: > > How do I load sprite and 3D data into the N-Z? N-Z? > Am I supposed to access the PC's file system from the code i.e fopen() (Or > similar) > Or, do I link the data to the executable in some way? If you 'compile' your sprite objects into .o files (convert raw source to a C char array), then you can link objects very easily. E.G char MyGraphic[] = { 0x34, 0x2a, 0x44..... }; You just reference the graphic as MyGraphic and you're away laughing. However, this can get to be a bit of a pain, especially when you adjust 3 pixels in your source BMP file, and you've got to reconvert the raw file to C. In addition, you can only have 64K of static data linked to your executable (or is that 64K of global variables... damn, can't remember), so when you start writing large games, this method won't work. The alternatice method that everyone uses is: Make your graphic/sound/3D file. In your C, make a #define like: #define MY_GRAPHIC 0x80100000 This is an address in Yaroze memory to place your graphic. In your C program, reference the graphic as MY_GRAPHIC. Make the program. Upload the CODE for the program (what gcc and the linker generated) and the GRAPHIC itself separately. Load the graphic to the address you specified. A SIOCONS script to do this might look like: local dload c:\graphics\my_wizard.tim 80100000 local load c:\psx_code\my_program go This will load the file c:\graphics\my_wizard.tim to yaroze address 0x80100000, and the code file c:\psx_code\my_program to wherever you linked the program to. (When you link the program, you specify which address you want, and the 'load' function puts it there). The "go" part starts the execution of your program. Because your program referenced MY_GRAPHIC, which was really address 0x80100000, and you loaded your graphic to 0x80100000 with SIOCONS, your program will be accessing the graphic data just as if you had linked the data to be at 0x80100000. Valid address ranges are from 0x80090000 to 0x801fffff. Most people load their data at 0x80090000 and their code at 0x80100000. You have to manually make sure that multiple data loads won't overlap other data, so that means you have to sit down with a calculator and figure out the sizes and addresses of all the data. Cheers, James -- ==PEACE COMPUTERS ==James.Russell@peace.co.nz - 64(9)3730400 -Fax 64(9)3730401 A poor man's holodeck: A tab of acid and a glass of water.