Avoiding using signed multiplication while in Mode 7
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Avoiding using signed multiplication while in Mode 7
Unfortunately my sprite rotation routine happens outside of the main loop, and can be interrupted by NMI at any time, and uses multiplication registers so it needs to disable interrupts. Doing so might cause it to go into NMI pretty late, causing black bars if the DMA is also being used.
Re: Avoiding using signed multiplication while in Mode 7
The multiplication registers do their work in the background, and software only has to read and write them, right? I'd think that the state of those registers would survive the NMI interrupt, as long as you don't touch those registers in your interrupt routine. Let me know if I'm wrong though.
SNES NTSC 2/1/3 1CHIP | serial number UN318588627
Re: Avoiding using signed multiplication while in Mode 7
I mean, that's only a problem if the interrupt is using the multiplier too, right? I suppose one might wish to leave the option open...psycopathicteen wrote:uses multiplication registers so it needs to disable interrupts.
Alternately, you could dedicate a couple of banks to an 8x8 multiplication table. I think the ALU should be a bit faster, especially if you use the waiting time intelligently, but you could use tabulated multiplication in interrupts without worrying about what the main code is doing, and if you wanted to waste four banks instead of two you could do 7x7 signed multiply just as easily.
Let's see:
Code: Select all
sep #$20
lda A
xba
lda B
rep #$20
asl
tax
bcs +
lda.l multable_low,x
bra ++
+ lda.l multable_high,x
++
Hold on. If you split the results into low-byte and high-byte tables:
Code: Select all
sep #$20
lda A
xba
lda B
tax
lda.l multable_hib,x
xba
lda.l multable_lob,x
rep #$20
Last edited by 93143 on Mon Jan 29, 2018 4:54 pm, edited 1 time in total.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Avoiding using signed multiplication while in Mode 7
The entire game runs in the "NMI" code. All that's being done outside of NMI, is rotating sprites, and that takes many frames to finish.
I decided to check what scanline the code is on before doing the multiplication and if it is on the last 2 lines in a frame it waits for the next frame.
I decided to check what scanline the code is on before doing the multiplication and if it is on the last 2 lines in a frame it waits for the next frame.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Avoiding using signed multiplication while in Mode 7
Now I just need to figure out how to seamlessly switch to Mode 7 mid level. I'd have to make an alternate version of the tile-map scrolling code. I can probably limit the first area of the level to use the second 16kB chunk of VRAM, and only use the first half the Mode-7 layer's memory.