PPCenter :: devblog

PPcenter. Arts and craft for my Sega Saturn. Since 1847 :D

Compiling Pseudo Saturn Kai

Written by cafealpha 2 comments
I was recently asked about the instructions to compile Pseudo Saturn Kai from sources archive provided with Pseudo Saturn Kai binaries, so let's write a short blog article to make things clear to everyone.

The simple answer is : Pseudo Saturn Kai can't be compiled with theses sources.


End of simple answer. Those who want more details can refer to the few lines below.
Technically, some sources files are missing from source archive, preventing someone from opening sources archive, making some few changes, and installing it on a cartridge.

Why ? For the simple reason nobody won't help me if ...
  1. Some dude takes sources, change logo and credits page and then release this as "Pseudo Saturn Kai Gold Edition made by some dude".
  2. Some dude adds a major new feature to Pseudo Saturn Kai, and start doing business by making this firmware (and the cartridges compatible with it) available for paying.
    This dude will eventually forget to release any source, but who care about that except me and few other nerds ...

Maybe I would be told this I'm overthinking, but case 1 and 2 above already exist. Theses are detailed in another blog entry, and deserve a look if your time allows it.

Concretely speaking, there is one model using Pseudo Saturn sources (whose sources are fully available, and with build instructions too), hacked to don't show any startup menu (why not would you say, it's more convenient for the consumer), and consequently not showing any credits nor any mention it was made from Pseudo Saturn ... why not would you say, but that's a massive NO for me, and the Pseudo Saturn team will certainly not appreciate that too.

Some other projects are using fancy case and label instead of Action Replay ones (I'm OK with that, especially because Action Replay design guidelines are completely outdated), but don't mention anything about Pseudo Saturn Kai on their covers and labels until booting the cartridge and discovering ... a vanilla version of Pseudo Saturn Kai without any mention of the fancy product name advertised on the cartridge box and label
I'm sorry for the consumers who were expecting firmware design to be unified with cartridge box and label : this wasn't done because some few files are missing in Pseudo Saturn Kai sources !


This case of "some people are making money from rebranded homebrew projects" is also detailed on Segaxtreme forums, which deserves a look if your time allows it.
The thread there is not by me, nor about Pseudo Saturn Kai, so I hope how real the fact is that there are people making money from other people's hard work ... that's maybe normal in any work place (), but that's a dick move in such a small Saturn homebrew community.


To sum up the bulky paragraph above, the way of sharing Pseudo Saturn Kai source code is not how it works in free software world.
In an ideal world, everybody share source code, and everybody other make contributions, and the project is getting brighter by brighter.
So if the story stops here, I'm the bad one, but in real world, people deface the credits page, rebrand the projects under fancy names and start making cash and show business from projects they didn't contributed on ... Maybe it's selfish from me, but I don't want that and consequently removed few files from Pseudo Saturn Kai source code.


And if I may add an additional paragraph about Pseudo Saturn Kai, I would like to say it is quite open in the magic world of application to play games on Saturn real hardware : modchips are completely closed-sources, ODE too.
In Pseudo Saturn Kai, the sources of the exploit to play CD-Rs, as well as the ones to redirect memory devices to SD card are available.
The source code of the implementation of cheat codes engine is available too. I coded it from scratch because sources of Action Replay firmware are not open source ...


To add a bit of melodramatic taste to this blog article, I would like to say I spent the last four years developing Pseudo Saturn Kai.

I didn't asked for any payment about it. The next day after I received a $5 donation for it, I changed my donation page from "send money here if you want" to "send me kind message or a comment on my blog".

I didn't begged for any kind of crowdfunding too, and just wanted to continue the project where CyberWarriorX left it.

While four years seems a long period for just two or three features, you probably may want to look at Pseudo Saturn Kai credits page, and all the people who contributed to it.
Theses two or three feature are not the kind of thing someone develop, test, re-test, fix, and keep testing more and more during a weekend. From my own experience, normal people don't continue development so far and just give up development after a couple of weeks.
And, I won't appreciate this credits page to be defaced. Not for my nick to be removed (I'm listed there only one time), but for the respect to all the contributors being lost.

