Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "CorrelationOutputTextSharedCode.asm"
- CorrelationOutput:
- ;HL is the number of arguments.
- ld a, l
- ;See if there are 3 or 4 arguments, otherwise the parser
- ;can take over
- cp 3
- jr z, ++_
- ;Parse Normally
- _
- cp a
- ret
- _
- ld a, (Character_Height)
- cp 8
- jp nz, Wrong_Size_Error
- ld a, (Character_Width)
- cp 6
- jp nz, Wrong_Size_Error
- ld a, (OutputOrText)
- ;If A = 0, We were using ln(.
- or a
- jr nz, SixBitMode ;We don't
- ;need to copy
- ;Output( code
- ;to StatVars.
- inc a
- ld (OutputOrText), a
- ld hl, Put_Text_Into_Buffer_Start
- ld de, StatVars
- ld bc, Put_Text_Into_Buffer_End - Put_Text_Into_Buffer_Start
- ldir
- ;The only thing we can display immediately is
- ;a 6x8 font. Set the display to work with
- ;6-bit mode.
- SixBitMode:
- in a, ($10)
- rla
- jr c, SixBitMode
- xor a
- out ($10), a
- call OutputTextShared
- jr c, NegativeNumberOutputY
- or a
- jr z, ++_
- cp 17
- jr c, ContinueOutputPart3
- _
- bjump(_ErrDomain)
- _
- ld bc, 0 ;For a coordinate of 0, interpret it as
- ;-1
- NegativeNumberOutputY:
- inc bc
- ;BC contains the amount to multiply by 16.
- sla c \ rl b
- sla c \ rl b
- sla c \ rl b
- sla c \ rl b
- ld (StringAdjuster), bc
- ld a, 1
- ContinueOutputPart3:
- dec a
- ld (TextBufferX), a
- ;If we are in Map Mode,
- ;1. Put TextBufferX into MapX
- ; Reminder to self: MapX is the X coordinate
- ; because in Map Mode, text does not necessarily
- ; move to the front of the screen
- ;2. The number of characters to skip will be
- ; (ThetaStep + 2) - 16 + MapX
- ld a, (TextBufferX)
- ld (MapX), a
- ld a, (ThetaStep + 2)
- sub 16
- ld b, a
- ld a, (MapX)
- add a, b
- ld bc, (StringAdjuster)
- add a, c
- ld (NumberOfCharactersToSkip), a
- ;Go to the next number, the Y Coordinate.
- ld de, -11
- add hl, de
- call CodeToCall1
- jr c, NegativeNumberOutputX
- or a
- jr z, ++_
- cp 9
- jr c, EmergencyLocalLabel3
- _
- bjump(_ErrDomain)
- _
- ld bc, 0 ;For a coordinate of 0, interpret it as
- ;-1
- NegativeNumberOutputX:
- inc bc
- ex de, hl
- ld hl, (StringAdjuster)
- add hl, bc
- ld (StringAdjuster), hl
- ex de, hl
- ld a, 1
- EmergencyLocalLabel3:
- dec a
- ld (TextBufferY), a
- rlca \ rlca \ rlca
- ld (penRow), a
- jp ContinueOutputPart4
- Wrong_Size_Error:
- ld hl, ErrorWrongSize
- ld de, appErr1
- ld bc, 11
- ldir
- B_CALL $4D41
- ErrorWrongSize:
- .db "WRONG SIZE", 0
- Put_Text_Into_Buffer_Start:
- relocate(statVars)
- Put_Text_Into_Buffer:
- ld a, (FontPage)
- or a
- jr z, _
- out (6), a
- _
- ;hl is the text to display. The text must end ;in azero.
- ;PenRow and PenCol are the X, Y coordinates.
- ld bc, (StringAdjuster)
- add hl, bc
- ;For 6x8 text, text will only be displayed to the
- ;buffer unless we want it to be displayed immediately.
- ;For the sake of speed, Word Wrap is not a
- ;consideration. Neither are windows and lowercase letters.
- ;Animated tiles are allowed, but are not needed for simply putting
- ;text in the buffer, since animated text is taken care of only
- ;when pictures are updated
- ;HL points to the string to draw. Save the
- ;value temporarily.
- push hl
- ;DE will hold the position in the text buffer
- ;to copy text.
- ld a, (TextBufferY)
- ;Multiply TextBufferY by 16.
- rlca \ rlca \ rlca \ rlca
- ld hl, CorrelationTextBuffer
- ld d, 0
- ld e, a
- add hl, de
- ld a, (TextBufferX)
- ld e, a
- add hl, de
- ex de, hl
- pop hl
- ;DE now points to the text buffer, hl to the text.
- Read_Text_Loop_Homescreen:
- ;Save the location where text will be placed in
- ;the buffer
- push de
- ld de, (String_Length)
- ld a, d
- or e
- jp z, QuitDisplayingFontHomescreen
- dec de
- ld (String_Length), de
- ;See if this value is greater than 16. If so, either stop drawing
- ;or wrap
- ld a, (TextBufferX)
- cp 16
- jr c, PenColFinalizedHomescreen
- xor a
- ld (TextBufferX), a
- ld a, (Display_Mode)
- cp 1 ;Clip the sprite?
- jp z, QuitDisplayingFontHomescreen
- WrapTextHomescreen:
- ;Wrap to the next row. Take the height of the characters, and add it
- ;to the PenRow
- ld a, (TextBufferY)
- ;If a is greater than 63, don't display anymore text.
- cp 8
- jp nc, QuitDisplayingFontHomescreen
- inc a
- _
- ld (TextBufferY), a
- ;If in MapMode, go to proper text in HL.
- ld a, (Display_Mode)
- cp Map
- jr nz, PenColFinalizedHomescreen
- ld d, 0
- ld a, (CharactersToSkip)
- ld e, a
- add hl, de
- push hl
- ld hl, (String_Length)
- or a
- sbc hl, de
- ld (String_Length), hl
- pop hl
- jp c, QuitDisplayingFontHomescreen
- ld a, (TextBufferX)
- PenColFinalizedHomescreen:
- ;Our goal is to increase PenCol to the position of the character
- ;after the one we are currently working with
- ld c, a ;Saves the pencol coordinates
- ABCHomescreen:
- in a, ($10)
- rla
- jr c, ABCHomescreen
- ;Output the X Coordinate. THIS IS SMC, since
- ;instead this might be dividing by six instead of
- ;eight. Instead of srl a 3 times, it would be
- ;call divide by 6.
- ld a, c
- add a, $20
- out ($10), a
- ld a, c
- inc a
- ld (TextBufferX), a
- Draw_TextHomescreen:
- ld a, (hl)
- ;-------------------------------
- ;THIS IS SMC. CONDITION:
- ;If Error Checking off, skip.
- ;If Animated Tiles Off, skip.
- ;If lowercase off, skip.
- ;-------------------------------
- ;See if the character is one that cannot
- ;be used inside of a string
- cp $26
- jp z, Not_Allowed
- cp $3F
- jp z, Not_Allowed
- cp $5C
- jr c, _
- cp $5F
- jp c, Not_Allowed
- _
- cp $60
- jr c, _
- cp $54
- jp c, Not_Allowed
- _
- cp $7E
- jp z, Not_Allowed
- cp $AA
- jp z, Not_Allowed
- cp $BB
- jp nz, Check116
- jp NoLowerInOutput
- Check116:
- cp $EF
- jp z, Not_Allowed
- push hl
- ;Check to see if the character is greater than
- ;the maximum value, to avoid displaying garbage
- ld d, a
- ld hl, Ending_Character
- ;If the maximum value is 255,
- ;the user cannot go over the limit.
- ld a, (hl)
- cp 255
- jr z, EmergencyLocalLabel88
- ;If the maximum value is not 255, it
- ;is 254 or less. So we increase the
- ;maximum value to 255 to check for
- ;the C flag, since it does >= instead
- ;of simply >.
- inc (hl)
- ld a, d
- cp (hl)
- jp nc, Out_Of_Range
- dec (hl)
- ld hl, Starting_Character
- sub (hl)
- jp c, Out_Of_Range
- EmergencyLocalLabel88:
- ld a, d
- DoneWithLowerCaseHomescreen:
- ;If we are not displaying immediately, go to the next character.
- pop hl
- pop de
- ld (de), a
- inc de
- inc hl
- bit CopyOneCharacter, (IY + asm_flag1)
- jp z, Read_Text_Loop_Homescreen
- push hl
- push de
- push af
- ld a, (TextBufferY)
- rlca \ rlca \ rlca
- add a, $80
- ld c, $10
- ABCHomescreen2:
- in b, (c)
- rl b
- jr c, ABCHomescreen
- out (c), a
- pop af
- DisplayHomescreenCharacterImmediately:
- ;If animated tiles are allowed, we might need to
- ;draw a different character for whatever is inside
- ;of register A
- cp tRad
- jr c, CannotAnimateTileHomescreen
- cp tShade
- jr nc, CannotAnimateTileHomescreen
- ;bit AnimateTiles, (IY + asm_flag1)
- ;jr z, CannotAnimateTile
- AnimatedTilesHomescreen:
- push af
- ld hl, Starting_Character
- sub (hl)
- ld hl, AnimatedTileData + 1
- add a, a
- call Add_A_To_HL
- pop af
- add a, (hl)
- ;AT this point, A goes into the text buffer.
- CannotAnimateTileHomescreen:
- ld hl, Starting_Character
- sub (hl)
- ld d, 0
- ld e, 8
- Call Multiply_DE_By_A
- ld de, (FontLocation)
- add hl, de
- ld b, 8 ;8 rows to draw
- ld c, $10
- ld a, (hl)
- rrca \ rrca
- ;HL points to the font location. We only need
- ;put (hl) into a in order to put a to port ($11)
- Put_Character_6x8:
- in d, (c)
- rl d
- jr c, Put_Character_6x8
- out ($11), a
- inc hl
- ld a, (hl)
- rrca \ rrca
- djnz Put_Character_6x8
- pop de
- pop hl
- jp Read_Text_Loop_Homescreen
- QuitDisplayingFontHomescreen:
- pop de
- ld a, (ApplicationPageLocation)
- out (6), a
- ld a, (Display_Mode)
- cp WordWrap
- ret z
- res LowerCaseMode, (IY + asm_flag1)
- ret
- NoLowerInOutput:
- endrelocate()
- Put_Text_Into_Buffer_End:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement