translated document of optimized graphics routines
-
- Microbot
- Posts: 148
- Joined: Fri Nov 24, 2017 5:09 pm
- Location: Syracuse, NY, USA
- Contact:
translated document of optimized graphics routines
While learning about different assembler techniques, I occasionally come across various Russian articles. One in particular caught my interest at https://zxpress.ru/article.php?id=5429. The problem using Google translate is the odd wording that be a result of the process. This can occur especially when words are broken and a general result of off translations. Technical terms and slang will also throw off a translation.
So what I have done should be a better translation of the above document to English.
The article is an optimization of some of the code presented in the book - 40 Best Machine Code Routines for the ZX Spectrum by John Hardman and Andrew Hewson .
None of this code is mine and I did not write the article, I'm just doing a translation of the document. I have an Open office document of this as well as a PDF. I have also included a .ASM file that I created with ZX Assembler.
The link is https://1drv.ms/f/s!Atc34t6eCvqj2kRv9PT ... f?e=wefdd9.
I can not make any guarantees on how long Onedrive will keep this link available.
enjoy
Andy Dansby
So what I have done should be a better translation of the above document to English.
The article is an optimization of some of the code presented in the book - 40 Best Machine Code Routines for the ZX Spectrum by John Hardman and Andrew Hewson .
None of this code is mine and I did not write the article, I'm just doing a translation of the document. I have an Open office document of this as well as a PDF. I have also included a .ASM file that I created with ZX Assembler.
The link is https://1drv.ms/f/s!Atc34t6eCvqj2kRv9PT ... f?e=wefdd9.
I can not make any guarantees on how long Onedrive will keep this link available.
enjoy
Andy Dansby
- Einar Saukas
- Bugaboo
- Posts: 3145
- Joined: Wed Nov 15, 2017 2:48 pm
Re: translated document of optimized graphics routines
Good work!
Notice there's still considerable room for improvement in these routines. Not surprising, considering this article was written over 25 years ago...
For instance:
It can be rearranged as follows:
There's no need to spend time copying DE to HL every time when they are already identical (the same mistake happens in most routines).
Also there's no need to reload A every time since it never changes.
Notice there's still considerable room for improvement in these routines. Not surprising, considering this article was written over 25 years ago...
For instance:
Code: Select all
; ;-------------------------------------------
; ;Shift attributes to the right
; ;-------------------------------------------
ASRL_RG:
LD DE,#5AFF ; address of the last attribute byte
LP_ASRG: LD H,D ; ;copied DE to HL -
LD L,E ; last byte of the attribute line
DEC HL ; last byte of the attribute line
LD BC,#001F ; <attribute line length> - 1
LDDR ; shift the attribute line to the right
LD A,(CONSTS) ; fill color after shift
LD (DE),A ; set a new attribute
DEC DE ; go to next line from top
BIT 3,D ; if we are still in attributes,
JR NZ, LP_ASRG ; then we repeat the cycle for the next one. lines
RET ; exit procedure
Code: Select all
; ;-------------------------------------------
; ;Shift attributes to the right
; ;-------------------------------------------
ASRL_RG:
LD A,(CONSTS) ; color to be filled after shift
LD DE,#5AFF ; address of the last attribute byte
LD H,D ; ;copied DE to HL -
LD L,E ; last byte of the attribute line
LP_ASRG: DEC HL ; last byte of the attribute line
LD BC,#001F ; <attribute line length> - 1
LDDR ; shift the attribute line to the right
LD (DE),A ; set a new attribute
DEC DE ; go to next line from top
BIT 3,D ; if we are still in attributes,
JR NZ, LP_ASRG ; then we repeat the cycle for the next one. lines
RET ; exit procedure
Also there's no need to reload A every time since it never changes.
Re: translated document of optimized graphics routines
Maybe just as a curiosity, when asm graphics is mentioned here: In the eighties 3D routines for ZX Spectrum were published in the Czechoslovakian magazine "Amaterske radio" (5 pages).
In the next article, the code was sped up considerably (4 pages).
The third article is about drawing an ellipse (2 pages).
https://sam.speccy.cz/zx/asm_grafika.7z
In the next article, the code was sped up considerably (4 pages).
The third article is about drawing an ellipse (2 pages).
https://sam.speccy.cz/zx/asm_grafika.7z
- Einar Saukas
- Bugaboo
- Posts: 3145
- Joined: Wed Nov 15, 2017 2:48 pm
Re: translated document of optimized graphics routines
There are lots of magazine issues here:
https://worldradiohistory.com/INTERNATI ... e%20Radio/
https://archive.org/search?query=Amaterske+Radio
Do you know when it started to publish any Sinclair-related content? I can add this magazine to ZXDB too, but it doesn't make sense to include all issues since 1952...
https://worldradiohistory.com/INTERNATI ... e%20Radio/
https://archive.org/search?query=Amaterske+Radio
Do you know when it started to publish any Sinclair-related content? I can add this magazine to ZXDB too, but it doesn't make sense to include all issues since 1952...
Re: translated document of optimized graphics routines
I am sure that articles about Sinclair computers have been published since early on. There were two series of the magazine (red and blue series).
There are incomplete lists and searches on the Internet, e.g.
https://petrfaltus.net/petr-faltus-amat ... data-1.php
http://jirky.webz.cz/index.php?page=cas ... 0&w=Hledat
Some of our colleagues here may have a database of all zx-related AR articles in files for Datalog or for Masterfile. I'll look for it and let you know.
There are incomplete lists and searches on the Internet, e.g.
https://petrfaltus.net/petr-faltus-amat ... data-1.php
http://jirky.webz.cz/index.php?page=cas ... 0&w=Hledat
Some of our colleagues here may have a database of all zx-related AR articles in files for Datalog or for Masterfile. I'll look for it and let you know.
- Einar Saukas
- Bugaboo
- Posts: 3145
- Joined: Wed Nov 15, 2017 2:48 pm
Re: translated document of optimized graphics routines
Cause I'm native, if you need some help, I can help to understand slang and poorly scanned words, where instead of Cyrillic letters there are Latin, and vice versa.andydansby wrote: ↑Sat Sep 16, 2023 12:01 pm While learning about different assembler techniques, I occasionally come across various Russian articles. One in particular caught my interest at https://zxpress.ru/article.php?id=5429. The problem using Google translate is the odd wording that be a result of the process.
-
- Microbot
- Posts: 148
- Joined: Fri Nov 24, 2017 5:09 pm
- Location: Syracuse, NY, USA
- Contact:
Re: translated document of optimized graphics routines
It can be a challenge at times. I use ABBYY screenshot reader, paste the results in a word processor, correct any incorrect letters and remove dashes that separate words in half (especially in magazine articles).
I then paste those results in 2-3 translators to get a basic understanding of what is being said and correct the grammar as best as I can.
Slang and some technical references catch me off guard because translators will often screw them up badly like sometimes instead of "Register", it will choose the word "Battery". Translators are often odd at times.
Re: translated document of optimized graphics routines
After you create first automatic translation, send me both rus+eng text, and I can do quick checking. =)andydansby wrote: ↑Sun Sep 17, 2023 1:41 pm Slang and some technical references catch me off guard because translators will often screw them up badly like sometimes instead of "Register", it will choose the word "Battery". Translators are often odd at times.
- flatduckrecords
- Manic Miner
- Posts: 787
- Joined: Thu May 07, 2020 11:47 am
- Location: Oban, Scotland
- Contact:
Re: translated document of optimized graphics routines
Thanks for sharing this!
I’ve actually backed that new edition of the book on Kickstarter (I think they’re doing final proofing now before the print run so hopefully it will be along soon). I’m curious to see what’s been updated and now I’m really curious to compare it with these optimised routines.
I spotted a fun one on page three, “column of familiarity” instead of “character cell”. (I quite like that, though. Might start using it).
I’ve actually backed that new edition of the book on Kickstarter (I think they’re doing final proofing now before the print run so hopefully it will be along soon). I’m curious to see what’s been updated and now I’m really curious to compare it with these optimised routines.
-
- Microbot
- Posts: 148
- Joined: Fri Nov 24, 2017 5:09 pm
- Location: Syracuse, NY, USA
- Contact:
Re: translated document of optimized graphics routines
Good catch.flatduckrecords wrote: ↑Mon Sep 18, 2023 12:59 am Thanks for sharing this!
I spotted a fun one on page three, “column of familiarity” instead of “character cell”. (I quite like that, though. Might start using it).
I’ve actually backed that new edition of the book on Kickstarter (I think they’re doing final proofing now before the print run so hopefully it will be along soon). I’m curious to see what’s been updated and now I’m really curious to compare it with these optimised routines.
I've moved the documents and asm file to
https://github.com/andydansby/zx_spectr ... l_routines. This will allow for easier editing. At some point I'll do a version with @Einar Saukas optimization suggestions. I might even do a Z88dk version for a tester.