Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
User | Post |
Sukasa Posts: 74/2068 |
Nah, I use SNES as a base for the calculations, but the final result is a String, SNES$. Do you know how to make a variable 32 bit? I have rebuilt this computer, and although I didn't install and OS'es onto it, I know that the processor IS a 32 bit proc. SNES is just used because I wondered if converting to a string and back all the time was casing a problem, but the original code only had PC and SNES$, not PC, SNES$, and SNES.
EDIT: Oh, and I tried using the decimal form of it. It screwed that up, too. |
Euclid Posts: 11/83 |
if that's the case you can always replace &H8000 with 32768, but if the variables PC and SNES are 16 bits then it's already impossible to do this calculation since snes addresses are 24 bits long. |
Sukasa Posts: 69/2068 |
Ah. I'm using qbasic right now, since that's easily available to me for quick stuff. I will try your bank calcultion method, I just hope the HEX$() won't mess up like it has been.
EDIT: I think I know one problem: It keeps using 16-bit numbers. Print &HA000 gives me -24576 or something similar to that. No wonder- If it ran in 32-bit natively, I wouldn't have had any problems in the first place! |
Euclid Posts: 10/83 |
i don't know what language that code is in but here's how i usually do it (for lorom anyway)
addr = PC mod 0x8000 + 0x8000 bank = PC / 0x8000 (decimal division, just truncate decimals or something similar if the programming language you're using leaves decimals) after that it's your choice what you do with those 2 values. |
Sukasa Posts: 64/2068 |
Like the title suggests, I'm working on some code to convert a PC address into a SNES LoROM address for SMW, but when I try to get the bank number, I can either get it correctly in decimal, or way off in hex. I'm working with qbasic right now, and the code does this to get the bank number:
LET SNES = (PC - (PC MOD &H8000) / &H8000 ' get decimal bank number LET SNES$ = STR$(SNES) ' get decimal bank number, string form That works perfectly fine, as does the rest of the code, but only if I want the bank number to be decimal (the code to get the lower 16 bits of the address works perfectly, and outputs hex). However, LET SNES$ = HEX$(SNES) in place of LET SNES$ = STR$(SNES) puts out this, when &H316557 is the input PC address: FFFFFF9E:E557 Also, if STR$ is used, it gives me 98:E557. instead of 62:E557, which is what Lunar address gives me. Could anyone please tell me what I am doing wrong? I tried HEX$(&H100000000 - SNES), but it got an overflow error (presumably because &H100000000 is a 33-bit number, on a 32-bit proc). |