Jump to content

Photo

IntyBASIC compiler v1.2.9: The good things are now better!

Intellivision IntyBASIC

361 replies to this topic

#351 artrag ONLINE  

artrag

    Dragonstomper

  • 991 posts

Posted Wed Mar 28, 2018 11:07 AM

I support any hardware related functionality easy to implement and useful to get faster/smaller/more efficient programs.
The noob programers can choose to use the commands they like and understand while more advanced coders can exploit the platform at its best without having to resort to assembly.

But of course, compromises are needed, for Oscar's sanity 😁

Edited by artrag, Wed Mar 28, 2018 11:10 AM.


#352 nanochess OFFLINE  

nanochess

    Processorus Polyglotus

  • Topic Starter
  • 5,389 posts
  • Coding something good
  • Location:Mexico City

Posted Wed Mar 28, 2018 12:34 PM

I support any hardware related functionality easy to implement and useful to get faster/smaller/more efficient programs.
The noob programers can choose to use the commands they like and understand while more advanced coders can exploit the platform at its best without having to resort to assembly.

But of course, compromises are needed, for Oscar's sanity


After all the requests I've implemented I'm not sane anymore :dunce:

#353 intvnut OFFLINE  

intvnut

    River Patroller

  • 3,020 posts
  • Location:@R6 (top of stack)

Posted Mon Apr 2, 2018 4:12 AM

Maybe a dull question.

I'm computing a bit mask for testing COLX for a given events

How do I do powers of 2 in intybasic ?

 

m = 2^n

 

It seems that ^ is not supported, I could solve with an array of bit masks but I wanted just to be sure that this is the sole way.

 

PS

Maybe an operator to shift bit positions could be more efficient and would allow things like this (COLX>>n) and 1 

 

Bit shifting by multiple positions is somewhat of a drag on the Intellivision, especially if the shift-amount is variable.

 

For testing bits, just declare a small table of bit values and use array indexing.  It will be quite a bit faster.

 

If you really want (x >> n) AND 1, for variable 'n', the execution time is going to be proportional to n unless you add a lookup table and use array indexing.



#354 artrag ONLINE  

artrag

    Dragonstomper

  • 991 posts

Posted Mon Apr 2, 2018 4:20 AM

I have a question about 

DEFINE card_num,total,XXXX

and

DEFINE ALTERNATE

 

Why you do not allow the use of a general 16bit expression in place of XXXX?

 

now in place of XXXX I use varptr #mydata(put the expression here)

This means in ASM mydata+expression, so, why not allow directly the user to point in memory according to its expression

 

In my case I have

 

REM graphic data

data0: data x,x,x,x....

data1: data x,x,x,x....

data2: data x,x,x,x....

 
datalist: data varptr data0(0),varptr data1(0),varptr data2(0),....
 
and I would like to do
 

DEFINE card_num,total,datalist(n)  <-- address of the nth graphic set 

 


#355 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 10,722 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Mon Apr 2, 2018 4:49 AM

 

Bit shifting by multiple positions is somewhat of a drag on the Intellivision, especially if the shift-amount is variable.

 

For testing bits, just declare a small table of bit values and use array indexing.  It will be quite a bit faster.

 

If you really want (x >> n) AND 1, for variable 'n', the execution time is going to be proportional to n unless you add a lookup table and use array indexing.

 

I just wanted to add to intvnut's comment to explain that the reason for the expense is that the CP-1610 shift instruction can only shift one or two bits at a time.  You can somewhat optimize shift amounts higher than 8 by using the SWAP instruction, which byte-swaps a register (indeed, this is what IntyBASIC's constant multiplication routine does; see the "MULT" macro in the "intybasic_epilogue.asm" file), but you still have to mask the irrelevant bits or extend the sign yourself.

 

If you really need to squeeze performance out of it, you are better off using a look-up table, like intvnut suggested.  Array indexing in IntyBASIC is pretty fast.

 

   -dZ.


Edited by DZ-Jay, Mon Apr 2, 2018 4:52 AM.


#356 artrag ONLINE  

artrag

    Dragonstomper

  • 991 posts

Posted Mon Apr 2, 2018 6:55 AM

In many high level compiled languages shift instructions are resolved by an in line sequence of shift/rotation asm instructions when not solved with a call to a loop of shifts.
In this, intellivision having shift by 2 positions and a swap instruction seems advantaged with respect to other architectures

#357 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 10,722 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Mon Apr 2, 2018 8:19 AM

In many high level compiled languages shift instructions are resolved by an in line sequence of shift/rotation asm instructions when not solved with a call to a loop of shifts.
In this, intellivision having shift by 2 positions and a swap instruction seems advantaged with respect to other architectures


