Jump to content

Photo

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

Intellivision IntyBASIC

384 replies to this topic

#301 First Spear OFFLINE  

First Spear

    Stargunner

  • 1,286 posts
  • Location:Somewhere in Uptown

Posted Wed Jan 24, 2018 7:03 AM

Where can the latest IntyBASIC "constants.bas" be found for use with v1.2.9?

 

The one I have looks like the included. Thanks!

 

Attached File  constants.bas   27.91KB   20 downloads

 

 

Spoiler



#302 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Wed Jan 24, 2018 8:33 AM

The latest constants.bas is always included with distribution with Mark blessing.



#303 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,818 posts
  • Busy bee!
  • Location:England

Posted Wed Jan 24, 2018 1:51 PM

Is there no way to use colored squares mode in IntyBASIC? I don't think I've ever tried it.


Check out ColouredSquares.bas in the contrib folder of IntyBASIC. It draws lines in that mode.

#304 carlsson ONLINE  

carlsson

    Metagalactic Mule

  • 7,323 posts
  • Location:Västerås, Sweden

Posted Thu Feb 1, 2018 4:16 AM

Is this a general question/support thread? If so, is there any way to seed either of the random number generators in IntyBASIC, so you get a known sequence of pseudo random numbers? I don't see any mention of this in the manual, but perhaps it has been covered in the forum before.

 

If not, I'm fine writing my own PRNG that has that ability.



#305 Kiwi OFFLINE  

Kiwi

    Stargunner

  • 1,580 posts

Posted Thu Feb 1, 2018 5:40 AM

I think the RAND uses the FRAME to generate a random number.  I do not know whether or not you could write a new 16-bit number into this variable FRAME.  This could be the seed for the RNG.



#306 carlsson ONLINE  

carlsson

    Metagalactic Mule

  • 7,323 posts
  • Location:Västerås, Sweden

Posted Thu Feb 1, 2018 6:14 AM

Hm, I came to a similar conclusion. I might use the Defender of the Crown PRNG instead.



#307 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Thu Feb 1, 2018 8:00 AM

Is this a general question/support thread? If so, is there any way to seed either of the random number generators in IntyBASIC, so you get a known sequence of pseudo random numbers? I don't see any mention of this in the manual, but perhaps it has been covered in the forum before.
 
If not, I'm fine writing my own PRNG that has that ability.


It used to start at zero at boot, but now it's seeded with the random numbers remaining in RAM at boot.

You can force it to a seed using:

        ASM MVI #value,R0    ; Anything between 0-255
        ASM MVO R0,_rand


#308 carlsson ONLINE  

carlsson

    Metagalactic Mule

  • 7,323 posts
  • Location:Västerås, Sweden

Posted Thu Feb 1, 2018 8:12 AM

I might try that later, except that I would first generate N "free flowing" random seeds that I assign to an array or similar, and then reseed the PRNG with respective seed. I will study the ASM file to figure out how such arrays normally are addressed. By placing the array as the first variable, I should be able to deterministically use inline assembly language to reseed the PRNG.

Edit: I tried this, which for me appears like the random number sequence is similar, but not the exact same. Or perhaps I have another bug in my code, which is fully possible.

  ASM MVII #0,R0
  ASM MVO R0,_rand
  ASM MVO R0,_frame
The reason I reset _frame is that it is involved in the routine _next_random.

Edited by carlsson, Thu Feb 1, 2018 9:01 AM.


#309 intvnut OFFLINE  

intvnut

    River Patroller

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

Posted Thu Feb 1, 2018 12:43 PM

I might try that later, except that I would first generate N "free flowing" random seeds that I assign to an array or similar, and then reseed the PRNG with respective seed. I will study the ASM file to figure out how such arrays normally are addressed. By placing the array as the first variable, I should be able to deterministically use inline assembly language to reseed the PRNG.

Edit: I tried this, which for me appears like the random number sequence is similar, but not the exact same. Or perhaps I have another bug in my code, which is fully possible.
 

  ASM MVII #0,R0
  ASM MVO R0,_rand
  ASM MVO R0,_frame
The reason I reset _frame is that it is involved in the routine _next_random.

 

 

_next_random is called from an interrupt service routine.  So, if anything changes your timing relative to display refresh, that'll change your random number stream.



#310 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Thu Feb 1, 2018 9:11 PM

I might try that later, except that I would first generate N "free flowing" random seeds that I assign to an array or similar, and then reseed the PRNG with respective seed. I will study the ASM file to figure out how such arrays normally are addressed. By placing the array as the first variable, I should be able to deterministically use inline assembly language to reseed the PRNG.

