Jump to content
Sign in to follow this  
Osmeroid

H-O-M question

Recommended Posts

I know its not true programming but I was messing around with Barnstorming using Hack-O-Matic & managed to to get the game to restart everytime I flew the airplane over the first windmill. The (apparent?) significance of this did not register on me until later & have now erased that modified file.

 

Question is, is Hack-O-Matic purely an image editor or can you play around with the source code of the rom with it?

Share this post


Link to post
Share on other sites

Hack-O-Matic may seem like just a sprite editor, but actually you are altering the bytes of the program. These bytes could be anything from sprites to program instructions to data tables...it doesn't matter to HOM (in fact, I've posted cheats in the past that can be done with a standard sprite editor like HOM...since they are the easiest Rom editors to use).

 

As a program editor, HOM would be a bad choice (since it would be more alien to read...even to a seasoned programmer). The purpose of source code is to be understandable to the programmer, and seemingly random pixels on the screen are impossible to read through quickly enough to be of any use.

 

Anyway, it's important that you only alter the lines where you KNOW a sprite exists. In the program or other data table areas, a pixel in the wrong spot may make the game undecypherable by the CPU...crashing it out or having unpredictable effects.

 

BTW a "source code" of a program is really just a text file...completely alien to the computer. In order to run it, the code needs to be compiled into machine language (which creates the .bin file containing all of those bits (pixels) seen in HOM. In other words, the computer never "runs" source code.

Share this post


Link to post
Share on other sites

Thanks Nukey, a few attempts have crashed on me as I tried just randomly altering bits to see what happened.

 

After reading Kirk Israel's "2600 101" tutorial & playing around on H-O-M, attempting some real programming for the 2600 doesn't seem quite so intimidating.

 

Famous last words! :D

Share this post


Link to post
Share on other sites

You might want to look into the debugging feature of an emulator like PCAE...where you can actually see the instructions that those bytes contain. When I was at a total loss to understand where to begin looking for interesting effects, I could always resort to using NOP instructions in place of the original ones. The NOP instruction is ignored by the computer...so I could see what the game wasn't doing the next time I ran it. This worked out especially well when I was hacking into 8-bit games...which usually have a good deal of JSR instructions. JSR tells the computer to jump to a different part of the program to do something...so by covering up that instruction with NOPs, I would have a good chance of seeing what that part of the program was supposed to do. Example:

Let's assume that this instruction is in a game...

 

$7000 : JSR $84FF...20 FF 84

$7003 : (etc.)

 

$7000 is the instruction's address...sort of like the line number in Basic. It pinpoints exactly where the instruction is in the M/L code. The instruction is telling the processor to jump to a subroutine at $84FF. So if I wanted a clue on what the routine there did, I could just cover it up with NOP instructions (by using the value $EA). Now the program looks like this:

$7000 : NOP...EA

$7001 : NOP...EA

$7002 : NOP...EA

$7003 : (etc.)

I would use three EAs because the instruction originally used three bytes.

 

If I ran the hacked program and found that the firebutton was not working, it probably means that the routine at $84FF has something to do with what is supposed to happen when the button is pressed...or maybe how the program checks to see if it was.

 

Granted, this type of hit-and-miss reverse engineering is probably more effective on an 8-bit computer...since that hardware pretty much takes care of itself. The 2600 is much more sensitive since the program has to run it's own show.

 

BTW you can use HOM to generate NOPs for you. You would use the binary value of 11101010 (put pixels where the 1s are). It's still pretty tricky though, because without looking at a disassembly you might be covering up just part of an instruction. If I would have just used a couple of them in the above example, the program would get confused...

 

$7000 : JSR $EAEA...20 EA EA

$7003 : (etc)

 

The program is jumping way off someplace else instead of doing nothing.

Share this post


Link to post
Share on other sites

So to use that facility, would your line would look like this?

 

$7000 : NOP JSR $84FF...20 FF 84 EA

 

 

Would you recommend using PCAE over StellaX for development & testing purposes?

 

I've had problems in the past using PCAE, like just running unmodified games on it.

 

Do the emulators differentiate (in terms of display) between NTSC & PAL?

 

I only ask this as one particular aspect of Simon Quernhorst's Mental Kombat that I really liked was using a console switch (colour/bw) to actually run the game in either TV format, sort of like having a universal cart! I think that this is one of the cleverest innovations I've encountered & if (a BIG if!) I ever managed to produce a game I'd really like to be able to add this function in. But how could you tell if the program's format switch had worked just using an emulator?

 

Perhaps I'm seeing trouble where there isn't any.

Share this post


Link to post
Share on other sites
So to use that facility, would your line would look like this?  

 

$7000 : NOP JSR $84FF...20 FF 84 EA

 

No...you are not "adding" anything really. The alteration "covers up" what was originally there. By using 3 NOPs at $7000, the JSR $84FF that was there would simply cease to be there. BTW, 65xx instructions can only be a maximum of 3 bytes long.

 

Would you recommend using PCAE over StellaX for development & testing purposes?

 

Yes, because the debugger gives you the ability to "step" through a program (i.e. pausing after every instruction). Machine language is extremely fast compared to Basic, and effects might wink out before you even get a chance to notice them.

 

Dunno much about PAL...but I imagine that the display kernal is different between the two formats. In Mental Kombat, the program just probably checks the switch to see what position it's in, and then stores that value in Ram. Whenever something is to be displayed, the program could use that value to decide which part of the program to do (i.e. two kernals).

Techs?

Share this post


Link to post
Share on other sites
No...you are not "adding" anything really.  The alteration "covers up" what was originally there.  By using 3 NOPs at $7000, the JSR $84FF that was there would simply cease to be there.  BTW, 65xx instructions can only be a maximum of 3 bytes long.

 

I got it - sort of like taking a detour past that piece of coding? Reminds me of using 'REM' statements in BASIC (many, many moons ago) :D

Share this post


Link to post
Share on other sites

Yep. JSR's are like Basic's GOSUB statement (M/L uses RTS instead of RETURN). So in a Basic program line like 10 GOSUB 200, you could just edit it to be 10 REM to skip the statement (of course, you could just as well remove the line completely, but you'd run into problems if another line GOTO's it). In machine language, you don't need line numbers...since every part of the .bin is already at a specific address. So if you didn't know what a certian JSR did, you could just cover the instruction completely with machine language's NOP instructions to help give a clue what that part of the program is supposed to be doing. The number of the values on the right (after the ...) is the number of NOPs that you need to use.

Share this post


Link to post
Share on other sites
I only ask this as one particular aspect of Simon Quernhorst's Mental Kombat that I really liked was using a console switch (colour/bw) to actually run the game in either TV format, sort of like having a universal cart!  I think that this is one of the cleverest innovations I've encountered & if (a BIG if!) I ever managed to produce a game I'd really like to be able to add this function in.

 

Thank you, Osmeroid. :-)

 

