Jump to content
Sign in to follow this  
RSS Bot

Robin Gravel's Blog - Subroutines in C

Recommended Posts

I learned something new in C recently:

Theses codes are for Colecovision.


This code is like if I type it in Basic, without numbers.

 

 



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

 

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();
print_at(1,1,"TESTING");
fill_vram(0x2200,0xe1,256);
loop:
goto loop;
}



This one uses a subroutine.

 

 



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

 

void nmi(void) {}
void testing(void){
print_at(1,1,"TESTING");
}

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();
testing();
fill_vram(0x2200,0xe1,256);
loop:
goto loop;
}


Both codes give the same result except the last one use a subroutine.


When I saw codes from source games for the first time, I was confusing and completely lost.

Now, I'm fine with it and I can go further.

My GOOMW (Get Out Of My Way) is a mess and need to clean up using subroutines instead.

http://atariage.com/forums/blog/56/entry-15530-subroutines-in-c/

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...