|
- ; vrow.s - draw one screen row for the c64 vim clone (called from power c).
- ;
- ; Position independent: no absolute jumps and no absolute data, so the bytes can
- ; sit in a C array and be called at wherever the linker put that array.
- ;
- ; Parameters live in zero page scratch that Power C leaves to ML routines
- ; (decimal 34-42 = $22-$2A), poked by C before the call (see vml.c):
- ; $22/$23 src address of the first byte of text (petscii)
- ; $24 len bytes of text to show, 0..40
- ; $25/$26 dst screen RAM address of the row's first cell
- ; $27 cur column to show reverse (the cursor), $FF = none
- ; $28 rev $00 normal text, $80 whole row reverse (status row)
- ;
- ; The row is cleared to blanks, the text is converted petscii -> screen code
- ; and copied, then the cursor cell is flipped to reverse video. Codes below
- ; $20 show as a blank. Colour RAM is set once at start-up, not here.
- ;
- ; Build: build-ml.ps1 (ca65 + ld65 -> vrow.bin -> vml.c).
-
- src = $22
- len = $24
- dst = $25
- cur = $27
- rev = $28
-
- .segment "CODE"
-
- entry: lda rev ; clear the row
- ora #$20
- ldy #39
- clr: sta (dst),y
- dey
- bpl clr
-
- ldy #0
- cp: cpy len
- beq done
- lda (src),y
- cmp #$20
- bcs ok
- lda #$20
- ok: cmp #$C0 ; petscii -> screen code
- bcc l1
- sbc #$80
- bcs st ; carry is still set: an unconditional branch
- l1: cmp #$A0
- bcc l2
- sbc #$40
- bcs st
- l2: cmp #$60
- bcc l3
- sbc #$20
- bcs st
- l3: cmp #$40
- bcc st
- sbc #$40
- st: ora rev
- sta (dst),y
- iny
- bne cp ; y never wraps (max 40): unconditional
-
- done: lda cur
- cmp #$FF
- beq fin
- tay
- lda (dst),y
- eor #$80
- sta (dst),y
- fin: rts
|