PCEngineFans.com - The PC Engine and TurboGrafx-16 Community Forum

Tech and Homebrew => Turbo/PCE Game/Tool Development => Topic started by: touko on May 07, 2015, 08:15:30 AM

Title: a faster _satb_update routine
Post by: touko on May 07, 2015, 08:15:30 AM
Hi guy, i post my optimised _satb_update routine .

As it use self modifying code ,it must be used for CD projects only .
Code: [Select]
#asm
_satb_update:
; // Use TIA, but BLiT 32 words at a time (64 bytes)
; // Because interrupt must not deferred too much
; // 8 sprites at a time

stw #_satb , .vram_tia_satb + 1    ; // Source

       ; // Set VRAM destination address
st0 #0
st1 #$00
st2 #$7F

       ; // Enable VDC write mode 
st0 #2

ldx #8

  .vram_tia_satb:
tia $0000 , $0002 , $40
addw        #$40 , .vram_tia_satb + 1
dex
bne .vram_tia_satb
 
rts
#endasm

i can post a rom version if someone is interested .
Title: Re: a faster _satb_update routine
Post by: Debvgger_ on May 07, 2015, 08:17:01 AM
Thanks :-)
Title: Re: a faster _satb_update routine
Post by: Debvgger_ on May 07, 2015, 10:41:22 AM
I would like to take a peek at the ROM version if you want to post it, too :-)
Title: Re: a faster _satb_update routine
Post by: touko on May 07, 2015, 10:13:40 PM
I would like to take a peek at the ROM version if you want to post it, too :-)
Ok no problem ;-)

Code: [Select]
#asm
_satb_update:
; // Use TIA, but BLiT 32 words at a time (64 bytes)
; // Because interrupt must not deferred too much
; // 8 sprites at a time

; // set source,destination and size for executing tia in RAM
stw #_satb , _ram_hdwr_tia_src    ; // Source
stw #$0002 , _ram_hdwr_tia_dest ; // Destination
stw #$40 , _ram_hdwr_tia_size ; // Size

    ; // Set VRAM destination address
st0 #0
st1 #$00
st2 #$7F

    ; // Enable VDC write mode 
st0 #2

ldx #8

  .vram_tia_satb:
jsr _ram_hdwr_tia
addw #$40 , _ram_hdwr_tia_src
dex
bne .vram_tia_satb
 
rts
#endasm

All _ram_hdwr_tia variables are already declared in huc (in library.asm)
Title: Re: a faster _satb_update routine
Post by: elmer on May 09, 2015, 04:49:35 AM
Ahhhhhh .... It always warms my heart to see self-modifying code!  :)
Title: Re: a faster _satb_update routine
Post by: Debvgger_ on May 09, 2015, 09:29:38 PM
elmer: Me too; as I always say, damn caches  :lol:
Title: Re: a faster _satb_update routine
Post by: touko on May 10, 2015, 05:13:45 AM
LOL, CPU's cache is the evil  :evil: