Sonic and Sega Retro Message Board: Machine Code Monitor Programming Guide - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

Machine Code Monitor Programming Guide If that even makes sense to you.

#1 User is offline Sonic 65 

Posted 25 October 2004 - 07:57 AM

  • Posts: 1166
  • Joined: 09-October 04
  • Gender:Male
  • Project:Dustin Wyatt's Epic Jailbreak
  • Wiki edits:13
I made a guide that tells you the location of parts of monitor code and what those parts do. Not much, but hey. Updates coming later.

Attached File(s)



#2 User is offline Erik JS 

Posted 25 October 2004 - 08:38 AM

  • Posts: 21
  • Joined: 24-August 04
  • Gender:Male
  • Location:São Bernardo do Campo - SP - BRASIL

Quote

I am skipping Eggman monitor programming because I don't know the ASM codes for some commands in it.


But you're talking about S1, right? It can't be S2 because monitor code in that game is at a higher address. Eggman monitor does nothing in S1, so it isn't too hard to figure out what a jump to "4E 75" does. :P

Try to put in the next update info on how to have unused monitors to do something.

#3 User is offline Hivebrain 

Posted 25 October 2004 - 11:28 AM

  • Posts: 2658
  • Joined: 15-January 03
  • Gender:Male
  • Location:53.4N, 1.5W
  • Project:HivePal 2.0
  • Wiki edits:6,176
Wouldn't it be better to look at a disassembly if you want to know how things work?

#4 User is offline LOst 

Posted 25 October 2004 - 12:26 PM

  • Posts: 4886
  • Joined: 10-January 03
  • Gender:Male
  • Wiki edits:2
I made a document on this in pure assembler a long time ago. You can find it here:
http://area51.ssonic...p?showtopic=193

#5 User is offline Hayate 

Posted 25 October 2004 - 01:53 PM

  • Posts: 2379
  • Joined: 01-February 04
  • Gender:Male
  • Location:Torquay, England
  • Wiki edits:70
LOst, do you have a machine code to ASM table anywhere? That would help me out a lot more than this other stuff...

#6 User is offline Sonic 65 

Posted 25 October 2004 - 03:27 PM

  • Posts: 1166
  • Joined: 09-October 04
  • Gender:Male
  • Project:Dustin Wyatt's Epic Jailbreak
  • Wiki edits:13
I made a little machine-code-to-ASM text file sometime ago. The only problem is that it hasn't seen an update in ages. I'll update it a little and edit this post to have it attached.

Oh yeah, and Erik JS, the Eggman code is more than a jump to 4E 75.

addq.b #2, $24(a0) ;???
move.w #$1D, $1E(a0) ;???
move.b $1C (a0) ,d0 ;???
cmpi.b #1 , d0 ;Does monitor contain Eggman?
bne.s loc_A384 ;If not, branch
rts ;4E 75

NOTE: Actually, my file is ASM-to-machine code, but it can also be used vice-versa.

Attached File(s)


This post has been edited by Sonic 65: 25 October 2004 - 04:01 PM

#7 User is offline Rika Chou 

Posted 26 October 2004 - 07:15 AM

  • Adopt
  • Posts: 5172
  • Joined: 11-January 03
  • Gender:Not Telling
  • Location:CA US
  • Wiki edits:4
Very good, Sonic 65, I can tell you have put a lot of time into this.

#8 User is offline Sonic 65 

Posted 26 October 2004 - 03:56 PM

  • Posts: 1166
  • Joined: 09-October 04
  • Gender:Male
  • Project:Dustin Wyatt's Epic Jailbreak
  • Wiki edits:13
Thanks. Making a machine code guide isn't nearly as hard if you have a disassembly. :D

#9 User is offline Quickman 

Posted 26 October 2004 - 04:00 PM

  • Posts: 5584
  • Joined: 03-December 03
  • Gender:Male
  • Location::x
  • Project:omg porjcet
  • Wiki edits:10
Or you could just use the documentation Motorola give. That's how I learned ASM.

EDIT:

addq.b #2, $24(a0) ; advance to next object routine
move.w #$1D, $1E(a0) ; set collision size for object to $1D
move.b $1C (a0) ,d0 ; load animation frame into d0
cmpi.b #1 , d0 ; Subtract one from animation frame number (frame 1 is Eggman)
bne.s loc_A384 ; If not equal to 0 (I.e. if frame is not Eggman), continue to other frame checks
rts ; We'll reach here if it IS equal to 0 - nothing happens
This post has been edited by Quick Man: 26 October 2004 - 04:06 PM

#10 User is offline Hivebrain 

Posted 27 October 2004 - 08:27 AM

  • Posts: 2658
  • Joined: 15-January 03
  • Gender:Male
  • Location:53.4N, 1.5W
  • Project:HivePal 2.0
  • Wiki edits:6,176

Quote

move.w #$1D, $1E(a0) ; set collision size for object to $1D

Isn't $1E(a0) something to do with animation? IIRC, $1A-$1E(a0) are used by the animation subroutines.

#11 User is offline Hayate 

Posted 27 October 2004 - 09:11 AM

  • Posts: 2379
  • Joined: 01-February 04
  • Gender:Male
  • Location:Torquay, England
  • Wiki edits:70
Sonic 65: Sorry to sound annoying, but it doesn't have all of the commands, like ADD or BEQ (now that's useful)...

Edit: S65 for Tech Member! :D
This post has been edited by bobxp: 27 October 2004 - 09:12 AM

#12 User is offline Quickman 

