FullHD81 - an improved video driver

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

FullHD81 - an improved video driver

Post by zsolt »

Dear All,

In 2011-2012, when I dealt with the BBX81 project (an unfinished host for BBC Basic 80), I planned to realize a "HDready" (320x200 :D ) displaying too. I got similar results as B0D0 Wenzel: 6 hi-res lines (continuous 240 bytes) were in center of a 256 bytes chunk, and there was a big (200x4 = 800 bytes) hi-res stack.
In that 33 (+1) chunks were 528 bytes (33*16) unusable space, what I found too much, and the 800 bytes stack did not fit on code space (the host's maximal size can be about 3K), so the idea was dropped.
TheOldHRstack.gif
TheOldHRstack.gif (14.78 KiB) Viewed 4325 times
Some days (weeks) ago, I found these sketches and I was wondering why I did not apply such solution as in case of the SPONZY. There were little helper routines which radically decreased the stack size. The possibility is given here too.

Step1: we have to change the whole hi-res address just once in a 256 bytes chunk. In the next 5 cases it is enough to change the lower byte only.

Code: Select all

NextLine
	add a,40		; the next line in the 256B chunk
	jp dfe_cont	; continue d-file execution (delay)
dfe_cont
	jp dfe_ldR		; continue d-file execution

	;

;
; ======================================================== the dummy D-FILE
;
df_exec	.equ $+$8000

	pop hl			; get line address
	ld a,h			;
	ld i,a			; set MSB
	ld a,l			;
	;
dfe_ldR	.equ $+$8000

	ld r,a			; set LSB
ddf_data
	.ds 40			; the line buffer

	ret nc			;
;
; ========================================================== HI-RES section
;
HR_stack
	.dw df_exec,Line001
	.dw NextLine,NextLine,NextLine,NextLine, NextLine
	.dw df_exec,Line006
	.dw NextLine,NextLine,NextLine,NextLine,NextLine
	;
	;
	.dw df_exec,Line235
	.dw NextLine,NextLine,NextLine,NextLine,NextLine
	.dw dfe_exit	;  the last return address in the HR_stack
;
;	==================================================== 
;		320x240 pixel hires data (40x256 bytes)
;	==================================================== 
Line001
	; etc
So we have 14 bytes by chunks in the stack (it is originally 24). Counting with 240 lines (40 chunks), the stack size is 560 bytes instead of original 960.

Step2: there are 16 bytes between the 240 bytes parts of hi-res data. Is it possible to insert here that 14 bytes parts of the stack :?: Yes, it is :!: - using an other helper routine, which sets the stack pointer to the next location (and of course the lower byte of the address too).

Code: Select all

NextLine
	add a,40		; the next line in the 256B chunk
	jp dfe_cont	; continue d-file execution (delay)
ChgStack
	ld l,c		; set stack pointer to the end of
	ld sp,hl		; the 6th hires line in the chunk
	ld a,208		; addr. of the 6th hires line
dfe_cont
	jp dfe_ldR		; continue d-file execution

;
; ======================================================== the dummy D-FILE
;
df_exec	.equ $+$8000

	pop hl			; get line address
	ld a,h			;
	ld i,a			; set MSB
	ld a,l			;
	;
dfe_ldR	.equ $+$8000

	ld r,a			; set LSB
ddf_data
	.ds 40			; the line buffer

	ret nc			;
;
; ====================================================== the HI-RES section
;
HR_stack
	.dw df_exec,Line001
	.dw NextLine,NextLine,NextLine,NextLine
	.dw ChgStack
Line001
	.ds 240		; the 6 hi-res lines

	.dw df_exec,Line006
	.dw NextLine,NextLine,NextLine,NextLine
	.dw ChgStack,0
Line006
	.ds 240		; the 6 hi-res lines
	;
	;
	.dw df_exec,Line235
	.dw NextLine,NextLine,NextLine,NextLine
	.dw ChgStack,0
Line235
	.ds 240		; the 6 hi-res lines
	.dw dfe_exit	;  the last return address in the HR_stack
As a result, the hi-res stack is completely moved to the unused space of the expanded h-file.

The attachment contains a little demo (and a tool to create it), which is optimised for tape loading:

- the code is as small (and smart ;) ) as possible;
- it stores the picture (h-file) in unexpanded format (9600 bytes);
- the size of the ".p"-file is less than 10K;

