added sys.waitrastborder() for c64

This commit is contained in:
Irmen de Jong 2021-04-01 18:53:16 +02:00
parent 129e17b33a
commit 3f30d3aa89
3 changed files with 33 additions and 0 deletions

View File

@ -502,6 +502,8 @@ sys {
; --- busy wait till the next vsync has occurred (approximately), without depending on custom irq handling. ; --- busy wait till the next vsync has occurred (approximately), without depending on custom irq handling.
; note: a more accurate way to wait for vsync is to set up a vsync irq handler instead. ; note: a more accurate way to wait for vsync is to set up a vsync irq handler instead.
%asm {{ %asm {{
- lda c64.RASTER
beq -
- lda c64.RASTER - lda c64.RASTER
bne - bne -
bit c64.SCROLY bit c64.SCROLY
@ -510,6 +512,15 @@ sys {
}} }}
} }
inline asmsub waitrastborder() {
; --- busy wait till the raster position has reached the bottom screen border (approximately)
; note: a more accurate way to do this is by using a raster irq handler instead.
%asm {{
- bit c64.SCROLY
bpl -
}}
}
asmsub memcopy(uword source @R0, uword target @R1, uword count @AY) clobbers(A,X,Y) { asmsub memcopy(uword source @R0, uword target @R1, uword count @AY) clobbers(A,X,Y) {
%asm {{ %asm {{
ldx cx16.r0 ldx cx16.r0

View File

@ -105,9 +105,15 @@ sys (part of syslib)
``waitvsync()`` ``waitvsync()``
busy wait till the next vsync has occurred (approximately), without depending on custom irq handling. busy wait till the next vsync has occurred (approximately), without depending on custom irq handling.
can be used to avoid screen flicker/tearing when updating screen contents.
note: a more accurate way to wait for vsync is to set up a vsync irq handler instead. note: a more accurate way to wait for vsync is to set up a vsync irq handler instead.
note for cx16: the system irq handler has to be active for this to work (this is not required on c64) note for cx16: the system irq handler has to be active for this to work (this is not required on c64)
``waitrastborder()`` (c64 target only)
busy wait till the raster position has reached the bottom screen border (approximately)
can be used to avoid screen flicker/tearing when updating screen contents.
note: a more accurate way to do this is by using a raster irq handler instead.
``reset_system()`` ``reset_system()``
Soft-reset the system back to initial power-on Basic prompt. Soft-reset the system back to initial power-on Basic prompt.
(called automatically by Prog8 when the main subroutine returns and the program is not using basicsafe zeropage option) (called automatically by Prog8 when the main subroutine returns and the program is not using basicsafe zeropage option)

View File

@ -1,10 +1,26 @@
%import textio %import textio
%zeropage basicsafe %zeropage basicsafe
%option no_sysinit
main { main {
sub start() { sub start() {
ubyte color=0
ubyte xx
uword ptr = $0400
@($02) = 0
repeat {
sys.waitvsync()
%asm {{
ldy $02
lda #'*'
sta $0400,y
inc $02
}}
}
txt.print("hello") txt.print("hello")
; str filename = "titlescreen.bin" ; str filename = "titlescreen.bin"