Edit: I tried this, which for me appears like the random number sequence is similar, but not the exact same. Or perhaps I have another bug in my code, which is fully possible.
 

  ASM MVII #0,R0
  ASM MVO R0,_rand
  ASM MVO R0,_frame
The reason I reset _frame is that it is involved in the routine _next_random.


I think you should do a WAIT before running this code in order to synchronize state.

#311 intvnut OFFLINE  

intvnut

    River Patroller

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

Posted Sun Feb 4, 2018 2:26 AM

In another thread, nanochess mentioned something about posting where IntyBASIC doesn't generate the best possible code.  Here's one I recently noticed.

 

I come from the C and C++ world, where writing a += b is exceedingly natural.  It's supposed to be equivalent to writing a = a + b.  Right now, at least for arrays, it turns out it's more efficient to write that as a = b + a, as the address of 'a' for the input gets loaded last, and reused for the result.

 

Consider this input:

.

DIM #P(8), #V(8), #A(8)

ASM ; This one sucks:
FOR I = 0 TO 7
    #V(I) = #V(I) + #A(I)
    #P(I) = #P(I) + #V(I)
NEXT I

ASM ; This one is much better:
FOR I = 0 TO 7
    #V(I) = #A(I) + #V(I)
    #P(I) = #V(I) + #P(I)
NEXT I

.

Now lets look at the generated code.  I've removed unnecessary comments/directives from the output to make it (hopefully) easier to follow.

.

    ;FILE quality.bas
    ;[1] DIM #P(8), #V(8), #A(8)
    ;[3] ASM ; This one sucks:
 ; This one sucks:
    ;[4] FOR I = 0 TO 7
    CLRR R0
    MVO R0,V1
T1:
    ;[5]     #V(I) = #V(I) + #A(I)
    MVII #Q4,R3
    ADD V1,R3
    MVI@ R3,R0
    ADDI #(Q5-Q4) AND $FFFF,R3
    ADD@ R3,R0
    ADDI #(Q4-Q5) AND $FFFF,R3
    MVO@ R0,R3
    ;[6]     #P(I) = #P(I) + #V(I)
    ADDI #(Q3-Q4) AND $FFFF,R3
    MVI@ R3,R0
    ADDI #(Q4-Q3) AND $FFFF,R3
    ADD@ R3,R0
    ADDI #(Q3-Q4) AND $FFFF,R3
    MVO@ R0,R3
    ;[7] NEXT I
    MVI V1,R0
    INCR R0
    MVO R0,V1
    CMPI #7,R0
    BLE T1
    ;[9] ASM ; This one is much better:
 ; This one is much better:
    ;[10] FOR I = 0 TO 7
    CLRR R0
    MVO R0,V1
T2:
    ;[11]     #V(I) = #A(I) + #V(I)
    MVII #Q5,R3
    ADD V1,R3
    MVI@ R3,R0
    ADDI #(Q4-Q5) AND $FFFF,R3
    ADD@ R3,R0
    MVO@ R0,R3
    ;[12]     #P(I) = #V(I) + #P(I)
    MVI@ R3,R0
    ADDI #(Q3-Q4) AND $FFFF,R3
    ADD@ R3,R0
    MVO@ R0,R3
    ;[13] NEXT I
    MVI V1,R0
    INCR R0
    MVO R0,V1
    CMPI #7,R0
    BLE T2

.

I'm not saying IntyBASIC needs a hardcore expression canonicalizer.  I am saying, though, that IntyBASIC programmers should be aware that a = a + b may be noticeably more expensive than a = b + a, and that's a bit counter-intuitive.



#312 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Sun Feb 4, 2018 7:30 AM

In another thread, nanochess mentioned something about posting where IntyBASIC doesn't generate the best possible code.  Here's one I recently noticed.
 
I come from the C and C++ world, where writing a += b is exceedingly natural.  It's supposed to be equivalent to writing a = a + b.  Right now, at least for arrays, it turns out it's more efficient to write that as a = b + a, as the address of 'a' for the input gets loaded last, and reused for the result.
 
Consider this input:
.

DIM #P(8), #V(8), #A(8)

ASM ; This one sucks:
FOR I = 0 TO 7
    #V(I) = #V(I) + #A(I)
    #P(I) = #P(I) + #V(I)
NEXT I

ASM ; This one is much better:
FOR I = 0 TO 7
    #V(I) = #A(I) + #V(I)
    #P(I) = #V(I) + #P(I)
NEXT I
.
Now lets look at the generated code.  I've removed unnecessary comments/directives from the output to make it (hopefully) easier to follow.
.
    ;FILE quality.bas
    ;[1] DIM #P(8), #V(8), #A(8)
    ;[3] ASM ; This one sucks:
 ; This one sucks:
    ;[4] FOR I = 0 TO 7
    CLRR R0
    MVO R0,V1
T1:
    ;[5]     #V(I) = #V(I) + #A(I)
    MVII #Q4,R3
    ADD V1,R3
    MVI@ R3,R0
    ADDI #(Q5-Q4) AND $FFFF,R3
    ADD@ R3,R0
    ADDI #(Q4-Q5) AND $FFFF,R3
    MVO@ R0,R3
    ;[6]     #P(I) = #P(I) + #V(I)
    ADDI #(Q3-Q4) AND $FFFF,R3
    MVI@ R3,R0
    ADDI #(Q4-Q3) AND $FFFF,R3
    ADD@ R3,R0
    ADDI #(Q3-Q4) AND $FFFF,R3
    MVO@ R0,R3
    ;[7] NEXT I
    MVI V1,R0
    INCR R0
    MVO R0,V1
    CMPI #7,R0
    BLE T1
    ;[9] ASM ; This one is much better:
 ; This one is much better:
    ;[10] FOR I = 0 TO 7
    CLRR R0
    MVO R0,V1
T2:
    ;[11]     #V(I) = #A(I) + #V(I)
    MVII #Q5,R3
    ADD V1,R3
    MVI@ R3,R0
    ADDI #(Q4-Q5) AND $FFFF,R3
    ADD@ R3,R0
    MVO@ R0,R3
    ;[12]     #P(I) = #V(I) + #P(I)
    MVI@ R3,R0
    ADDI #(Q3-Q4) AND $FFFF,R3
    ADD@ R3,R0
    MVO@ R0,R3
    ;[13] NEXT I
    MVI V1,R0
    INCR R0
    MVO R0,V1
    CMPI #7,R0
    BLE T2
.
I'm not saying IntyBASIC needs a hardcore expression canonicalizer.  I am saying, though, that IntyBASIC programmers should be aware that a = a + b may be noticeably more expensive than a = b + a, and that's a bit counter-intuitive.

I could enhance this. BTW it was even worst before you suggested the ADD offset feature. ;)

#313 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 11,067 posts
  • The P-Machinery AGE is almost here!
  • Location:NC, USA

Posted Sun Feb 4, 2018 7:44 AM

I could enhance this. BTW it was even worst before you suggested the ADD offset feature. ;)

 

I like it!

 

BionicBASIC.png



#314 carlsson ONLINE  

carlsson

    Metagalactic Mule

  • 7,323 posts
  • Location:Västerås, Sweden

Posted Wed Feb 7, 2018 5:49 AM

I think you should do a WAIT before running this code in order to synchronize state.

Thanks, this solved my problem.

Partial code snippets:

  DIM seeds(15)
  SIGNED sx,sy

  FOR i=0 TO 14
    seeds(i)=RANDOM(255)
  NEXT

  sx=2:sy=1

loop:
  i=seeds(sy*5+sx)

  WAIT
  ASM MVI V1,R0      : REM i is the first regular variable used in my program, so it happens to become V1
  ASM MVO R0,_rand
  ASM MVO R0,_frame

  [..]
  j=RANDOM(255)
  [..]

This lets me reseed the built-in random number generator with 15 different seeds grabbed at the beginning of the program and get the same stream of random numbers after reseeding. I don't know what the by-effects are from resetting the frame counter.



#315 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Wed Feb 7, 2018 7:10 AM

... I don't know what the by-effects are from resetting the frame counter.


None for IntyBASIC core. It's simply a counter being incremented in each frame.

#316 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 11,067 posts
  • The P-Machinery AGE is almost here!
  • Location:NC, USA

Posted Wed Feb 7, 2018 7:21 AM

I don't know what the by-effects are from resetting the frame counter.

 

If you are using it to count frames for, say, animations; then you may end up repeating frames.  However, I would imagine that you would only reseed the PRNG during game transitions and initializations, so I wouldn't expect there to be any effect at all.

 

  -dZ.



#317 artrag ONLINE  

artrag

    Stargunner

  • 1,064 posts

Posted Sun Feb 11, 2018 2:48 AM

Question about PLAY: I need to pause a song, use all psg channels for a while, and then restart the song where it was at the time of the pause.

 

I've tried with PLAY OFF but then I do not know how to make music restart form the position where it was...

Any suggestion ?



#318 artrag ONLINE  

artrag

    Stargunner

  • 1,064 posts

Posted Sun Feb 11, 2018 6:09 AM

Aside from the question above I have a feature request. Would it be possible to extend the music player to 6 channels when the ECS module is detected?
I do not remember if the subject has been already touched.

Edited by artrag, Mon Feb 12, 2018 5:59 AM.


#319 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Sun Feb 11, 2018 7:47 PM

Question about PLAY: I need to pause a song, use all psg channels for a while, and then restart the song where it was at the time of the pause.

 

I've tried with PLAY OFF but then I do not know how to make music restart form the position where it was...

Any suggestion ?

 

Use PLAY NONE, put all channels volume to zero, and then do whatever you want, to restart music tracker use PLAY SIMPLE or PLAY FULL as you were using.

 

Aside from the question above I have a feature request. Would it be possible to extend the music player to 6 channels when the ECS module is detected?
Ai do not remember if the subject has been already touched.

 

I'm thinking on it, I know it will use a lot of precious 16-bit variables.



#320 Kiwi OFFLINE  

Kiwi

    Stargunner

  • 1,580 posts

Posted Mon Feb 12, 2018 4:21 AM

I'm thinking on it, I know it will use a lot of precious 16-bit variables.

The ECS module does come with 2KB of RAM.  I'm unsure if it is 16-bit RAM or 8-bit RAM. 

EDIT: Nevermind, groovybee said it's 8-bit wide in this thread. http://atariage.com/...ning/?p=3296479


Edited by Kiwi, Mon Feb 12, 2018 4:27 AM.


#321 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 11,067 posts
  • The P-Machinery AGE is almost here!
  • Location:NC, USA

Posted Mon Feb 12, 2018 5:18 AM

Use PLAY NONE, put all channels volume to zero, and then do whatever you want, to restart music tracker use PLAY SIMPLE or PLAY FULL as you were using.

 

But if he plays sound effects in the meantime, would that change any of the internal data structures of the music tracker and corrupt the song when it re-plays?  Will the music tracker also know to re-set all PSG registers which could have changed in the meantime?

 

 

I'm thinking on it, I know it will use a lot of precious 16-bit variables.

 
It could be optional, for those who wish to give up those variables.

 

Also, one thing that has to be considered is that it will eat precious game loop cycles because the music tracker will need to read and decode three more tracks from data, update their data structures, and update the second PSG registers.

 

It is certainly possible, and perhaps even desirable, but it doesn't come for free.
 
 

The ECS module does come with 2KB of RAM.  I'm unsure if it is 16-bit RAM or 8-bit RAM.

 

8-bit RAM.

 

  -dZ.



#322 nanochess ONLINE  

nanochess

    Processorus Polyglotus

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

Posted Mon Feb 12, 2018 11:10 AM

But if he plays sound effects in the meantime, would that change any of the internal data structures of the music tracker and corrupt the song when it re-plays?  Will the music tracker also know to re-set all PSG registers which could have changed in the meantime?


A good point.

The music tracker will re-use the channels immediately in the next state. Also the noise and mixer register. Only could fail if you use NO DRUMS then you should setup mixer/noise correctly.
 

It could be optional, for those who wish to give up those variables.
 
Also, one thing that has to be considered is that it will eat precious game loop cycles because the music tracker will need to read and decode three more tracks from data, update their data structures, and update the second PSG registers.
 
It is certainly possible, and perhaps even desirable, but it doesn't come for free.


That's right.

8-bit RAM.
 
  -dZ.


Not yet a way to use this ECS capability.

#323 intvnut OFFLINE  

intvnut

    River Patroller

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

Posted Mon Feb 12, 2018 3:03 PM

Not yet a way to use this ECS capability.

 

PEEK and POKE work.  Address range is $4040 - $47FF.   And as others have mentioned, ECS RAM is 8-bit.  So, if you're OK w/ using PEEK/POKE to access those data structures, you have an option.

 

Here's my ECS tech-info summary from ages ago: http://spatula-city....v/tech/ecs.html

 

Does it make sense to add a DPEEK and DPOKE that reads/writes 16-bit data across two 8 bit locations?  (If reads use SDBD; MVI@ explicitly, that could be used for some interesting programming tricks even in 16-bit memory.)



#324 intvnut OFFLINE  

intvnut

    River Patroller

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

Posted Mon Feb 12, 2018 3:42 PM

(Also, technically $4000 - $403F is available, but POKEs in that address range may write to STIC registers at $0000 - $003F, and a PEEK at $4021 could flip your video mode.)



#325 artrag ONLINE  

artrag

    Stargunner

  • 1,064 posts

Posted Tue Feb 13, 2018 2:25 AM

About the 6 channel player, I've added a trick to duplicate the psg on the ecs on a different octave. Effortless, but still effective. You can listen it in the last deep zone build.





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