MSX FUSION-C, Talking about bugs, errors, mistakes

Página 1/12
| 2 | 3 | 4 | 5 | 6

Por ericb59

Paladin (859)

Imagen del ericb59

22-01-2019, 17:12

Hi everybody,
In this section, post any issues you may have with FUSION-C. Please also report here bugs, errors and faults you can find.

Error Page 67 of the Book or Page 35 of the Quick Manual
SetScrollV : Vertical Hardware scrolling is working on MSX2, 2+ and Tr
SetScrollH : Horizontal Hardware Scrolling is working on MSX2+ and Tr, not on MSX2 as it was written

Forget Example in the folder : Fusion-c/examples

Hardware Scrolling for MSX2 Example.

//
// Fusion-C
// Hardware Scrolling Screen 8 Example
//

#include <string.h>
#include "fusion-c/header/msx_fusion.h"
#include "fusion-c/header/vdp_graph2.h"

static FCB file;                        // Init the FCB Structure variable

unsigned char LDbuffer[2400];           // Set A loading Buffer of 2400 Bytes

/* ---------------------------------
                FT_Wait

                Waiting 
-----------------------------------*/ 
void FT_wait(int cicles)
{
  int i;
  for(i=0;iname[i] = ' ';
  }
  for( i = 0; (i < 8) && (p_name[i] != 0) && (p_name[i] != '.'); i++ ) {
    p_fcb->name[i] =  p_name[i];
  }
  if( p_name[i] == '.' ) {
    i++;
    for( j = 0; (j < 3) && (p_name[i + j] != 0) && (p_name[i + j] != '.'); j++ ) {
      p_fcb->ext[j] =  p_name[i + j] ;
    }
  }
}

/* ---------------------------------
            FT_errorHandler

          In case of Error
-----------------------------------*/ 
void FT_errorHandler(char n, char *name)
{
  Screen(0);
  SetColors(15,6,6);
  switch (n)
  {
      case 1:
          Print("\n\rFAILED: fcb_open(): ");
          Print(name);
      break;

      case 2:
          Print("\n\rFAILED: fcb_close():");
          Print(name);
      break;  

      case 3:
          Print("\n\rStop Kidding, run me on MSX2 !");
      break; 
  }
Exit(0);
}

/* ---------------------------------
          FT_LoadSc8Image

    Load a SC8 Picture and put datas
  on screen, begining at start_Y line
-----------------------------------*/ 
int FT_LoadSc8Image(char *file_name, unsigned int start_Y, char *buffer)
    {
        int rd=2304;
        int nbl=0;
        InitPSG();
        FT_SetName( &file, file_name );
        if(fcb_open( &file ) != FCB_SUCCESS) 
        {
          FT_errorHandler(1, file_name);
          return (0);
        }
        fcb_read( &file, buffer, 7 );  // Skip 7 first bytes of the file
        while(rd!=0)
        {
            SetColors(15,0,buffer[192]);
            rd = fcb_read( &file, buffer, 2304 );
                if (rd!=0)
                {
                  SetColors(15,0,0);
                  nbl=rd/256;
                  HMMC(buffer, 0,start_Y,256,nbl ); // Move the buffer to VRAM. 17 lines x 256 pixels  from memory
                  start_Y=start_Y+nbl; 
              }
        }
      if( fcb_close( &file ) != FCB_SUCCESS ) 
      {
         FT_errorHandler(2, file_name);
          return (0);
      }

return(1);
}


void main(void) 
{
	int i,n;
  char rd;
  
  rd=ReadMSXtype();                   // Read MSX Type

  if (rd==0)                          // If MSX1 got to Error !
  {
    FT_errorHandler(3,"msx 1 ");
  }
  
  Screen(8);                          // Init Screen 8
  FillVram(0,0,65535);                // Clear VRAM Pape 0 by Byte 0 (Black)

  FT_LoadSc8Image("SUPERGIR.SC8",0,LDbuffer); // Loading Image To Page 0

  if (rd>=1)      // If Computer is At least MSX2 Do a Vertical Scroll
  {
    for (n = 0; n<3; n++)
    {
      for (i = 0; i < 256; ++i)
      {
        SetScrollV(i);
        FT_wait(1);
      }
    }
  }
  if (rd>=2)      // If computer is At least MSX2+ Do a Horizontal Scroll
  {
    for (n = 0; n<3; n++)
    {
      for (i = 0; i < 256; ++i)
      {
        SetScrollH(i);
        FT_wait(1);
      }
    }
  }

  	 Screen(0);
  	 Exit(0);

}
 

Copy / Paste / Compile.
The .SC8 image this program is loading is in the fusion-c/examples folder

Login sesión o register para postear comentarios

Por ericb59

Paladin (859)

Imagen del ericb59

22-01-2019, 17:27

Other example may be useful.

Pseudo Random Number Generator

