Getting VBlank Status
Posted: Thu Oct 10, 2024 2:47 am
I'm deep diving into VERA at the moment, but even with the documentation available, I'm not quite sure how to handle VBlank. Whether it matters that I'm working in 320x240, if I have to count lines, or if there's a flag.
I wrote the following C code, thinking I understand. However, given the resulting flicker, something isn't working correctly.
I wrote the following C code, thinking I understand. However, given the resulting flicker, something isn't working correctly.
Code: Select all
#include <stdio.h>
typedef unsigned char u8;
typedef volatile unsigned char vu8;
#define ROM_BANK (*(vu8*)0x9f60)
// KERNAL
// PETSCII
// VERA
#define ADDRx_L (*(vu8*)0x9f20)
#define ADDRx_M (*(vu8*)0x9f21)
#define ADDRx_H (*(vu8*)0x9f22)
#define DATA_0 (*(vu8*)0x9f23)
#define DATA_1 (*(vu8*)0x9f24)
#define CTRL (*(vu8*)0x9f25)
#define IEN (*(vu8*)0x9f26)
#define ISR (*(vu8*)0x9f97)
#define DC_HSCALE (*(vu8*)0x9f2a)
#define DC_VSCALE (*(vu8*)0x9f2b)
void AddressSelect(u8 HighByte,u8 MidByte,u8 LowByte){
ADDRx_L = LowByte;
ADDRx_M = MidByte;
ADDRx_H = HighByte;
}
void FixScreen(){
asm("lda #$8f");
asm("jsr $ffd2");
asm("lda #$8e");
asm("jsr $ffd2");
}
void ClearScreen(){
asm("lda #$93");
asm("jsr $ffd2");
}
void main(void){
FixScreen();
DC_HSCALE = 0x40;
DC_VSCALE = 0x40;
while(1){
while(ISR & 0x01){
printf("hello");
ClearScreen();
}
}
}