Jump to content

Photo

DPC+ kernel and fixed_point_math.asm


8 replies to this topic

#1 gauauu OFFLINE  

gauauu

    Moonsweeper

  • 332 posts
  • Location:Illinois

Posted Wed Jul 26, 2017 3:48 PM

I've just started playing around with bBasic for the first time, and ran into this question.  I'm trying to use the DPC+ kernel, along with the fixed_point_math module.

 

If I include the fixed_point_math module at the beginning of my program, I get an Origin Reverse-indexed error upon compilation (it's over-filling the first bank where the DPC/arm code is supposed to be?):

 
  include fixed_point_math.asm

  set kernel DPC+
  set tv ntsc
  set optimization inlinerand


  goto __Start_Restart bank2

  bank 2

__Start_Restart
....etc

gives:

segment:  1fd4          eqm       vs current org: 202f
 free ram: 0
 DPC free RAM= 603
      -91 bytes of ROM space left in bank 1

spw.bas.asm (1407): error: Origin Reverse-indexed.

Alternatively, I could put the fixed_point_math into a different bank (bank 2?) but it wasn't clear how to make this work -- it seems bBasic keeps trying to do a bank jump to bank 1 to call the fixed point routines.

 

Let me know if I'm missing something obvious, or doing something dumb.  Thanks!

 



#2 RevEng OFFLINE  

RevEng

    River Patroller

  • 4,704 posts
  • Bitnik
  • Location:Canada

Posted Thu Jul 27, 2017 5:54 AM

The bB DPC+ format has hardly any space in the first bank, since it has it's kernel there. "include" sticks the included assembly module in the first bank, so it isn't going to work with DPC+.

Try using "inline fixed_point_math.asm" in another bank, somewhere away from the code flow.

A couple things to note - First, you only need to use fixed_point_math.asm if you're mixing 8.8 and 4.4 types together in math assignments. If you stick completely to 8.8 or 4.4 types, or if you don't do math that mixes 8.8 and 4.4 types, it isn't needed, since other fixed point operations are built right into the bB parser. Second, in a bank switched program you can only access include/inline routines from the bank containing the include/inline statement. So in this case, you'd need to limit your mixture of 8.8 and 4.4 types to that single bank.



#3 RevEng OFFLINE  

RevEng

    River Patroller

  • 4,704 posts
  • Bitnik
  • Location:Canada

Posted Thu Jul 27, 2017 7:25 AM

It looks like my inline solution will work for compiling, but not for usage. batari did add bank switching functionality, but it's fixed to bank 1. (as you advised) For now that means you can't mix 8.8 and 4.4 math in DPC+.

 

I've edited my previous post.



#4 gauauu OFFLINE  

gauauu

    Moonsweeper

  • Topic Starter
  • 332 posts
  • Location:Illinois

Posted Thu Jul 27, 2017 8:22 AM

Thanks, RevEng, that confirms what I was seeing.  

 

A couple things to note - First, you only need to use fixed_point_math.asm if you're mixing 8.8 and 4.4 types together in math assignments. If you stick completely to 8.8 or 4.4 types, or if you don't do math that mixes 8.8 and 4.4 types, it isn't needed, since other fixed point operations are built right into the bB parser. 

 

Yeah, I found this by experimentation.  I was hoping to mix them to save ram space (8.8 is overkill for velocity), but I'll have to try something else.

 

It looks like my inline solution will work for compiling, but not for usage. batari did add bank switching functionality, but it's fixed to bank 1. (as you advised) For now that means you can't mix 8.8 and 4.4 math in DPC+.

 

My other potential solution is a lot more drastic: include it into bank 2, then run a post-processor on the generated assembly to change all the calls so that they work properly in bank 2 instead :)



#5 gauauu OFFLINE  

gauauu

    Moonsweeper

  • Topic Starter
  • 332 posts
  • Location:Illinois

Posted Thu Jul 27, 2017 8:26 AM

Oh wait, bBasic comes with source code. Changing the bBasic compiler might be easier than making a post-processor  :)

 

 

What could possibly go wrong here....



#6 RevEng OFFLINE  

RevEng

    River Patroller

  • 4,704 posts
  • Bitnik
  • Location:Canada

Posted Thu Jul 27, 2017 8:45 AM

If you're going to do that, I think the jsrbank1() in statements.c might be a good place to introduce the change. Maybe use bank 2 as an alternate when DPC+ is being used. (bs==28 when DPC is used).

 

Fixing "include" to use bank 2 for DPC+ would be a bit more complicated, since the command insists on being first in the source (at bank 1). There are ways around that, but it's probably easiest to punt and just manually use the "inline" command in bank 2 for DPC+.



#7 gauauu OFFLINE  

gauauu

    Moonsweeper

  • Topic Starter
  • 332 posts
  • Location:Illinois

Posted Thu Jul 27, 2017 9:29 AM

Yeah, that's exactly what I was looking at.  Although I'm leaning towards just making sure all my fixed point math happens in bank 2, and changing it to a non-banked jump, just to make it more efficient.  



#8 RevEng OFFLINE  

RevEng

    River Patroller

  • 4,704 posts
  • Bitnik
  • Location:Canada

Posted Thu Jul 27, 2017 9:30 AM

Yeah, that's a good punt too. :)



#9 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 28,245 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Fri Aug 4, 2017 5:47 AM

The bB DPC+ format has hardly any space in the first bank, since it has it's kernel there. "include" sticks the included assembly module in the first bank, so it isn't going to work with DPC+.

Try using "inline fixed_point_math.asm" in another bank, somewhere away from the code flow.

A couple things to note - First, you only need to use fixed_point_math.asm if you're mixing 8.8 and 4.4 types together in math assignments. If you stick completely to 8.8 or 4.4 types, or if you don't do math that mixes 8.8 and 4.4 types, it isn't needed, since other fixed point operations are built right into the bB parser. Second, in a bank switched program you can only access include/inline routines from the bank containing the include/inline statement. So in this case, you'd need to limit your mixture of 8.8 and 4.4 types to that single bank.

 

I just remembered to add this to the bB page:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#reveng_fp_note






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users