Single pixel motion in high res?

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
ChrisB
Posts: 31
Joined: Tue Dec 17, 2024 8:53 am
Location: France

Re: Single pixel motion in high res?

Post by ChrisB »

I did remove the erasing, but that is still flashing a bit.
Then I removed the "also second position" part , and it is not more flashing at all.
What is this needed for ?

Code: Select all

;
prudg1
	ld a,(de)		; get udg 
	;xor (hl)		; xor udg on screen
	ld (hl),a		; write on screen
	inc de
	inc hl
	;ld a,(de)		; also second position
	;xor (hl)
	;ld (hl),a
	inc de
	ld a,l
	add a,31		; move to next line on screen
	ld l,a
	jr nc,bdec
	inc h			; next block on screen when needed
demo001.p
(2.07 KiB) Downloaded 19 times
demo001.asm
(16.91 KiB) Downloaded 34 times
dr beep
Posts: 2428
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Single pixel motion in high res?

Post by dr beep »

you are displaying single udg not double sized so only 1 position is enough to display.
ChrisB
Posts: 31
Joined: Tue Dec 17, 2024 8:53 am
Location: France

Re: Single pixel motion in high res?

Post by ChrisB »

Thank you Dr Beep !
ChrisB
Posts: 31
Joined: Tue Dec 17, 2024 8:53 am
Location: France

Re: Single pixel motion in high res?

Post by ChrisB »

Hello,
I am trying to put a few lines of lowres display AFTER the hires, but I can't get a proper alignment, I am certainly missing something.
Thanks for helping me !

Code: Select all

; DEMO Hires moving UDG
; version with lowres at BOTTOM
;                        ------

	ORG  #4009             ;#4009                        
  
; program starts here, both BASIC and machinecode               
basic      EX   AF,AF'            ; delay intrupt,opcode no bit 6
           LD   H,B               ; preset for 48K bug to #40   
           JR   init0             ; continue where room         
                       
           DEFB 236,212,28        ; The BASIC                   
           DEFB 126               ; fully placed over sysvar    
           DEFB 143,0,18          ; start BASIC=#4009 also MC   
                       
           DEFW last              ; needed by loading           
chadd      DEFW last-1 
xptr       DEFW 0      
stkbot     DEFW last   
stkend     DEFW last   
berg       DEFB 0      
mem        DEFW 0      
           DEFB 128    
  
           DEFB 0,0,0  
  
; all above reusable AFTER loading                              
  
lastk      DEFB 255,255,255     ; used by ZX81                
margin     DEFB 55              ; used by ZX81                
nxtlin     DEFW basic           ; reusable after load     

	nop  
	defb #40,#40,#40   
	
  	nop                 
   
taddr      DEFW 0               ; used by ZX81 on LOAD only   
	; unharmed code               

    DEFW 0               
   
frames
    DEFB 255                   
    DEFB 255               		; highbyte must have bit 7 set
coords     DEFW 0                

prcc       DB 0,0,0              
   
cdflag     DEFB 64              ; used by ZX81                

;-------------------------------------------------------------------   
; Place ANY code to fill up to #4040                            
; init

init0
	ld ix,hr	; goto HR-mode

;-------------------------------------------------------------------
; game loop

ploop
	ld bc,(mycoord)	; get X and Y UDG on screen in BC
	call scrad		; calculate screen address
	push hl			; save position

	ld de,myudg
	call prudg		; show UDG

	ld hl,frames
	ld a,(hl)
	sub 1			; lower number will speed up game.
wfr
	cp (hl)
	jr nz,wfr		; wait some time
	
	pop hl
	ld de,myudg
	call prudg		; erase udg

	ld bc,(lastk)	; read last key pressed
	ld a,c
	inc a			; test a key pressed
	call nz,#7bd	; if a key pressed, translate in keynumber
	ld bc,(mycoord)	; get XY again
	cp 5			; is it "A"
	jr nz,tup		; not, test up
	inc b			; go down
tup
	cp 10			; is it "Q"
	jr nz,tleft
	dec b
tleft
	cp 26		; is it "O"
	jr nz,tright

mleft
	ld a,c		; do a left move
	and 7
	call z,swap		; we need to swap udg
	dec c			; do the step left
	
	ld hl,myudg+15	; we need to move a pixel 1 pos to left			
	ld e,8
rllp
	rl (hl)		; rotate 1 pixel
	dec hl
	rl (hl)			; rotate pixel in new position
	dec hl
	dec e
	jr nz,rllp		; rotate 8 bytes	

tright
	cp 25		; is it "P"
	jr nz,savecr			

mright
	ld hl,myudg	; rotate right 1 pixel
	ld e,8
rrlp
	rr (hl)		; rotate 1 pixel
	inc hl
	rr (hl)			; rotate pixel on new position
	inc hl
	dec e
	jr nz,rrlp

	inc c			; move 1 x to right
	ld a,c
	and 7			; test swap needed
	call z,swap		; swap udg bytes

savecr
	ld (mycoord),bc		; save coordinates
	jr ploop		; do playloop

