Clipping Works on the Hardware

Do you live and breathe hexadecimal? Do you like speaking to hardware directly?

Moderator: Programming Moderators

Post Reply
User avatar
robpearmain
Posts: 59
Joined: Tue May 30, 2017 5:35 pm
Location: York
Contact:

Clipping Works on the Hardware

Post by robpearmain » Mon Dec 25, 2017 1:11 pm

Hi

So I have been using CSpect, and updated the layer2.asm example just before the comments with the following code (See https://www.specnext.com/tbblue-io-port-system/ for reference).

Note, this is currently not implemented on CSpect.

Essentially, the code sets layer2 to clip to 0,40 to 127,191, Sprites to clip 128,40 to 255,191 and ULA (Spec Screen) to 0,0,255,39

Is there a way to achieve the same using the NEXTREG op codes?

Code: Select all

; Layer2

		ld      bc,$243b
                ld      a,$18
                out     (c),a
		ld      bc,$253b
                ld 	a,0
                out     (c),a
                ld 	a,127
                out     (c),a
                ld 	a,40
                out     (c),a
                ld 	a,191
                out     (c),a

; Sprites
		ld      bc,$243b
                ld      a,$19
                out     (c),a
		ld      bc,$253b
                ld 	a,128
                out     (c),a
                ld 	a,255
                out     (c),a
                ld 	a,40
                out     (c),a
                ld 	a,191
                out     (c),a
 
; ULA
		ld      bc,$243b
                ld      a,$1A
                out     (c),a
		ld      bc,$253b
                ld 	a,0
                out     (c),a
                ld 	a,255
                out     (c),a
                ld 	a,0
                out     (c),a
                ld 	a,39
                out     (c),a

Rob Pearmain
Bipboi (Zx Spectrum 48k), Harry Hedgehog (ZX Spectrum [1K]), Luna C (PC), Turbotoons (PC)

ZX Spectrum 48k, +, 128k, Next (board)

Alcoholics Anonymous
Posts: 495
Joined: Mon May 29, 2017 7:00 pm

Re: Clipping Works on the Hardware

Post by Alcoholics Anonymous » Tue Dec 26, 2017 1:17 am

I would clear the clipping windows' index first just to be safe.
You can do a bunch of nextreg but I'm not sure if that's the shortest.

Code: Select all

nextreg 0x1c, 7   ; reset all clipping windows' current index

; layer 2

nextreg 0x18, 0
nextreg 0x18, 127
nextreg 0x18, 40
nextreg 0x18, 191

; etc
16 bytes per window compared to your 21 bytes per window

Another is using the outinb instruction which is like outi except b is not decremented.

Code: Select all

nextreg 0x1c, 7   ; reset all clipping windows' current index

ld hl,windows
ld bc,0x243b

; layer 2

ld a,0x18
out (c),a
inc b
outinb
outinb
outinb
outi   ; b--

; etc

...

windows:
window_layer2:
   defb 0, 127, 40, 191
16+2 bytes per window. You can make it smaller by making a subroutine for the outs.

nextreg does not currently work, not sure about outinb.

User avatar
robpearmain
Posts: 59
Joined: Tue May 30, 2017 5:35 pm
Location: York
Contact:

Re: Clipping Works on the Hardware

Post by robpearmain » Sat Jan 06, 2018 3:52 pm

This works a treat with CSpect 1.6 and the hardware

Code: Select all

; Layer2

nextreg 0x1c, 7   ; reset all clipping windows' current index

; layer 2

nextreg $18, 32
nextreg $18, 127
nextreg $18, 40
nextreg $18, 191

; Sprites

nextreg $19, 128
nextreg $19, 255
nextreg $19, 40
nextreg $19, 191
 
; ULA

nextreg $1A, 0
nextreg $1A, 255
nextreg $1A, 0
nextreg $1A, 39
Rob Pearmain
Bipboi (Zx Spectrum 48k), Harry Hedgehog (ZX Spectrum [1K]), Luna C (PC), Turbotoons (PC)

ZX Spectrum 48k, +, 128k, Next (board)

Post Reply