will my code work?

mrkotfw

Mid Boss
Code:
/* ----------------------------------------------

 * Sega Saturn Smpc Check 0.1

 * ---------------------------------------------- */

	#include "define.c"

int ss_main(void)

{

	int i = 0;

	int error = 3;

	for(i = 0; i < error; i++)

	slColRAMMode(CRM16_1024);

 slBack1ColSet((void *)BACK_COL_ADR,0x8000);

	/* ----------------------------------------

 * Smpc Check 1

 * ---------------------------------------- */

 	{

  slInitSystem(TV_320x224, NULL, 1);

  slGetLanguage();

  if(slGetLanguage() != SMPC_ESPANOL) {

  	slSetLanguage(SMPC_ESPANOL);

  }

  i++;

  slSetSmpcMemory();

  slCurColor(C_RGB(25,0,0));

  	slPrint("Sega Saturn Info Corecto", slLocate(1,1));

  	slPrint(i,slLocate(27,1));

   slSynch();

 	}

	/* ----------------------------------------

 * Smpc Check 2

 * ---------------------------------------- */

 	{

  SmpcDateTime * date = &(Smpc_Status->rtc);

  	date->year = 0x1999;

  	date->month = SMPC_FRI | SMPC_DEC;

  	date->date = 0x31;

  	date->hour = 0x23;

  	date->minute = 0x59;

  	date->second = 0x59;

  i++;

  slSetDateTime();

  slCurColor(C_RGB(25,0,0));

  	slPrint("Sega Saturn Info Corecto", slLocate(1,1));

  	slPrint(i,slLocate(27,1));

   slSynch();

 	}

	/* ----------------------------------------

 * Smpc Check 3

 * ---------------------------------------- */

 	{

  if(Per_Connect1) {

  	PerDigital * pad;

  	pad = Smpc_Peripheral + 0;

  	if(!(pad->data & PER_DGT_ST)) {

   return;

  	}

   else if(!Per_Connect1)

  i--;

  slGetStatus();

  slCurColor(C_RGB(25,0,0));

  	slPrint("Sega Saturn Info Corecto", slLocate(1,1));

  	slPrint(i,slLocate(27,1));

   slSynch();

 	}

 }

	}

well my problem is i want to do: printf("%d",i); so i can print the int i; but the problem is saturn probaly doesn't like it. slPrint(i,slLocate(27,1)); doesnt work either, is there another way? oh also my rest of my code looks good? any suggestions please feel free to suggest! Thank you.
 
slPrint can only print strings. Check out sprintf. As for the reast of your code, you're probably missing a set of braces around the if (i...) loop at the top. Now the loop only executes the statement slColRAMMode(CRM16_1024) three times. Also, while it is perfectly legal C to open arbitrary compound statements it is very unusual to do so and IMO hurts legibility if used unnecessarily. The rest I can't comment on as I don't know enough SGL.
 
the SGL provides slPrintFX, and slPrintHex to print numerical values, but if you use them you'll have to use SGL's conversion macros too. Using sprintf seems to be a better idea.

Code:
char str[SIZE];

sprintf(str,"%d",i);

The rest of the code is rather not clear to me... you should not mix a "for i" loop and the direct manipulation of the value of i. (oh, and why do you need to include a .C file ?)

Tell what you want your code to do, and i'll be happy to help you.
 
what i want to do is just check SMPC, thats it. later im going to improve it to load a File... also, ssf still gives me errors, satourne gives me errors, why is that? i do not have a AR+COMSSLINK
sad.gif
thanks guys i didnt know slPrintFX(); did that
smile.gif
 
How Should my Compiler SATURN dir be set? heres my setenv.bat:

REM sh-hms

SET PATH=C:\SS-SDK\SATURN\BIN;%PATH%

SET GCC_EXEC_PREFIX=C:\SS-SDK\SATURN\LIB\

SET INFOPATH=C:\SS-SDK\SATURN\INFO

SET C_INCLUDE_PATH=C:\SS-SDK\SATURN\INCLUDE

SET CPLUS_INCLUDE_PATH=C:\SS-SDK\SATURN\INCLUDE\CXX;C:\SS-SDK\SATURN\INCLUDE

SET GO32=EMU D:\SATURN\BIN\EMU387

REM Set TMPDIR to point to a ramdisk if you have one

SET TMPDIR=C:\WINDOWS\TMP

--

How Do I need 2 set it up???

also, It gives me this message:

C:\SS-SDK\SATURN\Data>make

gcc main.c -O2 -m2 -g -c -I../../INCLUDE/ -o main.o

gcc -m2 -L../../LIB/ -Xlinker -T../../SAMPLE/COMMON//sl.lnk -Xlinker -Map -Xlink

er sl.map -Xlinker -e -Xlinker ___Start -nostartfiles ../../SAMPLE/COMMON/cinit.

o ../../LIB/sglarea.o main.o ../../LIB/sega_sys.a -lcd -lsgl -o sl.coff

objcopy -O binary sl.coff sl.bin

Compiles Good but I dont know if it does it right.

I then use MK.BAT to make my ISO....

i used the Ip.bin Off the VCD TOOLS Folder (3rd Party)

then i use SATCONV tho change the CODE to U.

Then It loads Fine, Then It Gives me a Japanese ERror on SFF...

I also did a little test if my CD TOOLS are OK and they are, i copied a 0.bin off cotton boomerang 2

and then created a ISO... ran it on my SSF and it worked!
sad.gif
there is something wrong with my compiler for sure!

i know my test Code Works! I also tried compiling a example, and i still got the SH error..... :/

could ya please help me by showing me like how its suppose to be setup? maybe setup a FTP so i can see how to set yours up

lol i know its stupid but i need some help on it. also how will i bev able to code in ASM + setup my compiler?

hehehe
 
I didn't test it, since i'm waiting for my Action replay to be shipped, and commslink to find...

but i need some explanation about this part of the code.

Code:
/* ----------------------------------------

* Smpc Check 2

* ---------------------------------------- */

{

SmpcDateTime * date = &(Smpc_Status->rtc);

date->year = 0x1999;

date->month = SMPC_FRI | SMPC_DEC;

date->date = 0x31;

date->hour = 0x23;

date->minute = 0x59;

date->second = 0x59;

i++;

slSetDateTime();

///////////

I think you are asking something that can not be read by the saturn.

0x1999 is the hexadecimal form of 6553

This may be correct, sega use 4 byte for the year.

But the other date setting are not good.

The day, you ask for the 49th day of the month ( 0x31 )

It may not be the answer.

I'll make some verification latter about this.

Bye,
 
Here this is a somewhat more legible version of your code. I don't really get what you want to do, but I solved the references to erroneous slPrint code, fixed some slInit references out of order, removed the brackets (one of them ended the ss_main function midway the code), and added a loop at the end of the code to avoid the program running into the big memory unknown.

Code:
/* ----------------------------------------------

* Sega Saturn Smpc Check 0.1

* ---------------------------------------------- */

#include "define.c"

int ss_main(void)

{

	int i = 0;

	int pos = 0;

	int error = 3;

	slInitSystem(TV_320x224, NULL, 1);

	slColRAMMode(CRM16_1024);

	slBack1ColSet((void *)BACK_COL_ADR,0x8000);

/* ----------------------------------------

* Smpc Check 1

* ---------------------------------------- */

	for (i = 0; i < error; i++){

 slGetLanguage();

 if(slGetLanguage() != SMPC_ESPANOL) {

 slSetLanguage(SMPC_ESPANOL);

 slSetSmpcMemory();

 slCurColor(C_RGB(25,0,0));

 slPrint("Sega Saturn Info Corecto", slLocate(1,1));

 slPrintHex(i,slLocate(27,1));

 slSynch();

	}

	i = error - 1; //I can't remember the status of a variable used in a for function.

/* ----------------------------------------

* Smpc Check 2

* ---------------------------------------- */

	SmpcDateTime * date = &(Smpc_Status->rtc);

	date->year = 0x1999;

	date->month = SMPC_FRI | SMPC_DEC;

	date->date = 0x31;

	date->hour = 0x23;

	date->minute = 0x59;

	date->second = 0x59;

	slSetDateTime();

	slCurColor(C_RGB(25,0,0));

	slPrint("Sega Saturn Info Corecto", slLocate(1,1));

	slPrintHex(i,slLocate(27,1));

	slSynch();

/* ----------------------------------------

* Smpc Check 3

* ---------------------------------------- */

	if(Per_Connect1) {

 PerDigital * pad;

 pad = Smpc_Peripheral + 0;

 if(!(pad->data & PER_DGT_ST)) {

 return;

	}

	else if(!Per_Connect1)

	i--;

	slGetStatus();

	slCurColor(C_RGB(25,0,0));

	slPrint("Sega Saturn Info Corecto", slLocate(1,1));

	slPrintHex(i,slLocate(27,1));

	while(1){

 slSynch();

	}

}
 
hehe, thanks guys but i scrapped that :/ hey, the forums are back up! i just got back from DOS hell.... trying to install linux... what happened to the Nes development stuff? hehe
 
well, I'd still be interested in forming a team with some guys... I can't do it myself as 1. i don't know jack about the Saturn's hardware, only the CPU's asm language 2. I already have another emu project for the PSX and 3. I don't feel like making a gui ;-)

so, I'd be willing to write a 6502 emulation core in SH-2 asm if somebody else did the gui and stuff.
 
Are you sure you're able to make the core in assembly ? in that case I'm really interested to finish the SMS emu and replace some functions in assembly. I can work on the gui (the same as I made on SMS emu) with a simple help and enough to choose the ROM you want to play.

I was also thinking about putting the two emu on the same ISO using one bin file or two if someone manage to load saturn bin files on the fly (I'll have a look on that soon).

PS : the NES topic is still open.
 
well, as the C core wasn't fast enough I think ASM is the only option to get SMS emu running at full speed... the 6502 is a simple CPU, the Z80 is somewhat more complicated but not too much.
 
hey guys, why wont we meet up at #segaxtreme

so we can talk about development there, i prefer to have live chats.

it'd be nice (vbt: i'll be happy to continue NES emulation)

so how bout it ?
 
Back
Top