Subject: [stella] Why Timers refuse to work the way they should? From: Rodrigo Silva <stella@xxxxxxxxxxxxx> Date: Sat, 20 Sep 2003 19:00:14 -0300 |
; Copyleft 2003 By Rodrigo E.S. Silva - atari@xxxxxxxxxxxxx ; Under GPL - GNU Public Licence - http://www.fsf.org/copyleft/gpl.html ; You may copy, distribuite, use, edit, sell, whatever, as long as such freedom ; is propagated in evey version and my credit for original work is kept ; "GPL = Freeware that should remain Free" processor 6502 ; Atari 2600 CPU include "vcs.h" ; TIA Definitions include "macro.h" ; Useful Functions ;/////////////////////////////////////////////////////////////////////////////// SEG.U Variables ORG $80 ;/////////////////// Global Variables GlobalDummy ds 0 ;------------------------------------------------------------------------------ ; OVERLAYS! ; These variables are overlays, and should be managed with care ; That is, variables are ALREADY DEFINED, and we're reusing RAM for other ; purposes ; EACH OF THESE ARE VARIABLES (TEMPORARY) USED BY ONE ROUTINE (AND IT'S ; SUBROUTINES) THAT IS, LOCAL VARIABLES. USE 'EM FREELY, THEY COST NOTHING ; TOTAL SPACE USED BY ANY OVERLAY GROUP SHOULD BE <= SIZE OF 'Overlay' ;------------------------------------------------------------------------------ Overlay ds 0 ; overlay (share) variables (make sure this is as big ; as the biggest overlay subsection) ;/////////////////// 1st set of Overlay Variables - repeat block as necessary ORG Overlay ov1_Dummy ds 0 ECHO [*-$80]d,"out of 128 RAM bytes used",[$100-*]d,"bytes left" ;/////////////////////////////////////////////////////////////////////////////// SEG ORG $F000 Reset CLEAN_START ; Clear RAM and all TIA registers ; Now A = X = Y = 0 ;---------------------------------------------------------------------- ; Once-only initialization... take your time ; End of once-only initialization ;---------------------------------------------------------------------- StartOfFrame lda #%00000010 sta VSYNC ; Starts VSYNC sta WSYNC ; End of VSYNC Line 1 sta WSYNC ; End of VSYNC Line 2 sta WSYNC ; End of VSYNC Line 3 lda #%00000000 ; Get ready to turn off VSYNC sta VSYNC ; Turn off VSYNC lda #44 ; sta TIM64T ; Start the timer for VBlank ;---------------------------------------------------------------------- ; 37 scanlines of vertical blank... have fun with XXXX cycles ; End of fun ;---------------------------------------------------------------------- WaitEndOfVBlank lda INTIM ; check timer... bne WaitEndOfVBlank ; lda #%00000000 ; Get ready to turn off VBLANK sta WSYNC ;---------------------------------------------------------------------- ; Do 192 scanlines ; 1st line has 5 cycles less then the others , ; so blew it off if kernel is too tight sta VBLANK ; Turns VBLANK off ldx #192 ; scanline counter ;dex ; uncomment here and below if needed ;sta WSYNC ; (prematuraly ends 1st scanline, but ; guarantees that all the other lines ; have exactly the same cycle counting) Kernel ;--Go kernel, go! ;---------------- sta WSYNC dex ; bne Kernel ; ;---------------------------------------------------------------------- ; 30 scanlines of overscan... lda #%01000010 ; Get ready for Blanking sta VBLANK ; End of screen - enter blanking lda #36 ; sta TIM64T ; Start Timer for Overscan ;---------------------------------------------------------------------- ; Have more fun with XXXX cycles left for overscan ; Sorry pal, time's up - get ready for next frame ;---------------------------------------------------------------------- WaitEndOfOverscan lda INTIM ; check timer... bne WaitEndOfOverscan sta WSYNC jmp StartOfFrame ;/////////////////////////////////////////////////////////////////////////////// ECHO [*-$F000+6]d,"out of 4096 ROM bytes used",[$FFF9-*]d,"bytes left" ORG $FFFA InterruptVectors .word Reset ; NMI .word Reset ; RESET .word Reset ; IRQ END ; EOF
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Poorlords Alpha, Fabrizio Zavagli | Thread | Re: [stella] Why Timers refuse to w, Andrew Davie |
Re: [stella] Where's the middle?, Andrew Towers | Date | Re: [stella] new project; fpga2600, clarkin |
Month |