It is currently Wed Oct 18, 2017 11:44 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3

How much does your TV display?
Entire screen is showing 56%  56%  [ 5 ]
Less or equal to 16 pixels clipped evenly between top and bottom 33%  33%  [ 3 ]
Less or equal to 16 pixels clipped unevenly between top and bottom 11%  11%  [ 1 ]
More than 16 pixels clipped evenly between top and bottom 0%  0%  [ 0 ]
More than 16 pixels clipped unevenly between top and bottom 0%  0%  [ 0 ]
Total votes : 9
Author Message
PostPosted: Thu Dec 22, 2016 4:53 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3071
Location: Nacogdoches, Texas
You know, I had thought I had thought of a few optimizations for my tile uploading routine, and I figured I'd post them here. Here's the complete code that I'll talk about:

Code:
.proc tile_uploader
  sep #$10
  rep #$20
  lda #$4300
  tcd
  lda #$1801         ;Set DMA mode (word, normal increment) and destination register (VRAM write register)
  sta $00
  sta $10
  sta $20
  sta $30
  ldy #$80
  sty a:$2115
  lda a:TileRequestCounter16x16
  beq tile_uploader_32x32
  ldx #$00

tile_uploader_16x16_loop:
  lda #$0040
  sta $05
  sta $15

;16x16 Top Half
  lda a:TileRequest16x16LoWordTable,x
  sta $02
  clc
  adc #$0040
  sta $12

  lda a:TileRequest16x16BankByteTable,x
  tay
  sty $04
  sty $14

  lda a:TileRequest16x16VramAddressTable,x
  sta a:$2116

  ldy #$01      ;Initiate DMA transfer (channel 0)
  sty a:$420B

;16x16 Bottom Half 
  clc
  adc #$0100
  sta a:$2116

  ldy #$02      ;Initiate DMA transfer (channel 1)
  sty a:$420B

  inx
  inx
  beq tile_uploader_done
  cpx a:TileRequestCounter16x16
  bne tile_uploader_16x16_loop

tile_uploader_32x32:
  lda a:TileRequestCounter32x32
  beq tile_uploader_done
  ldx #$00

tile_uploader_32x32_loop:
  lda #$0080
  sta $05
  sta $15
  sta $25
  sta $35

;32x32 Top Part
  lda a:TileRequest32x32LoWordTable,x
  sta $02
  clc
  adc #$0080
  sta $12
  adc #$0080
  sta $22
  adc #$0080
  sta $32

  lda a:TileRequest32x32BankByteTable,x
  tay
  sty $04
  sty $14
  sty $24
  sty $34

  lda a:TileRequest32x32VramAddressTable,x
  sta a:$2116

  ldy #$01      ;Initiate DMA transfer (channel 0)
  sty a:$420B

;32x32 Upper Middle Part
  clc
  adc #$0100
  sta a:$2116

  ldy #$02      ;Initiate DMA transfer (channel 1)
  sty a:$420B

;32x32 Lower Middle Part
  adc #$0100
  sta a:$2116

  ldy #$04      ;Initiate DMA transfer (channel 2)
  sty a:$420B

;32x32 Bottom Part
  adc #$0100
  sta a:$2116

  ldy #$08      ;Initiate DMA transfer (channel 3)
  sty a:$420B

  inx
  inx
  cpx #$40
  beq tile_uploader_done
  cpx a:TileRequestCounter32x32
  bne tile_uploader_32x32_loop

tile_uploader_done:
  lda #$0000
  tcd
  stz TileRequestCounter16x16
  stz TileRequestCounter32x32
  rts
.endproc

The main thing that I have had done is set direct page to #$4300, because the 256 byte area I am interacting with the most is there, and because it's on a page boundary, it's one cycle less. I am using Y for loading and storing when I can, which is faster as it is only 8 bit. And finally, I am only using "clc" at the beginning of when I'm doing my additions, because the number shouldn't ever overflow because a graphic won't be partially in two different banks. I'm sure you've already done these optimizations though; I'm still learning. :lol:

One thing I've been dealing with that I should stop worrying about is the vram finding routine. I thought of some extra stuff to speed up finding slots and although I shouldn't need to look through as many slots to find an empty one, each slot is slower. I'll have to see what's faster, but for that I'd have to get something working first... :lol:

Edits: I found a couple lot of bugs that just so happened not to affect anything by chance. I just fixed them.


Last edited by Espozo on Thu Dec 22, 2016 11:41 pm, edited 5 times in total.

Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 7:43 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2285
If 16x16 tiles are set up like that, you don't need to add #$0040 to $4302. It leaves off at the end of the dma copy.


Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 7:49 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3071
Location: Nacogdoches, Texas
Okay. I tested it, and you're right, I'll change the code above. I don't think there's much left you can do to make it faster now.


Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 11:06 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2285
It only works if it's the same channel.


Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 11:36 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3071
Location: Nacogdoches, Texas
God, I'm an idiot. I realized I only said it worked because I only ran the 32x32 code that I noticed didn't have the changes done to it yet. Although you don't need to do the addition thing if it's the same channel, you still have to set everything else up again, so I'll pass.


Top
 Profile  
 
PostPosted: Mon Jan 09, 2017 9:26 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1771
Location: DIGDUG
After careful observation, I'm losing exactly zero pixels on both of my test TVs (1 LCD, 1 CRT), on my US (NTSC) SNES.

That's on all 4 edges.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Mon Jan 09, 2017 10:37 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3071
Location: Nacogdoches, Texas
Oh... :? I've come under the conclusion that I'm going to have to end up using forced blanking though, as there's no way I'll be able to fit all the updates in the small 6KB window. Although I might be able to pull of updating sprite tiles evenly between 20 and 30fps, there'd be absolutely no room for anything else and possibly not always sprite tiles either.


Top
 Profile  
 
PostPosted: Tue Jan 10, 2017 11:36 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2285
How many of you have a TV where you can see a little overscan on the left or right, but none on the top and bottom? My girlfriend's TV does it when we played Super Nintendo games.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 7 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group