diff --git a/doc/funcref.sgml b/doc/funcref.sgml
index 3e74b2785..14113cbab 100644
--- a/doc/funcref.sgml
+++ b/doc/funcref.sgml
@@ -437,7 +437,7 @@ function.
-
+
(incomplete)
diff --git a/doc/nes.sgml b/doc/nes.sgml
index 98c25b6af..8f4374e05 100644
--- a/doc/nes.sgml
+++ b/doc/nes.sgml
@@ -69,8 +69,8 @@ Programs containing NES specific code may use the NES specific functions
-- waitvblank - wait until the start of vblank
-
- get_tv
+
- waitvsync - wait until the start of the next frame
+- get_tv
diff --git a/doc/pce.sgml b/doc/pce.sgml
index 104dee526..927df8f5c 100644
--- a/doc/pce.sgml
+++ b/doc/pce.sgml
@@ -77,7 +77,7 @@ Programs containing PCE specific code may use the PCE specific functions
-- waitvblank
+- waitvsync
- get_tv (since all PCE systems are NTSC, this always returns TV_NTSC)
diff --git a/doc/supervision.sgml b/doc/supervision.sgml
index 97495dea5..cf2af7967 100644
--- a/doc/supervision.sgml
+++ b/doc/supervision.sgml
@@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the Supervision specific functions
-- waitvblank
+
- waitvsync
diff --git a/include/cbm.h b/include/cbm.h
index 241d70a6e..226a09793 100644
--- a/include/cbm.h
+++ b/include/cbm.h
@@ -153,7 +153,10 @@ struct cbm_dirent {
unsigned char get_tv (void);
/* Return the video mode the machine is using. */
-
+#if !defined(__CBM610__) && !defined(__PET__)
+void waitvsync (void);
+/* wait for the start of the next frame */
+#endif
/*****************************************************************************/
/* CBM kernal functions */
diff --git a/include/gamate.h b/include/gamate.h
index 82bca08b1..96c70c9bc 100644
--- a/include/gamate.h
+++ b/include/gamate.h
@@ -188,8 +188,8 @@ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
#define JOY_START 6
#define JOY_SELECT 7
-void waitvblank (void);
-/* Wait for the vertical blanking */
+void waitvsync (void);
+/* Wait for start of next frame */
/* NOTE: all Gamate are "NTSC" */
#define get_tv() TV_NTSC
diff --git a/include/nes.h b/include/nes.h
index a472a0f3c..95e2fe93b 100644
--- a/include/nes.h
+++ b/include/nes.h
@@ -163,8 +163,8 @@ extern void nes_64_56_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
-void waitvblank (void);
-/* Wait for the vertical blanking */
+void waitvsync (void);
+/* Wait for start of the next frame */
unsigned char get_tv (void);
/* Return the video mode the machine is using. */
diff --git a/include/pce.h b/include/pce.h
index 7700654c8..856a2fa1d 100644
--- a/include/pce.h
+++ b/include/pce.h
@@ -83,8 +83,8 @@ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
#define JOY_SELECT 6
#define JOY_RUN 7
-void waitvblank (void);
-/* Wait for the vertical blanking */
+void waitvsync (void);
+/* Wait for start of the next frame */
/* NOTE: all PCE are NTSC */
#define get_tv() TV_NTSC
diff --git a/libsrc/c128/waitvsync.s b/libsrc/c128/waitvsync.s
new file mode 100644
index 000000000..e4bbbf7c9
--- /dev/null
+++ b/libsrc/c128/waitvsync.s
@@ -0,0 +1,30 @@
+;
+; Written by Groepaz
+;
+; void waitvsync (void);
+;
+
+ .export _waitvsync
+
+ .include "c128.inc"
+
+_waitvsync:
+
+ bit MODE
+ bmi @c80
+
+@l1:
+ bit VIC_CTRL1
+ bpl @l1
+@l2:
+ bit VIC_CTRL1
+ bmi @l2
+ rts
+
+@c80:
+ ;FIXME: do we have to switch banks?
+@l3:
+ lda VDC_INDEX
+ and #$20
+ beq @l3
+ rts
diff --git a/libsrc/c64/waitvsync.s b/libsrc/c64/waitvsync.s
new file mode 100644
index 000000000..a4bf13080
--- /dev/null
+++ b/libsrc/c64/waitvsync.s
@@ -0,0 +1,18 @@
+;
+; Written by Groepaz
+;
+; void waitvsync (void);
+;
+
+ .export _waitvsync
+
+ .include "c64.inc"
+
+_waitvsync:
+@l1:
+ bit VIC_CTRL1
+ bpl @l1
+@l2:
+ bit VIC_CTRL1
+ bmi @l2
+ rts
diff --git a/libsrc/cbm510/waitvsync.s b/libsrc/cbm510/waitvsync.s
new file mode 100644
index 000000000..ed7300f7c
--- /dev/null
+++ b/libsrc/cbm510/waitvsync.s
@@ -0,0 +1,28 @@
+;
+; Written by Groepaz
+;
+; void waitvsync (void);
+;
+
+ .export _waitvsync
+ .import PALFLAG
+ .import sys_bank, restore_bank
+
+ .importzp vic
+
+ .include "cbm510.inc"
+
+_waitvsync:
+ jsr sys_bank ; Switch to the system bank
+ sei
+
+ ldy #VIC_CTRL1
+@l1:
+ lda (vic),y
+ bpl @l1
+@l2:
+ lda (vic),y
+ bmi @l2
+
+ cli
+ jmp restore_bank
diff --git a/libsrc/gamate/waitvblank.s b/libsrc/gamate/waitvsync.s
similarity index 67%
rename from libsrc/gamate/waitvblank.s
rename to libsrc/gamate/waitvsync.s
index 66686c08a..dee83400d 100644
--- a/libsrc/gamate/waitvblank.s
+++ b/libsrc/gamate/waitvsync.s
@@ -1,16 +1,18 @@
;
-; void waitvblank (void);
+; Written by Groepaz
+;
+; void waitvsync (void);
;
.include "gamate.inc"
.include "extzp.inc"
.forceimport ticktock
- .export _waitvblank
+ .export _waitvsync
; FIXME: is this actually correct?
-.proc _waitvblank
+.proc _waitvsync
lda tickcount
@lp: cmp tickcount
diff --git a/libsrc/nes/waitvblank.s b/libsrc/nes/waitvsync.s
similarity index 56%
rename from libsrc/nes/waitvblank.s
rename to libsrc/nes/waitvsync.s
index 408646904..4bdf9a9d0 100644
--- a/libsrc/nes/waitvblank.s
+++ b/libsrc/nes/waitvsync.s
@@ -1,15 +1,15 @@
;
-; Written by Groepaz/Hitmen
+; Written by Groepaz
; Cleanup by Ullrich von Bassewitz
;
-; void waitvblank(void);
+; void waitvsync(void);
;
- .export _waitvblank
+ .export _waitvsync
.include "nes.inc"
-.proc _waitvblank
+.proc _waitvsync
wait: lda PPU_STATUS
bpl wait
diff --git a/libsrc/pce/waitvblank.s b/libsrc/pce/waitvsync.s
similarity index 63%
rename from libsrc/pce/waitvblank.s
rename to libsrc/pce/waitvsync.s
index b9f0f902f..c6435dabd 100644
--- a/libsrc/pce/waitvblank.s
+++ b/libsrc/pce/waitvsync.s
@@ -1,14 +1,16 @@
;
-; void waitvblank (void);
+; Written by Groepaz
+;
+; void waitvsync (void);
;
.include "pce.inc"
.include "extzp.inc"
.forceimport ticktock
- .export _waitvblank
+ .export _waitvsync
-.proc _waitvblank
+.proc _waitvsync
lda tickcount
@lp: cmp tickcount
diff --git a/libsrc/plus4/waitvsync.s b/libsrc/plus4/waitvsync.s
new file mode 100644
index 000000000..32b81b52b
--- /dev/null
+++ b/libsrc/plus4/waitvsync.s
@@ -0,0 +1,17 @@
+;
+; Written by Groepaz
+;
+; void waitvsync (void);
+;
+
+ .export _waitvsync
+
+ .include "plus4.inc"
+
+_waitvsync:
+@l1:
+ lda TED_VLINEHI
+ and #$01
+ ora TED_VLINELO
+ bne @l1
+ rts
diff --git a/libsrc/vic20/waitvsync.s b/libsrc/vic20/waitvsync.s
new file mode 100644
index 000000000..1c76f2497
--- /dev/null
+++ b/libsrc/vic20/waitvsync.s
@@ -0,0 +1,16 @@
+;
+; Written by Groepaz
+;
+; void waitvsync (void);
+;
+
+ .export _waitvsync
+
+ .include "vic20.inc"
+
+_waitvsync:
+@l2:
+ lda VIC_HLINE
+ bne @l2
+ rts
+
diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c
index fe977ec08..13188d1cd 100644
--- a/testcode/lib/conio.c
+++ b/testcode/lib/conio.c
@@ -117,8 +117,8 @@ void main(void)
gotoxy(7 + inpos,1);
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
- /* not all targets have waitvblank */
- waitvblank();
+ /* not all targets have waitvsync */
+ waitvsync();
/* for targets that do not have a keyboard, read the first
joystick */
joy = joy_read(JOY_1);
diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c
index dfebd9bef..793770cee 100644
--- a/testcode/lib/gamate/ctest.c
+++ b/testcode/lib/gamate/ctest.c
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
break;
}
- waitvblank();
+ waitvsync();
(*((unsigned char*)LCD_XPOS)) = x;
(*((unsigned char*)LCD_YPOS)) = y;
diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c
index a4bd63b15..00ae3c157 100644
--- a/testcode/lib/pce/conio.c
+++ b/testcode/lib/pce/conio.c
@@ -123,7 +123,7 @@ void main(void)
p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
}
- waitvblank();
+ waitvsync();
++n;
}
}