Respectful greetings, fellow hackers;
I think I might be writing bloated code. Sometimes there just isn't enough usable freespace in a ROM to add huge new subroutines. Super Mario Bros. 3 actually has a lot of (usually bank-switched) freespace addresses, but with other ROMs we aren't always so lucky. Could you guys evaluate the following routines & provide some useful suggestions about how I can get away with fewer instructions? Sorry about the format, it was easier to just copy/paste from Nestopia's .nsp cheat file:
The first two branch statements seem like they can be made into one, that is if I can carry the conditional flag appropriately. Or am I wrong? To overcome certain limitations, is it possible to load values into either the X or Y registers, thus beneficially altering the resultant conditional flag? Supposing I could do that, I'd be saving 3 lines of code at worst. Any code-reducing recommendations will be helpful!
Also: Do you have any good tutorials or fact sheets regarding bank switching? I already know that any particular ROM can hold only so much data, but I'd like to use that space to its fullest and use bank switching to alternate the RAM, even at the cost of gameplay speed.
I think I might be writing bloated code. Sometimes there just isn't enough usable freespace in a ROM to add huge new subroutines. Super Mario Bros. 3 actually has a lot of (usually bank-switched) freespace addresses, but with other ROMs we aren't always so lucky. Could you guys evaluate the following routines & provide some useful suggestions about how I can get away with fewer instructions? Sorry about the format, it was easier to just copy/paste from Nestopia's .nsp cheat file:
Code:
SMB3 Flying Hack version 0.3 [B]// jump to freespace -CHEAT 0xFEC7 0xB6 0x12 on -CHEAT 0xFEC8 0x9F 0xFF on // test against the SELECT button -CHEAT 0x9FB6 0xA5 0xFF on (load button state) -CHEAT 0x9FB7 0xF7 0xFF on -CHEAT 0x9FB8 0x29 0xFF on (is select pressed?) -CHEAT 0x9FB9 0x20 0xFF on -CHEAT 0x9FBA 0xF0 0xFF on (if false, BEQ to JMP) -CHEAT 0x9FBB 0x24 0xFF on -CHEAT 0x9FBC 0x18 0xFF on (CLC) // test against the ground state -CHEAT 0x9FBD 0xA5 0xFF on (load ground state) -CHEAT 0x9FBE 0xD8 0xFF on -CHEAT 0x9FBF 0x29 0xFF on (in the air?) -CHEAT 0x9FC0 0x03 0xFF on -CHEAT 0x9FC1 0xF0 0xFF on (if false, BEQ to JMP) -CHEAT 0x9FC2 0x1D 0xFF on -CHEAT 0x9FC3 0x18 0xFF on (CLC) // keep player's vertical velocity at 0 -CHEAT 0x9FC4 0xA9 0xFF on -CHEAT 0x9FC5 0x00 0xFF on -CHEAT 0x9FC6 0x85 0xFF on -CHEAT 0x9FC7 0xCF 0xFF on // test against UP button -CHEAT 0x9FC8 0xA5 0xFF on (load button state) -CHEAT 0x9FC9 0xF7 0xFF on -CHEAT 0x9FCA 0x29 0xFF on (conditional UP button press) -CHEAT 0x9FCB 0x08 0xFF on -CHEAT 0x9FCC 0xF0 0xFF on (if false, BEQ to DOWN test) -CHEAT 0x9FCD 0x06 0xFF on -CHEAT 0x9FCE 0x18 0xFF on (CLC) // if true, rise by specified amount -CHEAT 0x9FCF 0xA9 0xFF on (load a value) -CHEAT 0x9FD0 0xDF 0xFF on -CHEAT 0x9FD1 0x8D 0xFF on (save it) -CHEAT 0x9FD2 0xCF 0xFF on -CHEAT 0x9FD3 0x00 0xFF on // test against DOWN button -CHEAT 0x9FD4 0xA5 0xFF on (load button state) -CHEAT 0x9FD5 0xF7 0xFF on -CHEAT 0x9FD6 0x29 0xFF on (conditional DOWN button press) -CHEAT 0x9FD7 0x04 0xFF on -CHEAT 0x9FD8 0xF0 0xFF on (if false, BEQ to JMP) -CHEAT 0x9FD9 0x06 0xFF on -CHEAT 0x9FDA 0x18 0xFF on (CLC) // if true, fall by specified amount -CHEAT 0x9FDB 0xA9 0xFF on (load a value) -CHEAT 0x9FDC 0x23 0xFF on -CHEAT 0x9FDD 0x8D 0xFF on (save it) -CHEAT 0x9FDE 0xCF 0xFF on -CHEAT 0x9FDF 0x00 0xFF on // return to original JSR destination -CHEAT 0x9FE0 0x4c 0xFF on -CHEAT 0x9FE1 0x12 0xFF on -CHEAT 0x9FE2 0xFF 0xFF on [/B]
Also: Do you have any good tutorials or fact sheets regarding bank switching? I already know that any particular ROM can hold only so much data, but I'd like to use that space to its fullest and use bank switching to alternate the RAM, even at the cost of gameplay speed.
I'll check into the 6502 docs to see what can be done.
Comment