This section
is all about displaying PETSCII/Text characters on to the screen. Well,
before we move on to the next part of putting text/characters from
screen data memory on to the screen RAM, we shall do a simple little
HELLO WORLD program. Alright, so this is nothing special, but it will
introduce you to a command, often used in turbo assembler called .TEXT.
This is useful for those of you who want to write text, without
designing a screen using any specific hardware or software, i.e. Action
Replay cartridge, Screen Editor, etc. We are using default BANK #3, to
display our screen characters. So the character store range will be
from $0400-$07E7. Where $0400 will be the very first char on screen,
and $07E7 will be the last char on screen.
An example of the HELLO WORLD program.
;======================================
;
HELLO WORLD - ASSEMBLY VERSION
;======================================


How can we display text or characters on the screen? Easy, we use loops, but we need to use screen RAM, which is located in different memory banks. We shall stick to the normal C64 display bank ($0400 - $07E7), so that then we can display some text.
For a start off, let us try and something, which is located at $4000 and then pastes it through the whole of the screen area. Remember, this is only an experiment. There are different methods, but we'll use a simple method on displaying a screen, that is located at $4000.
;================================
;DISPLAYING
TEXT AT BANK
#$03
;================================
;SET UP PERAMETERS
SCREENLOC1 =
$4000
SCREENLOC2
= $4100
SCREENLOC3
= $4200
SCREENLOC4
= $42E8
SCREENPOS1 =
$0400
SCREENPOS2
= $0500
SCREENPOS3
= $0600
SCREENPOS4
= $06E8
* = $0900
SEI
LDX
#$00
;X=0
DISPLAY
LDA
SCREENLOC1,X
;READ
FROM SCREENLOC1 'X' TIMES
STA
SCREENPOS1,X
;PASTE TO SCREENPOS1 'X' TIMES
LDA SCREENLOC2,X ;READ
FROM SCREENLOC2 'X' TIMES
STA
SCREENPOS2,X
;PASTE TO SCREENPOS2 'X' TIMES
LDA SCREENLOC3,X ;READ
FROM SCREENLOC3 'X' TIMES
STA
SCREENPOS3,X
;PASTE TO SCREENPOS3 'X' TIMES
LDA SCREENLOC4,X ;READ
FROM SCREENLOC4 'X' TIMES
STA
SCREENPOS4,X
;PASTE TO SCREENPOS4 'X' TIMES
INX
; X=X+1 UNTIL X = $FF (256)
BNE
DISPLAY
;IF X <> $FF THEN GOTO DISPLAY
RTS
;END PROGRAM
Compared to using BASIC, this routine is smaller and more compact to display text.
Now that you know how to display the screens, we want to display colours for the text. And here is how we can do this:
The colour RAM is always between $D800 and $DBE7. Therefore, variables can be created for the colours. So create some new variables, which are as follows:
COLOURPOS1
=
$D800
COLOURPOS2
= $D900
COLOURPOS3
= $DA00
COLOURPOS4
= $DAE8
Then inside
your
loop
(underneath STA SCREENPOS4,X) enter the following:
LDA #$0A
STA COLOURPOS1,X
STA COLOURPOS2,X
STA COLOURPOS3,X
STA COLOURPOS4,X
You don't just get the screen displaying only text, but you get the text to display painted in pink ;o)
Why not play around with the colours. Here is a small table on which colour does what job :o)