English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 27 May 2024, 10:31   #1
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
Super noob ColSplit question

Hi everyone !


Trying to do something very simple with Blitz 2 on my A1230/AGA/Indivision. Not done proper development for... 20 years ! (used to do stuff in C for MOS)


I was just checking the behaviour of the ColSplit function. I was surprised that even with a super simple example, I was getting an odd behaviour.



Basically, after the bitmap and slice definitions, with a simple :


For A=0 to 15
ColSplit 0,A,0,A,A*15
Next


What happens is, one bar is missing - so one of the bars is twice as big as the others. The others look correct.


But, with other value of the last (Y) parameter, it looks correct (all 15 regular bars). For instance, with A*10 instead of A*15.


Last edited by mahen; 27 May 2024 at 11:22.
mahen is offline  
Old 27 May 2024, 16:04   #2
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
(BTW... Should I stick to the regular Slices or switch to the Coplists from the "new" Display library ?? There is very little info about the latter in the documentation...)
mahen is offline  
Old 27 May 2024, 16:22   #3
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 871
looks like it doesn't like the numbers 207-211 (for when a is 14)

changing

ColSplit 0,A,0,A,A*15

to

If A=14
ColSplit 0,A,0,A,(A*15)+2
Else
ColSplit 0,A,0,A,A*15
End if

Seems to work
Coagulus is offline  
Old 27 May 2024, 16:48   #4
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
Thanks for your reply !
Hmm... So there would be forbidden values which are not documented ?
Strange...
Meanwhile I tried to build my example with the latest AmiBlitz 3 beta : it crashed during compilation
Also, I tested this example with compatibility stuff like killaga, nofastmem etc. just in case, no difference.

Edit : I tried to switch to the Display library to check if it made a difference. Seems ColSplit is not compatible with Display library but only with Slices ?