;-------------------------------------------------------------------
; swap udg

swap
	ld hl,myudg
	push bc			; save xy
	ld b,8			; 8 bytes in udg
swap1
	ld a,(hl)		; get position1
	inc hl
	ld c,(hl)		; get position2
	ld (hl),a		; swap position1 to position2
	dec hl
	ld (hl),c		; swap position2 to position1
	inc hl
	inc hl			; goto next byte of udg
	djnz swap1		; swap all bytes
	pop bc
	ret

;-------------------------------------------------------------------
; show udg

prudg
	ld b,8
prudg1
	ld a,(de)		; get udg 
	xor (hl)		; xor udg on screen
	ld (hl),a		; write on screen
	inc de
	inc hl
	ld a,(de)		; also second position
	xor (hl)
	ld (hl),a
	inc de
	ld a,l
	add a,31		; move to next line on screen
	ld l,a
	jr nc,bdec
	inc h			; next block on screen when needed
bdec
	djnz prudg1 
	ret

;-------------------------------------------------------------------
; calculate screenaddress for XY-pos in BC (optimized in speed)
; Right address = SCREEN + B*32 + INT (C/8)
; B*32 = B/8 where B MOD 8 must be in 3 highbits C

scrad
	srl b		; B / 2
	rr c			; Bit 0 from B in bit 7 C, and C/2
	srl b			; B / 2, now B = B/4
	rr c			; Bit 0 from B in bit 7 C, and C/2, C= C/4
	srl b			; B / 2, now B = B/8
	rr c			; Bit 0 from B in bit 7 C, and C/2, C= C/8
	ld hl,screen	; BC now B*32+ INT (C/8), now we need start of screen too
	add hl,bc		; HL now screenaddress
	ret

;-------------------------------------------------------------------      

hr
    LD   B,7	    ; match hires display with lowres
hr00 DJNZ hr00   

	ld hl,screen-32	; start of hiresscreen (must be NNX0) where X = 0 2 4 8 A C E
	ld de,32		; screen line length  

;-------------------------------------------------------------------
; the hr part          

	ld b,152		; display 176 lines (22 x 8)
	
hr1	
	add hl,de		; next line
	ld a,h			; preset first line to show
	ld i,a			; set highbyte of display (always the same)
	call lbuf+#8000
	
	dec b
	jp nz,hr1
; lowres	
	ld hl,lowres+#8000		; the lowres display          
    ld bc,#420           	; 3 line lowres text          
    ld a,#1E  
    ld i,a    
    ld a,#FB  
    call #2B5       ; show lowres screen   

; fixed end of HR-routine
exit
	call #292   ; back from intrupt           	
	call #220   
	ld   ix,hr  
	jp   #2A4   

lbuf
	ld a,l
	ld r,a
	block 32,0
	ret nc

;-------------------------------------------------------------------

screen 	equ #6000	; somewhere far away in memory 
mycoord db 0,0		; middle of the screen, 128,92

myudg
	db %00011000,0
	db %00101100,0
	db %00111100,0
	db %00011000,0
	db %00111100,0
	db %00101100,0
	db %01011110,0
	db %01111110,0

lowres
	db 118
	db "L"+101,"I"+101,"N"+101,"E"+101,0,"X"+101
	db 118
	db "L"+101,"I"+101,"N"+101,"E"+101,0,"Y"+101		
	db 118
	db "L"+101,"I"+101,"N"+101,"E"+101,0,"Z"+101		
	db 118

	
	; this byte fills the unused part of the screen
	jp (hl)

vars	db 128
last	equ $
demo001.asm
(6.15 KiB) Downloaded 26 times
demo001.p
(349 Bytes) Downloaded 28 times
dr beep
Posts: 2428
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Single pixel motion in high res?

Post by dr beep »

LD A,#FB decrease if you want lowres text to right, increase if text must go left

I have done it in my games too, but I mostly place lowres text on top now.
ChrisB
Posts: 31
Joined: Tue Dec 17, 2024 8:53 am
Location: France

Re: Single pixel motion in high res?

Post by ChrisB »

Thank you,but I mean vertical alignment, see the capture :
Image1.jpg
dr beep
Posts: 2428
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Single pixel motion in high res?

Post by dr beep »

I don’t know what you mean. You do a hires display and then a lowres. There is no vertical allignment.
ChrisB
Posts: 31
Joined: Tue Dec 17, 2024 8:53 am
Location: France

Re: Single pixel motion in high res?

Post by ChrisB »

Sorry if I am not clear.
I want the first line of lowres to be just after the end of hires screen, like this :
but I only get a short black line, a few white lines, and the required text (lines x, y , z)
Image3.jpg
dr beep
Posts: 2428
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Single pixel motion in high res?

Post by dr beep »

I don’t think you can have it so close, but something like this?
IMG_0960.png
dr beep
Posts: 2428
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Single pixel motion in high res?

Post by dr beep »

I think I see your mistake.

You have BC #420, make it #401
Post Reply