Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
1 user currently in Rom Hacking: hukka | 2 guests
Acmlm's Board - I2 Archive - Rom Hacking - FCEUXD progress (04-09-05) | |
Pages: 1 2Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Parasyte

Bullet Bill
Level: 35

Posts: 425/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-10-05 08:29 AM Link | Quote
Ahoy!
Regulars in #rom-hacking probably know that I have been updating some pieces of FCEUXD recently. While I don't have a complete list of changes, here are the important ones:

1) A lot of bugs in the memory editor have been fixed, including visual bugs as well as potentially harzardous bugs.
2) PPU Viewer has been updated slightly to use 8-bit bitmaps, rather than 32-bit. This SHOULD help speed things up some.
3) A completely new disassembler has been written. It's no longer using a standard edit control, but a custom control I am writing. This will allow for colors, and other drawn features to aid in debugging.
4) Conditional breakpoints are implimented and fully working! *See below for more information.


Here's what the new disassembler looks like, so far:

(Click for larger view)

Eventually, I want to include jump and branch pointers (Meaning arrows drawn to show where branches and jumps lead) and other features from IDA. It will also be integrated with the memory editor so you may see modified bytes in red and such. Execute breakpoints will display the address(es) in red. Read/write breakpoints will also be shown in different colors (data bytes will be colored in this case). Double clicking an address will add a n execute breakpoint, double clicking bytes will add read/write breakpoints. Single clicking an address or byte will display the "file address" just as the old disassembler's "helper bar" did on mouse-over. A right-click menu will give you access to "Send to Memory Editor" and "Send to GG Encoder" options, among other things.
I'm also looking for other suggestions, if anyone has a few. So shoot away!


Now for the conditional breakpoints! This is the really interesting part of the post. Originally, I had planned to make conditions similar to C-syntax expressions, such as "A == $30" and "(A != 0) && (A != $FF)", but it would require a compiler to parse the expressions properly. Noting this, I decided to create a pseudo-machine code language to handle the conditions. Oddly enough, I've named it "Pseudo-Machine Code" or PMC. PMC is a very simple assembly-like language with no real syntax specs. Since it's only purpose is for handling breakpoint conditions in FCEUXD exclusively, I have not developed the language much beyond the opcode stage.
Now, since I have not written a compiler yet, we are entering our conditionals in raw PMC. Raw PMC looks a lot like just a bunch of hex numbers. And that's because that is exactly what it is! The first PMC program I wrote (by the way, it's pretty interesting creating a new programming language and writting the first program for it) was one to cause a break only when the [PPU] hardware was displaying a certain scanline. This kind of condition is extremely useful for debugging precisely timed code...

To help illustrate what a PMC program (condition) looks like, and how it works, I will paste the full contents of the pmc.h include file from the newest build of FCEUXD:

/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 Jason Oster
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/


/*
Pseudo Machine Code (PMC) engine

Simple Low-Level specs:
Two 16-bit registers named r0 and r1.
Program counter named i.
Full access to NES memory via READ instruction.
Access to NES registers and non-memory data via COPY instruction.
Immediate value loading via LOAD instruction.
Jump instructions with integrated unsigned comparison against r0 and r1.
Subroutine return instructions with integrated return value.

Compiler specs:
Work register (operand) defined in LSB of all instructions.
Instructions without register operands make no current use of LSB.
Jumps are compiled on the first pass with a 'pointer' to indicate where to jump
MSB signifies to second pass that the byte is a label for jumps.
On second pass, jump 'pointer' is replaced with an i-relative pointer, based on where the pointed label is found.
Labels are removed on second pass in favor of above behavior.

Virtual syntax:
READ: 2-byte operand for little endian pointer
LOAD: 2-byte operand for little endian value
COPY: 1-byte operand for source
JUMP: 1-byte operand for i-relative increment (unsigned)

Notes:
For i-relative jumps, i = next instruction. A jump operand of 0 will literally never jump.
*/


