;########################################## ; VWF Routine for whatever # ; Just an idea of a way I would do a VWF # ; Code compiled using ASM2HEX by LordTech # ;########################################## #define Counter $00 #define FontPtr $14 #define TilePosi $1274 #define Buffer $7EF000 #define Buffer2 $7EF020 #define PixLeft $7EFFFE #define Masking $1E #filename "Keroppi.smc" #romtype lorom ;--------------------------------; ; Main code area for VWF routine ; ;--------------------------------; code VWF{ %position ; this is the offset of where the old routine would be replace LDX #$0000 LDA #$0010 ; we only need a 8x15 tile STA Counter ; Last BYTE is the fonts' width ; Make sure we are not OR'ing data to the tile ; from existing data in our "pixels left" variable ; This helps on starting the text routine LDA PixLeft AND #$0007 ; 8 pixel wide font STA PixLeft ; We need to clean the pixels ; Left variable for safety BNE NoNewTile ; If we have data on the tile ; we go to the "ORA" routine ;-----------------------; ; Regular routine is all; ; That's needed at this ; ; point ; ;-----------------------; JSR STA_Tiles BRA _Next ;-----------------------; ; Go to the OR routine ; ;-----------------------; NoNewTile: JSR OR_Tiles _Next: JMP $DA02 } ;-----------------------; ; ; ; Standard routine. ; ; ; ;-----------------------; code STORE_TILES { %position ; this is the offset of the routine which would stoe tiles directly to the FONT buffer STA_Tiles: ; Assume: X = Buffer Position ; : Counter = Bytes to read ( 15 BYTES ) ; : The 16th BYTE is the Width ; LDA ( FontPtr ) ; get font data to use AND #$00FF ORA Masking STA Buffer,X LDA #$0000 ; Clear other half of 16x16 tile ORA Masking STA Buffer2,X INC FontPtr INX INX DEC Counter BNE STA_Tiles LDA ( FontPtr ) ; Get the font's width AND #$000F ;------------------------------; ; ; ;------------------------------; _Universal: STA Counter LDA #$0008 ; Get a Tile's Width SEC SBC Counter ; Subtract Pixels Used AND #$0007 STA PixLeft ; if (value & $07) = $00, then the complete Tile was used BNE _NoINC ; if (value & $07) = $0x, then we have more pixel space left on the tile INC TilePosi ; we need to get to the next ; Tile and use it!!! _NoINC: RTS } ;-----------------------; ; ; ; VWF routine. ; ; ; ;-----------------------; code OR_TILES { %position ; This is where the VWF routine would go in ROM OR_Tiles: ; Assume: X = Buffer Position ; : Counter = Bytes to read ( 15 BYTES ) ; : The 16th BYTE is the Width ; ;---------------------------; ; Set up the shifting amount; ;---------------------------; LDA #$0008 ; Get a Tile's Width SEC SBC PixLeft ; 8 - PixLeft = Last Tile's Width STA Buffer ; use as temp space LDA PixLeft ; we need the variable for a PHA ; shifting counter. Save contents! LDA Buffer PHA ShiftLoop: PLA ; This is simply for looping purposes STA PixLeft PHA ; Save value as the shift amount! LDA ( FontPtr ) AND #$00FF XBA ; Make the Font data the High BYTE AND #$FF00 ; Clear the low BYTE. Bits will ; be shifted into the low BYTE ; 00001111 00000000 >> 2 = ; 00000011 11000000 ShiftData: ; THis a SLOW way of doing this shifting process LSR ; Adjust the Tile Data for ORing DEC PixLeft BNE ShiftData PHA ; Save this value for later XBA AND #$00FF ; We only need the High BYTE for ORing ORA Masking STA Buffer,X ; ; PLA ; we get the value we saved AND #$00FF ; this data gets stored in the other ORA Masking ; half of the 16x16 Tile STA Buffer2,X ; We use a 16x16 tile so we don't lose the shifted BITS AND we can transfer ; the whole 16x16 font to VRAM without having to load this font AGAIN to show the lost bits INC FontPtr INX INX DEC Counter BNE ShiftLoop PLA ; This is the shift amount. Garbage!! PLA ; This is the Pixels Left, restore this value STA PixLeft LDA ( FontPtr ) ; Get the font's width AND #$000F STA Counter ; we will subtract this from Pixels Left LDA PixLeft SEC SBC Counter ; Subtract Pixels Used BPL NoTileINC ; if ( PixLeft - FontWidth ) >= 0 we are good!!! =] ; This is where it gets tricky! EOR #$FFFF ; value was less than ZERO meaning INC ; that we used more pixels than we had to use INC TilePosi ; we need to hit the next Tile JMP _Universal ; what we need to do next has been done already! ; at the _Universal offset. Go back and referrence that NoTileINC: AND #$0007 STA PixLeft RTS }