Jump to content
IGNORED

Fixed point math and bankswitching?


jrok

Recommended Posts

I've been having some trouble getting fixed point math to work with bankswitched games. I've tried to troubleshoot the fixed-point module, but I feel like my head is screwed on backwards looking at it. compilation fails.

 

In the version of fixed_point_math.asm that I have, it assigns for bankswitched games with:

 

 ifconst bankswitch
Assign88to44bs:

; A(4.4) = A,X(8.8)

   stx temp1
   rol temp1
   asl
   rol temp1
   asl
   rol temp1
   asl
   rol temp1
   asl
   RETURN

;assignment from 4.4 to 8.8
;

Assign44to88bs:

; A,X(8.8) = A(4.4)

   sta temp1
   lda #0
   asl temp1
   sbc #0;
   eor #$ff; do sign extend
   rol
   asl temp1
   rol
   asl temp1
   rol
   asl temp1
   rol
   ldx temp1
   RETURN
endif

 

If the program contains no operations, then it compiles fine. But compilation fails on any operation, additive or subtractive. Is this a portion of the module that just wasn't completed? If anyone has found a workaround, I gladly will send you chocolates and a case of beer. I am using the latest-greatest 2600basic.exe and DASM V2.20.07. Thanks in advance!

 

fixed_point_math.zip

bankswitch.zip

 

EDT:

I just attached a sample program (courtesy of Michael Rideout) that illustrates the problem. Compile fails on this operation:

 

   if c{1} then p0_y = p0_y - momentum

 

jumping.bas

Edited by jrok
Link to comment
Share on other sites

I'm not sure why compilation fails - by my limited analysis, it should compile but not work correctly unless all calculations are in the first bank. I had long forgotten about this issue. It arises because programmers typically include the fixed point math routines at the beginning of the code and they go in the first bank, so it didn't work with the framework that put certain graphics routines in the last bank, and I never fixed it.

 

If compilation is failing, can you show us the error generated? You are including the fixed point math module, right?

Link to comment
Share on other sites

Hi Fred. Thanks for the help!

 

I'm not sure why compilation fails - by my limited analysis, it should compile but not work correctly unless all calculations are in the first bank. I had long forgotten about this issue. It arises because programmers typically include the fixed point math routines at the beginning of the code and they go in the first bank, so it didn't work with the framework that put certain graphics routines in the last bank, and I never fixed it.

 

Yep, one of the first things I tried wsa including the routines in the last bank, but that didn't work.

 

If compilation is failing, can you show us the error generated? You are including the fixed point math module, right?

 

If it's an addition operation it fails on:

  Add44to88				0000 ????		 (R )

 

If subtraction:

  Sub44from88				0000 ????		 (R )

 

I added an example BAS file to my original post above if that's any help. The program compiles and functions without bankswitching routines, but fails with them.

 

Thanks again!

Jarod.

Link to comment
Share on other sites

That helps. First, the compiler generates a warning on line 3, telling us the include is ignored because it was placed after the "includesfile" command. Moving it before the includesfile does not allow it to compile, however - the includesfile alone is not enough to fully specify bankswitching - you also need to set the ROM size. It's not necessary to specify the includesfile at all, actually, unless you're using a customized one with a different name.

 

So to fix, place your include fixed_point_math first, then set romsize to whatever your size is.

 

And... I'll see if I can fix the issue with fixed point math routines (and other math routines for that matter) working only in the first bank.

Edited by batari
Link to comment
Share on other sites

That helps. First, the compiler generates a warning on line 3, telling us the include is ignored because it was placed after the "includesfile" command. Moving it before the includesfile does not allow it to compile, however - the includesfile alone is not enough to fully specify bankswitching - you also need to set the ROM size. It's not necessary to specify the includesfile at all, actually, unless you're using a customized one with a different name.

 

So to fix, place your include fixed_point_math first, then set romsize to whatever your size is.

 

And... I'll see if I can fix the issue with fixed point math routines (and other math routines for that matter) working only in the first bank.

 

Thanks Fred! Compiles fine now. Where do I send the chocolate and beer?

 

Cheers,

Jarod

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...