|
| 1 | +#importonce |
| 2 | +.segmentdef Vdc [start=$1c01] |
| 3 | +.segment Vdc |
| 4 | + |
| 5 | +c128lib_BasicUpstart128($1c10) |
| 6 | + |
| 7 | +.namespace Vdc { |
| 8 | +* = $1c10 "Entry" |
| 9 | +Entry: { |
| 10 | +// Clean screen |
| 11 | + jsr c128lib.Kernal.CINT |
| 12 | + |
| 13 | + c128lib_Go80() |
| 14 | + |
| 15 | +// Set cursor on (0, 2) |
| 16 | + clc |
| 17 | + ldx #2 |
| 18 | + ldy #0 |
| 19 | + jsr c128lib.Kernal.PLOT |
| 20 | + |
| 21 | +// Print string at current cursor position |
| 22 | + ldx #0 |
| 23 | + !: |
| 24 | + lda SampleString, x |
| 25 | + jsr c128lib.Kernal.BSOUT |
| 26 | + inx |
| 27 | + cpx #SampleStringLength |
| 28 | + bne !- |
| 29 | + |
| 30 | + IsReturnPressedAndReleased() |
| 31 | + |
| 32 | + c128lib_SetBackgroundForegroundColor(c128lib.Vdc.VDC_DARK_CYAN, c128lib.Vdc.VDC_LIGHT_CYAN); |
| 33 | + |
| 34 | +// Set cursor on (0, 5) |
| 35 | + clc |
| 36 | + ldx #5 |
| 37 | + ldy #0 |
| 38 | + jsr c128lib.Kernal.PLOT |
| 39 | + |
| 40 | +// Print string at current cursor position |
| 41 | + ldx #0 |
| 42 | + !: |
| 43 | + lda SampleString2, x |
| 44 | + jsr c128lib.Kernal.BSOUT |
| 45 | + inx |
| 46 | + cpx #SampleString2Length |
| 47 | + bne !- |
| 48 | + |
| 49 | + IsReturnPressedAndReleased() |
| 50 | + |
| 51 | + c128lib_SetBackgroundForegroundColor(c128lib.Vdc.VDC_DARK_RED, c128lib.Vdc.VDC_LIGHT_RED); |
| 52 | + |
| 53 | +// Set cursor on (0, 8) |
| 54 | + clc |
| 55 | + ldx #8 |
| 56 | + ldy #0 |
| 57 | + jsr c128lib.Kernal.PLOT |
| 58 | + |
| 59 | +// Print string at current cursor position |
| 60 | + ldx #0 |
| 61 | + !: |
| 62 | + lda SampleString3, x |
| 63 | + jsr c128lib.Kernal.BSOUT |
| 64 | + inx |
| 65 | + cpx #SampleString3Length |
| 66 | + bne !- |
| 67 | + |
| 68 | + IsReturnPressedAndReleased() |
| 69 | + |
| 70 | +// Now let the user choose his favourite color |
| 71 | + UserSelect: |
| 72 | + clc |
| 73 | + ldx #11 |
| 74 | + ldy #0 |
| 75 | + jsr c128lib.Kernal.PLOT |
| 76 | + |
| 77 | +// Print string at current cursor position |
| 78 | + ldx #0 |
| 79 | + !: |
| 80 | + lda ColorString, x |
| 81 | + jsr c128lib.Kernal.BSOUT |
| 82 | + inx |
| 83 | + cpx #ColorStringLength |
| 84 | + bne !- |
| 85 | + |
| 86 | + jsr c128lib.Kernal.GETIN |
| 87 | + cmp #48 |
| 88 | + bcc UserSelect // Lower than '0' |
| 89 | + cmp #71 |
| 90 | + bcs UserSelect // Greater than 'F' |
| 91 | + cmp #58 |
| 92 | + bcc IsNumber |
| 93 | + cmp #65 |
| 94 | + bcs IsLetter |
| 95 | + jmp UserSelect // If it's between ':' AND '-' restart |
| 96 | + |
| 97 | + IsNumber: |
| 98 | + and #%00001111 // Number, take the lower nibble |
| 99 | + jmp ChooseColor |
| 100 | + |
| 101 | + IsLetter: |
| 102 | + and #%00001111 // Letter, take the lower nibble |
| 103 | + clc |
| 104 | + adc #9 // Add 9 to convert to Hex |
| 105 | + |
| 106 | + ChooseColor: |
| 107 | + sta background // Background |
| 108 | + eor #$FF |
| 109 | + and #%00001111 |
| 110 | + sta foreground // Foreground is EOR(background) to make text readable |
| 111 | + c128lib_SetBackgroundForegroundColorWithVars(background, foreground) |
| 112 | + |
| 113 | + jmp UserSelect // Back to user selection |
| 114 | + |
| 115 | + background: .byte 0 |
| 116 | + foreground: .byte 0 |
| 117 | +} |
| 118 | + |
| 119 | +} |
| 120 | + |
| 121 | +ColorString: .text "SELECT COLOR (0 TO F): " |
| 122 | +.label ColorStringLength = 23; |
| 123 | + |
| 124 | +SampleString: .text "LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT. MAURIS MOLLIS NEC MI VEL COMMODO." |
| 125 | +.label SampleStringLength = 90; |
| 126 | + |
| 127 | +SampleString2: .text "UT EU LOREM URNA. PHASELLUS AC MAXIMUS LIBERO, VITAE FINIBUS NISL." |
| 128 | +.label SampleString2Length = 66; |
| 129 | + |
| 130 | +SampleString3: .text "DUIS QUIS TEMPOR TELLUS. VIVAMUS MATTIS VESTIBULUM TORTOR ELEIFEND GRAVIDA." |
| 131 | +.label SampleString3Length = 75; |
| 132 | + |
| 133 | +#import "keyboard-helper.asm" |
| 134 | + |
| 135 | +#import "./common/lib/common-global.asm" |
| 136 | +#import "./chipset/lib/vdc-global.asm" |
0 commit comments