| |||
Views: 88,442,959 |
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search | 04-20-24 05:01 PM |
|
Guest: Register | Login |
0 users currently in ROM Hacking | 1 guest |
Main - ROM Hacking - 6502 ASM Questions... [Please?] | New thread | New reply |
MapleMario |
| ||
Red Koopa Level: 27 Posts: 17/126 EXP: 111383 Next: 4776 Since: 04-28-07 From: USA Last post: 5063 days Last view: 3882 days |
I tried compiling my ASM file with asm6, and it gave me errors on the labels. In addition I tried compiling some of the snippets posted earlier and again it gave me errors. Ca65 worked fine for me but it outputted a ".o" file and I don't know how to inject that into NES ROM.
Also, just out of curiosity... how would I draw, say, a fire flower (or really any sprite) to a certain position on the game screen? I haven't seen this kind of thing covered in any tutorial and I can't begin to think of how to do it. First, how do you do conditionals? Would the easiest/most efficient way for, say, checking if the accumulator is less than a certain RAM value be to use a CMP/CPX/CPY or a BEQ/BNE/something of that sort? In addition, for either of these, how would I run certain code if the condition evaluates to be true, and certain other code if it doesn't? Also, can someone tell me how to do ROM expansion? I'm not very good at finding freespace XD. I haven't had much experience with low-level programming languages so be gentle with me please. ____________________ SGMB3 is now being developed with Reuben. Hopefully v1.0 will be released by the time I get world 1 done... - Layout: MM v0.31 |
boingboingsplat |
| |||||
Giant Koopa [PREFSTRING:wonderful bounciness] Level: 74 Posts: 1214/1292 EXP: 3632013 Next: 21531 Since: 07-23-07 From: Michicola Last post: 4836 days Last view: 4799 days |
|
smkdan |
| ||
Ninji Level: 36 Posts: 225/238 EXP: 288515 Next: 19595 Since: 05-26-07 Last post: 4057 days Last view: 4006 days |
CMP sets carry flag if content of A is larger or equal to the value used in the CMP. It will not branch, it will simply fall through to the instruction if carry flag ends up being set. BCC just branches if carry flag is clear. BCS being the opposite. BEQ/BNE is the same for zero flag and there's more for negative/overflow. It's important to know that much about how they actually work to get the full use out of them.
Another way to do conditional stuff (can be faster in some places) is to follow up an increment/decrement with BEQ or BNE. INX/INY/DEX/DEY set the zero flag based on the result in X or Y. If I wanted to do a loop using this...
bit more obscure: this tests the number of '1' bits in a RAM address:
DEX sets zero flag based on what result was after decrementing X. Until it hits zero, it will keep branching back to loop so STA $2007 is run 64 times. The branches just act based on what flags in status register are at the time and instructions like INX/CMP/ADC etc. modify them. The other example uses the fact that LSR puts bit0 into carry flag so it can then be used by BCC to determine if bit0 was set or not. --- For rom expansion I'm guessing this is the NES? You have to take a look at what mapper the game uses (if it uses one that is, a 32KB program ROM on a mapperless game demands you hack in a mapper before increasing amount of PRG ROM). nesdevwiki is a decent reference for popular ones. If the games uses CHR ROM then the PRG ROM is sandwiched between the iNES header and CHR. If the mapper allows for expansion based on the current ROM isze, you can insert however many banks of data for your own use. But then you have to hack the game to actually take advantage of the free space, you must insert a hack to switch to the free bank (how you do this depends on the mapper of your game) since the NES only sees 32KB or sometimes 40KB of ROM at any given time. On the SNES it's not really an issue since you have direct access normally to 4MB of ROM without bank switching. On the NES you have to switch manually for almost every game. |
MapleMario |
| ||
Red Koopa Level: 27 Posts: 18/126 EXP: 111383 Next: 4776 Since: 04-28-07 From: USA Last post: 5063 days Last view: 3882 days |
About the ROM expansion, I'm hacking SMB3. I think it uses PRG but I'm not sure.
About the ASM, I think I understand what you're saying about BEQ/BNE/BCC/BCS, but I'd like to ask one thing: When you declare a label, how do you compile that into bytecode? For example, if you could just take your first example there and compile that for me, I think it'd be easier. Or can I just use a subroutine there? Can I say BEQ $DCD0 in the same way that I use JSR $DCD0? ____________________ SGMB3 is now being developed with Reuben. Hopefully v1.0 will be released by the time I get world 1 done... - Layout: MM v0.31 |
Kawa |
| ||
CHIKKN NI A BAAZZKIT!!! 80's Cheerilee is best pony Level: 138 Posts: 3276/5344 EXP: 30930698 Next: 732283 Since: 02-20-07 From: The Netherlands Last post: 4492 days Last view: 2627 days |
Posted by MapleMarioIsn't that a bit of a given? I think you meant to say it uses the MMC3 mapper ____________________ Wife make lunch - Shampoo Opera - give it a spin Spare some of your free time? <GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered Kawa rocks — byuu |
never-obsolete |
| ||
Rat Level: 24 Posts: 61/96 EXP: 74461 Next: 3664 Since: 02-22-07 From: Phoenix, AZ Last post: 2590 days Last view: 2590 days |
The operand for branches is an 8bit signed displacement, so as long as the destination is within range, you can. Keep in mind that a return address will not be pushed onto the stack. |
MapleMario |
| ||
Red Koopa Level: 27 Posts: 21/126 EXP: 111383 Next: 4776 Since: 04-28-07 From: USA Last post: 5063 days Last view: 3882 days |
Posted by Kawa Lol, yeah, that's what I meant. Posted by never-obsolete That'd be fine. Thanks. So I'm assuming that for CMP, using something like the following:
Would that work the way I intend it to? ____________________ SGMB3 is now being developed with Reuben. Hopefully v1.0 will be released by the time I get world 1 done... - Layout: MM v0.31 |
never-obsolete |
| ||
Rat Level: 24 Posts: 62/96 EXP: 74461 Next: 3664 Since: 02-22-07 From: Phoenix, AZ Last post: 2590 days Last view: 2590 days |
You need to put a branch and destination. A JMP is needed if you don't want the second function called.
Here's an explanation on how the compares work. There's a table in the middle that shows which branch to use for each equality test. |
MapleMario |
| ||
Red Koopa Level: 27 Posts: 22/126 EXP: 111383 Next: 4776 Since: 04-28-07 From: USA Last post: 5063 days Last view: 3882 days |
Posted by never-obsolete Thanks, but I still don't understand how you could compile _isMore and _isLess and _exit into bytecode insertable into the SMB3 ROM. EDIT: Wait, sorry, I didn't see your link when I posted. Let me go check that out. EDIT2: Yeah, I still can't see how you would compile those names into bytecode. ____________________ SGMB3 is now being developed with Reuben. Hopefully v1.0 will be released by the time I get world 1 done... - Layout: MM v0.31 |
boingboingsplat |
| ||||
Giant Koopa [PREFSTRING:wonderful bounciness] Level: 74 Posts: 1216/1292 EXP: 3632013 Next: 21531 Since: 07-23-07 From: Michicola Last post: 4836 days Last view: 4799 days |
|
smkdan |
| ||
Ninji Level: 36 Posts: 226/238 EXP: 288515 Next: 19595 Since: 05-26-07 Last post: 4057 days Last view: 4006 days |
http://www.romhacking.net/utils/674/
Is easy to use and has decent feature set. I used ca65 before for NES stuff but it requires some setting up to get it up and running, but it's very powerful. Not the best one to use for starting out for sure. Labels, includes and whole bunch of other stuff (depends on feature set) are specific to the assembler so try out asm6. |
MapleMario |
| ||
Red Koopa Level: 27 Posts: 23/126 EXP: 111383 Next: 4776 Since: 04-28-07 From: USA Last post: 5063 days Last view: 3882 days |
Posted by smkdan Thanks, that looks about perfect. I tried compiling my ASM file, and it gave me errors on the labels. In addition I tried compiling some of the snippets posted earlier and again it gave me errors. Ca65 worked fine for me but it outputted a ".o" file and I don't know how to inject that into NES ROM. ____________________ SGMB3 is now being developed with Reuben. Hopefully v1.0 will be released by the time I get world 1 done... - Layout: MM v0.31 |
Main - ROM Hacking - 6502 ASM Questions... [Please?] | New thread | New reply |
© 2005-2023 Acmlm, blackhole89, Xkeeper et al. |
MySQL - queries: 87, rows: 118/119, time: 0.017 seconds. |