And while I developed custom cartridge using Pseudo Saturn Kai, I kept support for Action Replay cartridge and their clones. That may sound obvious, but technically speaking it isn't, mostly because Action Replay have limited ROM size.
At some point of Pseudo Saturn Kai development, I hesitated to put cheat codes feature in a ROM portion larger than current one, but unavailable from Action Replay cartridges.
This would had made more cheat codes available, but the feature itself usable on Gamer's Cartridge only. I choose to keep a reasonable size for cheat codes list, so that it would be available for everyone on Action Replay cartridges


Words count for this initially expected "short" article is about to reach four digits soon (it's 827 words now), and as I doubt a lot of people will read it entirely, it's probably time to conclude :
  • No full sources for Pseudo Saturn Kai
  • If you want to make you own Saturn cartridge firmware, then feel free to use Pseudo Saturn sources as a starting point.
  • Feel free to technically refer to Pseudo Saturn Kai source code, and to merge whatever you find interesting there to your project.
Still begging for Pseudo Saturn Kai full source code ? No problem, I shall make it available to everyone ... if there's not a physical disaster on my dev laptop or its SSD in the meanwhile.
At that time, this will definitely be the end of Pseudo Saturn Kai development. For you, and for me too.

Read more Compiling Pseudo Saturn Kai

Bit shift in Saturn minimalistic C program

Written by cafealpha 4 comments
While making a Saturn program running directly from ROM, constraint is usually to have program as small as possible. Why ? Because I would like to make Pseudo Saturn Kai continue supporting Action Replay, which have limited ROM size

So, in that situation, I use homemade, minimalistic stdlib, containing usually only memcpy and memset functions, and everything goes well.
But for some reason, current program was begging for __ashlsi3 and __ashrsi3 functions.
... What's these things ? __ashlsi3 is an assembly function doing left shifts of data, and as you probably guessed, __ashrsi3 does the same, but with right shifts

No problem, let's ask my friend google, and copy & paste theses functions without minding about their contents Theses functions are standard functions provided by C library, so sources can be found here and there.


An example of what __ashrsi3 function looks like

A day after that, here comes the time to do basic testing of this ROM code
Let's first start with simple things such as screen display ...


Text display ... not as expected ?!

Hrm, it's probably a problem in my printchar routine ?

printchar source code : this is the core thing
behind text display in my programs


But that's a very long time I didn't touched this routine, which works well on Pseudo Saturn Kai, and works even better in vdp1ex from Charles MacDonald sample programs, because all my printchar routines come from there
But just in case of, let's try to tune one " <<3 " into " *8 " in the code above, and see if that changes something. Theses two operations are equivalent, so this should give the same result, but ... Saturn screen becomes all black

Okay, there's definitely something weird regarding that printchar, but I just re-used it as-is from other project, so what's going wrong with my it ?!
[...]
And then (finally) a light-bulb above my head appears Maybe there's something wrong regarding the __ashlsi3 and __ashrsi3 routines ?
And, yes there was something wrong regarding theses routines ... I wrote a paragraph about them on the first half of this article, so it would be surprising the problem came from somewhere else

In more accurate words, routines are OK, which is normal since they are written by people smarter than me But the calling convention of __ashrsi3 was not as my gcc was expecting ?
Well, that's just a guess from the display results, because it seems to display the same pixel 8 times on each row of a given character, which may happen when ignoring shift parameter in __ashrsi3 function.

Anyway, rather than finding in details what's wrong, let's fix the problem First, with assembly by hand, in desperately trying to change input parameter handling ... I don't remember exactly what I wrote, but that was something like pushing a register to stack, moving parameter to it, finally restoring register, putting nop instructions everywhere, etc ... nothing difficult, but over my extent in assembly programming

The result is ... a mixed success :

Trying to modify __ashrsi3 routine by hand ... well, it seems that
some shift values are not correctly handled


Okay, so let's re-ask google about that __ashrsi3 routine ... and a different implementation arrives in search results. Let's try it


__ashrsi3

And the execution result :

Execution result with second version of __ashrsi3 function

Yeah, it works this time !!! And don't ask me why, because I didn't took time in understanding what's different in that second version of __ashrsi3 function
And, rather than understanding why it works ... let's close that assembly pandora box before some other mystic bugs pop from it

I will probably see about this in the future, but that was absolutely out of the scope of today's programming, and in software world, too much digression leads to freeze of projects, which I would like to avoid in order to go forward to next pending project 

As a example, I started to adapt yeti3d engine to Saturn in 2010 (7 years ago !), and this ended in ... developing a SD card based memory cartridge for Saturn !
The point above is is not a joke : menus used in my yeti3d adaptation are the origin of menus used in Pseudo Saturn Kai, which shows the continuity (co-consanguinity ? ) in my projects. And after getting yeti3d working a bit, I really would like to load levels from something else than CD-ROM, which was from PC (via adequate link cable) on a first time, and which will (should ?) then evolve to SD card.
That would be cool to make a Saturn game not requiring to burn CD-ROM somedays, but before that I need to finish neighboring side quests


Evolution of my Saturn projects

To conclude this article, let's say it was terribly fun to see some bits of the internals behind C language
By the past, I remember I did something similar with my yeti3d adaptation, but remained at "C language level" : optimization done at that time was (IIRC, ) to avoid 4 bits shifts, because theses are not available in a single SH-2 CPU instruction. Avoiding 4 bits shifts was simply done by merging two fixed point operation in a single one (or something like that : I did this 7 years ago !), and this actually gave some improvements in 3D scene rendering Theses were the good times ... I sometimes think "I'm Getting Too Old For This Shit", but that's only to motivate to finish my old projects

But before that, Pseudo Saturn Kai, and then Kicad and Quartus are waiting for me


BTW, in the case you wondered about what was today's programming session, you probably guessed it was about exception handler addition to Pseudo Saturn Kai. This not a new feature, since it was available in Pseudo Saturn 0.83x ... in fact, I grabbed some sources from Pseudo Saturn 0.83x in order to implement this exception handler (thank you CyberWarriorX !) This exception handler will be available as a small add-don to cheat codes feature in Pseudo Saturn Kai next major release.

Read more Bit shift in Saturn minimalistic C program

Treatment report (2014/08/12)

Written by cafealpha no comments
Nothing really special today.
This morning, the roommate in front of me (separated by 2 curtains) left hospital, so I am now the patient with the longest stay in this room.
Previous roommate always spoke to himself while sleeping, so it's great that he finally left hospital


Among the two roommates remaining with me in this hospital room,
 - first one snores loudly ...
 - second one likes to play with room's air conditioner settings ... I don't know why he set temperature room to 28℃ .... maybe a game with me, I don't know.
Anyway, I plan to restore temperature to 26℃ as soon he changes it ... I have no choice, because his favorite temperature feels like hell to me.
And if he really continues to bother me, I will pour extra strong bond on air conditioner remote controller buttons


Doctor now use small syringe to pour sterilized solution in my mouth's scar in order to clean it, which is a sign that everything is going well for it
Also, according to the doctor, there's no longer need to clean this scar twice a day : once a day is now enough, which is another good sign about this scar :]
I hope this scar will close properly this week. After that, I finally will be able to start eating rehabilitation !!


On Saturn dev side (at first, this blog was intended to be a Saturn dev related blog !), I had fun with interrupt C and code executing on ROM ... except constant ones (of course), no global variable is allowed for ROM code ! Ouch.
Still not compiling, less than half of the project is coded, nothing tested, so I will continue tomorrow

Read more Treatment report (2014/08/12)

Rss feed of the tag