[HN Gopher] PS1 Programming Course with MIPS Assembly and C
___________________________________________________________________
PS1 Programming Course with MIPS Assembly and C
Author : ibobev
Score : 143 points
Date : 2024-04-09 17:43 UTC (5 hours ago)
(HTM) web link (pikuma.com)
(TXT) w3m dump (pikuma.com)
| jsheard wrote:
| > We'll also learn how to use the official Sony Psy-Q libraries
|
| Is there not a cleanroom SDK for the PS1? I doubt Sony cares too
| much at this point, but selling a course which relies on leaked
| proprietary tools still feels a bit dicey.
|
| The Portal N64 demake got shut down because it used the leaked
| N64 SDK rather than cleanroom tools.
| ranger_danger wrote:
| yes there are multiple, such as
| https://github.com/Lameguy64/PSn00bSDK
| spicyjpeg wrote:
| PSn00bSDK maintainer here. Unfortunately the project cannot
| really be considered clean room; the original versions of
| most libraries contained code that was either lifted straight
| from Psy-Q disassemblies or _heavily inspired_ by them. I
| have since rewritten pretty much all of it (with the
| exception of the GTE library which still has some Sony code)
| using only Psy-Q API documentation as a reference, but the
| "ship of Theseus" nature of the rewrite makes it hard to
| argue that it is a clean and legally safe project.
|
| On the flip side, there are plenty of other open source PS1
| SDK options that have been written from scratch, do not
| reimplement the same API as Psy-Q and can thus be considered
| clean for the most part. Here's a few of them:
|
| - https://github.com/grumpycoders/pcsx-
| redux/tree/main/src/mip...
|
| - https://github.com/ChenThread/candyk-psx
|
| - https://github.com/cuckydev/CKSDK
|
| - https://github.com/spicyjpeg/ps1-bare-metal (shameless
| plug)
| VS1999 wrote:
| That was interesting because the author didn't receive a legal
| takedown notice, and the request came from Valve instead of
| Nintendo. It's possible nintendo didn't care, and likely that
| sony cares less than nintendo.
| mrbungie wrote:
| I think Nintendo cares a lot. In fact I think Nintendo gives
| so much fucks about its IP (of any kind, not only
| games/stories/characters, but also SDKs/APIs/console
| design/etc) that Valve _fears_ any kind of association with
| potentially illegal or at least dubious origin software
| related to Nintendo.
|
| Remember Valve is a company that normally celebrates and
| promotes the modding community, even when using their IP
| directly (i.e. Black Mesa). Valve's decision was totally and
| exclusively because it included BOTH their and Nintendo's IPs
| in the equation.
| boricj wrote:
| If you want a source-compatible reimplementation for modern
| systems there's https://github.com/OpenDriver2/PsyCross
| ranger_danger wrote:
| Course looks really cool, just wish it wasn't $100 but I know
| that's unrealistic to expect. It seems most people who want to
| get into video game programming are poor.
| VS1999 wrote:
| The good news is that if you actually do make it into videogame
| programming, you're still poor
| iforgotpassword wrote:
| But you're getting a nice burnout on top!
| udev4096 wrote:
| And how we casually joke about it :)
| omoikane wrote:
| Many modern game engines are free and less frustrating than
| SDKs for old consoles (e.g. a lot of common tasks are often
| built-in with new game engines, such as physics). For people
| who want to get into making games, I would recommend one of
| those game engines rather than paying $100.
|
| That said, I am not sure this course is targeting new game
| developers.
| danjoredd wrote:
| Agreed. Godot, Unity, Unreal, etc. all are better options for
| beginners. Gamemaker Studio even lets you program for
| free...you have to pay to make an executable though.
|
| If someone is dead-set on making a game for PS1, there are
| free tutorials out there also: https://www.youtube.com/playli
| st?list=PLAQybJIBW2UtXJITyUTJi...
|
| You won't have as intimate knowledge of PS1 hardware as OP's
| course, but I think thats a better starting point than paying
| first and then stopping because you didn't already know
| programming and it turned out more involved than you thought
| it would be.
|
| Now I DO think that there is a place for a paid course like
| this. I can see the appeal of getting hyperfixated on
| extremely specific hardware such as this, and making some
| cool stuff for it. For that type of person, the 100$ is worth
| it.
| Solvency wrote:
| As a kid I always dreamt of coding for PS1 on one of those black
| dev console kits.
|
| As an adult.. boy I wish someone made a cozy Javascript
| transpiler to PS1 tool.
| dijit wrote:
| I too remember being mesmerized by the image of the black PS1
| "developer" kit.
|
| It truly captured my imagination and alongside the movie
| Hackers from 1995 is probably one of the reasons I ended up
| wanting to be associated with computers in my future as a
| child.
| spxneo wrote:
| yaroze devkit costs upwards of $10,000 USD now
| sumtechguy wrote:
| I just looked they are going from 800 to 10k. The 10k ones
| are the collectors ones where it is new in box (or at least
| complete in box). As long as you have the cables, console,
| and dev card you probably could get in at around 1-2k.
| sumtechguy wrote:
| I have one of those yaroze things. I had all sorts of plans for
| it. Until I realized that the memory on the thing was identical
| to the size of the normal in store ones and getting at the CD
| for extra storage was basically broken at the SDK level. That
| made debugging 'interesting'. Even splurged for the codewarrior
| dev kit. It was a decent step down in tooling and memory that I
| could get on other platforms. Kind of fun for a bit.
| stuaxo wrote:
| About 15 years ago, my friend got about 10 ps1s from a car
| boot sale, one of the ones from that day was a yaroze.
| 0xcde4c3db wrote:
| Same. As far as I know, though, the black PS1 didn't actually
| do anything special to enable development, it just allowed Sony
| to arbitrarily make the devkit incompatible with retail PS1
| consoles. It still required a special memory card dongle and
| boot disc in addition to the special console model for some
| reason. I seem to recall that someone cracked the boot disc to
| run on retail consoles without the dongle, and the serial link
| just needed a level shifter like a MAX232 (though these days
| you'd probably use a USB UART like CP2102 or FT231).
| pjmlp wrote:
| To note that PS1 was the first games console on the home
| market[0] to fully embrace C on its SDK, until then it was
| Assembly all the way, hence why so many studios were happy to
| jump into it.
|
| [0] - The arcades adopted it much earlier, and there were UNIX
| and VAX/VMS devkits with cross-compiling capabilities for them.
| boricj wrote:
| I'm reverse-engineering a PlayStation video game that is rather
| unoptimized and I'm amazed that the game managed to do so much
| with such horrible game code. That SDK really was fairly
| forgiving for its time to new, inexperienced developers.
|
| Yet to squeeze out performance out of the in-order, single-
| issue 33 MHz MIPS CPU you had to be very mindful of low-level
| details. The 4 KiB instruction cache hates code bloat, the lack
| of data cache means spilling registers anywhere but onto the 1
| KiB of scratchpad memory is costly, yet the god-awful C
| compilers of the era liked to do both of these things. That's
| just for the CPU, the rest of the system also has plenty of
| details you need to pay attention to for performance.
|
| I haven't actually programmed for the console, but the
| achievements done by talented developers such as Naughty Dogs
| on this dirt-cheap system are truly impressive. The console
| might be easy to develop for, but to make it really fly still
| takes a lot of skill.
| jonhohle wrote:
| Have you published anything? There are a few games that I
| would love to be able to round trip between the original disc
| contents and a build with a few tweaks or experimental
| features. I know there is a Wipeout decompile/source leak,
| but having more examples is always wonderful.
|
| Something like the Mario 64 reverse engineering project has
| made the game playable effectively everywhere with the
| ability to take advantage of modern hardware (16:9 displays).
| It would be great to see efforts like that for any console.
| boricj wrote:
| I'm documenting my progress on my personal blog
| (https://boricj.net). Currently I'm in the process of
| porting data from a leftover SYM file onto a closely
| matching EXE, the next article should be out by the end of
| the week-end.
|
| Be warned, I'm going about this with a _very_ different
| approach than most decompilation projects out there. I want
| to _delink_ these executables back into working, reusable
| object files. The plan is to make a native Linux MIPS port
| on the cheap using PsyCross, then to rewrite each piece
| Ship-of-Theseus style until I have a complete, portable set
| of source code for the game.
|
| As for why I'm doing it this way, I've written about it
| here before: https://news.ycombinator.com/item?id=37165533.
| I've also written about the delinking process itself here:
| https://news.ycombinator.com/item?id=35738758.
| spxneo wrote:
| may I ask what game?
| boricj wrote:
| It's _Tenchu: Stealth Assassins_. More specifically, the
| updated Japanese re-release version, which has goodies like
| a level editor we didn 't have in the West until _Tenchu 2:
| Birth of the Stealth Assassins_.
|
| I do not expect to finish it anytime soon, although finding
| debugging symbols in a leftover file inside a proprietary
| archive format has been a very lucky find. Most of the past
| two years have actually been spent on the tooling to delink
| executables back into object files, which should prove
| extremely useful if this crazy approach of mine works out.
| dmbaggett wrote:
| Yes, for Crash Bandicoot we had to entirely skip the C SDK
| for everything performance-critical; pushing arguments onto
| the stack and the SDK popping them off for each function call
| used more cycles than the underlying operation in many of
| these SDK calls.
|
| Sony explicitly forbade this, presumably because they
| envisioned the API established by the C SDK as a way to
| ensure future backward-compatibility. We just ignored the
| rules and hoped the superior performance we could achieve
| would overcome any bureaucratic obstacles.
|
| We also had to reverse engineer some of the PS1's really nice
| capabilities. I only learned the hardware supported vector
| pipelining for strip rendering by noticing the coordinate
| values move from one register set to the next in the
| debugger.
|
| Seeing that was a revelation: when rendering a polygonal
| mesh, you naively have to project three coordinates for each
| triangle. But if you convert your mesh into sequences of
| polygonal strips where each triangle shares an edge with the
| next triangle in the mesh, you only need to project a single
| additional vertex for each additional polygon in the strip.
| Observing the behavior in the debugger, it was obvious to me
| that the Sony hardware had in fact been optimized for this
| approach. But not only were we not given any documentation on
| this, we were instead told to use the C SDK, which didn't
| expose this capability at all.
|
| The PS1 also had 2KB of "scratchpad" that was slower than
| registers but much faster than RAM. Hearsay was this was a
| way for the CPU designers to make use of the physical space
| on the die meant for floating point instructions which the
| MIPS CPU in the PS1 didn't have.
|
| I used the scratchpad to store projected 2D "stamps" of the
| 3D world (stored in an octree) and Crash: a kind of low-res
| Crash Flatland. I could then check for X/Y collisions between
| Crash and the world very rapidly by inspecting the flatland
| bitmap stored in the 2K scratchpad. This was Mark Cerny's
| idea; he was our producer on the Crash games and has also
| been responsible for PS2 through PS5 hardware.
| gryson wrote:
| Thank you for posting this!
| znpy wrote:
| Hey I just wanted to chime in and say that I spent a lot of
| time in my infancy/youth playing crash bandicoot, thank you
| very much.
|
| Also, i've seen many videos on YouTube about all the crazy
| things you had to do to make stuff work. And every time i
| get to read some additional detail it's always super
| intriguing...
|
| Have you considered doing something like a documentary?
| Like, a series of long form videos on the topic? With
| interviews to people involved etc?
| dmbaggett wrote:
| Hopefully you've read the Polygon article and seen the
| videos with Andy Gavin talking about the underlying tech.
| I was going to do part two of the video series but COVID
| killed it. Maybe we'll revive that; it would be fun.
| Keyframe wrote:
| I like the idea, and other courses seem solid in overview too.
| However, I'm put off by not being able to download the course. I
| understand it's my old-man mentality kicking in, but I just have
| this bug in my mind "what if it goes down", "I wanna watch this
| offline", "what if dude disappears"..). I also understand why
| there's no option for that.
|
| I don't know, anyone else have feelings like these in general?
| I'd have no issue if it was way cheaper, and I'd have no problem
| if it was somewhat more expensive if I could download. It's a
| weird feeling like that that ultimately did affect me not
| purchasing it.
|
| edit: I realized I wouldn't mind it if it was on a big platform
| like I don't know what would support it, steam? appstore? I know
| those won't go away and I have stuff there.
| gustavopezzi wrote:
| Hi! Creator of the course here. This is a really good point,
| and I honestly did not consider someone's fear of a platform
| "disappearing" as a potential friction to buy before I read
| your comment. It makes total sense.
|
| I have been doing this for a while, so disappearing was not
| even in my thoughts. :)
|
| But I'll need to think about that and how to make it clear for
| everyone that visits the school.
|
| Thanks!
| fallat wrote:
| Release the videos as lower quality; maybe make the
| downloadable content not as nice to browse?
| keb_ wrote:
| > I have been doing this for a while, so disappearing was not
| even in my thoughts. :)
|
| To be frank, this is not very re-assuring. Every platform
| that has ever gone offline has at one point told their
| customers something similar.
|
| It's also possible you may go offline for reasons outside of
| your control.
| gustavopezzi wrote:
| > It's also possible you may go offline for reasons outside
| of your control.
|
| I see. I've just discussed about this with other people at
| the school. I guess if something like that ever happens,
| the course content will probably be made available in full
| to all students.
|
| One thing is that I am personally _always_ updating the
| course and adding new examples and lectures to it. If
| students simply download the content once there will be
| different versions of it. This was one of the reasons I 've
| decided to record lectures instead of simply writing a
| book, for example.
| Keyframe wrote:
| Thanks for consideration. Maybe easiest path would be to go
| through one of the bigger platforms but maybe more expensive
| and also offer same but cheaper on your own.
|
| I've read through your FAQ, but one more thing to consider is
| to offer a bundle discount, like for buy all or similar.
| keb_ wrote:
| > I don't know, anyone else have feelings like these in
| general? I'd have no issue if it was way cheaper, and I'd have
| no problem if it was somewhat more expensive if I could
| download. It's a weird feeling like that that ultimately did
| affect me not purchasing it.
|
| Yeah, I'm the same. These courses sound and look right up my
| alley, but I try to only support DRM-Free material where I can
| for the reasons your described. The Pragmatic Studio [1] is a
| good example of an online school that offers DRM-Free downloads
| for customers.
|
| [1] https://pragmaticstudio.com/
| theogravity wrote:
| Does it also require a Net Yaroze?
|
| https://en.m.wikipedia.org/wiki/Net_Yaroze
| jonhohle wrote:
| I started collecting obscure retro consoles almost a decade ago
| when Net Yarozes could be found for prices that weren't
| completely outlandish. Now it's common to see them on popular
| marketplaces for $700 or more.
|
| Their aesthetic is amazing. The PS1 holds up, imho, as one of
| the best looking Sony products and consoles of all time and the
| dark gray color way is a hint of what the next three consoles
| would look like.
| boricj wrote:
| With modern quality emulators like DuckStation, there's really
| no reason to use real hardware anymore as the primary target.
| Besides, you'd probably just have a standard PlayStation
| console with a modchip on hand and iterating with CD-Rs would
| be very slow and wasteful.
| Keyframe wrote:
| Friend, today we have wonders like ODE and PSIO. No need to
| burn chemicals on a spinning disc anymore!
| tycho-newman wrote:
| Will I learn how to run Crysis?
| transitivebs wrote:
| If anyone's looking for a solid MIPS assembly IDE, I wrote this
| one ~18 years ago in undergrad http://mipscope.cs.brown.edu
|
| wow I'm getting old
| hedgehog wrote:
| Just wait until kids start asking "MIPS... is that like
| RISC-V?"
| gustavopezzi wrote:
| Hi! Author of the course here.
|
| Thank you so much for sharing. :)
| boricj wrote:
| Hi, what prompted you to create a 25 hour course about
| programming the original PlayStation? Don't get me wrong, it's
| very cool that such a resource exists, but it is a rather
| peculiar topic for a course.
| gustavopezzi wrote:
| Hey. Good question! People think I'm crazy, but I promise you
| I'm very sober about my approach to my courses.
|
| I teach CS & mathematics at a university here in London.
| Empirically, I've noticed that students can find ways to be
| productive but they are seriously lacking the fundamentals.
|
| To be fair, it is nothing short of overwhelming to try and
| grok the fundamentals of computing using modern machines,
| modern OSs, and a modern dev toolchain.
|
| So what I try to do with the courses is to go back in time
| and limit myself with a closed hardware box that is still
| small and simple (compared to what we have today).
|
| Instead of using a fake instruction set, I can have students
| learn the basics of MIPS, use a very simple assembler, output
| binary code, and execute those instructions on a hardware
| that exists (or existed once). That allows me to explain
| about CPU architecture with real examples, talk about DMA,
| endianness, interrupts, and so many other concepts that
| students can read online but they don't really grok until
| they get their hands dirty with grease.
|
| Weirdly enough, so far it's been proven to be a good idea.
| It's definitely not for _everyone_ , but if someone is at a
| stage of their career where they think it's fun to learn
| about RISC pipeline, fixed-point math, game physics, 3D
| graphics, compressing assets, computer architecture, etc.,
| then I still think this type of course is valid!
|
| I'm positive that in 25 hours learning how to program the
| original PlayStation they'll learn a lot more about computer
| science than taking an expensive class to read about 'Digital
| Transformation' or something like that.
|
| To each, its own.
| boricj wrote:
| That really makes a lot of sense. Given the constraints,
| the PlayStation is indeed a good fit (if you want to be
| sadistic, I can't think of a worse fit than the Atari
| Jaguar with its numerous pipeline hazards inside its
| proprietary RISC processors).
|
| I do think using a modern SDK would streamline the
| experience without compromising on the authenticity, it
| might be a good idea to at least mention this option since
| the original Sony SDK is technically leaked tooling.
| znpy wrote:
| Hey, the website isn't loading for me right now (i'll try
| again later) so i wanted to ask: does the course include
| examples on how to run the code on a playstation, real or
| emulated?
| janice1999 wrote:
| Cool course. Are you aware of any game engines for the PS1? Is
| there an active hobbyist community?
| spicyjpeg wrote:
| There definitely is one [1], albeit perhaps not as large and
| active as the homebrew communities for 8/16 bit consoles
| (which benefit from low-code tools such as GB Studio and the
| ability to sell physical game cartridges that do not require
| modchips) or more modern ones (which tend to have a much
| lower barrier to entry, given the better specs and
| availability of SDL ports and whatnot). It is definitely
| growing though, as I'm seeing more and more people get
| interested in developing for the PS1.
|
| [1]: https://psx.dev/
| marai2 wrote:
| The author's Learn 3D Graphics Programming is one of those
| extremely rare courses that takes you from the basics and peels
| back the curtain to show you the Wizard.
|
| https://pikuma.com/courses/learn-3d-computer-graphics-progra...
|
| One of the best courses I've ever taken. (Thanks Gustavo!)
|
| By the way Gustavo, with your talent for explanation, graphics
| and Maths, maybe you should do some courses on Machine Learning!
| (You'll make a lot of money ;-)
| gustavopezzi wrote:
| Hey, Gustavo here! Thank you so much for your kind words.
|
| I'm still deciding what to tackle next. I had a couple of
| ideas, but since my true background is really math I'll
| probably consider that.
|
| I'm not sure there's much money in what I do, but it sure it's
| a fun topic. Fun always trumps everything else at the end of
| the day. :)
| aidenn0 wrote:
| If you're taking requests, I'd love a good linear-algebra
| refresher course. I recently ran into the term "eigenvector"
| in a professional setting and that's a word I hadn't heard
| since my freshman year of college, which is over 2 decades at
| this point.
| durpleDrank wrote:
| I took this dudes Atari 2600 Course on Udemy cause it was only
| $13 bucks. It is awesome/great. Made the whole thing super simple
| to learn. Very idiot proof. It's too the point (which I find
| helpful).
| 0xPIT wrote:
| What or whose lifetime do they refer to when they offer lifetime
| access?
| spicyjpeg wrote:
| Not directly related to the course, but, should anybody want to
| see what programming on the PS1 would look like using only modern
| tools (latest GCC, CMake, no third party libraries), I've written
| a few bare metal C examples that explain in depth how the
| console's hardware works [1]. Currently only graphics and input
| are covered, but I'm planning to add examples showing how to
| handle interrupts, play audio and access the CD-ROM next.
|
| [1]: https://github.com/spicyjpeg/ps1-bare-metal
| gustavopezzi wrote:
| Good mention! I actually list your username & your repo at the
| end of the course as suggested reading.
|
| PS: thank you for all the good help on the PSX Discord, as
| always.
___________________________________________________________________
(page generated 2024-04-09 23:00 UTC)