True, but it is still slower than some alternatives. All shift instructions (including SWAP) cost 6 CPU cycles for a single position shift, and 8 for a two position shift. Doing it twice (for x >> 4) already puts you on level ground with a register immediate load and indirect move in from a look-up table.

Generalizing it may be more expensive.

Then again, I'm willing to bet that arbitrary shifts or multiplications are not the bottleneck of most IntyBASIC programs.

I do take your point that an idiom for "x >> n" allows for more expressivity, so why not?

dZ.

#358 nanochess OFFLINE  

nanochess

    Processorus Polyglotus

  • Topic Starter
  • 5,389 posts
  • Coding something good
  • Location:Mexico City

Posted Mon Apr 2, 2018 11:56 AM

DEFINE card_num,total,datalist(n)  <-- address of the nth graphic set


The most close thing to what you want to do is abusing VARPTR syntax:

#c = your_varptr_array(index)
DEFINE card_num,total,VARPTR xyz_array(#c - VARPTR xyz_array(0))

your_varptr_array:
DATA VARPTR bitmap0(0), VARPTR bitmap1(0)
I would prefer to use offsets instead of using VARPTR like this, more or less like this:

#c = my_offsets(index)
DEFINE card_num,total,VARPTR bitmaps(#c)

my_offsets:
DATA 0 * 4, 1 * 4    ' Multiplied by 4 because is the size of a 8x8 bitmap


#359 artrag ONLINE  

artrag

    Dragonstomper

  • 991 posts

Posted Wed Apr 4, 2018 5:50 AM

Another request :-)

 

Could SIGNED/UNSIGNED and DIM be combined in one line ?

 

I was expecting something like DIM SIGNED X(10),Y(10)



#360 artrag ONLINE  

artrag

    Dragonstomper

  • 991 posts

Posted Sat Apr 7, 2018 2:28 AM

Question, for confirmation:

 

I see that constants and labels can have the same name without any apparent conflict or side effect.

Is this a planned feature ?

If yes, maybe it could be documented in the manual 

 

I have this in my code and works fine

	const isr_menu  = 0
	const isr_title = 1
	const isr_game  = 2
	const isr_boss  = 3
	const isr_warp  = 4

[...]
	
	isr_mode = isr_menu

[...]

		on (isr_mode) 	goto	isr_menu, isr_title, isr_game, isr_boss, isr_warp
[...]
		
isr_title:
		if	play_log then 
			gosub log_play
		end if
		return 
isr_game:
		gosub bullet_multiplex
		gosub voice_samples
		gosub sfx_player
		return
isr_boss:
[...]

Edited by artrag, Sat Apr 7, 2018 2:31 AM.


#361 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 10,722 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Sat Apr 7, 2018 4:44 AM

 

Question, for confirmation:

 

I see that constants and labels can have the same name without any apparent conflict or side effect.

Is this a planned feature ?

If yes, maybe it could be documented in the manual 

 

I have this in my code and works fine

	const isr_menu  = 0
	const isr_title = 1
	const isr_game  = 2
	const isr_boss  = 3
	const isr_warp  = 4

[...]
	
	isr_mode = isr_menu

[...]

		on (isr_mode) 	goto	isr_menu, isr_title, isr_game, isr_boss, isr_warp
[...]
		
isr_title:
		if	play_log then 
			gosub log_play
		end if
		return 
isr_game:
		gosub bullet_multiplex
		gosub voice_samples
		gosub sfx_player
		return
isr_boss:
[...]

 

 

Are you saying that a constant and a label with the same name do not collide?  If so, this is probably by design, since a constant (an arbitrary value) is conceptually different from a label (a location in the program).

 

I would imagine that it only needs to be documented if they collide, since that would be non-obvious behaviour.  Now, a variable and a constant, on the other hand, should exist in the same namespace, so they cannot have the same name.

 

   -dZ.

 

 

EDIT:  I misunderstood artag's comment originally, so re-wrote my response.


Edited by DZ-Jay, Sat Apr 7, 2018 4:50 AM.


#362 Darkhog OFFLINE  

Darkhog

    Chopper Commander

  • 156 posts

Posted Tue May 29, 2018 9:35 AM

I wish we could easily edit envelopes without editing the epilogue files. Proposed syntax:

 

ENVELOPE (envid) (envdata)

 

Where envid would be one of the numbers used for envelopes in the music data and the envelope data would be in the same format it is in the epilogue asm file. Perhaps even allow for more instruments? This would also allow for instrument remapping: Don't need a piano now and need it other instruments? Remap it with the command.







Also tagged with one or more of these keywords: Intellivision, IntyBASIC

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users