Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;Not completed, still has some bugs, but if you don't need to worry about clipping (all text will fit between y-coords from 0 and 63) then you should be fine.
- ;;included routines:
- ;;text_y, text_x are the coords
- ;;(buf0) and (buf1) are the buffers to draw to
- ;;dispC: A is the char to draw.
- ;;putString: HL points to the zero-terminated string. Ex. .db "Hello",0
- ;;zPutString: The string directly follows the call.
- ;; Ex.
- ;; call zPutString
- ;; .db "Hello",0
- smc = 1
- yes = 1
- no = 0
- _OR = 0
- _XOR = 1
- _AND = 2
- _Erase = 3
- _Any = -1 ;***Not Implemented***
- allow_fonts = no ;can use multiple fonts during program use
- multiple_buffers= yes
- draw_logic = _OR
- allow_invert = no
- allow_wrap = no
- allow_windows = no ;***Not Implemented***
- #IF smc == 0
- fontloc = 8000h
- text_y = 8002h
- text_x = 8003h
- text_offset = 8004h
- shift_num = 8006h
- #IF draw_logic == _Any
- drawmask = 8007h
- #ENDIF
- #ENDIF
- .db $BB,$6D
- .org $9D95
- text_disp_test:
- loop:
- call zPutString
- .db "Hello World! Tatertatertater moo",0
- ; ld hl,(text_y)
- ; inc l
- ; ld a,l
- ; add a,a
- ; add a,l
- ; ld h,a
- ; ld (text_y),hl
- ; jr nz,loop
- ret
- zPutString:
- ex (sp),hl
- push af
- push bc
- push de
- call putString
- pop de
- pop bc
- pop af
- ex (sp),hl
- ret
- putString:
- ;;Input:
- ;; HL points to the zero-terminated string to draw.
- ;; (text_x) is the x coordinate
- ;; (text_y) is the y coordinate
- ;; (buf0) points to a buffer to draw to
- ;; (buf1) points to a buffer to draw to
- ;;Output:
- ;; Draws the string to the screen.
- ;; HL points to the byte after the null-terminated string.
- ;; A=0
- ld a,(hl)
- inc hl
- or a
- ret z
- push hl
- call dispC
- pop hl
- jp putString
- dispC:
- ;;Inputs: A is the char to draw
- ;; (text_x) is the x coordinate
- ;; (text_y) is the y coordinate
- ;; (buf0) points to a buffer to draw to
- ;; (buf1) points to a buffer to draw to
- ;; (fontloc) points to the font data
- ;;Outputs:
- ;; Text is drawn to the buf with OR logic
- ;; text_x and text_y are updated accordingly
- ;;Notes:
- ;; Performs proper clipping.
- ;; Uses a nibble-packed monospace font of 4 pixels wide, 6 pixels tall.
- ;; Somewhat portable on monochrome TI calculators
- ;;=====================================================
- ;;initialize variables to suit your needs
- ;;=====================================================
- ld h,0
- ld l,a
- add hl,hl
- add a,l
- ld l,a
- jr nc,$+3
- inc h
- #IF (smc == 1) | (allow_fonts == no)
- fontloc = $+1
- ld de,font
- #ELSE
- ld de,(fontloc)
- #ENDIF
- add hl,de
- ex de,hl
- #IF smc == 1
- text_y = $+1
- text_x = $+2
- ld bc,$0303
- #ELSE
- ld bc,(text_y)
- #ENDIF
- ld a,c
- add a,3
- cp 67
- ret nc
- ld a,b
- add a,5
- cp 101
- ret nc
- ld a,b
- ld l,c
- ld h,0
- ld b,h
- add hl,hl
- add hl,bc
- add hl,hl
- add hl,hl
- ld c,a
- rla
- sbc a,a
- ld b,a
- ld a,c
- sra c
- sra c
- sra c
- add hl,bc
- ld (text_offset),hl
- and 7
- ld (shift_num),a
- #IF draw_logic == _Any
- ld b,a
- ld a,8
- sub b
- ld l,$FF
- ld a,$0F
- scf
- rra
- rr l
- djnz $-3
- ld h,a
- ld (drawmask),hl
- #ENDIF
- ld b,3
- textdrawloop:
- push bc
- ld a,(de)
- #IF allow_invert == yes
- bit textInverse,(iy+textFlags) ;/-----------------------------------\
- jr z,$+3 ;| uncomment to allow inverse text |
- cpl ;\-----------------------------------/
- #ENDIF
- #IF draw_logic < 3
- and $F0 ;or, xor
- #ELSE
- #IF draw_logic == _Erase
- cpl
- #ENDIF
- or $0F ;and, erase
- #ENDIF
- call textrendsub
- ld a,(de)
- #IF allow_invert == yes
- bit textInverse,(iy+textFlags) ;/-----------------------------------\
- jr z,$+3 ;| uncomment to allow inverse text |
- cpl ;\-----------------------------------/
- #ENDIF
- add a,a
- add a,a
- add a,a
- add a,a
- #IF draw_logic == _Erase
- cpl
- or $0F
- #ENDIF
- #IF draw_logic == _AND
- or $0F
- #ENDIF
- call textrendsub
- inc de
- pop bc
- djnz textdrawloop
- ld hl,(text_y)
- ld a,h
- add a,4
- ld h,a
- #IF allow_wrap == yes
- cp 96 ;| uncomment to allow text wrapping |
- #ENDIF
- ld a,l
- #IF allow_wrap == yes
- bit textWrap,(iy+textFlags) ;/-----------------------------------\
- jr z,$+7 ;| |
- jr nc,$+5 ;| uncomment to allow text wrapping |
- ld h,b ;| |
- jr $+5 ;\-----------------------------------/
- #ENDIF
- sub 6
- ld l,a
- #IF allow_wrap == yes
- bit textWrap,(iy+textFlags) ;/-----------------------------------\
- jr z,$+7 ;| |
- cp 64 ;| uncomment to allow text wrapping |
- jr nc,$+3 ;| |
- ld l,b ;\-----------------------------------/
- #ENDIF
- ld (text_y),hl
- ret
- textrendsub:
- push de
- ld d,a
- ld a,(text_y)
- cp 64
- jr nc,norend
- ld a,d
- #IF smc == 1
- text_offset = $+1
- ld de,0
- shift_num = $+2
- #IF draw_logic > 2
- ld bc,$00FF
- #ELSE
- ld bc,0
- or a
- #ENDIF
- #ELSE
- ld de,(text_offset)
- ld bc,(shiftnum-1)
- #IF draw_logic > 2
- ld c,-1
- #ELSE
- ld c,0
- #ENDIF
- #ENDIF
- inc b
- dec b
- jr z,$+7
- rra
- rr c
- djnz $-3
- ld b,a
- ;OR B to (hl), C to (hl+1)
- ld a,(text_x)
- cp 96
- jr nc,norend_half1
- #IF smc == 1
- buf0 = $+1
- ld hl,9340h
- #ELSE
- ld hl,(buf0)
- #ENDIF
- add hl,de
- ld a,(hl)
- #if draw_logic == _OR
- or b
- #elif draw_logic == _XOR
- xor b
- #else
- and b
- #endif
- ld (hl),a
- ld a,(text_x)
- norend_half1:
- add a,4
- cp 96
- jr nc,norend_half2
- inc hl
- ld a,(hl)
- #if draw_logic == _OR
- or c
- #elif draw_logic == _XOR
- xor c
- #else
- and c
- #endif
- ld (hl),a
- norend_half2:
- #if multiple_buffers ==1
- ld a,(text_x)
- cp 96
- jr nc,norend_half3
- #IF smc == 1
- buf1 = $+1
- ld hl,9340h
- #ELSE
- ld hl,(buf1)
- #ENDIF
- add hl,de
- ld a,(hl)
- #if draw_logic == _OR
- or b
- #elif draw_logic == _XOR
- xor b
- #else
- and b
- #endif
- ld (hl),a
- ld a,(text_x)
- norend_half3:
- add a,4
- cp 96
- jr nc,norend_half4
- inc hl
- ld a,(hl)
- #if draw_logic == _OR
- or c
- #elif draw_logic == _XOR
- xor c
- #else
- and c
- #endif
- ld (hl),a
- norend_half4:
- #endif
- ld a,(text_y)
- norend:
- inc a
- ld (text_y),a
- ld hl,(text_offset)
- ld de,12
- add hl,de
- ld (text_offset),hl
- pop de
- ret
- ;===============================================================
- font: ;standard for Grammer, FileSyst, and various others
- ;===============================================================
- ;00~7F
- .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$8C,$EC,$80,$00,$00,$00,$00,$00,$00
- .db $24,$44,$20,$0A,$4A,$00,$00,$EA,$E0,$00,$4E,$40,$00,$04,$00,$00,$E4,$44,$E4,$2C,$00,$EC,$EC,$C0
- .db $65,$5C,$40,$62,$A2,$00,$C2,$4E,$00,$02,$48,$E0,$69,$96,$00,$AC,$88,$00,$E4,$40,$00,$68,$60,$E0
- .db $2E,$4E,$80,$C2,$C0,$E0,$06,$00,$00,$E8,$C8,$E0,$42,$F2,$40,$AD,$DD,$A0,$4E,$44,$40,$44,$4E,$40
- .db $00,$00,$00,$44,$40,$40,$AA,$A0,$00,$00,$00,$00,$00,$00,$00,$A2,$48,$A0,$4A,$4A,$50,$88,$80,$00
- .db $24,$44,$20,$84,$44,$80,$00,$40,$00,$04,$E4,$00,$00,$44,$80,$00,$E0,$00,$00,$00,$80,$22,$48,$80
- ;FontNumbers
- .db $4A,$AA,$40,$4C,$44,$E0,$C2,$48,$E0,$C2,$42,$C0,$AA,$E2,$20,$E8,$C2,$C0,$68,$EA,$E0,$E2,$44,$40,$EA,$EA,$E0,$EA,$E2,$20
- ;3Ah~3Fh
- .db $04,$04,$00,$04,$04,$80,$24,$84,$20,$0E,$0E,$00,$84,$24,$80,$C2,$40,$40
- .db $00,$00,$00,$4A,$EA,$A0,$CA,$CA,$C0,$68,$88,$60,$CA,$AA,$C0,$E8,$C8,$E0,$E8,$C8,$80,$68,$AA,$60
- .db $AA,$EA,$A0,$E4,$44,$E0,$62,$2A,$40,$AA,$CA,$A0,$88,$88,$E0,$AE,$AA,$A0,$CA,$AA,$A0,$EA,$AA,$E0
- .db $CA,$C8,$80,$EA,$AE,$60,$CA,$CA,$A0,$68,$42,$C0,$E4,$44,$40,$AA,$AA,$E0,$AA,$AA,$40,$AA,$AE,$A0
- .db $AA,$4A,$A0,$AA,$44,$40,$E2,$48,$E0,$4A,$EA,$40,$88,$42,$20,$C4,$44,$C0,$4A,$00,$00,$00,$00,$E0
- .db $84,$00,$00,$06,$AA,$60,$88,$CA,$C0,$06,$88,$60,$22,$6A,$60,$04,$AC,$60,$48,$C8,$80,$06,$A6,$2C
- .db $88,$CA,$A0,$40,$44,$40,$20,$22,$A4,$8A,$CA,$A0,$88,$88,$40,$0A,$EA,$A0,$0C,$AA,$A0,$04,$AA,$40
- .db $0C,$AC,$80,$06,$A6,$22,$0A,$C8,$80,$0C,$84,$C0,$4E,$44,$20,$0A,$AA,$E0,$0A,$AA,$40,$0A,$AE,$A0
- .db $0A,$44,$A0,$0A,$A6,$24,$0E,$24,$E0,$64,$84,$60,$44,$44,$40,$C4,$24,$C0,$05,$A0,$00,$E0,$E0,$E0
- ;FontNumbers2
- .db $04,$AA,$A4,$04,$C4,$4E,$0C,$24,$8E,$0C,$24,$2C,$0A,$AE,$22,$0E,$8C,$2C,$06,$8E,$AE,$0E,$24,$44
- .db $0E,$AE,$AE,$0E,$AE,$22
- ;Accented A
- .db $24,$AE,$A0,$84,$AE,$A0,$00,$00,$00,$A4,$AE,$A0
- ;Accented a
- .db $24,$06,$A5,$42,$06,$A5,$4A,$06,$A5,$A0,$6A,$60
- ;Accented E
- .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- ;Accented e
- .db $48,$4A,$C6,$42,$4A,$C6,$4A,$4A,$C6,$A0,$4A,$C6
- ;Accented I
- .db $24,$0E,$4E,$84,$0E,$4E,$4A,$0E,$4E,$A0,$E4,$E0
- ;Accented i
- .db $24,$04,$44,$84,$04,$44,$4A,$04,$44,$A0,$44,$40
- ;Bombs... er, accented O
- .db $24,$69,$96,$84,$69,$96,$4A,$69,$96,$A0,$69,$96
- ;Lowercase bombs
- .db $24,$06,$96,$84,$06,$96,$4A,$06,$96,$A0,$06,$96
- ;Accented U
- .db $24,$AA,$A6,$84,$AA,$A6,$4A,$AA,$A6,$A0,$AA,$A6
- ;Accented u
- .db $24,$0A,$A6,$84,$0A,$A6,$4A,$0A,$A6,$A0,$0A,$A6
- ;Accented C,c,N,n
- .db $4A,$8A,$48,$06,$88,$6C,$5A,$0C,$AA,$5A,$0C,$AA
- ;Other Puntuation
- .db $24,$00,$00,$84,$00,$00,$A0,$00,$00,$40,$48,$60
- ;Upside-Down Exclamation Point Identical to lowercase i
- ;Change to something else?
- .db $00,$00,$00
- ;Greek
- .db $05,$AA,$50,$25,$65,$A0,$05,$A2,$20,$00,$4A,$E0,$34,$27,$96,$68,$E8,$60
- ;[
- .db $64,$44,$60
- ;Greek (continued)
- .db $84,$25,$90,$0A,$AD,$80,$0F,$55,$90,$25,$56,$48,$F4,$24,$F0
- .db $07,$55,$40,$07,$A2,$10
- ;Idunno howta do these
- .db $4E,$AE,$40,$69,$99,$69
- ;CC~CF
- .db $E0,$A4,$A0,$E0,$A6,$24,$52,$50,$00,$00,$00,$A0,$26,$E6,$20
- ;D0~D5
- .db $44,$40,$00,$22,$48,$80,$00,$60,$00,$C4,$8C,$00,$EA,$E0,$00,$E4,$2C,$00
- ;D6
- .db $00,$00,$00
- ;D7~DF
- .db $40,$44,$20,$04,$CA,$C8,$8A,$4A,$20,$E9,$AE,$A8,$69,$E8,$60,$00,$44,$60,$9D,$FB,$90,$A5,$55,$A0,$4E,$FE,$40
- ;Overwrite Cursor
- .db $FF,$FF,$FF,$FB,$1B,$BF,$FB,$51,$5F,$FF,$95,$9F
- ;Insert Cursor
- .db $00,$00,$0F,$4E,$EE,$0F,$4A,$EA,$0F,$06,$A6,$0F
- ;E8~EF
- .db $00,$84,$20,$00,$C6,$20,$00,$E6,$20,$00,$8C,$E0,$25,$D5,$20,$4A,$AA,$40,$4E,$44,$40
- ;F0~F4
- .db $44,$4E,$40,$5A,$5A,$5A,$27,$A6,$3E,$4E,$44,$00,$69,$A9,$A0
- ;male/female
- .db $73,$5E,$AE,$EA,$E4,$E4
- ;BlockEater Down $F7
- .db $6F,$96,$90
- ;BlockEater Left $F8
- .db $6F,$16,$90
- ;BlockEater Right $F9
- .db $6F,$86,$90
- ;BlockEater Up $FA
- .db $69,$96,$90
- ;FB~FE
- .db $09,$AC,$E0,$08,$53,$70,$EC,$A1,$00,$73,$58,$00
- ;FF
- .db $A5,$A5,$A5
- .echo $-$9D95
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement