Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:24 28 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : NEXT STEP- To start converting all the archive of programs.

     Page 2 of 2    
Author Message
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 01:24am 31 Jul 2020
Copy link to clipboard 
Print this post

  TassyJim said  Start with something simple.

I had to make two changes to this program. I could have used OPTION LEGACY but prefer to make the changes.

Pixel(X,Y) = COUNT Mod 8

This sets the pixel to a colour number 0 to 7

The 'new' method is:
Pixel X,Y, col(COUNT Mod 8)

It sets the colour which is stored in an array col()
This array is filled with the (more or less) standard GW Basic colours.
 'GW Basic colours
 DIM col(15) ' GWBasic colours
 col(0) = RGB( 0, 0, 0)      ' black
 col(1) = RGB( 0, 0, 170)    ' blue
 col(2) = RGB( 0, 170, 0)    ' green
 col(3) = RGB( 0, 153, 153)  ' cyan
 col(4) = RGB( 170, 0, 0)    ' red
 col(5) = RGB( 153, 0, 153)  ' magenta
 col(6) = RGB( 153, 102, 0)  ' brown
 col(7) = RGB( 170, 170, 170)' dull white
 col(8) = RGB( 85, 85, 85)   ' grey
 col(9) = RGB( 102, 102, 255)' light blue
 col(10) = RGB(102, 255, 102)' light green
 col(11) = RGB(102, 255, 255)' light cyan
 col(12) = RGB(255, 102, 102)' light red
 col(13) = RGB(255, 102, 255)' light magenta
 col(14) = RGB(255, 255, 102)' yellow
 col(15) = RGB(255, 255, 255)' bright white
 

I have that code saved as an INC file to save copy and pasting it in each time.

'JULIA.BAS - Draws Julia set fractal images
'by loki

Mode 3
Cls
 'GW Basic colours
 DIM col(15) ' GWBasic colours
 col(0) = RGB( 0, 0, 0)      ' black
 col(1) = RGB( 0, 0, 170)    ' blue
 col(2) = RGB( 0, 170, 0)    ' green
 col(3) = RGB( 0, 153, 153)  ' cyan
 col(4) = RGB( 170, 0, 0)    ' red
 col(5) = RGB( 153, 0, 153)  ' magenta
 col(6) = RGB( 153, 102, 0)  ' brown
 col(7) = RGB( 170, 170, 170)' dull white
 col(8) = RGB( 85, 85, 85)   ' grey
 col(9) = RGB( 102, 102, 255)' light blue
 col(10) = RGB(102, 255, 102)' light green
 col(11) = RGB(102, 255, 255)' light cyan
 col(12) = RGB(255, 102, 102)' light red
 col(13) = RGB(255, 102, 255)' light magenta
 col(14) = RGB(255, 255, 102)' yellow
 col(15) = RGB(255, 255, 255)' bright white
 
'Specify initial values
RealOffset = -1.30
ImaginOffset = -1.22
'------------------------------------------------*
'Set the Julia set constant [eg C = -1.2 + 0.8i]
CRealVal = -0.78
CImagVal = -0.20
'------------------------------------------------*
MAXIT=80 'max iterations
PixelWidth = MM.HRes
PixelHeight = MM.VRes
GAP = PixelHeight / PixelWidth
SIZE = 2.50
XDelta = SIZE / PixelWidth
YDelta = (SIZE * GAP) / PixelHeight

'Loop processing - visit every pixel
For X = 0 To (PixelWidth - 1)
 CX = X * Xdelta + RealOffset
 For Y = 0 To (PixelHeight - 1)
   CY = Y * YDelta + ImaginOffset
   Zr = CX
   Zi = CY
   COUNT = 0
   'Begin Iteration loop
   Do While (( COUNT <= MAXIT ) And (( Zr * Zr + Zi * Zi ) < 4 ))
     new_Zr = Zr * Zr - Zi * Zi + CRealVal
     new_Zi = 2 * Zr * Zi + CImagVal
     Zr = new_Zr
     Zi = new_Zi
     COUNT = COUNT + 1
   Loop
   'Pixel(X,Y) = COUNT Mod 8 ' CMM1 method
   Pixel X,Y, col(COUNT Mod 8)
 Next Y
Next X
Do
 a$ = Inkey$
Loop While a$ = ""


No other changes were required in this case.

Jim


I see this deals with both the different colours, and the different Pixel command syntax.

I was going to ask if you had the original source, but I see it's just the same but without the added code at the front, and with the different Pixel command which you've included in the comments.

I've noticed that the second argument to MODE can be left off, this should go in the manual if it's officially supported: "MODE r, [bits [, bg [, int]]]" with the extra square brackets instead of "MODE r, bits [, bg [, int]]". Is there a default colour depth?
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 03:49pm 31 Jul 2020
Copy link to clipboard 
Print this post