Posted 27 October 2004 - 11:44 AM

  • Posts: 5584
  • Joined: 03-December 03
  • Gender:Male
  • Location::x
  • Project:omg porjcet
  • Wiki edits:10

Hivebrain, on Oct 27 2004, 01:27 PM, said:

Quote

move.w #$1D, $1E(a0) ; set collision size for object to $1D

Isn't $1E(a0) something to do with animation? IIRC, $1A-$1E(a0) are used by the animation subroutines.

I was going by MY document on the SST, hosted by drx on the Hacking CulT.

#13 User is offline Hivebrain 

Posted 27 October 2004 - 11:51 AM

  • Posts: 2658
  • Joined: 15-January 03
  • Gender:Male
  • Location:53.4N, 1.5W
  • Project:HivePal 2.0
  • Wiki edits:6,176

Quick Man, on Oct 27 2004, 04:44 PM, said:

Hivebrain, on Oct 27 2004, 01:27 PM, said:

Quote

move.w #$1D, $1E(a0) ; set collision size for object to $1D

Isn't $1E(a0) something to do with animation? IIRC, $1A-$1E(a0) are used by the animation subroutines.

I was going by MY document on the SST, hosted by drx on the Hacking CulT.

That document is inaccurate. And exactly how much of the information on it did you find yourself?

#14 User is offline Quickman 

Posted 27 October 2004 - 11:55 AM

  • Posts: 5584
  • Joined: 03-December 03
  • Gender:Male
  • Location::x
  • Project:omg porjcet
  • Wiki edits:10
I have no idea. I've long since lost the original to check (it was on my old hard drive before I got my computer which for the moment doesn't suck).

#15 User is offline Sonic Hachelle-Bee 

Posted 27 October 2004 - 01:21 PM

  • Lost in Wood zone
  • Posts: 724
  • Joined: 03-March 04
  • Gender:Male
  • Location:Paris, France
  • Project:Sonic 2 Long Version

Quote

Sonic 65: Sorry to sound annoying, but it doesn't have all of the commands, like ADD or BEQ (now that's useful)...

You've just asked for it. :(

Flags:
N: Negative. Set to 1 if result negative.
Z: Zero. Set to 1 if result is 0 (false).
V: Overflow. Set to 1 if overflow (Pos + Pos = Neg or Neg + Neg = Pos)
C: Carry.
X: Like C, Carry.

Assembly <-> Hexadecimal

MOVE.B <-> 11 FC 12 34 AB CD (Store byte 34 at RAM $ABCD)
MOVE.L <-> 21 FC 12 34 56 78 AB CD (Store long 12345678 at RAM $ABCD)
MOVE.W <-> 31 FC 12 34 AB CD (Store word 1234 at RAM $ABCD)

CMPI.B <-> 0C 38 12 34 AB CD (compare byte 34 at data from RAM $ABCD)
CMPI.W <-> 0C 78 12 34 AB CD (compare word 1234 at data from RAM $ABCD)
CMPI.L <-> 0C B8 12 34 56 78 AB CD (compare long 12345678 at data from RAM $ABCD)

BRA.S <-> 60 11 (Branch always, jump 11 bytes)
BSR.S <-> 61 11 (Branch under sub-routine)
BHI.S <-> 62 11 (Branch if C=0 and Z=0)
BLS.S <-> 63 11 (Branch if C=1 or Z=1)
BCC.S <-> 64 11 (Branch if Carry clear, C=0)
BCS.S <-> 65 11 (Branch if Carry set, C=1)
BNE.S <-> 66 11 (Branch if non equal, Z=0 (false))
BEQ.S <-> 67 11 (Branch if equal, Z=1 (true))
BVC.S <-> 68 11 (Branch if Overflow clear, V=0)
BVS.S <-> 69 11 (Branch if Overflow set, V=1)
BPL.S <-> 6A 11 (Branch if result plus, N=0)
BMI.S <-> 6B 11 (Branch if result minus, N=1)
BGE.S <-> 6C 11 (Branch if greater or equal to, N=V)
BLT.S <-> 6D 11 (Branch if lower than, N is not the same as V)
BGT.S <-> 6E 11 (Branch if greater than, N=V and Z=0)
BLE.S <-> 6F 11 (Branch if lower or equal to, N is not the same as V or Z=1)

ADD <-> 52 38 AB CD (Add 1 at value in RAM $ABCD)
ADD <-> 54 38 AB CD (Add 2 at value in RAM $ABCD)

JMP <-> 4E F9 11 11 11 11 (Jump at ROM $11111111)
JSR <-> 4E B9 11 11 11 11 (Jump at sub-routine at ROM $11111111)

NOP <-> 4E 71 (Non operation, do nothing and continue)
RTS <-> 4E 75 (Return to sub-routine)

EDIT: Examples:

RAM $FE10: Level loaded.
RAM $ FE 11: Act loaded.
RAM $ EE 00: Camera X position.
RAM $ EE 04: Camera Y position.
RAM $ F64A: Water Y height.

0C 78 04 01 FE 10 67 10
If Metropolis zone 2 (level 04 01) is loaded, jump 10 bytes.

0C 78 0E 00 EE 00 6F 08
If Camera X position is lower or equal to 0E 00, jump 08 bytes.

0C 78 15 00 EE 00 6F 10 31 FC 02 00 F6 4A
If Camera X position is greater than 15 00, set water Y height to 02 00.
Else, jump 10 bytes.

Helpful? There might be some errors, I haven't a 68K disassembly program for Mac, then I found this myself. ;)
This post has been edited by Sonic Hachelle-Bee: 28 October 2004 - 01:10 AM

  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users