//PMC opcodes
#define PMC_READ 0x00 /* Read NES memory into r0 or r1 */
#define PMC_LOAD 0x02 /* Load immediate value into r0 or r1 */
#define PMC_COPY 0x04 /* Copy NES register into r0 or r1 */
#define PMC_JMPE 0x10 /* Jump if r0 == r1 (unsigned) */
#define PMC_JMPN 0x12 /* Jump if r0 != r1 (unsigned) */
#define PMC_JMPG 0x14 /* Jump if r0 > r1 (unsigned) */
#define PMC_JMPL 0x16 /* Jump if r0 < r1 (unsigned) */
#define PMC_JUMP 0x18 /* Unconditional jump */
#define PMC_GOOD 0x20 /* End routine with success */
#define PMC_EROR 0x22 /* End routine with error */

//defines for PMC registers
//#define PMC_R0 0x00
//#define PMC_R1 0x01

//defines for COPY instruction
#define PMC_COPY_A 0x00 /* NES A register */
#define PMC_COPY_X 0x01 /* NES X register */
#define PMC_COPY_Y 0x02 /* NES Y register */
#define PMC_COPY_PC 0x03 /* NES PC register */
#define PMC_COPY_S 0x04 /* NES Stack register */
#define PMC_COPY_SCAN 0x05 /* NES Scanline counter */


Once you've read that, you can take a look at the scanline condition:
022000050510012220

WTF does that mean?! Let's break it down:

02 20 00  LOAD r0,$0020  ;load 32 into r0
05 05 COPY r1,SCAN ;copy scanline counter into r1
10 01 JMPE i+$01 ;if r0 == r1, jump to GOOD
22 EROR ;exit with error (no break)
20 GOOD ;exit with success (cause break)


As you can see, this PMC will cause a break if the scanline counter is currently at 32 -- scanline 32. So you may place a BPX on the range $0000 - $FFFF, with the above PMC condition. The game will continue running until scanline 32 is reached. Quite a thing of beauty!

Some examples of things you can do with PMC conditions: Ignore execution of certain address ranges, ignore breaks when registers contain certain values, ignore breaks that occur outside of Vblank, accurately time your code along with Hblank ... etc!
While these things are all well and good, PMC is still lacking some functionality, which will develop over time. Mainly the lack of a compiler or assembler, even though the language is so simple, we're writing it in pure binary. It is also lacking pointer support. With pointer support, you will be able to cause breaks on certain instructions by reading the byte at PC, or watching the stack and other such things. It is quite a powerful conditional sub-system, and I'm a bit proud of it. ;D