Edit 2 : man. DisplayRainbow supersedes ColSplit, right ? For some reason, no mention of this function in the book I read (Guide to Blitz Basic, which is more comprehensive than "BB Manual" overall, but not for the Display library apparenty.

Last edited by mahen; 27 May 2024 at 17:30.
mahen is offline  
Old 27 May 2024, 17:52   #5
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 871
Quote:
Originally Posted by mahen View Post
Thanks for your reply !
Hmm... So there would be forbidden values which are not documented ?
Strange...
Meanwhile I tried to build my example with the latest AmiBlitz 3 beta : it crashed during compilation
Also, I tested this example with compatibility stuff like killaga, nofastmem etc. just in case, no difference.

Edit : I tried to switch to the Display library to check if it made a difference. Seems ColSplit is not compatible with Display library but only with Slices ?

Edit 2 : man. DisplayRainbow supersedes ColSplit, right ? For some reason, no mention of this function in the book I read (Guide to Blitz Basic, which is more comprehensive than "BB Manual" overall, but not for the Display library apparenty.
Displayrainbow is the command for the Display library (instead of using Slice)

And I think DisplayRGB for individual values.

see here https://eab.abime.net/showthread.php?t=69550

and https://eab.abime.net/showthread.php?t=93921
Coagulus is offline  
Old 27 May 2024, 18:00   #6
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
Great, will give this a try !

I'll switch to the Display library.

Still interested to know what is wrong with the ColSplit function if it rings anyone a bell
mahen is offline  
Old 28 May 2024, 11:25   #7
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
Hi ! Been tinkering with the Display lib, understood and played with your example etc. Pretty cool ! Actually works better than the Slice+Colsplit, which, in my tests, induced flickering...

2 things bug me :

- I have some corruption at the top of the screen when I use the ShowRainbow command with a palette of which indexes 254 and 255 are set with AGAPalRGB (not zeroed). Must stop at 253. Not a big deal but is that normal ? (what I call corruption is, the first lines are filled with the bad colour, the last one I guess, as if there was an overflow, timing issue or something)

- I output text with BitmapOutput and PRINT. Even when altering the palette or using the Colour command, the text is ALWAYS black. Altering the index 1 of the current palette or setting a different colour makes no difference. Even after removing all the Rainbow stuff and making a minimalistic example. Any idea ?! Of course, I did use InitPalette, AGAPalRGB, InitCopList, Bitmap, DisplayPalette, CreateDisplay, DisplayBitMap, BitMapOutPut and tripled checked all arguments.

Thanks so much for your help


Last edited by mahen; 28 May 2024 at 21:53.
mahen is offline  
Old 28 May 2024, 14:21   #8
AF2013
Registered User
 
Join Date: Apr 2013
Location: .
Posts: 262
Blitzbasic 2 is bit more complex(mean bit harder) than Amiga Amos to learn.

Once you learn how own framework sprites(and understanding how copper work,playfield effect) working up and running with no crashing then you are on way to used recode work whichever game you making

Good Luck mahen
AF2013 is offline  
Old 28 May 2024, 20:03   #9
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 871
Glad you're getting there!

Difficult, without seeing the code+images etc, to diagnose but if the text is black it'll be being displayed using a pen that is currently black.

Alternatively the coplist has been opened with the wrong flags so the wrong colours get displayed?

maybe draw a few filled squares on the bitmap using all the available pens to see what the palette is, it might be the palette hasn't loaded/set correctly...
Coagulus is offline  
Old 28 May 2024, 22:53   #10
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
Oh man. Found. The initcoplist had a 1 colour argument. I assumed it was 1 bitplane hence 2 colours. I wonder what a 1 colour screen actually means ?!

I was sure I had tried other values several times but apparently not !

Cannot believe I spent hours on this !! sorry guys !!

Last edited by mahen; 28 May 2024 at 23:15.
mahen is offline  
Old 28 May 2024, 23:22   #11
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 871
Quote:
Originally Posted by mahen View Post
Oh man. Found. The initcoplist had a 1 colour argument. I assumed it was 1 bitplane hence 2 colours. I wonder what a 1 colour screen actually means ?!

I was sure I had tried other values several times but apparently not !

Cannot believe I spent hours on this !! sorry guys !!
We've all been there, especially with InitCoplist (and wonderfully vague commands like DisplayAdjust and DisplayScroll which at least have been deciphered in this group!)

Keep at i!
Coagulus is offline  
Old 29 May 2024, 11:01   #12
mahen
Registered User
 
Join Date: Apr 2008
Location: France
Age: 41
Posts: 467
Hi !

Been making progress. I thought maybe I should show you a bit of code in the probable case I'm doing stuff in a horrible way !

So here my code. Hmm... I wrote everything in French for my own pleasure but maybe I should switch to English if I am to ask for advice... :-/

Here is what the code does :

- it monitors MIDI events from the serial port
- it detects chords (for the moment only triads)
- it adds "enemies" on the screen which for the moment are just displayed as copper bars of random size/position/speed
- to defeat an enemy you must hit the right chord on the MIDI keyboard with the proper inversion when specified between parenthesis

That is all for the time being.

Here are my problems :
- for some reason, it triggers an exception (crash) when I invoke "CLS" from my affichageListeEnnemis{} function (which displays in text form the "weak points" of the enemies -- ie the chord you have to hit)
BUT CLS does work when invoked before the function. I don't understand as NPrint does work properly from the function.

- performance issues. As soon as there are many big enemies. Look for "; Affichage des ennemis" in the code to see the spot. This is where I prepare the palette #1 for the ShowRainbow effect to display the enemy as a copper bar. MAybe I should use more temporary variables to reduce the amount of computations ?

(my target machine is my A1230@50)

- it's not visible in the game but when using ShowRainbow, I can see sometimes the wrong colour at the end of a line -- it can show the colour of the next line at the end of the previous one. Happens on the first line of copper bars, here is an example on a 1 line bar :



Any comment is welcome !

Code:
;    ______________________________________
;   /                                     /
;  /  TEST reception MIDI en mode Blitz  /
; /_____________________________________/

; Config gameplay
#MAX_ENNEMIS=15

; Protocole MIDI
#MIDI_ACTIVE_SENSE=$FE  ; recu environ toutes les 300 ms si pas d'evenement
#MIDI_NOTE_ON=$90       ; note ON chan 0 (de 0x90 a 0x9F), note, velo
                        ; middle C = 60
#MIDI_NOTE_OFF=$80      ; equivalent a NOTE_ON 0

DEFTYPE.w

NEWTYPE.Note
  ton.b   ; byte suffisant car valeur entre 0 et 127
;  *suivante.Note
End NEWTYPE

;DEFTYPE .Note Accord
;DEFTYPE *courante.Note
Dim List Clavier.Note(10)

#ACCORD_NULL   = 0 :
#ACCORD_MAJ    = 1 :    #MASQUE_ACCORD_MAJ    = %10001001
                        #MASQUE_ACCORD_MAJ_R1 = %100100001
                        #MASQUE_ACCORD_MAJ_R2 = %1000010001
#ACCORD_MIN    = 2 :    #MASQUE_ACCORD_MIN    = %10010001
                        #MASQUE_ACCORD_MIN_R1 = %1000100001
                        #MASQUE_ACCORD_MIN_R2 = %100001001
#ACCORD_DIM    = 3 :    #MASQUE_ACCORD_DIM    = %1001001
                        #MASQUE_ACCORD_DIM_R1 = %1001000001
#ACCORD_MAX    = 3 :    #MASQUE_ACCORD_DIM_R2 = %1000001001

NEWTYPE.Accord
  fondamentale.b
  typeAccord.b
  renversement.b
End NEWTYPE

Function modulo{x.b, y.b}
  div_ent.b = x/y
  Function Return x - (div_ent * y)
End Function

Function RechercheAccord{}
  SHARED Clavier()     ; TODO : passer en parametre si besoin ?
  SHARED accord.Accord ; resultat de la fonction
  masqueAccord.l = 0   ; representation d'une portion de clavier
                       ; entre 2 touches enfoncees

  ResetList Clavier()
    If LastItem(Clavier())
      noteFin=Clavier()\ton
      masqueAccord = 1
    EndIf

  While PrevItem(Clavier())
      Let masqueAccord + 2^(noteFin-Clavier()\ton)
  Wend

  tmp_type = 0 : tmp_inv.b = 0 : tmp_delta_fondamentale.b = 0

  Select masqueAccord
    Case #MASQUE_ACCORD_MAJ
      tmp_type = #ACCORD_MAJ
    Case #MASQUE_ACCORD_MAJ_R1
      tmp_type = #ACCORD_MAJ : tmp_inv = 1 : tmp_delta_fondamentale = 8
    Case #MASQUE_ACCORD_MAJ_R2
      tmp_type = #ACCORD_MAJ : tmp_inv = 2 : tmp_delta_fondamentale = 5
    Case #MASQUE_ACCORD_MIN
      tmp_type = #ACCORD_MIN
    Case #MASQUE_ACCORD_MIN_R1
      tmp_type = #ACCORD_MIN
      tmp_inv = 1 : tmp_delta_fondamentale = 9
    Case #MASQUE_ACCORD_MIN_R2
      tmp_type = #ACCORD_MIN
      tmp_inv = 2 : tmp_delta_fondamentale = 5
    Case #MASQUE_ACCORD_DIM
      tmp_type = #ACCORD_DIM
    Case #MASQUE_ACCORD_DIM_R1
      tmp_type = #ACCORD_DIM : tmp_inv = 1 : tmp_delta_fondamentale = 9
    Case #MASQUE_ACCORD_DIM_R2
      tmp_type = #ACCORD_DIM : tmp_inv = 2 : tmp_delta_fondamentale = 6
  End Select

  If tmp_type <> 0
    accord.Accord\fondamentale = modulo{Clavier()\ton + tmp_delta_fondamentale, 12}
    accord.Accord\renversement = tmp_inv
    accord.Accord\typeAccord = tmp_type
    ;NPrint "Accord : ", accord\fondamentale, ", renv ",accord\renversement, ", type ", accord\typeAccord
    Function Return True
  Else
    Function Return False
  EndIf
End Function

Function$ QuelleNote{n.b}
  Select modulo{n.b, 12}
    Case 0
      res$="Do"
    Case 1
      res$="Do#"
    Case 2
      res$="Re"
    Case 3
      res$="Re#"
    Case 4
      res$="Mi"
    Case 5
      res$="Fa"
    Case 6
      res$="Fa#"
    Case 7
      res$="Sol"
    Case 8
      res$="Sol#"
    Case 9
      res$="La"
    Case 10
      res$="La#"
    Case 11
      res$="Si"
  End Select
  Function Return res$
End Function

Function$ QuelAccord{n.b}
  Select n
    Case #ACCORD_MAJ
      Function Return "Majeur"
    Case #ACCORD_MIN
      Function Return "mineur"
    Case #ACCORD_DIM
      Function Return "diminue"
    Default
      Function Return ""
  End Select
End Function

; TODO : ne pas parcourir toute la liste si element trouve
Statement NoteRelachee{n.b}
  SHARED Clavier() ; la flemme de passer l'argument a chaque fois
  ResetList Clavier()
  While NextItem(Clavier())
    If Clavier()\ton = n
      KillItem Clavier()
    EndIf
  Wend
End Statement

NEWTYPE.Ennemi
  position.w
  taille.b
  vitesse.b
  accord.Accord
End NEWTYPE

Dim List Ennemis.Ennemi(#MAX_ENNEMIS)

Function AjoutEnnemi{}
  SHARED Ennemis()
  If AddItem(Ennemis())
    Ennemis()\taille = Rnd(50)+2 ; Attention aux valeurs illegales
    Ennemis()\position = Rnd(50)
    Ennemis()\vitesse = Rnd(3)+1
    Ennemis()\accord\fondamentale = Rnd(11)
    Ennemis()\accord\renversement = Rnd(2)
    Ennemis()\accord\typeAccord = Rnd(#ACCORD_MAX-1)+1
    Function Return True
  Else
    Function Return False
  EndIf
End Function

Statement AffichageListeEnnemis{}
  SHARED Ennemis()
  NPrint "Listes des ennemis"
  NPrint "******************", ""
  ResetList Ennemis()
  While NextItem (Ennemis())
    Print QuelleNote{Ennemis()\accord\fondamentale}, " ", QuelAccord{Ennemis()\accord\typeAccord}
    NPrint " (", Ennemis()\accord\renversement, ")"
  Wend

End Statement

Statement DessineCercleQuintes{}
  tmp_milieu_x = 160 : tmp_milieu_y = 128
  Circle tmp_milieu_x,tmp_milieu_y,120,1
  Circle tmp_milieu_x,tmp_milieu_y,80,1
  Circle tmp_milieu_x,tmp_milieu_y,40,1
End Statement

BLITZ
ser.l = OpenSerial ("serial.device", 0, 31250, 144)

InitPalette 0,2
AGAPalRGB 0,1,128,0,128

BitMap 0,320,256,1
InitCopList 0,44,256,$10000|$01|$10|$400,8,2,-4
DisplayPalette 0,0
CreateDisplay 0
DisplayBitMap 0,0
BitMapOutput 0

NPrint "** Test MIDI en mode Blitz **"

#ETAT_MIDI_NULL = 0 :     #ETAT_MIDI_NOTE = 1 :     #ETAT_MIDI_VELO = 2
                          #ETAT_MIDI_NOTE_OFF = 3 : #ETAT_MIDI_VELO_OFF = 4
etatMessageMidi = #ETAT_MIDI_NULL
derniereNote.b = 0 : nbFrames = 0 : nbEnnemis = 0;
aTraiter = False

SetErr
  NPrint "BUG"
  MouseWait
  End
End SetErr

While Joyb(0)=0

  ; Ajout d'ennemis de temps en temps
  If nbFrames = 50
    If AjoutEnnemi{}
      Cls
      Locate 0,0
      AffichageListeEnnemis{}
      nbFrames = 0
    EndIf
  EndIf

  entree.w = ReadSerial(0)
  While entree.w <> -1
  ; TODO : filtrer les evenements realtime et contenu des SYSEX...
  ;        mettre etat MIDI_NULL si code debut SYSEX
  ;        exclure dans le while initial la plage d'evt realtime
  ; TODO : test ouverture serie

    Select entree.w
      Case #MIDI_ACTIVE_SENSE
      Case #MIDI_NOTE_ON
        etatMessageMidi = #ETAT_MIDI_NOTE
      Case #MIDI_NOTE_OFF
        etatMessageMidi = #ETAT_MIDI_NOTE_OFF
      Default
        Select etatMessageMidi
          Case #ETAT_MIDI_NOTE
            derniereNote = entree
            etatMessageMidi = #ETAT_MIDI_VELO
          Case #ETAT_MIDI_NOTE_OFF
            dernierNote = entree
            etatMessageMidi = #ETAT_MIDI_VELO_OFF
          Case #ETAT_MIDI_VELO
            If entree = 0 ; equivaut a NOTE_OFF
              NoteRelachee{derniereNote}
            Else
              If AddItem(Clavier())
                Clavier()\ton=derniereNote
              EndIf
            EndIf
            aTraiter=True
            etatMessageMidi=#ETAT_MIDI_NOTE
          Case #ETAT_MIDI_VELO_OFF
            NoteRelachee{derniereNote}
            etatMessageMidi=#ETAT_MIDI_NOTE_OFF
        End Select
    End Select

    entree.w = ReadSerial(0)

  Wend

  ; Verif de l'etat du clavier. A-t-on des accords ?

  If aTraiter=True
    If FirstItem(Clavier())= True
      SortList Clavier(),0

      tmp_accordTrouve = RechercheAccord{}

      ResetList Ennemis()
      While NextItem(Ennemis())

        ;A-t-On atteint un ennemi ?
        If tmp_accordTrouve
          If Ennemis()\accord\fondamentale = accord\fondamentale
            If Ennemis()\accord\typeAccord = accord\typeAccord
              If Ennemis()\accord\renversement = accord\renversement
                KillItem Ennemis()
                AffichageListeEnnemis{}
                Cls
                Locate 0,0
              EndIf
              ; sinon peut etre retour gfx ?
            EndIf
          EndIf
        EndIf
      Wend

    aTraiter=False
    EndIf
  EndIf


  ; Affichage des ennemis
  ResetList Ennemis()
  While NextItem(Ennemis())
    tmp_taille = Ennemis()\taille/2
    tmp_pos = Ennemis()\position
    tmp_inc = 256/tmp_taille
    For a=0 To tmp_taille-1
      AGAPalRGB 1,tmp_pos+a,a*tmp_inc,0,0
      AGAPalRGB 1,tmp_pos+tmp_taille+a,255-(a*tmp_inc),0,0
    Next

    ; Deplacement des ennemis
    tmp_vit.b = Ennemis()\vitesse
    If tmp_vit > 0
      If (tmp_taille*2+tmp_pos+tmp_vit > 255) Ennemis()\vitesse = -tmp_vit
    Else
      If (tmp_pos + tmp_vit < 0) Ennemis()\vitesse = -tmp_vit
    EndIf
    Let Ennemis()\position + Ennemis()\vitesse
  Wend

  ;DessineCercleQuintes{} ; super lent oopsie

  VWait ; Plus rien sur le buffer, on attend la VBL pour pas busylooper
  Let nbFrames + 1
  DisplayRainbow 0,0,1
  InitPalette 1,256
Wend
AMIGA

;MouseWait
End

Last edited by mahen; 29 May 2024 at 17:20.
mahen is offline  
Old 29 May 2024, 11:47   #13
AF2013
Registered User
 
Join Date: Apr 2013
Location: .
Posts: 262
Hello,

You seem be advance Blitz 2 Programmer and you deserve gold medal

keep good work up
AF2013 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
noob question Pixelfill Coders. Asm / Hardware 7 07 February 2020 15:04
Noob question, sorry. fitzsteve project.WHDLoad 3 23 August 2009 16:56
Noob Question but anyway. trackah123 Coders. General 17 30 October 2008 14:39
yet another noob question AliasXZ New to Emulation or Amiga scene 11 23 January 2008 23:28
AmigaOS Noob question Rochabian New to Emulation or Amiga scene 4 11 January 2007 14:15

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:56.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09135 seconds with 15 queries