Display Codes

Post Reply
User avatar
mz-80a
Posts: 403
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Display Codes

Post by mz-80a »

Here's an interesting question: Why are the display codes in the Display Code Table ordered in the way that they are?

For instance, it would have been nice if Sharp had put the numeric symbols before the alphabetic symbols. That way if you wanted to print the number "5" on the screen you wouldn't have to do any calculations about what display code to use (not that that is difficult), if the display code for the character '5' was just the value '5' it would be useful.

But apart from that.... there's some cool stuff Sharp did. The pseudo-pixel graphic characters found at the end of the table are all represented by a single bit in the least significant bits for that character. The top-left 'dot' is represented by the LSB (least significant bit). Top-right is the next bit (bit 1 if we're counting from 0). Bottom-left 'dot' is the third bit and bottom-right is represented by the 4th bit. So each 'dot' has its own bit. That makes it very easy to turn dots on and off on the display.

I notice also that they have grouped similar symbols together where the most significant 4 bits don't change but only 1 bit in the least significant 4 bits changes.

Also, along those lines, the filled circle and the empty (or unfilled) circle are easily switched between by inverting the bits! Filled circle is 0111 and unfilled circle is 1000.

Any other patterns in there that are useful?
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
https: //mz-sharpworks.co.uk/
User avatar
Pacman
Posts: 172
Joined: Mon Feb 05, 2018 2:59 pm

Re: Display Codes

Post by Pacman »

DISPLAY 1:

Vertical bars:
0x71 -> 0x31 -> 0x75 -> 0x35 -> 0x79 -> 0x39 -> 0x7D -> 0x3D
-0x40 +0x44 -0x40 +0x44 -0x40 +0x44 -0x40

Horizontal bars:
0x70 -> 0x30 -> 0x74 -> 0x34 -> 0x78 -> 0x38 -> 0x7C -> 0x3C
-0x40 +0x44 -0x40 +0x44 -0x40 +0x44 -0x40
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Display Codes

Post by hlide »

Indeed.

From Left/top to right/bottom:

Code: Select all

NEXT_BAR:
		SUB	$40		; A' = (A - $40) MOD 256 
		JR	C,@f		; if A == $7x then A' = $3x and skip the next instruction else A' = $Fx and execute the next instruction   
		ADD	$84		; A'' = $Fx + $84 = $7x' where x' = (x + 4) MOD 16; wrap from $7C/7D to $70/$71. 
	@@:	...
From Right/bottom to left/top:

Code: Select all

NEXT_BAR:
		ADD	$40		; A' = (A + $40) MOD 256 
		JP	P,@f		; if A == $3x then A' = $7x and skip the next instruction else A' = $Bx and execute the next instruction   
		SUB	$84		; A'' = $Bx - $84 = $3x' where x' = (x - 4) MOD 16; wrap from $30/31 to $3C/3D.
	@@:	...
User avatar
Pacman
Posts: 172
Joined: Mon Feb 05, 2018 2:59 pm

Re: Display Codes

Post by Pacman »

There are others in the same style:

Square :
0x72 0x73
0x32 0x33

Complements :
0x3A and 0x7A : +0x40
0x3B and 0x7B : +0x40
0x5B and 0x6C : +0x11

Large circle :

Code: Select all

0x9C 0x9D 0x9E 0x9F
0xB0           0xB3
0xB4           0xB7
0xB8 0xB9 0xBA 0xBB
User avatar
mz-80a
Posts: 403
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: Display Codes

Post by mz-80a »

All very cool! Thanks :)

I guess Sharp put some thought into it.
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
https: //mz-sharpworks.co.uk/
Post Reply