[MSX-C] Q&A official thread

Страница 5/68
1 | 2 | 3 | 4 | | 6 | 7 | 8 | 9 | 10

By PingPong

Enlighted (4156)

Аватар пользователя PingPong

28-08-2015, 21:24

AxelStone wrote:
Sylvester wrote:

Nice! to make the function more reusable i would introduce some params (filename, page) but that's for the next version Smile
About the palette, according to https://github.com/sharksym/CPMEMU_HI-TECH_C/blob/master/BLG...
It's almost the same routine as for the image, it loads the file (see bl_grp_load_ge5_pat()) and then places it into the VRAM. Maybe it helps, else you have to wait for other solutions :)

Sure, the idea is to make the function reusable: filename, page, even screen. BUFSIZE should calculate dinamically depending on SCREEN mode (128bytes for SC5, 256bytes for SC7/SC8) and the header size I'm not sure if equals in all screens (7 bytes).

For palette, lets wait for JaviLM translation. MSX-C libraries has several palette functions, so I suposse this time it's a good idea to use them instead to make it yourself ;) .

When the final version of both functions were finished, we'll share the source code.

Take care of stack size. We are not on 2015 world. I do not know but i think the buffer it's actually allocated on stack. 256 maybe to large.... suggest you to declare as static

By anonymous

incognito ergo sum (116)

Аватар пользователя anonymous

29-08-2015, 03:38

I think you should be able to just do a rstplt() immediately after loading the file into VRAM. I haven't tried, but I think that rstplt() does exactly the same as COLOR=RESTORE in BASIC.

By AxelStone

Prophet (3199)

Аватар пользователя AxelStone

29-08-2015, 11:54

JaviLM wrote:

I think you should be able to just do a rstplt() immediately after loading the file into VRAM. I haven't tried, but I think that rstplt() does exactly the same as COLOR=RESTORE in BASIC.

Hi Javi, I've translated to MSX-C the steps I did in Basic, this is:

10 BLOAD"image.pl5",S:COLOR=RESTORE:BLOAD"image.sc5",S

This is: palette, restore, image.

You suggest to make: palette, image, restore. Perhaps your behaivor is more acurate since some .sc5 images has the palette built in into the picture file and you can make simply:

10 BLOAD"image.sc5",S:COLOR=RESTORE

BMP2MSX for example can generate images in this way. In this case, if you want to overwrite the palette included you should made the loadplt after the load image.

It should be a good exercise: try to load a BMP2MSX generated image in order to see if palette works Smile

By anonymous

incognito ergo sum (116)

Аватар пользователя anonymous

29-08-2015, 19:28

AxelStone wrote:
JaviLM wrote:

I think you should be able to just do a rstplt() immediately after loading the file into VRAM. I haven't tried, but I think that rstplt() does exactly the same as COLOR=RESTORE in BASIC.

You suggest to make: palette, image, restore. Perhaps your behaivor is more acurate since some .sc5 images has the palette built in into the picture file and you can make simply:

No, that's not what I meant. What I meant is that if the palette information was embedded in the image (as is the case on images generated via BSAVE or .GE5 files created with DD倶楽部), then you can just do a rstplt() instead of making another function just to set the colors.

This would be the modified program. I've actually modified main() to take the file name from the command line, and I've modified the fread() loop in loadimg() to actually check that we're not reaching the end of file:

#include 
#include 

#define PAGE0   0x0000
#define PAGE1   0x8000

#define SCREEN5 (TINY)5
#define SCREEN0 (TINY)0

#define BUFSIZE 1024

VOID    loadImg(filename)
char    *filename;
{
        FILE    *fp;
        char    buf[BUFSIZE];
        int     i, nread;
        int     vrami = PAGE0;

        if ((fp = fopen(filename, "rb"))) {
                fread(buf, 7, 1, fp);   /* Skip 7-byte header */

                /* Read the file to VRAM */
                while ((nread = fread(buf, sizeof(char), BUFSIZE, fp))) {
                        ldirvm(vrami, buf, nread);
                        vrami += BUFSIZE;
                }

                fclose(fp);
        } else {
                return;
        }
}

VOID    main(argc, argv)
int     argc;
char    *argv[];
{
        if (argc < 2) {
                printf("Usage: GE5READ \n");
                exit(0);
        }

        screen(SCREEN5);
        loadImg(argv[1]);
        rstplt();
        getchar();
        screen(SCREEN0);
}

By AxelStone

Prophet (3199)

Аватар пользователя AxelStone

29-08-2015, 19:50

JaviLM][quote=AxelStone wrote:

No, that's not what I meant. What I meant is that if the palette information was embedded in the image (as is the case on images generated via BSAVE or .GE5 files created with DD倶楽部), then you can just do a rstplt() instead of making another function just to set the colors.

Right, BMP2MSX integrates palette inside image too, so you could do the same. Other image converters as MiFui doesn't do that, so you must do it manually.

Since image load seems to be working, let's go for another question, this time very simple Smile . I've compiled "Hello world" and it indicates 39528 bytes free. How much memory is available to develop in C?

Thanks!

By anonymous

incognito ergo sum (116)

Аватар пользователя anonymous

29-08-2015, 19:58

JaviLM wrote:
#include 
[...]

Hmmm, the < and > aren't displayed properly. Let me try again:

#include <stdio.h>
#include <glib.h>

#define PAGE0   0x0000
#define PAGE1   0x8000

#define SCREEN5 (TINY)5
#define SCREEN0 (TINY)0

#define BUFSIZE 1024

VOID    loadImg(filename)
char    *filename;
{
        FILE    *fp;
        char    buf[BUFSIZE];
        int     i, nread;
        int     vrami = PAGE0;

        if ((fp = fopen(filename, "rb"))) {
                fread(buf, 7, 1, fp);   /* Skip 7-byte header */

                /* Read the file to VRAM */
                while ((nread = fread(buf, sizeof(char), BUFSIZE, fp))) {
                        ldirvm(vrami, buf, nread);
                        vrami += BUFSIZE;
                }

                fclose(fp);
        } else {
                return;
        }
}

VOID    main(argc, argv)
int     argc;
char    *argv[];
{
        if (argc < 2) {
                printf("Usage: GE5READ <filename>\n");
                exit(0);
        }

        screen(SCREEN5);
        loadImg(argv[1]);
        rstplt();
        getchar();
        screen(SCREEN0);
}

By anonymous

incognito ergo sum (116)

Аватар пользователя anonymous

29-08-2015, 20:17

AxelStone wrote:

Since image load seems to be working, let's go for another question, this time very simple Smile . I've compiled "Hello world" and it indicates 39528 bytes free. How much memory is available to develop in C?

Without touching the memory mapper, you have all the space between 0100h and the start of the system work area. Under MSX-DOS the start address of the system work area is stored in addresses 0006h-0007h (it should be somewhere above D000h).

If I'm not mistaken (I'm way too sleepy), you'll have around 50-53KB for your programs.

By AxelStone

Prophet (3199)

Аватар пользователя AxelStone

29-08-2015, 20:51

@JaviLM 50Kb is a great amount, thanks. Perhaps it's time to try next thing, I'm going to try some image manipulation as scrolls. This implies to play with interrupts in order not to get teering, so it's a good chance to learn about interruption handle in C.

The thread is being really interesting, I think that all of us are learning some things about MSX-C Thanks everybody for your colaboration Wink

By Grauw

Ascended (10821)

Аватар пользователя Grauw

29-08-2015, 23:45

AxelStone wrote:

The thread is being really interesting, I think that all of us are learning some things about MSX-C Thanks everybody for your colaboration Wink

Agreed!

By anonymous

incognito ergo sum (116)

Аватар пользователя anonymous

30-08-2015, 03:38

Oh, and by the way, the message about the 39528 bytes free is from the linker (L80). It's not related to how much memory you have for your program.

Страница 5/68
1 | 2 | 3 | 4 | | 6 | 7 | 8 | 9 | 10