+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  VWF Explained
Pages: 1 [2]
Author Topic: VWF Explained  (Read 2 times)
MathOnNapkins
Guest
« Reply #15 on: January 16, 2008, 01:08:04 pm »

VRAM writing is handled automatically via the NMI. Their routine (as well as my own version based on it but altered considerably) simply try to output as many characters in a frame as possible to an intermediate buffer at $7F0000, which at 21 tiles by 6 tiles is 0x7E0 bytes long). The whole buffer is copied during NMI via DMA, and I don't intend to change that. The bottleneck is the actual generation of data for that buffer, which is inevitably done with cpu instructions, not DMA. I'd like to use DMA though. This isn't really a problem problem, just something I would like to make faster but can't see how to make it faster.
« Last Edit: January 16, 2008, 01:49:02 pm by MathOnNapkins »
Tauwasser
Guest
« Reply #16 on: January 16, 2008, 03:01:02 pm »

So what's your approach? Do you dma the tile data from a buffer into vram, or do you directly edit vram? (It begins at 7F, doesn't it?).
I usually use a buffer in tilelength and just dma this buffer after write of a character (or full tile) to vram. Some gfx routines i've seen in games tend to use the method of constantly working in vram though, which slows down a whole lot.

cYa,

Tauwasser
Bongo`
Guest
« Reply #17 on: January 16, 2008, 04:21:39 pm »

  I don't know many tricks, but one that I use SOME TIMES is a single test for the space
character. If it is the space character AND the tile data has cleared pixel data on it, then
I just jump to the pixels remaining ( NC: Tile buffer position or what it's called ) variable adjustment.
Since it's a space it does not need to be processed really.

  Another optimization I do at times is this...These tables replace the
the shifting loop that can eat up some cpu cycles. If the room
is available, I suggest using the shifting table. Not sure off hand of any
other optimizations.

For 8x16 VWF
Code:
;-------------------;
; Shifting Code     ;
;-------------------;
DoShift:           
  ; Assumes X = Index to Shift Table
  ; Assumes Accum = Font data
  PHP
  REP #$20

  AND #$00FF
  XBA
  JMP (_Shifter,X) 

_Shifter:
 dw _1,_2,_3,_4,_5,_6,_7

;-------------;
;             ;
;-------------;
_1:
  LSR
_2:
  LSR
_3:
  LSR
_4:
  LSR
_5:
  LSR
_6:
  LSR
_7:
  LSR

  ;------------;
  PLP
RTS

; For 16x16 VWF using 8x16 Tile increments
; and ASL for adding lost pixels to the following
; 8x16 tile
Code:
;############################
; Bit Shifting Code         ;
;############################
ShiftBits:
  ; Assumes X = Index to Shift Table
  ; Assumes Accum = Font data
 
  jmp (_Shifter_,X)

_Shifter_:
 dw _R1,_R2,_R3,_R4,_R5,_R6,_R7,_R8,_R9,_RA,_RB,_RC,_RD,_RE,_RF
 dw _L1,_L2,_L3,_L4,_L5,_L6,_L7,_L8,_L9,_LA,_LB,_LC,_LD,_LE,_LF


;###########################
; Shift bits to the right  ;
;###########################
_R1:
  LSR
_R2:
  LSR
_R3:
  LSR
_R4:
  LSR
_R5:
  LSR
_R6:
  LSR
_R7:
  LSR
_R8:
  LSR
_R9:
  LSR
_RA:
  LSR
_RB:
  LSR
_RC:
  LSR
_RD:
  LSR
_RE:
  LSR
_RF:
  LSR

  ;------------;
rts


;###########################
; Shift bits to the left   ;
;###########################
_L1:
  ASL
_L2:
  ASL
_L3:
  ASL
_L4:
  ASL
_L5:
  ASL
_L6:
  ASL
_L7:
  ASL
_L8:
  ASL
_L9:
  ASL
_LA:
  ASL
_LB:
  ASL
_LC:
  ASL
_LD:
  ASL
_LE:
  ASL
_LF:
  ASL

  ;------------;
rts
MathOnNapkins
Guest
« Reply #18 on: January 16, 2008, 04:32:32 pm »

Bongo: nice idea but unfortunately I can't skip the space character in LTTP. That is, unless I implement some other way of clearing the screen or a line, which I could do. Some of the game's original text relies upon being able to use 42 spaces to clear a whole line (they're 4 pixels wide a piece).

Tauwasser: VRAM is a separate entity unto itself on the SNES. I'd say in my situation you can ignore VRAM for all intents and purposes. $7F0000 is just the start of the second WRAM (work ram) bank. The only difference between my approach and the game's original approach is how the data is written to the WRAM buffer for the text. The old method is to to examine every pixel of the character (which is referenced from ROM) and copy it to the buffer by first masking out any existing pixel data there, then writing the actual character's pixel value. This is done *bit by bit* which I found to be obnoxious. I opted to copy a row of 8 pixels (a 2 byte value) from the character, then use the character width to mask out the pixels, and finally use the buffer position (in pixels) to rotate the data appropriately (with the data that gets shifted out being used for the next tile). Before I can copy it though, I need to select a mask (based on the buffer position to erase the contents of where I intend to copy to. In theory I thought this would speed it up (copying up to 16-bits instead of 1 at a time, but the extra overhead has made the gain minimal :/.
Bongo`
Guest
« Reply #19 on: January 16, 2008, 11:05:24 pm »

  This file is pretty useless to many but if anyone wants to see how a 16x16 VWF routine
is done for a particular game I'm working on, here it is...

Click me  :thumbsup: Have a nice day!  :thumbsup:

Any questions, just let me know and I'll try to clarify things...
Maybe I should write a more detailed tutorial with a "for dummies" touch
since that is the only way I can learn.   Embarrassed
Pages: 1 [2]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC