forked from MightyPork/crsn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
353 lines
10 KiB
353 lines
10 KiB
(
|
|
; This is a demo of a bitmap font and string rendering using buffers.
|
|
; You can do this many ways.
|
|
|
|
(sc-init 800 250)
|
|
(sc-opt SCREEN_UPSCALE 5)
|
|
|
|
; Define a font. This should be less ugly once we have includes implemented...
|
|
(sym FONT g15)
|
|
(mkbf FONT (
|
|
0x0000000000000000 ; 0
|
|
0x7e81a581bd99817e ; 1
|
|
0x7effdbffc3e7ff7e ; 2
|
|
0x367f7f7f3e1c0800 ; 3
|
|
0x081c3e7f3e1c0800 ; 4
|
|
0x1c3e1c7f7f3e1c3e ; 5
|
|
0x08081c3e7f3e1c3e ; 6
|
|
0x0000183c3c180000 ; 7
|
|
0xffffe7c3c3e7ffff ; 8
|
|
0x003c664242663c00 ; 9
|
|
0xffc399bdbd99c3ff ; 10
|
|
0xf0e0f0be3333331e ; 11
|
|
0x3c6666663c187e18 ; 12
|
|
0xfcccfc0c0c0e0f07 ; 13
|
|
0xfec6fec6c6e66703 ; 14
|
|
0x995a3ce7e73c5a99 ; 15
|
|
0x01071f7f1f070100 ; 16
|
|
0x40707c7f7c704000 ; 17
|
|
0x183c7e18187e3c18 ; 18
|
|
0x6666666666006600 ; 19
|
|
0xfedbdbded8d8d800 ; 20
|
|
0x7cc61c36361c331e ; 21
|
|
0x000000007e7e7e00 ; 22
|
|
0x183c7e187e3c18ff ; 23
|
|
0x183c7e1818181800 ; 24
|
|
0x181818187e3c1800 ; 25
|
|
0x0018307f30180000 ; 26
|
|
0x000c067f060c0000 ; 27
|
|
0x00000303037f0000 ; 28
|
|
0x002466ff66240000 ; 29
|
|
0x00183c7effff0000 ; 30
|
|
0x00ffff7e3c180000 ; 31
|
|
0x0000000000000000 ; 32 ' '
|
|
0x0c1e1e0c0c000c00 ; 33 '!'
|
|
0x3636360000000000 ; 34 '"'
|
|
0x36367f367f363600 ; 35 '#'
|
|
0x0c3e031e301f0c00 ; 36 '$'
|
|
0x006333180c666300 ; 37 '%'
|
|
0x1c361c6e3b336e00 ; 38 '&'
|
|
0x0606030000000000 ; 39 '''
|
|
0x180c0606060c1800 ; 40 '('
|
|
0x060c1818180c0600 ; 41 ')'
|
|
0x00663cff3c660000 ; 42 '*'
|
|
0x000c0c3f0c0c0000 ; 43 '+'
|
|
0x00000000000c0c06 ; 44 ','
|
|
0x0000003f00000000 ; 45 '-'
|
|
0x00000000000c0c00 ; 46 '.'
|
|
0x6030180c06030100 ; 47 '/'
|
|
0x3e63737b6f673e00 ; 48 '0'
|
|
0x0c0e0c0c0c0c3f00 ; 49 '1'
|
|
0x1e33301c06333f00 ; 50 '2'
|
|
0x1e33301c30331e00 ; 51 '3'
|
|
0x383c36337f307800 ; 52 '4'
|
|
0x3f031f3030331e00 ; 53 '5'
|
|
0x1c06031f33331e00 ; 54 '6'
|
|
0x3f3330180c0c0c00 ; 55 '7'
|
|
0x1e33331e33331e00 ; 56 '8'
|
|
0x1e33333e30180e00 ; 57 '9'
|
|
0x000c0c00000c0c00 ; 58 ':'
|
|
0x000c0c00000c0c06 ; 59 ';'
|
|
0x180c0603060c1800 ; 60 '<'
|
|
0x00003f00003f0000 ; 61 '='
|
|
0x060c1830180c0600 ; 62 '>'
|
|
0x1e3330180c000c00 ; 63 '?'
|
|
0x3e637b7b7b031e00 ; 64 '@'
|
|
0x0c1e33333f333300 ; 65 'A'
|
|
0x3f66663e66663f00 ; 66 'B'
|
|
0x3c66030303663c00 ; 67 'C'
|
|
0x1f36666666361f00 ; 68 'D'
|
|
0x7f46161e16467f00 ; 69 'E'
|
|
0x7f46161e16060f00 ; 70 'F'
|
|
0x3c66030373667c00 ; 71 'G'
|
|
0x3333333f33333300 ; 72 'H'
|
|
0x1e0c0c0c0c0c1e00 ; 73 'I'
|
|
0x7830303033331e00 ; 74 'J'
|
|
0x6766361e36666700 ; 75 'K'
|
|
0x0f06060646667f00 ; 76 'L'
|
|
0x63777f7f6b636300 ; 77 'M'
|
|
0x63676f7b73636300 ; 78 'N'
|
|
0x1c36636363361c00 ; 79 'O'
|
|
0x3f66663e06060f00 ; 80 'P'
|
|
0x1e3333333b1e3800 ; 81 'Q'
|
|
0x3f66663e36666700 ; 82 'R'
|
|
0x1e33070e38331e00 ; 83 'S'
|
|
0x3f2d0c0c0c0c1e00 ; 84 'T'
|
|
0x3333333333333f00 ; 85 'U'
|
|
0x33333333331e0c00 ; 86 'V'
|
|
0x6363636b7f776300 ; 87 'W'
|
|
0x6363361c1c366300 ; 88 'X'
|
|
0x3333331e0c0c1e00 ; 89 'Y'
|
|
0x7f6331184c667f00 ; 90 'Z'
|
|
0x1e06060606061e00 ; 91 '['
|
|
0x03060c1830604000 ; 92 '\'
|
|
0x1e18181818181e00 ; 93 ']'
|
|
0x081c366300000000 ; 94 '^'
|
|
0x00000000000000ff ; 95 '_'
|
|
0x0c0c180000000000 ; 96 '`'
|
|
0x00001e303e336e00 ; 97 'a'
|
|
0x0706063e66663b00 ; 98 'b'
|
|
0x00001e3303331e00 ; 99 'c'
|
|
0x3830303e33336e00 ; 100 'd'
|
|
0x00001e333f031e00 ; 101 'e'
|
|
0x1c36060f06060f00 ; 102 'f'
|
|
0x00006e33333e301f ; 103 'g'
|
|
0x0706366e66666700 ; 104 'h'
|
|
0x0c000e0c0c0c1e00 ; 105 'i'
|
|
0x300030303033331e ; 106 'j'
|
|
0x070666361e366700 ; 107 'k'
|
|
0x0e0c0c0c0c0c1e00 ; 108 'l'
|
|
0x0000337f7f6b6300 ; 109 'm'
|
|
0x00001f3333333300 ; 110 'n'
|
|
0x00001e3333331e00 ; 111 'o'
|
|
0x00003b66663e060f ; 112 'p'
|
|
0x00006e33333e3078 ; 113 'q'
|
|
0x00003b6e66060f00 ; 114 'r'
|
|
0x00003e031e301f00 ; 115 's'
|
|
0x080c3e0c0c2c1800 ; 116 't'
|
|
0x0000333333336e00 ; 117 'u'
|
|
0x00003333331e0c00 ; 118 'v'
|
|
0x0000636b7f7f3600 ; 119 'w'
|
|
0x000063361c366300 ; 120 'x'
|
|
0x00003333333e301f ; 121 'y'
|
|
0x00003f190c263f00 ; 122 'z'
|
|
0x380c0c070c0c3800 ; 123 '{'
|
|
0x1818180018181800 ; 124 '|'
|
|
0x070c0c380c0c0700 ; 125 '}'
|
|
0x6e3b000000000000 ; 126 '~'
|
|
0x00081c3663637f00 ; 127
|
|
0x1e3303331e18301e ; 128
|
|
0x0033003333337e00 ; 129
|
|
0x38001e333f031e00 ; 130
|
|
0x7ec33c607c66fc00 ; 131
|
|
0x33001e303e337e00 ; 132
|
|
0x07001e303e337e00 ; 133
|
|
0x0c0c1e303e337e00 ; 134
|
|
0x00001e03031e301c ; 135
|
|
0x7ec33c667e063c00 ; 136
|
|
0x33001e333f031e00 ; 137
|
|
0x07001e333f031e00 ; 138
|
|
0x33000e0c0c0c1e00 ; 139
|
|
0x3e631c1818183c00 ; 140
|
|
0x07000e0c0c0c1e00 ; 141
|
|
0x631c36637f636300 ; 142
|
|
0x0c0c001e333f3300 ; 143
|
|
0x38003f061e063f00 ; 144
|
|
0x0000fe30fe33fe00 ; 145
|
|
0x7c36337f33337300 ; 146
|
|
0x1e33001e33331e00 ; 147
|
|
0x0033001e33331e00 ; 148
|
|
0x0007001e33331e00 ; 149
|
|
0x1e33003333337e00 ; 150
|
|
0x0007003333337e00 ; 151
|
|
0x00330033333e301f ; 152
|
|
0xc3183c66663c1800 ; 153
|
|
0x3300333333331e00 ; 154
|
|
0x18187e03037e1818 ; 155
|
|
0x1c36260f06673f00 ; 156
|
|
0x33331e3f0c3f0c0c ; 157
|
|
0x1f33335f63f363e3 ; 158
|
|
0x70d8183c18181b0e ; 159
|
|
0x38001e303e337e00 ; 160
|
|
0x1c000e0c0c0c1e00 ; 161
|
|
0x0038001e33331e00 ; 162
|
|
0x0038003333337e00 ; 163
|
|
0x001f001f33333300 ; 164
|
|
0x3f0033373f3b3300 ; 165
|
|
0x3c36367c007e0000 ; 166
|
|
0x1c36361c003e0000 ; 167
|
|
0x0c000c0603331e00 ; 168
|
|
0x0000003f03030000 ; 169
|
|
0x0000003f30300000 ; 170
|
|
0xc363337bcc6633f0 ; 171
|
|
0xc36333dbecf6f3c0 ; 172
|
|
0x1818001818181800 ; 173
|
|
0x00cc663366cc0000 ; 174
|
|
0x003366cc66330000 ; 175
|
|
0x4411441144114411 ; 176
|
|
0xaa55aa55aa55aa55 ; 177
|
|
0xdbeedb77dbeedb77 ; 178
|
|
0x1818181818181818 ; 179
|
|
0x181818181f181818 ; 180
|
|
0x18181f181f181818 ; 181
|
|
0x6c6c6c6c6f6c6c6c ; 182
|
|
0x000000007f6c6c6c ; 183
|
|
0x00001f181f181818 ; 184
|
|
0x6c6c6f606f6c6c6c ; 185
|
|
0x6c6c6c6c6c6c6c6c ; 186
|
|
0x00007f606f6c6c6c ; 187
|
|
0x6c6c6f607f000000 ; 188
|
|
0x6c6c6c6c7f000000 ; 189
|
|
0x18181f181f000000 ; 190
|
|
0x000000001f181818 ; 191
|
|
0x18181818f8000000 ; 192
|
|
0x18181818ff000000 ; 193
|
|
0x00000000ff181818 ; 194
|
|
0x18181818f8181818 ; 195
|
|
0x00000000ff000000 ; 196
|
|
0x18181818ff181818 ; 197
|
|
0x1818f818f8181818 ; 198
|
|
0x6c6c6c6cec6c6c6c ; 199
|
|
0x6c6cec0cfc000000 ; 200
|
|
0x0000fc0cec6c6c6c ; 201
|
|
0x6c6cef00ff000000 ; 202
|
|
0x0000ff00ef6c6c6c ; 203
|
|
0x6c6cec0cec6c6c6c ; 204
|
|
0x0000ff00ff000000 ; 205
|
|
0x6c6cef00ef6c6c6c ; 206
|
|
0x1818ff00ff000000 ; 207
|
|
0x6c6c6c6cff000000 ; 208
|
|
0x0000ff00ff181818 ; 209
|
|
0x00000000ff6c6c6c ; 210
|
|
0x6c6c6c6cfc000000 ; 211
|
|
0x1818f818f8000000 ; 212
|
|
0x0000f818f8181818 ; 213
|
|
0x00000000fc6c6c6c ; 214
|
|
0x6c6c6c6cff6c6c6c ; 215
|
|
0x1818ff18ff181818 ; 216
|
|
0x181818181f000000 ; 217
|
|
0x00000000f8181818 ; 218
|
|
0xffffffffffffffff ; 219
|
|
0x00000000ffffffff ; 220
|
|
0x0f0f0f0f0f0f0f0f ; 221
|
|
0xf0f0f0f0f0f0f0f0 ; 222
|
|
0xffffffff00000000 ; 223
|
|
0x00006e3b133b6e00 ; 224
|
|
0x001e331f331f0303 ; 225
|
|
0x003f330303030300 ; 226
|
|
0x007f363636363600 ; 227
|
|
0x3f33060c06333f00 ; 228
|
|
0x00007e1b1b1b0e00 ; 229
|
|
0x00666666663e0603 ; 230
|
|
0x006e3b1818181800 ; 231
|
|
0x3f0c1e33331e0c3f ; 232
|
|
0x1c36637f63361c00 ; 233
|
|
0x1c36636336367700 ; 234
|
|
0x380c183e33331e00 ; 235
|
|
0x00007edbdb7e0000 ; 236
|
|
0x60307edbdb7e0603 ; 237
|
|
0x1c06031f03061c00 ; 238
|
|
0x1e33333333333300 ; 239
|
|
0x003f003f003f0000 ; 240
|
|
0x0c0c3f0c0c003f00 ; 241
|
|
0x060c180c06003f00 ; 242
|
|
0x180c060c18003f00 ; 243
|
|
0x70d8d81818181818 ; 244
|
|
0x18181818181b1b0e ; 245
|
|
0x0c0c003f000c0c00 ; 246
|
|
0x006e3b006e3b0000 ; 247
|
|
0x1c36361c00000000 ; 248
|
|
0x0000001818000000 ; 249
|
|
0x0000000018000000 ; 250
|
|
0xf030303037363c38 ; 251
|
|
0x1e36363636000000 ; 252
|
|
0x0e180c061e000000 ; 253
|
|
0x00003c3c3c3c0000 ; 254
|
|
0x0000000000000000 ; 255
|
|
))
|
|
|
|
(mkbf r7 " Hello World ")
|
|
(bfpush @r7 1) ; ASCII smileys
|
|
(bfrpush @r7 2)
|
|
|
|
; It sometimes randomly doesn't show... ???
|
|
|
|
; Test
|
|
(sc-wr 0 0 #ff00ff)
|
|
(sc-blit)
|
|
|
|
(call ShowChar 10 10 #ffffff 'A')
|
|
|
|
(call ShowString 10 20 #ffff00 r7)
|
|
(sc-blit)
|
|
|
|
(bfrsz @r7 0)
|
|
|
|
(lds @cout "Type something: ")
|
|
(:read)
|
|
(ld r0 @cin (eof? (halt)))
|
|
(ld @cout r0)
|
|
(ld @r7 r0)
|
|
(call ShowString 10 30 #ff0000 r7)
|
|
(sc-blit)
|
|
(j :read)
|
|
|
|
(proc ShowString x y color str
|
|
(sym size r10)
|
|
(sym index r11)
|
|
(sym xx r12)
|
|
|
|
(bfsz size @str (z? (ret)))
|
|
(ld index 0)
|
|
(ld xx x)
|
|
(:ch)
|
|
(bfrd r0 @str index)
|
|
(call ShowChar xx y color r0)
|
|
(add xx 8)
|
|
(inc index)
|
|
(dec size (z? (ret)))
|
|
(j :ch)
|
|
)
|
|
|
|
(proc ShowChar x y color ch
|
|
(rcmp ch 0 255)
|
|
(ret.ne)
|
|
|
|
(sym s r15)
|
|
(bfrd s @FONT ch)
|
|
(rev s)
|
|
|
|
(sym xx r5)
|
|
(sym yy r6)
|
|
(sym nb r7)
|
|
(sym xmax r8)
|
|
(add xmax x 8)
|
|
|
|
(ld xx x)
|
|
(ld yy y)
|
|
(ld nb 64)
|
|
|
|
(:nb)
|
|
(and r0 s 1)
|
|
(j.z :skip)
|
|
|
|
(sc-wr xx yy color)
|
|
|
|
(:skip)
|
|
(ror s 1)
|
|
(inc xx)
|
|
(cmp xx xmax (eq? (ld xx x)(inc yy)))
|
|
(dec nb)
|
|
(j.nz :nb)
|
|
(ret)
|
|
)
|
|
|
|
|
|
(proc WaitForClose
|
|
(:j)
|
|
(sc-blit)
|
|
;(sc-poll)
|
|
(mslp 100)
|
|
(j :j)
|
|
)
|
|
)
|
|
|