What I've been up to the past week ...

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
byuu

What I've been up to the past week ...

Post by byuu »

First person to figure out what this patch is for (eg what you should apply it to) wins a cookie.

Code: Select all

;restart patch for Mac OS X 10.5.2 (vanilla mach_kernel 9.2.2)
;author: byuu
;license: public domain
;date: 2008-04-28
;assemble with "yasm -f bin restart.asm -o restart.bin"

bits 32

%define base 0x09d80e
%define relative(n) n - (base + $ - zero)

zero:
  push ebp
  mov  ebp,esp
  sub  esp,24

  mov  eax,[ebp+8]
  test eax,eax
  je  .shutdown

.restart
  mov  dword[esp],0x4621f4
  call relative(0x0232f8)
; mov  dword[esp],1
  xor  eax,eax
  inc  eax
  mov  [esp],eax
  call relative(0x32066a)
; jmp .hang
  mov  al,0xfe
  out  0x64,al
  hlt

.shutdown
  mov  dword[esp],0x462204
  call relative(0x0232f8)
; mov  dword[esp],0
  xor  eax,eax
  mov  [esp],eax
  call relative(0x32066a)

.hang
  jmp .hang

;original:
;offset  hex
;09d80e  55 89 e5 83 ec 18 8b 45 08 85 c0 74 1a c7 04 24
;09d81e  f4 21 46 00 e8 d1 5a f8 ff c7 04 24 01 00 00 00
;09d82e  e8 37 2e 28 00 eb 18 c7 04 24 04 22 46 00 e8 b7
;09d83e  5a f8 ff c7 04 24 00 00 00 00 e8 1d 2e 28 00 eb
;09d84e  fe

;modified:
;offset  hex
;09d80e  55 89 e5 83 ec 18 8b 45 08 85 c0 74 1c c7 04 24
;09d81e  f4 21 46 00 e8 d1 5a f8 ff 31 c0 40 89 04 24 e8
;09d82e  38 2e 28 00 b0 fe e6 64 f4 c7 04 24 04 22 46 00
;09d83e  e8 b5 5a f8 ff 31 c0 89 04 24 e8 1d 2e 28 00 eb
;09d84e  fe
(EDIT: fixed small typo in the above code.)
Last edited by byuu on Tue Apr 29, 2008 3:44 am, edited 1 time in total.
joebells
Rookie
Posts: 29
Joined: Thu Apr 17, 2008 10:27 pm

Post by joebells »

what kind of cookie?
augnober
Rookie
Posts: 15
Joined: Fri Apr 18, 2008 5:29 am

Post by augnober »

"Looks like you're trying to restart the system."

