Browse Source

Add vblank checking and busyloop vsync_wait

vblank-busyloop
Bjorn Astrom 1 year ago
parent
commit
b0609f7a6b
2 changed files with 116 additions and 7 deletions
  1. +10
    -6
      rtg/mntgfx.c
  2. +106
    -1
      rtg/zz9000.h

+ 10
- 6
rtg/mntgfx.c View File

@@ -418,15 +418,19 @@ void set_write_mask(__reg("a0") struct RTGBoard* b, __reg("d0") uint8 m) {
}
void set_clear_mask(__reg("a0") struct RTGBoard* b, __reg("d0") uint8 m) {
}
void vsync_wait(__reg("a0") struct RTGBoard* b) {
}

static int toggle = 0;
// FIXME this returned -1 which caused WB to hang after selecting a screenmode!
int is_vsynced(__reg("a0") struct RTGBoard* b, __reg("d0") uint8 p) {
toggle = 1-toggle;
return toggle;
uint32 vblank_state = ((uint16*)b->registers)[REG_ZZ_VBLANK_STATUS / 2];
return vblank_state;
}

void vsync_wait(__reg("a0") struct RTGBoard* b) {
uint32 vblank_state = ((volatile uint16*)b->registers)[REG_ZZ_VBLANK_STATUS / 2];
while(vblank_state == 0) {
vblank_state = ((volatile uint16*)b->registers)[REG_ZZ_VBLANK_STATUS / 2];
}
}

void set_clock(__reg("a0") struct RTGBoard* b) {
}



+ 106
- 1
rtg/zz9000.h View File

@@ -70,8 +70,9 @@ typedef volatile struct MNTZZ9KRegs {

u16 sprite_bitmap; // 48
u16 sprite_colors; // 4a
u16 vblank_status; // 4c
u16 un_3[0x18]; // 4c..7e
u16 un_3[0x17]; // 4e..7e
u16 eth_tx; // 80
u16 eth_rx; // 82
@@ -95,3 +96,107 @@ typedef volatile struct MNTZZ9KCXRegs {
u16 video_control_op; // 04
u16 videocap_mode; // 06
} MNTZZ9KCXRegs;

enum zz_reg_offsets {
REG_FW_VERSION = 0x00,
REG_ZZ_MODE = 0x02,
REG_ZZ_CONFIG = 0x04,
REG_ZZ_SPRITE_X = 0x06,
REG_ZZ_SPRITE_Y = 0x08,
REG_ZZ_PAN_HI = 0x0A,
REG_ZZ_PAN_LO = 0x0C,
REG_ZZ_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