OK, I am trying to convert a game with a load sprite ( ) comand and it error out saying to many sprites.  What was the limit of CMM1 because we have the limit of 64.  If CMM1 had more why did it get limited on the CMM2.  On a simulare limitation CMM1 had 8 levels of demintions of arrays I think and CMM2 is limited to 5. I know most programs will seldom need more than 5 but why, if it has not been discused yet. Was it a performance issue?  Thanks.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 06:11pm 31 Jul 2020
Copy link to clipboard 
Print this post

Sounds like an oddity of the syntax or your code or some such.

Maybe post the simplest way to show it.  If it's a bug a simple example will be needed anyway.

John
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 07:22am 01 Aug 2020
Copy link to clipboard 
Print this post

  Quote  Was it a performance issue?

Yes

  Quote   If CMM1 had more why did it get limited on the CMM2.

Sprites are computationally very expensive particularly the collision detection. If you need more than 64 sprites then you are probably using the wrong approach and should look at tiles and BLIT. Sprites should be reserved for moving elements where collision detection is an essential component. If you need diferent sprites for different levels then sprites slots can be closed and reused.
Edited 2020-08-01 18:20 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 09:35am 01 Aug 2020
Copy link to clipboard 
Print this post

To convert the 8-bit Guys Tetris

Put the command OPTION LEGACY ON at the top of the program.
Then insert the command MODE 5
Delete the existing MODE command later in the program (leave the CLS)
Then change the two commands below to stop the text scrolling
Print @(170,180,1) "ESC to
Print @(170,190,1) "PAUSE/EXIT"
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 11:04pm 01 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Was it a performance issue?

Yes

  Quote   If CMM1 had more why did it get limited on the CMM2.

Sprites are computationally very expensive particularly the collision detection. If you need more than 64 sprites then you are probably using the wrong approach and should look at tiles and BLIT. Sprites should be reserved for moving elements where collision detection is an essential component. If you need diferent sprites for different levels then sprites slots can be closed and reused.


Yah I think is was not clear because I brought up 2 issues when I was mostly interested in why so many of the programs for the CMM1 error out saying you have exceeded the number of sprites. I look at the spr file they are trying to load and it seems like there are less than 64 in the file. I am not sure what is happening there and because I was getting that error I was asking if there where different max # of sprints. I want to understand how I can fix the games when I get one of those errors.

On the performance thing, I am guessing that the sprites are not hardware-based like on some of the old 8bit and 16bit systems. I thought they might be. I'm realy trying to undersand how this thing works and am feeling a little overwhelmed as I am not figuring much out so far.
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 03:05am 02 Aug 2020
Copy link to clipboard 
Print this post

  mclout999 said  
  matherp said  
  Quote  Was it a performance issue?

Yes

  Quote   If CMM1 had more why did it get limited on the CMM2.

Sprites are computationally very expensive particularly the collision detection. If you need more than 64 sprites then you are probably using the wrong approach and should look at tiles and BLIT. Sprites should be reserved for moving elements where collision detection is an essential component. If you need diferent sprites for different levels then sprites slots can be closed and reused.


Yah I think is was not clear because I brought up 2 issues when I was mostly interested in why so many of the programs for the CMM1 error out saying you have exceeded the number of sprites. I look at the spr file they are trying to load and it seems like there are less than 64 in the file.

I don't know why else you might get the error. Unless the program is using "SPRITE COPY" to make more sprites than are in the file. In which case it could be using high numbered sprites even with only a few sprites, as it lets you set the new sprite numbers.

Is the error happening at a SPRITE LOAD command, or could it be somewhere else?
  Quote  
I am not sure what is happening there and because I was getting that error I was asking if there where different max # of sprints. I want to understand how I can fix the games when I get one of those errors.

On the performance thing, I am guessing that the sprites are not hardware-based like on some of the old 8bit and 16bit systems. I thought they might be. I'm realy trying to undersand how this thing works and am feeling a little overwhelmed as I am not figuring much out so far.


From the old manual: "The sprites are defined in a file which is loaded into memory using the SPRITE LOAD command, the number of sprites contained in the file is only limited by the amount of available memory"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 03:46am 02 Aug 2020
Copy link to clipboard 
Print this post

  mclout999 said  
Yah I think is was not clear because I brought up 2 issues when I was mostly interested in why so many of the programs for the CMM1 error out saying you have exceeded the number of sprites. I look at the spr file they are trying to load and it seems like there are less than 64 in the file. I am not sure what is happening there and because I was getting that error I was asking if there where different max # of sprints. I want to understand how I can fix the games when I get one of those errors.

Give us a clue.
What program are to have trouble with?
Pick one, preferably not too big and start with it.

Jim
VK7JH
MMedit   MMBasic Help
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 04:59am 02 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  
  mclout999 said  
Yah I think is was not clear because I brought up 2 issues when I was mostly interested in why so many of the programs for the CMM1 error out saying you have exceeded the number of sprites. I look at the spr file they are trying to load and it seems like there are less than 64 in the file. I am not sure what is happening there and because I was getting that error I was asking if there where different max # of sprints. I want to understand how I can fix the games when I get one of those errors.

Give us a clue.
What program are to have trouble with?
Pick one, preferably not too big and start with it.

Jim


A game of Space invaders  File name Col_inv.bas

The error it throws is [40] Error: Maximum of 64 sprites
I got it somewhere I can't tell you where. When I come across any more gain(now I cant find them.  I have literally downloaded every MMbasic code I have found and I search high and low.


SPACEInvaders.zip
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 05:27am 02 Aug 2020
Copy link to clipboard 
Print this post

Looking at "invader2.spr"
'SprMite0Generated0Sprites
'D:\projets\2k12_DXE2\SprMite\invader.spr
16,100
0000000000000000
0000000000000000
0000000000000000
0000000000000000


The first non-comment line is
16,100
which means the size of the sprites is 16x16 and the number of sprites in the file is 100
The original sprites were always 16x16

Line 46 of the program has
MaxSprite = 94

which I would suggest that the program is using up to 94 sprites.

Try changing the "invader2.spr" file line 3 from 16,100 to 16,64
and line 46 of "Col_Inv.bas" to MaxSprite = 64

You might have to cut the end off the sprite file to bring it down to 1027 lines but try as is first. (16 lines x 64 sprites + 3 comments and specs = 1027)

That might get you going.

Here are the fonts files, converted to CMM2 format

SPACEInvaders.zip

Jim
Edited 2020-08-02 15:35 by TassyJim
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 05:57am 02 Aug 2020
Copy link to clipboard 
Print this post

You might have better luck with 63 as a maximum number of sprites.
VK7JH
MMedit   MMBasic Help
 
darthvader
Regular Member

Joined: 31/01/2020
Location: France
Posts: 72
Posted: 10:22am 02 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  You might have better luck with 63 as a maximum number of sprites.


Hi , i just have take a look at the original source , and i think they are some misunderstood on the number of sprite used.

Original sprite file was 'font file' :


'AniMite Generated Fonts and Sprites
'D:\projets\2k12_DXE2\AniMite\invader.fnt
13,16,97,121
               
               
               
               
               
   o     o    
    o   o      
   ooooooo    
  oo ooo oo    
 ooooooooooo  
 o ooooooo o  
 o o     o o  
    oo oo      
               
....              


It means , each sprite is 16 pixels wide , 13 pixels high , the first sprite 'font' start at 97 and the last is the number 121 , they are then only 25 sprites  

The original program load the new font :


'Get the Invaders font (16 x 13 pixels)
Font Load "invader.fnt" As #6
'Get the start Screen font (8 x 8 pixels)
Font Load "invmenu.fnt" As #7



I actually don't have get my CMM2 and don't know how you convert the old sprite to the new one. Just take care where the sprite starts/ends and how much they really are  

Cheers.
Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why ;)
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 09:47pm 02 Aug 2020
Copy link to clipboard 
Print this post

  darthvader said  
Hi , i just have take a look at the original source , and i think they are some misunderstood on the number of sprite used.

Original sprite file was 'font file' :


I actually don't have get my CMM2 and don't know how you convert the old sprite to the new one. Just take care where the sprite starts/ends and how much they really are  

Cheers.


That is for the mono version of the game.
He is trying to convert a colour version which does use sprites to get multi colour sprites.

Converting old font files to the new format is easy - just use FontTweak.

Jim
VK7JH
MMedit   MMBasic Help
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 11:29pm 02 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  
  darthvader said  
Hi , i just have take a look at the original source , and i think they are some misunderstood on the number of sprite used.

Original sprite file was 'font file' :


I actually don't have get my CMM2 and don't know how you convert the old sprite to the new one. Just take care where the sprite starts/ends and how much they really are  

Cheers.


That is for the mono version of the game.
He is trying to convert a colour version which does use sprites to get multi colour sprites.

Converting old font files to the new format is easy - just use FontTweak.

Jim


This was what I needed thanks.  I have your app so I will convert that file and go on from there.  Thanks.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 12:17am 03 Aug 2020
Copy link to clipboard 
Print this post

  mclout999 said  

This was what I needed thanks.  I have your app so I will convert that file and go on from there.  Thanks.

Remember that you can only 'load' one font and it must be font #8

If you want more than one, it is simplest to put them all in a .inc file and that way you can have many loaded at once.
By using an INC file, it makes editing your main program easier without the extra lines of font definition as a distraction.

Jim
VK7JH
MMedit   MMBasic Help
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024