[cc65] tgi interrupts?

From: Karri Kaksonen <karri1sipo.fi>
Date: 2009-09-09 11:22:42
In all my programs I have a VBL interrupt handler in order to swap 
tgi_drawpage and tgi_showpage at a time when the user won't notice the 

Somehow it would be nice to include this service to the cc65 libraries.

Perhaps a separate tgi_utils.s ?

.segment "ZP_DATA"
     .byte     0
     .byte     0
     .byte     0
     .byte     0
     .byte     0
     .byte     0

.proc   _tgi_swap: near
        lda     _paused
        bne     @L0
        inc     _framecounter
        bne     @L0
        inc     _framecounter+1
        bne     @L0
        inc     _framecounter+2
        lda     _tgi_swapbuffers
        beq     @L1
        lda     _tgi_drawpage
        jsr     _tgi_setviewpage
        lda     _tgi_drawpage
        eor     #$01
        sta     _tgi_drawpage
        jsr     _tgi_setdrawpage
        stz     _drawPending

The variables _paused and _framecounter could be in ZP as they are very 
usable for other things also.

The framecounter can be used for controlling the tempo of the music.
The framecounter can also be used as a source for a real time clock.

The variable _tgi_swapbuffers is set by the game application to trigger 
the swap buffer function.

game code
if (screen_update_needed && !tgi_swapbuffers) {
  ... draw stuff on the drawpage
  tgi_swapbuffers = true;

The _tgi_swap code is called at every vertical blanking interrupt.


To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Sep 9 11:22:56 2009

This archive was generated by hypermail 2.1.8 : 2009-09-09 11:22:58 CEST