Hmm.. it appears to be for something that's PC compatible, and it's 32-bit code (and would run on a 32-bit CPU). You preserved the same number of bytes - which means you are probably unable to rebuild it from source (you probably don't have the source). I notice you did the xor eax, eax twice to get 0.. which was probably just necessary to save you a few bytes. It seems that this thing had code to give it the ability to do a software shutdown and perhaps a restart or hang, triggered by software. You were apparently unsatisfied because you weren't able to get it to restart, and so you decided to output 0xfe to 0x64. Presumably you are satisfied with the change you have made, so I guess this was successful. The patch is applied relative to a base of 0x09d80e.

Under what circumstances would something want to shutdown and/or restart the system? Why wasn't its code satisfactory? Why would you care to fix this? Where does this converge? Quite mysterious..
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Game patch for a 32 bit system?

>.>
augnober
Rookie
Posts: 15
Joined: Fri Apr 18, 2008 5:29 am

Post by augnober »

I'm going to take a crazy stab at this, and say that this is being applied to part of Windows (XP?). Most Windows versions I've had have eventually gotten into a situation where it doesn't properly restart itself, and just hangs endlessly until I turn it off myself. Why not automate the process? :)
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

this is the patch that makes the democratic party relevant again.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Oh, no worries, Iraq has made them relevant again.
Gil_Hamilton
Buzzkill Gil
Posts: 4294
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

(saving the thread from political flames)

Does it add plasma rifles to Mecarobot Golf?
byuu

Post by byuu »

> Hmm.. it appears to be for something that's PC compatible, and it's 32-bit code (and would run on a 32-bit CPU).

Yep.

> You preserved the same number of bytes - which means you are probably unable to rebuild it from source (you probably don't have the source).

Yep.

> I notice you did the xor eax, eax twice to get 0.. which was probably just necessary to save you a few bytes.

Yep.

> It seems that this thing had code to give it the ability to do a software shutdown and perhaps a restart or hang, triggered by software. You were apparently unsatisfied because you weren't able to get it to restart, and so you decided to output 0xfe to 0x64.

Yep. Port 0x64 is the keyboard controller, writing 0xfe causes a PC to restart. And that obviously requires ring 0 access. Who the hell knows why they decided to put that functionality in the KBC port, but it's a lot easier than generating a CPU triple fault.

> I'm going to take a crazy stab at this, and say that this is being applied to part of Windows (XP?).

Nope, not an XP patch.

> Does it add plasma rifles to Mecarobot Golf?

Good lord, an x86 in an SNES game ... heh. Must be the SF-TOWNS add-on unit you're thinking of.
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

This just popped into my head... Magna Carta? Talbain recently mentioned he needed hacking help with that, and both you and him were/are associated with D...

>.>
DataPath
Lurker
Posts: 128
Joined: Wed Jul 28, 2004 1:35 am
Contact:

Post by DataPath »

My guess is that byuu has given up on operating system compatibility and portability for bsnes, and thus is expanding bsnes to be a bootable OS, and this is to add the reboot/shutdown capability to it.

bsnesos - the choice of a retro generation.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

byuu wrote:> Does it add plasma rifles to Mecarobot Golf?

Good lord, an x86 in an SNES game ...
Obviously there'll be an 80i386 on that cartridge. Mecarobot Golf is only for testing; the project's real purpose is teh ultimate Doom port as it was really meant to be.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

>.>

<.<

I'd buy that for a dollar.
mastershake1
Rookie
Posts: 19
Joined: Mon Sep 04, 2006 4:03 pm

Post by mastershake1 »

bsneXBOX?
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

mastershake1 wrote:bsneXBOX?
Definately not.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
byuu

Post by byuu »

Gil_Hamilton
Buzzkill Gil
Posts: 4294
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

Awww...

I bet it was oatmeal raisin anyways.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

byuu wrote:Time's up, no cookie :P

http://byuu.cinnamonpirate.com/articles/osx86/
Massive fail. All that's needed now is Nach's explaination of how bad Apple's tools are.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

remember the mantra: Apple is a Hardware Company.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
sweener2001
Inmate
Posts: 1751
Joined: Mon Dec 06, 2004 7:47 am
Location: WA

Post by sweener2001 »

[img]http://i26.photobucket.com/albums/c128/sweener2001/StewieSIGPIC.png[/img]
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

This reminds me of that Mac ad where they claim Apple makes all the hardware in Macs.

Frigging liars.
etabeta
Rookie
Posts: 29
Joined: Sun Jun 17, 2007 9:18 am

Post by etabeta »

byuu wrote:Time's up, no cookie :P

http://byuu.cinnamonpirate.com/articles/osx86/
nice read. about software on mac:

* pros: you have that any *nix software works almost perfectly as soon as you install X11

* cons: if you plan to develop on mac you shall remind that it uses a custom gcc (not based on the latest version even if you take latest Xcode) and that native macosx sdl libraries uses slightly different convention (e.g. no sdlconfig and you have to include SDLMain.c in you sourcetree). you could simply use X11 versions of these, but I would consider it a bit cheating ;)

as you already said, anyway, it's mainly a matter of considering them as differences rather than flaws
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

etabeta wrote:as you already said, anyway, it's mainly a matter of considering them as differences rather than flaws
In some instances, you could call them quirkyness, and at worse case flaws, as flaws as what they truly are. :P
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
byuu

Post by byuu »

Massive fail. All that's needed now is Nach's explaination of how bad Apple's tools are.
Fail? I didn't say OS X had a good development environment. It's not at all surprising that it's not pleasant, though. All the more reason I'll be taking my time learning this stuff. And if they force me to use Objective C for the GUI, I may not even bother.
remember the mantra: Apple is a Hardware Company.
You mean a hardware reseller. And people only use it for the software.

It's the same with any of these damn companies. Sony's afraid people will buy the PSP at a loss and not buy games if they can run their own software? Sell a dev-enabled version for a profit, then. Apple is afraid of losing hardware revenue? Sell Leopard IBM PC Edition for a markup.

People are going to hack their way around artificial restrictions anyway. Might as well cash in on the honest people. I'd have rather paid ~$200 for an OS X copy that I didn't have to hack up. Would've made the money back anyway if I didn't have to swap out my AMD board + processor.
psystar
... costs $125 more than my complete example system based on Newegg prices. And you can tell they opted for the $25 case.
joebells
Rookie
Posts: 29
Joined: Thu Apr 17, 2008 10:27 pm

Post by joebells »

I think if you use it more and more you'll grow to like the way osx does stuff, just little things you'll notice here and there. Plus there is expose my favorite feature over windows. Saves me alot of time, if you don't know what expose is yet press either f3 or f9 I believe it is.
http://en.wikipedia.org/wiki/Expos%C3%A9_(Mac_OS_X)

best damn feature. Much better and useful than vista's stupid 3d flip thing. It may seem simple but it really helps me when I have a ton of windows open.

Oh and the hardware for the mini might be a bit overpriced but people will pay a premium for miniturization and such. When the mac pro came out it was cheaper than a similarly configured dell. People were really surprised. The imac also isn't too bad a deal when you consider the specs and such. When you look at the notebooks they are also a good deal, especially when you factor in the superior hardware(the scrolling trackpad is beautiful, so much nicer than the junk they put on most laptops) We'll gladly pay a slight premium for the superior os and nicer design. But thats just us.

I just disagree with your statement
unbelievable premiums for underpowered hardware
the mini might be a bit but the other stuff isn't too bad. And the way osx does stuff different is nicer to most who do give it a couple of weeks time to get used to it. Even the little black dot that goes in a document windows red circle is just a little touch that is nice. It lets you know that the document has changes that are not saved by just glancing over there. The whole thing is based off of maximising productivity. When you press the maximize button it doesn't take up all the desktop space it takes up the amount of space that window needs to show all of its contents allowing you to still, possibly, see other things behind it and such.

But enough of the mac fanboyism, I used to be a hardcore windows guy myself, hated osx when I first tried it, but after using it a while and understanding why they do certain things I really get annoyed when using my windows box now(the osx box is mainly the girlfriends machine for college) I think if you give it some time you'll really grow to like using osx as you essentially said you might towards the end of your post.
Locked