Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 KB | None | 0 0
  1. #include "CorrelationOutputTextSharedCode.asm"
  2.  
  3. CorrelationOutput:
  4.  
  5. ;HL is the number of arguments.
  6.  
  7. ld a, l
  8.  
  9. ;See if there are 3 or 4 arguments, otherwise the parser
  10. ;can take over
  11.  
  12. cp 3
  13.  
  14. jr z, ++_
  15.  
  16. ;Parse Normally
  17.  
  18. _
  19.  
  20.  
  21. cp a
  22. ret
  23.  
  24. _
  25.  
  26.  
  27.  
  28. ld a, (Character_Height)
  29. cp 8
  30. jp nz, Wrong_Size_Error
  31. ld a, (Character_Width)
  32. cp 6
  33. jp nz, Wrong_Size_Error
  34.  
  35. ld a, (OutputOrText)
  36.  
  37. ;If A = 0, We were using ln(.
  38.  
  39.  
  40. or a
  41. jr nz, SixBitMode ;We don't
  42. ;need to copy
  43. ;Output( code
  44. ;to StatVars.
  45.  
  46. inc a
  47. ld (OutputOrText), a
  48.  
  49. ld hl, Put_Text_Into_Buffer_Start
  50. ld de, StatVars
  51. ld bc, Put_Text_Into_Buffer_End - Put_Text_Into_Buffer_Start
  52. ldir
  53.  
  54. ;The only thing we can display immediately is
  55. ;a 6x8 font. Set the display to work with
  56. ;6-bit mode.
  57.  
  58. SixBitMode:
  59.  
  60. in a, ($10)
  61. rla
  62. jr c, SixBitMode
  63.  
  64. xor a
  65. out ($10), a
  66.  
  67.  
  68.  
  69. call OutputTextShared
  70.  
  71.  
  72.  
  73.  
  74. jr c, NegativeNumberOutputY
  75.  
  76.  
  77. or a
  78. jr z, ++_
  79. cp 17
  80. jr c, ContinueOutputPart3
  81.  
  82. _
  83. bjump(_ErrDomain)
  84.  
  85.  
  86. _
  87.  
  88. ld bc, 0 ;For a coordinate of 0, interpret it as
  89. ;-1
  90.  
  91.  
  92. NegativeNumberOutputY:
  93.  
  94. inc bc
  95.  
  96. ;BC contains the amount to multiply by 16.
  97.  
  98.  
  99. sla c \ rl b
  100. sla c \ rl b
  101. sla c \ rl b
  102. sla c \ rl b
  103.  
  104. ld (StringAdjuster), bc
  105. ld a, 1
  106.  
  107.  
  108.  
  109.  
  110.  
  111. ContinueOutputPart3:
  112.  
  113.  
  114. dec a
  115.  
  116.  
  117. ld (TextBufferX), a
  118.  
  119.  
  120. ;If we are in Map Mode,
  121. ;1. Put TextBufferX into MapX
  122. ; Reminder to self: MapX is the X coordinate
  123. ; because in Map Mode, text does not necessarily
  124. ; move to the front of the screen
  125. ;2. The number of characters to skip will be
  126. ; (ThetaStep + 2) - 16 + MapX
  127.  
  128.  
  129. ld a, (TextBufferX)
  130. ld (MapX), a
  131.  
  132. ld a, (ThetaStep + 2)
  133. sub 16
  134. ld b, a
  135. ld a, (MapX)
  136. add a, b
  137.  
  138. ld bc, (StringAdjuster)
  139. add a, c
  140.  
  141. ld (NumberOfCharactersToSkip), a
  142.  
  143.  
  144.  
  145.  
  146.  
  147. ;Go to the next number, the Y Coordinate.
  148.  
  149. ld de, -11
  150. add hl, de
  151.  
  152. call CodeToCall1
  153.  
  154.  
  155.  
  156. jr c, NegativeNumberOutputX
  157.  
  158. or a
  159. jr z, ++_
  160. cp 9
  161. jr c, EmergencyLocalLabel3
  162.  
  163. _
  164. bjump(_ErrDomain)
  165.  
  166.  
  167. _
  168.  
  169. ld bc, 0 ;For a coordinate of 0, interpret it as
  170. ;-1
  171.  
  172.  
  173. NegativeNumberOutputX:
  174.  
  175. inc bc
  176.  
  177.  
  178.  
  179. ex de, hl
  180. ld hl, (StringAdjuster)
  181. add hl, bc
  182.  
  183. ld (StringAdjuster), hl
  184. ex de, hl
  185.  
  186. ld a, 1
  187.  
  188. EmergencyLocalLabel3:
  189.  
  190. dec a
  191.  
  192. ld (TextBufferY), a
  193.  
  194. rlca \ rlca \ rlca
  195.  
  196. ld (penRow), a
  197. jp ContinueOutputPart4
  198.  
  199.  
  200. Wrong_Size_Error:
  201.  
  202.  
  203. ld hl, ErrorWrongSize
  204. ld de, appErr1
  205. ld bc, 11
  206. ldir
  207.  
  208. B_CALL $4D41
  209.  
  210. ErrorWrongSize:
  211.  
  212. .db "WRONG SIZE", 0
  213.  
  214. Put_Text_Into_Buffer_Start:
  215.  
  216. relocate(statVars)
  217.  
  218. Put_Text_Into_Buffer:
  219.  
  220.  
  221.  
  222. ld a, (FontPage)
  223. or a
  224. jr z, _
  225.  
  226.  
  227. out (6), a
  228.  
  229. _
  230.  
  231.  
  232. ;hl is the text to display. The text must end ;in azero.
  233. ;PenRow and PenCol are the X, Y coordinates.
  234.  
  235. ld bc, (StringAdjuster)
  236.  
  237.  
  238. add hl, bc
  239.  
  240.  
  241.  
  242. ;For 6x8 text, text will only be displayed to the
  243. ;buffer unless we want it to be displayed immediately.
  244. ;For the sake of speed, Word Wrap is not a
  245. ;consideration. Neither are windows and lowercase letters.
  246. ;Animated tiles are allowed, but are not needed for simply putting
  247. ;text in the buffer, since animated text is taken care of only
  248. ;when pictures are updated
  249.  
  250. ;HL points to the string to draw. Save the
  251. ;value temporarily.
  252.  
  253. push hl
  254.  
  255. ;DE will hold the position in the text buffer
  256. ;to copy text.
  257.  
  258. ld a, (TextBufferY)
  259.  
  260. ;Multiply TextBufferY by 16.
  261.  
  262. rlca \ rlca \ rlca \ rlca
  263.  
  264. ld hl, CorrelationTextBuffer
  265. ld d, 0
  266. ld e, a
  267. add hl, de
  268. ld a, (TextBufferX)
  269. ld e, a
  270. add hl, de
  271. ex de, hl
  272. pop hl
  273.  
  274. ;DE now points to the text buffer, hl to the text.
  275.  
  276.  
  277.  
  278.  
  279. Read_Text_Loop_Homescreen:
  280.  
  281. ;Save the location where text will be placed in
  282. ;the buffer
  283.  
  284. push de
  285.  
  286.  
  287. ld de, (String_Length)
  288.  
  289. ld a, d
  290. or e
  291.  
  292. jp z, QuitDisplayingFontHomescreen
  293.  
  294. dec de
  295. ld (String_Length), de
  296.  
  297.  
  298. ;See if this value is greater than 16. If so, either stop drawing
  299. ;or wrap
  300.  
  301.  
  302. ld a, (TextBufferX)
  303. cp 16
  304. jr c, PenColFinalizedHomescreen
  305.  
  306.  
  307. xor a
  308. ld (TextBufferX), a
  309.  
  310.  
  311. ld a, (Display_Mode)
  312. cp 1 ;Clip the sprite?
  313.  
  314. jp z, QuitDisplayingFontHomescreen
  315.  
  316. WrapTextHomescreen:
  317.  
  318. ;Wrap to the next row. Take the height of the characters, and add it
  319. ;to the PenRow
  320.  
  321.  
  322.  
  323.  
  324. ld a, (TextBufferY)
  325.  
  326.  
  327.  
  328.  
  329. ;If a is greater than 63, don't display anymore text.
  330.  
  331. cp 8
  332.  
  333. jp nc, QuitDisplayingFontHomescreen
  334.  
  335. inc a
  336.  
  337. _
  338.  
  339. ld (TextBufferY), a
  340.  
  341.  
  342.  
  343. ;If in MapMode, go to proper text in HL.
  344.  
  345.  
  346. ld a, (Display_Mode)
  347. cp Map
  348. jr nz, PenColFinalizedHomescreen
  349.  
  350. ld d, 0
  351. ld a, (CharactersToSkip)
  352. ld e, a
  353.  
  354. add hl, de
  355. push hl
  356. ld hl, (String_Length)
  357. or a
  358. sbc hl, de
  359. ld (String_Length), hl
  360. pop hl
  361. jp c, QuitDisplayingFontHomescreen
  362.  
  363.  
  364. ld a, (TextBufferX)
  365.  
  366. PenColFinalizedHomescreen:
  367.  
  368.  
  369.  
  370. ;Our goal is to increase PenCol to the position of the character
  371. ;after the one we are currently working with
  372.  
  373. ld c, a ;Saves the pencol coordinates
  374.  
  375. ABCHomescreen:
  376.  
  377. in a, ($10)
  378. rla
  379. jr c, ABCHomescreen
  380.  
  381.  
  382. ;Output the X Coordinate. THIS IS SMC, since
  383. ;instead this might be dividing by six instead of
  384. ;eight. Instead of srl a 3 times, it would be
  385. ;call divide by 6.
  386.  
  387. ld a, c
  388. add a, $20
  389. out ($10), a
  390.  
  391.  
  392. ld a, c
  393. inc a
  394. ld (TextBufferX), a
  395.  
  396.  
  397. Draw_TextHomescreen:
  398.  
  399. ld a, (hl)
  400.  
  401.  
  402. ;-------------------------------
  403. ;THIS IS SMC. CONDITION:
  404. ;If Error Checking off, skip.
  405. ;If Animated Tiles Off, skip.
  406. ;If lowercase off, skip.
  407. ;-------------------------------
  408.  
  409.  
  410.  
  411. ;See if the character is one that cannot
  412. ;be used inside of a string
  413.  
  414. cp $26
  415. jp z, Not_Allowed
  416. cp $3F
  417. jp z, Not_Allowed
  418. cp $5C
  419. jr c, _
  420. cp $5F
  421. jp c, Not_Allowed
  422.  
  423. _
  424.  
  425. cp $60
  426. jr c, _
  427. cp $54
  428. jp c, Not_Allowed
  429.  
  430. _
  431.  
  432. cp $7E
  433. jp z, Not_Allowed
  434. cp $AA
  435. jp z, Not_Allowed
  436. cp $BB
  437.  
  438. jp nz, Check116
  439. jp NoLowerInOutput
  440.  
  441. Check116:
  442. cp $EF
  443. jp z, Not_Allowed
  444.  
  445.  
  446. push hl
  447.  
  448. ;Check to see if the character is greater than
  449. ;the maximum value, to avoid displaying garbage
  450.  
  451. ld d, a
  452. ld hl, Ending_Character
  453.  
  454. ;If the maximum value is 255,
  455. ;the user cannot go over the limit.
  456.  
  457. ld a, (hl)
  458. cp 255
  459.  
  460. jr z, EmergencyLocalLabel88
  461.  
  462. ;If the maximum value is not 255, it
  463. ;is 254 or less. So we increase the
  464. ;maximum value to 255 to check for
  465. ;the C flag, since it does >= instead
  466. ;of simply >.
  467.  
  468.  
  469. inc (hl)
  470. ld a, d
  471. cp (hl)
  472. jp nc, Out_Of_Range
  473. dec (hl)
  474.  
  475. ld hl, Starting_Character
  476. sub (hl)
  477.  
  478. jp c, Out_Of_Range
  479.  
  480. EmergencyLocalLabel88:
  481.  
  482.  
  483.  
  484. ld a, d
  485.  
  486.  
  487.  
  488. DoneWithLowerCaseHomescreen:
  489.  
  490.  
  491. ;If we are not displaying immediately, go to the next character.
  492.  
  493. pop hl
  494. pop de
  495. ld (de), a
  496. inc de
  497. inc hl
  498.  
  499.  
  500.  
  501. bit CopyOneCharacter, (IY + asm_flag1)
  502. jp z, Read_Text_Loop_Homescreen
  503.  
  504.  
  505. push hl
  506. push de
  507. push af
  508. ld a, (TextBufferY)
  509. rlca \ rlca \ rlca
  510. add a, $80
  511.  
  512.  
  513. ld c, $10
  514. ABCHomescreen2:
  515.  
  516. in b, (c)
  517. rl b
  518. jr c, ABCHomescreen
  519.  
  520. out (c), a
  521. pop af
  522.  
  523. DisplayHomescreenCharacterImmediately:
  524.  
  525. ;If animated tiles are allowed, we might need to
  526. ;draw a different character for whatever is inside
  527. ;of register A
  528.  
  529. cp tRad
  530. jr c, CannotAnimateTileHomescreen
  531.  
  532. cp tShade
  533. jr nc, CannotAnimateTileHomescreen
  534.  
  535. ;bit AnimateTiles, (IY + asm_flag1)
  536. ;jr z, CannotAnimateTile
  537.  
  538. AnimatedTilesHomescreen:
  539.  
  540.  
  541. push af
  542.  
  543. ld hl, Starting_Character
  544. sub (hl)
  545.  
  546. ld hl, AnimatedTileData + 1
  547. add a, a
  548. call Add_A_To_HL
  549.  
  550. pop af
  551. add a, (hl)
  552.  
  553. ;AT this point, A goes into the text buffer.
  554.  
  555.  
  556.  
  557.  
  558. CannotAnimateTileHomescreen:
  559.  
  560. ld hl, Starting_Character
  561. sub (hl)
  562.  
  563. ld d, 0
  564. ld e, 8
  565. Call Multiply_DE_By_A
  566.  
  567.  
  568. ld de, (FontLocation)
  569. add hl, de
  570.  
  571. ld b, 8 ;8 rows to draw
  572. ld c, $10
  573. ld a, (hl)
  574. rrca \ rrca
  575. ;HL points to the font location. We only need
  576. ;put (hl) into a in order to put a to port ($11)
  577.  
  578.  
  579. Put_Character_6x8:
  580.  
  581. in d, (c)
  582. rl d
  583. jr c, Put_Character_6x8
  584.  
  585. out ($11), a
  586. inc hl
  587. ld a, (hl)
  588. rrca \ rrca
  589. djnz Put_Character_6x8
  590.  
  591. pop de
  592. pop hl
  593.  
  594. jp Read_Text_Loop_Homescreen
  595.  
  596.  
  597. QuitDisplayingFontHomescreen:
  598.  
  599. pop de
  600. ld a, (ApplicationPageLocation)
  601. out (6), a
  602. ld a, (Display_Mode)
  603. cp WordWrap
  604. ret z
  605. res LowerCaseMode, (IY + asm_flag1)
  606.  
  607. ret
  608.  
  609. NoLowerInOutput:
  610.  
  611. endrelocate()
  612.  
  613. Put_Text_Into_Buffer_End:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement