How do you clear the screen in machine language?
Posted: Thu Mar 28, 2019 6:56 pm
How do you clear the screen in machine language? I'm trying to make my first VIC-20 demo in CBM prg Studio.
The Commodore Vic 20 Forum
http://www.sleepingelephant.com/ipw-web/bulletin/bb/
http://www.sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?t=9301
Code: Select all
Do_ClearScreenRam
ldy #0
lda #$20
ClearScreenRamLoop
sta $1e00,y
sta $1f00,y
iny
bne ClearScreenRamLoop
rts
Code: Select all
*=$1001
byte $0B,$10,$DC,$07
byte $9E,$34,$31,$30,$39
byte $00,$00,$00
jmp Main
;-----------------------------------
; VIC 20 Color Defines
;-----------------------------------
Black = 0
White = 1
Red = 2
Cyan = 3
Purple = 4
Green = 5
Blue = 6
Yellow = 7
Orange = 8
LightOrange = 9
Pink = 10
LightCyan = 11
LightPurple = 12
LightGreen = 13
LightBlue = 14
LightYellow = 15
;-----------------------------------
; Defines
;-----------------------------------
ScreenRam = $1e00
GridCharacter = $00
BlankCharacter = $20
;-----------------------------------
; Variables
;-----------------------------------
Pointer = $00
Main
jsr Do_ClearScreenRam
jsr Do_DrawGridToScreenRam
LoopForever
jmp LoopForever
;-----------------------------------
;
;-----------------------------------
Do_ClearScreenRam
ldy #0
lda #BlankCharacter
ClearScreenRamLoop
sta ScreenRam+0,y
sta ScreenRam+256,y
iny
bne ClearScreenRamLoop
rts
;-----------------------------------
; Draw And Color Grid
;-----------------------------------
Do_DrawGridToScreenRam
lda #>ScreenRam
sta Pointer+1
lda #<ScreenRam+44
sta Pointer+0
ldx #18 ;ScreenRows
DrawNextRowLoop
ldy #20 ;ScreenColumns
DrawNextColumnLoop
lda #GridCharacter
sta (Pointer),y
lda Pointer+1
pha
clc
adc #$78
sta Pointer+1
ColorNextColumn
lda #Red
sta (Pointer),y
pla
sta Pointer+1
dey
bne DrawNextColumnLoop
lda Pointer+0
clc
adc #22
sta Pointer+0
lda Pointer+1
adc #0
sta Pointer+1
dex
bne DrawNextRowLoop
rts
Even some of the most picky assembly folks on denial use the kernal routines as a convenient library of commands. It is good to know what the routine does, however. That said, once you do there is no reason not to use kernal routines unless you have/need a much faster/custom routine. I've heard even expert demo scene guys like Michael Steil say they use the floating point stuff built in because its fast and already there.OmegaMax wrote:Might be a good idea to clear the screen memory with your own code instead of using the kernal,if your going to program the VIC in assembly,starting with small routines/code is a good idea.
The KERNAL routines are often useful, unfortunately the screen code has 22x23 hardcoded so if you are using a different size you have to end up writing your own.Forbidden64 wrote:Even some of the most picky assembly folks on denial use the kernal routines as a convenient library of commands. It is good to know what the routine does, however. That said, once you do there is no reason not to use kernal routines unless you have/need a much faster/custom routine. I've heard even expert demo scene guys like Michael Steil say they use the floating point stuff built in because its fast and already there.