Okay, this reference is targeted at those who want to effectively use advanced things like console screen with CPU.
Intro:
What are hi-speed links? Well, in few words, they allow you to directly access variables/memory of another device, bypassing the regular wire interface. For example, we have the RAM, and we want to write 100 values in it, via CPU. We could connect clock, data, and writeaddress to ports, and write single value. Lets see, it takes at least 2 operations for setting current value, plus the loop, plus the speed of wire system (which limits us). That can be something like 10 seconds. Not much?
Now, we have the hi-speed link. We can access the RAM via the CPU memory. If you connected RAM directly to CPU, then RAM will "live" on top of CPU internal RAM, i.e. starting from address 65536 and further.
Okay, we just write values from 65536 to 65635 (100 values). One instruction per value, and same speed as CPU. You see, copying 100 values here would be 100% equal to copying them into internal CPU RAM.
100 values will be copied instantly (at speed of 5khz for example).
Or you know, you can copy them via the MCOPY opcode, and that will be even faster...
To sum up, hi-speed allows us to gain access to some device just as we were accessing CPU RAM, starting from address 65536.
To use Hi-Speed link system you have to make an i/o link between a device (CPU for example) and another device, just like the regular devices.
For example to connect Console Screen to CPU you will have to connect CPU memory input to console screen memory output with your Wire tool. If destination device has more than one output, its okay to connect to any output. Note that these outputs may act as regular value output too.
We will call the memory of device "device address space"
Lets begin now.
Zyelios CPU
Hi-Speed inputs: MemBus, IOBus
Hi-Speed outputs: Error/Memory
CPU has 2 address spaces: the memory address space and the i/o address space. The only difference between them is that you access the memory space using memory pointers, and i/o space using ports (port0,port234,etc.).
Also, number of ports is limited to 1024, while you can have as much memory as you want.
CPU Memory Space addresses 0..65535 are occupied by internal CPU RAM, the one where program is stored, along with various variables.
By connecting hi-speed device to MemBus input, we link it to addresses 65536, and further. Lets see the example:
We have some device X linked to MemBus input. Lets say device X will print what address it recieves, and what value it recieves when we write to it.
For CPU the memory of our device is situated on addresses starting from 65536.
Lets write to it. Writing 65537 and value 123 will make our device to display "1 - 123". But why?
We wanted address 65537. Device starts from 65536. So that means that we access address 65537-65536 = 1 (remember that addresses start from 0) which is second value.
If you exceed the device address range you will recieve CPU error (memory fault)
IOBus is pretty same, if you would connect the same device X to IOBus input, and output 123 to port4 you will see "4 - 123" (port4 means address 4, again starting from 0)
The only CPU output is hi-speed link to the CPU memory (also thats error value). You can use it as RAM.
RAM
Hi-Speed outputs: Memory/Data
Nothing to add here, it acts like RAM should. You can write/read values from it (notice that toggle/sr latches/etc have only 1 value). Exceeding the limits will result in CPU error.
Address bus
Hi-Speed inputs: Memory1..Memory4
Hi-Speed outputs: Memory
This device is very handy - it can "connect" few address spaces/devices together. What that means? For example we can have device A having memory addresses 0..128, second device will be 256..1023, etc.
You set up offset and size of "block" for each device. If block size wont match to the device address space size, then:
A ) If you read beyond device limits, you will get 0 value (not error)
B ) If device address space is bigger then the size you specified, then the rest after final address will be "cut", and not accessible.
Address spaces can overlap, and in case they do:
A ) When you read, the value will be read from address space with lower number
B ) When you write, the value will be written to all address spaces
Data port
Hi-Speed outputs: Memory (all ports)
This device acts like the ports acted in previous versions of CPU. It has 8 inputs and 8 outputs.
When you write to some address (in range of 0..7) it outputs this value on the related output.
When you read from some address, it returns value of related input.
You can use this to "communicate" with devices which have no hi-speed interface.
Console screen
Hi-Speed outputs: Memory
Console screen has 2 memory areas:
0..1080 - The video memory (what is displayed on screen)
1081..2048 - Internal registers & reserved area.
Format of video memory:
Code:
Content: Character | Parameter | Character | Parameter | ...
Address: 0 1 2 3
Character holds the ASCII code of displayed character.
Parameter holds the parameters of previous character.
Low 3 digits of parameter hold foreground color, encoded in 3-digit RGB (each digit shows shade of red,green,blue respectively)
High 3 digits hold background color. If 7th digit is equal to 1 then this character will flash (background and foreground changing places).
Code:
Address | Meaning
----------------------------------------------
2031 | Low shift column
2032 | High shift column
2033 | Low shift row
2034 | High shift row
2035 | Charset, always 0
2036 | Brightness (-127..127)
2037 | Shift cells * Obsolete *
2038 | Shift rows (number of rows, >0 shift down, <0 shift up)*****
2039 | Clear Row (Written value specifies the row)
2040 | Clear Column (Written value specifies the column)
2041 | Clear Screen
2042 | Background Color*
2043 | Cursor Blink Rate, in seconds
2044 | Cursor Size, in percent**
2045 | Cursor Address
2046 | Cursor Enabled
2047 | Clk****
* - When BG color is 000, it will be replaced with this color.
** - For example 0.25 will mean 1/4 of character height
*** - "Freezes" the image when set to 0
**** - Same as "clk" input
***** - Use this to move portion of image up/down/left/right without speed loss (no need to copy data!)
Digital screen
Hi-Speed outputs: Memory
Pretty much same as console screen, except here each byte is a dual-pixel.
Format of a pixel:
GGG - Value of gray, 0..255
RGB - Color encoded in 3-digit RGB (each digit shows shade of red,green,blue respectively).
Code:
Address | Meaning
----------------------------------------------
2039 | Clear Row (Written value specifies the row)
2040 | Clear Column (Written value specifies the column)
2041 | Clear Screen
2047 | Clk
Keyboard
Hi-Speed outputs: Memory/Key
Keyboard! You push keys, and it reacts! By default it outputs last pressed key to its only output, BUT the only output also serves as hi-speed link..!
Virtual memory area thing of wired keyboard is divided into 2 areas: 1 is the key buffer, and other one is array of pressed keys.
Key buffer is situated at first 32 bytes of keyboard, and it has following structure:
Zeroth byte shows how much keys there are in the buffer. New keys are appended on start.
Writing value to ANY of these 32 bytes except first will clear value you wrote from key buffer. I.e. if our buffer looks like:
4,2,3,4,5
it means that there are 4 variables. If we write "3" to it, it will become:
3,2,4,5
Writing removes most recent entry of key.
Ideally you'd read a key, trigger your event, and write back this code to same position you read it from.
Writing value to first value clears ENTIRE buffer.
There is also other area, which is situated from 32 bytes and up. It is ASCII-mapped array, where for each byte it's value shows if key is pressed or no.
I.e. if we wanna know if key #48 is pressed (thats "0") we look what is at address 32+48. If theres 1, we're off! Else meh, bad luck, key isn't pressed yet.
Bookmarks