Challenge: sc2 setpixel

Pagina 1/10
| 2 | 3 | 4 | 5 | 6

Door PingPong

Prophet (4093)

afbeelding van PingPong

03-11-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?

Aangemeld of registreer om reacties te plaatsen

Van PingPong

Prophet (4093)

afbeelding van PingPong

03-11-2007, 20:17

no challenge/interest? or no z80 asm coders?

Van dvik

Prophet (2200)

afbeelding van dvik

03-11-2007, 20:52

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

Van PingPong

Prophet (4093)

afbeelding van PingPong

03-11-2007, 21:17

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

Van dvik

Prophet (2200)

afbeelding van dvik

03-11-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
        

Van PingPong

Prophet (4093)

afbeelding van PingPong

03-11-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. Shocked!
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, Big smile maybe one day will be useful for me or another people. Those from BIOS are slow...

Van PingPong

Prophet (4093)

afbeelding van PingPong

05-11-2007, 19:48

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

Van AuroraMSX

Paragon (1902)

afbeelding van AuroraMSX

05-11-2007, 21:50

Well, I see an enourmus interest..... Wink TongueYeah 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 Shocked!

Van PingPong

Prophet (4093)

afbeelding van PingPong

05-11-2007, 21:53

Well, I see an enourmus interest..... Wink TongueYeah 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 Shocked!

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?

Van ARTRAG

Enlighted (6923)

afbeelding van ARTRAG

19-09-2010, 23:48

Sorry to resurrect this topic but i face a problem in emulators:
this code

	di
	ld	a,e
	out	(099h),a
	ld	a,d
	;and	03Fh
	out	(099h),a
	
	in	a,(098h)
	or	(hl)
	ld	c,a

	ld	a,e
	out	(099h),a
	ld	a,d
	;and	03Fh
	or	040h
	out	(099h),a

	ld	a,c
	out	(098h),a
	ei

is part of a setpixel routine that works only on emulators but NOT in my real TR.
Can anyone tell why?

Van ARTRAG

Enlighted (6923)

afbeelding van ARTRAG

20-09-2010, 08:17

adding a NOP between out (099h),a in a,(098h) seems to solve...
So is it a "fast" access problem ? Is it on TR only or on any vdp?
And if it is, is it correct the dvick's routine, when it does

        ; Set VRAM read pointer and fetch
        ; current value in VRAM
        out     (c),l
        out     (c),h
        in      a,($98)
Pagina 1/10
| 2 | 3 | 4 | 5 | 6