- if the picture contains more black pixels (ones) than whites (zeros), then the ".p"- (and the ".wav")-file will store the inverse of the picture
(this won't affect the tool's other outputs).
TheTool.gif
TheTool.gif (21.37 KiB) Viewed 4325 times
You can calibrate the picture position on the screen using the arrow keys (SHIFT+ 5,6,7,8) - by default it is calibrated for the EightyOne's displaying - and If you press SHIFT+9 together, that inverts the picture :mrgreen: .

Enjoy,
Zsolt

ps.: my test machine is under construction, so feedbacks are welcome
Attachments
FullHD81.zip
(888.89 KiB) Downloaded 261 times
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: FullHD81 - an improved video driver

Post by Andy Rea »

nice work im looking forward to having a little play with this, i really must try to devote more time to the humble zeddy :-)

thanks Andy
what's that Smell.... smells like fresh flux and solder fumes...
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: FullHD81 - an improved video driver

Post by nollkolltroll »

Very nice indeed!
/Adam
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: FullHD81 - an improved video driver

Post by sirmorris »

Kewl!
dr beep
Posts: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: FullHD81 - an improved video driver

Post by dr beep »

Respect,

But I think I can add 8 pixels in width to it, making it 328 pixels.

Stack must however be seperate from datalines, so there is some overflow of data.

Stack needs 4 bytes per 6 lines, but I think I need to think about end of screen after 200 lines.
dr beep
Posts: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: FullHD81 - an improved video driver

Post by dr beep »

Each 6 lines are stored in 256 bytes.
Start at #nn05
Line is 41 bytes in length.
Stack holds next data position, flags and returnaddress per 6 lines

Code: Select all

Nline:
Pop af   ; fetch next highbyte and alter flags
Ld i,a 
Ld a,e ; fixed value 5 set in advance
Lines:
Ld r,a
Defb 41x NOP
Ret nc ; end condition test, to nline on end of datablock
Add A,d ; point to next line, d is set to 41
Cp 210 ; test for final line done in front, flag will be used after display
Ld b,b
Ld b,b ; 2x filler
Jp lines+#8000

dr beep
Posts: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: FullHD81 - an improved video driver

Post by dr beep »

Stack can be set in first 256 bytes, as well as first 2 lines, then 33 blocks of 256 bytes for next 198 lines.
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: FullHD81 - an improved video driver

Post by zsolt »

Hi Dottore, ;)

BRILLIANT solution as always, :D but...

1. My goal was to free up that memory, which was used by the stack, but (if we count with those 200 lines) we lose newer 34x4=136 bytes from memory :shock: and there are (remain) 33x10 = 300 unused/unusable bytes...

2. I don't know how it looks on a real TV. (my zeddy is under construction - maybe this weekend will work again) Is there 8 pixels visible space?

Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
dr beep
Posts: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: FullHD81 - an improved video driver

Post by dr beep »

zsolt wrote:Hi Dottore, ;)

BRILLIANT solution as always, :D but...

1. My goal was to free up that memory, which was used by the stack, but (if we count with those 200 lines) we lose newer 34x4=136 bytes from memory :shock: and there are (remain) 33x10 = 300 unused/unusable bytes...

2. I don't know how it looks on a real TV. (my zeddy is under construction - maybe this weekend will work again) Is there 8 pixels visible space?

Zsolt
As stated. Your job is well done by saving the memory. My goal was to make a wider screen.
When you reduce my code to 320 you can reduce your stack further. Extra memory can be used for variables or short routines,
My goal was to widthen the screen. And yes, I don't know how this will reflect on a real machine. Just my thoughts written down and not tested. Nor do I have the time to do it.

Still a question about your 9600 bytes size. When 6 lines are stored in 256 bytes, then I can store 200 lines in max 34x256=8706 bytes, so where is the rest needed for?
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: FullHD81 - an improved video driver

Post by zsolt »

Still a question about your 9600 bytes size. When 6 lines are stored in 256 bytes, then I can store 200 lines in max 34x256=8706 bytes, so where is the rest needed for?
If you read again the first post, then you see that the unexpanded picture (320x240) requires 9600 bytes.

Btw. there are 2 other problems in your code:

Code: Select all

Cp 210 ; test for final line done in front, flag will be used after display
:
Jp lines+#8000
These 2 instructions use more machine cycles. The 2nd (and the 3rd in case of the jump) is a simple memory read (without /M1+A15), so the CPU will read some other than expected.
Just my thoughts written down ...
And I always really glad to read :D

Regards,
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
Post Reply