//
// Fusion-C
// Pseudo Random Number
//
#include <stdlib.h>
#include <stdio.h>
#include "fusion-c/header/msx_fusion.h"

TIME tm;  //Init the Time Structure variable


/* ---------------------------------
                FT_Random
           Return a Random Number 
             between a and b-1
-----------------------------------*/ 
char FT_RandomNumber (char a, char b)
{
    char random;
 
    random = rand()%(b-a)+a;  
    return(random);
}


void main(void) 
{
    char n,i;

    GetTime(&tm);               // Retreive MSX-DOS Clock, and set the tm strucutre with clock's values
    srand(tm.sec);              // use current clock seconds as seed in the random generator

    for(i=0;i < 10; i++)
    {
        n=FT_RandomNumber(1,101);     // Choose random number between 1 and 100 
        printf("%d,",n);
    }
 
    Exit(0);
}

Por ToriHino

Champion (360)

Imagen del ToriHino

22-01-2019, 19:36

Are you sure the first example will work? Looks like it is missing FT_SetName and that it is somehow mixed up with the FT__wait function.

Por ericb59

Paladin (859)

Imagen del ericb59

22-01-2019, 20:44

ToriHino wrote:

Are you sure the first example will work? Looks like it is missing FT_SetName and that it is somehow mixed up with the FT__wait function.

Damn ! What's happened to my Copy/paste ?
Yes FT_SetName is not there !!

In fact, I just noticed some part of the code are not displayed ! There is something wrong here with some text tags ?
Can an admin give me some clues about the problem ?

Until the problem is solve you can check the examples from here : http://msx.ebsoft.fr/fusion-c/examples/

Por ericb59

Paladin (859)

Imagen del ericb59

26-01-2019, 08:10

Missing function :
The function : SetBorderColor is used in some examples but its definition is not included, it cause compilation error.

to fix this problem, edit the file : fusion-c/header/msx_fusion.h
at the line 128 add this :

void SetBorderColor(unsigned char bor_color);

Por ToriHino

Champion (360)

Imagen del ToriHino

27-01-2019, 11:25

When i use command line arguments for my program (so using the extended version of the crt0 startup code by modifying the two lines in compil.bat) i get different behavior as described in the book (or as the C standard):

When no argument is supplied: argc is 0
When 1 argument is supplied: argc is 1 and argv[0] contains the argument

So the name of the program is not in the list at all.
Next to that, putting arguments between double quotes does not combine it into a single argument.

Por Grauw

Ascended (8381)

Imagen del Grauw

27-01-2019, 11:58

ericb59 wrote:
ToriHino wrote:

Are you sure the first example will work? Looks like it is missing FT_SetName and that it is somehow mixed up with the FT__wait function.

Damn ! What's happened to my Copy/paste ? Yes FT_SetName is not there !!

In fact, I just noticed some part of the code are not displayed ! There is something wrong here with some text tags ? Can an admin give me some clues about the problem ?

MRC Troubleshooting FAQ: How do I write a < character?

People can also press the “quote” button to see the original message.

Por ericb59

Paladin (859)

Imagen del ericb59

27-01-2019, 21:55

@ToriHino : Yes you 're right !
Thank you for pointing that.

Por DamnedAngel

Master (143)

Imagen del DamnedAngel

28-01-2019, 22:34

Hi ericb59,

Thank you for putting a considerable ammount of effort in this lib!

I have a question, though.
I don't know if I missed something, but why compil.bat and makefile set --code-loc to 0x107 or 0x180 (depending on the main() signature), if crt0_msxdos.s and crt0_msxdos_advanced.s inform that they should be compiled with 0x106 and 0x170, respectively?

I tried both 0x106 and 0x107 with crt0_msxdos.s and both worked ok (but, obviously, 0x107 rendered a executable 1 byte bigger).

Does it make a difference? May I just keep using 0x106 and 0x170 as I used before Fusion-C?

best,

Por ericb59

Paladin (859)

Imagen del ericb59

29-01-2019, 13:24

@Damnedangel : Yes, you are right, as Konamiman indicates in the source code, the CodeLoc must be 0x106 or 0x170 for the crt0_msxdos_advanced. But these settings had never worked for me. Compiler warmed me with "Overlapped Data". I was not the only one experienced this problem. Thus, I used other values that works for more people.

I don't know why sometimes other settings values are needed. One other user, must use codeloc at 0x0100 !
It's very strange....
Anyway, feel free to use the settings that works for you, and you think are the best.
But remember if you have overlapped data somewhere, or bugs in your program, that can come from the codeloc setting.

Por DamnedAngel

Master (143)

Imagen del DamnedAngel

29-01-2019, 13:38

Hi ericb59,

Thanks for your answer. It's good to know where the values came from.
I will keep my original parameters and one eye on warnings. When/If overlapping comes up, I will know its probable origin!

best,

Página 1/12
| 2 | 3 | 4 | 5 | 6