Challenge: sc2 setpixel (Development MSX Fora)MSX Resource Center            
            
English Nederlands Espa�ol Portugu�s Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 70 gasten en 4 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - Challenge: sc2 setpixel

Schrijver

Challenge: sc2 setpixel

PingPong
msx professional
Berichten: 1023
Geplaatst: 03 November 2007, 17:24   
Hi, who want to make the most speedy set pixel routine for screen2?

Rules:
1) No attribute support: the attr table is uniformly filled with a &hf1 for the entire table.
2) Because of (1) the routine should not access the attribute table.
3) the routine should expect the coordinates x,y in the register pair l,h and the vram pattern table is expected to start at 0
4) you can destroy all registers, except IX,IY, if you need it, save it!
5) no self modifying code.

Who from all the z80 experts like to join?
PingPong
msx professional
Berichten: 1023
Geplaatst: 03 November 2007, 20:17   
no challenge/interest? or no z80 asm coders?
dvik
msx master
Berichten: 1339
Geplaatst: 03 November 2007, 20:52   
If I needed a speedy setpixel routine I would consider a faster interface than passing x and y coordinates.
PingPong
msx professional
Berichten: 1023
Geplaatst: 03 November 2007, 21:17   
Quote:

If I needed a speedy setpixel routine I would consider a faster interface than passing x and y coordinates.


more precisely?
dvik
msx master
Berichten: 1339
Geplaatst: 03 November 2007, 21:32   
Nevermind. It all depends on what you want to do with the routine. When I write code I try to make the data and variablesas efficient as possible for the task I want to achieve. This is almost always where the big speed savings can be done. Then optimizing the code becomes a secondary task. But since I don't know what you want to do with the routine its wrong of me to say its not a good interface.

Anyways, here is a pretty fast routine. The outs are very close and need to be spaced apart but I didn't want to do that because then it will be harder to read the code (I should say I haven't tested the code but I believe its correct):

*EDIT* I fixed a minor bug in the routine

ds  ($10000-$) AND $ff
pset_table:
db  $01,$02,$04,$08,$10,$20,$40,$80

;--------------------------------------------------
; Sets a pixel in vram
; h = y
; l = x
;
; Description:
;   VRAMPTR = 8 * (x / 8) + (y & 7) + 256 * (y / 8)
;           = (x & F8h) + (y & 07h) + 256 * (y / 8)
;   If VRAMPTR is stored in hl, then
;   l = (l & F8h) + (h & 07h)
;   h = y >> 3
;         
;--------------------------------------------------
pset:
        ; Save X & 07h in d
        ld      a,h
        and     7
        ld      d,a
        
        ; Save Y & 07h in b
        ld      a,l
        and     7
        ld      b,a
        
        ; Calculate h = Y >> 3
        ld      a,h
        and     $f8
        rrca
        rrca
        rrca
        ld      h,a
        
        ; Calculate l = (X & F8h) + (Y & 07h)
        ld      a,l
        and     $f8
        or      d
        ld      l,a
        
        ld      c,$99
        
        ; Set VRAM read pointer and fetch
        ; current value in VRAM
        out     (c),l
        out     (c),h
        in      a,($98)
        
        ; Set the bit in loaded byte
        ld      d,pset_table / 256
        ld      e,a
        ld      a,(de)
        or      b
        
        ; Output new value
        out     (c),l
        set     6,h
        out     (c),h
        out     ($98),a
        
        ret
        




PingPong
msx professional
Berichten: 1023
Geplaatst: 03 November 2007, 22:08   
Hi, dvik. I'm not been clear: i do not need a setpixel routine. Sorry for the time you wasted in writing this.
The post is only to start a new 'game challenge' to see how much a almost useless routine can be optimized. That's the meaning of the rules 1-5. Only to set some limitations. This post *is not* for real implementation.
It's only because in this period the msx threads are a bit under the usual rate.
Anyway thx for the routine, maybe one day will be useful for me or another people. Those from BIOS are slow...
PingPong
msx professional
Berichten: 1023
Geplaatst: 05 November 2007, 19:48   
Well, I see an enourmus interest.....
AuroraMSX

msx master
Berichten: 1260
Geplaatst: 05 November 2007, 21:50   
Quote:

Well, I see an enourmus interest.....

Yeah well, the 'challenge' is a bit vague.
You said you wanted a fast setpixel routine, dvik gave you one and only after that you told dvik that that was not what you were looking for and said you were trying to start a game challenge.

/me (and others too, prolly) confused to the max
PingPong
msx professional
Berichten: 1023
Geplaatst: 05 November 2007, 21:53   
Quote:

Quote:

Well, I see an enourmus interest.....

Yeah well, the 'challenge' is a bit vague.
You said you wanted a fast setpixel routine, dvik gave you one and only after that you told dvik that that was not what you were looking for and said you were trying to start a game challenge.

/me (and others too, prolly) confused to the max



Sorry, i've been not clear again. Not game in the real meaning of term, ("GAME" but only a challenge with this goal:

"write the fastest setpixel routine in asm or 'c' with respect of the limits above (1-5)"
the 'game' is this...
Now, it's clear?
 
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.