News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

cpctelera : cpct_img2tileset for mode 2 not ok.

Started by funkheld, 09:39, 21 November 20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

funkheld


Hi good afternoon.


I would like to implement a bild.bmp with cpct_img2tileset, please.
the sprite.jpg is 40x40 pixels.


it is to be implemented for mode 2. but does not work that way.
cpct_img2tileset -m 2 -tw 40 -th 40 sprite.jpg


how must the color of the image.jpg look like that this is converted correctly.


greeting


------------------------------
#include "sprite.h"
// Data created with Img2CPC - (c) Retroworks - 2007-2015
u8* const g_tile_tileset[1] = {
   g_tile_sprite
};
// Tile g_tile_sprite: 40x40 pixels, 5x40 bytes.
const u8 g_tile_sprite[5 * 40] = {
   0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff,
.....
......
.......
--------------------------------


-------------------------------
// Data created with Img2CPC - (c) Retroworks - 2007-2015
#ifndef _SPRITE_H_
#define _SPRITE_H_


#include <types.h>
extern u8* const g_tile_tileset[1];


#define G_TILE_SPRITE_W 5
#define G_TILE_SPRITE_H 40
extern const u8 g_tile_sprite[5 * 40];


#endif


----------------------------



#include <cpctelera.h>
#include "sprite.h"




void main(void) {
   u8* video_memory_start  = (u8*)0xC000;
   
   cpct_setVideoMode(2);


   cpct_drawSprite(g_tile_sprite, video_memory_start, 5, 40);


   while (1);
}



ervin

I haven't used cpct_img2tileset, but I would not recommend using JPG files, as they are of poor quality and often don't contain accurate colour information.
It's better to have a perfect copy of your image in BMP or PNG format.

funkheld

#2

have now made a sprite.jpg.
exactly the same kaos.


have now made the sprite.jpg in white / black.
kaos.


mode 2 ?
-------------------------------------

const u8 g_tile_sprite[5 * 40] = {
   0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x03, 0xff, 0x00, 0x00,
   0x00, 0x0f, 0xff, 0xe0, 0x00,
   0x00, 0x3e, 0x00, 0x78, 0x00,
   0x00, 0x78, 0x00, 0x3c, 0x00,
   0x00, 0xe0, 0x00, 0x0e, 0x00,
   0x01, 0xc0, 0x00, 0x07, 0x00,
....
....
....
----------------------------------

Thank you.
greeting

ervin

If you zoom in to your new sprite.jpg, you will see that it is not a clean image.
JPG compression means that colour information is not accurate.
Draw your image in correct CPC colours, and save it as a BMP or PNG.
Do not use JPG.

funkheld

blue = 0000ff
yellow = ffff00

hmmm ... the same crap mode 2


greeting


prototano

Have you specified the to use palette on the img2tileset command?
For example:cpct_img2tileset -m 2 -tw 40 -th 40 -pf '{0 26}' sprite.jpg
The command will approximate the image colors to the palette given. And also, you will need to set the same palette on the code.

ronaldo

#6
Quote from: funkheld on 16:58, 21 November 20
blue = 0000ff
yellow = ffff00
hmmm ... the same crap mode 2
greeting

Again and again same rudeness: this is crap, this is kaos, this is not working... And again and again this is the same we told you last time. You are asking the same questions and making the same mistakes. But, of course, you continue to be rude and blame the tools. Not a single trace of listenting to what we already told you many times.

First of all, I remember you what I already told you for the third or fourth time. CPCtelera is a tool for developers. If you are not a developer, CPCtelera does not magically turn you into a developer. If you can't understand things, you need much time and conscious effort to learn and become a developer. Nothing in CPCtelera will save you from your own lack of knowledge. If you are not a developer, and don't know what you are doing, you will continuously fail. But again, this is not demerit of the tools. This is the consequence of your own lack of knowledge. And judging from your continuos rudeness, I take that you want tools to do the right thing even if you don't know how to tell them. No single tool will do that. No single tool has the power to make you understand that learning is your responsiblity. Only you can do that. And, of course, no single tool can prevent you from blaming your own lack of knowledge on them.

Second, @ervin is completely right in telling you not to use JPG. JPG does not store pixel values, but compress the image by losing quality. It makes an approximation to the real image. Therefore, your sprites won't be same as you designed them. They will lose quality for sure if you insist on using JPG.

What's the point on asking if you insist on not listening to the people that take their time to look at your problem and try to help you?

And third, the sprite conversion is not crap, is totally correct. The kaos and crap should be in your own code and, again, in your lack of knowledge. And this is because you even haven't looked at your output properly. Your screen is showing 4 colours, which clearly is MODE 1!. How on earth are you expecting a MODE 2 sprite to show properly on a MODE 1 screen?

I have tested your conveted values on a MODE 2 screen and they correctly show your sprite.

Again, I'm tired of telling you this. Do you actually want to learn? Then stop being rude, stop blaming tools, stop asking others every tiny detail. If you really want to learn, invest time in learning. Using developer tools without knowledge is like piloting a spacecraft without training. That's what you are doing. And it is not the spacecraft's fault that you are constantly crashing.

funkheld


hello, in mode 1 all sprites that you have created yourself are visible in all forms as in the bmp.


mode 2 no...it's egg plums


greeting

funkheld

#8

all sprites are now in png and bmp.
nevertheless this error comes in mode 2.



i make  :
cpct_img2tileset -m 2 -tw 40 -th 40 -pf  {0 26}

if 4 colors are displayed in mode 2, it's not up to me, my program is correct.

this is mode 2 :

#include <cpctelera.h>
#include "test.h"

void main(void) {
   u8* video_memory_start  = (u8*)0xC000;
   
   cpct_setVideoMode(2);

   cpct_drawSprite(g_test, video_memory_start, 10, 20);

   while (1);
}



mode 2:


#include <cpctelera.h>
#include "test.h"


#define SP_W   10
#define SP_H   20


#define SCR_W   80
#define SCR_H  200


void main(void) {
   u8  x=10, y=10;   
   u8* pvideomem;   


   cpct_disableFirmware();
   cpct_setVideoMode(2);


   while(1) {
      cpct_scanKeyboard_f();


      if(cpct_isKeyPressed(Key_CursorRight) && x < (SCR_W - SP_W) )
      {       
        ++x;
        cpct_memcpy(0xc000,0x4000,0x4000);
      } 
      else if (cpct_isKeyPressed(Key_CursorLeft)  && x > 0)
      {       
        --x;
        cpct_memcpy(0xc000,0x4000,0x4000);
      } 
      if(cpct_isKeyPressed(Key_CursorUp)    && y > 0)
      {
        y=y-2;
        cpct_memcpy(0xc000,0x4000,0x4000);
      }
      else if (cpct_isKeyPressed(Key_CursorDown)  && y < (SCR_H - SP_H) )
      {
        y=y+2;
        cpct_memcpy(0xc000,0x4000,0x4000);
      }
     
      pvideomem = cpct_getScreenPtr(CPCT_VMEM_START, x, y);
      cpct_drawSprite(g_test, pvideomem, SP_W, SP_H);
   }
}
[/mode]




greeting.

prototano

As is specified on the documentation, set the video mode requires to have the firmware disabled. Look at the docs and check the cpctelera's examples.

funkheld


Hi, Thank You.


that's it.
it works now.


but why?


greeting

ronaldo

#11
Quote from: funkheld on 19:20, 21 November 20
all sprites are now in png and bmp.
nevertheless this error comes in mode 2.
i make  :
cpct_img2tileset -m 2 -tw 40 -th 40 -pf  {0 26}

if 4 colors are displayed in mode 2, it's not up to me, my program is correct.

Again, the problem is your lack of knowledge, but you still continue to blame others. It's up to you knowing exactly what your code does and why does what it does. If you don't know it, it's your fault, not a problem of the tool.

In fact, there is no need to be a developer to know that an Amstrad CPC can't display 4 colours in MODE 2 without programming counscious tricks. As that's not what you were doing, you should have noticed that your emulator was showing a MODE 1 screen, not a MODE 2 screen. That's completely up to you. You are the developer, you need to know because the tools give you complete control. And if you don't know what you are doing, having complete control is your fastest path to crashing.

And it is clear that you don't know what you are doing. You can insist that this is not your fault, but clearly is your lack of knowledge again. You didn't know that you had to disable firmware to be able to use videomode changing functions. That is clearly stated in the documentation. It is your responsability to read it carefully before blaming the tools. Moreover, you are programming an Amstrad CPC: if you don't know how it works internally, that is also your responsabilty. You are the developer: those are your responsibilities. No single tool is to blame for your lack of knowledge, be it a tool integrated in CPCtelera or any other.

Your program wasn't correct. You need to disable the firmware because the firmware maintains its own MODE and colours, and if you change them the firmware restores them again in less than 1/50s. So, that means your Amstrad CPC was still in MODE 1.

And as I take from your answers that you want to continue in your same mood, being rude and not listening, I will refrain from now on to tell you this again. My time is limited and wasting it on helping someone that does not want to listen is a pity.

After this, my best recommendation to you is that you consider 2 alternatives seriously: 1) If you want to be a developer, accept that you don't know many many things and change your mood. To become an Amstrad developer you need to learn. 2) Stop using developer tools and go for other options. You can use magnificent AGD by Jonathan Cauldwell which could be a much better entry point for making games for you.

funkheld


Hello Howdy.


you are such a nice person, i like you.
I hope you can help me again later
instead of writing so much. i have with my age
sometimes pauses for thought and forgetfulness.


I guess you're still in a good mood, stay like this.  :-*


greeting

SRS

@ronaldo

Look for CPCMAN at CPCWIKI.DE Forum and you may feel better. Guess we just need to answer only questions that show some understandment and self-effort. But thats only my opinion ...



ervin

Quote from: funkheld on 23:00, 21 November 20
Hello Howdy.

you are such a nice person, i like you.
I hope you can help me again later
instead of writing so much. i have with my age
sometimes pauses for thought and forgetfulness.

I guess you're still in a good mood, stay like this.  :-*

greeting

@funkheld With that sort of attitude, you have probably hurt your chances of getting help from many of us.

@ronaldo is an absolutely outstanding teacher.
Everything he said is 100% correct.

@funkheld You however, are not trying hard enough to learn.
You are not being a good student.
All you do is ask us to hold your hand through every little thing that you try.
Read both of @ronaldo's posts again, and listen to what he has said.
It is the best advice you will ever receive regarding becoming a developer.

If you make a real effort to LEARN, you will start to get some results.
If you show more respect, and prove that you have really tried to learn (instead of just guessing and fumbling around), people will be happier to help you.

I wish you good luck, and I wish you would listen to the outstanding advice you have been given.

AMSDOS

@funkheld - if you have ideas for games or other programmes, though are having trouble implementing, write those ideas down and post in the programming forum. New ideas are more valuable.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

funkheld

#16
my ideas are not just games.


there is much more to cpctelera than just using it for games. The so-called Sprite can
also be used for a surface that is operated with the mouse , a user interface (Desktop)

the cpc is not just a game box.

Greeting

trocoloco

Quote from: funkheld on 18:20, 22 November 20there is much more to cpctelera than just using it for games

you should read carefully before answering -> " if you have ideas for games OR OTHER PROGRAMMES"

SpDizzy

#18
Quote from: ronaldo on 18:50, 21 November 20
Again, I'm tired of telling you this. Do you actually want to learn? Then stop being rude, stop blaming tools, stop asking others every tiny detail. If you really want to learn, invest time in learning. Using developer tools without knowledge is like piloting a spacecraft without training. That's what you are doing. And it is not the spacecraft's fault that you are constantly crashing.
I told myself I would never lose time anymore trying to help @funkheld after various vain attemps. You now have received the best advice ever, from the best knowlegde source. Please take it, otherwise you wouldn't be able to experience the enormous pleasure of seeing everything working as expected.

Powered by SMFPacks Menu Editor Mod