Jump to content
Serguei2

put_at: too many parameters and won't compile

Recommended Posts

I can't make put_at to work.

 

 

 

#include <coleco.h>
#include <getput1.h>
void nmi(void) {}
void testing(void){
put_at(1,3,"TESTING",4);
}

void main(void)
{
vdp_out(0,1);
vdp_out(0,0x1F85);
paper(0xc);
screen_mode_2_text();
upload_default_ascii(NORMAL);
duplicate_pattern();
cls();
screen_on();
fill_vram(0x2200,0xe1,256);
testing();
loop:
goto loop;
}
Edited by Serguei2

Share this post


Link to post
Share on other sites

use this:

 

print_at(1,3,"TESTING");

 

 

 

void print_at (byte x, byte y,char *s)
{
register unsigned i;
disable_nmi ();
i = (byte) strlen (s);
put_vram (chrtab+y*32+x,s,i);
enable_nmi ();
}

Share this post


Link to post
Share on other sites

Like this?

 

 

 

#include <coleco.h>
#include <getput1.h>
void print_at (byte x, byte y,char *s)
{
register unsigned i;
disable_nmi ();
i = (byte) strlen (s);
put_vram (chrtab+y*32+x,s,i);
enable_nmi ();
}
void nmi(void) {}
void main(void)
{
vdp_out(0,1);
vdp_out(0,0x1F85);
paper(0xc);
screen_mode_2_text();
upload_default_ascii(NORMAL);
duplicate_pattern();
cls();
screen_on();
fill_vram(0x2200,0xe1,256);
print_at(1,3,"TESTING");
loop:
goto loop;
}

 

I got this error:

 

Try to compile : put_at.c
put_at.c:10: warning 112: function 'strlen' implicit declaration
C:\robin\ColecoVision\robin>sdcc -mz80 -c --std-c99 --oldralloc put_at.c
put_at.c:10: error 101: too many parameters
put_at.c:10: error 47: indirections to different types assignment
from type 'void'
to type 'unsigned-int register'
put_at.c:11: error 20: Undefined identifier 'chrtab'
put_at.c:17: error 65: function 'nmi' already has body
put_at.c:26: warning 112: function 'duplicate_pattern' implicit declaration

Share this post


Link to post
Share on other sites

Maybe SDCC is defining some default defines that don't play well with the header files. When the compiler starts spitting out nonsense error messages, I always suspect macro issues. Try this:

 

sdcc -mz80 -E --std-c99 --oldralloc put_at.c > put_at.s

 

Then look for the put_at in put_at.s and see what the preprocessor REALLY did to it.

Share this post


Link to post
Share on other sites

print_at is used for printing string. Similar to put_at. Put at don't use the string. Example to use put at,

const byte sample[] = {
'S','a','m','p','l','e'};

void main(){
..
put_at(4,6,sample,6);
..
};

sample is a pointer address.

 

Corrected source:

#include <coleco.h>
#include <getput1.h>

const byte testingstring[] = {
'T','E','S','T','I','N','G'
};

void nmi(void) {}
void testing(void){
 put_at(1,3,testingstring,4);
}
 
void main(void)
{
 vdp_out(0,1);   
 vdp_out(0,0x1F85);
 paper(0xc);
 screen_mode_2_text();
 upload_default_ascii(NORMAL);
 duplicate_pattern();
 cls();
 screen_on();
 fill_vram(0x2200,0xe1,256);
 testing();
 loop:
  goto loop;
}

That should print "TEST"

Share this post


Link to post
Share on other sites

I get this error:

 

Try to compile : put_at.c
put_at.c:10: warning 112: function 'put_at' implicit declaration
C:\robin\ColecoVision\robin>sdcc -mz80 -c --std-c99 --oldralloc put_at.c
put_at.c:10: error 101: too many parameters
put_at.c:20: warning 112: function 'duplicate_pattern' implicit declaration
Try to link project : robin
C:\robin\ColecoVision\robin>sdcc -mz80 --code-loc 0x8024 --data-loc 0x7000 --no-std-crt0 ../crtcv.rel ../cvlib.lib ../getput.lib ../comp.lib
?ASlink-Warning-Undefined Global '_main' referenced by module 'crt0'
C:\robin\ColecoVision\robin>objcopy --input-target=ihex --output-target=binary crtcv.ihx result.rom
?ASlink-Warning-Undefined Global '_nmi' referenced by module 'crt0'

 

Did I mess up when copying your code?

 

 

#include <coleco.h>
#include <getput1.h>
const byte testingstring[] = {
'T','E','S','T','I','N','G'
};
void nmi(void) {}
void testing(void){
put_at(1,3,testingstring,4);
}

void main(void)
{
vdp_out(0,1);
vdp_out(0,0x1F85);
paper(0xc);
screen_mode_2_text();
upload_default_ascii(NORMAL);
duplicate_pattern();
cls();
screen_on();
fill_vram(0x2200,0xe1,256);
testing();
loop:
goto loop;
}

Share this post


Link to post
Share on other sites

If SDCC is that picky, it violates the C standard. You can always pass a "char *" to a function that expects a "void *". Also, C has no concept of "string". Neither does C++, but it now has a standard library with a class called "string". A string literal is just syntactic sugar for an anonymous array of char defined by the given sequence of bytes and a NULL terminator.

 

That said, the error message is about too many args, which makes no sense. The second message seems to be their way of saying "type mismatch" but it is completely ignorant of the fact that both types are pointers.

 

So again, I am pretty sure there is a problem with either the header files or the default defines in SDCC.

Share this post


Link to post
Share on other sites

Maybe SDCC is defining some default defines that don't play well with the header files. When the compiler starts spitting out nonsense error messages, I always suspect macro issues. Try this:

 

sdcc -mz80 -E --std-c99 --oldralloc put_at.c > put_at.s

 

Then look for the put_at in put_at.s and see what the preprocessor REALLY did to it.

 

I tried it with ChildOfCv's code I use.

 

Here I get:

 

 

# 1 "test.c"

# 1 "<built-in>"

# 1 "<command line>"

# 1 "test.c"

# 1 "C:/Program Files/SDCC/bin/../include/coleco.h" 1 3 4

# 34 "C:/Program Files/SDCC/bin/../include/coleco.h" 3 4

typedef unsigned char byte;

extern byte no_nmi;

extern byte vdp_status;
extern byte spinner_1,spinner_2;
extern byte joypad_1,joypad_2,keypad_1,keypad_2;
extern byte nmi_flag;
void os7 (unsigned addr,...);

void vdp_out (byte reg,byte val);

void put_vram (unsigned offset,void *ptr,unsigned count);
void get_vram (unsigned offset,void *ptr,unsigned count);
void fill_vram (unsigned offset,byte value,unsigned count);
void put_vram_ex (unsigned offset,void *ptr,unsigned count,

byte and_mask,byte xor_mask);

void put_vram_pattern (unsigned offset,void *pattern,

byte psize,unsigned count);

void set_default_name_table (unsigned offset);

void enable_nmi (void);

void disable_nmi (void);

void screen_on (void);

void screen_off (void);

void delay (unsigned count);

void update_sound (void);

void *start_sound (void *data,byte priority);
void stop_sound (void *channel);
void sound_on (void);
void sound_off (void);
typedef struct

{

byte y;

byte x;

byte pattern;

byte colour;

} sprite_t;

extern sprite_t sprites[64];

void update_sprites (byte numsprites,unsigned sprtab);

byte check_collision (sprite_t *sprite1,sprite_t *sprite2,

unsigned sprite1_size_hor,unsigned sprite1_size_vert,

unsigned sprite2_size_hor,unsigned sprite2_size_vert);

void utoa (unsigned value,void *buffer,byte null_character);

void *rle2ram (void *rledata,void *dest);

void *rle2vram (void *rledata,unsigned dest);

byte get_random (void);

void memcpyb (void *dest,void *src,unsigned n);

void memcpyf (void *dest,void *src,unsigned n);

void upload_ascii (byte first,byte count,unsigned offset,byte flags);

# 2 "test.c" 2

# 1 "C:/Program Files/SDCC/bin/../include/getput1.h" 1 3 4

# 9 "C:/Program Files/SDCC/bin/../include/getput1.h" 3 4

char get_char (byte x,byte y);

void put_char (byte x,byte y,char s);

void center_string (byte l,char *s);

void cls(void);

void pause (void);

void pause_delay(unsigned i);

void print_at (byte x, byte y,char *s);

# 36 "C:/Program Files/SDCC/bin/../include/getput1.h" 3 4

unsigned rnd(unsigned min, unsigned max);

byte rnd_byte(byte min, byte max);

char *str(unsigned value);

void show_picture(void *picture);

void screen_mode_2_bitmap(void);

void screen_mode_2_text(void);

void upload_default_ascii(byte flags);

void paper(byte color);

void load_color(byte *color);

void load_namerle(byte *namerle);

void load_patternrle(byte *patternrle);

void load_spatternrle(byte *spatternrle);

void change_pattern(byte c, byte *pattern, byte l);

void change_spattern(byte s, byte *pattern, byte N);

void change_color(byte c, byte *color, byte l);

void fill_color(byte c, byte color, byte n);

void change_multicolor(byte c, byte *color);

void change_multicolor_pattern(byte c, byte *color, byte n);

byte choice_keypad_1(byte min, byte max);

byte choice_keypad_2(byte min, byte max);

void updatesprites(byte first, byte count);

void sprites_simple(void);

void sprites_double(void);

void sprites_8x8(void);

void sprites_16x16(void);

# 138 "C:/Program Files/SDCC/bin/../include/getput1.h" 3 4

void wipe_off_down(void);

void wipe_off_up(void);

# 3 "test.c" 2

void print_at (byte x, byte y,char *s)

{

register unsigned i;

disable_nmi ();

i = (byte) strlen (s);

put_vram (chrtab+y*32+x,s,i);

enable_nmi ();

}

void nmi(void) {}

void main(void)

{

vdp_out(0,1);

vdp_out(0,0x1F85);

paper(0xc);

screen_mode_2_text();

upload_default_ascii(0);

duplicate_pattern();

cls();

screen_on();

fill_vram(0x2200,0xe1,256);

print_at(1,3,"TESTING");

loop:

goto loop;

}

Share this post


Link to post
Share on other sites

const byte testingstring[] = {
'T','E','S','T','I','N','G'
};


void testing(void){
 put_at(1,3,testingstring,4);
}
 
void main(void)
{
 vdp_out(0,1);   
 vdp_out(0,0x1F85);
 paper(0xc);
 screen_mode_2_text();
 upload_default_ascii(NORMAL);
 duplicate_pattern();
 cls();
 screen_on();
 fill_vram(0x2200,0xe1,256);
 testing();
 loop:
  goto loop;
}
void nmi(void) {}

This compiles. I had the void nmi(void) at the wrong spot. Should be at below main()

 

Check in C:\Program Files\SDCC\include

 

See if getput1.h and coleco.h is in this folder. If not, copy and paste from your homebrew kit. The batchall file doesn't work in Window 7 and up due to security setting if you're using external program to write in the program files. I usually refer to this video if I'm installing sdcc on a new machine.

 

 

That error also happens if you misspelled your function name like I do some of the times.

 

Share this post


Link to post
Share on other sites

In that latest snippet, I guess you're using the print_at function that one of the other posters offered instead. SDCC does indeed seem to be amazingly obstinate about following the C standard.

 

First, you didn't include the proper header to get strlen() defined. SDCC seems to make the default return type 'void' rather than 'int'. That violates the C standard. However, you should be able to add "#include <string.h>" at the top in order to get a definition for strlen anyway.

 

 

 

But all of that seems to be moot though, for this reason: getput1.h defines 'print_at' for you (but I don't see put_at...). That likely means that the library has an implementation already, and you don't need to create your own. I bet SDCC gives you its own incompatible version of getput1.h, as the original was made to use with Hi-Tech C. In fact, I just noticed the warning that put_at was implicitly defined.

Edited by ChildOfCv

Share this post


Link to post
Share on other sites

Would it be a possibility he might have an older getput.h.? This one have put_at...

/* gpputat.as */
void put_at (char x, char y, void *s, unsigned size);

I attached the .zip that contains getput.lib, put in same folder as cci3

And getput1.h in the C:/Program Files/sdcc/include folder.

I've wondered if I can put up newcoleco homebrew kit on this forum and we can put a sticky thread? It is getting more scarce to find his homebrew kit. I have the higher resolution of cv programming.pdf too. I think I'll start posting tutorial once I finish up this game I been making for the past 3 weeks. I do want to help people get started programming in C for the Colecovision.

getput.zip

Share this post


Link to post
Share on other sites

Would it be a possibility he might have an older getput.h.? This one have put_at...

 

 

/* gpputat.as */
void put_at (char x, char y, void *s, unsigned size);

I attached the .zip that contains getput.lib, put in same folder as cci3

 

And getput1.h in the C:/Program Files/sdcc/include folder.

 

I've wondered if I can put up newcoleco homebrew kit on this forum and we can put a sticky thread? It is getting more scarce to find his homebrew kit. I have the higher resolution of cv programming.pdf too. I think I'll start posting tutorial once I finish up this game I been making for the past 3 weeks. I do want to help people get started programming in C for the Colecovision.

 

Thanks it works. I still get warnings, but at least, it compiled.

  • Like 1

Share this post


Link to post
Share on other sites

 

Thanks it works. I still get warnings, but at least, it compiled.

No problem. Just curious, what was the warning. I think it may be " warning 230: label without statement". I got that and I think that was new in the latest sdcc, you can ignore that one.

Share this post


Link to post
Share on other sites

The same as usual.

 

put_at.c:20: warning 112: function 'duplicate_pattern' implicit declaration
C:\robin\ColecoVision\robin>sdcc -mz80 -c --std-c99 --oldralloc put_at.c
put_at.c:20: warning 84: 'auto' variable 'duplicate_pattern' may be used before initialization
put_at.c:20: warning 84: 'auto' variable 'duplicate_pattern' may be used before initialization

 

I always get this when I compile my stuff.

Share this post


Link to post
Share on other sites

Oh wait, just read. Duplicate pattern that one was new too.

Here's the updated coleco.h:coleco.zip

put in the sdcc/include folder

Sample from my beach clean up of the usage of this function. Notice that the disable_nmi(); and enable_nmi(); when doing mass vram write, this prevent nmi from interrupting the routine. It probably won't interrupt rle2vram, but will interrupt pletter decompression.

void main(void){
set_snd_table(snd_table);
screen_mode_2_text();
points=0;points2=0;

resetgame:
disable_nmi();
rle2vram(BeachSprite,0x3000);
rle2vram(BeachSprite,0x3800);
delay(5);
pletter(BeachHoldSprite,0x3000);
pletter(BeachNotHoldSprite,0x3800);
rle2vram(beachPATTERN,0x0000);
duplicate_pattern();
rle2vram(beachCOLOR,0x2000);

for(ID=0;ID!=8;ID++){RemoveObject();}
Instruction();
screen_on();
enable_nmi();
delay(5);
seconds=0;tick=0;
game=1;
while(game==1){

When using screen_mode_2_text();, this will set the vdp to 3 pattern table, and 1 color table mode. The old version used 1 pattern table and 1 color table. There's a bug on the real hardware affecting sprite 8-31, so it been changed to 3 pattern and 1 color table. So that work out for me because I can use the other 2 color table for something else like additional name tables and sprite tables to switch to.

screen_mode_2_text(); also uses the screen_off(); to hide the graphic loading so makes sure to use screen_on(); to turn on the screen.


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...