refactor WGClearScreen

This commit is contained in:
4am 2018-03-02 14:20:17 -05:00
parent 6a8b8652d9
commit 3c9aee9d6b
2 changed files with 34 additions and 57 deletions

View File

@ -7,80 +7,57 @@
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGClearScreen
; Clears the text screen (assumes 80 cols)
; Side effects: Clobbers BASL,BASH
;
WGClearScreen:
SAVE_AXY
SETSWITCH PAGE2OFF
ldx #23
WGClearScreen_lineLoop:
lda TEXTLINES_L,x ; Compute video memory address of line
sta BASL
lda TEXTLINES_H,x
sta BASH
ldy #39
lda #' ' + $80
WGClearScreen_charLoop:
sta (BASL),y
SETSWITCH PAGE2ON
sta (BASL),y
SETSWITCH PAGE2OFF
dey
bpl WGClearScreen_charLoop
dex
bpl WGClearScreen_lineLoop
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGDesktop ; WGDesktop
; Paints the desktop pattern (assumes 80 cols) ; Paints the desktop pattern (assumes 80 cols)
; ;
WGDesktop: WGDesktop:
pha
lda #'W'
sta WGClearScreen_charPage1+1
lda #'V'
bra WGClearScreen_common
SAVE_AXY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGClearScreen
; Clears the text screen (assumes 80 cols)
;
WGClearScreen:
pha
lda #' ' + $80
sta WGClearScreen_charPage1+1
WGClearScreen_common:
sta WGClearScreen_charPage2+1
SAVE_XY
SETSWITCH PAGE2OFF SETSWITCH PAGE2OFF
ldx #23 ldx #23
WGClearScreen_lineLoop:
WGDesktop_lineLoop: lda TEXTLINES_L,x ; Compute video memory address of line
lda TEXTLINES_L,x ; Compute video memory address of line sta WGClearScreen_charLoop1+1
sta WGDesktop_charLoop+1 sta WGClearScreen_charLoop2+1
sta WGDesktop_charLoop2+1 lda TEXTLINES_H,x
lda TEXTLINES_H,x sta WGClearScreen_charLoop1+2
sta WGDesktop_charLoop+2 sta WGClearScreen_charLoop2+2
sta WGDesktop_charLoop2+2
ldy #39 ldy #39
lda #'W' WGClearScreen_charPage1:
WGDesktop_charLoop: lda #$FF ; Self-modifying code!
WGClearScreen_charLoop1:
sta $FFFF,y ; Self-modifying code! sta $FFFF,y ; Self-modifying code!
dey dey
bpl WGDesktop_charLoop bpl WGClearScreen_charLoop1
SETSWITCH PAGE2ON SETSWITCH PAGE2ON
ldy #39 ldy #39
lda #'V' WGClearScreen_charPage2:
WGDesktop_charLoop2: lda #$FF ; Self-modifying code!
WGClearScreen_charLoop2:
sta $FFFF,y ; Self-modifying code! sta $FFFF,y ; Self-modifying code!
dey dey
bpl WGDesktop_charLoop2 bpl WGClearScreen_charLoop2
SETSWITCH PAGE2OFF SETSWITCH PAGE2OFF
dex dex
bpl WGDesktop_lineLoop bpl WGClearScreen_lineLoop
RESTORE_XY
RESTORE_AXY pla
rts rts

Binary file not shown.