SNES Splatoon (How do I shot HiROM?)
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
Re: SNES Splatoon (Not Even A Demo Yet Though...)
The latest version of bsnes-plus has the option to use the otherwise-unused WDM instruction as a breakpoint, so it will only affect execution if that option is enabled but is basically a no-op otherwise. It's probably ideal for development compared to "normal" breakpoints since you don't have to know exactly where the code of interest is located in memory.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES Splatoon (Not Even A Demo Yet Though...)
Revenant wrote:If you want the BRK instruction to actually freeze the game, you should make it lead to an infinite loop rather than an RTI. Or ideally, use an emulator that supports breakpoints (which it looks like you're already doing) and use those instead.
Oh, that's what I wanted to do. I thought "BRK" would just stop the CPU in whatever way, but "STP" is what does that. Yeah, it freezes both times now, like intended. I actually went through the splat drawing code, and somehow, it goes through the entire thing and exits at the right spot (I put STPs at all the exits except the intended one, and I tested to see how far it would go by moving how far I placed the STP) but nothing gets drawn. I'm going to have to look over it carefully. I don't think I've ever made a code work not as intended but without having it crash, so this is new to me.93143 wrote:no$sns will automatically open the debugger on STP.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES Splatoon (Not Even A Demo Yet Though...)
I think I might have found something out. I've actually been busy even during spring break, so I haven't been able to work on this...
Anyway, instead of
I wrote
and looked at $7E2000 to see if anything showed up, but somehow, the game actually crashed. I looked at the spot in ram, and it appeared to be empty, and I then looked around $0000 and it was filled with FFFF. I'm assuming by some miracle that it worked originally, because I thought that "and #$0000" would make everything there 0, and I was speculating that the "y" value was incorrect and not getting the right data but the weirdest thing is that it's crashing even when I wrote
Anyway though, it really shouldn't be writing anything in that location anyway if long addressing is being used, which I feel it isn't. Is there a way to force it?
Anyway, apparently to add to my confusion, take a look at this:
None of those #$87's should be there, and only two bytes should be filled out at most. I'm assuming another code is looking at the variables in ram that are no incorrect and if freaking out. A couple values actually get updated every frame, surprisingly.
Code: Select all
lda InkBuffer,x
and $0000,y
ora $0002,y
sta InkBuffer,xCode: Select all
lda #$FFFF
sta InkBuffer,xCode: Select all
lda #$0000
sta InkBuffer,xAnyway, apparently to add to my confusion, take a look at this:
None of those #$87's should be there, and only two bytes should be filled out at most. I'm assuming another code is looking at the variables in ram that are no incorrect and if freaking out. A couple values actually get updated every frame, surprisingly.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES Splatoon (Not Even A Demo Yet Though...)
I found something. Putting an "stp" at the end of the drawing code (to where no other code gets written) still produces the same garbage in ram, so it must be something self contained. Isn't there a way to make ca65 give you files that say exactly what the assembler is doing, because it makes 0 sense for it to be screwing up for loading a number there. putting an "stp" after the first thing I did in ram doesn't appear to create the weird crazy patterns I showed you guys, but it might be messing up a variable that's triggering a chain reaction. Again, I need the files to tell me if it's the assembler's fault, and I've already had one of those with a different assembler...
Damn it, does anyone else ever get problems like this?
Edit: I thought it would be wise to upload the .bat file I use for assembling everything, so if anyone knows how to fix it to give me .lst files, here it is:
I have two .exe files called ca65 and ld65, if that helps. It looks like several people have already downloaded the .zip file I posted though.
Damn it, does anyone else ever get problems like this?
Edit: I thought it would be wise to upload the .bat file I use for assembling everything, so if anyone knows how to fix it to give me .lst files, here it is:
Code: Select all
@echo off
ca65 Main.asm -o Game.o
if errorlevel 1 goto end
ld65 -o Game.sfc Game.o -C SNES.cfg
if errorlevel 1 goto end
ucon64 -q --snes --nhd --chk %1.sfc >nul 2>&1
echo assembly completed.
if exist Game.o del Game.o
if exist Game.sfc start Game.sfc
exit
:end
echo assembly failed.
if exist Game.o del Game.oRe: SNES Splatoon (Not Even A Demo Yet Though...)
Espozo wrote:Code: Select all
ca65 Main.asm -o Game.o
Code: Select all
ca65 -l Main.asm -o Game.oRe: SNES Splatoon (Not Even A Demo Yet Though...)
My guess is that you're pushing a register without popping it, building up values on the stack. Checked for that?
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES Splatoon (Not Even A Demo Yet Though...)
I just checked for that, and no, there's no pushing or pulling involved. That shouldn't even mess it up anyway, because it's only ran once. The "lda #$0000" definitely shouldn't mess it up.nicklausw wrote:My guess is that you're pushing a register without popping it, building up values on the stack. Checked for that?
I tried that but it didn't work. I was actually messing around with it, and I fixed it though by guessing:Joe wrote:ca65 -l Main.asm -o Game.o
Code: Select all
ca65 Main.asm -o Game.o -l Game.lstI just noticed something. How did I know this would happen...
Code: Select all
0003BFr 2 BD rr rr lda InkBuffer,xRe: SNES Splatoon (Not Even A Demo Yet Though...)
If the data segment register B is equal to $7E, you can access variables in $7E0000-$7EFFFF using 2-byte addresses. That might save a cycle.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES Splatoon (Not Even A Demo Yet Though...)
How would I do this? I just don't want to do long addressing when I don't need to, and the assembler seems to think that InkBuffer fits in a 16 bit address...
Re: SNES Splatoon (Not Even A Demo Yet Though...)
Code: Select all
phb
; 8-bit accumulator (EDIT)
lda #$7e
pha
plb
; do stuff with bank $7e
lda $2100 ;wow mom, I loaded $7e2100 !!
plb ; restore old databank
Last edited by bazz on Fri Mar 18, 2016 12:35 pm, edited 1 time in total.
Re: SNES Splatoon (Not Even A Demo Yet Though...)
Don't forget the accumulator needs to be in 8-bit mode (sep #$20 minimum) for aforementioned to work properly, otherwise you'll eventually end up with a stack overflow. So be sure to add that to your cycle counting, in addition to any necessary rep #$20 or equivalent thereafter.
Re: SNES Splatoon (Not Even A Demo Yet Though...)
One trick I like to do is pea two bytes onto the stack and then plb one at a time.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES Splatoon (Not Even A Demo Yet Though...)
Wait a minute, if the bank register is set to anything other than #$00 and I want to load from something from an area in ram where the top 8 bits are #$00, then won't I have to do "a:" and take up an extra cycle for that?
This is what I'm doing, if it helps. It's taking 8 2bit pixels, masking them, applying a pattern, and then storing them in the original spot. Each step is its own line.
This is what I'm doing, if it helps. It's taking 8 2bit pixels, masking them, applying a pattern, and then storing them in the original spot. Each step is its own line.
Code: Select all
lda InkBuffer,x
and $0000,y
ora $0002,y
sta InkBuffer,xRe: SNES Splatoon (Not Even A Demo Yet Though...)
The RAM at $0000-$1FFF is mirrored in both bank $00 and bank $7E.
Re: SNES Splatoon (Not Even A Demo Yet Though...)
Exhaustively:
The only RAM as such in bank $00 (other than a handful of sometimes-useful bytes in the $43xx range) is what some call shadow RAM, the mirror of the bottom 8K of WRAM. If you're in any bank from $00-$3F or $80-$BF, shadow RAM works normally. If you're accessing bank $7E, shadow RAM still works normally, because $7E:0000-1FFF is what shadow RAM is a mirror of.
If you're in bank $7F or $40-$7D or $C0-$FF, you don't have access to shadow RAM. You can use direct page, because direct page is always in bank $00. But if what you want isn't in direct page, you have to either change the data bank register to access a bank with shadow RAM, change the direct page register so the data you want is in range, or use 24-bit addressing.
The only RAM as such in bank $00 (other than a handful of sometimes-useful bytes in the $43xx range) is what some call shadow RAM, the mirror of the bottom 8K of WRAM. If you're in any bank from $00-$3F or $80-$BF, shadow RAM works normally. If you're accessing bank $7E, shadow RAM still works normally, because $7E:0000-1FFF is what shadow RAM is a mirror of.
If you're in bank $7F or $40-$7D or $C0-$FF, you don't have access to shadow RAM. You can use direct page, because direct page is always in bank $00. But if what you want isn't in direct page, you have to either change the data bank register to access a bank with shadow RAM, change the direct page register so the data you want is in range, or use 24-bit addressing.