Jump to content



Photo
- - - - -

Clearing/Updating Buffers


  • Please log in to reply
11 replies to this topic

#1 k3v

k3v

    Casio Fan

  • Members
  • PipPip
  • 40 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio Classpad 300 Plus \
    2 x Casio Fx-9860AU \
    Casio CFX-9850GB Plus \

Posted 23 November 2007 - 01:25 PM

Latest rev-fx is great!

Now how do i clear and update buffers continuously without getting extra flicker?

My current setup is this, and it creates tons of extra flicker as each loop it draws the cleared screen... rather then clear it behind the scenes
[not actual code, just the general idea]

int AddIn_main(int isAppli, unsigned short OptionNum)
{

GrayInit(3270, 3270); 
GrayLinkBuffers(buffer1, buffer2);

while(1){		  //main loop

memset(buffer1, 0, 1024);
memset(buffer2, 0, 1024); //clear each buffer

DrawSprites(); //Draw what i want etc.

} //repeat!

return 1;

}


#2 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 24 November 2007 - 01:50 AM

To overcome flickering, you should use the double buffer technique. If you've looked at the source code for MLC fx-9860, it employs this technique to overcome flickering. The idea is to first draw your sprites onto separate buffers, then when finished, copy them to the screen.

#3 k3v

k3v

    Casio Fan

  • Members
  • PipPip
  • 40 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio Classpad 300 Plus \
    2 x Casio Fx-9860AU \
    Casio CFX-9850GB Plus \

Posted 24 November 2007 - 12:24 PM

Lol cmon help us out a bit more, haha i dont know were i can find the source to MLC-fx-9860 either...

#4 Andreas B

Andreas B

    Casio Freak

  • Members
  • PipPipPipPip
  • 160 posts
  • Gender:Male
  • Location:Norway

  • Calculators:
    fx-9860G SD

Posted 24 November 2007 - 02:26 PM

You should search or ask what exactly kucalc meant with:

The idea is to first draw your sprites onto separate buffers, then when finished, copy them to the screen.


http://www.google.co...ouble buffering

#5 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 24 November 2007 - 06:37 PM

Lol cmon help us out a bit more, haha i dont know were i can find the source to MLC-fx-9860 either...

Lol, I don't know how to describe it in more detail. If you read what I posted, you could get the idea:

The idea is to first draw your sprites onto separate buffers, then when finished, copy them to the screen.

Now, that we got the idea let's implement it into some code.
unsigned char deck_buffer1[1024];

unsigned char deck_buffer2[1024];	  // We draw to these buffers



unsigned char screen_buffer1[1024];

unsigned char screen_buffer2[1024];   // These buffers are for the screen



GrayLinkBuffers(screen_buffer1, screen_buffer2);

GrayInit(3280, 3280);



while (1) {

	memset(deck_buffer1, 0, 1024);

	memset(deck_buffer2, 0, 1024);	// Only clear the deck buffers



	DrawSprites...();   // Draw only to deck_buffer1 and deck_buffer2

	

	// After finishing drawing to the deck buffers copy them to the screen buffers

	memcpy(screen_buffer1, deck_buffer1, 1024);

	memcpy(screen_buffer2, deck_buffer2, 1024);

}


#6 k3v

k3v

    Casio Fan

  • Members
  • PipPip
  • 40 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio Classpad 300 Plus \
    2 x Casio Fx-9860AU \
    Casio CFX-9850GB Plus \

Posted 25 November 2007 - 12:02 PM

lol i tried, i tried! But found nothing that could help me. The way i understood what you said kucalc sounded like what i was allready doing haha so i was like wtf?!?!?, i didnt think about two pairs of buffers. But thanks now i understand, i wasnt familiar with that buffer copying command either.

It reminds me of when i first asked about buffers, i completely missed the boat on that one haha... :roll:

EDIT: Ergh, with the four buffers now im getting a complile error:

The size of B and R section should be 0x2000 bytes or less.
Please refer to "C:Program FilesCASIOfx-9860G SDKk3v's gamesDD2 GreyscaleDebugFXADDINror.map".

Build was not successful.

How can i fix this?

#7 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 25 November 2007 - 02:51 PM

EDIT: Ergh, with the four buffers now im getting a complile error:

The size of B and R section should be 0x2000 bytes or less.
Please refer to "C:Program FilesCASIOfx-9860G SDKk3v's gamesDD2 GreyscaleDebugFXADDINror.map".

Build was not successful.

How can i fix this?

You need to trim down on how much working memory your using. The fx-9860 only allows you to use 8KB of working memory. Four buffers already consume 4KB (half of the working memory). My suggestion is to look over your code and try to replace as many large datatypes (like int - 4 bytes) with something smaller (like char - 1 byte) if possible or look for stuff you don't need that can be removed.

#8 k3v

k3v

    Casio Fan

  • Members
  • PipPip
  • 40 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio Classpad 300 Plus \
    2 x Casio Fx-9860AU \
    Casio CFX-9850GB Plus \

Posted 26 November 2007 - 09:52 AM

lol ok, will do.

Sorry for all the bitching/questions haha, its great your there for help though! Appreciated!

#9 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 26 November 2007 - 01:50 PM

lol ok, will do.

So, did you do it? We're you able to minimize the amount of memory you were using?

Sorry for all the bitching/questions haha, its great your there for help though! Appreciated!

No problem. :)

#10 k3v

k3v

    Casio Fan

  • Members
  • PipPip
  • 40 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio Classpad 300 Plus \
    2 x Casio Fx-9860AU \
    Casio CFX-9850GB Plus \

Posted 27 November 2007 - 04:17 AM

Yep i was, its all fine (for the moment ;) )

#11 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 27 November 2007 - 06:42 AM

Yep i was, its all fine (for the moment ;) )

Cool. If it's not too much to ask for since we did kind of help you out, could you perhaps put in some credit to the UCPF and Revolution-FX, maybe perhaps like a start up screen announcing the UCPF/Revolution-FX. Any amount of attention for the UCPF would be great. :)

#12 k3v

k3v

    Casio Fan

  • Members
  • PipPip
  • 40 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio Classpad 300 Plus \
    2 x Casio Fx-9860AU \
    Casio CFX-9850GB Plus \

Posted 28 November 2007 - 04:53 AM

Haha, well i was definately going to put some sort of thanks to your work kucalc since it wouldnt be possible without it. Sure.. why not ;)

Offtopic: Are you entering the planet-casio competition? Im in a mad rush to try finish mine.. :lol:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users