C64: 2d proof of concept demo - text displaying functionality, converting to ASCII

This commit is contained in:
BagoZonde 2016-01-14 00:57:19 +00:00
parent db1e6c3a6c
commit f545d733d3
8 changed files with 128 additions and 19 deletions

View File

@ -51,6 +51,10 @@ mapOffsetPointer_HI = $34
playerPosition_LO = $35
playerPosition_HI = $36
outputCursor = $37
wordCursor = $38
ignoreNextCharacterFlag = $39
BANK_START_ADDR=$4000 ;$4000 - $7FFF
SCREEN=$6000 ;Bitmap range: $6000 - $7F3F
SCREEN_VIDEO_RAM=$5C00 ;Screen Video RAM range: $5C00 - $5FFF
@ -283,7 +287,8 @@ jmp *
.binary "binary/colormem.PRG",2,64*4
*=FONTS
.binary "binary/fonts.PRG",2,8*26+8*26+8*3
.binary "binary/fonts.map",0,8*8*130
*=MAP_DATA
;.binary "binary/map.bin" ;TODO: As we have no map file yet, let's use fake map for test purposes
@ -296,3 +301,4 @@ Raster_Indicator
.byte 0
Raster_Indicator_Key_Pressed
.byte 0
.byte $FF

View File

@ -44,12 +44,10 @@ TEXT_POINTERS ;(LO/HI)
TEXTS
text1
.byte 26, 54, 18, 20, 1, 19, 11, 4, 54, 1, 17, 4, 4, 25, 4, 54
.byte 18, 19, 8, 17, 18, 54, 3, 20, 18, 19, 54, 54, 54, 54, 54, 54
.byte 0, 2, 17, 14, 18, 18, 54, 19, 7, 4, 54, 3, 17, 24, 54, 54
.byte 3, 4, 18, 4, 17, 19, 54, 5, 11, 14, 14, 17, 52
.binary "../texts/text01.asm"
.byte $FF
text2
.byte 26, 54, 2, 7, 4, 18, 19, 52
.binary "../texts/text02.asm"
.byte $FF

View File

@ -1,21 +1,100 @@
drawText
stx textPointer+1
sty textPointer+2
stx preTextPointer+1
sty preTextPointer+2
lda #$FF
sta textCursor
sta outputCursor
ldx #0 ;x is for pre-drawing calculation if each word will fit in currently drawn line
stx ignoreNextCharacterFlag
;Check if the next word fits in current line
preDrawTextInit
stx wordCursor
drawTextLoop
preDrawTextLoop
ldy textCursor
preDrawTextLoop2
iny
inx
jsr preTextPointer
cmp #$FF
bne +
jmp drawWord
+
cmp #$20
bne +
jmp drawWord
+
cmp #13 ;ignore this character as this is the part of breakline: chr(13) and chr(10)
bne +
dex
jmp preDrawTextLoop2
+
cmp #10
bne +
ldx #0
jmp drawWord
+
cpx #16
bcc ++ ;skip if word fits in line
ldx #0
stx wordCursor
;Check if next character is the space character so we don't need then to break the line
iny
jsr preTextPointer
cmp #$20
beq +
jsr breakLine
jmp drawWord
+
inc ignoreNextCharacterFlag
jmp drawWord
+
jmp preDrawTextLoop2
drawWord
ldx wordCursor
drawWordLoop
inc outputCursor
drawWordLoop2
inc textCursor
inx
ldy textCursor
textPointer
lda $1234,y
cmp #$FF
cmp #$FF ;end of text
beq drawTextDone
cmp #13 ;ignore this character as this is the part of breakline: chr(13) and chr(10)
bne +
jmp drawWordLoop2
+
cmp #10 ;next line
bne +
jsr eatNextCharacter
ldx #0
jsr breakLine
jmp preDrawTextInit
+
cmp #$20
bne +
jsr eatNextCharacter
jmp preDrawTextInit
+
sta letter+1
ldy textCursor
ldy outputCursor
lda textPortTable_LO,y
sta textPortPointer+1
@ -38,8 +117,8 @@ letter
ldy #8
-
;Switch colour on for this letter
lda #1
;Switch colour on for this letter
lda #1
textPortColor
sta $1234
@ -49,11 +128,35 @@ textPortPointer
sta $1234,y
dey
bne -
jmp drawWordLoop
jmp drawTextLoop
drawTextDone
preTextPointer
lda $1234,y
rts
breakLine
clc
lda outputCursor
lsr
lsr
lsr
lsr
asl
asl
asl
asl
adc #15
sta outputCursor
rts
eatNextCharacter
lda ignoreNextCharacterFlag
beq +
dec outputCursor
dec ignoreNextCharacterFlag
+
rts
drawTextDone
rts

View File

@ -2,7 +2,7 @@
searchText
;Clear old text
ldy #15
ldy #16
lda #0
-
.for step=0, step<=15, step=step+1

View File

@ -1,10 +1,10 @@
fontsTable_LO
.for l=0, l<=60, l=l+1
.for l=0, l<=130, l=l+1
.byte <FONTS+l*8-1
.next
fontsTable_HI
.for l=0, l<=60, l=l+1
.for l=0, l<=130, l=l+1
.byte >FONTS+l*8-1
.next

View File

@ -0,0 +1 @@
A subtle breeze stirs dust across the dry desert floor.

View File

@ -0,0 +1 @@
The wooden bridge rattles from the rush of water just below.