diff --git a/Platform/C64/src/2d.asm b/Platform/C64/src/2d.asm index ab01d3f1..d7e9fbe1 100644 --- a/Platform/C64/src/2d.asm +++ b/Platform/C64/src/2d.asm @@ -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 \ No newline at end of file diff --git a/Platform/C64/src/binary/fonts.PRG b/Platform/C64/src/binary/fonts.map similarity index 93% rename from Platform/C64/src/binary/fonts.PRG rename to Platform/C64/src/binary/fonts.map index 593f8b45..4efc0ad4 100644 Binary files a/Platform/C64/src/binary/fonts.PRG and b/Platform/C64/src/binary/fonts.map differ diff --git a/Platform/C64/src/binary/map.asm b/Platform/C64/src/binary/map.asm index 313763ef..e4503f8c 100644 --- a/Platform/C64/src/binary/map.asm +++ b/Platform/C64/src/binary/map.asm @@ -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 + diff --git a/Platform/C64/src/includes/drawText.asm b/Platform/C64/src/includes/drawText.asm index c8ab86b4..3201bf54 100644 --- a/Platform/C64/src/includes/drawText.asm +++ b/Platform/C64/src/includes/drawText.asm @@ -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 diff --git a/Platform/C64/src/includes/searchText.asm b/Platform/C64/src/includes/searchText.asm index 4393ee40..890981e9 100644 --- a/Platform/C64/src/includes/searchText.asm +++ b/Platform/C64/src/includes/searchText.asm @@ -2,7 +2,7 @@ searchText ;Clear old text - ldy #15 + ldy #16 lda #0 - .for step=0, step<=15, step=step+1 diff --git a/Platform/C64/src/includes/tables/textTables.asm b/Platform/C64/src/includes/tables/textTables.asm index 868f61c4..1f0c4777 100644 --- a/Platform/C64/src/includes/tables/textTables.asm +++ b/Platform/C64/src/includes/tables/textTables.asm @@ -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 diff --git a/Platform/C64/src/texts/text01.asm b/Platform/C64/src/texts/text01.asm new file mode 100644 index 00000000..302400f6 --- /dev/null +++ b/Platform/C64/src/texts/text01.asm @@ -0,0 +1 @@ +A subtle breeze stirs dust across the dry desert floor. diff --git a/Platform/C64/src/texts/text02.asm b/Platform/C64/src/texts/text02.asm new file mode 100644 index 00000000..2120e4ec --- /dev/null +++ b/Platform/C64/src/texts/text02.asm @@ -0,0 +1 @@ +The wooden bridge rattles from the rush of water just below.