kthacker | 6de6775 | 2006-04-17 15:02:26 +0000 | [diff] [blame] | 1 | |
| 2 | ;--------------------------------------------------------------------- |
| 3 | .importzp ptr1, ptr2, ptr3, ptr4, sreg |
| 4 | .importzp sp |
| 5 | |
| 6 | .import pushax |
| 7 | .import incsp2 |
| 8 | |
| 9 | .import _ctk_80col_screencolors |
| 10 | .import _ctk_80col_screenpattern |
| 11 | |
| 12 | .import _ctk_80col_lefttab |
| 13 | .import _ctk_80col_righttab |
| 14 | |
| 15 | .import _ctk_80col_cursx |
| 16 | .import _ctk_80col_cursy |
| 17 | .import _ctk_80col_color |
| 18 | .import _ctk_80col_underline |
| 19 | .import _ctk_80col_reversed |
| 20 | |
| 21 | .import _ctk_80col_yscreenaddr |
| 22 | .import _ctk_80col_yhiresaddr |
| 23 | |
| 24 | .import _ctk_80col_windowparams |
| 25 | |
| 26 | .import _ctk_80col_bitmapptr |
| 27 | |
| 28 | .import _ctk_80col_versionstring |
| 29 | .import _ctk_80col_versionstring_len |
| 30 | |
| 31 | .import _ctk_80col_theme |
| 32 | |
| 33 | .export _ctk_80col_cclear |
| 34 | .export _ctk_80col_chline |
| 35 | .export _ctk_80col_cputc |
| 36 | .export _ctk_80col_cputsn |
| 37 | |
| 38 | .export _ctk_80col_clear_line |
| 39 | .export _ctk_80col_draw_bitmapline |
| 40 | |
| 41 | .export _ctk_80col_draw_windowborders |
| 42 | |
| 43 | ;--------------------------------------------------------------------- |
| 44 | |
| 45 | ptr5 = sreg |
| 46 | |
| 47 | ;; Offsets in the theme struct |
| 48 | |
| 49 | ulcornerpattern = 8 |
| 50 | titlebarpattern = ulcornerpattern+8 |
| 51 | urcornerpattern = titlebarpattern+8 |
| 52 | rborderpattern = urcornerpattern+8 |
| 53 | lrcornerpattern = rborderpattern+8 |
| 54 | lowerborderpattern = lrcornerpattern+8 |
| 55 | llcornerpattern = lowerborderpattern+8 |
| 56 | lborderpattern = llcornerpattern+8 |
| 57 | |
| 58 | |
| 59 | buttonleftpattern = lborderpattern+8 |
| 60 | buttonrightpattern = buttonleftpattern+8 |
| 61 | |
| 62 | |
| 63 | .bss |
| 64 | tmp01: .res 1 |
| 65 | tmpl: .res 1 |
| 66 | tmpf: .res 1 |
| 67 | tmpc: .res 1 |
| 68 | tmpw: .res 1 |
| 69 | tmpptr: .res 2 |
| 70 | |
| 71 | tmpy: .res 1 |
| 72 | tmph: .res 1 |
| 73 | |
| 74 | ;; Window border parameters |
| 75 | w: .res 1 |
| 76 | wpw = 0 |
| 77 | h: .res 1 |
| 78 | wph = 1 |
| 79 | clipy1: .res 1 |
| 80 | wpclipy1 = 2 |
| 81 | clipy2: .res 1 |
| 82 | wpclipy2 = 3 |
| 83 | color1: .res 1 |
| 84 | wpcolor1 = 4 |
| 85 | color2: .res 1 |
| 86 | wpcolor2 = 5 |
| 87 | titlecolor: .res 1 |
| 88 | wptitlecolor = 6 |
| 89 | titlelen: .res 1 |
| 90 | wptitlelen = 7 |
| 91 | title: .res 2 |
| 92 | wptitle = 8 |
| 93 | |
| 94 | ;--------------------------------------------------------------------- |
| 95 | .data |
| 96 | ;--------------------------------------------------------------------- |
| 97 | .code |
| 98 | setupptrs: |
| 99 | ;; Find hires address. |
| 100 | lda _ctk_80col_cursy |
| 101 | asl |
| 102 | tax |
| 103 | lda _ctk_80col_yhiresaddr,x |
| 104 | sta ptr2 |
| 105 | lda _ctk_80col_yhiresaddr+1,x |
| 106 | sta ptr2+1 |
| 107 | |
| 108 | ;; Add X coordinate to the hires address. |
| 109 | lda #0 |
| 110 | sta ptr1+1 |
| 111 | lda _ctk_80col_cursx |
| 112 | asl |
| 113 | rol ptr1+1 |
| 114 | ; asl |
| 115 | ; rol ptr1+1 |
| 116 | asl |
| 117 | rol ptr1+1 |
| 118 | clc |
| 119 | adc ptr2 |
| 120 | and #$f8 |
| 121 | sta ptr2 |
| 122 | lda ptr2+1 |
| 123 | adc ptr1+1 |
| 124 | sta ptr2+1 |
| 125 | |
| 126 | ;; Find screen address. |
| 127 | lda _ctk_80col_cursy |
| 128 | asl |
| 129 | tax |
| 130 | lda _ctk_80col_cursx |
| 131 | lsr |
| 132 | clc |
| 133 | adc _ctk_80col_yscreenaddr,x |
| 134 | sta ptr1 |
| 135 | lda _ctk_80col_yscreenaddr+1,x |
| 136 | adc #0 |
| 137 | sta ptr1+1 |
| 138 | |
| 139 | ;; Turn off interrupts, prepare $01 to store color data in RAM |
| 140 | ;; under I/O area. |
| 141 | sei |
| 142 | lda $01 |
| 143 | sta tmp01 |
| 144 | and #$f8 |
| 145 | sta $01 |
| 146 | rts |
| 147 | ;--------------------------------------------------------------------- |
| 148 | restore01: |
| 149 | lda tmp01 |
| 150 | sta $01 |
| 151 | cli |
| 152 | rts |
| 153 | ;--------------------------------------------------------------------- |
| 154 | _ctk_80col_cclear: |
| 155 | sta tmpl |
| 156 | cmp #0 |
| 157 | bne @norts |
| 158 | rts |
| 159 | @norts: |
| 160 | |
| 161 | jsr setupptrs |
| 162 | |
| 163 | ldy tmpl |
| 164 | lda _ctk_80col_color |
| 165 | : |
| 166 | sta (ptr1),y |
| 167 | dey |
| 168 | bpl :- |
| 169 | |
| 170 | ;; Store either $00 or $ff in hires memory, depending on the |
| 171 | ;; reversed flag |
| 172 | |
| 173 | ldx tmpl |
| 174 | lda _ctk_80col_reversed |
| 175 | beq @noff |
| 176 | lda #$ff |
| 177 | @noff: |
| 178 | sta tmpf |
| 179 | |
| 180 | |
| 181 | @loop1: |
| 182 | ldy #7 |
| 183 | lda tmpf |
| 184 | @loop2: |
| 185 | sta (ptr2),y |
| 186 | dey |
| 187 | bpl @loop2 |
| 188 | |
| 189 | lda ptr2 |
| 190 | clc |
| 191 | adc #8 |
| 192 | sta ptr2 |
| 193 | bcc @noinc |
| 194 | inc ptr2+1 |
| 195 | @noinc: |
| 196 | |
| 197 | inc _ctk_80col_cursx |
| 198 | |
| 199 | dex |
| 200 | bpl @loop1 |
| 201 | |
| 202 | jmp restore01 |
| 203 | ;--------------------------------------------------------------------- |
| 204 | _ctk_80col_chline: |
| 205 | sta tmpl |
| 206 | cmp #0 |
| 207 | bne @norts |
| 208 | rts |
| 209 | @norts: |
| 210 | |
| 211 | jsr setupptrs |
| 212 | |
| 213 | ;; Store horizontal line pattern in hires memory |
| 214 | ldx tmpl |
| 215 | @loop1: |
| 216 | ldy #0 |
| 217 | lda #$00 |
| 218 | sta (ptr2),y |
| 219 | iny |
| 220 | lda #$00 |
| 221 | sta (ptr2),y |
| 222 | iny |
| 223 | lda #$00 |
| 224 | sta (ptr2),y |
| 225 | iny |
| 226 | lda #$ff |
| 227 | sta (ptr2),y |
| 228 | iny |
| 229 | lda #$ff |
| 230 | sta (ptr2),y |
| 231 | iny |
| 232 | lda #$00 |
| 233 | sta (ptr2),y |
| 234 | iny |
| 235 | lda #$00 |
| 236 | sta (ptr2),y |
| 237 | iny |
| 238 | lda #$00 |
| 239 | sta (ptr2),y |
| 240 | |
| 241 | |
| 242 | lda ptr2 |
| 243 | clc |
| 244 | adc #8 |
| 245 | sta ptr2 |
| 246 | bcc @noinc |
| 247 | inc ptr2+1 |
| 248 | @noinc: |
| 249 | |
| 250 | inc _ctk_80col_cursx |
| 251 | |
| 252 | dex |
| 253 | bne @loop1 |
| 254 | |
| 255 | jmp restore01 |
| 256 | ;--------------------------------------------------------------------- |
| 257 | _ctk_80col_cputc: |
| 258 | sta tmpc |
| 259 | |
| 260 | jsr setupptrs |
| 261 | |
| 262 | ;; Turn on font ROM |
| 263 | lda tmp01 |
| 264 | and #$f8 |
| 265 | ora #$01 |
| 266 | sta $01 |
| 267 | |
| 268 | lda #0 |
| 269 | sta ptr1+1 |
| 270 | |
| 271 | ;; Convert from PETSCII to screen encoding |
| 272 | lda tmpc |
| 273 | eor #$e0 |
| 274 | clc |
| 275 | adc #$20 |
| 276 | bpl @cont |
| 277 | adc #$40 |
| 278 | bpl @cont |
| 279 | eor #$a0 |
| 280 | @cont: |
| 281 | ldx _ctk_80col_reversed |
| 282 | beq :+ |
| 283 | eor #$80 |
| 284 | : |
| 285 | |
| 286 | ;; Convert to address in character ROM |
| 287 | asl |
| 288 | rol ptr1+1 |
| 289 | asl |
| 290 | rol ptr1+1 |
| 291 | asl |
| 292 | rol ptr1+1 |
| 293 | sta ptr1 |
| 294 | lda #$d8 |
| 295 | adc ptr1+1 |
| 296 | sta ptr1+1 |
| 297 | |
| 298 | lda _ctk_80col_cursx |
| 299 | and #1 |
| 300 | beq @left |
| 301 | |
| 302 | ;; Print on hires screen, bottom-up. If we should underline, |
| 303 | ;; we do this by eor:ing the bottom line with #$ff |
| 304 | ldy #7 |
| 305 | lda (ptr1),y |
| 306 | ldx _ctk_80col_underline |
| 307 | beq @rightnounderline |
| 308 | eor #$ff |
| 309 | @rightnounderline: |
| 310 | tax |
| 311 | lda (ptr2),y |
| 312 | and #$f0 |
| 313 | ora _ctk_80col_righttab,x |
| 314 | sta (ptr2),y |
| 315 | dey |
| 316 | @rightloop: |
| 317 | lda (ptr1),y |
| 318 | tax |
| 319 | lda (ptr2),y |
| 320 | and #$f0 |
| 321 | ora _ctk_80col_righttab,x |
| 322 | sta (ptr2),y |
| 323 | dey |
| 324 | bpl @rightloop |
| 325 | |
| 326 | inc _ctk_80col_cursx |
| 327 | |
| 328 | jmp restore01 |
| 329 | |
| 330 | @left: |
| 331 | ;; Print on hires screen, bottom-up. If we should underline, |
| 332 | ;; we do this by eor:ing the bottom line with #$ff |
| 333 | ldy #7 |
| 334 | lda (ptr1),y |
| 335 | ldx _ctk_80col_underline |
| 336 | beq @nounderline |
| 337 | eor #$ff |
| 338 | @nounderline: |
| 339 | tax |
| 340 | lda (ptr2),y |
| 341 | and #$0f |
| 342 | ora _ctk_80col_lefttab,x |
| 343 | sta (ptr2),y |
| 344 | dey |
| 345 | @loop: |
| 346 | lda (ptr1),y |
| 347 | tax |
| 348 | lda (ptr2),y |
| 349 | and #$0f |
| 350 | ora _ctk_80col_lefttab,x |
| 351 | sta (ptr2),y |
| 352 | dey |
| 353 | bpl @loop |
| 354 | |
| 355 | |
| 356 | |
| 357 | inc _ctk_80col_cursx |
| 358 | |
| 359 | jmp restore01 |
| 360 | ;--------------------------------------------------------------------- |
| 361 | _ctk_80col_cputsn: |
| 362 | sta tmpl |
| 363 | cmp #0 |
| 364 | bne :+ |
| 365 | jmp incsp2 |
| 366 | : |
| 367 | |
| 368 | jsr setupptrs |
| 369 | |
| 370 | ;; Turn on font ROM |
| 371 | lda tmp01 |
| 372 | and #$f8 |
| 373 | ora #$01 |
| 374 | sta $01 |
| 375 | |
| 376 | ;; Output each character from the string |
| 377 | lda #0 |
| 378 | sta tmpc |
| 379 | ldy #0 |
| 380 | lda (sp),y |
| 381 | sta ptr3 |
| 382 | iny |
| 383 | lda (sp),y |
| 384 | sta ptr3+1 |
| 385 | |
| 386 | @loop1: |
| 387 | |
| 388 | |
| 389 | lda #0 |
| 390 | sta ptr1+1 |
| 391 | |
| 392 | ldy tmpc |
| 393 | lda (ptr3),y |
| 394 | bne :+ |
| 395 | jmp @end |
| 396 | : |
| 397 | |
| 398 | ;; Convert from PETSCII to screen encoding |
| 399 | eor #$e0 |
| 400 | clc |
| 401 | adc #$20 |
| 402 | bpl @cont |
| 403 | adc #$40 |
| 404 | bpl @cont |
| 405 | eor #$a0 |
| 406 | @cont: |
| 407 | ldx _ctk_80col_reversed |
| 408 | beq :+ |
| 409 | eor #$80 |
| 410 | : |
| 411 | |
| 412 | ;; Convert to address in character ROM |
| 413 | asl |
| 414 | rol ptr1+1 |
| 415 | asl |
| 416 | rol ptr1+1 |
| 417 | asl |
| 418 | rol ptr1+1 |
| 419 | sta ptr1 |
| 420 | lda #$d8 |
| 421 | adc ptr1+1 |
| 422 | sta ptr1+1 |
| 423 | |
| 424 | lda _ctk_80col_cursx |
| 425 | and #1 |
| 426 | beq @left |
| 427 | |
| 428 | ;; Print on hires screen, bottom-up. If we should underline, |
| 429 | ;; we do this by eor:ing the bottom line with #$ff |
| 430 | ldy #7 |
| 431 | lda (ptr1),y |
| 432 | ldx _ctk_80col_underline |
| 433 | beq @rightnounderline |
| 434 | eor #$ff |
| 435 | @rightnounderline: |
| 436 | tax |
| 437 | lda (ptr2),y |
| 438 | and #$f0 |
| 439 | ora _ctk_80col_righttab,x |
| 440 | sta (ptr2),y |
| 441 | dey |
| 442 | @rightloop: |
| 443 | lda (ptr1),y |
| 444 | tax |
| 445 | lda (ptr2),y |
| 446 | and #$f0 |
| 447 | ora _ctk_80col_righttab,x |
| 448 | sta (ptr2),y |
| 449 | dey |
| 450 | bpl @rightloop |
| 451 | |
| 452 | |
| 453 | lda ptr2 |
| 454 | clc |
| 455 | adc #8 |
| 456 | sta ptr2 |
| 457 | bcc :+ |
| 458 | inc ptr2+1 |
| 459 | : |
| 460 | |
| 461 | inc _ctk_80col_cursx |
| 462 | |
| 463 | jmp @loopend |
| 464 | |
| 465 | @left: |
| 466 | ;; Print on hires screen, bottom-up. If we should underline, |
| 467 | ;; we do this by eor:ing the bottom line with #$ff |
| 468 | ldy #7 |
| 469 | lda (ptr1),y |
| 470 | ldx _ctk_80col_underline |
| 471 | beq @nounderline |
| 472 | eor #$ff |
| 473 | @nounderline: |
| 474 | tax |
| 475 | lda (ptr2),y |
| 476 | and #$0f |
| 477 | ora _ctk_80col_lefttab,x |
| 478 | sta (ptr2),y |
| 479 | dey |
| 480 | @loop: |
| 481 | lda (ptr1),y |
| 482 | tax |
| 483 | lda (ptr2),y |
| 484 | and #$0f |
| 485 | ora _ctk_80col_lefttab,x |
| 486 | sta (ptr2),y |
| 487 | dey |
| 488 | bpl @loop |
| 489 | |
| 490 | inc _ctk_80col_cursx |
| 491 | @loopend: |
| 492 | inc tmpc |
| 493 | lda tmpc |
| 494 | cmp tmpl |
| 495 | beq :+ |
| 496 | jmp @loop1 |
| 497 | : |
| 498 | |
| 499 | @end: |
| 500 | jsr restore01 |
| 501 | |
| 502 | jmp incsp2 |
| 503 | ;--------------------------------------------------------------------- |
| 504 | _ctk_80col_clear_line: |
| 505 | sta tmpl |
| 506 | asl |
| 507 | tax |
| 508 | lda _ctk_80col_yscreenaddr,x |
| 509 | sta ptr1 |
| 510 | lda _ctk_80col_yscreenaddr+1,x |
| 511 | sta ptr1+1 |
| 512 | lda _ctk_80col_yhiresaddr,x |
| 513 | sta ptr2 |
| 514 | lda _ctk_80col_yhiresaddr+1,x |
| 515 | sta ptr2+1 |
| 516 | |
| 517 | sei |
| 518 | lda $01 |
| 519 | sta tmp01 |
| 520 | and #$f8 |
| 521 | sta $01 |
| 522 | |
| 523 | ldy #39 |
| 524 | ldx tmpl |
| 525 | lda _ctk_80col_screencolors,x |
| 526 | : |
| 527 | sta (ptr1),y |
| 528 | dey |
| 529 | bpl :- |
| 530 | |
| 531 | lda tmpl |
| 532 | asl |
| 533 | asl |
| 534 | asl |
| 535 | tax |
| 536 | ldy #0 |
| 537 | : |
| 538 | lda _ctk_80col_screenpattern,x |
| 539 | sta (ptr2),y |
| 540 | iny |
| 541 | lda _ctk_80col_screenpattern+1,x |
| 542 | sta (ptr2),y |
| 543 | iny |
| 544 | lda _ctk_80col_screenpattern+2,x |
| 545 | sta (ptr2),y |
| 546 | iny |
| 547 | lda _ctk_80col_screenpattern+3,x |
| 548 | sta (ptr2),y |
| 549 | iny |
| 550 | lda _ctk_80col_screenpattern+4,x |
| 551 | sta (ptr2),y |
| 552 | iny |
| 553 | lda _ctk_80col_screenpattern+5,x |
| 554 | sta (ptr2),y |
| 555 | iny |
| 556 | lda _ctk_80col_screenpattern+6,x |
| 557 | sta (ptr2),y |
| 558 | iny |
| 559 | lda _ctk_80col_screenpattern+7,x |
| 560 | sta (ptr2),y |
| 561 | iny |
| 562 | bne :- |
| 563 | |
| 564 | inc ptr2+1 |
| 565 | |
| 566 | : |
| 567 | lda _ctk_80col_screenpattern,x |
| 568 | sta (ptr2),y |
| 569 | iny |
| 570 | lda _ctk_80col_screenpattern+1,x |
| 571 | sta (ptr2),y |
| 572 | iny |
| 573 | lda _ctk_80col_screenpattern+2,x |
| 574 | sta (ptr2),y |
| 575 | iny |
| 576 | lda _ctk_80col_screenpattern+3,x |
| 577 | sta (ptr2),y |
| 578 | iny |
| 579 | lda _ctk_80col_screenpattern+4,x |
| 580 | sta (ptr2),y |
| 581 | iny |
| 582 | lda _ctk_80col_screenpattern+5,x |
| 583 | sta (ptr2),y |
| 584 | iny |
| 585 | lda _ctk_80col_screenpattern+6,x |
| 586 | sta (ptr2),y |
| 587 | iny |
| 588 | lda _ctk_80col_screenpattern+7,x |
| 589 | sta (ptr2),y |
| 590 | iny |
| 591 | cpy #$40 |
| 592 | bne :- |
| 593 | |
| 594 | lda tmpl |
| 595 | cmp #24 |
| 596 | bne :+ |
| 597 | |
| 598 | sta _ctk_80col_cursy |
| 599 | lda #2 |
| 600 | sta _ctk_80col_cursx |
| 601 | |
| 602 | jsr restore01 |
| 603 | |
| 604 | lda #<_ctk_80col_versionstring |
| 605 | ldx #>_ctk_80col_versionstring |
| 606 | jsr pushax |
| 607 | lda _ctk_80col_versionstring_len |
| 608 | jmp _ctk_80col_cputsn |
| 609 | : |
| 610 | jmp restore01 |
| 611 | ;--------------------------------------------------------------------- |
| 612 | _ctk_80col_draw_bitmapline: |
| 613 | sta tmpl |
| 614 | cmp #0 |
| 615 | bne :+ |
| 616 | rts |
| 617 | : |
| 618 | |
| 619 | jsr setupptrs |
| 620 | |
| 621 | ldy #0 |
| 622 | lda _ctk_80col_color |
| 623 | : |
| 624 | sta (ptr1),y |
| 625 | iny |
| 626 | cpy tmpl |
| 627 | bne :- |
| 628 | |
| 629 | lda _ctk_80col_bitmapptr |
| 630 | sta ptr1 |
| 631 | lda _ctk_80col_bitmapptr+1 |
| 632 | sta ptr1+1 |
| 633 | |
| 634 | ldy #0 |
| 635 | ldx #0 |
| 636 | : |
| 637 | lda (ptr1),y |
| 638 | sta (ptr2),y |
| 639 | iny |
| 640 | inx |
| 641 | cpx #8 |
| 642 | bne :- |
| 643 | |
| 644 | ldx #0 |
| 645 | |
| 646 | dec tmpl |
| 647 | bne :- |
| 648 | |
| 649 | jmp restore01 |
| 650 | ;--------------------------------------------------------------------- |
| 651 | _ctk_80col_draw_windowborders: |
| 652 | |
| 653 | jsr setupptrs |
| 654 | |
| 655 | lda _ctk_80col_windowparams + wpclipy1 |
| 656 | beq :+ |
| 657 | jmp @nofirstline |
| 658 | : |
| 659 | |
| 660 | ;; Draw first line of the border, including the window title |
| 661 | |
| 662 | ;; Start with filling color memory |
| 663 | lda _ctk_80col_windowparams + wpw |
| 664 | sta tmpw |
| 665 | |
| 666 | |
| 667 | ldy #0 |
| 668 | lda _ctk_80col_windowparams + wptitlecolor |
| 669 | : |
| 670 | sta (ptr1),y |
| 671 | iny |
| 672 | cpy tmpw |
| 673 | bcc :- |
| 674 | |
| 675 | dec tmpw |
| 676 | |
| 677 | ;; Set color for upper right corner |
| 678 | sta (ptr1),y |
| 679 | iny |
| 680 | sta (ptr1),y |
| 681 | |
| 682 | |
| 683 | ;; Turn on font ROM for drawing the title |
| 684 | lda tmp01 |
| 685 | and #$f8 |
| 686 | ora #$01 |
| 687 | sta $01 |
| 688 | |
| 689 | ;; Use a temporary pointer (ptr3) rather than ptr2 so we can |
| 690 | ;; reuse it later. |
| 691 | lda ptr2 |
| 692 | sta ptr3 |
| 693 | lda ptr2+1 |
| 694 | sta ptr3+1 |
| 695 | |
| 696 | ;; Draw upper left corner |
| 697 | ldy #7 |
| 698 | : |
| 699 | lda _ctk_80col_theme+ulcornerpattern,y |
| 700 | sta (ptr3),y |
| 701 | dey |
| 702 | bpl :- |
| 703 | |
| 704 | lda ptr3 |
| 705 | clc |
| 706 | adc #$8 |
| 707 | sta ptr3 |
| 708 | bcc :+ |
| 709 | inc ptr3+1 |
| 710 | : |
| 711 | |
| 712 | |
| 713 | ;; Draw window title bar pattern |
| 714 | @titlebarloop: |
| 715 | ldy #7 |
| 716 | : |
| 717 | lda _ctk_80col_theme+titlebarpattern,y |
| 718 | sta (ptr3),y |
| 719 | dey |
| 720 | bpl :- |
| 721 | |
| 722 | lda ptr3 |
| 723 | clc |
| 724 | adc #$8 |
| 725 | sta ptr3 |
| 726 | bcc :+ |
| 727 | inc ptr3+1 |
| 728 | : |
| 729 | ;; Loop until we are three characters away from right border |
| 730 | ;; to avoid flickering since we would be overwriting the close |
| 731 | ;; button. |
| 732 | dec tmpw |
| 733 | bpl @titlebarloop |
| 734 | |
| 735 | ;; Draw upper right corner piece |
| 736 | ldy #7 |
| 737 | : |
| 738 | lda _ctk_80col_theme+urcornerpattern,y |
| 739 | sta (ptr3),y |
| 740 | dey |
| 741 | bpl :- |
| 742 | |
| 743 | |
| 744 | @nofirstline: |
| 745 | |
| 746 | |
| 747 | ldx _ctk_80col_windowparams + wph |
| 748 | inx |
| 749 | stx tmph |
| 750 | |
| 751 | ;; Draw left and right borders |
| 752 | |
| 753 | ;; Fill color memory (pointer in ptr1, setup by setupptrs) |
| 754 | |
| 755 | ;; First check how much we actually should draw by inspecting |
| 756 | ;; the clipy1 and clipy2 fields in the _ctk_80col_windowparams |
| 757 | ;; structure |
| 758 | |
| 759 | lda #1 |
| 760 | sta tmpy |
| 761 | |
| 762 | ldx _ctk_80col_windowparams + wpclipy1 |
| 763 | @clipy1loop: |
| 764 | cpx #0 |
| 765 | beq @clipy1loopend |
| 766 | lda ptr1 |
| 767 | clc |
| 768 | adc #$28 |
| 769 | sta ptr1 |
| 770 | bcc :+ |
| 771 | inc ptr1+1 |
| 772 | : |
| 773 | lda ptr3 |
| 774 | clc |
| 775 | adc #$40 |
| 776 | sta ptr3 |
| 777 | lda ptr3+1 |
| 778 | adc #1 |
| 779 | sta ptr3+1 |
| 780 | |
| 781 | inc tmpy |
| 782 | |
| 783 | dex |
| 784 | jmp @clipy1loop |
| 785 | @clipy1loopend: |
| 786 | |
| 787 | lda ptr1 |
| 788 | clc |
| 789 | adc #$28 |
| 790 | sta ptr1 |
| 791 | bcc :+ |
| 792 | inc ptr1+1 |
| 793 | : |
| 794 | |
| 795 | ldx tmpy |
| 796 | ldy _ctk_80col_windowparams + wpw |
| 797 | iny |
| 798 | sty tmpw |
| 799 | @bordercloop: |
| 800 | cpx _ctk_80col_windowparams + wpclipy2 |
| 801 | beq @bordercloopend |
| 802 | |
| 803 | ldy tmpw |
| 804 | lda _ctk_80col_windowparams + wpcolor2 |
| 805 | sta (ptr1),y |
| 806 | ldy #0 |
| 807 | lda _ctk_80col_windowparams + wpcolor1 |
| 808 | sta (ptr1),y |
| 809 | |
| 810 | lda ptr1 |
| 811 | clc |
| 812 | adc #$28 |
| 813 | sta ptr1 |
| 814 | bcc :+ |
| 815 | inc ptr1+1 |
| 816 | : |
| 817 | |
| 818 | inx |
| 819 | cpx tmph |
| 820 | bcc @bordercloop |
| 821 | beq @bordercloop |
| 822 | @bordercloopend: |
| 823 | |
| 824 | |
| 825 | ;; Fill color memory for lower border, if clipy2 allows |
| 826 | cpx _ctk_80col_windowparams + wpclipy2 |
| 827 | beq @noclowerborder |
| 828 | |
| 829 | lda ptr1 |
| 830 | sec |
| 831 | sbc #$28 |
| 832 | sta ptr1 |
| 833 | bcs :+ |
| 834 | dec ptr1+1 |
| 835 | : |
| 836 | |
| 837 | ldy _ctk_80col_windowparams + wpw |
| 838 | lda _ctk_80col_windowparams + wpcolor2 |
| 839 | @lbordercloop: |
| 840 | sta (ptr1),y |
| 841 | dey |
| 842 | bne @lbordercloop |
| 843 | |
| 844 | @noclowerborder: |
| 845 | |
| 846 | ;; Draw right border |
| 847 | ldx tmpy |
| 848 | @rborderloop: |
| 849 | cpx _ctk_80col_windowparams + wpclipy2 |
| 850 | beq @rborderloopend |
| 851 | |
| 852 | lda ptr3 |
| 853 | clc |
| 854 | adc #$40 |
| 855 | sta ptr3 |
| 856 | lda ptr3+1 |
| 857 | adc #1 |
| 858 | sta ptr3+1 |
| 859 | |
| 860 | ldy #7 |
| 861 | : |
| 862 | lda _ctk_80col_theme+rborderpattern,y |
| 863 | sta (ptr3),y |
| 864 | dey |
| 865 | bpl :- |
| 866 | |
| 867 | inx |
| 868 | cpx tmph |
| 869 | bne @rborderloop |
| 870 | @rborderloopend: |
| 871 | |
| 872 | cpx _ctk_80col_windowparams + wpclipy2 |
| 873 | beq @norbordercorner |
| 874 | |
| 875 | lda ptr3 |
| 876 | clc |
| 877 | adc #$40 |
| 878 | sta ptr3 |
| 879 | lda ptr3+1 |
| 880 | adc #1 |
| 881 | sta ptr3+1 |
| 882 | |
| 883 | ;; Draw lower right corner, if clipy2 allows it |
| 884 | ldy #7 |
| 885 | : |
| 886 | lda _ctk_80col_theme+lrcornerpattern,y |
| 887 | sta (ptr3),y |
| 888 | dey |
| 889 | bpl :- |
| 890 | |
| 891 | @norbordercorner: |
| 892 | |
| 893 | stx tmpy |
| 894 | |
| 895 | ;; Draw lower border |
| 896 | ldx _ctk_80col_windowparams + wpw |
| 897 | |
| 898 | @lowerborderloop: |
| 899 | lda ptr3 |
| 900 | sec |
| 901 | sbc #$8 |
| 902 | sta ptr3 |
| 903 | bcs :+ |
| 904 | dec ptr3+1 |
| 905 | : |
| 906 | |
| 907 | lda tmpy |
| 908 | cmp _ctk_80col_windowparams + wpclipy2 |
| 909 | beq @nolowerborder |
| 910 | |
| 911 | ldy #7 |
| 912 | : |
| 913 | lda _ctk_80col_theme+lowerborderpattern,y |
| 914 | sta (ptr3),y |
| 915 | dey |
| 916 | bpl :- |
| 917 | @nolowerborder: |
| 918 | |
| 919 | dex |
| 920 | bne @lowerborderloop |
| 921 | |
| 922 | lda ptr3 |
| 923 | sec |
| 924 | sbc #$8 |
| 925 | sta ptr3 |
| 926 | bcs :+ |
| 927 | dec ptr3+1 |
| 928 | : |
| 929 | |
| 930 | |
| 931 | ldx tmpy |
| 932 | cpx tmph |
| 933 | bne @nolbordercorner |
| 934 | |
| 935 | ;; Draw lower left corner, if clipy2 allows it |
| 936 | ldy #7 |
| 937 | : |
| 938 | lda _ctk_80col_theme+llcornerpattern,y |
| 939 | sta (ptr3),y |
| 940 | dey |
| 941 | bpl :- |
| 942 | |
| 943 | lda ptr3 |
| 944 | sec |
| 945 | sbc #$40 |
| 946 | sta ptr3 |
| 947 | lda ptr3+1 |
| 948 | sbc #1 |
| 949 | sta ptr3+1 |
| 950 | |
| 951 | @nolbordercorner: |
| 952 | |
| 953 | ;; Draw left border |
| 954 | |
| 955 | |
| 956 | |
| 957 | @lborderloop: |
| 958 | cpx #1 |
| 959 | beq @lborderloopend |
| 960 | cpx _ctk_80col_windowparams + wpclipy1 |
| 961 | bcc @lborderloopend |
| 962 | |
| 963 | ldy #7 |
| 964 | : |
| 965 | lda _ctk_80col_theme+lborderpattern,y |
| 966 | sta (ptr3),y |
| 967 | dey |
| 968 | bpl :- |
| 969 | |
| 970 | lda ptr3 |
| 971 | sec |
| 972 | sbc #$40 |
| 973 | sta ptr3 |
| 974 | lda ptr3+1 |
| 975 | sbc #1 |
| 976 | sta ptr3+1 |
| 977 | |
| 978 | dex |
| 979 | jmp @lborderloop |
| 980 | |
| 981 | @lborderloopend: |
| 982 | |
| 983 | |
| 984 | jmp restore01 |
| 985 | ;--------------------------------------------------------------------- |
| 986 | |