I would expect to see the next FCEUXD release in a few months or so, if all goes well. (Which probably won't be the case, in all honesty.)


OK! Now bring on your suggestions and concerns.


(edited by Parasyte on 04-10-05 02:48 AM)
Setzer

Popo
Level: 36

Posts: 169/532
EXP: 290182
For next: 17928

Since: 04-22-04
From: Not Florida. because I'm going to sink it.

Since last post: 5 hours
Last activity: 48 min.
Posted on 04-10-05 08:31 AM Link | Quote
I didn't read it all yet; But I want to be the first [on this forum anyways] to say kick ass.
edit: Okay, now that I read it. and figured out it's power. the only words I can think of to say are "I love you" and "kick ass"


(edited by Skiffles on 04-09-05 03:44 PM)
iamhiro1112

Armos
Level: 35

Posts: 369/487
EXP: 259927
For next: 20009

Since: 03-27-04
From: sd

Since last post: 18 days
Last activity: 7 days
Posted on 04-10-05 09:03 AM Link | Quote
I look forward to the new release. I hope you guys put in programmable keys. As in we can edit what button we can use to access certain features. Right now I use Joy 2 key so that I can save and load with my controller.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4111/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 04-10-05 09:52 AM Link | Quote
Have my baby.

I'll have to incorporate a lot of these into my GB emulator on the odd chance I ever finish it. You gonna release that control?
Geiger

Buster Beetle
Level: 34

Posts: 350/460
EXP: 241080
For next: 12571

Since: 03-15-04
From: Indianapolis, IN, USA

Since last post: 6 hours
Last activity: 6 hours
Posted on 04-10-05 10:15 AM Link | Quote
02 20 00  LOAD r0,$0020  ;load 32 into r0
05 05 COPY r1,SCAN ;copy scanline counter into r1


How are you specifying r0 and r1 here?

---T.Geiger
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4113/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 04-10-05 11:01 AM Link | Quote
Originally posted by Parasyte
Work register (operand) defined in LSB of all instructions.
Instructions without register operands make no current use of LSB.

Come to think of it, that also answers my question as to why it skips all the odd numbers. (Though why are 6-F skipped? )

Are there going to be compares for >= and <= too? It'd help shorten the code a bit.
Parasyte

Bullet Bill
Level: 35

Posts: 427/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-10-05 11:48 AM Link | Quote
I'm glad I'm not that one who had to point out the obvious. ;D

As for the not-so-obvious, I had no plans for <= or >=, because those can be done with JMPE and JMPL(G) together. Adding them wouldn't really hurt anything, though...
Why were some defines skipped? Future expansion! As I mentioned in the initial post, PMC is missing some things, like pointer access. For that, I will probably use a MOVE instruction, located at 0x06... I don't see much use for bitwise logic or arithmetic instructions, but if they are needed, there's still plenty of room for expansion!

Also, I'm debating whether I should change the 'compiler specs' so it doesn't use the MSB for labels. Instead, it may be better to keep a local symbol table, with each label referencing it. Though that's a bit out of scope, as it's something the user will never see.

[D'oh!] Yes, the control source will be released. Afterall, the whole project always has (and always will be) open source via GPL.


(edited by Parasyte on 04-09-05 06:51 PM)
(edited by Parasyte on 04-09-05 06:52 PM)
Kyoufu Kawa
I'm not bad. I'm just drawn that way.
Level: 70

Posts: 1410/2481
EXP: 3008456
For next: 7355

Since: 03-19-04
From: Catgirl Central

Since last post: 14 hours
Last activity: 13 hours
Posted on 04-10-05 05:06 PM Link | Quote
Well, that makes two acmlmboarders that write their own psuedocode and are proud of it.
Parasyte

Bullet Bill
Level: 35

Posts: 429/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-10-05 07:35 PM Link | Quote
I suppose so!


Well, I tried adding the copy/paste functionality to the disassembler control, but got a bit side-tracked and added branch/jump x-ref (Cross-Reference) handling instead. It's a bit primative, at the moment, but it looks really nice.

Here's some eye candy:
(Bigger images with the clickage!)







(edited by Parasyte on 04-10-05 02:48 AM)
(edited by Parasyte on 04-10-05 02:49 AM)
Sokarhacd

Ball and Chain Trooper
Resistance is Futile
You Will Be Assimilated
Hab SoSlI' Quch
Level: 61

Posts: 1130/1757
EXP: 1799888
For next: 76708

Since: 03-15-04

Since last post: 6 days
Last activity: 4 hours
Posted on 04-10-05 08:38 PM Link | Quote
awesome, I might have to get back into nes hacking when this is released
Setzer

Popo
Level: 36

Posts: 170/532
EXP: 290182
For next: 17928

Since: 04-22-04
From: Not Florida. because I'm going to sink it.

Since last post: 5 hours
Last activity: 48 min.
Posted on 04-11-05 03:11 AM Link | Quote
There's no reason not to get back into NES hacking now. the current debugger is fine; they're just re-writing it to be more awesomefull.
Dwedit

Shyguy
Level: 17

Posts: 21/92
EXP: 20794
For next: 3949

Since: 04-26-04

Since last post: 5 days
Last activity: 1 day
Posted on 04-11-05 03:31 AM Link | Quote
Conditional logging perhaps? I'd like to log all the output on controller 1's port so I can figure out how the Miracle Piano IO works.
Apophis

Red Super Koopa
Level: 45

Posts: 448/882
EXP: 640255
For next: 19909

Since: 03-15-04

Since last post: 15 hours
Last activity: 15 hours
Posted on 04-11-05 03:36 AM Link | Quote
Any idea when we can expect it to be released? I know you said in the next few months, but can you be any more specific?


(edited by Apophis on 04-10-05 10:37 AM)
Googie

Surarok
Level: 39

Posts: 334/624
EXP: 380784
For next: 23987

Since: 03-15-04
From: Corona Queens New York

Since last post: 3 hours
Last activity: 3 hours
Posted on 04-11-05 04:39 AM Link | Quote
Makin an already awsome program even better? Sign me up! I can't wait for the next release.
Parasyte

Bullet Bill
Level: 35

Posts: 430/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-11-05 06:30 AM Link | Quote
Apophis, I can't be any more specific; it could be sooner, could be later. Depends a lot on how I spend my free time. ;O

Dwedit, what exactly do you need? Using breakpoints and copying the addresses down should be enough to get you started, right? That's the method I use when hacking most everything.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4152/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 04-11-05 07:50 AM Link | Quote
Kickass. Might help to colour the arrows though; I can't follow them very well in some of the more complicated-looking ones.
Dwedit

Shyguy
Level: 17

Posts: 22/92
EXP: 20794
For next: 3949

Since: 04-26-04

Since last post: 5 days
Last activity: 1 day
Posted on 04-11-05 10:06 AM Link | Quote
I've mainly been using custom compiles of Nester to log all output on 4016 to a binary file. But it looks like all the piano IO is being written via register A rather than register X, so I'd like a way to log all output from register A to 4016. Then maybe I could somehow analyze it and try to find midi data in there or something.
drjayphd

Beamos
What's that spell?




pimp!
Level: 56

Posts: 943/1477
EXP: 1387410
For next: 10766

Since: 03-15-04
From: CT

Since last post: 2 hours
Last activity: 2 hours
Posted on 04-11-05 11:52 AM Link | Quote
Holy crap, someone remembers the Miracle Piano?! How are you even using that? I'd imagine there's enough keys on a keyboard, never mind the controller.
Dwedit

Shyguy
Level: 17

Posts: 23/92
EXP: 20794
For next: 3949

Since: 04-26-04

Since last post: 5 days
Last activity: 1 day
Posted on 04-11-05 09:19 PM Link | Quote
For the sound output, I could see using a patch map to translate it into general midi, or maybe just using some sample sets, or possibly even piping it directly into an actual miracle piano (which I have hooked up to my PC!).

If you have a MIDI keyboard plugged in, it should be an obvious choice for an input device. For stuff like Rhythm Practice or Robo Man, maybe even a joystick is enough.
Parasyte

Bullet Bill
Level: 35

Posts: 432/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-11-05 09:57 PM Link | Quote
Dwedit, why can't you just use breakpoints and manually copy [some of] the assembly into notepad? All the cool kids are doing it... But really, I'm not sure why you would need 'conditional logging'? The logger in FCEUXD already does something similar, thanks to the CDL.

As for trouble making sense of the x-refs, yes, it can get confusing. I don't know if I want to do arrow highlighting, but I will definitely do special highlights on single click... (Yep! IDA style!) For example, you can click on an address, and all instances of that addresses will be highlighted with a special background color just for this type of highlighting. I suppose it MAY be possible to add arrow coloring, as well. But the main problem I foresee is that destination addresses with many x-refs will ALL have their arrows colored. That would probably not help things in a lot of cases. So rather than basing arrow highlighting on the addresses (x-refs) it might as well be done based on the 'selected' line of disassembly. In that way, it would disregard arrows pointing to the selected line, and color only the arrow leading from it. Hmm, that would actually work quite well in conjuntion with the single-click highlighter.

Blah, blah. I think I'm rambling now. It's all this lack-of-sleep, I tell you!


(edited by Parasyte on 04-11-05 04:58 AM)
Pages: 1 2Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Rom Hacking - FCEUXD progress (04-09-05) | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.021 seconds.