Advertisement
Zeda

putS

Feb 27th, 2015
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;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.
  2.  
  3. ;;included routines:
  4. ;;text_y, text_x are the coords
  5. ;;(buf0) and (buf1) are the buffers to draw to
  6. ;;dispC: A is the char to draw.
  7. ;;putString: HL points to the zero-terminated string. Ex. .db "Hello",0
  8. ;;zPutString: The string directly follows the call.
  9. ;;          Ex.
  10. ;;              call zPutString
  11. ;;              .db "Hello",0
  12.  
  13.  
  14. smc = 1
  15.  
  16. yes = 1
  17. no  = 0
  18. _OR  = 0
  19. _XOR = 1
  20. _AND = 2
  21. _Erase = 3
  22. _Any = -1               ;***Not Implemented***
  23. allow_fonts     = no    ;can use multiple fonts during program use
  24. multiple_buffers= yes
  25. draw_logic      = _OR
  26. allow_invert    = no
  27. allow_wrap      = no
  28. allow_windows   = no    ;***Not Implemented***
  29. #IF smc == 0
  30. fontloc     = 8000h
  31. text_y      = 8002h
  32. text_x      = 8003h
  33. text_offset = 8004h
  34. shift_num   = 8006h
  35. #IF draw_logic == _Any
  36. drawmask    = 8007h
  37. #ENDIF
  38. #ENDIF
  39.  
  40. .db $BB,$6D
  41. .org $9D95
  42. text_disp_test:
  43. loop:
  44.     call zPutString
  45.     .db "Hello World! Tatertatertater moo",0
  46. ;    ld hl,(text_y)
  47. ;    inc l
  48. ;    ld a,l
  49. ;    add a,a
  50. ;    add a,l
  51. ;    ld h,a
  52. ;    ld (text_y),hl
  53. ;    jr nz,loop
  54.     ret
  55.  
  56. zPutString:
  57.     ex (sp),hl
  58.     push af
  59.     push bc
  60.     push de
  61.     call putString
  62.     pop de
  63.     pop bc
  64.     pop af
  65.     ex (sp),hl
  66.     ret
  67. putString:
  68. ;;Input:
  69. ;;  HL points to the zero-terminated string to draw.
  70. ;;  (text_x) is the x coordinate
  71. ;;  (text_y) is the y coordinate
  72. ;;  (buf0) points to a buffer to draw to
  73. ;;  (buf1) points to a buffer to draw to
  74. ;;Output:
  75. ;;  Draws the string to the screen.
  76. ;;  HL points to the byte after the null-terminated string.
  77. ;;  A=0
  78.     ld a,(hl)
  79.     inc hl
  80.     or a
  81.     ret z
  82.     push hl
  83.     call dispC
  84.     pop hl
  85.     jp putString
  86. dispC:
  87. ;;Inputs: A is the char to draw
  88. ;;  (text_x) is the x coordinate
  89. ;;  (text_y) is the y coordinate
  90. ;;  (buf0) points to a buffer to draw to
  91. ;;  (buf1) points to a buffer to draw to
  92. ;;  (fontloc) points to the font data
  93. ;;Outputs:
  94. ;;  Text is drawn to the buf with OR logic
  95. ;;  text_x and text_y are updated accordingly
  96. ;;Notes:
  97. ;;  Performs proper clipping.
  98. ;;  Uses a nibble-packed monospace font of 4 pixels wide, 6 pixels tall.
  99. ;;  Somewhat portable on monochrome TI calculators
  100. ;;=====================================================
  101. ;;initialize variables to suit your needs
  102. ;;=====================================================
  103.     ld h,0
  104.     ld l,a
  105.     add hl,hl
  106.     add a,l
  107.     ld l,a
  108.     jr nc,$+3
  109.     inc h
  110. #IF (smc == 1) | (allow_fonts == no)
  111. fontloc = $+1
  112.     ld de,font
  113. #ELSE
  114.     ld de,(fontloc)
  115. #ENDIF
  116.    
  117.     add hl,de
  118.     ex de,hl
  119. #IF smc == 1
  120. text_y = $+1
  121. text_x = $+2
  122.     ld bc,$0303
  123. #ELSE
  124.     ld bc,(text_y)
  125. #ENDIF
  126.     ld a,c
  127.     add a,3
  128.     cp 67
  129.     ret nc
  130.     ld a,b
  131.     add a,5
  132.     cp 101
  133.     ret nc
  134.  
  135.     ld a,b
  136.     ld l,c
  137.     ld h,0
  138.     ld b,h
  139.     add hl,hl
  140.     add hl,bc
  141.     add hl,hl
  142.     add hl,hl
  143.     ld c,a
  144.     rla
  145.     sbc a,a
  146.     ld b,a
  147.     ld a,c
  148.     sra c
  149.     sra c
  150.     sra c
  151.     add hl,bc
  152.     ld (text_offset),hl
  153.     and 7
  154.     ld (shift_num),a
  155. #IF draw_logic == _Any
  156.     ld b,a
  157.     ld a,8
  158.     sub b
  159.     ld l,$FF
  160.     ld a,$0F
  161.     scf
  162.     rra
  163.     rr l
  164.     djnz $-3
  165.     ld h,a
  166.     ld (drawmask),hl
  167. #ENDIF
  168.     ld b,3
  169. textdrawloop:
  170.     push bc
  171.     ld a,(de)
  172. #IF allow_invert == yes
  173.     bit textInverse,(iy+textFlags) ;/-----------------------------------\
  174.     jr z,$+3                       ;|  uncomment to allow inverse text  |
  175.     cpl                            ;\-----------------------------------/
  176. #ENDIF
  177. #IF draw_logic < 3
  178.     and $F0   ;or, xor
  179. #ELSE
  180. #IF draw_logic == _Erase
  181.     cpl
  182. #ENDIF
  183.     or $0F    ;and, erase
  184. #ENDIF
  185.     call textrendsub
  186.     ld a,(de)
  187. #IF allow_invert == yes
  188.     bit textInverse,(iy+textFlags) ;/-----------------------------------\
  189.     jr z,$+3                       ;|  uncomment to allow inverse text  |
  190.     cpl                            ;\-----------------------------------/
  191. #ENDIF
  192.     add a,a
  193.     add a,a
  194.     add a,a
  195.     add a,a
  196. #IF draw_logic == _Erase
  197.     cpl
  198.     or $0F
  199. #ENDIF
  200. #IF draw_logic == _AND
  201.     or $0F
  202. #ENDIF
  203.     call textrendsub
  204.     inc de
  205.     pop bc
  206.     djnz textdrawloop
  207.     ld hl,(text_y)
  208.     ld a,h
  209.     add a,4
  210.     ld h,a
  211. #IF allow_wrap == yes
  212.     cp 96                          ;|  uncomment to allow text wrapping |
  213. #ENDIF
  214.     ld a,l
  215. #IF allow_wrap == yes
  216.     bit textWrap,(iy+textFlags)    ;/-----------------------------------\
  217.     jr z,$+7                       ;|                                   |
  218.     jr nc,$+5                      ;|  uncomment to allow text wrapping |
  219.     ld h,b                         ;|                                   |
  220.     jr $+5                         ;\-----------------------------------/
  221. #ENDIF
  222.     sub 6
  223.     ld l,a
  224. #IF allow_wrap == yes
  225.     bit textWrap,(iy+textFlags)    ;/-----------------------------------\
  226.     jr z,$+7                       ;|                                   |
  227.     cp 64                          ;|  uncomment to allow text wrapping |
  228.     jr nc,$+3                      ;|                                   |
  229.     ld l,b                         ;\-----------------------------------/
  230. #ENDIF
  231.     ld (text_y),hl
  232.     ret
  233. textrendsub:
  234.     push de
  235.     ld d,a
  236.     ld a,(text_y)
  237.     cp 64
  238.     jr nc,norend
  239.    
  240.     ld a,d
  241. #IF smc == 1
  242. text_offset = $+1
  243.     ld de,0
  244. shift_num = $+2
  245. #IF draw_logic > 2
  246.     ld bc,$00FF
  247. #ELSE
  248.     ld bc,0
  249.     or a
  250. #ENDIF
  251. #ELSE
  252.     ld de,(text_offset)
  253.     ld bc,(shiftnum-1)
  254. #IF draw_logic > 2
  255.     ld c,-1
  256. #ELSE
  257.     ld c,0
  258. #ENDIF
  259. #ENDIF
  260.     inc b
  261.     dec b
  262.     jr z,$+7
  263.     rra
  264.     rr c
  265.     djnz $-3
  266.     ld b,a
  267. ;OR B to (hl), C to (hl+1)
  268.  
  269.     ld a,(text_x)
  270.     cp 96
  271.     jr nc,norend_half1
  272. #IF smc == 1
  273. buf0 = $+1
  274.     ld hl,9340h
  275. #ELSE
  276.     ld hl,(buf0)
  277. #ENDIF
  278.     add hl,de
  279.     ld a,(hl)
  280. #if draw_logic == _OR
  281.     or b
  282. #elif draw_logic == _XOR
  283.     xor b
  284. #else
  285.     and b
  286. #endif
  287.     ld (hl),a    
  288.     ld a,(text_x)
  289. norend_half1:
  290.     add a,4
  291.     cp 96
  292.     jr nc,norend_half2
  293.     inc hl
  294.     ld a,(hl)
  295. #if draw_logic == _OR
  296.     or c
  297. #elif draw_logic == _XOR
  298.     xor c
  299. #else
  300.     and c
  301. #endif
  302.     ld (hl),a
  303. norend_half2:
  304. #if multiple_buffers ==1
  305.     ld a,(text_x)
  306.     cp 96
  307.     jr nc,norend_half3
  308. #IF smc == 1
  309. buf1 = $+1
  310.     ld hl,9340h
  311. #ELSE
  312.     ld hl,(buf1)
  313. #ENDIF
  314.     add hl,de
  315.     ld a,(hl)
  316. #if draw_logic == _OR
  317.     or b
  318. #elif draw_logic == _XOR
  319.     xor b
  320. #else
  321.     and b
  322. #endif
  323.     ld (hl),a    
  324.     ld a,(text_x)
  325. norend_half3:
  326.     add a,4
  327.     cp 96
  328.     jr nc,norend_half4
  329.     inc hl
  330.     ld a,(hl)
  331. #if draw_logic == _OR
  332.     or c
  333. #elif draw_logic == _XOR
  334.     xor c
  335. #else
  336.     and c
  337. #endif
  338.     ld (hl),a
  339. norend_half4:
  340. #endif
  341.  
  342.     ld a,(text_y)
  343. norend:
  344.     inc a
  345.     ld (text_y),a
  346.     ld hl,(text_offset)
  347.     ld de,12
  348.     add hl,de
  349.     ld (text_offset),hl
  350.     pop de
  351.     ret
  352.    
  353. ;===============================================================
  354. font:    ;standard for Grammer, FileSyst, and various others
  355. ;===============================================================
  356. ;00~7F
  357. .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
  358. .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
  359.  
  360. .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
  361. .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
  362.  
  363. .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
  364. .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
  365.  
  366. ;FontNumbers
  367. .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
  368.  
  369. ;3Ah~3Fh
  370. .db $04,$04,$00,$04,$04,$80,$24,$84,$20,$0E,$0E,$00,$84,$24,$80,$C2,$40,$40
  371.  
  372. .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
  373. .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
  374. .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
  375. .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
  376. .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
  377. .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
  378. .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
  379. .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
  380.  
  381. ;FontNumbers2
  382. .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
  383. .db $0E,$AE,$AE,$0E,$AE,$22
  384.  
  385. ;Accented A
  386. .db $24,$AE,$A0,$84,$AE,$A0,$00,$00,$00,$A4,$AE,$A0
  387.  
  388. ;Accented a
  389. .db $24,$06,$A5,$42,$06,$A5,$4A,$06,$A5,$A0,$6A,$60
  390.  
  391. ;Accented E
  392. .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  393.  
  394. ;Accented e
  395. .db $48,$4A,$C6,$42,$4A,$C6,$4A,$4A,$C6,$A0,$4A,$C6
  396.  
  397. ;Accented I
  398. .db $24,$0E,$4E,$84,$0E,$4E,$4A,$0E,$4E,$A0,$E4,$E0
  399.  
  400. ;Accented i
  401. .db $24,$04,$44,$84,$04,$44,$4A,$04,$44,$A0,$44,$40
  402.  
  403. ;Bombs... er, accented O
  404. .db $24,$69,$96,$84,$69,$96,$4A,$69,$96,$A0,$69,$96
  405.  
  406. ;Lowercase bombs
  407. .db $24,$06,$96,$84,$06,$96,$4A,$06,$96,$A0,$06,$96
  408.  
  409. ;Accented U
  410. .db $24,$AA,$A6,$84,$AA,$A6,$4A,$AA,$A6,$A0,$AA,$A6
  411.  
  412. ;Accented u
  413. .db $24,$0A,$A6,$84,$0A,$A6,$4A,$0A,$A6,$A0,$0A,$A6
  414.  
  415. ;Accented C,c,N,n
  416. .db $4A,$8A,$48,$06,$88,$6C,$5A,$0C,$AA,$5A,$0C,$AA
  417.  
  418. ;Other Puntuation
  419. .db $24,$00,$00,$84,$00,$00,$A0,$00,$00,$40,$48,$60
  420.  
  421. ;Upside-Down Exclamation Point Identical to lowercase i
  422. ;Change to something else?
  423. .db $00,$00,$00
  424.  
  425. ;Greek
  426. .db $05,$AA,$50,$25,$65,$A0,$05,$A2,$20,$00,$4A,$E0,$34,$27,$96,$68,$E8,$60
  427.  
  428. ;[
  429. .db $64,$44,$60
  430.  
  431. ;Greek (continued)
  432. .db $84,$25,$90,$0A,$AD,$80,$0F,$55,$90,$25,$56,$48,$F4,$24,$F0
  433. .db $07,$55,$40,$07,$A2,$10
  434. ;Idunno howta do these
  435. .db $4E,$AE,$40,$69,$99,$69
  436.  
  437. ;CC~CF
  438. .db $E0,$A4,$A0,$E0,$A6,$24,$52,$50,$00,$00,$00,$A0,$26,$E6,$20
  439.  
  440. ;D0~D5
  441. .db $44,$40,$00,$22,$48,$80,$00,$60,$00,$C4,$8C,$00,$EA,$E0,$00,$E4,$2C,$00
  442.  
  443. ;D6
  444. .db $00,$00,$00
  445.  
  446. ;D7~DF
  447. .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
  448.  
  449. ;Overwrite Cursor
  450. .db $FF,$FF,$FF,$FB,$1B,$BF,$FB,$51,$5F,$FF,$95,$9F
  451.  
  452. ;Insert Cursor
  453. .db $00,$00,$0F,$4E,$EE,$0F,$4A,$EA,$0F,$06,$A6,$0F
  454.  
  455. ;E8~EF
  456. .db $00,$84,$20,$00,$C6,$20,$00,$E6,$20,$00,$8C,$E0,$25,$D5,$20,$4A,$AA,$40,$4E,$44,$40
  457.  
  458. ;F0~F4
  459. .db $44,$4E,$40,$5A,$5A,$5A,$27,$A6,$3E,$4E,$44,$00,$69,$A9,$A0
  460.  
  461. ;male/female
  462. .db $73,$5E,$AE,$EA,$E4,$E4
  463.  
  464. ;BlockEater Down    $F7
  465. .db $6F,$96,$90
  466. ;BlockEater Left        $F8
  467. .db $6F,$16,$90
  468. ;BlockEater Right       $F9
  469. .db $6F,$86,$90
  470. ;BlockEater Up          $FA
  471. .db $69,$96,$90
  472.  
  473. ;FB~FE
  474. .db $09,$AC,$E0,$08,$53,$70,$EC,$A1,$00,$73,$58,$00
  475.  
  476. ;FF
  477. .db $A5,$A5,$A5
  478. .echo $-$9D95
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement