Author Topic: [Routine] Monospaced Text  (Read 3409 times)

0 Members and 1 Guest are viewing this topic.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
[Routine] Monospaced Text
« on: January 02, 2011, 02:25:53 am »
Here is a monospaced text routine I made :)
Code: [Select]
;Monospaced text
;inputs: penRow=y, penCol=x, hl=pointer to null (0) terminated text
DrawMonospaceString:
ld a, (hl)
inc hl
cp '\n'
jr z, monoWrapLine
cp '\r'
jr z, monoWrapLine
cp '\t'
jr z,monoTab
or a
ret z
push af
ld a,(penCol)
ld b,a
pop af
push bc
b_call _VPutMap
pop bc
ld a,b
add a,6
ld (penCol),a
cp 92
jr nc,monoWrapLine
jr DrawMonospaceString
monoTab:
ld a,(penCol)
add a,12
ld (penCol),a
cp 55
call nc,Newline
jr DrawMonospaceString
monoWrapLine:
call Newline
jr DrawMonospaceString
;newline, wrapps screen if necessary
;preserves af
Newline:
push af
xor a
ld (penCol),a
ld a,(penRow)
add a, 6
cp 55
jr nc,NewLine_top
ld (penRow),a
pop af
ret
NewLine_top:
xor a
ld (penRow),a
pop af
ret
It also parses \n and \r as a newline, which it wraps to the top of the screen if you go off the edge. \t is replaced with a double space as well. Hope some people find this useful :)
(Oh and credit goes to SirCmpwn because I got a bunch of the code from KOS, but it is modified for TI-OS's font and to make it monospaced. I use this in TBP for text input)

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
Re: [Routine] Monospaced Text
« Reply #1 on: January 02, 2011, 02:34:49 am »
Pretty nifty Eeems!
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [Routine] Monospaced Text
« Reply #2 on: January 02, 2011, 02:36:20 am »
Thanks :) I hope someone has some use for it, or some ways to make it better :P

edit: oh and I forgot to mention, it also wraps the text when it reaches the edge of the screen :)
« Last Edit: January 02, 2011, 02:36:50 am by Eeems »
/e

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: [Routine] Monospaced Text
« Reply #3 on: January 02, 2011, 03:22:25 am »
Nice!  Does it wrap text by letters or words?

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [Routine] Monospaced Text
« Reply #4 on: January 02, 2011, 04:31:37 am »
Letters. Words would require a much larger routine.
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Routine] Monospaced Text
« Reply #5 on: January 03, 2011, 07:36:50 pm »
Nice, this should hopefully be useful for other ASM coders. :D

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [Routine] Monospaced Text
« Reply #6 on: January 05, 2011, 03:36:17 am »
Yeah :) that's my hope :)
I like making these little routines I make available to others. Maybe I should release my menu code for TBP too, since it makes making menus pretty simple.
Code: [Select]
Menu:
 .db "Menu",0,2
 .db "Item 1",0
 .db "Item 2",0
 .dw Item_1_goto
 .dw Item_2_goto
 .dw clear_button_goto
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Routine] Monospaced Text
« Reply #7 on: January 05, 2011, 04:47:26 am »
That looks quite easy to read actually, code-wise.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [Routine] Monospaced Text
« Reply #8 on: January 05, 2011, 10:57:14 am »
Yep :) Takes up hardly any space too :)
/e