From 26787ba3800f87a889ab937fb081203f7c8d71ed Mon Sep 17 00:00:00 2001 From: Karri Kaksonen Date: Tue, 19 Apr 2022 20:01:47 +0300 Subject: [PATCH] Fix race condition --- libsrc/atari7800/clrscr.s | 22 +++++----------------- libsrc/atari7800/conio.s | 6 +++--- libsrc/atari7800/conio_font.s | 4 ++-- libsrc/atari7800/mono_clrscr.s | 22 +++++----------------- libsrc/atari7800/mono_setcursor.s | 10 ++++++++-- libsrc/atari7800/setcursor.s | 7 ++++++- 6 files changed, 29 insertions(+), 42 deletions(-) diff --git a/libsrc/atari7800/clrscr.s b/libsrc/atari7800/clrscr.s index 7ce690af4..f9d4938b0 100644 --- a/libsrc/atari7800/clrscr.s +++ b/libsrc/atari7800/clrscr.s @@ -4,7 +4,7 @@ .export _clrscr .import _screen - .import pusha0,pushax + .import pushax, __bzero .include "extzp.inc" .code @@ -13,22 +13,10 @@ lda #<_screen ldx #>_screen - sta ptr7800 - stx ptr7800+1 - ldx #screenrows -@L1: ldy #charsperline - lda #0 -@L2: sta (ptr7800),y - dey - bne @L2 - lda ptr7800 - clc - adc #charsperline - bcc @L3 - inc ptr7800+1 -@L3: dex - bne @L1 - rts + jsr pushax + ldx #>(charsperline * screenrows) + lda #<(charsperline * screenrows) + jmp __bzero .endproc diff --git a/libsrc/atari7800/conio.s b/libsrc/atari7800/conio.s index 1240c2e5d..92cc7d8b1 100644 --- a/libsrc/atari7800/conio.s +++ b/libsrc/atari7800/conio.s @@ -9,7 +9,7 @@ .constructor initconio .include "atari7800.inc" .include "extzp.inc" - .import _font + .import _conio_font .import _get_tv .export _screen .export _zones @@ -58,7 +58,7 @@ _screen: ; Cursor .byte 254 .byte 0 - .byte >_font + .byte >_conio_font .byte 0 .endmacro @@ -206,7 +206,7 @@ vblankon: vblankoff: lda MSTAT bpl vblankoff - lda #>_font + lda #>_conio_font sta CHBASE lda #(CTRL_MODE160 | CTRL_KANGOFF | CTRL_BCBLACK | CTRL_CHAR2B | CTRL_DMAON | CTRL_CKOFF) sta CTRL diff --git a/libsrc/atari7800/conio_font.s b/libsrc/atari7800/conio_font.s index 07be43c4d..829e3e2ce 100644 --- a/libsrc/atari7800/conio_font.s +++ b/libsrc/atari7800/conio_font.s @@ -16,10 +16,10 @@ ; 0, 2, 4, 6, ... 254 ; Odd indices cannot be used. - .export _font + .export _conio_font .rodata .align 256 -_font: +_conio_font: .byte $0, $0, $41, $41, $0, $0, $14, $0 .byte $0, $0, $0, $0, $1, $40, $0, $0 .byte $0, $0, $0, $0, $0, $0, $0, $0 diff --git a/libsrc/atari7800/mono_clrscr.s b/libsrc/atari7800/mono_clrscr.s index a700aadc1..19f1fdfd6 100644 --- a/libsrc/atari7800/mono_clrscr.s +++ b/libsrc/atari7800/mono_clrscr.s @@ -4,7 +4,7 @@ .export _mono_clrscr .import _mono_screen - .import pusha0,pushax + .import pushax, __bzero .include "extzp.inc" .code @@ -13,22 +13,10 @@ lda #<_mono_screen ldx #>_mono_screen - sta ptr7800 - stx ptr7800+1 - ldx #screenrows -@L1: ldy #mono_charsperline - lda #0 -@L2: sta (ptr7800),y - dey - bne @L2 - lda ptr7800 - clc - adc #mono_charsperline - bcc @L3 - inc ptr7800+1 -@L3: dex - bne @L1 - rts + jsr pushax + ldx #>(mono_charsperline * screenrows) + lda #<(mono_charsperline * screenrows) + jmp __bzero .endproc diff --git a/libsrc/atari7800/mono_setcursor.s b/libsrc/atari7800/mono_setcursor.s index 42f9bf466..06d1f10d8 100644 --- a/libsrc/atari7800/mono_setcursor.s +++ b/libsrc/atari7800/mono_setcursor.s @@ -42,7 +42,7 @@ ; blink_time: - .byte 140 + .byte 255 .code @@ -175,6 +175,9 @@ umula0: ; Offset to cursor zone 5. ; .proc mono_blink_cursor + lda blink_time + cmp #255 + beq @L3 inc blink_time bne @L3 lda #140 @@ -197,7 +200,10 @@ umula0: .segment "ONCE" mono_init_cursor: lda #0 - jmp calccursorzone + jsr calccursorzone + lda #0 + sta blink_time + rts ;----------------------------------------------------------------------------- diff --git a/libsrc/atari7800/setcursor.s b/libsrc/atari7800/setcursor.s index d94eb8094..9ccc20ab6 100644 --- a/libsrc/atari7800/setcursor.s +++ b/libsrc/atari7800/setcursor.s @@ -42,7 +42,7 @@ ; blink_time: - .byte 140 + .byte 255 .code @@ -177,6 +177,9 @@ umula0: ; Offset to cursor zone 5. ; .proc blink_cursor + lda blink_time + cmp #255 + beq @L3 inc blink_time bne @L3 lda #140 @@ -199,6 +202,8 @@ umula0: init_cursor: lda #0 jsr calccursorzone + lda #0 + sta blink_time rts ;-----------------------------------------------------------------------------