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

페이지 17/21
10 | 11 | 12 | 13 | 14 | 15 | 16 | | 18 | 19 | 20 | 21

By ducasp

Champion (386)

ducasp의 아바타

14-04-2020, 17:06

Hi Eric,

LSeek was not working properly on MSX-DOS2, I've fixed it

Also, I've added Ensure, that will make sure buffers are flushed and all operations on the handle are performed before it returns, it is only for MSX-DOS2 and will return an error if called on MSX-DOS.

Both io.s and io.h can be found in the same place I've sent the code for interrupts:

https://drive.google.com/open?id=1inY5kp2QYKCJtnjxVaNr4GbV56...

Hope that helps ;)

P.s.: I have no idea if LSeek was working on MSX-DOS, and did not test it, neither have I changed it. In MSX-DOS2 it was getting garbage as input parameter and seeking a totally unrelated location in regards to what was sent in the parameter, but since MSX-DOS code is way different and deal with parameters in another way, I did not investigate or change it.

By marcoslm

Supporter (2)

marcoslm의 아바타

18-04-2020, 22:29

Hi Eric,

Thanks for your great job with Fusion-C. Your project has encouraged me to learn how to program C on MSX.

I am using the FT_LoadSc5Image function (extracted from the examples), but I see that the palette has to be assigned manually.
Is there a way to directly load the palette from a SC5 file like FT_LoadSc8Image does with SC8?

By Dolphin101546015

Champion (282)

Dolphin101546015의 아바타

19-04-2020, 05:10

marcoslm wrote:

Hi Eric,

Thanks for your great job with Fusion-C. Your project has encouraged me to learn how to program C on MSX.

I am using the FT_LoadSc5Image function (extracted from the examples), but I see that the palette has to be assigned manually.
Is there a way to directly load the palette from a SC5 file like FT_LoadSc8Image does with SC8?

In original SC5 file, palette placed in the end of file, last 32 bytes.

By ericb59

Paladin (1014)

ericb59의 아바타

19-04-2020, 19:34

Hello

@ducasp : Thank you very much. I will add your patch to the next version.

@Dolphin101546015 : All screen converter I use, as far as I know, are using a separate file for the palette. But, perhaps some put the palette to the end of the image file, let me know which one...

@marcoslm : Thank you for using Fusion-C. I'm happy you come to MSX programing with Fusion-C :-)
Most of the SC5 image files I know, are using a separate file to store the platte.
MSX screen convertor from Jannone https://msx.jannone.org/conv/
Is showing the palette as a MSX Basic program. Thus, you have to copy the data and paste them manually to the SetPalette function.
Some other converter like MifUI https://www.louthrax.net/mgr/. are saving the palette as a separate binary file.
Thus, you see there is no standard solution.

In case you want to use MifUI, or other converter and need to load a binary palette, I publish here a routine to load and apply the palette. Hope this will help you.

/* -------------------------------------------------------------------------------------
| LOAD BINARY PALETTE. Load a binary image palette (Example Mif UI bin Palette)
| Restrictions      : For screen mode 2,3,4,5,7
| Need              : FT_SetName & FT_errorHandler routines
|
| *file_name        : File name of the palette file to load
| *org_palette      : GLobal 64 bytes array to store the palette (see the SetPalette function)
+---------------------------------------------------------------------------------------*/

char FT_LoadBinPalette(char *file_name, char *org_palette)        
    {
        char n,c;
        char byte[7];
       
   
        FT_SetName( &file, file_name );
        if(FcbOpen( &file ) != FCB_SUCCESS) 
        {
              FT_errorHandler(1, file_name);
        }      
        
         n=0;
         c=0;
         FcbRead( &file, byte, 7 );                             // Bypass first 7 bytes (Header)
         
         while (c<16)                                           // 16 is the number of colors. Change it to 4 if you want to load a screen 6 Palette
         {
            org_palette[n]=c;
          
            n++;

            FcbRead( &file, byte, 2 );
     
            org_palette[n]=(byte[0]>>4) & 0b00000111;           // Red color
            n++;

            org_palette[n]=(byte[1]);                           // green color
            n++;

            org_palette[n]=(byte[0]) & 0b00000111;              // blue color
            n++;
            
            c++;
         }
         FcbClose(&file);
        
         SetPalette((Palette *)Mypalette);                   

    return(1);
}

By marcoslm

Supporter (2)

marcoslm의 아바타

19-04-2020, 21:45

Thanks guys! Problem solved.
I'm porting an old MSX-Basic project in which I used BMP2MSX for graphics conversion. After "hex-comparing" that files with a MIFui generated SC5, I can confirm that BMP2MSX embeds the contents of the palette at the end of the file.
It might be interesting to add the option to load SC5's embedded palettes (if any). The "Bload" basic instruction loads them and they can be applied with "color = restore".

By Dolphin101546015

Champion (282)

Dolphin101546015의 아바타

20-04-2020, 01:41

Nice! Smile
It come from MSX Basic.
This palette placing on load to VRAM as reserved buffer (V9938/9958 not have functions for read palette registers).
When you call color=restore, function read reserved buffer and fill VDP registers.

By ericb59

Paladin (1014)

ericb59의 아바타

20-04-2020, 09:14

ok. Yes I can add this to the routine.

In Fusion-c I did not implemented the way MSX Basic save the Palette to the VRAM.
With Screen5 the 32 bytes of the Palette are copied to 0x7680.
I think it's better to keep this area free to store other datas like graphics pattern for a game for example.
Also, it's easy to keep the palette in a Ram array.
The Fusion-C RestorePalette function only restore the default MSX palette. Not the Image Palette.

By raymond

Champion (462)

raymond의 아바타

23-04-2020, 14:14

ericb59 wrote:

Ok good Big smile

I think I will publish Fusion-C 1.3 before the end of the week.
There are many improvements in v1.3...
Before that, to overcome the confinement we endure, I launched myself a little challenge yesterday.
Here in video.
https://www.youtube.com/watch?v=WlOnX2uqRxE&t=32s

Do you know when the new 1.3 version will be released?

By Bengalack

Master (222)

Bengalack의 아바타

23-04-2020, 17:07

I'm currently working on 1.2. I'm aware that you are looking into rewriting the interrupt-routines, but I still look into the current ones, as they may be of use to me. Just want to point out some things:

I wonder if the idea is that your own code checks if the interrupt is due to VDP. If not so, it returns 0 (in l) and the interrupt-stub code is supposed to call the original interrupt-code to handle this. To me, it seems like this never really worked, as the "keyint" is 3 bytes starting with "jump": 0xC3. When the command

call z, backup_keyint

comes along it fails (?). Unnless I'm missing something, it should probably be:

call z, backup_keyint + 1

Anyways. In the current setting, I cannot confirm this 100%. Using openmsx, NMS 8255, there seem to be no other interrupts. In my testprogram

IsVsync() == 0

is never true.

...--Just thought I'd bring it up :)

By ducasp

Champion (386)

ducasp의 아바타

23-04-2020, 18:13

Yeah, interrupt stuff in 1.2 is prone to crashing/not work, we have talked about it hwre:

https://msx.org/forum/msx-talk/development/fusion-c-and-htimi

In page 3 of this topic I've shared a solution that is based on DarkScheineder suggestion, made two examples, one if you just want to be called every 1/60s (or 1/50s if PAL) and another one that is called every interrupt. In most cases only the VDP will interrupt, but other devices (i.e. External interfaces, drive interfaces, v9990, etc) will cause interruptions as well.

Whether you want to hook your function to all interrupts or just to VDP Interrupts is up to what you want to achieve, but refrain from using IsVsync, that function read the vdp status register and it will clear the vdp interrupt flag, thus causing the bios or dos functions to think it wasn't a vdp interruption and this will cause a lot of issues like keyboard reading not working.

페이지 17/21
10 | 11 | 12 | 13 | 14 | 15 | 16 | | 18 | 19 | 20 | 21