I wanted to implement PAL/NTSC compatibility from the beginning on. When I started VCS programming I hoped that there would be a PAL/NTSC-register inside the machine, just like in a C=64, but there wasn't. So I had to use a console switch for that purpose.

 

On C=64 you can read a constant register and can check whether a PAL or NTSC machine is used. Back in the days when C=64-games were imported they needed to be fixed to work properly on PAL or NTSC and that fix was mostly installed with checking that register. Nevertheless not everyone seemed to know, as I remember a crack of "Grand Prix Circuit" where you had to push either "P" for PAL or "N" for NTSC mode. :D :D

 

Simon

Share this post


Link to post
Share on other sites

I :love: this site...where else can you get timely feedback from

the programmers themselves??

 

@Simon--

Was this sweatshop worker ever paid? j/k :)

hb01.jpg

Share this post


Link to post
Share on other sites

@Nukey - So do the kernels in 6502 assembly work similarly to the 'procedures' found in Pascal?

 

 

@Simon - Credit where its due! :D

Share this post


Link to post
Share on other sites

You're talking to the wrong guy...I only know how to hack up other people's work ;) And I never worked with Pascal (heck, even Forth had me confused).

Share this post


Link to post
Share on other sites
@Simon--

Was this sweatshop worker ever paid? j/k :)

 

Of course she was! I tried to convince her with a private copy of my game, but she wanted money for her work. :D

 

And because of the massive work she had with producing those 200 headbands (and the very expensive printing of the cardboard-gameboxes), the special edition of Mental Kombat is that expensive. I'm sorry for that, but the boxes and the headbands make the game something very special I think and I'm still not sorry for having produced them.

 

Due to the high price, I still have around 25 copies of the special edition left. I hope that there are still some more collectors to order the pack...

Share this post


Link to post
Share on other sites

Kernels are more like the main loop in Pascal programs. Or more specifically, the timing sensitive part of the main loop - you don't want to call any other procedures (JSR's) from within it if you can avoid it since you're too busy changing the color shooting out of the electron beam as it makes its way down the screen. ;)

 

Can't remember what the syntax/idiom is because it's been about 10 years since I wrote Turbo Pascal code - procedure main() maybe?

 

Rob

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...