Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Draw a VWF character on the screen.
- //
- // INPUT : A -> Character code
- //
- // REQUIRES : P(8A/16XY)
- // MODIFIES : P, A, X, Y
- //
- renderVwf:
- sta {vwfChar} // Save the character code.
- lda {vwfShift} // A = Bits already drawn in the tile
- and #$07 // A %= 8
- bne + // Jump if there is still room in the tile.
- jsr nextTile // Go the next tile in VRAM.
- jsr clearBuffer // Clear the VWF buffer.
- // vwfShift2 = vwfShift * 2
- // (Required for indexing the jump table)
- +; lda {vwfShift}; asl; sta {vwfShift2}
- lda {vwfChar} // Reload the char code.
- jsr charIndex // X = Index of the char in the font
- ldy #$0000 // Y = Index in the VWF buffer
- // Draw the character:
- .lsr:
- lda.l font, x // Load a byte of the char.
- // Shift the pixels to the right:
- phx; ldx {vwfShift2}
- jsr (shiftRight.table, x); plx
- // Draw the result in the tile:
- ora {vwfBuffer}, y
- sta {vwfBuffer}, y
- // Loop until the end of the char:
- inx; iny
- cpy #$0010
- bne .lsr
- ldx {vwfChar} // X = Char code
- lda.l font.widthTable, x // A = Width of the char
- // Verify if there was overflow:
- clc; adc {vwfShift}
- cmp #$08
- and #$07
- sta {vwfShift} // Save the new shift value.
- // (A <= 8) --> No overflow, exit:
- bcc .exit; beq .exit
- phx; jsr sendVwfBuffer; plx // Send the tile to VRAM.
- lda.l font.widthTable, x // A = Width of the char
- // Calculate the number of left shifts to draw overflow:
- sec; sbc {vwfShift}; asl
- sta {vwfShift2}
- txa; jsr charIndex // X = Index of the char in the font
- ldy #$0000
- // Draw the second part of the character:
- .asl:
- lda.l font, x // Load a byte of the char.
- // Shift the pixels to the left:
- phx; ldx {vwfShift2}
- jsr (shiftLeft.table, x); plx
- sta {vwfBuffer}, y // Write the result to the buffer.
- // Loop until the end of the char:
- inx; iny
- cpy #$0010
- bne .asl
- // Select the next tile in VRAM:
- jsr nextTile
- .exit:
- jsr sendVwfBuffer // Write the tile in VRAM.
- // Write the tile in the tilemap:
- stz $2115
- ldx {tileMapPtr}
- stx $2116
- lda {vramPtr}
- lsr; lsr; lsr
- // Wait for VBlank before writing in VRAM:
- pha
- .waitVBlank:
- lda $4212
- bpl .waitVBlank
- pla
- sta $2118 // Do the write.
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement